Skip to content

Commit

Permalink
Client code now compiling.
Browse files Browse the repository at this point in the history
  • Loading branch information
clemire committed Jul 12, 2024
1 parent ed9ce4e commit 2fa9c8a
Show file tree
Hide file tree
Showing 16 changed files with 194 additions and 53 deletions.
3 changes: 2 additions & 1 deletion contracts/scripts/deployments/DeploySpace.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ contract DeploySpace is DiamondDeployer {
DeployDiamondCut diamondCutHelper = new DeployDiamondCut();
DeployDiamondLoupe diamondLoupeHelper = new DeployDiamondLoupe();
DeployIntrospection introspectionHelper = new DeployIntrospection();
DeployEntitlementGatedV2 entitlementGatedV2Helper = new DeployEntitlementGatedV2();
DeployEntitlementGatedV2 entitlementGatedV2Helper =
new DeployEntitlementGatedV2();
DeployERC721AQueryable erc721aQueryableHelper = new DeployERC721AQueryable();
DeployBanning banningHelper = new DeployBanning();
DeployMembership membershipHelper = new DeployMembership();
Expand Down
4 changes: 4 additions & 0 deletions contracts/src/spaces/entitlements/rule/IRuleEntitlementV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ interface IRuleEntitlementV2 is IEntitlement {
uint256 threshold;
}

struct MockParams {
uint256 threshold;
}

struct LogicalOperation {
LogicalOperationType logOpType;
uint8 leftOperationIndex;
Expand Down
12 changes: 12 additions & 0 deletions contracts/src/spaces/entitlements/rule/RuleDataUtil.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ library RuleDataUtil {
(IRuleEntitlementV2.ERC20Params)
);
v1CheckOp.threshold = v2Params.threshold;
} else if (
v2CheckOp.opType == IRuleEntitlementV2.CheckOperationType.MOCK
) {
IRuleEntitlementV2.MockParams memory v2Params = abi.decode(
v2CheckOp.params,
(IRuleEntitlementV2.MockParams)
);
v1CheckOp.threshold = v2Params.threshold;
} else if (
v2CheckOp.opType == IRuleEntitlementV2.CheckOperationType.ERC1155
) {
Expand Down Expand Up @@ -202,6 +210,10 @@ library RuleDataUtil {
IRuleEntitlementV2.ERC20Params memory v2Params;
v2Params.threshold = v1CheckOp.threshold;
v2CheckOp.params = abi.encode(v2Params);
} else if (v1CheckOp.opType == IRuleEntitlement.CheckOperationType.MOCK) {
IRuleEntitlementV2.MockParams memory v2Params;
v2Params.threshold = v1CheckOp.threshold;
v2CheckOp.params = abi.encode(v2Params);
} else if (
v1CheckOp.opType == IRuleEntitlement.CheckOperationType.ERC1155
) {
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/channelsWithEntitlements.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { makeUserStreamId } from './id'
import { dlog } from '@river-build/dlog'
import {
NoopRuleData,
IRuleEntitlement,
IRuleEntitlementV2,
Permission,
getContractAddress,
publicMint,
Expand All @@ -43,7 +43,7 @@ const log = dlog('csb:test:channelsWithEntitlements')
// pass in users as 'alice', 'bob', 'carol' - b/c their wallets are created here
async function setupChannelWithCustomRole(
userNames: string[],
ruleData: IRuleEntitlement.RuleDataStruct,
ruleData: IRuleEntitlementV2.RuleDataStruct,
permissions: Permission[] = [Permission.Read],
) {
const {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/membershipManagement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { makeBaseChainConfig } from './riverConfig'
const log = dlog('csb:test:membershipManagement')

describe('membershipManagement', () => {
test.only('anoint memberships', async () => {
test('anoint memberships', async () => {
// make a space and mint some memberships for friends

log('start')
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/spaceWithEntitlements.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
getContractAddress,
publicMint,
treeToRuleData,
IRuleEntitlement,
IRuleEntitlementV2,
ISpaceDapp,
} from '@river-build/web3'

Expand All @@ -42,7 +42,7 @@ const log = dlog('csb:test:spaceWithEntitlements')
async function createTownWithRequirements(requirements: {
everyone: boolean
users: string[]
ruleData: IRuleEntitlement.RuleDataStruct
ruleData: IRuleEntitlementV2.RuleDataStruct
}) {
const {
alice,
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
createExternalNFTStruct,
createRiverRegistry,
createSpaceDapp,
IRuleEntitlement,
IRuleEntitlementV2,
Permission,
ISpaceDapp,
IArchitectBase,
Expand Down Expand Up @@ -498,7 +498,7 @@ export function twoNftRuleData(
nft1Address: string,
nft2Address: string,
logOpType: LogicalOperationType.AND | LogicalOperationType.OR = LogicalOperationType.AND,
): IRuleEntitlement.RuleDataStruct {
): IRuleEntitlementV2.RuleDataStruct {
const leftOperation: Operation = {
opType: OperationType.CHECK,
checkType: CheckOperationType.ERC721,
Expand Down Expand Up @@ -680,7 +680,7 @@ export const getFixedPricingModule = (pricingModules: PricingModuleStruct[]) =>
return pricingModules.find((module) => module.name === FIXED_PRICING)
}

export function getNftRuleData(testNftAddress: `0x${string}`): IRuleEntitlement.RuleDataStruct {
export function getNftRuleData(testNftAddress: `0x${string}`): IRuleEntitlementV2.RuleDataStruct {
return createExternalNFTStruct([testNftAddress])
}

Expand All @@ -696,7 +696,7 @@ export async function createRole(
roleName: string,
permissions: Permission[],
users: string[],
ruleData: IRuleEntitlement.RuleDataStruct,
ruleData: IRuleEntitlementV2.RuleDataStruct,
signer: ethers.Signer,
): Promise<CreateRoleContext> {
let txn: ethers.ContractTransaction | undefined = undefined
Expand Down
8 changes: 4 additions & 4 deletions packages/web3/src/ContractTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from './v3/ISpaceArchitectShim'
import { IRolesBase as IRolesBaseV3 } from './v3/IRolesShim'
import { RuleEntitlementShim } from './v3/RuleEntitlementShim'
import { IRuleEntitlement } from './v3'
import { IRuleEntitlementV2 } from './v3'
import { IPricingModulesBase } from './v3/IPricingShim'

export const Permission = {
Expand Down Expand Up @@ -56,7 +56,7 @@ export interface RoleDetails {
name: string
permissions: Permission[]
users: string[]
ruleData: IRuleEntitlement.RuleDataStruct
ruleData: IRuleEntitlementV2.RuleDataStruct
channels: ChannelMetadata[]
}

Expand Down Expand Up @@ -90,15 +90,15 @@ export interface RoleEntitlements {
name: string
permissions: Permission[]
users: string[]
ruleData: IRuleEntitlement.RuleDataStruct
ruleData: IRuleEntitlementV2.RuleDataStruct
}

/*
Decoded Token and User entitlenment details
*/
export interface EntitlementDetails {
users: string[]
ruleData: IRuleEntitlement.RuleDataStruct
ruleData: IRuleEntitlementV2.RuleDataStruct
}

export interface BasicRoleInfo {
Expand Down
4 changes: 2 additions & 2 deletions packages/web3/src/ConvertersEntitlements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ethers } from 'ethers'
import { Address, EntitlementStruct } from './ContractTypes'
import { Hex, decodeAbiParameters, parseAbiParameters } from 'viem'
import { encodeEntitlementData } from './entitlement'
import { IRuleEntitlement } from './v3'
import { IRuleEntitlementV2 } from './v3'

const UserAddressesEncoding = 'address[]'

Expand Down Expand Up @@ -50,7 +50,7 @@ export function createUserEntitlementStruct(

export function createRuleEntitlementStruct(
moduleAddress: `0x${string}`,
ruleData: IRuleEntitlement.RuleDataStruct,
ruleData: IRuleEntitlementV2.RuleDataStruct,
): EntitlementStruct {
const encoded = encodeEntitlementData(ruleData)
return {
Expand Down
4 changes: 2 additions & 2 deletions packages/web3/src/ConvertersRoles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { EntitlementModuleType, Permission, EntitlementStruct } from './Contract
import { createRuleEntitlementStruct, createUserEntitlementStruct } from './ConvertersEntitlements'

import { Space as SpaceV3 } from './v3/Space'
import { IRuleEntitlement } from './v3'
import { IRuleEntitlementV2 } from './v3'

export async function createEntitlementStruct<Space extends SpaceV3>(
spaceIn: Space,
users: string[],
ruleData: IRuleEntitlement.RuleDataStruct,
ruleData: IRuleEntitlementV2.RuleDataStruct,
): Promise<EntitlementStruct[]> {
const space = spaceIn as SpaceV3
// figure out the addresses for each entitlement module
Expand Down
6 changes: 3 additions & 3 deletions packages/web3/src/ISpaceDapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { WalletLink as WalletLinkV3 } from './v3/WalletLink'
import { BigNumber, BytesLike, ContractReceipt, ContractTransaction, ethers } from 'ethers'
import { SpaceInfo } from './types'
import { IRolesBase, Space, SpaceRegistrar, IRuleEntitlement } from './v3'
import { IRolesBase, Space, SpaceRegistrar, IRuleEntitlementV2 } from './v3'
import { PricingModules } from './v3/PricingModules'
import { BaseChainConfig } from './IStaticContractsInfo'
import { PlatformRequirements } from './v3/PlatformRequirements'
Expand Down Expand Up @@ -44,7 +44,7 @@ export interface UpdateRoleParams {
roleName: string
permissions: Permission[]
users: string[]
ruleData: IRuleEntitlement.RuleDataStruct
ruleData: IRuleEntitlementV2.RuleDataStruct
}

export interface TransactionOpts {
Expand Down Expand Up @@ -105,7 +105,7 @@ export interface ISpaceDapp {
roleName: string,
permissions: Permission[],
users: string[],
ruleData: IRuleEntitlement.RuleDataStruct,
ruleData: IRuleEntitlementV2.RuleDataStruct,
signer: SignerType,
txnOpts?: TransactionOpts,
): Promise<TransactionType>
Expand Down
Loading

0 comments on commit 2fa9c8a

Please sign in to comment.