diff --git a/packages/core-sdk/package.json b/packages/core-sdk/package.json index f975cb88..67cf9ce8 100644 --- a/packages/core-sdk/package.json +++ b/packages/core-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@story-protocol/core-sdk", - "version": "1.2.0-rc.0", + "version": "1.2.0-rc.1", "description": "Story Protocol Core SDK", "main": "dist/story-protocol-core-sdk.cjs.js", "module": "dist/story-protocol-core-sdk.esm.js", @@ -31,7 +31,9 @@ "dependencies": { "abitype": "^0.10.2", "axios": "^1.5.1", + "bs58": "^6.0.0", "dotenv": "^16.3.1", + "multiformats": "9.9.0", "viem": "^2.8.12" }, "devDependencies": { diff --git a/packages/core-sdk/src/abi/generated.ts b/packages/core-sdk/src/abi/generated.ts index 1d31e9df..74f608c8 100644 --- a/packages/core-sdk/src/abi/generated.ts +++ b/packages/core-sdk/src/abi/generated.ts @@ -390,7 +390,7 @@ export const accessControllerAbi = [ * */ export const accessControllerAddress = { - 1513: "0xbcaD7EA76Ee68Cc507874e9050a7E7D7ff07BB09", + 1516: "0xf709c8001E94e2ca6F98b7fFBCd5BD3943E46D81", } as const; /** @@ -401,265 +401,6 @@ export const accessControllerConfig = { abi: accessControllerAbi, } as const; -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// ArbitrationPolicySP -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -/** - * - */ -export const arbitrationPolicySpAbi = [ - { - type: "constructor", - inputs: [ - { name: "disputeModule", internalType: "address", type: "address" }, - { name: "paymentToken", internalType: "address", type: "address" }, - { name: "arbitrationPrice", internalType: "uint256", type: "uint256" }, - ], - stateMutability: "nonpayable", - }, - { - type: "error", - inputs: [{ name: "authority", internalType: "address", type: "address" }], - name: "AccessManagedInvalidAuthority", - }, - { - type: "error", - inputs: [ - { name: "caller", internalType: "address", type: "address" }, - { name: "delay", internalType: "uint32", type: "uint32" }, - ], - name: "AccessManagedRequiredDelay", - }, - { - type: "error", - inputs: [{ name: "caller", internalType: "address", type: "address" }], - name: "AccessManagedUnauthorized", - }, - { - type: "error", - inputs: [{ name: "target", internalType: "address", type: "address" }], - name: "AddressEmptyCode", - }, - { - type: "error", - inputs: [{ name: "account", internalType: "address", type: "address" }], - name: "AddressInsufficientBalance", - }, - { type: "error", inputs: [], name: "ArbitrationPolicySP__NotDisputeModule" }, - { type: "error", inputs: [], name: "ArbitrationPolicySP__ZeroAccessManager" }, - { type: "error", inputs: [], name: "ArbitrationPolicySP__ZeroDisputeModule" }, - { type: "error", inputs: [], name: "ArbitrationPolicySP__ZeroPaymentToken" }, - { type: "error", inputs: [], name: "ArbitrationPolicySP__ZeroTreasury" }, - { - type: "error", - inputs: [{ name: "implementation", internalType: "address", type: "address" }], - name: "ERC1967InvalidImplementation", - }, - { type: "error", inputs: [], name: "ERC1967NonPayable" }, - { type: "error", inputs: [], name: "FailedInnerCall" }, - { type: "error", inputs: [], name: "InvalidInitialization" }, - { type: "error", inputs: [], name: "NotInitializing" }, - { - type: "error", - inputs: [{ name: "token", internalType: "address", type: "address" }], - name: "SafeERC20FailedOperation", - }, - { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, - { - type: "error", - inputs: [{ name: "slot", internalType: "bytes32", type: "bytes32" }], - name: "UUPSUnsupportedProxiableUUID", - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "authority", - internalType: "address", - type: "address", - indexed: false, - }, - ], - name: "AuthorityUpdated", - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "version", - internalType: "uint64", - type: "uint64", - indexed: false, - }, - ], - name: "Initialized", - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "implementation", - internalType: "address", - type: "address", - indexed: true, - }, - ], - name: "Upgraded", - }, - { - type: "function", - inputs: [], - name: "ARBITRATION_PRICE", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [], - name: "DISPUTE_MODULE", - outputs: [{ name: "", internalType: "address", type: "address" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [], - name: "PAYMENT_TOKEN", - outputs: [{ name: "", internalType: "address", type: "address" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [], - name: "UPGRADE_INTERFACE_VERSION", - outputs: [{ name: "", internalType: "string", type: "string" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [], - name: "authority", - outputs: [{ name: "", internalType: "address", type: "address" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [ - { name: "accessManager", internalType: "address", type: "address" }, - { name: "newTreasury", internalType: "address", type: "address" }, - ], - name: "initialize", - outputs: [], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [], - name: "isConsumingScheduledOp", - outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [ - { name: "caller", internalType: "address", type: "address" }, - { name: "disputeId", internalType: "uint256", type: "uint256" }, - { name: "data", internalType: "bytes", type: "bytes" }, - ], - name: "onDisputeCancel", - outputs: [], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [ - { name: "disputeId", internalType: "uint256", type: "uint256" }, - { name: "decision", internalType: "bool", type: "bool" }, - { name: "data", internalType: "bytes", type: "bytes" }, - ], - name: "onDisputeJudgement", - outputs: [], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [ - { name: "caller", internalType: "address", type: "address" }, - { name: "data", internalType: "bytes", type: "bytes" }, - ], - name: "onRaiseDispute", - outputs: [], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [ - { name: "caller", internalType: "address", type: "address" }, - { name: "disputeId", internalType: "uint256", type: "uint256" }, - { name: "data", internalType: "bytes", type: "bytes" }, - ], - name: "onResolveDispute", - outputs: [], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [], - name: "proxiableUUID", - outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [{ name: "newAuthority", internalType: "address", type: "address" }], - name: "setAuthority", - outputs: [], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [{ name: "newTreasury", internalType: "address", type: "address" }], - name: "setTreasury", - outputs: [], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [], - name: "treasury", - outputs: [{ name: "", internalType: "address", type: "address" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [ - { name: "newImplementation", internalType: "address", type: "address" }, - { name: "data", internalType: "bytes", type: "bytes" }, - ], - name: "upgradeToAndCall", - outputs: [], - stateMutability: "payable", - }, -] as const; - -/** - * - */ -export const arbitrationPolicySpAddress = { - 1513: "0x8038697357F63415e848785e45B00eB60BcD797b", -} as const; - -/** - * - */ -export const arbitrationPolicySpConfig = { - address: arbitrationPolicySpAddress, - abi: arbitrationPolicySpAbi, -} as const; - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CoreMetadataModule ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -950,7 +691,7 @@ export const coreMetadataModuleAbi = [ * */ export const coreMetadataModuleAddress = { - 1513: "0xa71Bd7aff91Da5E27A6f96c546D489F6e0870E45", + 1516: "0x89630Ccf23277417FBdfd3076C702F5248267e78", } as const; /** @@ -1408,7 +1149,7 @@ export const derivativeWorkflowsAbi = [ * */ export const derivativeWorkflowsAddress = { - 1513: "0xC022C70DA8c23Ae8e36B3de9039Ed24E4E42a127", + 1516: "0xa8815CEB96857FFb8f5F8ce920b1Ae6D70254C7B", } as const; /** @@ -2088,7 +1829,7 @@ export const disputeModuleAbi = [ * */ export const disputeModuleAddress = { - 1513: "0x26525b4A1c2261A27B9ee89D512c2f7DceF85f4a", + 1516: "0x692B47fa72eE7Ac0Ec617ea384a0cAD41098F712", } as const; /** @@ -2438,7 +2179,7 @@ export const evenSplitGroupPoolAbi = [ * */ export const evenSplitGroupPoolAddress = { - 1513: "0xA1dB7AB14900Cd9eF9A7eBA931A206250F403a14", + 1516: "0xC384B56fD62d6679Cd62A2fE0dA3fe4560f33391", } as const; /** @@ -2987,7 +2728,7 @@ export const groupingModuleAbi = [ * */ export const groupingModuleAddress = { - 1513: "0xaB7a16Ad9e46656C59e6071d920feeE7A3416ECf", + 1516: "0xa731948cfE05135ad77d48C71f75066333Da78Bf", } as const; /** @@ -3017,6 +2758,7 @@ export const groupingWorkflowsAbi = [ { name: "licenseRegistry", internalType: "address", type: "address" }, { name: "licensingModule", internalType: "address", type: "address" }, { name: "pilTemplate", internalType: "address", type: "address" }, + { name: "royaltyModule", internalType: "address", type: "address" }, ], stateMutability: "nonpayable", }, @@ -3167,6 +2909,13 @@ export const groupingWorkflowsAbi = [ ], stateMutability: "view", }, + { + type: "function", + inputs: [], + name: "ROYALTY_MODULE", + outputs: [{ name: "", internalType: "contract RoyaltyModule", type: "address" }], + stateMutability: "view", + }, { type: "function", inputs: [], @@ -3184,7 +2933,7 @@ export const groupingWorkflowsAbi = [ { type: "function", inputs: [ - { name: "groupId", internalType: "address", type: "address" }, + { name: "groupIpId", internalType: "address", type: "address" }, { name: "currencyTokens", internalType: "address[]", type: "address[]" }, { name: "groupSnapshotIds", @@ -3371,7 +3120,7 @@ export const groupingWorkflowsAbi = [ * */ export const groupingWorkflowsAddress = { - 1513: "0x426fF4F7E9Debe565F5Fe6F53334Ad3982295E20", + 1516: "0xcd754994eBE5Ce16D432C1f936f98ac0d4aABA0e", } as const; /** @@ -3795,7 +3544,7 @@ export const ipAccountImplAbi = [ * */ export const ipAccountImplAddress = { - 1513: "0xaE2D8F01920DB2328BEd676652154c9D2Cb863fa", + 1516: "0x24F08796561d6E1AC08e82b68BF4d9500B374Af6", } as const; /** @@ -3846,6 +3595,11 @@ export const ipAssetRegistryAbi = [ inputs: [{ name: "target", internalType: "address", type: "address" }], name: "AddressEmptyCode", }, + { + type: "error", + inputs: [{ name: "account", internalType: "address", type: "address" }], + name: "AddressInsufficientBalance", + }, { type: "error", inputs: [{ name: "implementation", internalType: "address", type: "address" }], @@ -3902,8 +3656,18 @@ export const ipAssetRegistryAbi = [ name: "IPAssetRegistry__UnsupportedIERC721Metadata", }, { type: "error", inputs: [], name: "IPAssetRegistry__ZeroAccessManager" }, + { + type: "error", + inputs: [{ name: "name", internalType: "string", type: "string" }], + name: "IPAssetRegistry__ZeroAddress", + }, { type: "error", inputs: [], name: "InvalidInitialization" }, { type: "error", inputs: [], name: "NotInitializing" }, + { + type: "error", + inputs: [{ name: "token", internalType: "address", type: "address" }], + name: "SafeERC20FailedOperation", + }, { type: "error", inputs: [ @@ -4007,6 +3771,37 @@ export const ipAssetRegistryAbi = [ ], name: "IPRegistered", }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "payer", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "treasury", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "feeToken", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "amount", + internalType: "uint96", + type: "uint96", + indexed: false, + }, + ], + name: "IPRegistrationFeePaid", + }, { type: "event", anonymous: false, @@ -4033,6 +3828,31 @@ export const ipAssetRegistryAbi = [ ], name: "Paused", }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "treasury", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "feeToken", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "feeAmount", + internalType: "uint96", + type: "uint96", + indexed: false, + }, + ], + name: "RegistrationFeeSet", + }, { type: "event", anonymous: false, @@ -4128,6 +3948,20 @@ export const ipAssetRegistryAbi = [ outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "view", }, + { + type: "function", + inputs: [], + name: "getFeeAmount", + outputs: [{ name: "", internalType: "uint96", type: "uint96" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "getFeeToken", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, { type: "function", inputs: [ @@ -4153,6 +3987,13 @@ export const ipAssetRegistryAbi = [ outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, + { + type: "function", + inputs: [], + name: "getTreasury", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, { type: "function", inputs: [{ name: "accessManager", internalType: "address", type: "address" }], @@ -4270,6 +4111,17 @@ export const ipAssetRegistryAbi = [ outputs: [], stateMutability: "nonpayable", }, + { + type: "function", + inputs: [ + { name: "treasury", internalType: "address", type: "address" }, + { name: "feeToken", internalType: "address", type: "address" }, + { name: "feeAmount", internalType: "uint96", type: "uint96" }, + ], + name: "setRegistrationFee", + outputs: [], + stateMutability: "nonpayable", + }, { type: "function", inputs: [{ name: "groupId", internalType: "address", type: "address" }], @@ -4314,7 +4166,7 @@ export const ipAssetRegistryAbi = [ * */ export const ipAssetRegistryAddress = { - 1513: "0x14CAB45705Fe73EC6d126518E59Fe3C61a181E40", + 1516: "0x28E59E91C0467e89fd0f0438D47Ca839cDfEc095", } as const; /** @@ -4769,7 +4621,7 @@ export const ipRoyaltyVaultImplAbi = [ * */ export const ipRoyaltyVaultImplAddress = { - 1513: "0x604dc8E58f720DEB345B2F3e08B2B354eA6CE498", + 1516: "0x1081250219B16cc3903Aa2d2d1403A75c6A2F9f5", } as const; /** @@ -5259,7 +5111,7 @@ export const licenseAttachmentWorkflowsAbi = [ * */ export const licenseAttachmentWorkflowsAddress = { - 1513: "0x1B95144b62B4566501482e928aa435Dd205fE71B", + 1516: "0x44Bad1E4035a44eAC1606B222873E4a85E8b7D9c", } as const; /** @@ -5284,7 +5136,6 @@ export const licenseRegistryAbi = [ { name: "licensingModule", internalType: "address", type: "address" }, { name: "disputeModule", internalType: "address", type: "address" }, { name: "ipGraphAcl", internalType: "address", type: "address" }, - { name: "ipGraph", internalType: "address", type: "address" }, ], stateMutability: "nonpayable", }, @@ -5962,7 +5813,7 @@ export const licenseRegistryAbi = [ * */ export const licenseRegistryAddress = { - 1513: "0x4D71a082DE74B40904c1d89d9C3bfB7079d4c542", + 1516: "0xBda3992c49E98392e75E78d82B934F3598bA495f", } as const; /** @@ -6583,7 +6434,7 @@ export const licenseTokenAbi = [ * */ export const licenseTokenAddress = { - 1513: "0xd8aEF404432a2b3363479A6157285926B6B3b743", + 1516: "0xB138aEd64814F2845554f9DBB116491a077eEB2D", } as const; /** @@ -7147,7 +6998,7 @@ export const licensingModuleAbi = [ * */ export const licensingModuleAddress = { - 1513: "0xC8f165950411504eA130692B87A7148e469f7090", + 1516: "0x5a7D9Fa17DE09350F481A53B470D798c1c1aabae", } as const; /** @@ -7347,7 +7198,7 @@ export const mockErc20Abi = [ * */ export const mockErc20Address = { - 1513: "0x91f6F05B08c16769d3c85867548615d270C42fC7", + 1516: "0x12A8b0DcC6e3bB0915638361D9D49942Da07F455", } as const; /** @@ -7652,7 +7503,7 @@ export const moduleRegistryAbi = [ * */ export const moduleRegistryAddress = { - 1513: "0x47bEae573B73F8BF1B4fa4Af065c39743871003f", + 1516: "0x9F18c5723BC4Ee447CF9B01a8543D3b08b7F09C7", } as const; /** @@ -8338,7 +8189,7 @@ export const piLicenseTemplateAbi = [ * */ export const piLicenseTemplateAddress = { - 1513: "0xbB7ACFBE330C56aA9a3aEb84870743C3566992c3", + 1516: "0x58E2c909D557Cd23EF90D14f8fd21667A5Ae7a93", } as const; /** @@ -8689,7 +8540,7 @@ export const registrationWorkflowsAbi = [ * */ export const registrationWorkflowsAddress = { - 1513: "0xF403fcCAAE6C503D0CC1D25904A0B2cCd5B96C6F", + 1516: "0xde13Be395E1cd753471447Cf6A656979ef87881c", } as const; /** @@ -8715,7 +8566,6 @@ export const royaltyModuleAbi = [ { name: "disputeModule", internalType: "address", type: "address" }, { name: "licenseRegistry", internalType: "address", type: "address" }, { name: "ipAssetRegistry", internalType: "address", type: "address" }, - { name: "ipGraph", internalType: "address", type: "address" }, ], stateMutability: "nonpayable", }, @@ -9580,7 +9430,7 @@ export const royaltyModuleAbi = [ * */ export const royaltyModuleAddress = { - 1513: "0xaCb5764E609aa3a5ED36bA74ba59679246Cb0963", + 1516: "0xEa6eD700b11DfF703665CCAF55887ca56134Ae3B", } as const; /** @@ -9604,7 +9454,6 @@ export const royaltyPolicyLapAbi = [ inputs: [ { name: "royaltyModule", internalType: "address", type: "address" }, { name: "ipGraphAcl", internalType: "address", type: "address" }, - { name: "ipGraph", internalType: "address", type: "address" }, ], stateMutability: "nonpayable", }, @@ -9952,7 +9801,7 @@ export const royaltyPolicyLapAbi = [ * */ export const royaltyPolicyLapAddress = { - 1513: "0x793Df8d32c12B0bE9985FFF6afB8893d347B6686", + 1516: "0x28b4F70ffE5ba7A26aEF979226f77Eb57fb9Fdb6", } as const; /** @@ -9976,7 +9825,6 @@ export const royaltyPolicyLrpAbi = [ inputs: [ { name: "royaltyModule", internalType: "address", type: "address" }, { name: "ipGraphAcl", internalType: "address", type: "address" }, - { name: "ipGraph", internalType: "address", type: "address" }, ], stateMutability: "nonpayable", }, @@ -10324,7 +10172,7 @@ export const royaltyPolicyLrpAbi = [ * */ export const royaltyPolicyLrpAddress = { - 1513: "0x1eF035c7054bd45e25B2a29A06a37b1350F50596", + 1516: "0x7D2d9af4E4ab14Afcfd86436BC348928B40963Dd", } as const; /** @@ -10584,7 +10432,7 @@ export const royaltyWorkflowsAbi = [ * */ export const royaltyWorkflowsAddress = { - 1513: "0xc757921ee0f7c8E935d44BFBDc2602786e0eda6C", + 1516: "0xAf922379B8e1abc6B0D78547128579221C7F7A22", } as const; /** @@ -10699,7 +10547,7 @@ export const spgnftBeaconAbi = [ * */ export const spgnftBeaconAddress = { - 1513: "0x02324ca8f369abB445F50c4cE79e956e49AC75d8", + 1516: "0x4b913A9da52806A0fd0b031bdf32fa33634d082a", } as const; /** @@ -10865,6 +10713,7 @@ export const spgnftImplAbi = [ ], name: "BatchMetadataUpdate", }, + { type: "event", anonymous: false, inputs: [], name: "ContractURIUpdated" }, { type: "event", anonymous: false, @@ -11025,6 +10874,13 @@ export const spgnftImplAbi = [ outputs: [{ name: "", internalType: "string", type: "string" }], stateMutability: "view", }, + { + type: "function", + inputs: [], + name: "contractURI", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", + }, { type: "function", inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], @@ -11070,6 +10926,7 @@ export const spgnftImplAbi = [ { name: "name", internalType: "string", type: "string" }, { name: "symbol", internalType: "string", type: "string" }, { name: "baseURI", internalType: "string", type: "string" }, + { name: "contractURI", internalType: "string", type: "string" }, { name: "maxSupply", internalType: "uint32", type: "uint32" }, { name: "mintFee", internalType: "uint256", type: "uint256" }, { name: "mintFeeToken", internalType: "address", type: "address" }, @@ -11228,6 +11085,13 @@ export const spgnftImplAbi = [ outputs: [], stateMutability: "nonpayable", }, + { + type: "function", + inputs: [{ name: "contractURI", internalType: "string", type: "string" }], + name: "setContractURI", + outputs: [], + stateMutability: "nonpayable", + }, { type: "function", inputs: [{ name: "fee", internalType: "uint256", type: "uint256" }], @@ -11315,7 +11179,7 @@ export const spgnftImplAbi = [ * */ export const spgnftImplAddress = { - 1513: "0xC8E4376Da033cE244027B03f9b94dc0d7005D67E", + 1516: "0x32c03CD2B4CC3456aCD86C7d5BA8E0405665DbF9", } as const; /** @@ -11415,879 +11279,181 @@ export type AccessControllerSetPermissionRequest = { ipAccount: Address; signer: Address; to: Address; - func: Hex; - permission: number; -}; - -/** - * contract AccessController event - */ -export class AccessControllerEventClient { - protected readonly rpcClient: PublicClient; - public readonly address: Address; - - constructor(rpcClient: PublicClient, address?: Address) { - this.address = address || getAddress(accessControllerAddress, rpcClient.chain?.id); - this.rpcClient = rpcClient; - } - - /** - * event PermissionSet for contract AccessController - */ - public watchPermissionSetEvent( - onLogs: (txHash: Hex, ev: Partial) => void, - ): WatchContractEventReturnType { - return this.rpcClient.watchContractEvent({ - abi: accessControllerAbi, - address: this.address, - eventName: "PermissionSet", - onLogs: (evs) => { - evs.forEach((it) => onLogs(it.transactionHash, it.args)); - }, - }); - } - - /** - * parse tx receipt event PermissionSet for contract AccessController - */ - public parseTxPermissionSetEvent( - txReceipt: TransactionReceipt, - ): Array { - const targetLogs: Array = []; - for (const log of txReceipt.logs) { - try { - const event = decodeEventLog({ - abi: accessControllerAbi, - eventName: "PermissionSet", - data: log.data, - topics: log.topics, - }); - if (event.eventName === "PermissionSet") { - targetLogs.push(event.args); - } - } catch (e) { - /* empty */ - } - } - return targetLogs; - } -} - -/** - * contract AccessController write method - */ -export class AccessControllerClient extends AccessControllerEventClient { - protected readonly wallet: SimpleWalletClient; - - constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { - super(rpcClient, address); - this.wallet = wallet; - } - - /** - * method setAllPermissions for contract AccessController - * - * @param request AccessControllerSetAllPermissionsRequest - * @return Promise - */ - public async setAllPermissions( - request: AccessControllerSetAllPermissionsRequest, - ): Promise { - const { request: call } = await this.rpcClient.simulateContract({ - abi: accessControllerAbi, - address: this.address, - functionName: "setAllPermissions", - account: this.wallet.account, - args: [request.ipAccount, request.signer, request.permission], - }); - return await this.wallet.writeContract(call as WriteContractParameters); - } - - /** - * method setAllPermissions for contract AccessController with only encode - * - * @param request AccessControllerSetAllPermissionsRequest - * @return EncodedTxData - */ - public setAllPermissionsEncode(request: AccessControllerSetAllPermissionsRequest): EncodedTxData { - return { - to: this.address, - data: encodeFunctionData({ - abi: accessControllerAbi, - functionName: "setAllPermissions", - args: [request.ipAccount, request.signer, request.permission], - }), - }; - } - - /** - * method setBatchPermissions for contract AccessController - * - * @param request AccessControllerSetBatchPermissionsRequest - * @return Promise - */ - public async setBatchPermissions( - request: AccessControllerSetBatchPermissionsRequest, - ): Promise { - const { request: call } = await this.rpcClient.simulateContract({ - abi: accessControllerAbi, - address: this.address, - functionName: "setBatchPermissions", - account: this.wallet.account, - args: [request.permissions], - }); - return await this.wallet.writeContract(call as WriteContractParameters); - } - - /** - * method setBatchPermissions for contract AccessController with only encode - * - * @param request AccessControllerSetBatchPermissionsRequest - * @return EncodedTxData - */ - public setBatchPermissionsEncode( - request: AccessControllerSetBatchPermissionsRequest, - ): EncodedTxData { - return { - to: this.address, - data: encodeFunctionData({ - abi: accessControllerAbi, - functionName: "setBatchPermissions", - args: [request.permissions], - }), - }; - } - - /** - * method setPermission for contract AccessController - * - * @param request AccessControllerSetPermissionRequest - * @return Promise - */ - public async setPermission( - request: AccessControllerSetPermissionRequest, - ): Promise { - const { request: call } = await this.rpcClient.simulateContract({ - abi: accessControllerAbi, - address: this.address, - functionName: "setPermission", - account: this.wallet.account, - args: [request.ipAccount, request.signer, request.to, request.func, request.permission], - }); - return await this.wallet.writeContract(call as WriteContractParameters); - } - - /** - * method setPermission for contract AccessController with only encode - * - * @param request AccessControllerSetPermissionRequest - * @return EncodedTxData - */ - public setPermissionEncode(request: AccessControllerSetPermissionRequest): EncodedTxData { - return { - to: this.address, - data: encodeFunctionData({ - abi: accessControllerAbi, - functionName: "setPermission", - args: [request.ipAccount, request.signer, request.to, request.func, request.permission], - }), - }; - } -} - -// Contract ArbitrationPolicySP ============================================================= - -/** - * ArbitrationPolicySpAuthorityUpdatedEvent - * - * @param authority address - */ -export type ArbitrationPolicySpAuthorityUpdatedEvent = { - authority: Address; -}; - -/** - * ArbitrationPolicySpInitializedEvent - * - * @param version uint64 - */ -export type ArbitrationPolicySpInitializedEvent = { - version: bigint; -}; - -/** - * ArbitrationPolicySpUpgradedEvent - * - * @param implementation address - */ -export type ArbitrationPolicySpUpgradedEvent = { - implementation: Address; -}; - -export type ArbitrationPolicySpArbitrationPriceResponse = bigint; - -export type ArbitrationPolicySpDisputeModuleResponse = Address; - -export type ArbitrationPolicySpPaymentTokenResponse = Address; - -export type ArbitrationPolicySpUpgradeInterfaceVersionResponse = string; - -export type ArbitrationPolicySpAuthorityResponse = Address; - -export type ArbitrationPolicySpIsConsumingScheduledOpResponse = Hex; - -export type ArbitrationPolicySpProxiableUuidResponse = Hex; - -export type ArbitrationPolicySpTreasuryResponse = Address; - -/** - * ArbitrationPolicySpInitializeRequest - * - * @param accessManager address - * @param newTreasury address - */ -export type ArbitrationPolicySpInitializeRequest = { - accessManager: Address; - newTreasury: Address; -}; - -/** - * ArbitrationPolicySpOnDisputeCancelRequest - * - * @param caller address - * @param disputeId uint256 - * @param data bytes - */ -export type ArbitrationPolicySpOnDisputeCancelRequest = { - caller: Address; - disputeId: bigint; - data: Hex; -}; - -/** - * ArbitrationPolicySpOnDisputeJudgementRequest - * - * @param disputeId uint256 - * @param decision bool - * @param data bytes - */ -export type ArbitrationPolicySpOnDisputeJudgementRequest = { - disputeId: bigint; - decision: boolean; - data: Hex; -}; - -/** - * ArbitrationPolicySpOnRaiseDisputeRequest - * - * @param caller address - * @param data bytes - */ -export type ArbitrationPolicySpOnRaiseDisputeRequest = { - caller: Address; - data: Hex; -}; - -/** - * ArbitrationPolicySpOnResolveDisputeRequest - * - * @param caller address - * @param disputeId uint256 - * @param data bytes - */ -export type ArbitrationPolicySpOnResolveDisputeRequest = { - caller: Address; - disputeId: bigint; - data: Hex; -}; - -/** - * ArbitrationPolicySpSetAuthorityRequest - * - * @param newAuthority address - */ -export type ArbitrationPolicySpSetAuthorityRequest = { - newAuthority: Address; -}; - -/** - * ArbitrationPolicySpSetTreasuryRequest - * - * @param newTreasury address - */ -export type ArbitrationPolicySpSetTreasuryRequest = { - newTreasury: Address; -}; - -/** - * ArbitrationPolicySpUpgradeToAndCallRequest - * - * @param newImplementation address - * @param data bytes - */ -export type ArbitrationPolicySpUpgradeToAndCallRequest = { - newImplementation: Address; - data: Hex; -}; - -/** - * contract ArbitrationPolicySP event - */ -export class ArbitrationPolicySpEventClient { - protected readonly rpcClient: PublicClient; - public readonly address: Address; - - constructor(rpcClient: PublicClient, address?: Address) { - this.address = address || getAddress(arbitrationPolicySpAddress, rpcClient.chain?.id); - this.rpcClient = rpcClient; - } - - /** - * event AuthorityUpdated for contract ArbitrationPolicySP - */ - public watchAuthorityUpdatedEvent( - onLogs: (txHash: Hex, ev: Partial) => void, - ): WatchContractEventReturnType { - return this.rpcClient.watchContractEvent({ - abi: arbitrationPolicySpAbi, - address: this.address, - eventName: "AuthorityUpdated", - onLogs: (evs) => { - evs.forEach((it) => onLogs(it.transactionHash, it.args)); - }, - }); - } - - /** - * parse tx receipt event AuthorityUpdated for contract ArbitrationPolicySP - */ - public parseTxAuthorityUpdatedEvent( - txReceipt: TransactionReceipt, - ): Array { - const targetLogs: Array = []; - for (const log of txReceipt.logs) { - try { - const event = decodeEventLog({ - abi: arbitrationPolicySpAbi, - eventName: "AuthorityUpdated", - data: log.data, - topics: log.topics, - }); - if (event.eventName === "AuthorityUpdated") { - targetLogs.push(event.args); - } - } catch (e) { - /* empty */ - } - } - return targetLogs; - } - - /** - * event Initialized for contract ArbitrationPolicySP - */ - public watchInitializedEvent( - onLogs: (txHash: Hex, ev: Partial) => void, - ): WatchContractEventReturnType { - return this.rpcClient.watchContractEvent({ - abi: arbitrationPolicySpAbi, - address: this.address, - eventName: "Initialized", - onLogs: (evs) => { - evs.forEach((it) => onLogs(it.transactionHash, it.args)); - }, - }); - } - - /** - * parse tx receipt event Initialized for contract ArbitrationPolicySP - */ - public parseTxInitializedEvent( - txReceipt: TransactionReceipt, - ): Array { - const targetLogs: Array = []; - for (const log of txReceipt.logs) { - try { - const event = decodeEventLog({ - abi: arbitrationPolicySpAbi, - eventName: "Initialized", - data: log.data, - topics: log.topics, - }); - if (event.eventName === "Initialized") { - targetLogs.push(event.args); - } - } catch (e) { - /* empty */ - } - } - return targetLogs; - } - - /** - * event Upgraded for contract ArbitrationPolicySP - */ - public watchUpgradedEvent( - onLogs: (txHash: Hex, ev: Partial) => void, - ): WatchContractEventReturnType { - return this.rpcClient.watchContractEvent({ - abi: arbitrationPolicySpAbi, - address: this.address, - eventName: "Upgraded", - onLogs: (evs) => { - evs.forEach((it) => onLogs(it.transactionHash, it.args)); - }, - }); - } - - /** - * parse tx receipt event Upgraded for contract ArbitrationPolicySP - */ - public parseTxUpgradedEvent( - txReceipt: TransactionReceipt, - ): Array { - const targetLogs: Array = []; - for (const log of txReceipt.logs) { - try { - const event = decodeEventLog({ - abi: arbitrationPolicySpAbi, - eventName: "Upgraded", - data: log.data, - topics: log.topics, - }); - if (event.eventName === "Upgraded") { - targetLogs.push(event.args); - } - } catch (e) { - /* empty */ - } - } - return targetLogs; - } -} - -/** - * contract ArbitrationPolicySP readonly method - */ -export class ArbitrationPolicySpReadOnlyClient extends ArbitrationPolicySpEventClient { - constructor(rpcClient: PublicClient, address?: Address) { - super(rpcClient, address); - } - - /** - * method ARBITRATION_PRICE for contract ArbitrationPolicySP - * - * @param request ArbitrationPolicySpArbitrationPriceRequest - * @return Promise - */ - public async arbitrationPrice(): Promise { - return await this.rpcClient.readContract({ - abi: arbitrationPolicySpAbi, - address: this.address, - functionName: "ARBITRATION_PRICE", - }); - } - - /** - * method DISPUTE_MODULE for contract ArbitrationPolicySP - * - * @param request ArbitrationPolicySpDisputeModuleRequest - * @return Promise - */ - public async disputeModule(): Promise { - return await this.rpcClient.readContract({ - abi: arbitrationPolicySpAbi, - address: this.address, - functionName: "DISPUTE_MODULE", - }); - } - - /** - * method PAYMENT_TOKEN for contract ArbitrationPolicySP - * - * @param request ArbitrationPolicySpPaymentTokenRequest - * @return Promise - */ - public async paymentToken(): Promise { - return await this.rpcClient.readContract({ - abi: arbitrationPolicySpAbi, - address: this.address, - functionName: "PAYMENT_TOKEN", - }); - } - - /** - * method UPGRADE_INTERFACE_VERSION for contract ArbitrationPolicySP - * - * @param request ArbitrationPolicySpUpgradeInterfaceVersionRequest - * @return Promise - */ - public async upgradeInterfaceVersion(): Promise { - return await this.rpcClient.readContract({ - abi: arbitrationPolicySpAbi, - address: this.address, - functionName: "UPGRADE_INTERFACE_VERSION", - }); - } - - /** - * method authority for contract ArbitrationPolicySP - * - * @param request ArbitrationPolicySpAuthorityRequest - * @return Promise - */ - public async authority(): Promise { - return await this.rpcClient.readContract({ - abi: arbitrationPolicySpAbi, - address: this.address, - functionName: "authority", - }); - } - - /** - * method isConsumingScheduledOp for contract ArbitrationPolicySP - * - * @param request ArbitrationPolicySpIsConsumingScheduledOpRequest - * @return Promise - */ - public async isConsumingScheduledOp(): Promise { - return await this.rpcClient.readContract({ - abi: arbitrationPolicySpAbi, - address: this.address, - functionName: "isConsumingScheduledOp", - }); - } - - /** - * method proxiableUUID for contract ArbitrationPolicySP - * - * @param request ArbitrationPolicySpProxiableUuidRequest - * @return Promise - */ - public async proxiableUuid(): Promise { - return await this.rpcClient.readContract({ - abi: arbitrationPolicySpAbi, - address: this.address, - functionName: "proxiableUUID", - }); - } - - /** - * method treasury for contract ArbitrationPolicySP - * - * @param request ArbitrationPolicySpTreasuryRequest - * @return Promise - */ - public async treasury(): Promise { - return await this.rpcClient.readContract({ - abi: arbitrationPolicySpAbi, - address: this.address, - functionName: "treasury", - }); - } -} - -/** - * contract ArbitrationPolicySP write method - */ -export class ArbitrationPolicySpClient extends ArbitrationPolicySpReadOnlyClient { - protected readonly wallet: SimpleWalletClient; - - constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { - super(rpcClient, address); - this.wallet = wallet; - } - - /** - * method initialize for contract ArbitrationPolicySP - * - * @param request ArbitrationPolicySpInitializeRequest - * @return Promise - */ - public async initialize( - request: ArbitrationPolicySpInitializeRequest, - ): Promise { - const { request: call } = await this.rpcClient.simulateContract({ - abi: arbitrationPolicySpAbi, - address: this.address, - functionName: "initialize", - account: this.wallet.account, - args: [request.accessManager, request.newTreasury], - }); - return await this.wallet.writeContract(call as WriteContractParameters); - } - - /** - * method initialize for contract ArbitrationPolicySP with only encode - * - * @param request ArbitrationPolicySpInitializeRequest - * @return EncodedTxData - */ - public initializeEncode(request: ArbitrationPolicySpInitializeRequest): EncodedTxData { - return { - to: this.address, - data: encodeFunctionData({ - abi: arbitrationPolicySpAbi, - functionName: "initialize", - args: [request.accessManager, request.newTreasury], - }), - }; - } - - /** - * method onDisputeCancel for contract ArbitrationPolicySP - * - * @param request ArbitrationPolicySpOnDisputeCancelRequest - * @return Promise - */ - public async onDisputeCancel( - request: ArbitrationPolicySpOnDisputeCancelRequest, - ): Promise { - const { request: call } = await this.rpcClient.simulateContract({ - abi: arbitrationPolicySpAbi, - address: this.address, - functionName: "onDisputeCancel", - account: this.wallet.account, - args: [request.caller, request.disputeId, request.data], - }); - return await this.wallet.writeContract(call as WriteContractParameters); - } - - /** - * method onDisputeCancel for contract ArbitrationPolicySP with only encode - * - * @param request ArbitrationPolicySpOnDisputeCancelRequest - * @return EncodedTxData - */ - public onDisputeCancelEncode(request: ArbitrationPolicySpOnDisputeCancelRequest): EncodedTxData { - return { - to: this.address, - data: encodeFunctionData({ - abi: arbitrationPolicySpAbi, - functionName: "onDisputeCancel", - args: [request.caller, request.disputeId, request.data], - }), - }; - } + func: Hex; + permission: number; +}; - /** - * method onDisputeJudgement for contract ArbitrationPolicySP - * - * @param request ArbitrationPolicySpOnDisputeJudgementRequest - * @return Promise - */ - public async onDisputeJudgement( - request: ArbitrationPolicySpOnDisputeJudgementRequest, - ): Promise { - const { request: call } = await this.rpcClient.simulateContract({ - abi: arbitrationPolicySpAbi, - address: this.address, - functionName: "onDisputeJudgement", - account: this.wallet.account, - args: [request.disputeId, request.decision, request.data], - }); - return await this.wallet.writeContract(call as WriteContractParameters); - } +/** + * contract AccessController event + */ +export class AccessControllerEventClient { + protected readonly rpcClient: PublicClient; + public readonly address: Address; - /** - * method onDisputeJudgement for contract ArbitrationPolicySP with only encode - * - * @param request ArbitrationPolicySpOnDisputeJudgementRequest - * @return EncodedTxData - */ - public onDisputeJudgementEncode( - request: ArbitrationPolicySpOnDisputeJudgementRequest, - ): EncodedTxData { - return { - to: this.address, - data: encodeFunctionData({ - abi: arbitrationPolicySpAbi, - functionName: "onDisputeJudgement", - args: [request.disputeId, request.decision, request.data], - }), - }; + constructor(rpcClient: PublicClient, address?: Address) { + this.address = address || getAddress(accessControllerAddress, rpcClient.chain?.id); + this.rpcClient = rpcClient; } /** - * method onRaiseDispute for contract ArbitrationPolicySP - * - * @param request ArbitrationPolicySpOnRaiseDisputeRequest - * @return Promise + * event PermissionSet for contract AccessController */ - public async onRaiseDispute( - request: ArbitrationPolicySpOnRaiseDisputeRequest, - ): Promise { - const { request: call } = await this.rpcClient.simulateContract({ - abi: arbitrationPolicySpAbi, + public watchPermissionSetEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: accessControllerAbi, address: this.address, - functionName: "onRaiseDispute", - account: this.wallet.account, - args: [request.caller, request.data], + eventName: "PermissionSet", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, }); - return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method onRaiseDispute for contract ArbitrationPolicySP with only encode - * - * @param request ArbitrationPolicySpOnRaiseDisputeRequest - * @return EncodedTxData + * parse tx receipt event PermissionSet for contract AccessController */ - public onRaiseDisputeEncode(request: ArbitrationPolicySpOnRaiseDisputeRequest): EncodedTxData { - return { - to: this.address, - data: encodeFunctionData({ - abi: arbitrationPolicySpAbi, - functionName: "onRaiseDispute", - args: [request.caller, request.data], - }), - }; + public parseTxPermissionSetEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: accessControllerAbi, + eventName: "PermissionSet", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "PermissionSet") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; } +} - /** - * method onResolveDispute for contract ArbitrationPolicySP - * - * @param request ArbitrationPolicySpOnResolveDisputeRequest - * @return Promise - */ - public async onResolveDispute( - request: ArbitrationPolicySpOnResolveDisputeRequest, - ): Promise { - const { request: call } = await this.rpcClient.simulateContract({ - abi: arbitrationPolicySpAbi, - address: this.address, - functionName: "onResolveDispute", - account: this.wallet.account, - args: [request.caller, request.disputeId, request.data], - }); - return await this.wallet.writeContract(call as WriteContractParameters); - } +/** + * contract AccessController write method + */ +export class AccessControllerClient extends AccessControllerEventClient { + protected readonly wallet: SimpleWalletClient; - /** - * method onResolveDispute for contract ArbitrationPolicySP with only encode - * - * @param request ArbitrationPolicySpOnResolveDisputeRequest - * @return EncodedTxData - */ - public onResolveDisputeEncode( - request: ArbitrationPolicySpOnResolveDisputeRequest, - ): EncodedTxData { - return { - to: this.address, - data: encodeFunctionData({ - abi: arbitrationPolicySpAbi, - functionName: "onResolveDispute", - args: [request.caller, request.disputeId, request.data], - }), - }; + constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { + super(rpcClient, address); + this.wallet = wallet; } /** - * method setAuthority for contract ArbitrationPolicySP + * method setAllPermissions for contract AccessController * - * @param request ArbitrationPolicySpSetAuthorityRequest + * @param request AccessControllerSetAllPermissionsRequest * @return Promise */ - public async setAuthority( - request: ArbitrationPolicySpSetAuthorityRequest, + public async setAllPermissions( + request: AccessControllerSetAllPermissionsRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: arbitrationPolicySpAbi, + abi: accessControllerAbi, address: this.address, - functionName: "setAuthority", + functionName: "setAllPermissions", account: this.wallet.account, - args: [request.newAuthority], + args: [request.ipAccount, request.signer, request.permission], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method setAuthority for contract ArbitrationPolicySP with only encode + * method setAllPermissions for contract AccessController with only encode * - * @param request ArbitrationPolicySpSetAuthorityRequest + * @param request AccessControllerSetAllPermissionsRequest * @return EncodedTxData */ - public setAuthorityEncode(request: ArbitrationPolicySpSetAuthorityRequest): EncodedTxData { + public setAllPermissionsEncode(request: AccessControllerSetAllPermissionsRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: arbitrationPolicySpAbi, - functionName: "setAuthority", - args: [request.newAuthority], + abi: accessControllerAbi, + functionName: "setAllPermissions", + args: [request.ipAccount, request.signer, request.permission], }), }; } /** - * method setTreasury for contract ArbitrationPolicySP + * method setBatchPermissions for contract AccessController * - * @param request ArbitrationPolicySpSetTreasuryRequest + * @param request AccessControllerSetBatchPermissionsRequest * @return Promise */ - public async setTreasury( - request: ArbitrationPolicySpSetTreasuryRequest, + public async setBatchPermissions( + request: AccessControllerSetBatchPermissionsRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: arbitrationPolicySpAbi, + abi: accessControllerAbi, address: this.address, - functionName: "setTreasury", + functionName: "setBatchPermissions", account: this.wallet.account, - args: [request.newTreasury], + args: [request.permissions], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method setTreasury for contract ArbitrationPolicySP with only encode + * method setBatchPermissions for contract AccessController with only encode * - * @param request ArbitrationPolicySpSetTreasuryRequest + * @param request AccessControllerSetBatchPermissionsRequest * @return EncodedTxData */ - public setTreasuryEncode(request: ArbitrationPolicySpSetTreasuryRequest): EncodedTxData { + public setBatchPermissionsEncode( + request: AccessControllerSetBatchPermissionsRequest, + ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: arbitrationPolicySpAbi, - functionName: "setTreasury", - args: [request.newTreasury], + abi: accessControllerAbi, + functionName: "setBatchPermissions", + args: [request.permissions], }), }; } /** - * method upgradeToAndCall for contract ArbitrationPolicySP + * method setPermission for contract AccessController * - * @param request ArbitrationPolicySpUpgradeToAndCallRequest + * @param request AccessControllerSetPermissionRequest * @return Promise */ - public async upgradeToAndCall( - request: ArbitrationPolicySpUpgradeToAndCallRequest, + public async setPermission( + request: AccessControllerSetPermissionRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: arbitrationPolicySpAbi, + abi: accessControllerAbi, address: this.address, - functionName: "upgradeToAndCall", + functionName: "setPermission", account: this.wallet.account, - args: [request.newImplementation, request.data], + args: [request.ipAccount, request.signer, request.to, request.func, request.permission], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method upgradeToAndCall for contract ArbitrationPolicySP with only encode + * method setPermission for contract AccessController with only encode * - * @param request ArbitrationPolicySpUpgradeToAndCallRequest + * @param request AccessControllerSetPermissionRequest * @return EncodedTxData */ - public upgradeToAndCallEncode( - request: ArbitrationPolicySpUpgradeToAndCallRequest, - ): EncodedTxData { + public setPermissionEncode(request: AccessControllerSetPermissionRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: arbitrationPolicySpAbi, - functionName: "upgradeToAndCall", - args: [request.newImplementation, request.data], + abi: accessControllerAbi, + functionName: "setPermission", + args: [request.ipAccount, request.signer, request.to, request.func, request.permission], }), }; } @@ -19318,6 +18484,26 @@ export type LicensingModuleRegisterDerivativeWithLicenseTokensRequest = { royaltyContext: Hex; }; +/** + * LicensingModuleSetLicensingConfigRequest + * + * @param ipId address + * @param licenseTemplate address + * @param licenseTermsId uint256 + * @param licensingConfig tuple + */ +export type LicensingModuleSetLicensingConfigRequest = { + ipId: Address; + licenseTemplate: Address; + licenseTermsId: bigint; + licensingConfig: { + isSet: boolean; + mintingFee: bigint; + licensingHook: Address; + hookData: Hex; + }; +}; + /** * contract LicensingModule event */ @@ -19636,6 +18822,54 @@ export class LicensingModuleClient extends LicensingModuleReadOnlyClient { }), }; } + + /** + * method setLicensingConfig for contract LicensingModule + * + * @param request LicensingModuleSetLicensingConfigRequest + * @return Promise + */ + public async setLicensingConfig( + request: LicensingModuleSetLicensingConfigRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: licensingModuleAbi, + address: this.address, + functionName: "setLicensingConfig", + account: this.wallet.account, + args: [ + request.ipId, + request.licenseTemplate, + request.licenseTermsId, + request.licensingConfig, + ], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setLicensingConfig for contract LicensingModule with only encode + * + * @param request LicensingModuleSetLicensingConfigRequest + * @return EncodedTxData + */ + public setLicensingConfigEncode( + request: LicensingModuleSetLicensingConfigRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licensingModuleAbi, + functionName: "setLicensingConfig", + args: [ + request.ipId, + request.licenseTemplate, + request.licenseTermsId, + request.licensingConfig, + ], + }), + }; + } } // Contract MockERC20 ============================================================= @@ -23575,6 +22809,8 @@ export type SpgnftImplBalanceOfResponse = bigint; export type SpgnftImplBaseUriResponse = string; +export type SpgnftImplContractUriResponse = string; + /** * SpgnftImplGetApprovedRequest * @@ -23704,6 +22940,7 @@ export type SpgnftImplInitializeRequest = { name: string; symbol: string; baseURI: string; + contractURI: string; maxSupply: number; mintFee: bigint; mintFeeToken: Address; @@ -23808,6 +23045,15 @@ export type SpgnftImplSetBaseUriRequest = { baseURI: string; }; +/** + * SpgnftImplSetContractUriRequest + * + * @param contractURI string + */ +export type SpgnftImplSetContractUriRequest = { + contractURI: string; +}; + /** * SpgnftImplSetMintFeeRequest * @@ -24356,6 +23602,20 @@ export class SpgnftImplReadOnlyClient extends SpgnftImplEventClient { }); } + /** + * method contractURI for contract SPGNFTImpl + * + * @param request SpgnftImplContractUriRequest + * @return Promise + */ + public async contractUri(): Promise { + return await this.rpcClient.readContract({ + abi: spgnftImplAbi, + address: this.address, + functionName: "contractURI", + }); + } + /** * method getApproved for contract SPGNFTImpl * @@ -24977,6 +24237,42 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { }; } + /** + * method setContractURI for contract SPGNFTImpl + * + * @param request SpgnftImplSetContractUriRequest + * @return Promise + */ + public async setContractUri( + request: SpgnftImplSetContractUriRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: spgnftImplAbi, + address: this.address, + functionName: "setContractURI", + account: this.wallet.account, + args: [request.contractURI], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setContractURI for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplSetContractUriRequest + * @return EncodedTxData + */ + public setContractUriEncode(request: SpgnftImplSetContractUriRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "setContractURI", + args: [request.contractURI], + }), + }; + } + /** * method setMintFee for contract SPGNFTImpl * diff --git a/packages/core-sdk/src/client.ts b/packages/core-sdk/src/client.ts index b1b2fcf2..8de21cfa 100644 --- a/packages/core-sdk/src/client.ts +++ b/packages/core-sdk/src/client.ts @@ -12,7 +12,7 @@ import { PermissionClient } from "./resources/permission"; import { LicenseClient } from "./resources/license"; import { DisputeClient } from "./resources/dispute"; import { IPAccountClient } from "./resources/ipAccount"; -import { chainStringToViemChain } from "./utils/utils"; +import { chain, chainStringToViemChain } from "./utils/utils"; import { RoyaltyClient } from "./resources/royalty"; import { NftClient } from "./resources/nftClient"; import { GroupClient } from "./resources/group"; @@ -43,7 +43,7 @@ export class StoryClient { private constructor(config: StoryConfig) { this.config = { ...config, - chainId: config.chainId || "iliad", + chainId: chain[config.chainId || "odyssey"], }; if (!this.config.transport) { throw new Error( diff --git a/packages/core-sdk/src/index.ts b/packages/core-sdk/src/index.ts index d4d08a15..acd88fd4 100644 --- a/packages/core-sdk/src/index.ts +++ b/packages/core-sdk/src/index.ts @@ -1,6 +1,6 @@ export { StoryClient } from "./client"; export { AddressZero, HashZero } from "./constants/common"; -export { iliad } from "./utils/chain"; +export { odyssey } from "./utils/chain"; export { IPAssetClient } from "./resources/ipAsset"; export { PermissionClient } from "./resources/permission"; export { LicenseClient } from "./resources/license"; @@ -54,6 +54,9 @@ export type { MintLicenseTokensResponse, LicenseTermsId, LicenseTerms, + PredictMintingLicenseFeeRequest, + SetLicensingConfigRequest, + SetLicensingConfigResponse, } from "./types/resources/license"; export { PIL_TYPE } from "./types/resources/license"; @@ -124,6 +127,8 @@ export type { PiLicenseTemplateGetLicenseTermsResponse, IpAccountImplStateResponse, EncodedTxData, + LicensingModulePredictMintingLicenseFeeResponse, } from "./abi/generated"; export { getPermissionSignature } from "./utils/sign"; +export { convertCIDtoHashIPFS, convertHashIPFStoCID } from "./utils/ipfs"; diff --git a/packages/core-sdk/src/resources/dispute.ts b/packages/core-sdk/src/resources/dispute.ts index bddb2096..9348d28b 100644 --- a/packages/core-sdk/src/resources/dispute.ts +++ b/packages/core-sdk/src/resources/dispute.ts @@ -11,6 +11,7 @@ import { } from "../types/resources/dispute"; import { DisputeModuleClient, SimpleWalletClient } from "../abi/generated"; import { getAddress } from "../utils/utils"; +import { convertCIDtoHashIPFS } from "../utils/ipfs"; export class DisputeClient { private readonly rpcClient: PublicClient; @@ -26,7 +27,7 @@ export class DisputeClient { * @param request - The request object containing necessary data to raise a dispute. * @param request.targetIpId The IP ID that is the target of the dispute. * @param request.targetTag The target tag of the dispute. - * @param request.disputeEvidenceHash The hash pointing to the dispute evidence + * @param request.cid CID (Content Identifier) is a unique identifier in IPFS, including CID v0 (base58) and CID v1 (base32). * @param request.data The data to initialize the policy * @param request.txOptions [Optional] This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property. * @returns A Promise that resolves to a RaiseDisputeResponse containing the transaction hash. @@ -41,8 +42,10 @@ export class DisputeClient { const req = { targetIpId: getAddress(request.targetIpId, "request.targetIpId"), targetTag: stringToHex(request.targetTag, { size: 32 }), - data: request.data || "0x", - disputeEvidenceHash: request.disputeEvidenceHash, + data: + request.data || + "0x00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000278d0000000000000000000000000091f6f05b08c16769d3c85867548615d270c42fc700000000000000000000000000000000000000000000000000000000000000004153534552545f54525554480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a7465737420636c61696d00000000000000000000000000000000000000000000", + disputeEvidenceHash: convertCIDtoHashIPFS(request.cid), }; if (request.txOptions?.encodedTxDataOnly) { diff --git a/packages/core-sdk/src/resources/group.ts b/packages/core-sdk/src/resources/group.ts index b4a56457..731778b6 100644 --- a/packages/core-sdk/src/resources/group.ts +++ b/packages/core-sdk/src/resources/group.ts @@ -212,7 +212,7 @@ export class GroupClient { ): Promise { try { const ipIdAddress = await this.ipAssetRegistryClient.ipId({ - chainId: chain[this.chainId], + chainId: BigInt(chain[this.chainId]), tokenContract: getAddress(request.nftContract, "nftContract"), tokenId: BigInt(request.tokenId), }); diff --git a/packages/core-sdk/src/resources/ipAsset.ts b/packages/core-sdk/src/resources/ipAsset.ts index 9bd5d4ec..86005227 100644 --- a/packages/core-sdk/src/resources/ipAsset.ts +++ b/packages/core-sdk/src/resources/ipAsset.ts @@ -255,7 +255,7 @@ export class IPAssetClient { encodedTxData: this.ipAssetRegistryClient.registerEncode({ tokenContract: object.nftContract, tokenId: object.tokenId, - chainid: chain[this.chainId], + chainid: BigInt(chain[this.chainId]), }), }; } @@ -292,7 +292,7 @@ export class IPAssetClient { txHash = await this.ipAssetRegistryClient.register({ tokenContract: object.nftContract, tokenId: object.tokenId, - chainid: chain[this.chainId], + chainid: BigInt(chain[this.chainId]), }); } if (request.txOptions?.waitForTransaction) { @@ -442,6 +442,7 @@ export class IPAssetClient { * @param request.ipMetadata.ipMetadataHash [Optional] The hash of the metadata for the IP. * @param request.ipMetadata.nftMetadataURI [Optional] The URI of the metadata for the NFT. * @param request.ipMetadata.nftMetadataHash [Optional] The hash of the metadata for the IP NFT. + * @param request.royaltyPolicyAddress [Optional] The address of the royalty policy contract, default value is LAP. * @param request.recipient [Optional] The address of the recipient of the minted NFT,default value is your wallet address. * @param request.mintingFee [Optional] The fee to be paid when minting a license. * @param request.commercialRevShare [Optional] Percentage of revenue that must be shared with the licensor. @@ -462,10 +463,10 @@ export class IPAssetClient { defaultMintingFee: request.mintingFee, currency: request.currency, commercialRevShare: request.commercialRevShare, - royaltyPolicyLAPAddress: - royaltyPolicyLapAddress[ - chain[this.chainId] as unknown as keyof typeof royaltyPolicyLapAddress - ], + royaltyPolicyAddress: + (request.royaltyPolicyAddress && + getAddress(request.royaltyPolicyAddress, "request.royaltyPolicyAddress")) || + royaltyPolicyLapAddress[chain[this.chainId]], }); const object: LicenseAttachmentWorkflowsMintAndRegisterIpAndAttachPilTermsRequest = { spgNftContract: getAddress(request.spgNftContract, "request.spgNftContract"), @@ -520,6 +521,7 @@ export class IPAssetClient { * @param request.ipMetadata.ipMetadataHash [Optional] The hash of the metadata for the IP. * @param request.ipMetadata.nftMetadataURI [Optional] The URI of the metadata for the NFT. * @param request.ipMetadata.nftMetadataHash [Optional] The hash of the metadata for the IP NFT. + * @param request.royaltyPolicyAddress [Optional] The address of the royalty policy contract, default value is LAP. * @param request.deadline [Optional] The deadline for the signature in milliseconds, default is 1000ms. * @param request.mintingFee [Optional] The fee to be paid when minting a license. * @param request.commercialRevShare [Optional] Percentage of revenue that must be shared with the licensor. @@ -544,10 +546,10 @@ export class IPAssetClient { const licenseTerm = getLicenseTermByType(request.pilType, { defaultMintingFee: request.mintingFee, currency: request.currency, - royaltyPolicyLAPAddress: - royaltyPolicyLapAddress[ - chain[this.chainId] as unknown as keyof typeof royaltyPolicyLapAddress - ], + royaltyPolicyAddress: + (request.royaltyPolicyAddress && + getAddress(request.royaltyPolicyAddress, "request.royaltyPolicyAddress")) || + royaltyPolicyLapAddress[chain[this.chainId]], commercialRevShare: request.commercialRevShare, }); const calculatedDeadline = getDeadline(request.deadline); @@ -809,7 +811,7 @@ export class IPAssetClient { * @param request.ipMetadata.nftMetadataHash [Optional] The hash of the metadata for the IP NFT. * @param request.recipient [Optional] The address of the recipient of the minted NFT,default value is your wallet address. * @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property. - * @returns A Promise that resolves to an object containing the transaction hash and optional IP ID if waitForTxn is set to true. + * @returns A Promise that resolves to a transaction hash, and if encodedTxDataOnly is true, includes encoded transaction data, and if waitForTransaction is true, includes child ip id and token id. * @emits IPRegistered (ipId, chainId, tokenContract, tokenId, name, uri, registrationDate) */ public async mintAndRegisterIpAndMakeDerivative( @@ -871,7 +873,7 @@ export class IPAssetClient { hash: txHash, }); const log = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(receipt)[0]; - return { txHash, childIpId: log.ipId }; + return { txHash, childIpId: log.ipId, tokenId: log.tokenId }; } return { txHash }; } @@ -1197,7 +1199,7 @@ export class IPAssetClient { tokenId: bigint | string | number, ): Promise
{ const ipId = await this.ipAssetRegistryClient.ipId({ - chainId: chain[this.chainId], + chainId: BigInt(chain[this.chainId]), tokenContract: getAddress(nftContract, "nftContract"), tokenId: BigInt(tokenId), }); diff --git a/packages/core-sdk/src/resources/license.ts b/packages/core-sdk/src/resources/license.ts index f9d3d5f5..aa08971f 100644 --- a/packages/core-sdk/src/resources/license.ts +++ b/packages/core-sdk/src/resources/license.ts @@ -5,6 +5,10 @@ import { LicenseRegistryEventClient, LicenseRegistryReadOnlyClient, LicensingModuleClient, + LicensingModulePredictMintingLicenseFeeRequest, + LicensingModulePredictMintingLicenseFeeResponse, + LicensingModuleSetLicensingConfigRequest, + ModuleRegistryReadOnlyClient, PiLicenseTemplateClient, PiLicenseTemplateGetLicenseTermsResponse, PiLicenseTemplateReadOnlyClient, @@ -25,6 +29,9 @@ import { AttachLicenseTermsResponse, LicenseTermsId, RegisterPILTermsRequest, + PredictMintingLicenseFeeRequest, + SetLicensingConfigRequest, + SetLicensingConfigResponse, } from "../types/resources/license"; import { handleError } from "../utils/errors"; import { getLicenseTermByType, validateLicenseTerms } from "../utils/licenseTermsHelper"; @@ -38,6 +45,7 @@ export class LicenseClient { public piLicenseTemplateReadOnlyClient: PiLicenseTemplateReadOnlyClient; public licenseTemplateClient: PiLicenseTemplateClient; public licenseRegistryReadOnlyClient: LicenseRegistryReadOnlyClient; + public moduleRegistryReadOnlyClient: ModuleRegistryReadOnlyClient; private readonly rpcClient: PublicClient; private readonly wallet: SimpleWalletClient; private readonly chainId: SupportedChainIds; @@ -49,6 +57,7 @@ export class LicenseClient { this.licenseTemplateClient = new PiLicenseTemplateClient(rpcClient, wallet); this.licenseRegistryReadOnlyClient = new LicenseRegistryReadOnlyClient(rpcClient); this.ipAssetRegistryClient = new IpAssetRegistryClient(rpcClient, wallet); + this.moduleRegistryReadOnlyClient = new ModuleRegistryReadOnlyClient(rpcClient); this.rpcClient = rpcClient; this.wallet = wallet; this.chainId = chainId; @@ -74,7 +83,7 @@ export class LicenseClient { * @param request.currency The ERC20 token to be used to pay the minting fee. the token must be registered in story protocol. * @param request.uri The URI of the license terms, which can be used to fetch the offchain license terms. * @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property. - * @returns A Promise that resolves to an object containing the optional transaction hash, optional transaction encodedTxData and optional license terms Id. + * @returns A Promise that resolves to a transaction hash, and if encodedTxDataOnly is true, includes encoded transaction data, and if waitForTransaction is true, includes license terms Id. * @emits LicenseTermsRegistered (licenseTermsId, licenseTemplate, licenseTerms); */ public async registerPILTerms(request: RegisterPILTermsRequest): Promise { @@ -114,7 +123,7 @@ export class LicenseClient { * Convenient function to register a PIL non commercial social remix license to the registry * @param request - [Optional] The request object that contains all data needed to register a PIL non commercial social remix license. * @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property. - * @returns A Promise that resolves to an object containing the optional transaction hash and optional license terms Id. + * @returns A Promise that resolves to a transaction hash, and if encodedTxDataOnly is true, includes encoded transaction data, and if waitForTransaction is true, includes license terms Id. * @emits LicenseTermsRegistered (licenseTermsId, licenseTemplate, licenseTerms); */ public async registerNonComSocialRemixingPIL( @@ -157,8 +166,9 @@ export class LicenseClient { * @param request - The request object that contains all data needed to register a PIL commercial use license. * @param request.defaultMintingFee The fee to be paid when minting a license. * @param request.currency The ERC20 token to be used to pay the minting fee and the token must be registered in story protocol. + * @param request.royaltyPolicyAddress [Optional] The address of the royalty policy contract, default value is LAP. * @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property. - * @returns A Promise that resolves to an object containing the optional transaction hash and optional license terms Id. + * @returns A Promise that resolves to a transaction hash, and if encodedTxDataOnly is true, includes encoded transaction data, and if waitForTransaction is true, includes license terms Id. * @emits LicenseTermsRegistered (licenseTermsId, licenseTemplate, licenseTerms); */ public async registerCommercialUsePIL( @@ -168,10 +178,10 @@ export class LicenseClient { const licenseTerms = getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE, { defaultMintingFee: request.defaultMintingFee, currency: request.currency, - royaltyPolicyLAPAddress: - royaltyPolicyLapAddress[ - chain[this.chainId] as unknown as keyof typeof royaltyPolicyLapAddress - ], + royaltyPolicyAddress: + (request.royaltyPolicyAddress && + getAddress(request.royaltyPolicyAddress, "request.royaltyPolicyAddress")) || + royaltyPolicyLapAddress[chain[this.chainId]], }); const licenseTermsId = await this.getLicenseTermsId(licenseTerms); if (licenseTermsId !== 0n) { @@ -209,8 +219,9 @@ export class LicenseClient { * @param request.defaultMintingFee The fee to be paid when minting a license. * @param request.commercialRevShare Percentage of revenue that must be shared with the licensor. * @param request.currency The ERC20 token to be used to pay the minting fee. the token must be registered in story protocol. + * @param request.royaltyPolicyAddress [Optional] The address of the royalty policy contract, default value is LAP. * @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property. - * @returns A Promise that resolves to an object containing the optional transaction hash and optional license terms Id. + * @returns A Promise that resolves to a transaction hash, and if encodedTxDataOnly is true, includes encoded transaction data, and if waitForTransaction is true, includes license terms Id. * @emits LicenseTermsRegistered (licenseTermsId, licenseTemplate, licenseTerms); */ public async registerCommercialRemixPIL( @@ -220,10 +231,10 @@ export class LicenseClient { const licenseTerms = getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { defaultMintingFee: request.defaultMintingFee, currency: request.currency, - royaltyPolicyLAPAddress: - royaltyPolicyLapAddress[ - chain[this.chainId] as unknown as keyof typeof royaltyPolicyLapAddress - ], + royaltyPolicyAddress: + (request.royaltyPolicyAddress && + getAddress(request.royaltyPolicyAddress, "request.royaltyPolicyAddress")) || + royaltyPolicyLapAddress[chain[this.chainId]], commercialRevShare: request.commercialRevShare, }); const licenseTermsId = await this.getLicenseTermsId(licenseTerms); @@ -264,7 +275,8 @@ export class LicenseClient { * @param request.licenseTemplate The address of the license template. * @param request.licenseTermsId The ID of the license terms. * @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property. - * @returns A Promise that resolves to an object containing the transaction hash. + * @returns A Promise that resolves to a transaction hash, and if encodedTxDataOnly is true, includes encoded transaction data, and if waitForTransaction is true, includes success. + * If Ip have attached license terms, success will return false and txhash is empty. */ public async attachLicenseTerms( request: AttachLicenseTermsRequest, @@ -338,7 +350,7 @@ export class LicenseClient { * @param request.amount The amount of license tokens to mint. * @param request.receiver The address of the receiver. * @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property. - * @returns A Promise that resolves to an object containing the transaction hash and optional license token IDs if waitForTxn is set to true. + * @returns A Promise that resolves to a transaction hash, and if encodedTxDataOnly is true, includes encoded transaction data, and if waitForTransaction is true, includes license token IDs. * @emits LicenseTokensMinted (msg.sender, licensorIpId, licenseTemplate, licenseTermsId, amount, receiver, startLicenseTokenId); */ public async mintLicenseTokens( @@ -425,6 +437,124 @@ export class LicenseClient { } } + /** + * Pre-compute the minting license fee for the given IP and license terms. The function can be used to calculate the minting license fee before minting license tokens. + * @param request - The request object that contains all data needed to predict minting licenses fee. + * @param request.licensorIpId The IP ID of the licensor. + * @param request.licenseTermsId The ID of the license terms. + * @param request.amount The amount of license tokens to mint. + * @param request.licenseTemplate [Optional] The address of the license template,default value is Programmable IP License. + * @param request.receiver [Optional] The address of the receiver,default value is your wallet address. + * @param request.txOptions [Optional] This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property. + * @returns A Promise that resolves to an object containing the currency token and token amount. + */ + public async predictMintingLicenseFee( + request: PredictMintingLicenseFeeRequest, + ): Promise { + try { + const isLicenseIpIdRegistered = await this.ipAssetRegistryClient.isRegistered({ + id: getAddress(request.licensorIpId, "request.licensorIpId"), + }); + if (!isLicenseIpIdRegistered) { + throw new Error(`The licensor IP with id ${request.licensorIpId} is not registered.`); + } + const licenseTermsId = BigInt(request.licenseTermsId); + const isExisted = await this.piLicenseTemplateReadOnlyClient.exists({ + licenseTermsId, + }); + if (!isExisted) { + throw new Error(`License terms id ${request.licenseTermsId} do not exist.`); + } + const object: LicensingModulePredictMintingLicenseFeeRequest = { + ...request, + receiver: + (request.receiver && getAddress(request.receiver, "request.receiver")) || + this.wallet.account!.address, + amount: BigInt(request.amount), + royaltyContext: zeroAddress, + licenseTemplate: + (request.licenseTemplate && + getAddress(request.licenseTemplate, "request.licenseTemplate")) || + this.licenseTemplateClient.address, + licenseTermsId, + }; + return await this.licensingModuleClient.predictMintingLicenseFee(object); + } catch (error) { + handleError(error, "Failed to predict minting license fee"); + } + } + + /** + * Sets the licensing configuration for a specific license terms of an IP. If both licenseTemplate and licenseTermsId are not specified then the licensing config apply to all licenses of given IP. + * @param request - The request object that contains all data needed to set licensing config. + * @param request.ipId The address of the IP for which the configuration is being set. + * @param request.licenseTermsId The ID of the license terms within the license template. + * @param request.licenseTemplate The address of the license template used, If not specified, the configuration applies to all licenses. + * @param request.licensingConfig The licensing configuration for the license. + * @param request.licensingConfig.isSet Whether the configuration is set or not. + * @param request.licensingConfig.mintingFee The minting fee to be paid when minting license tokens. + * @param request.licensingConfig.hookData The data to be used by the licensing hook. + * @param request.licensingConfig.licensingHook The hook contract address for the licensing module, or address(0) if none. + * @param request.txOptions [Optional] This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property. + * @returns A Promise that resolves to a transaction hash, and if encodedTxDataOnly is true, includes encoded transaction data, and if waitForTransaction is true, includes success. + */ + public async setLicensingConfig( + request: SetLicensingConfigRequest, + ): Promise { + try { + const isLicenseIpIdRegistered = await this.ipAssetRegistryClient.isRegistered({ + id: getAddress(request.ipId, "request.ipId"), + }); + if (!isLicenseIpIdRegistered) { + throw new Error(`The licensor IP with id ${request.ipId} is not registered.`); + } + const licenseTermsId = BigInt(request.licenseTermsId); + const isExisted = await this.piLicenseTemplateReadOnlyClient.exists({ + licenseTermsId, + }); + if (!isExisted) { + throw new Error(`License terms id ${request.licenseTermsId} do not exist.`); + } + if (request.licensingConfig.licensingHook !== zeroAddress) { + const isRegistered = await this.moduleRegistryReadOnlyClient.isRegistered({ + moduleAddress: request.licensingConfig.licensingHook, + }); + if (!isRegistered) { + throw new Error("The licensing hook is not registered."); + } + } + + if (request.licenseTemplate === zeroAddress && request.licenseTermsId !== 0n) { + throw new Error("licenseTemplate is zero address but licenseTermsId is zero."); + } + const object: LicensingModuleSetLicensingConfigRequest = { + ipId: request.ipId, + licenseTemplate: getAddress(request.licenseTemplate, "request.licenseTemplate"), + licenseTermsId, + licensingConfig: { + isSet: request.licensingConfig.isSet, + mintingFee: BigInt(request.licensingConfig.mintingFee), + hookData: request.licensingConfig.hookData, + licensingHook: request.licensingConfig.licensingHook, + }, + }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: this.licensingModuleClient.setLicensingConfigEncode(object) }; + } else { + const txHash = await this.licensingModuleClient.setLicensingConfig(object); + if (request.txOptions?.waitForTransaction) { + await this.rpcClient.waitForTransactionReceipt({ + ...request.txOptions, + hash: txHash, + }); + return { txHash: txHash, success: true }; + } + return { txHash: txHash }; + } + } catch (error) { + handleError(error, "Failed to set licensing config"); + } + } private async getLicenseTermsId(request: LicenseTerms): Promise { const licenseRes = await this.licenseTemplateClient.getLicenseTermsId({ terms: request }); return licenseRes.selectedLicenseTermsId; diff --git a/packages/core-sdk/src/types/config.ts b/packages/core-sdk/src/types/config.ts index a6b020f4..41c9f8da 100644 --- a/packages/core-sdk/src/types/config.ts +++ b/packages/core-sdk/src/types/config.ts @@ -7,7 +7,7 @@ import { SimpleWalletClient } from "../abi/generated"; * * @public */ -export type SupportedChainIds = "1513" | "iliad"; +export type SupportedChainIds = "1516" | "odyssey"; /** * Configuration for the SDK Client. diff --git a/packages/core-sdk/src/types/resources/dispute.ts b/packages/core-sdk/src/types/resources/dispute.ts index cd88b601..9b9e1d40 100644 --- a/packages/core-sdk/src/types/resources/dispute.ts +++ b/packages/core-sdk/src/types/resources/dispute.ts @@ -5,9 +5,9 @@ import { EncodedTxData } from "../../abi/generated"; export type RaiseDisputeRequest = { targetIpId: Address; - disputeEvidenceHash: Hex; + cid: string; targetTag: string; - data?: Address; + data?: Hex; txOptions?: TxOptions; }; diff --git a/packages/core-sdk/src/types/resources/ipAsset.ts b/packages/core-sdk/src/types/resources/ipAsset.ts index 4b25b2d0..bf9adce0 100644 --- a/packages/core-sdk/src/types/resources/ipAsset.ts +++ b/packages/core-sdk/src/types/resources/ipAsset.ts @@ -41,6 +41,7 @@ export type RegisterDerivativeResponse = { txHash?: string; encodedTxData?: EncodedTxData; childIpId?: Address; + tokenId?: bigint; }; export type CreateIpAssetWithPilTermsRequest = { @@ -50,6 +51,7 @@ export type CreateIpAssetWithPilTermsRequest = { mintingFee?: string | number | bigint; recipient?: Address; commercialRevShare?: number; + royaltyPolicyAddress?: Address; } & IpMetadataAndTxOption; export type CreateIpAssetWithPilTermsResponse = { @@ -85,6 +87,7 @@ export type RegisterIpAndAttachPilTermsRequest = { currency: Address; deadline?: bigint | number | string; commercialRevShare?: number; + royaltyPolicyAddress?: Address; } & IpMetadataAndTxOption; export type RegisterIpAndAttachPilTermsResponse = { diff --git a/packages/core-sdk/src/types/resources/license.ts b/packages/core-sdk/src/types/resources/license.ts index 1d2c92e0..c0e51d23 100644 --- a/packages/core-sdk/src/types/resources/license.ts +++ b/packages/core-sdk/src/types/resources/license.ts @@ -1,4 +1,4 @@ -import { Address } from "viem"; +import { Address, Hex } from "viem"; import { TxOptions } from "../options"; import { EncodedTxData } from "../../abi/generated"; @@ -78,6 +78,7 @@ export type RegisterPILResponse = { export type RegisterCommercialUsePILRequest = { defaultMintingFee: string | number | bigint; currency: Address; + royaltyPolicyAddress?: Address; txOptions?: TxOptions; }; @@ -85,6 +86,7 @@ export type RegisterCommercialRemixPILRequest = { defaultMintingFee: string | number | bigint; commercialRevShare: number; currency: Address; + royaltyPolicyAddress?: Address; txOptions?: TxOptions; }; @@ -123,3 +125,31 @@ export enum PIL_TYPE { } export type LicenseTermsId = string | number | bigint; + +export type PredictMintingLicenseFeeRequest = { + licensorIpId: Address; + licenseTermsId: LicenseTermsId; + amount: string | number | bigint; + licenseTemplate?: Address; + receiver?: Address; + txOptions?: TxOptions; +}; + +export type SetLicensingConfigRequest = { + ipId: Address; + licenseTermsId: string | number | bigint; + licensingConfig: { + isSet: boolean; + mintingFee: bigint | string | number; + licensingHook: Address; + hookData: Hex; + }; + licenseTemplate: Address; + txOptions?: TxOptions; +}; + +export type SetLicensingConfigResponse = { + txHash?: string; + encodedTxData?: EncodedTxData; + success?: boolean; +}; diff --git a/packages/core-sdk/src/utils/chain.ts b/packages/core-sdk/src/utils/chain.ts index 0670dfb6..ded81e3c 100644 --- a/packages/core-sdk/src/utils/chain.ts +++ b/packages/core-sdk/src/utils/chain.ts @@ -1,22 +1,22 @@ import { defineChain } from "viem/utils"; -export const iliad = defineChain({ - id: 15_13, - name: "iliad", +export const odyssey = defineChain({ + id: 15_16, + name: "odyssey", nativeCurrency: { name: "IP", symbol: "IP", decimals: 18 }, rpcUrls: { default: { - http: ["https://testnet.storyrpc.io"], - webSocket: ["wss://story-network.rpc.caldera.xyz/ws"], + http: ["https://odyssey.storyrpc.io/"], }, }, blockExplorers: { default: { name: "Explorer", - url: "https://testnet.storyscan.xyz", + url: "https://odyssey-testnet-explorer.storyscan.xyz/", }, }, contracts: { + //TODO: need to confirm the addresses multicall3: { address: "0xcA11bde05977b3631167028862bE2a173976CA11", blockCreated: 5882, diff --git a/packages/core-sdk/src/utils/ipfs.ts b/packages/core-sdk/src/utils/ipfs.ts new file mode 100644 index 00000000..d1e44d3e --- /dev/null +++ b/packages/core-sdk/src/utils/ipfs.ts @@ -0,0 +1,27 @@ +import { CID } from "multiformats/cid"; +import bs58 from "bs58"; +import { base58btc } from "multiformats/bases/base58"; +import { Hex } from "viem"; + +const v0Prefix = "1220"; +export const convertCIDtoHashIPFS = (cid: string): Hex => { + const isV0 = cid.startsWith("Qm"); + const parsedCID = CID.parse(cid); + const base58CID = isV0 ? parsedCID.toString() : parsedCID.toV0().toString(); + const bytes = bs58.decode(base58CID); + const base16CID = Array.from(bytes) + .map((byte) => byte.toString(16).padStart(2, "0")) + .join(""); + return ("0x" + base16CID.slice(v0Prefix.length)) as Hex; +}; + +export const convertHashIPFStoCID = (hash: Hex, version: "v0" | "v1" = "v0"): string => { + const base16CID = v0Prefix + hash.slice(2); + const bytes = new Uint8Array(base16CID.match(/.{1,2}/g)!.map((byte) => parseInt(byte, 16))); + const base58CID = bs58.encode(Buffer.from(bytes)); + if (version === "v0") { + return base58CID; + } else { + return CID.parse(base58CID, base58btc).toV1().toString(); + } +}; diff --git a/packages/core-sdk/src/utils/licenseTermsHelper.ts b/packages/core-sdk/src/utils/licenseTermsHelper.ts index f81f3aeb..d48175f3 100644 --- a/packages/core-sdk/src/utils/licenseTermsHelper.ts +++ b/packages/core-sdk/src/utils/licenseTermsHelper.ts @@ -1,4 +1,4 @@ -import { Hex, PublicClient, zeroAddress } from "viem"; +import { Address, PublicClient, zeroAddress } from "viem"; import { PIL_TYPE, LicenseTerms, RegisterPILTermsRequest } from "../types/resources/license"; import { getAddress } from "./utils"; @@ -8,8 +8,8 @@ export function getLicenseTermByType( type: PIL_TYPE, term?: { defaultMintingFee?: string | number | bigint; - currency?: Hex; - royaltyPolicyLAPAddress: Hex; + currency?: Address; + royaltyPolicyAddress: Address; commercialRevShare?: number; }, ): LicenseTerms { @@ -40,7 +40,7 @@ export function getLicenseTermByType( throw new Error("DefaultMintingFee, currency are required for commercial use PIL."); } licenseTerms.royaltyPolicy = getAddress( - term.royaltyPolicyLAPAddress, + term.royaltyPolicyAddress, "term.royaltyPolicyLAPAddress", ); licenseTerms.defaultMintingFee = BigInt(term.defaultMintingFee); @@ -64,7 +64,7 @@ export function getLicenseTermByType( throw new Error("CommercialRevShare should be between 0 and 100."); } licenseTerms.royaltyPolicy = getAddress( - term.royaltyPolicyLAPAddress, + term.royaltyPolicyAddress, "term.royaltyPolicyLAPAddress", ); licenseTerms.defaultMintingFee = BigInt(term.defaultMintingFee); diff --git a/packages/core-sdk/src/utils/utils.ts b/packages/core-sdk/src/utils/utils.ts index ded0ec38..8355422e 100644 --- a/packages/core-sdk/src/utils/utils.ts +++ b/packages/core-sdk/src/utils/utils.ts @@ -13,7 +13,7 @@ import { } from "viem"; import { SupportedChainIds } from "../types/config"; -import { iliad } from "./chain"; +import { odyssey } from "./chain"; export async function waitTxAndFilterLog< const TAbi extends Abi | readonly unknown[], @@ -78,18 +78,18 @@ export async function waitTx( } export function chainStringToViemChain(chainId: SupportedChainIds): Chain { - switch (chainId) { - case "1513": - case "iliad": - return iliad; + switch (chainId.toString()) { + case "1516": + case "odyssey": + return odyssey; default: throw new Error(`chainId ${chainId as string} not supported`); } } -export const chain: { [key in SupportedChainIds]: bigint } = { - iliad: 1513n, - 1513: 1513n, +export const chain: { [key in SupportedChainIds]: "1516" } = { + odyssey: "1516", + 1516: "1516", }; export const getAddress = (address: string, name: string, chainId?: number): Address => { diff --git a/packages/core-sdk/test/integration/dispute.test.ts b/packages/core-sdk/test/integration/dispute.test.ts index 72fb322d..f553f39c 100644 --- a/packages/core-sdk/test/integration/dispute.test.ts +++ b/packages/core-sdk/test/integration/dispute.test.ts @@ -1,16 +1,14 @@ import chai from "chai"; import { StoryClient } from "../../src"; import { CancelDisputeRequest, RaiseDisputeRequest } from "../../src/index"; -import { mockERC721, getStoryClient, getTokenId, iliadChainId } from "./utils/util"; +import { mockERC721, getStoryClient, getTokenId } from "./utils/util"; import chaiAsPromised from "chai-as-promised"; import { Address } from "viem"; import { MockERC20 } from "./utils/mockERC20"; -import { arbitrationPolicySpAddress } from "../../src/abi/generated"; chai.use(chaiAsPromised); const expect = chai.expect; -//Because of IPFS issue, so currently we can't test this function -const arbitrationPolicyAddress = arbitrationPolicySpAddress[iliadChainId]; +// It won’t work in current version, so skip this test describe.skip("Dispute Functions", () => { let clientA: StoryClient; let clientB: StoryClient; @@ -22,7 +20,6 @@ describe.skip("Dispute Functions", () => { clientB = getStoryClient(); const mockERC20 = new MockERC20(); await mockERC20.mint(); - await mockERC20.approve(arbitrationPolicyAddress); const tokenId = await getTokenId(); ipIdB = ( await clientB.ipAsset.register({ @@ -38,7 +35,7 @@ describe.skip("Dispute Functions", () => { it("should not throw error when raise a dispute", async () => { const raiseDisputeRequest: RaiseDisputeRequest = { targetIpId: ipIdB, - disputeEvidenceHash: "0xb7b94ecbd1f9f8cb209909e5785fb2858c9a8c4b220c017995a75346ad1b5db5", + cid: "QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR", targetTag: "PLAGIARISM", txOptions: { waitForTransaction: true, @@ -49,8 +46,8 @@ describe.skip("Dispute Functions", () => { expect(response.txHash).to.be.a("string").and.not.empty; expect(response.disputeId).to.be.a("bigint"); }); - - it("should not throw error when cancel a dispute", async () => { + //In the current arbitration policy it is not possible to cancel disputes, so skip this test + it.skip("should not throw error when cancel a dispute", async () => { const cancelDispute: CancelDisputeRequest = { disputeId: disputeId, txOptions: { diff --git a/packages/core-sdk/test/integration/group.test.ts b/packages/core-sdk/test/integration/group.test.ts index edbbfe79..2ba2e5e4 100644 --- a/packages/core-sdk/test/integration/group.test.ts +++ b/packages/core-sdk/test/integration/group.test.ts @@ -1,12 +1,12 @@ import chai from "chai"; import chaiAsPromised from "chai-as-promised"; import { Address } from "viem"; -import { getStoryClient, iliadChainId, mintBySpg } from "./utils/util"; +import { getStoryClient, odyssey, mintBySpg } from "./utils/util"; import { PIL_TYPE, StoryClient } from "../../src"; import { MockERC20 } from "./utils/mockERC20"; import { evenSplitGroupPoolAddress } from "../../src/abi/generated"; -const groupPoolAddress = evenSplitGroupPoolAddress[iliadChainId]; +const groupPoolAddress = evenSplitGroupPoolAddress[odyssey]; chai.use(chaiAsPromised); const expect = chai.expect; diff --git a/packages/core-sdk/test/integration/ipAccount.test.ts b/packages/core-sdk/test/integration/ipAccount.test.ts index 91125567..ac9b7746 100644 --- a/packages/core-sdk/test/integration/ipAccount.test.ts +++ b/packages/core-sdk/test/integration/ipAccount.test.ts @@ -1,7 +1,7 @@ import chai from "chai"; import chaiAsPromised from "chai-as-promised"; import { AccessPermission, StoryClient } from "../../src"; -import { mockERC721, getStoryClient, getTokenId, iliadChainId } from "./utils/util"; +import { mockERC721, getStoryClient, getTokenId, odyssey } from "./utils/util"; import { Hex, encodeFunctionData, getAddress, toFunctionSelector } from "viem"; import { accessControllerAbi, @@ -15,8 +15,8 @@ describe("Ip Account functions", () => { let client: StoryClient; let ipId: Hex; let data: Hex; - const coreMetadataModule = coreMetadataModuleAddress[iliadChainId]; - const permissionAddress = accessControllerAddress[iliadChainId]; + const coreMetadataModule = coreMetadataModuleAddress[odyssey]; + const permissionAddress = accessControllerAddress[odyssey]; before(async () => { client = getStoryClient(); diff --git a/packages/core-sdk/test/integration/ipAsset.test.ts b/packages/core-sdk/test/integration/ipAsset.test.ts index 37bc350d..5694f5a6 100644 --- a/packages/core-sdk/test/integration/ipAsset.test.ts +++ b/packages/core-sdk/test/integration/ipAsset.test.ts @@ -7,7 +7,7 @@ import { getStoryClient, getTokenId, mintBySpg, - iliadChainId, + odyssey, approveForLicenseToken, } from "./utils/util"; import { MockERC20 } from "./utils/mockERC20"; @@ -112,8 +112,6 @@ describe("IP Asset Functions ", () => { let nftContract: Hex; let parentIpId: Hex; let licenseTermsId: bigint; - const mockERC20 = new MockERC20(); - mockERC20.approve(derivativeWorkflowsAddress[iliadChainId]); before(async () => { // Create a NFT collection for this test-suite const txData = await client.nftClient.createNFTCollection({ @@ -143,6 +141,9 @@ describe("IP Asset Functions ", () => { }); parentIpId = result.ipId!; licenseTermsId = result.licenseTermsId!; + const mockERC20 = new MockERC20(); + await mockERC20.approve(derivativeWorkflowsAddress[odyssey]); + await mockERC20.mint(); }); describe("should not throw error when mint and register ip and attach pil terms", async () => { @@ -281,6 +282,7 @@ describe("IP Asset Functions ", () => { }); expect(result.txHash).to.be.a("string").and.not.empty; expect(result.childIpId).to.be.a("string").and.not.empty; + expect(result.tokenId).to.be.a("bigint"); }); it("should not throw error when mint and register ip", async () => { @@ -339,7 +341,6 @@ describe("IP Asset Functions ", () => { }); it("should not throw error when call mint and register ip and make derivative with license tokens", async () => { - await mockERC20.approve(spgnftImplAddress[iliadChainId]); const mintLicenseTokensResult = await client.license.mintLicenseTokens({ licenseTermsId: noCommercialLicenseTermsId, licensorIpId: parentIpId, @@ -348,7 +349,7 @@ describe("IP Asset Functions ", () => { }, }); await approveForLicenseToken( - derivativeWorkflowsAddress[iliadChainId], + derivativeWorkflowsAddress[odyssey], mintLicenseTokensResult.licenseTokenIds![0], ); const result = await client.ipAsset.mintAndRegisterIpAndMakeDerivativeWithLicenseTokens({ @@ -378,7 +379,7 @@ describe("IP Asset Functions ", () => { }, }); await approveForLicenseToken( - derivativeWorkflowsAddress[iliadChainId], + derivativeWorkflowsAddress[odyssey], mintLicenseTokensResult.licenseTokenIds![0], ); const result = await client.ipAsset.registerIpAndMakeDerivativeWithLicenseTokens({ diff --git a/packages/core-sdk/test/integration/license.test.ts b/packages/core-sdk/test/integration/license.test.ts index f2d00331..9f1efd6e 100644 --- a/packages/core-sdk/test/integration/license.test.ts +++ b/packages/core-sdk/test/integration/license.test.ts @@ -2,7 +2,7 @@ import chai from "chai"; import { StoryClient } from "../../src"; import { Hex, zeroAddress } from "viem"; import chaiAsPromised from "chai-as-promised"; -import { mockERC721, getStoryClient, getTokenId, iliadChainId } from "./utils/util"; +import { mockERC721, getStoryClient, getTokenId, odyssey } from "./utils/util"; import { MockERC20 } from "./utils/mockERC20"; import { licensingModuleAddress } from "../../src/abi/generated"; @@ -87,9 +87,7 @@ describe("License Functions", () => { }, }); const mockERC20 = new MockERC20(); - await mockERC20.approve( - licensingModuleAddress[Number(iliadChainId) as keyof typeof licensingModuleAddress], - ); + await mockERC20.approve(licensingModuleAddress[odyssey]); ipId = registerResult.ipId!; const registerLicenseResult = await client.license.registerCommercialRemixPIL({ defaultMintingFee: "1", @@ -129,5 +127,35 @@ describe("License Functions", () => { const result = await client.license.getLicenseTerms(licenseId); expect(result).not.empty; }); + + it("should not throw error when predict minting license fee", async () => { + const result = await client.license.predictMintingLicenseFee({ + licenseTermsId: licenseId, + licensorIpId: ipId, + amount: 1, + }); + expect(result.currencyToken).to.be.a("string").and.not.empty; + expect(result.tokenAmount).to.be.a("bigint"); + }); + + it("should not throw error when set licensing config", async () => { + const licenseModule = licensingModuleAddress[odyssey]; + const result = await client.license.setLicensingConfig({ + ipId: ipId, + licenseTermsId: 0n, + licenseTemplate: zeroAddress, + licensingConfig: { + mintingFee: "1", + isSet: true, + licensingHook: zeroAddress, + hookData: "0xFcd3243590d29B131a26B1554B0b21a5B43e622e", + }, + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).to.be.a("string").and.not.empty; + expect(result.success).to.be.true; + }); }); }); diff --git a/packages/core-sdk/test/integration/permission.test.ts b/packages/core-sdk/test/integration/permission.test.ts index 3aa99cf6..4de48f98 100644 --- a/packages/core-sdk/test/integration/permission.test.ts +++ b/packages/core-sdk/test/integration/permission.test.ts @@ -1,6 +1,6 @@ import chai from "chai"; import { StoryClient } from "../../src"; -import { mockERC721, getStoryClient, getTokenId, iliadChainId } from "./utils/util"; +import { mockERC721, getStoryClient, getTokenId, odyssey } from "./utils/util"; import { Address } from "viem"; import { AccessPermission } from "../../src/types/resources/permission"; import chaiAsPromised from "chai-as-promised"; @@ -11,7 +11,7 @@ const expect = chai.expect; describe("Permission Functions", () => { let client: StoryClient; let ipId: Address; - const coreMetadataModule = coreMetadataModuleAddress[iliadChainId]; + const coreMetadataModule = coreMetadataModuleAddress[odyssey]; before(async () => { client = getStoryClient(); diff --git a/packages/core-sdk/test/integration/royalty.test.ts b/packages/core-sdk/test/integration/royalty.test.ts index 5f0835ef..1de96486 100644 --- a/packages/core-sdk/test/integration/royalty.test.ts +++ b/packages/core-sdk/test/integration/royalty.test.ts @@ -2,7 +2,7 @@ import chai from "chai"; import { StoryClient } from "../../src"; import { Address, Hex, encodeFunctionData } from "viem"; import chaiAsPromised from "chai-as-promised"; -import { mockERC721, getTokenId, getStoryClient, iliadChainId } from "./utils/util"; +import { mockERC721, getTokenId, getStoryClient, odyssey } from "./utils/util"; import { MockERC20 } from "./utils/mockERC20"; import { royaltyPolicyLapAddress } from "../../src/abi/generated"; @@ -292,7 +292,7 @@ describe("Test royalty Functions", () => { royaltyClaimDetails: [ { childIpId: childIpId, - royaltyPolicy: royaltyPolicyLapAddress[iliadChainId], + royaltyPolicy: royaltyPolicyLapAddress[odyssey], currencyToken: MockERC20.address, amount: BigInt(1), }, @@ -328,7 +328,7 @@ describe("Test royalty Functions", () => { royaltyClaimDetails: [ { childIpId: childIpId, - royaltyPolicy: royaltyPolicyLapAddress[iliadChainId], + royaltyPolicy: royaltyPolicyLapAddress[odyssey], currencyToken: MockERC20.address, amount: BigInt(1), }, diff --git a/packages/core-sdk/test/integration/utils/mockERC20.ts b/packages/core-sdk/test/integration/utils/mockERC20.ts index c0a3d896..25574c3e 100644 --- a/packages/core-sdk/test/integration/utils/mockERC20.ts +++ b/packages/core-sdk/test/integration/utils/mockERC20.ts @@ -9,17 +9,17 @@ import { } from "viem"; import { privateKeyToAccount } from "viem/accounts"; import { chainStringToViemChain, waitTx } from "../../../src/utils/utils"; -import { RPC, iliadChainId } from "./util"; +import { RPC, odyssey } from "./util"; import { mockErc20Address } from "../../../src/abi/generated"; export class MockERC20 { private publicClient: PublicClient; private walletClient: WalletClient; - static address: Hex = mockErc20Address[iliadChainId]; + static address: Hex = mockErc20Address[odyssey]; constructor() { const baseConfig = { - chain: chainStringToViemChain("iliad"), + chain: chainStringToViemChain("odyssey"), transport: http(RPC), } as const; this.publicClient = createPublicClient(baseConfig); diff --git a/packages/core-sdk/test/integration/utils/util.ts b/packages/core-sdk/test/integration/utils/util.ts index f6c7a68e..7727d3a5 100644 --- a/packages/core-sdk/test/integration/utils/util.ts +++ b/packages/core-sdk/test/integration/utils/util.ts @@ -7,17 +7,15 @@ import { licenseTokenAddress, spgnftBeaconAddress, } from "../../../src/abi/generated"; -export const RPC = "https://story-testnet.aura.network"; -export const iliadChainId = 1513; +export const RPC = "https://odyssey.storyrpc.io"; +export const odyssey = 1516; -export const mockERC721 = "0x322813fd9a801c5507c9de605d63cea4f2ce6c44"; -export const licenseToken = - licenseTokenAddress[Number(iliadChainId) as keyof typeof licenseTokenAddress]; -export const spgNftBeacon = - spgnftBeaconAddress[Number(iliadChainId) as keyof typeof spgnftBeaconAddress]; +export const mockERC721 = "0xd7eb01052362e9fb13f624c17b4ead08e0eaae17"; +export const licenseToken = licenseTokenAddress[odyssey]; +export const spgNftBeacon = spgnftBeaconAddress[odyssey]; const baseConfig = { - chain: chainStringToViemChain("iliad"), + chain: chainStringToViemChain("odyssey"), transport: http(RPC), } as const; export const publicClient = createPublicClient(baseConfig); @@ -105,7 +103,7 @@ export const approveForLicenseToken = async (address: Address, tokenId: bigint) }; export const getStoryClient = (): StoryClient => { const config: StoryConfig = { - chainId: "iliad", + chainId: "odyssey", transport: http(RPC), account: privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as Address), }; diff --git a/packages/core-sdk/test/unit/client.test.ts b/packages/core-sdk/test/unit/client.test.ts index e933bd26..d8506d95 100644 --- a/packages/core-sdk/test/unit/client.test.ts +++ b/packages/core-sdk/test/unit/client.test.ts @@ -1,7 +1,7 @@ import { expect } from "chai"; import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"; import { createWalletClient, http, Transport } from "viem"; -import { StoryClient, StoryConfig, iliad } from "../../src/index"; +import { StoryClient, StoryConfig, odyssey } from "../../src/index"; const rpc = "http://127.0.0.1:8545"; describe("Test StoryClient", () => { @@ -36,7 +36,7 @@ describe("Test StoryClient", () => { transport: http(rpc), wallet: createWalletClient({ account: privateKeyToAccount(generatePrivateKey()), - chain: iliad, + chain: odyssey, transport: http(rpc), }), }); @@ -49,7 +49,7 @@ describe("Test StoryClient", () => { transport: http(rpc), wallet: createWalletClient({ account: privateKeyToAccount(generatePrivateKey()), - chain: iliad, + chain: odyssey, transport: http(rpc), }), }); @@ -69,7 +69,7 @@ describe("Test StoryClient", () => { const account = privateKeyToAccount(generatePrivateKey()); const transport = http(rpc); const config: StoryConfig = { - chainId: "iliad", + chainId: "odyssey", transport, account, }; diff --git a/packages/core-sdk/test/unit/resources/dispute.test.ts b/packages/core-sdk/test/unit/resources/dispute.test.ts index 23ec9274..a422dc19 100644 --- a/packages/core-sdk/test/unit/resources/dispute.test.ts +++ b/packages/core-sdk/test/unit/resources/dispute.test.ts @@ -28,7 +28,7 @@ describe("Test DisputeClient", () => { try { await disputeClient.raiseDispute({ targetIpId: "0x", - disputeEvidenceHash: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + cid: "QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR", targetTag: "tag", }); } catch (e) { @@ -42,7 +42,7 @@ describe("Test DisputeClient", () => { sinon.stub(disputeClient.disputeModuleClient, "raiseDispute").resolves(txHash); const result = await disputeClient.raiseDispute({ targetIpId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", - disputeEvidenceHash: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + cid: "QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR", targetTag: "tag", }); @@ -64,7 +64,7 @@ describe("Test DisputeClient", () => { ]); const result = await disputeClient.raiseDispute({ targetIpId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", - disputeEvidenceHash: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + cid: "QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR", targetTag: "tag", txOptions: { waitForTransaction: true }, }); @@ -76,7 +76,7 @@ describe("Test DisputeClient", () => { it("should return encodedTxData when call raiseDispute successfully with encodedTxDataOnly", async () => { const result = await disputeClient.raiseDispute({ targetIpId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", - disputeEvidenceHash: "0xb7b94ecbd1f9f8cb209909e5785fb2858c9a8c4b220c017995a75346ad1b5db5", + cid: "QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR", targetTag: "tag", txOptions: { encodedTxDataOnly: true }, }); diff --git a/packages/core-sdk/test/unit/resources/group.test.ts b/packages/core-sdk/test/unit/resources/group.test.ts index 8f80f58a..2dcc20ac 100644 --- a/packages/core-sdk/test/unit/resources/group.test.ts +++ b/packages/core-sdk/test/unit/resources/group.test.ts @@ -22,7 +22,7 @@ describe("Test IpAssetClient", () => { walletMock.signTypedData = sinon .stub() .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); - groupClient = new GroupClient(rpcMock, walletMock, "1513"); + groupClient = new GroupClient(rpcMock, walletMock, "1516"); (groupClient.groupingWorkflowsClient as any).address = "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; (groupClient.groupingModuleClient as any).address = diff --git a/packages/core-sdk/test/unit/resources/ipAsset.test.ts b/packages/core-sdk/test/unit/resources/ipAsset.test.ts index 53c836dc..46b57b28 100644 --- a/packages/core-sdk/test/unit/resources/ipAsset.test.ts +++ b/packages/core-sdk/test/unit/resources/ipAsset.test.ts @@ -37,7 +37,7 @@ describe("Test IpAssetClient", () => { walletMock = createMock(); const accountMock = createMock(); walletMock.account = accountMock; - ipAssetClient = new IPAssetClient(rpcMock, walletMock, "iliad"); + ipAssetClient = new IPAssetClient(rpcMock, walletMock, "odyssey"); walletMock.signTypedData = sinon .stub() .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); @@ -206,7 +206,7 @@ describe("Test IpAssetClient", () => { it("should throw account error when register given wallet have no signTypedData ", async () => { const walletMock = createMock(); walletMock.account = createMock(); - ipAssetClient = new IPAssetClient(rpcMock, walletMock, "iliad"); + ipAssetClient = new IPAssetClient(rpcMock, walletMock, "odyssey"); (ipAssetClient.registrationWorkflowsClient as any).address = "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; (ipAssetClient.coreMetadataModuleClient as any).address = @@ -731,6 +731,7 @@ describe("Test IpAssetClient", () => { mintingFee: "100", currency: zeroAddress, recipient: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + royaltyPolicyAddress: zeroAddress, ipMetadata: { ipMetadataURI: "", ipMetadataHash: toHex(0, { size: 32 }), @@ -1112,6 +1113,7 @@ describe("Test IpAssetClient", () => { pilType: PIL_TYPE.COMMERCIAL_USE, mintingFee: "100", currency: zeroAddress, + royaltyPolicyAddress: zeroAddress, }); expect(result.txHash).to.equal(hash); diff --git a/packages/core-sdk/test/unit/resources/license.test.ts b/packages/core-sdk/test/unit/resources/license.test.ts index 576064c9..64aad11d 100644 --- a/packages/core-sdk/test/unit/resources/license.test.ts +++ b/packages/core-sdk/test/unit/resources/license.test.ts @@ -24,7 +24,7 @@ describe("Test LicenseClient", () => { const accountMock = createMock(); accountMock.address = "0x73fcb515cee99e4991465ef586cfe2b072ebb512"; walletMock.account = accountMock; - licenseClient = new LicenseClient(rpcMock, walletMock, "1513"); + licenseClient = new LicenseClient(rpcMock, walletMock, "1516"); }); afterEach(() => { @@ -347,6 +347,7 @@ describe("Test LicenseClient", () => { const result = await licenseClient.registerCommercialUsePIL({ defaultMintingFee: "1", currency: zeroAddress, + royaltyPolicyAddress: zeroAddress, txOptions: { encodedTxDataOnly: true, }, @@ -450,6 +451,7 @@ describe("Test LicenseClient", () => { defaultMintingFee: "1", commercialRevShare: 100, currency: zeroAddress, + royaltyPolicyAddress: zeroAddress, txOptions: { encodedTxDataOnly: true, }, @@ -827,4 +829,242 @@ describe("Test LicenseClient", () => { } }); }); + + describe("Test licenseClient.predictMintingLicenseFee", async () => { + it("should throw register error when call predictMintingLicenseFee given licenseTermsId is not registered", async () => { + sinon.stub(licenseClient.ipAssetRegistryClient, "isRegistered").resolves(false); + try { + await licenseClient.predictMintingLicenseFee({ + licenseTermsId: "1", + licensorIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + amount: "", + }); + } catch (error) { + expect((error as Error).message).equal( + "Failed to predict minting license fee: The licensor IP with id 0x73fcb515cee99e4991465ef586cfe2b072ebb512 is not registered.", + ); + } + }); + + it("should throw licenseTermsId error when call predictMintingLicenseFee given licenseTermsId is not exist", async () => { + sinon.stub(licenseClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon.stub(licenseClient.piLicenseTemplateReadOnlyClient, "exists").resolves(false); + try { + await licenseClient.predictMintingLicenseFee({ + licenseTermsId: "1", + licensorIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + amount: "", + }); + } catch (error) { + expect((error as Error).message).equal( + "Failed to predict minting license fee: License terms id 1 do not exist.", + ); + } + }); + + it("should return currency token and token amount when call predictMintingLicenseFee given licenseTemplate and receiver", async () => { + sinon.stub(licenseClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon.stub(licenseClient.piLicenseTemplateReadOnlyClient, "exists").resolves(true); + sinon.stub(licenseClient.licensingModuleClient, "predictMintingLicenseFee").resolves({ + currencyToken: zeroAddress, + tokenAmount: 1n, + }); + const result = await licenseClient.predictMintingLicenseFee({ + licenseTermsId: "1", + licensorIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + amount: "", + licenseTemplate: zeroAddress, + receiver: zeroAddress, + }); + + expect(result).to.deep.equal({ + currencyToken: zeroAddress, + tokenAmount: 1n, + }); + }); + it("should return currency token and token amount when call predictMintingLicenseFee given correct args ", async () => { + sinon.stub(licenseClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon.stub(licenseClient.piLicenseTemplateReadOnlyClient, "exists").resolves(true); + sinon.stub(licenseClient.licensingModuleClient, "predictMintingLicenseFee").resolves({ + currencyToken: zeroAddress, + tokenAmount: 1n, + }); + const result = await licenseClient.predictMintingLicenseFee({ + licenseTermsId: "1", + licensorIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + amount: "", + }); + + expect(result).to.deep.equal({ + currencyToken: zeroAddress, + tokenAmount: 1n, + }); + }); + }); + + describe("Test licenseClient.setLicensingConfig", async () => { + it("should throw ip registry error when call setLicensingConfig given ip id is not registered", async () => { + sinon.stub(licenseClient.ipAssetRegistryClient, "isRegistered").resolves(false); + try { + await licenseClient.setLicensingConfig({ + ipId: zeroAddress, + licenseTermsId: "1", + licenseTemplate: zeroAddress, + licensingConfig: { + isSet: false, + mintingFee: "", + licensingHook: zeroAddress, + hookData: zeroAddress, + }, + }); + } catch (error) { + expect((error as Error).message).equal( + "Failed to set licensing config: The licensor IP with id 0x0000000000000000000000000000000000000000 is not registered.", + ); + } + }); + + it("should throw licenseTermsId error when call setLicensingConfig given licenseTermsId is not exist", async () => { + sinon.stub(licenseClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon.stub(licenseClient.piLicenseTemplateReadOnlyClient, "exists").resolves(false); + try { + await licenseClient.setLicensingConfig({ + ipId: zeroAddress, + licenseTermsId: "1", + licenseTemplate: zeroAddress, + licensingConfig: { + isSet: false, + mintingFee: "", + licensingHook: zeroAddress, + hookData: zeroAddress, + }, + }); + } catch (error) { + expect((error as Error).message).equal( + "Failed to set licensing config: License terms id 1 do not exist.", + ); + } + }); + + it("should throw license hook error when call setLicensingConfig given license hook is not registered", async () => { + sinon.stub(licenseClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon.stub(licenseClient.piLicenseTemplateReadOnlyClient, "exists").resolves(true); + sinon.stub(licenseClient.moduleRegistryReadOnlyClient, "isRegistered").resolves(false); + try { + await licenseClient.setLicensingConfig({ + ipId: zeroAddress, + licenseTermsId: "1", + licenseTemplate: zeroAddress, + licensingConfig: { + isSet: false, + mintingFee: "", + licensingHook: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + hookData: zeroAddress, + }, + }); + } catch (error) { + expect((error as Error).message).equal( + "Failed to set licensing config: The licensing hook is not registered.", + ); + } + }); + + it("should throw license template and license terms mismatch error when call setLicensingConfig given license template is zero address and license terms id is not zero address", async () => { + sinon.stub(licenseClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon.stub(licenseClient.piLicenseTemplateReadOnlyClient, "exists").resolves(true); + sinon.stub(licenseClient.moduleRegistryReadOnlyClient, "isRegistered").resolves(true); + try { + await licenseClient.setLicensingConfig({ + ipId: zeroAddress, + licenseTermsId: "1", + licenseTemplate: zeroAddress, + licensingConfig: { + isSet: false, + mintingFee: "", + licensingHook: zeroAddress, + hookData: zeroAddress, + }, + }); + } catch (error) { + expect((error as Error).message).equal( + "Failed to set licensing config: licenseTemplate is zero address but licenseTermsId is zero.", + ); + } + }); + + it("should return encodedTxData when call setLicensingConfig given txOptions.encodedTxDataOnly of true and args is correct", async () => { + sinon.stub(licenseClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon.stub(licenseClient.piLicenseTemplateReadOnlyClient, "exists").resolves(true); + sinon.stub(licenseClient.moduleRegistryReadOnlyClient, "isRegistered").resolves(true); + sinon + .stub(licenseClient.licensingModuleClient, "setLicensingConfigEncode") + .returns({ to: zeroAddress, data: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c" }); + + const result = await licenseClient.setLicensingConfig({ + ipId: zeroAddress, + licenseTermsId: "1", + licenseTemplate: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + licensingConfig: { + isSet: false, + mintingFee: "", + licensingHook: zeroAddress, + hookData: zeroAddress, + }, + txOptions: { + encodedTxDataOnly: true, + }, + }); + + expect(result.encodedTxData).to.deep.equal({ + to: zeroAddress, + data: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }); + }); + + it("should return txHash when call setLicensingConfig given args is correct", async () => { + sinon.stub(licenseClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon.stub(licenseClient.piLicenseTemplateReadOnlyClient, "exists").resolves(true); + sinon.stub(licenseClient.moduleRegistryReadOnlyClient, "isRegistered").resolves(true); + sinon.stub(licenseClient.licensingModuleClient, "setLicensingConfig").resolves(txHash); + + const result = await licenseClient.setLicensingConfig({ + ipId: zeroAddress, + licenseTermsId: "1", + licenseTemplate: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + licensingConfig: { + isSet: false, + mintingFee: "", + licensingHook: zeroAddress, + hookData: zeroAddress, + }, + }); + + expect(result.txHash).to.equal(txHash); + }); + + it("should return txHash and success when call setLicensingConfig given args is correct and waitForTransaction of true", async () => { + sinon.stub(licenseClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon.stub(licenseClient.piLicenseTemplateReadOnlyClient, "exists").resolves(true); + sinon.stub(licenseClient.moduleRegistryReadOnlyClient, "isRegistered").resolves(true); + sinon.stub(licenseClient.licensingModuleClient, "setLicensingConfig").resolves(txHash); + + const result = await licenseClient.setLicensingConfig({ + ipId: zeroAddress, + licenseTermsId: "1", + licenseTemplate: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + licensingConfig: { + isSet: false, + mintingFee: "", + licensingHook: zeroAddress, + hookData: zeroAddress, + }, + txOptions: { + waitForTransaction: true, + }, + }); + + expect(result.txHash).to.equal(txHash); + expect(result.success).to.equal(true); + }); + }); }); diff --git a/packages/core-sdk/test/unit/resources/permission.test.ts b/packages/core-sdk/test/unit/resources/permission.test.ts index 23055567..7cbdfa75 100644 --- a/packages/core-sdk/test/unit/resources/permission.test.ts +++ b/packages/core-sdk/test/unit/resources/permission.test.ts @@ -20,7 +20,7 @@ describe("Test Permission", () => { walletMock.signTypedData = sinon .stub() .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); - permissionClient = new PermissionClient(rpcMock, walletMock, "iliad"); + permissionClient = new PermissionClient(rpcMock, walletMock, "odyssey"); sinon .stub(IpAccountImplClient.prototype, "state") .resolves({ result: "0x2e778894d11b5308e4153f094e190496c1e0609652c19f8b87e5176484b9a5e" }); @@ -225,7 +225,7 @@ describe("Test Permission", () => { it("should wallet error when call createSetPermissionSignature given wallet has no signTypedData method", async () => { walletMock = createMock(); - permissionClient = new PermissionClient(rpcMock, walletMock, "1513"); + permissionClient = new PermissionClient(rpcMock, walletMock, "1516"); sinon.stub(permissionClient.ipAssetRegistryClient, "isRegistered").resolves(true); (permissionClient.accessControllerClient as any).address = "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; diff --git a/packages/core-sdk/test/unit/utils/ipfs.test.ts b/packages/core-sdk/test/unit/utils/ipfs.test.ts new file mode 100644 index 00000000..d49862ff --- /dev/null +++ b/packages/core-sdk/test/unit/utils/ipfs.test.ts @@ -0,0 +1,32 @@ +import { expect } from "chai"; +import { convertCIDtoHashIPFS, convertHashIPFStoCID } from "../../../src/utils/ipfs"; +describe("IPFS", () => { + it("should return hash when call convertCIDtoHashIPFS given CID with v0", async () => { + const result = convertCIDtoHashIPFS("QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR"); + expect(result).to.equal("0xc3c4733ec8affd06cf9e9ff50ffc6bcd2ec85a6170004bb709669c31de94391a"); + }); + + it("should return hash when call convertCIDtoHashIPFS given CID with v1", async () => { + const result = convertCIDtoHashIPFS( + "bafybeihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku", + ); + console.log(result); + expect(result).to.equal("0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); + }); + + it("should return CID when call convertHashIPFStoCID given hash with v0", async () => { + const result = convertHashIPFStoCID( + "0xc3c4733ec8affd06cf9e9ff50ffc6bcd2ec85a6170004bb709669c31de94391a", + "v0", + ); + expect(result).to.equal("QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR"); + }); + + it("should return CID when call convertHashIPFStoCID given hash with v1", async () => { + const result = convertHashIPFStoCID( + "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "v1", + ); + expect(result).to.equal("bafybeihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku"); + }); +}); diff --git a/packages/core-sdk/test/unit/utils/licenseTermsHelper.test.ts b/packages/core-sdk/test/unit/utils/licenseTermsHelper.test.ts index dd47dbb3..aba0899e 100644 --- a/packages/core-sdk/test/unit/utils/licenseTermsHelper.test.ts +++ b/packages/core-sdk/test/unit/utils/licenseTermsHelper.test.ts @@ -43,7 +43,7 @@ describe("License Terms Helper", () => { expect(() => getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE, { currency: zeroAddress, - royaltyPolicyLAPAddress: zeroAddress, + royaltyPolicyAddress: zeroAddress, }), ).to.throw("DefaultMintingFee, currency are required for commercial use PIL."); }); @@ -51,7 +51,7 @@ describe("License Terms Helper", () => { it("it should throw when call getLicenseTermByType given COMMERCIAL_USE without currency", async () => { expect(() => getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE, { - royaltyPolicyLAPAddress: zeroAddress, + royaltyPolicyAddress: zeroAddress, defaultMintingFee: "1", }), ).to.throw("DefaultMintingFee, currency are required for commercial use PIL."); @@ -60,7 +60,7 @@ describe("License Terms Helper", () => { it("it should throw when call getLicenseTermByType given COMMERCIAL_USE and wrong royaltyAddress", async () => { expect(() => getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE, { - royaltyPolicyLAPAddress: "wrong" as Hex, + royaltyPolicyAddress: "wrong" as Hex, defaultMintingFee: "1", currency: zeroAddress, }), @@ -71,7 +71,7 @@ describe("License Terms Helper", () => { it("it should return commercial license terms when call getLicenseTermByType given COMMERCIAL_USE and correct args", async () => { const result = getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE, { - royaltyPolicyLAPAddress: zeroAddress, + royaltyPolicyAddress: zeroAddress, defaultMintingFee: "1", currency: zeroAddress, }); @@ -108,7 +108,7 @@ describe("License Terms Helper", () => { expect(() => getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { currency: zeroAddress, - royaltyPolicyLAPAddress: zeroAddress, + royaltyPolicyAddress: zeroAddress, commercialRevShare: 100, }), ).to.throw( @@ -119,7 +119,7 @@ describe("License Terms Helper", () => { it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX without currency", async () => { expect(() => getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { - royaltyPolicyLAPAddress: zeroAddress, + royaltyPolicyAddress: zeroAddress, defaultMintingFee: "1", commercialRevShare: 100, }), @@ -131,7 +131,7 @@ describe("License Terms Helper", () => { it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX and wrong royaltyAddress", async () => { expect(() => getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { - royaltyPolicyLAPAddress: "wrong" as Hex, + royaltyPolicyAddress: "wrong" as Hex, defaultMintingFee: "1", currency: zeroAddress, commercialRevShare: 100, @@ -144,7 +144,7 @@ describe("License Terms Helper", () => { it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX without commercialRevShare ", async () => { expect(() => getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { - royaltyPolicyLAPAddress: "wrong" as Hex, + royaltyPolicyAddress: "wrong" as Hex, defaultMintingFee: "1", currency: zeroAddress, }), @@ -155,7 +155,7 @@ describe("License Terms Helper", () => { it("it should return commercial license terms when call getLicenseTermByType given COMMERCIAL_REMIX and correct args", async () => { const result = getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { - royaltyPolicyLAPAddress: zeroAddress, + royaltyPolicyAddress: zeroAddress, defaultMintingFee: "1", currency: zeroAddress, commercialRevShare: 100, @@ -183,7 +183,7 @@ describe("License Terms Helper", () => { it("it throw commercialRevShare error when call getLicenseTermByType given COMMERCIAL_REMIX and commercialRevShare is less than 0 ", async () => { expect(() => getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { - royaltyPolicyLAPAddress: zeroAddress, + royaltyPolicyAddress: zeroAddress, defaultMintingFee: "1", currency: zeroAddress, commercialRevShare: -8, @@ -194,7 +194,7 @@ describe("License Terms Helper", () => { it("it throw commercialRevShare error when call getLicenseTermByType given COMMERCIAL_REMIX and commercialRevShare is greater than 100", async () => { expect(() => getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { - royaltyPolicyLAPAddress: zeroAddress, + royaltyPolicyAddress: zeroAddress, defaultMintingFee: "1", currency: zeroAddress, commercialRevShare: 105, @@ -204,7 +204,7 @@ describe("License Terms Helper", () => { it("it get commercialRevShare correct value when call getLicenseTermByType given COMMERCIAL_REMIX and commercialRevShare is 10", async () => { const result = getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { - royaltyPolicyLAPAddress: zeroAddress, + royaltyPolicyAddress: zeroAddress, defaultMintingFee: "1", currency: zeroAddress, commercialRevShare: 10, diff --git a/packages/core-sdk/test/unit/utils/sign.test.ts b/packages/core-sdk/test/unit/utils/sign.test.ts index ecf742f6..0dd526db 100644 --- a/packages/core-sdk/test/unit/utils/sign.test.ts +++ b/packages/core-sdk/test/unit/utils/sign.test.ts @@ -2,7 +2,7 @@ import { expect } from "chai"; import { getDeadline, getPermissionSignature } from "../../../src/utils/sign"; import { Hex, WalletClient, createWalletClient, http, zeroAddress } from "viem"; import { privateKeyToAccount } from "viem/accounts"; -import { iliadChainId } from "../../integration/utils/util"; +import { odyssey } from "../../integration/utils/util"; import sinon from "sinon"; import { chainStringToViemChain } from "../../../src/utils/utils"; @@ -16,7 +16,7 @@ describe("Sign", () => { deadline: 1000n, permissions: [], wallet: {} as WalletClient, - chainId: BigInt(iliadChainId), + chainId: BigInt(odyssey), }); } catch (e) { expect((e as Error).message).to.equal( @@ -33,7 +33,7 @@ describe("Sign", () => { deadline: 1000n, permissions: [], wallet: { signTypedData: () => Promise.resolve("") } as unknown as WalletClient, - chainId: BigInt(iliadChainId), + chainId: BigInt(odyssey), }); } catch (e) { expect((e as Error).message).to.equal( @@ -44,7 +44,7 @@ describe("Sign", () => { it("should return signature when call getPermissionSignature given account support signTypedData", async () => { const walletClient = createWalletClient({ - chain: chainStringToViemChain("iliad"), + chain: chainStringToViemChain("odyssey"), transport: http(), account: privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as Hex), }); @@ -54,7 +54,7 @@ describe("Sign", () => { deadline: 1000n, permissions: [{ ipId: zeroAddress, signer: zeroAddress, to: zeroAddress, permission: 0 }], wallet: walletClient, - chainId: BigInt(iliadChainId), + chainId: BigInt(odyssey), }); expect(result).is.a("string").and.not.empty; }); diff --git a/packages/core-sdk/test/unit/utils/utils.test.ts b/packages/core-sdk/test/unit/utils/utils.test.ts index a7f5d9b0..ee4c8939 100644 --- a/packages/core-sdk/test/unit/utils/utils.test.ts +++ b/packages/core-sdk/test/unit/utils/utils.test.ts @@ -10,7 +10,7 @@ import { } from "../../../src/utils/utils"; import { createMock } from "../testUtils"; import { licensingModuleAbi } from "../../../src/abi/generated"; -import { iliad } from "../../../src/index"; +import { odyssey } from "../../../src"; describe("Test waitTxAndFilterLog", () => { const txHash = "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"; @@ -152,13 +152,13 @@ describe("Test chainStringToViemChain", () => { } }); - it("should return iliad testnet if id is 1513", () => { - const chain = chainStringToViemChain("1513"); - expect(chain).to.equal(iliad); + it("should return iliad testnet if id is 1516", () => { + const chain = chainStringToViemChain("1516"); + expect(chain).to.equal(odyssey); }); it("should return iliad testnet if id is iliad", () => { - const chain = chainStringToViemChain("iliad"); - expect(chain).to.equal(iliad); + const chain = chainStringToViemChain("odyssey"); + expect(chain).to.equal(odyssey); }); }); diff --git a/packages/react-sdk/test/integration/utils/util.ts b/packages/react-sdk/test/integration/utils/util.ts index eeb80166..ed365285 100644 --- a/packages/react-sdk/test/integration/utils/util.ts +++ b/packages/react-sdk/test/integration/utils/util.ts @@ -46,9 +46,7 @@ export const walletClient = createWalletClient({ account: privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as Hex), }); -export const getTokenId = async ( - nftContract?: Address -): Promise => { +export const getTokenId = async (): Promise => { const { request } = await publicClient.simulateContract({ abi: [ { diff --git a/packages/wagmi-generator/wagmi.config.ts b/packages/wagmi-generator/wagmi.config.ts index 094a9a65..3fd74424 100644 --- a/packages/wagmi-generator/wagmi.config.ts +++ b/packages/wagmi-generator/wagmi.config.ts @@ -4,7 +4,7 @@ import type { Evaluate } from "@wagmi/cli/src/types"; import type { ContractConfig } from "@wagmi/cli/src/config"; import { resolveProxyContracts } from "./resolveProxyContracts"; import { optimizedBlockExplorer } from "./optimizedBlockExplorer"; -const iliadChainId = 1513; +const odysseyChainId = 1516; import "dotenv/config"; export default defineConfig(async () => { @@ -12,151 +12,145 @@ export default defineConfig(async () => { { name: "AccessController", address: { - [iliadChainId]: "0xbcaD7EA76Ee68Cc507874e9050a7E7D7ff07BB09", + [odysseyChainId]: "0xf709c8001E94e2ca6F98b7fFBCd5BD3943E46D81", }, }, { name: "DisputeModule", address: { - [iliadChainId]: "0x26525b4A1c2261A27B9ee89D512c2f7DceF85f4a", + [odysseyChainId]: "0x692B47fa72eE7Ac0Ec617ea384a0cAD41098F712", }, }, { name: "IPAccountImpl", address: { - [iliadChainId]: "0xaE2D8F01920DB2328BEd676652154c9D2Cb863fa", + [odysseyChainId]: "0x24F08796561d6E1AC08e82b68BF4d9500B374Af6", }, }, { name: "IPAssetRegistry", address: { - [iliadChainId]: "0x14CAB45705Fe73EC6d126518E59Fe3C61a181E40", + [odysseyChainId]: "0x28E59E91C0467e89fd0f0438D47Ca839cDfEc095", }, }, { name: "IpRoyaltyVaultImpl", address: { - [iliadChainId]: "0x604dc8E58f720DEB345B2F3e08B2B354eA6CE498", + [odysseyChainId]: "0x1081250219B16cc3903Aa2d2d1403A75c6A2F9f5", }, }, { name: "LicenseRegistry", address: { - [iliadChainId]: "0x4D71a082DE74B40904c1d89d9C3bfB7079d4c542", + [odysseyChainId]: "0xBda3992c49E98392e75E78d82B934F3598bA495f", }, }, { name: "LicenseToken", address: { - [iliadChainId]: "0xd8aEF404432a2b3363479A6157285926B6B3b743", + [odysseyChainId]: "0xB138aEd64814F2845554f9DBB116491a077eEB2D", }, }, { name: "LicensingModule", address: { - [iliadChainId]: "0xC8f165950411504eA130692B87A7148e469f7090", + [odysseyChainId]: "0x5a7D9Fa17DE09350F481A53B470D798c1c1aabae", }, }, { name: "PILicenseTemplate", address: { - [iliadChainId]: "0xbB7ACFBE330C56aA9a3aEb84870743C3566992c3", + [odysseyChainId]: "0x58E2c909D557Cd23EF90D14f8fd21667A5Ae7a93", }, }, { name: "ModuleRegistry", address: { - [iliadChainId]: "0x47bEae573B73F8BF1B4fa4Af065c39743871003f", + [odysseyChainId]: "0x9F18c5723BC4Ee447CF9B01a8543D3b08b7F09C7", }, }, { name: "RoyaltyModule", address: { - [iliadChainId]: "0xaCb5764E609aa3a5ED36bA74ba59679246Cb0963", + [odysseyChainId]: "0xEa6eD700b11DfF703665CCAF55887ca56134Ae3B", }, }, { name: "RoyaltyPolicyLAP", address: { - [iliadChainId]: "0x793Df8d32c12B0bE9985FFF6afB8893d347B6686", + [odysseyChainId]: "0x28b4F70ffE5ba7A26aEF979226f77Eb57fb9Fdb6", }, }, { name: "RoyaltyPolicyLRP", address: { - [iliadChainId]: "0x1eF035c7054bd45e25B2a29A06a37b1350F50596", + [odysseyChainId]: "0x7D2d9af4E4ab14Afcfd86436BC348928B40963Dd", }, }, { name: "SPGNFTBeacon", address: { - [iliadChainId]: "0x02324ca8f369abB445F50c4cE79e956e49AC75d8", + [odysseyChainId]: "0x4b913A9da52806A0fd0b031bdf32fa33634d082a", }, }, { name: "SPGNFTImpl", address: { - [iliadChainId]: "0xC8E4376Da033cE244027B03f9b94dc0d7005D67E", + [odysseyChainId]: "0x32c03CD2B4CC3456aCD86C7d5BA8E0405665DbF9", }, }, { name: "CoreMetadataModule", address: { - [iliadChainId]: "0xa71Bd7aff91Da5E27A6f96c546D489F6e0870E45", + [odysseyChainId]: "0x89630Ccf23277417FBdfd3076C702F5248267e78", }, }, { name: "DerivativeWorkflows", address: { - [iliadChainId]: "0xC022C70DA8c23Ae8e36B3de9039Ed24E4E42a127", + [odysseyChainId]: "0xa8815CEB96857FFb8f5F8ce920b1Ae6D70254C7B", }, }, { name: "GroupingWorkflows", address: { - [iliadChainId]: "0x426fF4F7E9Debe565F5Fe6F53334Ad3982295E20", + [odysseyChainId]: "0xcd754994eBE5Ce16D432C1f936f98ac0d4aABA0e", }, }, { name: "RegistrationWorkflows", address: { - [iliadChainId]: "0xF403fcCAAE6C503D0CC1D25904A0B2cCd5B96C6F", + [odysseyChainId]: "0xde13Be395E1cd753471447Cf6A656979ef87881c", }, }, { name: "RoyaltyWorkflows", address: { - [iliadChainId]: "0xc757921ee0f7c8E935d44BFBDc2602786e0eda6C", + [odysseyChainId]: "0xAf922379B8e1abc6B0D78547128579221C7F7A22", }, }, { name: "LicenseAttachmentWorkflows", address: { - [iliadChainId]: "0x1B95144b62B4566501482e928aa435Dd205fE71B", + [odysseyChainId]: "0x44Bad1E4035a44eAC1606B222873E4a85E8b7D9c", }, }, { name: "GroupingModule", address: { - [iliadChainId]: "0xaB7a16Ad9e46656C59e6071d920feeE7A3416ECf", + [odysseyChainId]: "0xa731948cfE05135ad77d48C71f75066333Da78Bf", }, }, { name: "EvenSplitGroupPool", address: { - [iliadChainId]: "0xA1dB7AB14900Cd9eF9A7eBA931A206250F403a14", - }, - }, - { - name: "ArbitrationPolicySP", - address: { - [iliadChainId]: "0x8038697357F63415e848785e45B00eB60BcD797b", + [odysseyChainId]: "0xC384B56fD62d6679Cd62A2fE0dA3fe4560f33391", }, }, { name: "MockERC20", address: { - [iliadChainId]: "0x91f6F05B08c16769d3c85867548615d270C42fC7", + [odysseyChainId]: "0x12A8b0DcC6e3bB0915638361D9D49942Da07F455", }, }, ]; @@ -165,12 +159,12 @@ export default defineConfig(async () => { contracts: [], plugins: [ optimizedBlockExplorer({ - baseUrl: "https://testnet.storyscan.xyz/api", - name: "iliad", + baseUrl: "https://odyssey-testnet-explorer.storyscan.xyz/api", + name: "Odyssey", getAddress: await resolveProxyContracts({ - baseUrl: "https://testnet.storyrpc.io", + baseUrl: "https://odyssey.storyrpc.io/", contracts: contracts, - chainId: iliadChainId, + chainId: odysseyChainId, }), contracts: contracts, }), @@ -224,6 +218,7 @@ export default defineConfig(async () => { "getLicenseTerms", "LicenseTermsAttached", "predictMintingLicenseFee", + "setLicensingConfig", ], ModuleRegistry: ["isRegistered", "getDefaultLicenseTerms"], RoyaltyModule: [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c7d8e8c8..f9c8ba7f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,9 +26,15 @@ importers: axios: specifier: ^1.5.1 version: 1.6.8 + bs58: + specifier: ^6.0.0 + version: 6.0.0 dotenv: specifier: ^16.3.1 version: 16.4.5 + multiformats: + specifier: 9.9.0 + version: 9.9.0 viem: specifier: ^2.8.12 version: 2.9.16(typescript@5.4.5)(zod@3.23.8) @@ -5380,6 +5386,10 @@ packages: /balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + /base-x@5.0.0: + resolution: {integrity: sha512-sMW3VGSX1QWVFA6l8U62MLKz29rRfpTlYdCqLdpLo1/Yd4zZwSbnUaDfciIAowAqvq7YFnWq9hrhdg1KYgc1lQ==} + dev: false + /base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} dev: true @@ -5466,6 +5476,12 @@ packages: update-browserslist-db: 1.0.13(browserslist@4.23.0) dev: true + /bs58@6.0.0: + resolution: {integrity: sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw==} + dependencies: + base-x: 5.0.0 + dev: false + /bser@2.1.1: resolution: {integrity: sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==} dependencies: @@ -9555,7 +9571,6 @@ packages: /multiformats@9.9.0: resolution: {integrity: sha512-HoMUjhH9T8DDBNT+6xzkrd9ga/XiBI4xLr58LJACwK6G3HTOPeMz4nB4KJs33L2BelrIJa7P0VuNaVF3hMYfjg==} - dev: true /natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==}