diff --git a/packages/core-sdk/package.json b/packages/core-sdk/package.json index 5301d49f..96e48020 100644 --- a/packages/core-sdk/package.json +++ b/packages/core-sdk/package.json @@ -17,7 +17,7 @@ ], "scripts": { "build": "pnpm run fix && preconstruct build", - "test": "pnpm run test:unit && pnpm run test:integration", + "test": "pnpm run test:unit", "test:unit": "TS_NODE_PROJECT='./tsconfig.test.json' c8 --all --src ./src mocha -r ts-node/register './test/unit/**/*.test.ts'", "test:integration": "TS_NODE_PROJECT='./tsconfig.test.json' mocha -r ts-node/register './test/integration/**/*.test.ts' --timeout 240000", "fix": "pnpm run format:fix && pnpm run lint:fix", diff --git a/packages/core-sdk/src/abi/generated.ts b/packages/core-sdk/src/abi/generated.ts index 5af6166f..1d31e9df 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: "0x01d470c28822d3701Db6325333cEE9737524776E", + 1513: "0xbcaD7EA76Ee68Cc507874e9050a7E7D7ff07BB09", } as const; /** @@ -401,6 +401,265 @@ 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 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -691,7 +950,7 @@ export const coreMetadataModuleAbi = [ * */ export const coreMetadataModuleAddress = { - 1513: "0x290F414EA46b361ECFB6b430F98346CB593D02b9", + 1513: "0xa71Bd7aff91Da5E27A6f96c546D489F6e0870E45", } as const; /** @@ -703,28 +962,27 @@ export const coreMetadataModuleConfig = { } as const; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// DisputeModule +// DerivativeWorkflows ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * */ -export const disputeModuleAbi = [ +export const derivativeWorkflowsAbi = [ { type: "constructor", inputs: [ { name: "accessController", internalType: "address", type: "address" }, + { name: "coreMetadataModule", internalType: "address", type: "address" }, { name: "ipAssetRegistry", internalType: "address", type: "address" }, { name: "licenseRegistry", internalType: "address", type: "address" }, + { name: "licenseToken", internalType: "address", type: "address" }, + { name: "licensingModule", internalType: "address", type: "address" }, + { name: "pilTemplate", internalType: "address", type: "address" }, + { name: "royaltyModule", internalType: "address", type: "address" }, ], stateMutability: "nonpayable", }, - { - type: "error", - inputs: [{ name: "ipAccount", internalType: "address", type: "address" }], - name: "AccessControlled__NotIpAccount", - }, - { type: "error", inputs: [], name: "AccessControlled__ZeroAddress" }, { type: "error", inputs: [{ name: "authority", internalType: "address", type: "address" }], @@ -748,62 +1006,39 @@ export const disputeModuleAbi = [ inputs: [{ name: "target", internalType: "address", type: "address" }], name: "AddressEmptyCode", }, - { type: "error", inputs: [], name: "DisputeModule__NotAbleToResolve" }, - { type: "error", inputs: [], name: "DisputeModule__NotAllowedToWhitelist" }, - { type: "error", inputs: [], name: "DisputeModule__NotDerivative" }, - { type: "error", inputs: [], name: "DisputeModule__NotDisputeInitiator" }, - { type: "error", inputs: [], name: "DisputeModule__NotInDisputeState" }, - { type: "error", inputs: [], name: "DisputeModule__NotRegisteredIpId" }, { type: "error", - inputs: [], - name: "DisputeModule__NotWhitelistedArbitrationPolicy", - }, - { - type: "error", - inputs: [], - name: "DisputeModule__NotWhitelistedArbitrationRelayer", - }, - { - type: "error", - inputs: [], - name: "DisputeModule__NotWhitelistedDisputeTag", + inputs: [{ name: "account", internalType: "address", type: "address" }], + name: "AddressInsufficientBalance", }, { type: "error", - inputs: [], - name: "DisputeModule__ParentDisputeNotResolved", + inputs: [ + { name: "tokenId", internalType: "uint256", type: "uint256" }, + { name: "caller", internalType: "address", type: "address" }, + { name: "actualTokenOwner", internalType: "address", type: "address" }, + ], + name: "DerivativeWorkflows__CallerAndNotTokenOwner", }, - { type: "error", inputs: [], name: "DisputeModule__ParentIpIdMismatch" }, - { type: "error", inputs: [], name: "DisputeModule__ParentNotTagged" }, - { type: "error", inputs: [], name: "DisputeModule__ZeroAccessController" }, - { type: "error", inputs: [], name: "DisputeModule__ZeroAccessManager" }, - { type: "error", inputs: [], name: "DisputeModule__ZeroArbitrationPolicy" }, - { type: "error", inputs: [], name: "DisputeModule__ZeroArbitrationRelayer" }, - { type: "error", inputs: [], name: "DisputeModule__ZeroDisputeTag" }, - { type: "error", inputs: [], name: "DisputeModule__ZeroIPAssetRegistry" }, - { type: "error", inputs: [], name: "DisputeModule__ZeroLicenseRegistry" }, { type: "error", inputs: [], - name: "DisputeModule__ZeroLinkToDisputeEvidence", + name: "DerivativeWorkflows__EmptyLicenseTokens", }, + { type: "error", inputs: [], name: "DerivativeWorkflows__ZeroAddressParam" }, { type: "error", inputs: [{ name: "implementation", internalType: "address", type: "address" }], name: "ERC1967InvalidImplementation", }, { type: "error", inputs: [], name: "ERC1967NonPayable" }, - { type: "error", inputs: [], name: "EnforcedPause" }, - { type: "error", inputs: [], name: "ExpectedPause" }, { type: "error", inputs: [], name: "FailedInnerCall" }, { type: "error", inputs: [], name: "InvalidInitialization" }, { type: "error", inputs: [], name: "NotInitializing" }, - { type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" }, { type: "error", - inputs: [{ name: "str", internalType: "string", type: "string" }], - name: "StringTooLong", + inputs: [{ name: "token", internalType: "address", type: "address" }], + name: "SafeERC20FailedOperation", }, { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, { @@ -811,59 +1046,7 @@ export const disputeModuleAbi = [ inputs: [{ name: "slot", internalType: "bytes32", type: "bytes32" }], name: "UUPSUnsupportedProxiableUUID", }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "ipId", - internalType: "address", - type: "address", - indexed: false, - }, - { - name: "arbitrationPolicy", - internalType: "address", - type: "address", - indexed: false, - }, - ], - name: "ArbitrationPolicySet", - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "arbitrationPolicy", - internalType: "address", - type: "address", - indexed: false, - }, - { name: "allowed", internalType: "bool", type: "bool", indexed: false }, - ], - name: "ArbitrationPolicyWhitelistUpdated", - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "arbitrationPolicy", - internalType: "address", - type: "address", - indexed: false, - }, - { - name: "arbitrationRelayer", - internalType: "address", - type: "address", - indexed: false, - }, - { name: "allowed", internalType: "bool", type: "bool", indexed: false }, - ], - name: "ArbitrationRelayerWhitelistUpdated", - }, + { type: "error", inputs: [], name: "Workflow__CallerNotAuthorizedToMint" }, { type: "event", anonymous: false, @@ -877,131 +1060,6 @@ export const disputeModuleAbi = [ ], name: "AuthorityUpdated", }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "arbitrationPolicy", - internalType: "address", - type: "address", - indexed: false, - }, - ], - name: "DefaultArbitrationPolicyUpdated", - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "parentIpId", - internalType: "address", - type: "address", - indexed: false, - }, - { - name: "derivativeIpId", - internalType: "address", - type: "address", - indexed: false, - }, - { - name: "parentDisputeId", - internalType: "uint256", - type: "uint256", - indexed: false, - }, - { name: "tag", internalType: "bytes32", type: "bytes32", indexed: false }, - ], - name: "DerivativeTaggedOnParentInfringement", - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "disputeId", - internalType: "uint256", - type: "uint256", - indexed: false, - }, - { name: "data", internalType: "bytes", type: "bytes", indexed: false }, - ], - name: "DisputeCancelled", - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "disputeId", - internalType: "uint256", - type: "uint256", - indexed: false, - }, - { name: "decision", internalType: "bool", type: "bool", indexed: false }, - { name: "data", internalType: "bytes", type: "bytes", indexed: false }, - ], - name: "DisputeJudgementSet", - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "disputeId", - internalType: "uint256", - type: "uint256", - indexed: false, - }, - { - name: "targetIpId", - internalType: "address", - type: "address", - indexed: false, - }, - { - name: "disputeInitiator", - internalType: "address", - type: "address", - indexed: false, - }, - { - name: "arbitrationPolicy", - internalType: "address", - type: "address", - indexed: false, - }, - { - name: "linkToDisputeEvidence", - internalType: "bytes32", - type: "bytes32", - indexed: false, - }, - { - name: "targetTag", - internalType: "bytes32", - type: "bytes32", - indexed: false, - }, - { name: "data", internalType: "bytes", type: "bytes", indexed: false }, - ], - name: "DisputeRaised", - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "disputeId", - internalType: "uint256", - type: "uint256", - indexed: false, - }, - ], - name: "DisputeResolved", - }, { type: "event", anonymous: false, @@ -1015,41 +1073,6 @@ export const disputeModuleAbi = [ ], name: "Initialized", }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "account", - internalType: "address", - type: "address", - indexed: false, - }, - ], - name: "Paused", - }, - { - type: "event", - anonymous: false, - inputs: [ - { name: "tag", internalType: "bytes32", type: "bytes32", indexed: false }, - { name: "allowed", internalType: "bool", type: "bool", indexed: false }, - ], - name: "TagWhitelistUpdated", - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "account", - internalType: "address", - type: "address", - indexed: false, - }, - ], - name: "Unpaused", - }, { type: "event", anonymous: false, @@ -1073,18 +1096,11 @@ export const disputeModuleAbi = [ { type: "function", inputs: [], - name: "IN_DISPUTE", - outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [], - name: "IP_ACCOUNT_REGISTRY", + name: "CORE_METADATA_MODULE", outputs: [ { name: "", - internalType: "contract IIPAccountRegistry", + internalType: "contract ICoreMetadataModule", type: "address", }, ], @@ -1107,72 +1123,49 @@ export const disputeModuleAbi = [ { type: "function", inputs: [], - name: "UPGRADE_INTERFACE_VERSION", - outputs: [{ name: "", internalType: "string", type: "string" }], + name: "LICENSE_TOKEN", + outputs: [{ name: "", internalType: "contract ILicenseToken", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "accessManager", internalType: "address", type: "address" }], - name: "__ProtocolPausable_init", - outputs: [], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [{ name: "ipId", internalType: "address", type: "address" }], - name: "arbitrationPolicies", - outputs: [{ name: "policy", internalType: "address", type: "address" }], + inputs: [], + name: "LICENSING_MODULE", + outputs: [{ name: "", internalType: "contract ILicensingModule", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "authority", - outputs: [{ name: "", internalType: "address", type: "address" }], + name: "PIL_TEMPLATE", + outputs: [ + { + name: "", + internalType: "contract IPILicenseTemplate", + type: "address", + }, + ], stateMutability: "view", }, { type: "function", inputs: [], - name: "baseArbitrationPolicy", - outputs: [{ name: "", internalType: "address", type: "address" }], + name: "ROYALTY_MODULE", + outputs: [{ name: "", internalType: "contract IRoyaltyModule", type: "address" }], stateMutability: "view", }, - { - type: "function", - inputs: [ - { name: "disputeId", internalType: "uint256", type: "uint256" }, - { name: "data", internalType: "bytes", type: "bytes" }, - ], - name: "cancelDispute", - outputs: [], - stateMutability: "nonpayable", - }, { type: "function", inputs: [], - name: "disputeCounter", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + name: "UPGRADE_INTERFACE_VERSION", + outputs: [{ name: "", internalType: "string", type: "string" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "disputeId", internalType: "uint256", type: "uint256" }], - name: "disputes", - outputs: [ - { name: "targetIpId", internalType: "address", type: "address" }, - { name: "disputeInitiator", internalType: "address", type: "address" }, - { name: "arbitrationPolicy", internalType: "address", type: "address" }, - { - name: "linkToDisputeEvidence", - internalType: "bytes32", - type: "bytes32", - }, - { name: "targetTag", internalType: "bytes32", type: "bytes32" }, - { name: "currentTag", internalType: "bytes32", type: "bytes32" }, - { name: "parentDisputeId", internalType: "uint256", type: "uint256" }, - ], + inputs: [], + name: "authority", + outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { @@ -1189,36 +1182,70 @@ export const disputeModuleAbi = [ outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], stateMutability: "view", }, - { - type: "function", - inputs: [{ name: "ipId", internalType: "address", type: "address" }], - name: "isIpTagged", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [{ name: "arbitrationPolicy", internalType: "address", type: "address" }], - name: "isWhitelistedArbitrationPolicy", - outputs: [{ name: "allowed", internalType: "bool", type: "bool" }], - stateMutability: "view", - }, { type: "function", inputs: [ - { name: "arbitrationPolicy", internalType: "address", type: "address" }, - { name: "arbitrationRelayer", internalType: "address", type: "address" }, + { name: "spgNftContract", internalType: "address", type: "address" }, + { + name: "derivData", + internalType: "struct WorkflowStructs.MakeDerivative", + type: "tuple", + components: [ + { name: "parentIpIds", internalType: "address[]", type: "address[]" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { + name: "licenseTermsIds", + internalType: "uint256[]", + type: "uint256[]", + }, + { name: "royaltyContext", internalType: "bytes", type: "bytes" }, + ], + }, + { + name: "ipMetadata", + internalType: "struct WorkflowStructs.IPMetadata", + type: "tuple", + components: [ + { name: "ipMetadataURI", internalType: "string", type: "string" }, + { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, + { name: "nftMetadataURI", internalType: "string", type: "string" }, + { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, + ], + }, + { name: "recipient", internalType: "address", type: "address" }, ], - name: "isWhitelistedArbitrationRelayer", - outputs: [{ name: "allowed", internalType: "bool", type: "bool" }], - stateMutability: "view", + name: "mintAndRegisterIpAndMakeDerivative", + outputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + ], + stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "tag", internalType: "bytes32", type: "bytes32" }], - name: "isWhitelistedDisputeTag", - outputs: [{ name: "allowed", internalType: "bool", type: "bool" }], - stateMutability: "view", + inputs: [ + { name: "spgNftContract", internalType: "address", type: "address" }, + { name: "licenseTokenIds", internalType: "uint256[]", type: "uint256[]" }, + { name: "royaltyContext", internalType: "bytes", type: "bytes" }, + { + name: "ipMetadata", + internalType: "struct WorkflowStructs.IPMetadata", + type: "tuple", + components: [ + { name: "ipMetadataURI", internalType: "string", type: "string" }, + { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, + { name: "nftMetadataURI", internalType: "string", type: "string" }, + { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, + ], + }, + { name: "recipient", internalType: "address", type: "address" }, + ], + name: "mintAndRegisterIpAndMakeDerivativeWithLicenseTokens", + outputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + ], + stateMutability: "nonpayable", }, { type: "function", @@ -1229,25 +1256,16 @@ export const disputeModuleAbi = [ }, { type: "function", - inputs: [], - name: "name", - outputs: [{ name: "", internalType: "string", type: "string" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [], - name: "pause", - outputs: [], + inputs: [ + { name: "", internalType: "address", type: "address" }, + { name: "", internalType: "address", type: "address" }, + { name: "", internalType: "uint256", type: "uint256" }, + { name: "", internalType: "bytes", type: "bytes" }, + ], + name: "onERC721Received", + outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], stateMutability: "nonpayable", }, - { - type: "function", - inputs: [], - name: "paused", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "view", - }, { type: "function", inputs: [], @@ -1258,82 +1276,119 @@ export const disputeModuleAbi = [ { type: "function", inputs: [ - { name: "targetIpId", internalType: "address", type: "address" }, - { name: "linkToDisputeEvidence", internalType: "string", type: "string" }, - { name: "targetTag", internalType: "bytes32", type: "bytes32" }, - { name: "data", internalType: "bytes", type: "bytes" }, + { name: "nftContract", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + { + name: "derivData", + internalType: "struct WorkflowStructs.MakeDerivative", + type: "tuple", + components: [ + { name: "parentIpIds", internalType: "address[]", type: "address[]" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { + name: "licenseTermsIds", + internalType: "uint256[]", + type: "uint256[]", + }, + { name: "royaltyContext", internalType: "bytes", type: "bytes" }, + ], + }, + { + name: "ipMetadata", + internalType: "struct WorkflowStructs.IPMetadata", + type: "tuple", + components: [ + { name: "ipMetadataURI", internalType: "string", type: "string" }, + { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, + { name: "nftMetadataURI", internalType: "string", type: "string" }, + { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, + ], + }, + { + name: "sigMetadata", + internalType: "struct WorkflowStructs.SignatureData", + type: "tuple", + components: [ + { name: "signer", internalType: "address", type: "address" }, + { name: "deadline", internalType: "uint256", type: "uint256" }, + { name: "signature", internalType: "bytes", type: "bytes" }, + ], + }, + { + name: "sigRegister", + internalType: "struct WorkflowStructs.SignatureData", + type: "tuple", + components: [ + { name: "signer", internalType: "address", type: "address" }, + { name: "deadline", internalType: "uint256", type: "uint256" }, + { name: "signature", internalType: "bytes", type: "bytes" }, + ], + }, ], - name: "raiseDispute", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + name: "registerIpAndMakeDerivative", + outputs: [{ name: "ipId", internalType: "address", type: "address" }], stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "disputeId", internalType: "uint256", type: "uint256" }, - { name: "data", internalType: "bytes", type: "bytes" }, + { name: "nftContract", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + { name: "licenseTokenIds", internalType: "uint256[]", type: "uint256[]" }, + { name: "royaltyContext", internalType: "bytes", type: "bytes" }, + { + name: "ipMetadata", + internalType: "struct WorkflowStructs.IPMetadata", + type: "tuple", + components: [ + { name: "ipMetadataURI", internalType: "string", type: "string" }, + { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, + { name: "nftMetadataURI", internalType: "string", type: "string" }, + { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, + ], + }, + { + name: "sigMetadata", + internalType: "struct WorkflowStructs.SignatureData", + type: "tuple", + components: [ + { name: "signer", internalType: "address", type: "address" }, + { name: "deadline", internalType: "uint256", type: "uint256" }, + { name: "signature", internalType: "bytes", type: "bytes" }, + ], + }, + { + name: "sigRegister", + internalType: "struct WorkflowStructs.SignatureData", + type: "tuple", + components: [ + { name: "signer", internalType: "address", type: "address" }, + { name: "deadline", internalType: "uint256", type: "uint256" }, + { name: "signature", internalType: "bytes", type: "bytes" }, + ], + }, ], - name: "resolveDispute", + name: "registerIpAndMakeDerivativeWithLicenseTokens", + outputs: [{ name: "ipId", internalType: "address", type: "address" }], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "newAuthority", internalType: "address", type: "address" }], + name: "setAuthority", outputs: [], stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "arbitrationPolicy", internalType: "address", type: "address" }, - ], - name: "setArbitrationPolicy", - outputs: [], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [{ name: "newAuthority", internalType: "address", type: "address" }], - name: "setAuthority", - outputs: [], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [{ name: "arbitrationPolicy", internalType: "address", type: "address" }], - name: "setBaseArbitrationPolicy", - 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: "setDisputeJudgement", - outputs: [], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }], - name: "supportsInterface", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [ - { name: "parentIpId", internalType: "address", type: "address" }, - { name: "derivativeIpId", internalType: "address", type: "address" }, - { name: "parentDisputeId", internalType: "uint256", type: "uint256" }, + { + name: "newNftContractBeacon", + internalType: "address", + type: "address", + }, ], - name: "tagDerivativeIfParentInfringed", - outputs: [], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [], - name: "unpause", + name: "setNftContractBeacon", outputs: [], stateMutability: "nonpayable", }, @@ -1347,652 +1402,785 @@ export const disputeModuleAbi = [ outputs: [], stateMutability: "payable", }, - { - type: "function", - inputs: [ - { name: "arbitrationPolicy", internalType: "address", type: "address" }, - { name: "allowed", internalType: "bool", type: "bool" }, - ], - name: "whitelistArbitrationPolicy", - outputs: [], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [ - { name: "arbitrationPolicy", internalType: "address", type: "address" }, - { name: "arbPolicyRelayer", internalType: "address", type: "address" }, - { name: "allowed", internalType: "bool", type: "bool" }, - ], - name: "whitelistArbitrationRelayer", - outputs: [], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [ - { name: "tag", internalType: "bytes32", type: "bytes32" }, - { name: "allowed", internalType: "bool", type: "bool" }, - ], - name: "whitelistDisputeTag", - outputs: [], - stateMutability: "nonpayable", - }, ] as const; /** * */ -export const disputeModuleAddress = { - 1513: "0xDae11663438a0958E7075F604E3a5eEe77FD3878", +export const derivativeWorkflowsAddress = { + 1513: "0xC022C70DA8c23Ae8e36B3de9039Ed24E4E42a127", } as const; /** * */ -export const disputeModuleConfig = { - address: disputeModuleAddress, - abi: disputeModuleAbi, +export const derivativeWorkflowsConfig = { + address: derivativeWorkflowsAddress, + abi: derivativeWorkflowsAbi, } as const; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// IPAccountImpl +// DisputeModule ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * */ -export const ipAccountImplAbi = [ +export const disputeModuleAbi = [ { type: "constructor", inputs: [ { name: "accessController", internalType: "address", type: "address" }, { name: "ipAssetRegistry", internalType: "address", type: "address" }, { name: "licenseRegistry", internalType: "address", type: "address" }, - { name: "moduleRegistry", internalType: "address", type: "address" }, ], stateMutability: "nonpayable", }, - { type: "error", inputs: [], name: "FnSelectorNotRecognized" }, - { type: "error", inputs: [], name: "IPAccountStorage__InvalidBatchLengths" }, { type: "error", - inputs: [{ name: "module", internalType: "address", type: "address" }], - name: "IPAccountStorage__NotRegisteredModule", + inputs: [{ name: "ipAccount", internalType: "address", type: "address" }], + name: "AccessControlled__NotIpAccount", + }, + { type: "error", inputs: [], name: "AccessControlled__ZeroAddress" }, + { + 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: "DisputeModule__NotAbleToResolve" }, + { type: "error", inputs: [], name: "DisputeModule__NotAllowedToWhitelist" }, + { type: "error", inputs: [], name: "DisputeModule__NotDerivative" }, + { type: "error", inputs: [], name: "DisputeModule__NotDisputeInitiator" }, + { type: "error", inputs: [], name: "DisputeModule__NotInDisputeState" }, + { type: "error", inputs: [], name: "DisputeModule__NotRegisteredIpId" }, + { + type: "error", + inputs: [], + name: "DisputeModule__NotWhitelistedArbitrationPolicy", + }, + { + type: "error", + inputs: [], + name: "DisputeModule__NotWhitelistedArbitrationRelayer", + }, + { + type: "error", + inputs: [], + name: "DisputeModule__NotWhitelistedDisputeTag", + }, + { + type: "error", + inputs: [], + name: "DisputeModule__ParentDisputeNotResolved", + }, + { type: "error", inputs: [], name: "DisputeModule__ParentIpIdMismatch" }, + { type: "error", inputs: [], name: "DisputeModule__ParentNotTagged" }, + { type: "error", inputs: [], name: "DisputeModule__ZeroAccessController" }, + { type: "error", inputs: [], name: "DisputeModule__ZeroAccessManager" }, + { type: "error", inputs: [], name: "DisputeModule__ZeroArbitrationPolicy" }, + { type: "error", inputs: [], name: "DisputeModule__ZeroArbitrationRelayer" }, + { type: "error", inputs: [], name: "DisputeModule__ZeroDisputeEvidenceHash" }, + { type: "error", inputs: [], name: "DisputeModule__ZeroDisputeTag" }, + { type: "error", inputs: [], name: "DisputeModule__ZeroIPAssetRegistry" }, + { type: "error", inputs: [], name: "DisputeModule__ZeroLicenseRegistry" }, + { + type: "error", + inputs: [{ name: "implementation", internalType: "address", type: "address" }], + name: "ERC1967InvalidImplementation", + }, + { type: "error", inputs: [], name: "ERC1967NonPayable" }, + { type: "error", inputs: [], name: "EnforcedPause" }, + { type: "error", inputs: [], name: "ExpectedPause" }, + { type: "error", inputs: [], name: "FailedInnerCall" }, + { type: "error", inputs: [], name: "InvalidInitialization" }, + { type: "error", inputs: [], name: "NotInitializing" }, + { type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" }, + { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, + { + type: "error", + inputs: [{ name: "slot", internalType: "bytes32", type: "bytes32" }], + name: "UUPSUnsupportedProxiableUUID", }, - { type: "error", inputs: [], name: "IPAccountStorage__ZeroIpAssetRegistry" }, - { type: "error", inputs: [], name: "IPAccountStorage__ZeroLicenseRegistry" }, - { type: "error", inputs: [], name: "IPAccountStorage__ZeroModuleRegistry" }, - { type: "error", inputs: [], name: "IPAccount__ExpiredSignature" }, - { type: "error", inputs: [], name: "IPAccount__InvalidCalldata" }, - { type: "error", inputs: [], name: "IPAccount__InvalidOperation" }, - { type: "error", inputs: [], name: "IPAccount__InvalidSignature" }, - { type: "error", inputs: [], name: "IPAccount__InvalidSigner" }, - { type: "error", inputs: [], name: "IPAccount__ZeroAccessController" }, - { type: "error", inputs: [], name: "OperationNotSupported" }, - { type: "error", inputs: [], name: "SelfOwnDetected" }, - { type: "error", inputs: [], name: "Unauthorized" }, - { type: "error", inputs: [], name: "UnauthorizedCallContext" }, - { type: "error", inputs: [], name: "UpgradeFailed" }, { type: "event", anonymous: false, inputs: [ - { name: "to", internalType: "address", type: "address", indexed: true }, { - name: "value", - internalType: "uint256", - type: "uint256", + name: "ipId", + internalType: "address", + type: "address", indexed: false, }, - { name: "data", internalType: "bytes", type: "bytes", indexed: false }, { - name: "nonce", - internalType: "bytes32", - type: "bytes32", + name: "arbitrationPolicy", + internalType: "address", + type: "address", indexed: false, }, ], - name: "Executed", + name: "ArbitrationPolicySet", }, { type: "event", anonymous: false, inputs: [ - { name: "to", internalType: "address", type: "address", indexed: true }, - { - name: "value", - internalType: "uint256", - type: "uint256", - indexed: false, - }, - { name: "data", internalType: "bytes", type: "bytes", indexed: false }, { - name: "nonce", - internalType: "bytes32", - type: "bytes32", + name: "arbitrationPolicy", + internalType: "address", + type: "address", indexed: false, }, + { name: "allowed", internalType: "bool", type: "bool", indexed: false }, + ], + name: "ArbitrationPolicyWhitelistUpdated", + }, + { + type: "event", + anonymous: false, + inputs: [ { - name: "deadline", - internalType: "uint256", - type: "uint256", + name: "arbitrationPolicy", + internalType: "address", + type: "address", indexed: false, }, { - name: "signer", + name: "arbitrationRelayer", internalType: "address", type: "address", - indexed: true, - }, - { - name: "signature", - internalType: "bytes", - type: "bytes", indexed: false, }, + { name: "allowed", internalType: "bool", type: "bool", indexed: false }, ], - name: "ExecutedWithSig", + name: "ArbitrationRelayerWhitelistUpdated", }, { type: "event", anonymous: false, inputs: [ { - name: "implementation", + name: "authority", internalType: "address", type: "address", - indexed: true, + indexed: false, }, ], - name: "Upgraded", + name: "AuthorityUpdated", }, - { type: "fallback", stateMutability: "payable" }, { - type: "function", - inputs: [], - name: "ACCESS_CONTROLLER", - outputs: [{ name: "", internalType: "address", type: "address" }], - stateMutability: "view", + type: "event", + anonymous: false, + inputs: [ + { + name: "arbitrationPolicy", + internalType: "address", + type: "address", + indexed: false, + }, + ], + name: "DefaultArbitrationPolicyUpdated", }, { - type: "function", - inputs: [], - name: "IP_ASSET_REGISTRY", - outputs: [{ name: "", internalType: "address", type: "address" }], - stateMutability: "view", + type: "event", + anonymous: false, + inputs: [ + { + name: "parentIpId", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "derivativeIpId", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "parentDisputeId", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + { name: "tag", internalType: "bytes32", type: "bytes32", indexed: false }, + ], + name: "DerivativeTaggedOnParentInfringement", }, { - type: "function", - inputs: [], - name: "LICENSE_REGISTRY", - outputs: [{ name: "", internalType: "address", type: "address" }], - stateMutability: "view", + type: "event", + anonymous: false, + inputs: [ + { + name: "disputeId", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + { name: "data", internalType: "bytes", type: "bytes", indexed: false }, + ], + name: "DisputeCancelled", }, { - type: "function", - inputs: [], - name: "MODULE_REGISTRY", - outputs: [{ name: "", internalType: "address", type: "address" }], - stateMutability: "view", + type: "event", + anonymous: false, + inputs: [ + { + name: "disputeId", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + { name: "decision", internalType: "bool", type: "bool", indexed: false }, + { name: "data", internalType: "bytes", type: "bytes", indexed: false }, + ], + name: "DisputeJudgementSet", }, { - type: "function", + type: "event", + anonymous: false, inputs: [ - { name: "", internalType: "bytes32", type: "bytes32" }, - { name: "", internalType: "bytes32", type: "bytes32" }, + { + name: "disputeId", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + { + name: "targetIpId", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "disputeInitiator", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "arbitrationPolicy", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "disputeEvidenceHash", + internalType: "bytes32", + type: "bytes32", + indexed: false, + }, + { + name: "targetTag", + internalType: "bytes32", + type: "bytes32", + indexed: false, + }, + { name: "data", internalType: "bytes", type: "bytes", indexed: false }, ], - name: "bytes32Data", - outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], - stateMutability: "view", + name: "DisputeRaised", }, { - type: "function", + type: "event", + anonymous: false, inputs: [ - { name: "", internalType: "bytes32", type: "bytes32" }, - { name: "", internalType: "bytes32", type: "bytes32" }, + { + name: "disputeId", + internalType: "uint256", + type: "uint256", + indexed: false, + }, ], - name: "bytesData", - outputs: [{ name: "", internalType: "bytes", type: "bytes" }], - stateMutability: "view", + name: "DisputeResolved", }, { - type: "function", - inputs: [], - name: "eip712Domain", - outputs: [ - { name: "fields", internalType: "bytes1", type: "bytes1" }, - { name: "name", internalType: "string", type: "string" }, - { name: "version", internalType: "string", type: "string" }, - { name: "chainId", internalType: "uint256", type: "uint256" }, - { name: "verifyingContract", internalType: "address", type: "address" }, - { name: "salt", internalType: "bytes32", type: "bytes32" }, - { name: "extensions", internalType: "uint256[]", type: "uint256[]" }, + type: "event", + anonymous: false, + inputs: [ + { + name: "version", + internalType: "uint64", + type: "uint64", + indexed: false, + }, ], - stateMutability: "view", + name: "Initialized", }, { - type: "function", + type: "event", + anonymous: false, inputs: [ - { name: "to", internalType: "address", type: "address" }, - { name: "value", internalType: "uint256", type: "uint256" }, - { name: "data", internalType: "bytes", type: "bytes" }, - { name: "operation", internalType: "uint8", type: "uint8" }, + { + name: "account", + internalType: "address", + type: "address", + indexed: false, + }, ], - name: "execute", - outputs: [{ name: "result", internalType: "bytes", type: "bytes" }], - stateMutability: "payable", + name: "Paused", }, { - type: "function", + type: "event", + anonymous: false, inputs: [ - { name: "to", internalType: "address", type: "address" }, - { name: "value", internalType: "uint256", type: "uint256" }, - { name: "data", internalType: "bytes", type: "bytes" }, + { name: "tag", internalType: "bytes32", type: "bytes32", indexed: false }, + { name: "allowed", internalType: "bool", type: "bool", indexed: false }, ], - name: "execute", - outputs: [{ name: "result", internalType: "bytes", type: "bytes" }], - stateMutability: "payable", + name: "TagWhitelistUpdated", }, { - type: "function", + type: "event", + anonymous: false, inputs: [ { - name: "calls", - internalType: "struct ERC6551.Call[]", - type: "tuple[]", - components: [ - { name: "target", internalType: "address", type: "address" }, - { name: "value", internalType: "uint256", type: "uint256" }, - { name: "data", internalType: "bytes", type: "bytes" }, - ], + name: "account", + internalType: "address", + type: "address", + indexed: false, }, - { name: "operation", internalType: "uint8", type: "uint8" }, ], - name: "executeBatch", - outputs: [{ name: "results", internalType: "bytes[]", type: "bytes[]" }], - stateMutability: "payable", + name: "Unpaused", }, { - type: "function", + type: "event", + anonymous: false, inputs: [ - { name: "to", internalType: "address", type: "address" }, - { name: "value", internalType: "uint256", type: "uint256" }, - { name: "data", internalType: "bytes", type: "bytes" }, - { name: "signer", internalType: "address", type: "address" }, - { name: "deadline", internalType: "uint256", type: "uint256" }, - { name: "signature", internalType: "bytes", type: "bytes" }, + { + name: "implementation", + internalType: "address", + type: "address", + indexed: true, + }, ], - name: "executeWithSig", - outputs: [{ name: "result", internalType: "bytes", type: "bytes" }], - stateMutability: "payable", - }, - { - type: "function", - inputs: [{ name: "key", internalType: "bytes32", type: "bytes32" }], - name: "getBytes", - outputs: [{ name: "", internalType: "bytes", type: "bytes" }], - stateMutability: "view", + name: "Upgraded", }, { type: "function", - inputs: [ - { name: "namespace", internalType: "bytes32", type: "bytes32" }, - { name: "key", internalType: "bytes32", type: "bytes32" }, - ], - name: "getBytes", - outputs: [{ name: "", internalType: "bytes", type: "bytes" }], + inputs: [], + name: "ACCESS_CONTROLLER", + outputs: [{ name: "", internalType: "contract IAccessController", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [ - { name: "namespace", internalType: "bytes32", type: "bytes32" }, - { name: "key", internalType: "bytes32", type: "bytes32" }, - ], - name: "getBytes32", + inputs: [], + name: "IN_DISPUTE", outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "key", internalType: "bytes32", type: "bytes32" }], - name: "getBytes32", - outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + inputs: [], + name: "IP_ACCOUNT_REGISTRY", + outputs: [ + { + name: "", + internalType: "contract IIPAccountRegistry", + type: "address", + }, + ], stateMutability: "view", }, { type: "function", - inputs: [ - { name: "namespaces", internalType: "bytes32[]", type: "bytes32[]" }, - { name: "keys", internalType: "bytes32[]", type: "bytes32[]" }, - ], - name: "getBytes32Batch", - outputs: [{ name: "values", internalType: "bytes32[]", type: "bytes32[]" }], + inputs: [], + name: "IP_ASSET_REGISTRY", + outputs: [{ name: "", internalType: "contract IIPAssetRegistry", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [ - { name: "namespaces", internalType: "bytes32[]", type: "bytes32[]" }, - { name: "keys", internalType: "bytes32[]", type: "bytes32[]" }, - ], - name: "getBytesBatch", - outputs: [{ name: "values", internalType: "bytes[]", type: "bytes[]" }], + inputs: [], + name: "LICENSE_REGISTRY", + outputs: [{ name: "", internalType: "contract ILicenseRegistry", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [ - { name: "hash", internalType: "bytes32", type: "bytes32" }, - { name: "signature", internalType: "bytes", type: "bytes" }, - ], - name: "isValidSignature", - outputs: [{ name: "result", internalType: "bytes4", type: "bytes4" }], + inputs: [], + name: "UPGRADE_INTERFACE_VERSION", + outputs: [{ name: "", internalType: "string", type: "string" }], stateMutability: "view", }, { type: "function", - inputs: [ - { name: "signer", internalType: "address", type: "address" }, - { name: "data", internalType: "bytes", type: "bytes" }, - ], - name: "isValidSigner", - outputs: [{ name: "result", internalType: "bytes4", type: "bytes4" }], - stateMutability: "view", + inputs: [{ name: "accessManager", internalType: "address", type: "address" }], + name: "__ProtocolPausable_init", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", - inputs: [ - { name: "signer", internalType: "address", type: "address" }, - { name: "to", internalType: "address", type: "address" }, - { name: "data", internalType: "bytes", type: "bytes" }, - ], - name: "isValidSigner", - outputs: [{ name: "", internalType: "bool", type: "bool" }], + inputs: [{ name: "ipId", internalType: "address", type: "address" }], + name: "arbitrationPolicies", + outputs: [{ name: "policy", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "owner", + name: "authority", outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "proxiableUUID", - outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + name: "baseArbitrationPolicy", + outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [ - { name: "key", internalType: "bytes32", type: "bytes32" }, - { name: "value", internalType: "bytes", type: "bytes" }, + { name: "disputeId", internalType: "uint256", type: "uint256" }, + { name: "data", internalType: "bytes", type: "bytes" }, ], - name: "setBytes", + name: "cancelDispute", outputs: [], stateMutability: "nonpayable", }, { type: "function", - inputs: [ - { name: "key", internalType: "bytes32", type: "bytes32" }, - { name: "value", internalType: "bytes32", type: "bytes32" }, - ], - name: "setBytes32", - outputs: [], - stateMutability: "nonpayable", + inputs: [], + name: "disputeCounter", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", }, { type: "function", - inputs: [ - { name: "keys", internalType: "bytes32[]", type: "bytes32[]" }, - { name: "values", internalType: "bytes32[]", type: "bytes32[]" }, + inputs: [{ name: "disputeId", internalType: "uint256", type: "uint256" }], + name: "disputes", + outputs: [ + { name: "targetIpId", internalType: "address", type: "address" }, + { name: "disputeInitiator", internalType: "address", type: "address" }, + { name: "arbitrationPolicy", internalType: "address", type: "address" }, + { name: "disputeEvidenceHash", internalType: "bytes32", type: "bytes32" }, + { name: "targetTag", internalType: "bytes32", type: "bytes32" }, + { name: "currentTag", internalType: "bytes32", type: "bytes32" }, + { name: "parentDisputeId", internalType: "uint256", type: "uint256" }, ], - name: "setBytes32Batch", - outputs: [], - stateMutability: "nonpayable", + stateMutability: "view", }, { type: "function", - inputs: [ - { name: "keys", internalType: "bytes32[]", type: "bytes32[]" }, - { name: "values", internalType: "bytes[]", type: "bytes[]" }, - ], - name: "setBytesBatch", + inputs: [{ name: "accessManager", internalType: "address", type: "address" }], + name: "initialize", outputs: [], stateMutability: "nonpayable", }, { type: "function", inputs: [], - name: "state", - outputs: [{ name: "result", internalType: "bytes32", type: "bytes32" }], + name: "isConsumingScheduledOp", + outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }], - name: "supportsInterface", + inputs: [{ name: "ipId", internalType: "address", type: "address" }], + name: "isIpTagged", outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "view", }, { type: "function", - inputs: [], - name: "token", - outputs: [ - { name: "", internalType: "uint256", type: "uint256" }, - { name: "", internalType: "address", type: "address" }, - { name: "", internalType: "uint256", type: "uint256" }, - ], + inputs: [{ name: "arbitrationPolicy", internalType: "address", type: "address" }], + name: "isWhitelistedArbitrationPolicy", + outputs: [{ name: "allowed", internalType: "bool", type: "bool" }], stateMutability: "view", }, { type: "function", inputs: [ - { name: "newImplementation", internalType: "address", type: "address" }, - { name: "data", internalType: "bytes", type: "bytes" }, + { name: "arbitrationPolicy", internalType: "address", type: "address" }, + { name: "arbitrationRelayer", internalType: "address", type: "address" }, ], - name: "upgradeToAndCall", - outputs: [], - stateMutability: "payable", + name: "isWhitelistedArbitrationRelayer", + outputs: [{ name: "allowed", internalType: "bool", type: "bool" }], + stateMutability: "view", }, - { type: "receive", stateMutability: "payable" }, -] as const; - -/** - * - */ -export const ipAccountImplAddress = { - 1513: "0x8F763c16753e830a8020c80f9F0131Eb8Ef52879", -} as const; - -/** - * - */ -export const ipAccountImplConfig = { - address: ipAccountImplAddress, - abi: ipAccountImplAbi, -} as const; - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// IPAssetRegistry -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -/** - * - */ -export const ipAssetRegistryAbi = [ { - type: "constructor", - inputs: [ - { name: "erc6551Registry", internalType: "address", type: "address" }, - { name: "ipAccountImpl", internalType: "address", type: "address" }, - ], - stateMutability: "nonpayable", + type: "function", + inputs: [{ name: "tag", internalType: "bytes32", type: "bytes32" }], + name: "isWhitelistedDisputeTag", + outputs: [{ name: "allowed", internalType: "bool", type: "bool" }], + stateMutability: "view", }, { - type: "error", - inputs: [{ name: "authority", internalType: "address", type: "address" }], - name: "AccessManagedInvalidAuthority", + type: "function", + inputs: [{ name: "data", internalType: "bytes[]", type: "bytes[]" }], + name: "multicall", + outputs: [{ name: "results", internalType: "bytes[]", type: "bytes[]" }], + stateMutability: "nonpayable", }, { - type: "error", - inputs: [ - { name: "caller", internalType: "address", type: "address" }, - { name: "delay", internalType: "uint32", type: "uint32" }, - ], - name: "AccessManagedRequiredDelay", + type: "function", + inputs: [], + name: "name", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", }, { - type: "error", - inputs: [{ name: "caller", internalType: "address", type: "address" }], - name: "AccessManagedUnauthorized", + type: "function", + inputs: [], + name: "pause", + outputs: [], + stateMutability: "nonpayable", }, { - type: "error", - inputs: [{ name: "target", internalType: "address", type: "address" }], - name: "AddressEmptyCode", + type: "function", + inputs: [], + name: "paused", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", }, { - type: "error", - inputs: [{ name: "implementation", internalType: "address", type: "address" }], - name: "ERC1967InvalidImplementation", + type: "function", + inputs: [], + name: "proxiableUUID", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view", }, - { type: "error", inputs: [], name: "ERC1967NonPayable" }, - { type: "error", inputs: [], name: "EnforcedPause" }, - { type: "error", inputs: [], name: "ExpectedPause" }, - { type: "error", inputs: [], name: "FailedInnerCall" }, - { type: "error", inputs: [], name: "IPAccountRegistry_ZeroERC6551Registry" }, - { type: "error", inputs: [], name: "IPAccountRegistry_ZeroIpAccountImpl" }, - { type: "error", inputs: [], name: "IPAssetRegistry__AlreadyRegistered" }, { - type: "error", + type: "function", inputs: [ - { name: "contractAddress", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, + { name: "targetIpId", internalType: "address", type: "address" }, + { name: "disputeEvidenceHash", internalType: "bytes32", type: "bytes32" }, + { name: "targetTag", internalType: "bytes32", type: "bytes32" }, + { name: "data", internalType: "bytes", type: "bytes" }, ], - name: "IPAssetRegistry__InvalidToken", - }, - { - type: "error", - inputs: [{ name: "contractAddress", internalType: "address", type: "address" }], - name: "IPAssetRegistry__UnsupportedIERC721", - }, - { - type: "error", - inputs: [{ name: "contractAddress", internalType: "address", type: "address" }], - name: "IPAssetRegistry__UnsupportedIERC721Metadata", + name: "raiseDispute", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "nonpayable", }, - { type: "error", inputs: [], name: "IPAssetRegistry__ZeroAccessManager" }, - { type: "error", inputs: [], name: "InvalidInitialization" }, - { type: "error", inputs: [], name: "NotInitializing" }, { - type: "error", + type: "function", inputs: [ - { name: "value", internalType: "uint256", type: "uint256" }, - { name: "length", internalType: "uint256", type: "uint256" }, + { name: "disputeId", internalType: "uint256", type: "uint256" }, + { name: "data", internalType: "bytes", type: "bytes" }, ], - name: "StringsInsufficientHexLength", + name: "resolveDispute", + outputs: [], + stateMutability: "nonpayable", }, - { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, { - type: "error", - inputs: [{ name: "slot", internalType: "bytes32", type: "bytes32" }], - name: "UUPSUnsupportedProxiableUUID", + type: "function", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "arbitrationPolicy", internalType: "address", type: "address" }, + ], + name: "setArbitrationPolicy", + outputs: [], + stateMutability: "nonpayable", }, { - type: "event", - anonymous: false, + type: "function", + inputs: [{ name: "newAuthority", internalType: "address", type: "address" }], + name: "setAuthority", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "arbitrationPolicy", internalType: "address", type: "address" }], + name: "setBaseArbitrationPolicy", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", inputs: [ - { - name: "authority", - internalType: "address", - type: "address", - indexed: false, - }, + { name: "disputeId", internalType: "uint256", type: "uint256" }, + { name: "decision", internalType: "bool", type: "bool" }, + { name: "data", internalType: "bytes", type: "bytes" }, ], - name: "AuthorityUpdated", + name: "setDisputeJudgement", + outputs: [], + stateMutability: "nonpayable", }, { - type: "event", - anonymous: false, + type: "function", + inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }], + name: "supportsInterface", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", inputs: [ - { - name: "account", - internalType: "address", - type: "address", - indexed: true, - }, - { - name: "implementation", - internalType: "address", - type: "address", - indexed: true, - }, - { - name: "chainId", - internalType: "uint256", - type: "uint256", - indexed: true, - }, - { - name: "tokenContract", - internalType: "address", - type: "address", - indexed: false, - }, - { - name: "tokenId", - internalType: "uint256", - type: "uint256", - indexed: false, - }, + { name: "parentIpId", internalType: "address", type: "address" }, + { name: "derivativeIpId", internalType: "address", type: "address" }, + { name: "parentDisputeId", internalType: "uint256", type: "uint256" }, ], - name: "IPAccountRegistered", + name: "tagDerivativeIfParentInfringed", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "unpause", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "newImplementation", internalType: "address", type: "address" }, + { name: "data", internalType: "bytes", type: "bytes" }, + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "arbitrationPolicy", internalType: "address", type: "address" }, + { name: "allowed", internalType: "bool", type: "bool" }, + ], + name: "whitelistArbitrationPolicy", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "arbitrationPolicy", internalType: "address", type: "address" }, + { name: "arbPolicyRelayer", internalType: "address", type: "address" }, + { name: "allowed", internalType: "bool", type: "bool" }, + ], + name: "whitelistArbitrationRelayer", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "tag", internalType: "bytes32", type: "bytes32" }, + { name: "allowed", internalType: "bool", type: "bool" }, + ], + name: "whitelistDisputeTag", + outputs: [], + stateMutability: "nonpayable", + }, +] as const; + +/** + * + */ +export const disputeModuleAddress = { + 1513: "0x26525b4A1c2261A27B9ee89D512c2f7DceF85f4a", +} as const; + +/** + * + */ +export const disputeModuleConfig = { + address: disputeModuleAddress, + abi: disputeModuleAbi, +} as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// EvenSplitGroupPool +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * + */ +export const evenSplitGroupPoolAbi = [ + { + type: "constructor", + inputs: [ + { name: "groupingModule", internalType: "address", type: "address" }, + { name: "royaltyModule", internalType: "address", type: "address" }, + { name: "ipAssetRegistry", internalType: "address", type: "address" }, + ], + 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: "implementation", internalType: "address", type: "address" }], + name: "ERC1967InvalidImplementation", + }, + { type: "error", inputs: [], name: "ERC1967NonPayable" }, + { type: "error", inputs: [], name: "EnforcedPause" }, + { + type: "error", + inputs: [{ name: "caller", internalType: "address", type: "address" }], + name: "EvenSplitGroupPool__CallerIsNotGroupingModule", + }, + { type: "error", inputs: [], name: "EvenSplitGroupPool__ZeroGroupingModule" }, + { + type: "error", + inputs: [], + name: "EvenSplitGroupPool__ZeroIPAssetRegistry", + }, + { type: "error", inputs: [], name: "EvenSplitGroupPool__ZeroRoyaltyModule" }, + { type: "error", inputs: [], name: "ExpectedPause" }, + { type: "error", inputs: [], name: "FailedInnerCall" }, + { type: "error", inputs: [], name: "GroupingModule__ZeroAccessManager" }, + { type: "error", inputs: [], name: "InvalidInitialization" }, + { type: "error", inputs: [], name: "NotInitializing" }, + { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, + { + type: "error", + inputs: [{ name: "slot", internalType: "bytes32", type: "bytes32" }], + name: "UUPSUnsupportedProxiableUUID", }, { type: "event", anonymous: false, inputs: [ { - name: "ipId", - internalType: "address", - type: "address", - indexed: false, - }, - { - name: "chainId", - internalType: "uint256", - type: "uint256", - indexed: true, - }, - { - name: "tokenContract", + name: "authority", internalType: "address", type: "address", - indexed: true, - }, - { - name: "tokenId", - internalType: "uint256", - type: "uint256", - indexed: true, - }, - { name: "name", internalType: "string", type: "string", indexed: false }, - { name: "uri", internalType: "string", type: "string", indexed: false }, - { - name: "registrationDate", - internalType: "uint256", - type: "uint256", indexed: false, }, ], - name: "IPRegistered", + name: "AuthorityUpdated", }, { type: "event", @@ -2049,22 +2237,28 @@ export const ipAssetRegistryAbi = [ { type: "function", inputs: [], - name: "ERC6551_PUBLIC_REGISTRY", - outputs: [{ name: "", internalType: "address", type: "address" }], + name: "GROUPING_MODULE", + outputs: [{ name: "", internalType: "contract IGroupingModule", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "IP_ACCOUNT_IMPL", - outputs: [{ name: "", internalType: "address", type: "address" }], + name: "GROUP_IP_ASSET_REGISTRY", + outputs: [ + { + name: "", + internalType: "contract IGroupIPAssetRegistry", + type: "address", + }, + ], stateMutability: "view", }, { type: "function", inputs: [], - name: "IP_ACCOUNT_SALT", - outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + name: "ROYALTY_MODULE", + outputs: [{ name: "", internalType: "contract IRoyaltyModule", type: "address" }], stateMutability: "view", }, { @@ -2083,47 +2277,89 @@ export const ipAssetRegistryAbi = [ }, { type: "function", - inputs: [], - name: "authority", - outputs: [{ name: "", internalType: "address", type: "address" }], - stateMutability: "view", + inputs: [ + { name: "groupId", internalType: "address", type: "address" }, + { name: "ipId", internalType: "address", type: "address" }, + ], + name: "addIp", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", inputs: [], - name: "getIPAccountImpl", + name: "authority", outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "accessManager", internalType: "address", type: "address" }], - name: "initialize", + inputs: [ + { name: "groupId", internalType: "address", type: "address" }, + { name: "token", internalType: "address", type: "address" }, + { name: "amount", internalType: "uint256", type: "uint256" }, + ], + name: "depositReward", outputs: [], stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "chainId", internalType: "uint256", type: "uint256" }, - { name: "tokenContract", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, + { name: "groupId", internalType: "address", type: "address" }, + { name: "token", internalType: "address", type: "address" }, + { name: "ipIds", internalType: "address[]", type: "address[]" }, ], - name: "ipAccount", - outputs: [{ name: "", internalType: "address", type: "address" }], + name: "distributeRewards", + outputs: [{ name: "rewards", internalType: "uint256[]", type: "uint256[]" }], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "groupId", internalType: "address", type: "address" }, + { name: "token", internalType: "address", type: "address" }, + { name: "ipIds", internalType: "address[]", type: "address[]" }, + ], + name: "getAvailableReward", + outputs: [{ name: "", internalType: "uint256[]", type: "uint256[]" }], stateMutability: "view", }, { type: "function", inputs: [ - { name: "chainId", internalType: "uint256", type: "uint256" }, - { name: "tokenContract", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, + { name: "groupId", internalType: "address", type: "address" }, + { name: "ipId", internalType: "address", type: "address" }, ], - name: "ipId", - outputs: [{ name: "", internalType: "address", type: "address" }], + name: "getIpAddedTime", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "groupId", internalType: "address", type: "address" }, + { name: "token", internalType: "address", type: "address" }, + { name: "ipId", internalType: "address", type: "address" }, + ], + name: "getIpRewardDebt", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "groupId", internalType: "address", type: "address" }], + name: "getTotalIps", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], stateMutability: "view", }, + { + type: "function", + inputs: [{ name: "accessManager", internalType: "address", type: "address" }], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + }, { type: "function", inputs: [], @@ -2133,8 +2369,11 @@ export const ipAssetRegistryAbi = [ }, { type: "function", - inputs: [{ name: "id", internalType: "address", type: "address" }], - name: "isRegistered", + inputs: [ + { name: "groupId", internalType: "address", type: "address" }, + { name: "ipId", internalType: "address", type: "address" }, + ], + name: "isIPAdded", outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "view", }, @@ -2162,12 +2401,11 @@ export const ipAssetRegistryAbi = [ { type: "function", inputs: [ - { name: "chainid", internalType: "uint256", type: "uint256" }, - { name: "tokenContract", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, + { name: "groupId", internalType: "address", type: "address" }, + { name: "ipId", internalType: "address", type: "address" }, ], - name: "register", - outputs: [{ name: "id", internalType: "address", type: "address" }], + name: "removeIp", + outputs: [], stateMutability: "nonpayable", }, { @@ -2177,13 +2415,6 @@ export const ipAssetRegistryAbi = [ outputs: [], stateMutability: "nonpayable", }, - { - type: "function", - inputs: [], - name: "totalSupply", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - stateMutability: "view", - }, { type: "function", inputs: [], @@ -2206,495 +2437,586 @@ export const ipAssetRegistryAbi = [ /** * */ -export const ipAssetRegistryAddress = { - 1513: "0xe34A78B3d658aF7ad69Ff1EFF9012ECa025a14Be", +export const evenSplitGroupPoolAddress = { + 1513: "0xA1dB7AB14900Cd9eF9A7eBA931A206250F403a14", } as const; /** * */ -export const ipAssetRegistryConfig = { - address: ipAssetRegistryAddress, - abi: ipAssetRegistryAbi, +export const evenSplitGroupPoolConfig = { + address: evenSplitGroupPoolAddress, + abi: evenSplitGroupPoolAbi, } as const; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// IpRoyaltyVaultImpl +// GroupingModule ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * */ -export const ipRoyaltyVaultImplAbi = [ +export const groupingModuleAbi = [ { type: "constructor", inputs: [ - { name: "royaltyPolicyLAP", internalType: "address", type: "address" }, - { name: "disputeModule", internalType: "address", type: "address" }, + { name: "accessController", internalType: "address", type: "address" }, + { name: "ipAssetRegistry", internalType: "address", type: "address" }, + { name: "licenseRegistry", internalType: "address", type: "address" }, + { name: "licenseToken", internalType: "address", type: "address" }, + { name: "groupNFT", internalType: "address", type: "address" }, + { name: "royaltyModule", internalType: "address", type: "address" }, ], stateMutability: "nonpayable", }, - { type: "error", inputs: [], name: "IpRoyaltyVault__AlreadyClaimed" }, - { type: "error", inputs: [], name: "IpRoyaltyVault__ClaimerNotAnAncestor" }, - { type: "error", inputs: [], name: "IpRoyaltyVault__EnforcedPause" }, - { type: "error", inputs: [], name: "IpRoyaltyVault__IpGraphCallFailed" }, - { type: "error", inputs: [], name: "IpRoyaltyVault__IpTagged" }, - { type: "error", inputs: [], name: "IpRoyaltyVault__NotRoyaltyPolicyLAP" }, { type: "error", - inputs: [], - name: "IpRoyaltyVault__SnapshotIntervalTooShort", + inputs: [{ name: "ipAccount", internalType: "address", type: "address" }], + name: "AccessControlled__NotIpAccount", + }, + { type: "error", inputs: [], name: "AccessControlled__ZeroAddress" }, + { + 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: "implementation", internalType: "address", type: "address" }], + name: "ERC1967InvalidImplementation", + }, + { type: "error", inputs: [], name: "ERC1967NonPayable" }, + { type: "error", inputs: [], name: "EnforcedPause" }, + { type: "error", inputs: [], name: "ExpectedPause" }, + { type: "error", inputs: [], name: "FailedInnerCall" }, + { + type: "error", + inputs: [ + { name: "groupId", internalType: "address", type: "address" }, + { name: "childGroupId", internalType: "address", type: "address" }, + ], + name: "GroupingModule__CannotAddGroupToGroup", + }, + { + type: "error", + inputs: [{ name: "groupId", internalType: "address", type: "address" }], + name: "GroupingModule__GroupFrozenDueToAlreadyMintLicenseTokens", + }, + { + type: "error", + inputs: [{ name: "groupId", internalType: "address", type: "address" }], + name: "GroupingModule__GroupFrozenDueToHasDerivativeIps", + }, + { + type: "error", + inputs: [ + { name: "groupId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + ], + name: "GroupingModule__GroupIPHasMintingFee", + }, + { + type: "error", + inputs: [{ name: "groupId", internalType: "address", type: "address" }], + name: "GroupingModule__GroupIPHasNoLicenseTerms", + }, + { + type: "error", + inputs: [{ name: "groupId", internalType: "address", type: "address" }], + name: "GroupingModule__GroupRoyaltyVaultNotCreated", + }, + { + type: "error", + inputs: [{ name: "groupNFT", internalType: "address", type: "address" }], + name: "GroupingModule__InvalidGroupNFT", + }, + { + type: "error", + inputs: [ + { name: "groupId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + ], + name: "GroupingModule__IpHasNoGroupLicenseTerms", + }, + { type: "error", inputs: [], name: "GroupingModule__ZeroAccessManager" }, + { type: "error", inputs: [], name: "GroupingModule__ZeroGroupNFT" }, + { type: "error", inputs: [], name: "GroupingModule__ZeroGroupRewardPool" }, + { type: "error", inputs: [], name: "GroupingModule__ZeroIpAssetRegistry" }, + { type: "error", inputs: [], name: "GroupingModule__ZeroLicenseRegistry" }, + { type: "error", inputs: [], name: "GroupingModule__ZeroLicenseToken" }, + { type: "error", inputs: [], name: "GroupingModule__ZeroRoyaltyModule" }, + { type: "error", inputs: [], name: "InvalidInitialization" }, + { type: "error", inputs: [], name: "NotInitializing" }, + { type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" }, + { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, + { + type: "error", + inputs: [{ name: "slot", internalType: "bytes32", type: "bytes32" }], + name: "UUPSUnsupportedProxiableUUID", }, - { type: "error", inputs: [], name: "IpRoyaltyVault__ZeroDisputeModule" }, - { type: "error", inputs: [], name: "IpRoyaltyVault__ZeroRoyaltyPolicyLAP" }, { type: "event", anonymous: false, inputs: [ { - name: "owner", - internalType: "address", - type: "address", - indexed: true, - }, - { - name: "spender", + name: "groupId", internalType: "address", type: "address", indexed: true, }, { - name: "value", - internalType: "uint256", - type: "uint256", + name: "ipIds", + internalType: "address[]", + type: "address[]", indexed: false, }, ], - name: "Approval", + name: "AddedIpToGroup", }, { type: "event", anonymous: false, - inputs: [{ name: "version", internalType: "uint8", type: "uint8", indexed: false }], - name: "Initialized", + inputs: [ + { + name: "authority", + internalType: "address", + type: "address", + indexed: false, + }, + ], + name: "AuthorityUpdated", }, { type: "event", anonymous: false, inputs: [ { - name: "claimer", + name: "groupId", internalType: "address", type: "address", - indexed: false, + indexed: true, }, { name: "token", internalType: "address", type: "address", + indexed: true, + }, + { + name: "ipId", + internalType: "address[]", + type: "address[]", indexed: false, }, { name: "amount", - internalType: "uint256", - type: "uint256", + internalType: "uint256[]", + type: "uint256[]", indexed: false, }, ], - name: "RevenueTokenClaimed", + name: "ClaimedReward", }, { type: "event", anonymous: false, inputs: [ { - name: "ancestorIpId", + name: "groupId", internalType: "address", type: "address", - indexed: false, + indexed: true, + }, + { + name: "token", + internalType: "address", + type: "address", + indexed: true, }, + { name: "pool", internalType: "address", type: "address", indexed: true }, { - name: "royaltyTokensCollected", + name: "amount", internalType: "uint256", type: "uint256", indexed: false, }, + { + name: "snapshots", + internalType: "uint256[]", + type: "uint256[]", + indexed: false, + }, ], - name: "RoyaltyTokensCollected", - }, - { - type: "event", - anonymous: false, - inputs: [{ name: "id", internalType: "uint256", type: "uint256", indexed: false }], - name: "Snapshot", + name: "CollectedRoyaltiesToGroupPool", }, { type: "event", anonymous: false, inputs: [ { - name: "snapshotId", - internalType: "uint256", - type: "uint256", - indexed: false, + name: "groupId", + internalType: "address", + type: "address", + indexed: true, }, { - name: "snapshotTimestamp", - internalType: "uint256", - type: "uint256", - indexed: false, + name: "groupPool", + internalType: "address", + type: "address", + indexed: true, }, + ], + name: "IPGroupRegistered", + }, + { + type: "event", + anonymous: false, + inputs: [ { - name: "unclaimedTokens", - internalType: "uint32", - type: "uint32", + name: "version", + internalType: "uint64", + type: "uint64", indexed: false, }, ], - name: "SnapshotCompleted", + name: "Initialized", }, { type: "event", anonymous: false, inputs: [ - { name: "from", internalType: "address", type: "address", indexed: true }, - { name: "to", internalType: "address", type: "address", indexed: true }, { - name: "value", - internalType: "uint256", - type: "uint256", + name: "account", + internalType: "address", + type: "address", indexed: false, }, ], - name: "Transfer", + name: "Paused", }, { - type: "function", - inputs: [], - name: "DISPUTE_MODULE", - outputs: [{ name: "", internalType: "contract IDisputeModule", type: "address" }], - stateMutability: "view", + type: "event", + anonymous: false, + inputs: [ + { + name: "groupId", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "ipIds", + internalType: "address[]", + type: "address[]", + indexed: false, + }, + ], + name: "RemovedIpFromGroup", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "account", + internalType: "address", + type: "address", + indexed: false, + }, + ], + name: "Unpaused", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "implementation", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "Upgraded", }, { type: "function", inputs: [], - name: "IP_GRAPH_CONTRACT", - outputs: [{ name: "", internalType: "address", type: "address" }], + name: "ACCESS_CONTROLLER", + outputs: [{ name: "", internalType: "contract IAccessController", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "ROYALTY_POLICY_LAP", - outputs: [{ name: "", internalType: "contract IRoyaltyPolicyLAP", type: "address" }], + name: "GROUP_IP_ASSET_REGISTRY", + outputs: [ + { + name: "", + internalType: "contract IGroupIPAssetRegistry", + type: "address", + }, + ], stateMutability: "view", }, { type: "function", - inputs: [{ name: "token", internalType: "address", type: "address" }], - name: "addIpRoyaltyVaultTokens", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "nonpayable", + inputs: [], + name: "GROUP_NFT", + outputs: [{ name: "", internalType: "contract IGroupNFT", type: "address" }], + stateMutability: "view", }, { type: "function", - inputs: [ - { name: "owner", internalType: "address", type: "address" }, - { name: "spender", internalType: "address", type: "address" }, + inputs: [], + name: "IP_ACCOUNT_REGISTRY", + outputs: [ + { + name: "", + internalType: "contract IIPAccountRegistry", + type: "address", + }, ], - name: "allowance", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "token", internalType: "address", type: "address" }], - name: "ancestorsVaultAmount", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + inputs: [], + name: "LICENSE_REGISTRY", + outputs: [{ name: "", internalType: "contract ILicenseRegistry", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [ - { name: "spender", internalType: "address", type: "address" }, - { name: "amount", internalType: "uint256", type: "uint256" }, - ], - name: "approve", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "nonpayable", + inputs: [], + name: "LICENSE_TOKEN", + outputs: [{ name: "", internalType: "contract ILicenseToken", type: "address" }], + stateMutability: "view", }, { type: "function", - inputs: [{ name: "account", internalType: "address", type: "address" }], - name: "balanceOf", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + inputs: [], + name: "ROYALTY_MODULE", + outputs: [{ name: "", internalType: "contract IRoyaltyModule", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [ - { name: "account", internalType: "address", type: "address" }, - { name: "snapshotId", internalType: "uint256", type: "uint256" }, - ], - name: "balanceOfAt", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + inputs: [], + name: "UPGRADE_INTERFACE_VERSION", + outputs: [{ name: "", internalType: "string", type: "string" }], stateMutability: "view", }, { type: "function", - inputs: [ - { name: "snapshotIds", internalType: "uint256[]", type: "uint256[]" }, - { name: "token", internalType: "address", type: "address" }, - ], - name: "claimRevenueBySnapshotBatch", + inputs: [{ name: "accessManager", internalType: "address", type: "address" }], + name: "__ProtocolPausable_init", outputs: [], stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "snapshotId", internalType: "uint256", type: "uint256" }, - { name: "tokenList", internalType: "address[]", type: "address[]" }, + { name: "groupIpId", internalType: "address", type: "address" }, + { name: "ipIds", internalType: "address[]", type: "address[]" }, ], - name: "claimRevenueByTokenBatch", + name: "addIp", outputs: [], stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "token", internalType: "address", type: "address" }], - name: "claimVaultAmount", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + inputs: [], + name: "authority", + outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [ - { name: "snapshotId", internalType: "uint256", type: "uint256" }, + { name: "groupId", internalType: "address", type: "address" }, { name: "token", internalType: "address", type: "address" }, + { name: "ipIds", internalType: "address[]", type: "address[]" }, ], - name: "claimableAtSnapshot", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - stateMutability: "view", + name: "claimReward", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "account", internalType: "address", type: "address" }, - { name: "snapshotId", internalType: "uint256", type: "uint256" }, + { name: "groupId", internalType: "address", type: "address" }, { name: "token", internalType: "address", type: "address" }, + { name: "snapshotIds", internalType: "uint256[]", type: "uint256[]" }, ], - name: "claimableRevenue", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - stateMutability: "view", + name: "collectRoyalties", + outputs: [{ name: "royalties", internalType: "uint256", type: "uint256" }], + stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "ancestorIpId", internalType: "address", type: "address" }, - { name: "_tokens", internalType: "address[]", type: "address[]" }, + { name: "groupId", internalType: "address", type: "address" }, + { name: "token", internalType: "address", type: "address" }, + { name: "ipIds", internalType: "address[]", type: "address[]" }, ], - name: "collectAccruedTokens", - outputs: [], - stateMutability: "nonpayable", + name: "getClaimableReward", + outputs: [{ name: "", internalType: "uint256[]", type: "uint256[]" }], + stateMutability: "view", }, { type: "function", - inputs: [{ name: "ancestorIpId", internalType: "address", type: "address" }], - name: "collectRoyaltyTokens", + inputs: [{ name: "accessManager", internalType: "address", type: "address" }], + name: "initialize", outputs: [], stateMutability: "nonpayable", }, - { - type: "function", - inputs: [ - { name: "ancestorIpId", internalType: "address", type: "address" }, - { name: "token", internalType: "address", type: "address" }, - ], - name: "collectableAmount", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - stateMutability: "view", - }, { type: "function", inputs: [], - name: "decimals", - outputs: [{ name: "", internalType: "uint8", type: "uint8" }], + name: "isConsumingScheduledOp", + outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], stateMutability: "view", }, { type: "function", - inputs: [ - { name: "spender", internalType: "address", type: "address" }, - { name: "subtractedValue", internalType: "uint256", type: "uint256" }, - ], - name: "decreaseAllowance", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [ - { name: "spender", internalType: "address", type: "address" }, - { name: "addedValue", internalType: "uint256", type: "uint256" }, - ], - name: "increaseAllowance", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "nonpayable", + inputs: [], + name: "name", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "pure", }, { type: "function", - inputs: [ - { name: "name", internalType: "string", type: "string" }, - { name: "symbol", internalType: "string", type: "string" }, - { name: "supply", internalType: "uint32", type: "uint32" }, - { name: "unclaimedTokens", internalType: "uint32", type: "uint32" }, - { name: "ipIdAddress", internalType: "address", type: "address" }, - ], - name: "initialize", + inputs: [], + name: "pause", outputs: [], stateMutability: "nonpayable", }, { type: "function", inputs: [], - name: "ipId", - outputs: [{ name: "", internalType: "address", type: "address" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [ - { name: "snapshotId", internalType: "uint256", type: "uint256" }, - { name: "claimer", internalType: "address", type: "address" }, - { name: "token", internalType: "address", type: "address" }, - ], - name: "isClaimedAtSnapshot", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [{ name: "ancestorIpId", internalType: "address", type: "address" }], - name: "isCollectedByAncestor", + name: "paused", outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "lastSnapshotTimestamp", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + name: "proxiableUUID", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], stateMutability: "view", }, { type: "function", - inputs: [], - name: "name", - outputs: [{ name: "", internalType: "string", type: "string" }], - stateMutability: "view", + inputs: [{ name: "groupPool", internalType: "address", type: "address" }], + name: "registerGroup", + outputs: [{ name: "groupId", internalType: "address", type: "address" }], + stateMutability: "nonpayable", }, { type: "function", - inputs: [], - name: "snapshot", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + inputs: [ + { name: "groupIpId", internalType: "address", type: "address" }, + { name: "ipIds", internalType: "address[]", type: "address[]" }, + ], + name: "removeIp", + outputs: [], stateMutability: "nonpayable", }, { type: "function", - inputs: [], - name: "symbol", - outputs: [{ name: "", internalType: "string", type: "string" }], - stateMutability: "view", + inputs: [{ name: "newAuthority", internalType: "address", type: "address" }], + name: "setAuthority", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", - inputs: [], - name: "tokens", - outputs: [{ name: "", internalType: "address[]", type: "address[]" }], + inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }], + name: "supportsInterface", + outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "totalSupply", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - stateMutability: "view", + name: "unpause", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "snapshotId", internalType: "uint256", type: "uint256" }], - name: "totalSupplyAt", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - stateMutability: "view", + inputs: [ + { name: "newImplementation", internalType: "address", type: "address" }, + { name: "data", internalType: "bytes", type: "bytes" }, + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", }, { type: "function", - inputs: [ - { name: "to", internalType: "address", type: "address" }, - { name: "amount", internalType: "uint256", type: "uint256" }, - ], - name: "transfer", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [ - { name: "from", internalType: "address", type: "address" }, - { name: "to", internalType: "address", type: "address" }, - { name: "amount", internalType: "uint256", type: "uint256" }, - ], - name: "transferFrom", - outputs: [{ name: "", internalType: "bool", type: "bool" }], + inputs: [{ name: "rewardPool", internalType: "address", type: "address" }], + name: "whitelistGroupRewardPool", + outputs: [], stateMutability: "nonpayable", }, - { - type: "function", - inputs: [{ name: "snapshotId", internalType: "uint256", type: "uint256" }], - name: "unclaimedAtSnapshot", - outputs: [{ name: "", internalType: "uint32", type: "uint32" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [], - name: "unclaimedRoyaltyTokens", - outputs: [{ name: "", internalType: "uint32", type: "uint32" }], - stateMutability: "view", - }, ] as const; /** * */ -export const ipRoyaltyVaultImplAddress = { - 1513: "0xfb5b5B61c9a437E06Ba87367aaBf3766d091E3D1", +export const groupingModuleAddress = { + 1513: "0xaB7a16Ad9e46656C59e6071d920feeE7A3416ECf", } as const; /** * */ -export const ipRoyaltyVaultImplConfig = { - address: ipRoyaltyVaultImplAddress, - abi: ipRoyaltyVaultImplAbi, +export const groupingModuleConfig = { + address: groupingModuleAddress, + abi: groupingModuleAbi, } as const; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// LicenseRegistry +// GroupingWorkflows ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * */ -export const licenseRegistryAbi = [ +export const groupingWorkflowsAbi = [ { type: "constructor", inputs: [ + { name: "accessController", internalType: "address", type: "address" }, + { name: "coreMetadataModule", internalType: "address", type: "address" }, + { name: "groupingModule", internalType: "address", type: "address" }, + { name: "groupNft", internalType: "address", type: "address" }, + { name: "ipAssetRegistry", internalType: "address", type: "address" }, + { name: "licenseRegistry", internalType: "address", type: "address" }, { name: "licensingModule", internalType: "address", type: "address" }, - { name: "disputeModule", internalType: "address", type: "address" }, - { name: "ipGraphAcl", internalType: "address", type: "address" }, + { name: "pilTemplate", internalType: "address", type: "address" }, ], stateMutability: "nonpayable", }, @@ -2728,152 +3050,8 @@ export const licenseRegistryAbi = [ }, { type: "error", inputs: [], name: "ERC1967NonPayable" }, { type: "error", inputs: [], name: "FailedInnerCall" }, + { type: "error", inputs: [], name: "GroupingWorkflows__ZeroAddressParam" }, { type: "error", inputs: [], name: "InvalidInitialization" }, - { - type: "error", - inputs: [ - { name: "childIpId", internalType: "address", type: "address" }, - { name: "parentIpIds", internalType: "address[]", type: "address[]" }, - ], - name: "LicenseRegistry__AddParentIpToIPGraphFailed", - }, - { - type: "error", - inputs: [], - name: "LicenseRegistry__CallerNotLicensingModule", - }, - { - type: "error", - inputs: [{ name: "childIpId", internalType: "address", type: "address" }], - name: "LicenseRegistry__DerivativeAlreadyRegistered", - }, - { - type: "error", - inputs: [{ name: "childIpId", internalType: "address", type: "address" }], - name: "LicenseRegistry__DerivativeIpAlreadyHasChild", - }, - { - type: "error", - inputs: [{ name: "childIpId", internalType: "address", type: "address" }], - name: "LicenseRegistry__DerivativeIpAlreadyHasLicense", - }, - { - type: "error", - inputs: [{ name: "ipId", internalType: "address", type: "address" }], - name: "LicenseRegistry__DerivativeIsParent", - }, - { - type: "error", - inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - ], - name: "LicenseRegistry__DuplicateLicense", - }, - { - type: "error", - inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "index", internalType: "uint256", type: "uint256" }, - { name: "length", internalType: "uint256", type: "uint256" }, - ], - name: "LicenseRegistry__IndexOutOfBounds", - }, - { - type: "error", - inputs: [{ name: "ipId", internalType: "address", type: "address" }], - name: "LicenseRegistry__IpExpired", - }, - { - type: "error", - inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - ], - name: "LicenseRegistry__LicenseTermsAlreadyAttached", - }, - { - type: "error", - inputs: [ - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - ], - name: "LicenseRegistry__LicenseTermsNotExists", - }, - { - type: "error", - inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - ], - name: "LicenseRegistry__LicensorIpHasNoLicenseTerms", - }, - { - type: "error", - inputs: [{ name: "licenseTemplate", internalType: "address", type: "address" }], - name: "LicenseRegistry__NotLicenseTemplate", - }, - { - type: "error", - inputs: [{ name: "ipId", internalType: "address", type: "address" }], - name: "LicenseRegistry__ParentIpExpired", - }, - { - type: "error", - inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - ], - name: "LicenseRegistry__ParentIpHasNoLicenseTerms", - }, - { - type: "error", - inputs: [{ name: "ipId", internalType: "address", type: "address" }], - name: "LicenseRegistry__ParentIpTagged", - }, - { - type: "error", - inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "licenseTemplate", internalType: "address", type: "address" }, - ], - name: "LicenseRegistry__ParentIpUnmatchedLicenseTemplate", - }, - { - type: "error", - inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "newLicenseTemplate", internalType: "address", type: "address" }, - ], - name: "LicenseRegistry__UnmatchedLicenseTemplate", - }, - { - type: "error", - inputs: [{ name: "licenseTemplate", internalType: "address", type: "address" }], - name: "LicenseRegistry__UnregisteredLicenseTemplate", - }, - { type: "error", inputs: [], name: "LicenseRegistry__ZeroAccessManager" }, - { type: "error", inputs: [], name: "LicenseRegistry__ZeroDisputeModule" }, - { type: "error", inputs: [], name: "LicenseRegistry__ZeroIPGraphACL" }, - { type: "error", inputs: [], name: "LicenseRegistry__ZeroLicenseTemplate" }, - { type: "error", inputs: [], name: "LicenseRegistry__ZeroLicensingModule" }, - { - type: "error", - inputs: [], - name: "LicensingModule__DerivativesCannotAddLicenseTerms", - }, - { - type: "error", - inputs: [ - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - ], - name: "LicensingModule__LicenseTermsNotFound", - }, { type: "error", inputs: [], name: "NotInitializing" }, { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, { @@ -2881,6 +3059,7 @@ export const licenseRegistryAbi = [ inputs: [{ name: "slot", internalType: "bytes32", type: "bytes32" }], name: "UUPSUnsupportedProxiableUUID", }, + { type: "error", inputs: [], name: "Workflow__CallerNotAuthorizedToMint" }, { type: "event", anonymous: false, @@ -2894,39 +3073,6 @@ export const licenseRegistryAbi = [ ], name: "AuthorityUpdated", }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "licenseTemplate", - internalType: "address", - type: "address", - indexed: false, - }, - { - name: "licenseTermsId", - internalType: "uint256", - type: "uint256", - indexed: false, - }, - ], - name: "DefaultLicenseTermsSet", - }, - { - type: "event", - anonymous: false, - inputs: [ - { name: "ipId", internalType: "address", type: "address", indexed: true }, - { - name: "expireTime", - internalType: "uint256", - type: "uint256", - indexed: false, - }, - ], - name: "ExpirationTimeSet", - }, { type: "event", anonymous: false, @@ -2945,93 +3091,60 @@ export const licenseRegistryAbi = [ anonymous: false, inputs: [ { - name: "licenseTemplate", + name: "implementation", internalType: "address", type: "address", indexed: true, }, ], - name: "LicenseTemplateRegistered", + name: "Upgraded", }, { - type: "event", - anonymous: false, - inputs: [ - { name: "ipId", internalType: "address", type: "address", indexed: true }, + type: "function", + inputs: [], + name: "ACCESS_CONTROLLER", + outputs: [{ name: "", internalType: "contract IAccessController", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "CORE_METADATA_MODULE", + outputs: [ { - name: "licensingConfig", - internalType: "struct Licensing.LicensingConfig", - type: "tuple", - components: [ - { name: "isSet", internalType: "bool", type: "bool" }, - { name: "mintingFee", internalType: "uint256", type: "uint256" }, - { name: "licensingHook", internalType: "address", type: "address" }, - { name: "hookData", internalType: "bytes", type: "bytes" }, - ], - indexed: false, + name: "", + internalType: "contract ICoreMetadataModule", + type: "address", }, ], - name: "LicensingConfigSetForIP", - }, - { - type: "event", - anonymous: false, - inputs: [ - { name: "ipId", internalType: "address", type: "address", indexed: true }, - { - name: "licenseTemplate", - internalType: "address", - type: "address", - indexed: true, - }, - { - name: "licenseTermsId", - internalType: "uint256", - type: "uint256", - indexed: true, - }, - ], - name: "LicensingConfigSetForLicense", - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "implementation", - internalType: "address", - type: "address", - indexed: true, - }, - ], - name: "Upgraded", + stateMutability: "view", }, { type: "function", inputs: [], - name: "DISPUTE_MODULE", - outputs: [{ name: "", internalType: "contract IDisputeModule", type: "address" }], + name: "GROUPING_MODULE", + outputs: [{ name: "", internalType: "contract IGroupingModule", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "EXPIRATION_TIME", - outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + name: "GROUP_NFT", + outputs: [{ name: "", internalType: "contract GroupNFT", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "IP_GRAPH_ACL", - outputs: [{ name: "", internalType: "contract IPGraphACL", type: "address" }], + name: "IP_ASSET_REGISTRY", + outputs: [{ name: "", internalType: "contract IIPAssetRegistry", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "IP_GRAPH_CONTRACT", - outputs: [{ name: "", internalType: "address", type: "address" }], + name: "LICENSE_REGISTRY", + outputs: [{ name: "", internalType: "contract ILicenseRegistry", type: "address" }], stateMutability: "view", }, { @@ -3044,20 +3157,22 @@ export const licenseRegistryAbi = [ { type: "function", inputs: [], - name: "UPGRADE_INTERFACE_VERSION", - outputs: [{ name: "", internalType: "string", type: "string" }], + name: "PIL_TEMPLATE", + outputs: [ + { + name: "", + internalType: "contract IPILicenseTemplate", + type: "address", + }, + ], stateMutability: "view", }, { type: "function", - inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - ], - name: "attachLicenseTermsToIp", - outputs: [], - stateMutability: "nonpayable", + inputs: [], + name: "UPGRADE_INTERFACE_VERSION", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", }, { type: "function", @@ -3069,320 +3184,642 @@ export const licenseRegistryAbi = [ { type: "function", inputs: [ - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - ], - name: "exists", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "index", internalType: "uint256", type: "uint256" }, + { name: "groupId", internalType: "address", type: "address" }, + { name: "currencyTokens", internalType: "address[]", type: "address[]" }, + { + name: "groupSnapshotIds", + internalType: "uint256[]", + type: "uint256[]", + }, + { name: "memberIpIds", internalType: "address[]", type: "address[]" }, ], - name: "getAttachedLicenseTerms", + name: "collectRoyaltiesAndClaimReward", outputs: [ - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { + name: "collectedRoyalties", + internalType: "uint256[]", + type: "uint256[]", + }, ], - stateMutability: "view", + stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "ipId", internalType: "address", type: "address" }], - name: "getAttachedLicenseTermsCount", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - stateMutability: "view", + inputs: [{ name: "accessManager", internalType: "address", type: "address" }], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", inputs: [], - name: "getDefaultLicenseTerms", - outputs: [ - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - ], - stateMutability: "view", - }, - { - type: "function", - inputs: [ - { name: "parentIpId", internalType: "address", type: "address" }, - { name: "index", internalType: "uint256", type: "uint256" }, - ], - name: "getDerivativeIp", - outputs: [{ name: "childIpId", internalType: "address", type: "address" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [{ name: "parentIpId", internalType: "address", type: "address" }], - name: "getDerivativeIpCount", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [{ name: "ipId", internalType: "address", type: "address" }], - name: "getExpireTime", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + name: "isConsumingScheduledOp", + outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], stateMutability: "view", }, { type: "function", inputs: [ - { name: "ipId", internalType: "address", type: "address" }, + { name: "spgNftContract", internalType: "address", type: "address" }, + { name: "groupId", internalType: "address", type: "address" }, + { name: "recipient", internalType: "address", type: "address" }, { name: "licenseTemplate", internalType: "address", type: "address" }, { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - ], - name: "getLicensingConfig", - outputs: [ { - name: "", - internalType: "struct Licensing.LicensingConfig", + name: "ipMetadata", + internalType: "struct WorkflowStructs.IPMetadata", type: "tuple", components: [ - { name: "isSet", internalType: "bool", type: "bool" }, - { name: "mintingFee", internalType: "uint256", type: "uint256" }, - { name: "licensingHook", internalType: "address", type: "address" }, - { name: "hookData", internalType: "bytes", type: "bytes" }, + { name: "ipMetadataURI", internalType: "string", type: "string" }, + { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, + { name: "nftMetadataURI", internalType: "string", type: "string" }, + { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, + ], + }, + { + name: "sigAddToGroup", + internalType: "struct WorkflowStructs.SignatureData", + type: "tuple", + components: [ + { name: "signer", internalType: "address", type: "address" }, + { name: "deadline", internalType: "uint256", type: "uint256" }, + { name: "signature", internalType: "bytes", type: "bytes" }, ], }, ], - stateMutability: "view", - }, - { - type: "function", - inputs: [ - { name: "childIpId", internalType: "address", type: "address" }, - { name: "index", internalType: "uint256", type: "uint256" }, + name: "mintAndRegisterIpAndAttachLicenseAndAddToGroup", + outputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, ], - name: "getParentIp", - outputs: [{ name: "parentIpId", internalType: "address", type: "address" }], - stateMutability: "view", + stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "childIpId", internalType: "address", type: "address" }], - name: "getParentIpCount", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - stateMutability: "view", + inputs: [{ name: "data", internalType: "bytes[]", type: "bytes[]" }], + name: "multicall", + outputs: [{ name: "results", internalType: "bytes[]", type: "bytes[]" }], + stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "parentIpId", internalType: "address", type: "address" }], - name: "hasDerivativeIps", - outputs: [{ name: "", internalType: "bool", type: "bool" }], + inputs: [], + name: "proxiableUUID", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], stateMutability: "view", }, { type: "function", inputs: [ - { name: "ipId", internalType: "address", type: "address" }, + { name: "groupPool", internalType: "address", type: "address" }, { name: "licenseTemplate", internalType: "address", type: "address" }, { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, ], - name: "hasIpAttachedLicenseTerms", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "view", + name: "registerGroupAndAttachLicense", + outputs: [{ name: "groupId", internalType: "address", type: "address" }], + stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "accessManager", internalType: "address", type: "address" }], - name: "initialize", - outputs: [], + inputs: [ + { name: "groupPool", internalType: "address", type: "address" }, + { name: "ipIds", internalType: "address[]", type: "address[]" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + ], + name: "registerGroupAndAttachLicenseAndAddIps", + outputs: [{ name: "groupId", internalType: "address", type: "address" }], stateMutability: "nonpayable", }, { type: "function", - inputs: [], - name: "isConsumingScheduledOp", - outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], - stateMutability: "view", + inputs: [ + { name: "nftContract", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + { name: "groupId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { + name: "ipMetadata", + internalType: "struct WorkflowStructs.IPMetadata", + type: "tuple", + components: [ + { name: "ipMetadataURI", internalType: "string", type: "string" }, + { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, + { name: "nftMetadataURI", internalType: "string", type: "string" }, + { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, + ], + }, + { + name: "sigMetadataAndAttach", + internalType: "struct WorkflowStructs.SignatureData", + type: "tuple", + components: [ + { name: "signer", internalType: "address", type: "address" }, + { name: "deadline", internalType: "uint256", type: "uint256" }, + { name: "signature", internalType: "bytes", type: "bytes" }, + ], + }, + { + name: "sigAddToGroup", + internalType: "struct WorkflowStructs.SignatureData", + type: "tuple", + components: [ + { name: "signer", internalType: "address", type: "address" }, + { name: "deadline", internalType: "uint256", type: "uint256" }, + { name: "signature", internalType: "bytes", type: "bytes" }, + ], + }, + ], + name: "registerIpAndAttachLicenseAndAddToGroup", + outputs: [{ name: "ipId", internalType: "address", type: "address" }], + stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "childIpId", internalType: "address", type: "address" }], - name: "isDerivativeIp", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "view", + inputs: [{ name: "newAuthority", internalType: "address", type: "address" }], + name: "setAuthority", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "ipId", internalType: "address", type: "address" }], - name: "isExpiredNow", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "view", + inputs: [ + { + name: "newNftContractBeacon", + internalType: "address", + type: "address", + }, + ], + name: "setNftContractBeacon", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "parentIpId", internalType: "address", type: "address" }, - { name: "childIpId", internalType: "address", type: "address" }, + { name: "newImplementation", internalType: "address", type: "address" }, + { name: "data", internalType: "bytes", type: "bytes" }, ], - name: "isParentIp", - outputs: [{ name: "", internalType: "bool", type: "bool" }], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + }, +] as const; + +/** + * + */ +export const groupingWorkflowsAddress = { + 1513: "0x426fF4F7E9Debe565F5Fe6F53334Ad3982295E20", +} as const; + +/** + * + */ +export const groupingWorkflowsConfig = { + address: groupingWorkflowsAddress, + abi: groupingWorkflowsAbi, +} as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// IPAccountImpl +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * + */ +export const ipAccountImplAbi = [ + { + type: "constructor", + inputs: [ + { name: "accessController", internalType: "address", type: "address" }, + { name: "ipAssetRegistry", internalType: "address", type: "address" }, + { name: "licenseRegistry", internalType: "address", type: "address" }, + { name: "moduleRegistry", internalType: "address", type: "address" }, + ], + stateMutability: "nonpayable", + }, + { type: "error", inputs: [], name: "FnSelectorNotRecognized" }, + { type: "error", inputs: [], name: "IPAccountStorage__InvalidBatchLengths" }, + { + type: "error", + inputs: [{ name: "module", internalType: "address", type: "address" }], + name: "IPAccountStorage__NotRegisteredModule", + }, + { type: "error", inputs: [], name: "IPAccountStorage__ZeroIpAssetRegistry" }, + { type: "error", inputs: [], name: "IPAccountStorage__ZeroLicenseRegistry" }, + { type: "error", inputs: [], name: "IPAccountStorage__ZeroModuleRegistry" }, + { type: "error", inputs: [], name: "IPAccount__ExpiredSignature" }, + { type: "error", inputs: [], name: "IPAccount__InvalidCalldata" }, + { type: "error", inputs: [], name: "IPAccount__InvalidOperation" }, + { type: "error", inputs: [], name: "IPAccount__InvalidSignature" }, + { type: "error", inputs: [], name: "IPAccount__InvalidSigner" }, + { type: "error", inputs: [], name: "IPAccount__ZeroAccessController" }, + { type: "error", inputs: [], name: "OperationNotSupported" }, + { type: "error", inputs: [], name: "SelfOwnDetected" }, + { type: "error", inputs: [], name: "Unauthorized" }, + { type: "error", inputs: [], name: "UnauthorizedCallContext" }, + { type: "error", inputs: [], name: "UpgradeFailed" }, + { + type: "event", + anonymous: false, + inputs: [ + { name: "to", internalType: "address", type: "address", indexed: true }, + { + name: "value", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + { name: "data", internalType: "bytes", type: "bytes", indexed: false }, + { + name: "nonce", + internalType: "bytes32", + type: "bytes32", + indexed: false, + }, + ], + name: "Executed", + }, + { + type: "event", + anonymous: false, + inputs: [ + { name: "to", internalType: "address", type: "address", indexed: true }, + { + name: "value", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + { name: "data", internalType: "bytes", type: "bytes", indexed: false }, + { + name: "nonce", + internalType: "bytes32", + type: "bytes32", + indexed: false, + }, + { + name: "deadline", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + { + name: "signer", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "signature", + internalType: "bytes", + type: "bytes", + indexed: false, + }, + ], + name: "ExecutedWithSig", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "implementation", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "Upgraded", + }, + { type: "fallback", stateMutability: "payable" }, + { + type: "function", + inputs: [], + name: "ACCESS_CONTROLLER", + outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "licenseTemplate", internalType: "address", type: "address" }], - name: "isRegisteredLicenseTemplate", - outputs: [{ name: "", internalType: "bool", type: "bool" }], + inputs: [], + name: "IP_ASSET_REGISTRY", + outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "proxiableUUID", - outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + name: "LICENSE_REGISTRY", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "MODULE_REGISTRY", + outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [ - { name: "childIpId", internalType: "address", type: "address" }, - { name: "parentIpIds", internalType: "address[]", type: "address[]" }, - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsIds", internalType: "uint256[]", type: "uint256[]" }, - { name: "isUsingLicenseToken", internalType: "bool", type: "bool" }, + { name: "", internalType: "bytes32", type: "bytes32" }, + { name: "", internalType: "bytes32", type: "bytes32" }, ], - name: "registerDerivativeIp", - outputs: [], - stateMutability: "nonpayable", + name: "bytes32Data", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view", }, { type: "function", - inputs: [{ name: "licenseTemplate", internalType: "address", type: "address" }], - name: "registerLicenseTemplate", - outputs: [], - stateMutability: "nonpayable", + inputs: [ + { name: "", internalType: "bytes32", type: "bytes32" }, + { name: "", internalType: "bytes32", type: "bytes32" }, + ], + name: "bytesData", + outputs: [{ name: "", internalType: "bytes", type: "bytes" }], + stateMutability: "view", }, { type: "function", - inputs: [{ name: "newAuthority", internalType: "address", type: "address" }], - name: "setAuthority", - outputs: [], - stateMutability: "nonpayable", + inputs: [], + name: "eip712Domain", + outputs: [ + { name: "fields", internalType: "bytes1", type: "bytes1" }, + { name: "name", internalType: "string", type: "string" }, + { name: "version", internalType: "string", type: "string" }, + { name: "chainId", internalType: "uint256", type: "uint256" }, + { name: "verifyingContract", internalType: "address", type: "address" }, + { name: "salt", internalType: "bytes32", type: "bytes32" }, + { name: "extensions", internalType: "uint256[]", type: "uint256[]" }, + ], + stateMutability: "view", }, { type: "function", inputs: [ - { name: "newLicenseTemplate", internalType: "address", type: "address" }, - { name: "newLicenseTermsId", internalType: "uint256", type: "uint256" }, + { name: "to", internalType: "address", type: "address" }, + { name: "value", internalType: "uint256", type: "uint256" }, + { name: "data", internalType: "bytes", type: "bytes" }, + { name: "operation", internalType: "uint8", type: "uint8" }, ], - name: "setDefaultLicenseTerms", - outputs: [], - stateMutability: "nonpayable", + name: "execute", + outputs: [{ name: "result", internalType: "bytes", type: "bytes" }], + stateMutability: "payable", }, { type: "function", inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { - name: "licensingConfig", - internalType: "struct Licensing.LicensingConfig", - type: "tuple", - components: [ - { name: "isSet", internalType: "bool", type: "bool" }, - { name: "mintingFee", internalType: "uint256", type: "uint256" }, - { name: "licensingHook", internalType: "address", type: "address" }, - { name: "hookData", internalType: "bytes", type: "bytes" }, - ], - }, + { name: "to", internalType: "address", type: "address" }, + { name: "value", internalType: "uint256", type: "uint256" }, + { name: "data", internalType: "bytes", type: "bytes" }, ], - name: "setLicensingConfigForIp", - outputs: [], - stateMutability: "nonpayable", + name: "execute", + outputs: [{ name: "result", internalType: "bytes", type: "bytes" }], + stateMutability: "payable", }, { type: "function", inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, { - name: "licensingConfig", - internalType: "struct Licensing.LicensingConfig", - type: "tuple", + name: "calls", + internalType: "struct ERC6551.Call[]", + type: "tuple[]", components: [ - { name: "isSet", internalType: "bool", type: "bool" }, - { name: "mintingFee", internalType: "uint256", type: "uint256" }, - { name: "licensingHook", internalType: "address", type: "address" }, - { name: "hookData", internalType: "bytes", type: "bytes" }, + { name: "target", internalType: "address", type: "address" }, + { name: "value", internalType: "uint256", type: "uint256" }, + { name: "data", internalType: "bytes", type: "bytes" }, ], }, + { name: "operation", internalType: "uint8", type: "uint8" }, ], - name: "setLicensingConfigForLicense", - outputs: [], - stateMutability: "nonpayable", + name: "executeBatch", + outputs: [{ name: "results", internalType: "bytes[]", type: "bytes[]" }], + stateMutability: "payable", }, { type: "function", inputs: [ - { name: "newImplementation", internalType: "address", type: "address" }, + { name: "to", internalType: "address", type: "address" }, + { name: "value", internalType: "uint256", type: "uint256" }, { name: "data", internalType: "bytes", type: "bytes" }, + { name: "signer", internalType: "address", type: "address" }, + { name: "deadline", internalType: "uint256", type: "uint256" }, + { name: "signature", internalType: "bytes", type: "bytes" }, ], - name: "upgradeToAndCall", - outputs: [], + name: "executeWithSig", + outputs: [{ name: "result", internalType: "bytes", type: "bytes" }], stateMutability: "payable", }, + { + type: "function", + inputs: [{ name: "key", internalType: "bytes32", type: "bytes32" }], + name: "getBytes", + outputs: [{ name: "", internalType: "bytes", type: "bytes" }], + stateMutability: "view", + }, { type: "function", inputs: [ - { name: "licensorIpId", internalType: "address", type: "address" }, - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - { name: "isMintedByIpOwner", internalType: "bool", type: "bool" }, + { name: "namespace", internalType: "bytes32", type: "bytes32" }, + { name: "key", internalType: "bytes32", type: "bytes32" }, ], - name: "verifyMintLicenseToken", + name: "getBytes", + outputs: [{ name: "", internalType: "bytes", type: "bytes" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "namespace", internalType: "bytes32", type: "bytes32" }, + { name: "key", internalType: "bytes32", type: "bytes32" }, + ], + name: "getBytes32", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "key", internalType: "bytes32", type: "bytes32" }], + name: "getBytes32", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "namespaces", internalType: "bytes32[]", type: "bytes32[]" }, + { name: "keys", internalType: "bytes32[]", type: "bytes32[]" }, + ], + name: "getBytes32Batch", + outputs: [{ name: "values", internalType: "bytes32[]", type: "bytes32[]" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "namespaces", internalType: "bytes32[]", type: "bytes32[]" }, + { name: "keys", internalType: "bytes32[]", type: "bytes32[]" }, + ], + name: "getBytesBatch", + outputs: [{ name: "values", internalType: "bytes[]", type: "bytes[]" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "hash", internalType: "bytes32", type: "bytes32" }, + { name: "signature", internalType: "bytes", type: "bytes" }, + ], + name: "isValidSignature", + outputs: [{ name: "result", internalType: "bytes4", type: "bytes4" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "signer", internalType: "address", type: "address" }, + { name: "data", internalType: "bytes", type: "bytes" }, + ], + name: "isValidSigner", + outputs: [{ name: "result", internalType: "bytes4", type: "bytes4" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "signer", internalType: "address", type: "address" }, + { name: "to", internalType: "address", type: "address" }, + { name: "data", internalType: "bytes", type: "bytes" }, + ], + name: "isValidSigner", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "owner", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "proxiableUUID", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "key", internalType: "bytes32", type: "bytes32" }, + { name: "value", internalType: "bytes", type: "bytes" }, + ], + name: "setBytes", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "key", internalType: "bytes32", type: "bytes32" }, + { name: "value", internalType: "bytes32", type: "bytes32" }, + ], + name: "setBytes32", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "keys", internalType: "bytes32[]", type: "bytes32[]" }, + { name: "values", internalType: "bytes32[]", type: "bytes32[]" }, + ], + name: "setBytes32Batch", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "keys", internalType: "bytes32[]", type: "bytes32[]" }, + { name: "values", internalType: "bytes[]", type: "bytes[]" }, + ], + name: "setBytesBatch", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "state", + outputs: [{ name: "result", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }], + name: "supportsInterface", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "token", outputs: [ - { - name: "", - internalType: "struct Licensing.LicensingConfig", - type: "tuple", - components: [ - { name: "isSet", internalType: "bool", type: "bool" }, - { name: "mintingFee", internalType: "uint256", type: "uint256" }, - { name: "licensingHook", internalType: "address", type: "address" }, - { name: "hookData", internalType: "bytes", type: "bytes" }, - ], - }, + { name: "", internalType: "uint256", type: "uint256" }, + { name: "", internalType: "address", type: "address" }, + { name: "", internalType: "uint256", type: "uint256" }, ], stateMutability: "view", }, + { + type: "function", + inputs: [ + { name: "newImplementation", internalType: "address", type: "address" }, + { name: "data", internalType: "bytes", type: "bytes" }, + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + }, + { type: "receive", stateMutability: "payable" }, ] as const; /** * */ -export const licenseRegistryAddress = { - 1513: "0xF542AF9a5A6E4A85a4f084D38B322516ec336097", +export const ipAccountImplAddress = { + 1513: "0xaE2D8F01920DB2328BEd676652154c9D2Cb863fa", } as const; /** * */ -export const licenseRegistryConfig = { - address: licenseRegistryAddress, - abi: licenseRegistryAbi, +export const ipAccountImplConfig = { + address: ipAccountImplAddress, + abi: ipAccountImplAbi, } as const; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// LicenseToken +// IPAssetRegistry ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * */ -export const licenseTokenAbi = [ +export const ipAssetRegistryAbi = [ { type: "constructor", inputs: [ - { name: "licensingModule", internalType: "address", type: "address" }, - { name: "disputeModule", internalType: "address", type: "address" }, + { name: "erc6551Registry", internalType: "address", type: "address" }, + { name: "ipAccountImpl", internalType: "address", type: "address" }, + { name: "groupingModule", internalType: "address", type: "address" }, ], stateMutability: "nonpayable", }, @@ -3415,185 +3852,160 @@ export const licenseTokenAbi = [ name: "ERC1967InvalidImplementation", }, { type: "error", inputs: [], name: "ERC1967NonPayable" }, - { type: "error", inputs: [], name: "ERC721EnumerableForbiddenBatchMint" }, + { type: "error", inputs: [], name: "EnforcedPause" }, + { type: "error", inputs: [], name: "ExpectedPause" }, + { type: "error", inputs: [], name: "FailedInnerCall" }, { type: "error", - inputs: [ - { name: "sender", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, - { name: "owner", internalType: "address", type: "address" }, - ], - name: "ERC721IncorrectOwner", + inputs: [{ name: "caller", internalType: "address", type: "address" }], + name: "GroupIPAssetRegistry__CallerIsNotGroupingModule", }, { type: "error", - inputs: [ - { name: "operator", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, - ], - name: "ERC721InsufficientApproval", + inputs: [{ name: "groupPool", internalType: "address", type: "address" }], + name: "GroupIPAssetRegistry__GroupRewardPoolNotRegistered", }, { type: "error", - inputs: [{ name: "approver", internalType: "address", type: "address" }], - name: "ERC721InvalidApprover", + inputs: [{ name: "rewardPool", internalType: "address", type: "address" }], + name: "GroupIPAssetRegistry__InvalidGroupRewardPool", }, { type: "error", - inputs: [{ name: "operator", internalType: "address", type: "address" }], - name: "ERC721InvalidOperator", + inputs: [{ name: "groupId", internalType: "address", type: "address" }], + name: "GroupIPAssetRegistry__NotRegisteredGroupIP", }, { type: "error", - inputs: [{ name: "owner", internalType: "address", type: "address" }], - name: "ERC721InvalidOwner", + inputs: [{ name: "ipId", internalType: "address", type: "address" }], + name: "GroupIPAssetRegistry__NotRegisteredIP", }, + { type: "error", inputs: [], name: "IPAccountRegistry_ZeroERC6551Registry" }, + { type: "error", inputs: [], name: "IPAccountRegistry_ZeroIpAccountImpl" }, + { type: "error", inputs: [], name: "IPAssetRegistry__AlreadyRegistered" }, { type: "error", - inputs: [{ name: "receiver", internalType: "address", type: "address" }], - name: "ERC721InvalidReceiver", + inputs: [ + { name: "contractAddress", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + ], + name: "IPAssetRegistry__InvalidToken", }, { type: "error", - inputs: [{ name: "sender", internalType: "address", type: "address" }], - name: "ERC721InvalidSender", + inputs: [{ name: "contractAddress", internalType: "address", type: "address" }], + name: "IPAssetRegistry__UnsupportedIERC721", }, { type: "error", - inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], - name: "ERC721NonexistentToken", + inputs: [{ name: "contractAddress", internalType: "address", type: "address" }], + name: "IPAssetRegistry__UnsupportedIERC721Metadata", }, + { type: "error", inputs: [], name: "IPAssetRegistry__ZeroAccessManager" }, + { type: "error", inputs: [], name: "InvalidInitialization" }, + { type: "error", inputs: [], name: "NotInitializing" }, { type: "error", inputs: [ - { name: "owner", internalType: "address", type: "address" }, - { name: "index", internalType: "uint256", type: "uint256" }, + { name: "value", internalType: "uint256", type: "uint256" }, + { name: "length", internalType: "uint256", type: "uint256" }, ], - name: "ERC721OutOfBoundsIndex", + name: "StringsInsufficientHexLength", }, - { type: "error", inputs: [], name: "FailedInnerCall" }, - { type: "error", inputs: [], name: "InvalidInitialization" }, + { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, { type: "error", - inputs: [ - { name: "licenseTemplate", internalType: "address", type: "address" }, + inputs: [{ name: "slot", internalType: "bytes32", type: "bytes32" }], + name: "UUPSUnsupportedProxiableUUID", + }, + { + type: "event", + anonymous: false, + inputs: [ { - name: "anotherLicenseTemplate", + name: "authority", internalType: "address", type: "address", + indexed: false, }, ], - name: "LicenseToken__AllLicenseTokensMustFromSameLicenseTemplate", - }, - { - type: "error", - inputs: [ - { name: "tokenId", internalType: "uint256", type: "uint256" }, - { name: "caller", internalType: "address", type: "address" }, - { name: "childIpIp", internalType: "address", type: "address" }, - { name: "actualTokenOwner", internalType: "address", type: "address" }, - ], - name: "LicenseToken__CallerAndChildIPNotTokenOwner", - }, - { type: "error", inputs: [], name: "LicenseToken__CallerNotLicensingModule" }, - { type: "error", inputs: [], name: "LicenseToken__NotTransferable" }, - { - type: "error", - inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], - name: "LicenseToken__RevokedLicense", - }, - { type: "error", inputs: [], name: "LicenseToken__ZeroAccessManager" }, - { type: "error", inputs: [], name: "NotInitializing" }, - { - type: "error", - inputs: [ - { name: "value", internalType: "uint256", type: "uint256" }, - { name: "length", internalType: "uint256", type: "uint256" }, - ], - name: "StringsInsufficientHexLength", - }, - { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, - { - type: "error", - inputs: [{ name: "slot", internalType: "bytes32", type: "bytes32" }], - name: "UUPSUnsupportedProxiableUUID", + name: "AuthorityUpdated", }, { type: "event", anonymous: false, inputs: [ { - name: "owner", + name: "account", internalType: "address", type: "address", indexed: true, }, { - name: "approved", + name: "implementation", internalType: "address", type: "address", indexed: true, }, { - name: "tokenId", + name: "chainId", internalType: "uint256", type: "uint256", indexed: true, }, - ], - name: "Approval", - }, - { - type: "event", - anonymous: false, - inputs: [ { - name: "owner", + name: "tokenContract", internalType: "address", type: "address", - indexed: true, + indexed: false, }, { - name: "operator", - internalType: "address", - type: "address", - indexed: true, + name: "tokenId", + internalType: "uint256", + type: "uint256", + indexed: false, }, - { name: "approved", internalType: "bool", type: "bool", indexed: false }, ], - name: "ApprovalForAll", + name: "IPAccountRegistered", }, { type: "event", anonymous: false, inputs: [ { - name: "authority", + name: "ipId", internalType: "address", type: "address", indexed: false, }, - ], - name: "AuthorityUpdated", - }, - { - type: "event", - anonymous: false, - inputs: [ { - name: "_fromTokenId", + name: "chainId", internalType: "uint256", type: "uint256", - indexed: false, + indexed: true, }, { - name: "_toTokenId", + name: "tokenContract", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "tokenId", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + { name: "name", internalType: "string", type: "string", indexed: false }, + { name: "uri", internalType: "string", type: "string", indexed: false }, + { + name: "registrationDate", internalType: "uint256", type: "uint256", indexed: false, }, ], - name: "BatchMetadataUpdate", + name: "IPRegistered", }, { type: "event", @@ -3613,40 +4025,26 @@ export const licenseTokenAbi = [ anonymous: false, inputs: [ { - name: "minter", - internalType: "address", - type: "address", - indexed: true, - }, - { - name: "receiver", + name: "account", internalType: "address", type: "address", - indexed: true, - }, - { - name: "tokenId", - internalType: "uint256", - type: "uint256", - indexed: true, + indexed: false, }, ], - name: "LicenseTokenMinted", + name: "Paused", }, { type: "event", anonymous: false, inputs: [ - { name: "from", internalType: "address", type: "address", indexed: true }, - { name: "to", internalType: "address", type: "address", indexed: true }, { - name: "tokenId", - internalType: "uint256", - type: "uint256", - indexed: true, + name: "account", + internalType: "address", + type: "address", + indexed: false, }, ], - name: "Transfer", + name: "Unpaused", }, { type: "event", @@ -3664,111 +4062,100 @@ export const licenseTokenAbi = [ { type: "function", inputs: [], - name: "DISPUTE_MODULE", - outputs: [{ name: "", internalType: "contract IDisputeModule", type: "address" }], + name: "ERC6551_PUBLIC_REGISTRY", + outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "LICENSING_MODULE", - outputs: [{ name: "", internalType: "contract ILicensingModule", type: "address" }], + name: "GROUPING_MODULE", + outputs: [{ name: "", internalType: "contract IGroupingModule", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "UPGRADE_INTERFACE_VERSION", - outputs: [{ name: "", internalType: "string", type: "string" }], + name: "IP_ACCOUNT_IMPL", + outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [ - { name: "to", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, - ], - name: "approve", - outputs: [], - stateMutability: "nonpayable", + inputs: [], + name: "IP_ACCOUNT_SALT", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view", }, { type: "function", inputs: [], - name: "authority", - outputs: [{ name: "", internalType: "address", type: "address" }], + name: "UPGRADE_INTERFACE_VERSION", + outputs: [{ name: "", internalType: "string", type: "string" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "owner", internalType: "address", type: "address" }], - name: "balanceOf", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - stateMutability: "view", + inputs: [{ name: "accessManager", internalType: "address", type: "address" }], + name: "__ProtocolPausable_init", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "holder", internalType: "address", type: "address" }, - { name: "tokenIds", internalType: "uint256[]", type: "uint256[]" }, + { name: "groupId", internalType: "address", type: "address" }, + { name: "ipIds", internalType: "address[]", type: "address[]" }, ], - name: "burnLicenseTokens", + name: "addGroupMember", outputs: [], stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], - name: "getApproved", + inputs: [], + name: "authority", outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], - name: "getLicenseTemplate", - outputs: [{ name: "", internalType: "address", type: "address" }], + inputs: [ + { name: "groupId", internalType: "address", type: "address" }, + { name: "ipId", internalType: "address", type: "address" }, + ], + name: "containsIp", + outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], - name: "getLicenseTermsId", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + inputs: [ + { name: "groupId", internalType: "address", type: "address" }, + { name: "startIndex", internalType: "uint256", type: "uint256" }, + { name: "size", internalType: "uint256", type: "uint256" }, + ], + name: "getGroupMembers", + outputs: [{ name: "results", internalType: "address[]", type: "address[]" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], - name: "getLicenseTokenMetadata", - outputs: [ - { - name: "", - internalType: "struct ILicenseToken.LicenseTokenMetadata", - type: "tuple", - components: [ - { name: "licensorIpId", internalType: "address", type: "address" }, - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - { name: "transferable", internalType: "bool", type: "bool" }, - ], - }, - ], + inputs: [{ name: "groupId", internalType: "address", type: "address" }], + name: "getGroupRewardPool", + outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], - name: "getLicensorIpId", + inputs: [], + name: "getIPAccountImpl", outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [ - { name: "accessManager", internalType: "address", type: "address" }, - { name: "imageUrl", internalType: "string", type: "string" }, - ], + inputs: [{ name: "accessManager", internalType: "address", type: "address" }], name: "initialize", outputs: [], stateMutability: "nonpayable", @@ -3776,11 +4163,23 @@ export const licenseTokenAbi = [ { type: "function", inputs: [ - { name: "owner", internalType: "address", type: "address" }, - { name: "operator", internalType: "address", type: "address" }, + { name: "chainId", internalType: "uint256", type: "uint256" }, + { name: "tokenContract", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, ], - name: "isApprovedForAll", - outputs: [{ name: "", internalType: "bool", type: "bool" }], + name: "ipAccount", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "chainId", internalType: "uint256", type: "uint256" }, + { name: "tokenContract", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + ], + name: "ipId", + outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { @@ -3792,37 +4191,37 @@ export const licenseTokenAbi = [ }, { type: "function", - inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], - name: "isLicenseTokenRevoked", + inputs: [{ name: "id", internalType: "address", type: "address" }], + name: "isRegistered", outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "view", }, { type: "function", - inputs: [ - { name: "licensorIpId", internalType: "address", type: "address" }, - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - { name: "amount", internalType: "uint256", type: "uint256" }, - { name: "minter", internalType: "address", type: "address" }, - { name: "receiver", internalType: "address", type: "address" }, - ], - name: "mintLicenseTokens", - outputs: [{ name: "startLicenseTokenId", internalType: "uint256", type: "uint256" }], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [], - name: "name", - outputs: [{ name: "", internalType: "string", type: "string" }], + inputs: [{ name: "groupId", internalType: "address", type: "address" }], + name: "isRegisteredGroup", + outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], - name: "ownerOf", - outputs: [{ name: "", internalType: "address", type: "address" }], + inputs: [{ name: "rewardPool", internalType: "address", type: "address" }], + name: "isWhitelistedGroupRewardPool", + outputs: [{ name: "isWhitelisted", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "pause", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "paused", + outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "view", }, { @@ -3835,33 +4234,32 @@ export const licenseTokenAbi = [ { type: "function", inputs: [ - { name: "from", internalType: "address", type: "address" }, - { name: "to", internalType: "address", type: "address" }, + { name: "chainid", internalType: "uint256", type: "uint256" }, + { name: "tokenContract", internalType: "address", type: "address" }, { name: "tokenId", internalType: "uint256", type: "uint256" }, ], - name: "safeTransferFrom", - outputs: [], + name: "register", + outputs: [{ name: "id", internalType: "address", type: "address" }], stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "from", internalType: "address", type: "address" }, - { name: "to", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, - { name: "data", internalType: "bytes", type: "bytes" }, + { name: "groupNft", internalType: "address", type: "address" }, + { name: "groupNftId", internalType: "uint256", type: "uint256" }, + { name: "rewardPool", internalType: "address", type: "address" }, ], - name: "safeTransferFrom", - outputs: [], + name: "registerGroup", + outputs: [{ name: "groupId", internalType: "address", type: "address" }], stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "operator", internalType: "address", type: "address" }, - { name: "approved", internalType: "bool", type: "bool" }, + { name: "groupId", internalType: "address", type: "address" }, + { name: "ipIds", internalType: "address[]", type: "address[]" }, ], - name: "setApprovalForAll", + name: "removeGroupMember", outputs: [], stateMutability: "nonpayable", }, @@ -3874,53 +4272,8 @@ export const licenseTokenAbi = [ }, { type: "function", - inputs: [{ name: "url", internalType: "string", type: "string" }], - name: "setLicensingImageUrl", - outputs: [], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }], - name: "supportsInterface", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [], - name: "symbol", - outputs: [{ name: "", internalType: "string", type: "string" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [{ name: "index", internalType: "uint256", type: "uint256" }], - name: "tokenByIndex", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [ - { name: "owner", internalType: "address", type: "address" }, - { name: "index", internalType: "uint256", type: "uint256" }, - ], - name: "tokenOfOwnerByIndex", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [{ name: "id", internalType: "uint256", type: "uint256" }], - name: "tokenURI", - outputs: [{ name: "", internalType: "string", type: "string" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [], - name: "totalMintedTokens", + inputs: [{ name: "groupId", internalType: "address", type: "address" }], + name: "totalMembers", outputs: [{ name: "", internalType: "uint256", type: "uint256" }], stateMutability: "view", }, @@ -3933,12 +4286,8 @@ export const licenseTokenAbi = [ }, { type: "function", - inputs: [ - { name: "from", internalType: "address", type: "address" }, - { name: "to", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, - ], - name: "transferFrom", + inputs: [], + name: "unpause", outputs: [], stateMutability: "nonpayable", }, @@ -3954,364 +4303,190 @@ export const licenseTokenAbi = [ }, { type: "function", - inputs: [ - { name: "caller", internalType: "address", type: "address" }, - { name: "childIpId", internalType: "address", type: "address" }, - { name: "tokenIds", internalType: "uint256[]", type: "uint256[]" }, - ], - name: "validateLicenseTokensForDerivative", - outputs: [ - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licensorIpIds", internalType: "address[]", type: "address[]" }, - { name: "licenseTermsIds", internalType: "uint256[]", type: "uint256[]" }, - ], - stateMutability: "view", + inputs: [{ name: "rewardPool", internalType: "address", type: "address" }], + name: "whitelistGroupRewardPool", + outputs: [], + stateMutability: "nonpayable", }, ] as const; /** * */ -export const licenseTokenAddress = { - 1513: "0xB31FE33De46A1FA5d4Ec669EDB049892E0A1EB4C", +export const ipAssetRegistryAddress = { + 1513: "0x14CAB45705Fe73EC6d126518E59Fe3C61a181E40", } as const; /** * */ -export const licenseTokenConfig = { - address: licenseTokenAddress, - abi: licenseTokenAbi, +export const ipAssetRegistryConfig = { + address: ipAssetRegistryAddress, + abi: ipAssetRegistryAbi, } as const; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// LicensingModule +// IpRoyaltyVaultImpl ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * */ -export const licensingModuleAbi = [ +export const ipRoyaltyVaultImplAbi = [ { type: "constructor", inputs: [ - { name: "accessController", internalType: "address", type: "address" }, - { name: "ipAccountRegistry", internalType: "address", type: "address" }, - { name: "moduleRegistry", internalType: "address", type: "address" }, - { name: "royaltyModule", internalType: "address", type: "address" }, - { name: "licenseRegistry", internalType: "address", type: "address" }, { name: "disputeModule", internalType: "address", type: "address" }, - { name: "licenseToken", internalType: "address", type: "address" }, + { name: "royaltyModule", internalType: "address", type: "address" }, ], stateMutability: "nonpayable", }, + { type: "error", inputs: [], name: "IpRoyaltyVault__EnforcedPause" }, { type: "error", - inputs: [{ name: "ipAccount", internalType: "address", type: "address" }], - name: "AccessControlled__NotIpAccount", - }, - { type: "error", inputs: [], name: "AccessControlled__ZeroAddress" }, - { - type: "error", - inputs: [{ name: "authority", internalType: "address", type: "address" }], - name: "AccessManagedInvalidAuthority", + inputs: [], + name: "IpRoyaltyVault__InsufficientTimeElapsedSinceLastSnapshot", }, + { type: "error", inputs: [], name: "IpRoyaltyVault__InvalidTargetIpId" }, + { type: "error", inputs: [], name: "IpRoyaltyVault__NoClaimableTokens" }, { type: "error", - inputs: [ - { name: "caller", internalType: "address", type: "address" }, - { name: "delay", internalType: "uint32", type: "uint32" }, - ], - name: "AccessManagedRequiredDelay", + inputs: [], + name: "IpRoyaltyVault__NoNewRevenueSinceLastSnapshot", }, { type: "error", - inputs: [{ name: "caller", internalType: "address", type: "address" }], - name: "AccessManagedUnauthorized", + inputs: [], + name: "IpRoyaltyVault__NotAllowedToAddTokenToVault", }, { type: "error", - inputs: [{ name: "target", internalType: "address", type: "address" }], - name: "AddressEmptyCode", + inputs: [], + name: "IpRoyaltyVault__NotWhitelistedRoyaltyToken", }, { type: "error", - inputs: [{ name: "implementation", internalType: "address", type: "address" }], - name: "ERC1967InvalidImplementation", + inputs: [], + name: "IpRoyaltyVault__VaultDoesNotBelongToAnAncestor", }, - { type: "error", inputs: [], name: "ERC1967NonPayable" }, - { type: "error", inputs: [], name: "EnforcedPause" }, - { type: "error", inputs: [], name: "ExpectedPause" }, - { type: "error", inputs: [], name: "FailedInnerCall" }, - { type: "error", inputs: [], name: "InvalidInitialization" }, - { type: "error", inputs: [], name: "LicensingModule__DisputedIpId" }, + { type: "error", inputs: [], name: "IpRoyaltyVault__VaultsMustClaimAsSelf" }, + { type: "error", inputs: [], name: "IpRoyaltyVault__ZeroAmount" }, + { type: "error", inputs: [], name: "IpRoyaltyVault__ZeroDisputeModule" }, + { type: "error", inputs: [], name: "IpRoyaltyVault__ZeroRoyaltyModule" }, { - type: "error", + type: "event", + anonymous: false, inputs: [ - { name: "royaltyPolicy", internalType: "address", type: "address" }, { - name: "anotherRoyaltyPolicy", + name: "owner", internalType: "address", type: "address", + indexed: true, + }, + { + name: "spender", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "value", + internalType: "uint256", + type: "uint256", + indexed: false, }, ], - name: "LicensingModule__IncompatibleRoyaltyPolicy", - }, - { - type: "error", - inputs: [ - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - ], - name: "LicensingModule__InvalidLicenseTermsId", - }, - { - type: "error", - inputs: [{ name: "hook", internalType: "address", type: "address" }], - name: "LicensingModule__InvalidLicensingHook", - }, - { - type: "error", - inputs: [ - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - { name: "licensorIpId", internalType: "address", type: "address" }, - ], - name: "LicensingModule__LicenseDenyMintLicenseToken", - }, - { - type: "error", - inputs: [{ name: "childIpId", internalType: "address", type: "address" }], - name: "LicensingModule__LicenseNotCompatibleForDerivative", - }, - { - type: "error", - inputs: [ - { name: "ipLength", internalType: "uint256", type: "uint256" }, - { name: "licenseTermsLength", internalType: "uint256", type: "uint256" }, - ], - name: "LicensingModule__LicenseTermsLengthMismatch", - }, - { - type: "error", - inputs: [ - { name: "childIpId", internalType: "address", type: "address" }, - { name: "licenseTokenIds", internalType: "uint256[]", type: "uint256[]" }, - ], - name: "LicensingModule__LicenseTokenNotCompatibleForDerivative", - }, - { - type: "error", - inputs: [], - name: "LicensingModule__LicensorIpNotRegistered", + name: "Approval", }, - { type: "error", inputs: [], name: "LicensingModule__MintAmountZero" }, - { type: "error", inputs: [], name: "LicensingModule__NoLicenseToken" }, - { type: "error", inputs: [], name: "LicensingModule__NoParentIp" }, - { type: "error", inputs: [], name: "LicensingModule__ReceiverZeroAddress" }, - { type: "error", inputs: [], name: "LicensingModule__ZeroAccessManager" }, - { type: "error", inputs: [], name: "LicensingModule__ZeroDisputeModule" }, - { type: "error", inputs: [], name: "LicensingModule__ZeroLicenseRegistry" }, - { type: "error", inputs: [], name: "LicensingModule__ZeroLicenseToken" }, - { type: "error", inputs: [], name: "LicensingModule__ZeroModuleRegistry" }, - { type: "error", inputs: [], name: "LicensingModule__ZeroRoyaltyModule" }, - { type: "error", inputs: [], name: "NotInitializing" }, - { type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" }, - { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, { - type: "error", - inputs: [{ name: "slot", internalType: "bytes32", type: "bytes32" }], - name: "UUPSUnsupportedProxiableUUID", + type: "event", + anonymous: false, + inputs: [{ name: "version", internalType: "uint8", type: "uint8", indexed: false }], + name: "Initialized", }, { type: "event", anonymous: false, inputs: [ { - name: "authority", + name: "token", internalType: "address", type: "address", indexed: false, }, + { + name: "amount", + internalType: "uint256", + type: "uint256", + indexed: false, + }, ], - name: "AuthorityUpdated", + name: "RevenueTokenAddedToVault", }, { type: "event", anonymous: false, inputs: [ { - name: "caller", + name: "claimer", internalType: "address", type: "address", - indexed: true, + indexed: false, }, { - name: "childIpId", + name: "token", internalType: "address", type: "address", - indexed: true, + indexed: false, }, { - name: "licenseTokenIds", - internalType: "uint256[]", - type: "uint256[]", - indexed: false, - }, - { - name: "parentIpIds", - internalType: "address[]", - type: "address[]", - indexed: false, - }, - { - name: "licenseTermsIds", - internalType: "uint256[]", - type: "uint256[]", - indexed: false, - }, - { - name: "licenseTemplate", - internalType: "address", - type: "address", - indexed: false, - }, - ], - name: "DerivativeRegistered", - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "version", - internalType: "uint64", - type: "uint64", + name: "amount", + internalType: "uint256", + type: "uint256", indexed: false, }, ], - name: "Initialized", + name: "RevenueTokenClaimed", }, { type: "event", anonymous: false, - inputs: [ - { - name: "caller", - internalType: "address", - type: "address", - indexed: true, - }, - { name: "ipId", internalType: "address", type: "address", indexed: true }, - { - name: "licenseTemplate", - internalType: "address", - type: "address", - indexed: false, - }, - { - name: "licenseTermsId", - internalType: "uint256", - type: "uint256", - indexed: false, - }, - ], - name: "LicenseTermsAttached", + inputs: [{ name: "id", internalType: "uint256", type: "uint256", indexed: false }], + name: "Snapshot", }, { type: "event", anonymous: false, inputs: [ { - name: "caller", - internalType: "address", - type: "address", - indexed: true, - }, - { - name: "licensorIpId", - internalType: "address", - type: "address", - indexed: true, - }, - { - name: "licenseTemplate", - internalType: "address", - type: "address", - indexed: false, - }, - { - name: "licenseTermsId", - internalType: "uint256", - type: "uint256", - indexed: true, - }, - { - name: "amount", + name: "snapshotId", internalType: "uint256", type: "uint256", indexed: false, }, { - name: "receiver", - internalType: "address", - type: "address", - indexed: false, - }, - { - name: "startLicenseTokenId", + name: "snapshotTimestamp", internalType: "uint256", type: "uint256", indexed: false, }, ], - name: "LicenseTokensMinted", - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "account", - internalType: "address", - type: "address", - indexed: false, - }, - ], - name: "Paused", + name: "SnapshotCompleted", }, { type: "event", anonymous: false, inputs: [ + { name: "from", internalType: "address", type: "address", indexed: true }, + { name: "to", internalType: "address", type: "address", indexed: true }, { - name: "account", - internalType: "address", - type: "address", + name: "value", + internalType: "uint256", + type: "uint256", indexed: false, }, ], - name: "Unpaused", - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "implementation", - internalType: "address", - type: "address", - indexed: true, - }, - ], - name: "Upgraded", - }, - { - type: "function", - inputs: [], - name: "ACCESS_CONTROLLER", - outputs: [{ name: "", internalType: "contract IAccessController", type: "address" }], - stateMutability: "view", + name: "Transfer", }, { type: "function", @@ -4323,235 +4498,308 @@ export const licensingModuleAbi = [ { type: "function", inputs: [], - name: "IP_ACCOUNT_REGISTRY", - outputs: [ - { - name: "", - internalType: "contract IIPAccountRegistry", - type: "address", - }, - ], + name: "ROYALTY_MODULE", + outputs: [{ name: "", internalType: "contract IRoyaltyModule", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [], - name: "LICENSE_NFT", - outputs: [{ name: "", internalType: "contract ILicenseToken", type: "address" }], + inputs: [ + { name: "owner", internalType: "address", type: "address" }, + { name: "spender", internalType: "address", type: "address" }, + ], + name: "allowance", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], stateMutability: "view", }, { type: "function", - inputs: [], - name: "LICENSE_REGISTRY", - outputs: [{ name: "", internalType: "contract ILicenseRegistry", type: "address" }], - stateMutability: "view", + inputs: [ + { name: "spender", internalType: "address", type: "address" }, + { name: "amount", internalType: "uint256", type: "uint256" }, + ], + name: "approve", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "nonpayable", }, { type: "function", - inputs: [], - name: "MODULE_REGISTRY", - outputs: [{ name: "", internalType: "contract IModuleRegistry", type: "address" }], + inputs: [{ name: "account", internalType: "address", type: "address" }], + name: "balanceOf", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], stateMutability: "view", }, { type: "function", - inputs: [], - name: "ROYALTY_MODULE", - outputs: [{ name: "", internalType: "contract RoyaltyModule", type: "address" }], + inputs: [ + { name: "account", internalType: "address", type: "address" }, + { name: "snapshotId", internalType: "uint256", type: "uint256" }, + ], + name: "balanceOfAt", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], stateMutability: "view", }, { type: "function", - inputs: [], - name: "UPGRADE_INTERFACE_VERSION", - outputs: [{ name: "", internalType: "string", type: "string" }], - stateMutability: "view", + inputs: [ + { name: "snapshotIds", internalType: "uint256[]", type: "uint256[]" }, + { name: "token", internalType: "address", type: "address" }, + { name: "targetIpId", internalType: "address", type: "address" }, + ], + name: "claimBySnapshotBatchAsSelf", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "accessManager", internalType: "address", type: "address" }], - name: "__ProtocolPausable_init", + inputs: [ + { name: "snapshotId", internalType: "uint256", type: "uint256" }, + { name: "tokenList", internalType: "address[]", type: "address[]" }, + { name: "targetIpId", internalType: "address", type: "address" }, + ], + name: "claimByTokenBatchAsSelf", outputs: [], stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { name: "snapshotIds", internalType: "uint256[]", type: "uint256[]" }, + { name: "token", internalType: "address", type: "address" }, + { name: "claimer", internalType: "address", type: "address" }, ], - name: "attachLicenseTerms", - outputs: [], + name: "claimRevenueOnBehalfBySnapshotBatch", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], stateMutability: "nonpayable", }, { type: "function", - inputs: [], - name: "authority", - outputs: [{ name: "", internalType: "address", type: "address" }], - stateMutability: "view", + inputs: [ + { name: "snapshotId", internalType: "uint256", type: "uint256" }, + { name: "tokenList", internalType: "address[]", type: "address[]" }, + { name: "claimer", internalType: "address", type: "address" }, + ], + name: "claimRevenueOnBehalfByTokenBatch", + outputs: [{ name: "", internalType: "uint256[]", type: "uint256[]" }], + stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "accessManager", internalType: "address", type: "address" }], - name: "initialize", - outputs: [], - stateMutability: "nonpayable", + inputs: [{ name: "token", internalType: "address", type: "address" }], + name: "claimVaultAmount", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", }, { type: "function", - inputs: [], - name: "isConsumingScheduledOp", - outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], + inputs: [ + { name: "snapshotId", internalType: "uint256", type: "uint256" }, + { name: "token", internalType: "address", type: "address" }, + ], + name: "claimableAtSnapshot", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], stateMutability: "view", }, { type: "function", inputs: [ - { name: "licensorIpId", internalType: "address", type: "address" }, - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - { name: "amount", internalType: "uint256", type: "uint256" }, - { name: "receiver", internalType: "address", type: "address" }, - { name: "royaltyContext", internalType: "bytes", type: "bytes" }, + { name: "account", internalType: "address", type: "address" }, + { name: "snapshotId", internalType: "uint256", type: "uint256" }, + { name: "token", internalType: "address", type: "address" }, ], - name: "mintLicenseTokens", - outputs: [{ name: "startLicenseTokenId", internalType: "uint256", type: "uint256" }], - stateMutability: "nonpayable", + name: "claimableRevenue", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", }, { type: "function", inputs: [], - name: "name", - outputs: [{ name: "", internalType: "string", type: "string" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [], - name: "pause", - outputs: [], - stateMutability: "nonpayable", + name: "decimals", + outputs: [{ name: "", internalType: "uint8", type: "uint8" }], + stateMutability: "pure", }, { type: "function", - inputs: [], - name: "paused", + inputs: [ + { name: "spender", internalType: "address", type: "address" }, + { name: "subtractedValue", internalType: "uint256", type: "uint256" }, + ], + name: "decreaseAllowance", outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "view", + stateMutability: "nonpayable", }, { type: "function", inputs: [], - name: "proxiableUUID", - outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + name: "getCurrentSnapshotId", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], stateMutability: "view", }, { type: "function", inputs: [ - { name: "childIpId", internalType: "address", type: "address" }, - { name: "parentIpIds", internalType: "address[]", type: "address[]" }, - { name: "licenseTermsIds", internalType: "uint256[]", type: "uint256[]" }, - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "royaltyContext", internalType: "bytes", type: "bytes" }, + { name: "spender", internalType: "address", type: "address" }, + { name: "addedValue", internalType: "uint256", type: "uint256" }, ], - name: "registerDerivative", - outputs: [], + name: "increaseAllowance", + outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "childIpId", internalType: "address", type: "address" }, - { name: "licenseTokenIds", internalType: "uint256[]", type: "uint256[]" }, - { name: "royaltyContext", internalType: "bytes", type: "bytes" }, + { name: "name", internalType: "string", type: "string" }, + { name: "symbol", internalType: "string", type: "string" }, + { name: "supply", internalType: "uint32", type: "uint32" }, + { name: "ipIdAddress", internalType: "address", type: "address" }, + { name: "rtReceiver", internalType: "address", type: "address" }, ], - name: "registerDerivativeWithLicenseTokens", + name: "initialize", outputs: [], stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "newAuthority", internalType: "address", type: "address" }], - name: "setAuthority", - outputs: [], - stateMutability: "nonpayable", + inputs: [], + name: "ipId", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", }, { type: "function", inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "licenseTemplate", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - { - name: "licensingConfig", - internalType: "struct Licensing.LicensingConfig", - type: "tuple", - components: [ - { name: "isSet", internalType: "bool", type: "bool" }, - { name: "mintingFee", internalType: "uint256", type: "uint256" }, - { name: "licensingHook", internalType: "address", type: "address" }, - { name: "hookData", internalType: "bytes", type: "bytes" }, - ], - }, + { name: "snapshotId", internalType: "uint256", type: "uint256" }, + { name: "claimer", internalType: "address", type: "address" }, + { name: "token", internalType: "address", type: "address" }, ], - name: "setLicensingConfig", - outputs: [], + name: "isClaimedAtSnapshot", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "lastSnapshotTimestamp", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "name", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "token", internalType: "address", type: "address" }], + name: "pendingVaultAmount", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "snapshot", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }], - name: "supportsInterface", - outputs: [{ name: "", internalType: "bool", type: "bool" }], + inputs: [], + name: "symbol", + outputs: [{ name: "", internalType: "string", type: "string" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "unpause", - outputs: [], + name: "tokens", + outputs: [{ name: "", internalType: "address[]", type: "address[]" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "totalSupply", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "snapshotId", internalType: "uint256", type: "uint256" }], + name: "totalSupplyAt", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "to", internalType: "address", type: "address" }, + { name: "amount", internalType: "uint256", type: "uint256" }, + ], + name: "transfer", + outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "newImplementation", internalType: "address", type: "address" }, - { name: "data", internalType: "bytes", type: "bytes" }, + { name: "from", internalType: "address", type: "address" }, + { name: "to", internalType: "address", type: "address" }, + { name: "amount", internalType: "uint256", type: "uint256" }, ], - name: "upgradeToAndCall", + name: "transferFrom", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "token", internalType: "address", type: "address" }, + { name: "amount", internalType: "uint256", type: "uint256" }, + ], + name: "updateVaultBalance", outputs: [], - stateMutability: "payable", + stateMutability: "nonpayable", }, ] as const; /** * */ -export const licensingModuleAddress = { - 1513: "0xf49da534215DA7b48E57A41d41dac25C912FCC60", +export const ipRoyaltyVaultImplAddress = { + 1513: "0x604dc8E58f720DEB345B2F3e08B2B354eA6CE498", } as const; /** * */ -export const licensingModuleConfig = { - address: licensingModuleAddress, - abi: licensingModuleAbi, +export const ipRoyaltyVaultImplConfig = { + address: ipRoyaltyVaultImplAddress, + abi: ipRoyaltyVaultImplAbi, } as const; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// ModuleRegistry +// LicenseAttachmentWorkflows ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * */ -export const moduleRegistryAbi = [ - { type: "constructor", inputs: [], stateMutability: "nonpayable" }, +export const licenseAttachmentWorkflowsAbi = [ + { + type: "constructor", + inputs: [ + { name: "accessController", internalType: "address", type: "address" }, + { name: "coreMetadataModule", internalType: "address", type: "address" }, + { name: "ipAssetRegistry", internalType: "address", type: "address" }, + { name: "licenseRegistry", internalType: "address", type: "address" }, + { name: "licensingModule", internalType: "address", type: "address" }, + { name: "pilTemplate", internalType: "address", type: "address" }, + ], + stateMutability: "nonpayable", + }, { type: "error", inputs: [{ name: "authority", internalType: "address", type: "address" }], @@ -4583,43 +4831,11 @@ export const moduleRegistryAbi = [ { type: "error", inputs: [], name: "ERC1967NonPayable" }, { type: "error", inputs: [], name: "FailedInnerCall" }, { type: "error", inputs: [], name: "InvalidInitialization" }, - { type: "error", inputs: [], name: "ModuleRegistry__InterfaceIdZero" }, - { - type: "error", - inputs: [], - name: "ModuleRegistry__ModuleAddressNotContract", - }, - { - type: "error", - inputs: [], - name: "ModuleRegistry__ModuleAddressZeroAddress", - }, - { - type: "error", - inputs: [], - name: "ModuleRegistry__ModuleAlreadyRegistered", - }, - { type: "error", inputs: [], name: "ModuleRegistry__ModuleNotRegistered" }, - { - type: "error", - inputs: [], - name: "ModuleRegistry__ModuleNotSupportExpectedModuleTypeInterfaceId", - }, - { - type: "error", - inputs: [], - name: "ModuleRegistry__ModuleTypeAlreadyRegistered", - }, - { type: "error", inputs: [], name: "ModuleRegistry__ModuleTypeEmptyString" }, { type: "error", inputs: [], - name: "ModuleRegistry__ModuleTypeNotRegistered", + name: "LicenseAttachmentWorkflows__ZeroAddressParam", }, - { type: "error", inputs: [], name: "ModuleRegistry__NameAlreadyRegistered" }, - { type: "error", inputs: [], name: "ModuleRegistry__NameDoesNotMatch" }, - { type: "error", inputs: [], name: "ModuleRegistry__NameEmptyString" }, - { type: "error", inputs: [], name: "ModuleRegistry__ZeroAccessManager" }, { type: "error", inputs: [], name: "NotInitializing" }, { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, { @@ -4627,6 +4843,7 @@ export const moduleRegistryAbi = [ inputs: [{ name: "slot", internalType: "bytes32", type: "bytes32" }], name: "UUPSUnsupportedProxiableUUID", }, + { type: "error", inputs: [], name: "Workflow__CallerNotAuthorizedToMint" }, { type: "event", anonymous: false, @@ -4653,46 +4870,6 @@ export const moduleRegistryAbi = [ ], name: "Initialized", }, - { - type: "event", - anonymous: false, - inputs: [ - { name: "name", internalType: "string", type: "string", indexed: false }, - { - name: "module", - internalType: "address", - type: "address", - indexed: true, - }, - { - name: "moduleTypeInterfaceId", - internalType: "bytes4", - type: "bytes4", - indexed: true, - }, - { - name: "moduleType", - internalType: "string", - type: "string", - indexed: false, - }, - ], - name: "ModuleAdded", - }, - { - type: "event", - anonymous: false, - inputs: [ - { name: "name", internalType: "string", type: "string", indexed: false }, - { - name: "module", - internalType: "address", - type: "address", - indexed: true, - }, - ], - name: "ModuleRemoved", - }, { type: "event", anonymous: false, @@ -4709,125 +4886,370 @@ export const moduleRegistryAbi = [ { type: "function", inputs: [], - name: "UPGRADE_INTERFACE_VERSION", - outputs: [{ name: "", internalType: "string", type: "string" }], + name: "ACCESS_CONTROLLER", + outputs: [{ name: "", internalType: "contract IAccessController", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "authority", - outputs: [{ name: "", internalType: "address", type: "address" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [{ name: "name", internalType: "string", type: "string" }], - name: "getModule", - outputs: [{ name: "", internalType: "address", type: "address" }], + name: "CORE_METADATA_MODULE", + outputs: [ + { + name: "", + internalType: "contract ICoreMetadataModule", + type: "address", + }, + ], stateMutability: "view", }, { type: "function", - inputs: [{ name: "moduleAddress", internalType: "address", type: "address" }], - name: "getModuleType", - outputs: [{ name: "", internalType: "string", type: "string" }], + inputs: [], + name: "IP_ASSET_REGISTRY", + outputs: [{ name: "", internalType: "contract IIPAssetRegistry", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "moduleType", internalType: "string", type: "string" }], - name: "getModuleTypeInterfaceId", - outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], + inputs: [], + name: "LICENSE_REGISTRY", + outputs: [{ name: "", internalType: "contract ILicenseRegistry", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "accessManager", internalType: "address", type: "address" }], - name: "initialize", - outputs: [], - stateMutability: "nonpayable", + inputs: [], + name: "LICENSING_MODULE", + outputs: [{ name: "", internalType: "contract ILicensingModule", type: "address" }], + stateMutability: "view", }, { type: "function", inputs: [], - name: "isConsumingScheduledOp", - outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], + name: "PIL_TEMPLATE", + outputs: [ + { + name: "", + internalType: "contract IPILicenseTemplate", + type: "address", + }, + ], stateMutability: "view", }, { type: "function", - inputs: [{ name: "moduleAddress", internalType: "address", type: "address" }], - name: "isRegistered", - outputs: [{ name: "", internalType: "bool", type: "bool" }], + inputs: [], + name: "UPGRADE_INTERFACE_VERSION", + outputs: [{ name: "", internalType: "string", type: "string" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "proxiableUUID", - outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + name: "authority", + outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [ - { name: "name", internalType: "string", type: "string" }, - { name: "moduleAddress", internalType: "address", type: "address" }, - ], - name: "registerModule", + inputs: [{ name: "accessManager", internalType: "address", type: "address" }], + name: "initialize", outputs: [], stateMutability: "nonpayable", }, { type: "function", - inputs: [ - { name: "name", internalType: "string", type: "string" }, - { name: "moduleAddress", internalType: "address", type: "address" }, - { name: "moduleType", internalType: "string", type: "string" }, - ], - name: "registerModule", - outputs: [], - stateMutability: "nonpayable", + inputs: [], + name: "isConsumingScheduledOp", + outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], + stateMutability: "view", }, { type: "function", inputs: [ - { name: "name", internalType: "string", type: "string" }, - { name: "interfaceId", internalType: "bytes4", type: "bytes4" }, + { name: "spgNftContract", internalType: "address", type: "address" }, + { name: "recipient", internalType: "address", type: "address" }, + { + name: "ipMetadata", + internalType: "struct WorkflowStructs.IPMetadata", + type: "tuple", + components: [ + { name: "ipMetadataURI", internalType: "string", type: "string" }, + { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, + { name: "nftMetadataURI", internalType: "string", type: "string" }, + { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, + ], + }, + { + name: "terms", + internalType: "struct PILTerms", + type: "tuple", + components: [ + { name: "transferable", internalType: "bool", type: "bool" }, + { name: "royaltyPolicy", internalType: "address", type: "address" }, + { + name: "defaultMintingFee", + internalType: "uint256", + type: "uint256", + }, + { name: "expiration", internalType: "uint256", type: "uint256" }, + { name: "commercialUse", internalType: "bool", type: "bool" }, + { name: "commercialAttribution", internalType: "bool", type: "bool" }, + { + name: "commercializerChecker", + internalType: "address", + type: "address", + }, + { + name: "commercializerCheckerData", + internalType: "bytes", + type: "bytes", + }, + { + name: "commercialRevShare", + internalType: "uint32", + type: "uint32", + }, + { + name: "commercialRevCeiling", + internalType: "uint256", + type: "uint256", + }, + { name: "derivativesAllowed", internalType: "bool", type: "bool" }, + { + name: "derivativesAttribution", + internalType: "bool", + type: "bool", + }, + { name: "derivativesApproval", internalType: "bool", type: "bool" }, + { name: "derivativesReciprocal", internalType: "bool", type: "bool" }, + { + name: "derivativeRevCeiling", + internalType: "uint256", + type: "uint256", + }, + { name: "currency", internalType: "address", type: "address" }, + { name: "uri", internalType: "string", type: "string" }, + ], + }, + ], + name: "mintAndRegisterIpAndAttachPILTerms", + outputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, ], - name: "registerModuleType", - outputs: [], stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "name", internalType: "string", type: "string" }], - name: "removeModule", - outputs: [], + inputs: [{ name: "data", internalType: "bytes[]", type: "bytes[]" }], + name: "multicall", + outputs: [{ name: "results", internalType: "bytes[]", type: "bytes[]" }], stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "name", internalType: "string", type: "string" }], - name: "removeModuleType", - outputs: [], - stateMutability: "nonpayable", + inputs: [], + name: "proxiableUUID", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view", }, { type: "function", - inputs: [{ name: "newAuthority", internalType: "address", type: "address" }], - name: "setAuthority", - outputs: [], + inputs: [ + { name: "nftContract", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + { + name: "ipMetadata", + internalType: "struct WorkflowStructs.IPMetadata", + type: "tuple", + components: [ + { name: "ipMetadataURI", internalType: "string", type: "string" }, + { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, + { name: "nftMetadataURI", internalType: "string", type: "string" }, + { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, + ], + }, + { + name: "terms", + internalType: "struct PILTerms", + type: "tuple", + components: [ + { name: "transferable", internalType: "bool", type: "bool" }, + { name: "royaltyPolicy", internalType: "address", type: "address" }, + { + name: "defaultMintingFee", + internalType: "uint256", + type: "uint256", + }, + { name: "expiration", internalType: "uint256", type: "uint256" }, + { name: "commercialUse", internalType: "bool", type: "bool" }, + { name: "commercialAttribution", internalType: "bool", type: "bool" }, + { + name: "commercializerChecker", + internalType: "address", + type: "address", + }, + { + name: "commercializerCheckerData", + internalType: "bytes", + type: "bytes", + }, + { + name: "commercialRevShare", + internalType: "uint32", + type: "uint32", + }, + { + name: "commercialRevCeiling", + internalType: "uint256", + type: "uint256", + }, + { name: "derivativesAllowed", internalType: "bool", type: "bool" }, + { + name: "derivativesAttribution", + internalType: "bool", + type: "bool", + }, + { name: "derivativesApproval", internalType: "bool", type: "bool" }, + { name: "derivativesReciprocal", internalType: "bool", type: "bool" }, + { + name: "derivativeRevCeiling", + internalType: "uint256", + type: "uint256", + }, + { name: "currency", internalType: "address", type: "address" }, + { name: "uri", internalType: "string", type: "string" }, + ], + }, + { + name: "sigMetadata", + internalType: "struct WorkflowStructs.SignatureData", + type: "tuple", + components: [ + { name: "signer", internalType: "address", type: "address" }, + { name: "deadline", internalType: "uint256", type: "uint256" }, + { name: "signature", internalType: "bytes", type: "bytes" }, + ], + }, + { + name: "sigAttach", + internalType: "struct WorkflowStructs.SignatureData", + type: "tuple", + components: [ + { name: "signer", internalType: "address", type: "address" }, + { name: "deadline", internalType: "uint256", type: "uint256" }, + { name: "signature", internalType: "bytes", type: "bytes" }, + ], + }, + ], + name: "registerIpAndAttachPILTerms", + outputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + ], stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "newImplementation", internalType: "address", type: "address" }, - { name: "data", internalType: "bytes", type: "bytes" }, - ], - name: "upgradeToAndCall", + { name: "ipId", internalType: "address", type: "address" }, + { + name: "terms", + internalType: "struct PILTerms", + type: "tuple", + components: [ + { name: "transferable", internalType: "bool", type: "bool" }, + { name: "royaltyPolicy", internalType: "address", type: "address" }, + { + name: "defaultMintingFee", + internalType: "uint256", + type: "uint256", + }, + { name: "expiration", internalType: "uint256", type: "uint256" }, + { name: "commercialUse", internalType: "bool", type: "bool" }, + { name: "commercialAttribution", internalType: "bool", type: "bool" }, + { + name: "commercializerChecker", + internalType: "address", + type: "address", + }, + { + name: "commercializerCheckerData", + internalType: "bytes", + type: "bytes", + }, + { + name: "commercialRevShare", + internalType: "uint32", + type: "uint32", + }, + { + name: "commercialRevCeiling", + internalType: "uint256", + type: "uint256", + }, + { name: "derivativesAllowed", internalType: "bool", type: "bool" }, + { + name: "derivativesAttribution", + internalType: "bool", + type: "bool", + }, + { name: "derivativesApproval", internalType: "bool", type: "bool" }, + { name: "derivativesReciprocal", internalType: "bool", type: "bool" }, + { + name: "derivativeRevCeiling", + internalType: "uint256", + type: "uint256", + }, + { name: "currency", internalType: "address", type: "address" }, + { name: "uri", internalType: "string", type: "string" }, + ], + }, + { + name: "sigAttach", + internalType: "struct WorkflowStructs.SignatureData", + type: "tuple", + components: [ + { name: "signer", internalType: "address", type: "address" }, + { name: "deadline", internalType: "uint256", type: "uint256" }, + { name: "signature", internalType: "bytes", type: "bytes" }, + ], + }, + ], + name: "registerPILTermsAndAttach", + outputs: [{ name: "licenseTermsId", internalType: "uint256", type: "uint256" }], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "newAuthority", internalType: "address", type: "address" }], + name: "setAuthority", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { + name: "newNftContractBeacon", + internalType: "address", + type: "address", + }, + ], + name: "setNftContractBeacon", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "newImplementation", internalType: "address", type: "address" }, + { name: "data", internalType: "bytes", type: "bytes" }, + ], + name: "upgradeToAndCall", outputs: [], stateMutability: "payable", }, @@ -4836,42 +5258,36 @@ export const moduleRegistryAbi = [ /** * */ -export const moduleRegistryAddress = { - 1513: "0x008ac202A8545D10f25707439bE4c139Be4Df75F", +export const licenseAttachmentWorkflowsAddress = { + 1513: "0x1B95144b62B4566501482e928aa435Dd205fE71B", } as const; /** * */ -export const moduleRegistryConfig = { - address: moduleRegistryAddress, - abi: moduleRegistryAbi, +export const licenseAttachmentWorkflowsConfig = { + address: licenseAttachmentWorkflowsAddress, + abi: licenseAttachmentWorkflowsAbi, } as const; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// PILicenseTemplate +// LicenseRegistry ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * */ -export const piLicenseTemplateAbi = [ +export const licenseRegistryAbi = [ { type: "constructor", inputs: [ - { name: "accessController", internalType: "address", type: "address" }, - { name: "ipAccountRegistry", internalType: "address", type: "address" }, - { name: "licenseRegistry", internalType: "address", type: "address" }, - { name: "royaltyModule", internalType: "address", type: "address" }, + { 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", }, - { - type: "error", - inputs: [{ name: "ipAccount", internalType: "address", type: "address" }], - name: "AccessControlled__NotIpAccount", - }, - { type: "error", inputs: [], name: "AccessControlled__ZeroAddress" }, { type: "error", inputs: [{ name: "authority", internalType: "address", type: "address" }], @@ -4903,86 +5319,152 @@ export const piLicenseTemplateAbi = [ { type: "error", inputs: [], name: "ERC1967NonPayable" }, { type: "error", inputs: [], name: "FailedInnerCall" }, { type: "error", inputs: [], name: "InvalidInitialization" }, - { type: "error", inputs: [], name: "NotInitializing" }, { type: "error", - inputs: [], - name: "PILicenseTemplate__CommercialDisabled_CantAddAttribution", + inputs: [ + { name: "childIpId", internalType: "address", type: "address" }, + { name: "parentIpIds", internalType: "address[]", type: "address[]" }, + ], + name: "LicenseRegistry__AddParentIpToIPGraphFailed", }, { type: "error", inputs: [], - name: "PILicenseTemplate__CommercialDisabled_CantAddCommercializers", + name: "LicenseRegistry__CallerNotLicensingModule", }, { type: "error", - inputs: [], - name: "PILicenseTemplate__CommercialDisabled_CantAddDerivativeRevCeiling", + inputs: [{ name: "childIpId", internalType: "address", type: "address" }], + name: "LicenseRegistry__DerivativeAlreadyRegistered", }, { type: "error", - inputs: [], - name: "PILicenseTemplate__CommercialDisabled_CantAddRevCeiling", + inputs: [{ name: "childIpId", internalType: "address", type: "address" }], + name: "LicenseRegistry__DerivativeIpAlreadyHasChild", }, { type: "error", - inputs: [], - name: "PILicenseTemplate__CommercialDisabled_CantAddRevShare", + inputs: [{ name: "childIpId", internalType: "address", type: "address" }], + name: "LicenseRegistry__DerivativeIpAlreadyHasLicense", }, { type: "error", - inputs: [], - name: "PILicenseTemplate__CommercialDisabled_CantAddRoyaltyPolicy", + inputs: [{ name: "ipId", internalType: "address", type: "address" }], + name: "LicenseRegistry__DerivativeIsParent", }, { type: "error", - inputs: [], - name: "PILicenseTemplate__CommercialEnabled_RoyaltyPolicyRequired", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + ], + name: "LicenseRegistry__DuplicateLicense", }, { type: "error", - inputs: [{ name: "checker", internalType: "address", type: "address" }], - name: "PILicenseTemplate__CommercializerCheckerDoesNotSupportHook", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "index", internalType: "uint256", type: "uint256" }, + { name: "length", internalType: "uint256", type: "uint256" }, + ], + name: "LicenseRegistry__IndexOutOfBounds", }, { type: "error", - inputs: [], - name: "PILicenseTemplate__CurrencyTokenNotWhitelisted", + inputs: [{ name: "ipId", internalType: "address", type: "address" }], + name: "LicenseRegistry__IpExpired", }, { type: "error", - inputs: [], - name: "PILicenseTemplate__DerivativesDisabled_CantAddApproval", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + ], + name: "LicenseRegistry__LicenseTermsAlreadyAttached", }, { type: "error", - inputs: [], - name: "PILicenseTemplate__DerivativesDisabled_CantAddAttribution", + inputs: [ + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + ], + name: "LicenseRegistry__LicenseTermsNotExists", }, { type: "error", - inputs: [], - name: "PILicenseTemplate__DerivativesDisabled_CantAddDerivativeRevCeiling", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + ], + name: "LicenseRegistry__LicensorIpHasNoLicenseTerms", }, { type: "error", - inputs: [], - name: "PILicenseTemplate__DerivativesDisabled_CantAddReciprocal", + inputs: [{ name: "licenseTemplate", internalType: "address", type: "address" }], + name: "LicenseRegistry__NotLicenseTemplate", }, { type: "error", - inputs: [], - name: "PILicenseTemplate__RoyaltyPolicyNotWhitelisted", + inputs: [{ name: "ipId", internalType: "address", type: "address" }], + name: "LicenseRegistry__ParentIpExpired", }, + { + type: "error", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + ], + name: "LicenseRegistry__ParentIpHasNoLicenseTerms", + }, + { + type: "error", + inputs: [{ name: "ipId", internalType: "address", type: "address" }], + name: "LicenseRegistry__ParentIpTagged", + }, + { + type: "error", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + ], + name: "LicenseRegistry__ParentIpUnmatchedLicenseTemplate", + }, + { + type: "error", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "newLicenseTemplate", internalType: "address", type: "address" }, + ], + name: "LicenseRegistry__UnmatchedLicenseTemplate", + }, + { + type: "error", + inputs: [{ name: "licenseTemplate", internalType: "address", type: "address" }], + name: "LicenseRegistry__UnregisteredLicenseTemplate", + }, + { type: "error", inputs: [], name: "LicenseRegistry__ZeroAccessManager" }, + { type: "error", inputs: [], name: "LicenseRegistry__ZeroDisputeModule" }, + { type: "error", inputs: [], name: "LicenseRegistry__ZeroIPGraphACL" }, + { type: "error", inputs: [], name: "LicenseRegistry__ZeroLicenseTemplate" }, + { type: "error", inputs: [], name: "LicenseRegistry__ZeroLicensingModule" }, { type: "error", inputs: [], - name: "PILicenseTemplate__RoyaltyPolicyRequiresCurrencyToken", + name: "LicensingModule__DerivativesCannotAddLicenseTerms", }, - { type: "error", inputs: [], name: "PILicenseTemplate__ZeroAccessManager" }, - { type: "error", inputs: [], name: "PILicenseTemplate__ZeroLicenseRegistry" }, - { type: "error", inputs: [], name: "PILicenseTemplate__ZeroRoyaltyModule" }, - { type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" }, + { + type: "error", + inputs: [ + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + ], + name: "LicensingModule__LicenseTermsNotFound", + }, + { type: "error", inputs: [], name: "NotInitializing" }, { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, { type: "error", @@ -5006,22 +5488,34 @@ export const piLicenseTemplateAbi = [ type: "event", anonymous: false, inputs: [ + { + name: "licenseTemplate", + internalType: "address", + type: "address", + indexed: false, + }, { name: "licenseTermsId", internalType: "uint256", type: "uint256", - indexed: true, + indexed: false, }, - { name: "ipId", internalType: "address", type: "address", indexed: true }, + ], + name: "DefaultLicenseTermsSet", + }, + { + type: "event", + anonymous: false, + inputs: [ + { name: "ipId", internalType: "address", type: "address", indexed: true }, { - name: "caller", - internalType: "address", - type: "address", - indexed: true, + name: "expireTime", + internalType: "uint256", + type: "uint256", + indexed: false, }, - { name: "approved", internalType: "bool", type: "bool", indexed: false }, ], - name: "DerivativeApproved", + name: "ExpirationTimeSet", }, { type: "event", @@ -5041,11 +5535,39 @@ export const piLicenseTemplateAbi = [ anonymous: false, inputs: [ { - name: "licenseTermsId", - internalType: "uint256", - type: "uint256", + name: "licenseTemplate", + internalType: "address", + type: "address", indexed: true, }, + ], + name: "LicenseTemplateRegistered", + }, + { + type: "event", + anonymous: false, + inputs: [ + { name: "ipId", internalType: "address", type: "address", indexed: true }, + { + name: "licensingConfig", + internalType: "struct Licensing.LicensingConfig", + type: "tuple", + components: [ + { name: "isSet", internalType: "bool", type: "bool" }, + { name: "mintingFee", internalType: "uint256", type: "uint256" }, + { name: "licensingHook", internalType: "address", type: "address" }, + { name: "hookData", internalType: "bytes", type: "bytes" }, + ], + indexed: false, + }, + ], + name: "LicensingConfigSetForIP", + }, + { + type: "event", + anonymous: false, + inputs: [ + { name: "ipId", internalType: "address", type: "address", indexed: true }, { name: "licenseTemplate", internalType: "address", @@ -5053,13 +5575,13 @@ export const piLicenseTemplateAbi = [ indexed: true, }, { - name: "licenseTerms", - internalType: "bytes", - type: "bytes", - indexed: false, + name: "licenseTermsId", + internalType: "uint256", + type: "uint256", + indexed: true, }, ], - name: "LicenseTermsRegistered", + name: "LicensingConfigSetForLicense", }, { type: "event", @@ -5077,42 +5599,36 @@ export const piLicenseTemplateAbi = [ { type: "function", inputs: [], - name: "ACCESS_CONTROLLER", - outputs: [{ name: "", internalType: "contract IAccessController", type: "address" }], + name: "DISPUTE_MODULE", + outputs: [{ name: "", internalType: "contract IDisputeModule", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "IP_ACCOUNT_REGISTRY", - outputs: [ - { - name: "", - internalType: "contract IIPAccountRegistry", - type: "address", - }, - ], + name: "EXPIRATION_TIME", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "LICENSE_REGISTRY", - outputs: [{ name: "", internalType: "contract ILicenseRegistry", type: "address" }], + name: "IP_GRAPH", + outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "ROYALTY_MODULE", - outputs: [{ name: "", internalType: "contract IRoyaltyModule", type: "address" }], + name: "IP_GRAPH_ACL", + outputs: [{ name: "", internalType: "contract IPGraphACL", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "TERMS_RENDERER", - outputs: [{ name: "", internalType: "contract PILTermsRenderer", type: "address" }], + name: "LICENSING_MODULE", + outputs: [{ name: "", internalType: "contract ILicensingModule", type: "address" }], stateMutability: "view", }, { @@ -5122,6 +5638,17 @@ export const piLicenseTemplateAbi = [ outputs: [{ name: "", internalType: "string", type: "string" }], stateMutability: "view", }, + { + type: "function", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + ], + name: "attachLicenseTermsToIp", + outputs: [], + stateMutability: "nonpayable", + }, { type: "function", inputs: [], @@ -5131,7 +5658,10 @@ export const piLicenseTemplateAbi = [ }, { type: "function", - inputs: [{ name: "licenseTermsId", internalType: "uint256", type: "uint256" }], + inputs: [ + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + ], name: "exists", outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "view", @@ -5139,19 +5669,53 @@ export const piLicenseTemplateAbi = [ { type: "function", inputs: [ - { name: "licenseTermsIds", internalType: "uint256[]", type: "uint256[]" }, - { name: "start", internalType: "uint256", type: "uint256" }, + { name: "ipId", internalType: "address", type: "address" }, + { name: "index", internalType: "uint256", type: "uint256" }, ], - name: "getEarlierExpireTime", + name: "getAttachedLicenseTerms", + outputs: [ + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + ], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "ipId", internalType: "address", type: "address" }], + name: "getAttachedLicenseTermsCount", outputs: [{ name: "", internalType: "uint256", type: "uint256" }], stateMutability: "view", }, { type: "function", - inputs: [ + inputs: [], + name: "getDefaultLicenseTerms", + outputs: [ + { name: "licenseTemplate", internalType: "address", type: "address" }, { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - { name: "start", internalType: "uint256", type: "uint256" }, ], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "parentIpId", internalType: "address", type: "address" }, + { name: "index", internalType: "uint256", type: "uint256" }, + ], + name: "getDerivativeIp", + outputs: [{ name: "childIpId", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "parentIpId", internalType: "address", type: "address" }], + name: "getDerivativeIpCount", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "ipId", internalType: "address", type: "address" }], name: "getExpireTime", outputs: [{ name: "", internalType: "uint256", type: "uint256" }], stateMutability: "view", @@ -5159,64 +5723,21 @@ export const piLicenseTemplateAbi = [ { type: "function", inputs: [ - { - name: "selectedLicenseTermsId", - internalType: "uint256", - type: "uint256", - }, + { name: "ipId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, ], - name: "getLicenseTerms", + name: "getLicensingConfig", outputs: [ { - name: "terms", - internalType: "struct PILTerms", + name: "", + internalType: "struct Licensing.LicensingConfig", type: "tuple", components: [ - { name: "transferable", internalType: "bool", type: "bool" }, - { name: "royaltyPolicy", internalType: "address", type: "address" }, - { - name: "defaultMintingFee", - internalType: "uint256", - type: "uint256", - }, - { name: "expiration", internalType: "uint256", type: "uint256" }, - { name: "commercialUse", internalType: "bool", type: "bool" }, - { name: "commercialAttribution", internalType: "bool", type: "bool" }, - { - name: "commercializerChecker", - internalType: "address", - type: "address", - }, - { - name: "commercializerCheckerData", - internalType: "bytes", - type: "bytes", - }, - { - name: "commercialRevShare", - internalType: "uint32", - type: "uint32", - }, - { - name: "commercialRevCeiling", - internalType: "uint256", - type: "uint256", - }, - { name: "derivativesAllowed", internalType: "bool", type: "bool" }, - { - name: "derivativesAttribution", - internalType: "bool", - type: "bool", - }, - { name: "derivativesApproval", internalType: "bool", type: "bool" }, - { name: "derivativesReciprocal", internalType: "bool", type: "bool" }, - { - name: "derivativeRevCeiling", - internalType: "uint256", - type: "uint256", - }, - { name: "currency", internalType: "address", type: "address" }, - { name: "uri", internalType: "string", type: "string" }, + { name: "isSet", internalType: "bool", type: "bool" }, + { name: "mintingFee", internalType: "uint256", type: "uint256" }, + { name: "licensingHook", internalType: "address", type: "address" }, + { name: "hookData", internalType: "bytes", type: "bytes" }, ], }, ], @@ -5225,102 +5746,54 @@ export const piLicenseTemplateAbi = [ { type: "function", inputs: [ - { - name: "terms", - internalType: "struct PILTerms", - type: "tuple", - components: [ - { name: "transferable", internalType: "bool", type: "bool" }, - { name: "royaltyPolicy", internalType: "address", type: "address" }, - { - name: "defaultMintingFee", - internalType: "uint256", - type: "uint256", - }, - { name: "expiration", internalType: "uint256", type: "uint256" }, - { name: "commercialUse", internalType: "bool", type: "bool" }, - { name: "commercialAttribution", internalType: "bool", type: "bool" }, - { - name: "commercializerChecker", - internalType: "address", - type: "address", - }, - { - name: "commercializerCheckerData", - internalType: "bytes", - type: "bytes", - }, - { - name: "commercialRevShare", - internalType: "uint32", - type: "uint32", - }, - { - name: "commercialRevCeiling", - internalType: "uint256", - type: "uint256", - }, - { name: "derivativesAllowed", internalType: "bool", type: "bool" }, - { - name: "derivativesAttribution", - internalType: "bool", - type: "bool", - }, - { name: "derivativesApproval", internalType: "bool", type: "bool" }, - { name: "derivativesReciprocal", internalType: "bool", type: "bool" }, - { - name: "derivativeRevCeiling", - internalType: "uint256", - type: "uint256", - }, - { name: "currency", internalType: "address", type: "address" }, - { name: "uri", internalType: "string", type: "string" }, - ], - }, - ], - name: "getLicenseTermsId", - outputs: [ - { - name: "selectedLicenseTermsId", - internalType: "uint256", - type: "uint256", - }, + { name: "childIpId", internalType: "address", type: "address" }, + { name: "index", internalType: "uint256", type: "uint256" }, ], + name: "getParentIp", + outputs: [{ name: "parentIpId", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "licenseTermsId", internalType: "uint256", type: "uint256" }], - name: "getLicenseTermsURI", - outputs: [{ name: "", internalType: "string", type: "string" }], + inputs: [{ name: "childIpId", internalType: "address", type: "address" }], + name: "getParentIpCount", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], stateMutability: "view", }, { type: "function", - inputs: [], - name: "getMetadataURI", - outputs: [{ name: "", internalType: "string", type: "string" }], + inputs: [ + { name: "childIpId", internalType: "address", type: "address" }, + { name: "parentIpId", internalType: "address", type: "address" }, + ], + name: "getParentLicenseTerms", + outputs: [ + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + ], stateMutability: "view", }, { type: "function", - inputs: [{ name: "licenseTermsId", internalType: "uint256", type: "uint256" }], - name: "getRoyaltyPolicy", - outputs: [ - { name: "royaltyPolicy", internalType: "address", type: "address" }, - { name: "royaltyData", internalType: "bytes", type: "bytes" }, - { name: "mintingFee", internalType: "uint256", type: "uint256" }, - { name: "currency", internalType: "address", type: "address" }, - ], + inputs: [{ name: "parentIpId", internalType: "address", type: "address" }], + name: "hasDerivativeIps", + outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "view", }, { type: "function", inputs: [ - { name: "accessManager", internalType: "address", type: "address" }, - { name: "name", internalType: "string", type: "string" }, - { name: "metadataURI", internalType: "string", type: "string" }, + { name: "ipId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, ], + name: "hasIpAttachedLicenseTerms", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "accessManager", internalType: "address", type: "address" }], name: "initialize", outputs: [], stateMutability: "nonpayable", @@ -5334,27 +5807,33 @@ export const piLicenseTemplateAbi = [ }, { type: "function", - inputs: [ - { name: "parentIpId", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - { name: "childIpId", internalType: "address", type: "address" }, - ], - name: "isDerivativeApproved", + inputs: [{ name: "childIpId", internalType: "address", type: "address" }], + name: "isDerivativeIp", outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "licenseTermsId", internalType: "uint256", type: "uint256" }], - name: "isLicenseTransferable", + inputs: [{ name: "ipId", internalType: "address", type: "address" }], + name: "isExpiredNow", outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "view", }, { type: "function", - inputs: [], - name: "name", - outputs: [{ name: "", internalType: "string", type: "string" }], + inputs: [ + { name: "parentIpId", internalType: "address", type: "address" }, + { name: "childIpId", internalType: "address", type: "address" }, + ], + name: "isParentIp", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "licenseTemplate", internalType: "address", type: "address" }], + name: "isRegisteredLicenseTemplate", + outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "view", }, { @@ -5367,72 +5846,20 @@ export const piLicenseTemplateAbi = [ { type: "function", inputs: [ - { - name: "terms", - internalType: "struct PILTerms", - type: "tuple", - components: [ - { name: "transferable", internalType: "bool", type: "bool" }, - { name: "royaltyPolicy", internalType: "address", type: "address" }, - { - name: "defaultMintingFee", - internalType: "uint256", - type: "uint256", - }, - { name: "expiration", internalType: "uint256", type: "uint256" }, - { name: "commercialUse", internalType: "bool", type: "bool" }, - { name: "commercialAttribution", internalType: "bool", type: "bool" }, - { - name: "commercializerChecker", - internalType: "address", - type: "address", - }, - { - name: "commercializerCheckerData", - internalType: "bytes", - type: "bytes", - }, - { - name: "commercialRevShare", - internalType: "uint32", - type: "uint32", - }, - { - name: "commercialRevCeiling", - internalType: "uint256", - type: "uint256", - }, - { name: "derivativesAllowed", internalType: "bool", type: "bool" }, - { - name: "derivativesAttribution", - internalType: "bool", - type: "bool", - }, - { name: "derivativesApproval", internalType: "bool", type: "bool" }, - { name: "derivativesReciprocal", internalType: "bool", type: "bool" }, - { - name: "derivativeRevCeiling", - internalType: "uint256", - type: "uint256", - }, - { name: "currency", internalType: "address", type: "address" }, - { name: "uri", internalType: "string", type: "string" }, - ], - }, + { name: "childIpId", internalType: "address", type: "address" }, + { name: "parentIpIds", internalType: "address[]", type: "address[]" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsIds", internalType: "uint256[]", type: "uint256[]" }, + { name: "isUsingLicenseToken", internalType: "bool", type: "bool" }, ], - name: "registerLicenseTerms", - outputs: [{ name: "id", internalType: "uint256", type: "uint256" }], + name: "registerDerivativeIp", + outputs: [], stateMutability: "nonpayable", }, { type: "function", - inputs: [ - { name: "parentIpId", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - { name: "childIpId", internalType: "address", type: "address" }, - { name: "approved", internalType: "bool", type: "bool" }, - ], - name: "setApproval", + inputs: [{ name: "licenseTemplate", internalType: "address", type: "address" }], + name: "registerLicenseTemplate", outputs: [], stateMutability: "nonpayable", }, @@ -5445,24 +5872,55 @@ export const piLicenseTemplateAbi = [ }, { type: "function", - inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }], - name: "supportsInterface", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "view", + inputs: [ + { name: "newLicenseTemplate", internalType: "address", type: "address" }, + { name: "newLicenseTermsId", internalType: "uint256", type: "uint256" }, + ], + name: "setDefaultLicenseTerms", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "licenseTermsId", internalType: "uint256", type: "uint256" }], - name: "toJson", - outputs: [{ name: "", internalType: "string", type: "string" }], - stateMutability: "view", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { + name: "licensingConfig", + internalType: "struct Licensing.LicensingConfig", + type: "tuple", + components: [ + { name: "isSet", internalType: "bool", type: "bool" }, + { name: "mintingFee", internalType: "uint256", type: "uint256" }, + { name: "licensingHook", internalType: "address", type: "address" }, + { name: "hookData", internalType: "bytes", type: "bytes" }, + ], + }, + ], + name: "setLicensingConfigForIp", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", - inputs: [], - name: "totalRegisteredLicenseTerms", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - stateMutability: "view", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { + name: "licensingConfig", + internalType: "struct Licensing.LicensingConfig", + type: "tuple", + components: [ + { name: "isSet", internalType: "bool", type: "bool" }, + { name: "mintingFee", internalType: "uint256", type: "uint256" }, + { name: "licensingHook", internalType: "address", type: "address" }, + { name: "hookData", internalType: "bytes", type: "bytes" }, + ], + }, + ], + name: "setLicensingConfigForLicense", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", @@ -5474,80 +5932,60 @@ export const piLicenseTemplateAbi = [ outputs: [], stateMutability: "payable", }, - { - type: "function", - inputs: [{ name: "licenseTermsIds", internalType: "uint256[]", type: "uint256[]" }], - name: "verifyCompatibleLicenses", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "view", - }, { type: "function", inputs: [ - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - { name: "licensee", internalType: "address", type: "address" }, { name: "licensorIpId", internalType: "address", type: "address" }, - { name: "", internalType: "uint256", type: "uint256" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { name: "isMintedByIpOwner", internalType: "bool", type: "bool" }, ], name: "verifyMintLicenseToken", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [ - { name: "childIpId", internalType: "address", type: "address" }, - { name: "parentIpId", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, - { name: "licensee", internalType: "address", type: "address" }, + outputs: [ + { + name: "", + internalType: "struct Licensing.LicensingConfig", + type: "tuple", + components: [ + { name: "isSet", internalType: "bool", type: "bool" }, + { name: "mintingFee", internalType: "uint256", type: "uint256" }, + { name: "licensingHook", internalType: "address", type: "address" }, + { name: "hookData", internalType: "bytes", type: "bytes" }, + ], + }, ], - name: "verifyRegisterDerivative", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [ - { name: "childIpId", internalType: "address", type: "address" }, - { name: "parentIpIds", internalType: "address[]", type: "address[]" }, - { name: "licenseTermsIds", internalType: "uint256[]", type: "uint256[]" }, - { name: "childIpOwner", internalType: "address", type: "address" }, - ], - name: "verifyRegisterDerivativeForAllParents", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "nonpayable", + stateMutability: "view", }, ] as const; /** * */ -export const piLicenseTemplateAddress = { - 1513: "0x8BB1ADE72E21090Fc891e1d4b88AC5E57b27cB31", +export const licenseRegistryAddress = { + 1513: "0x4D71a082DE74B40904c1d89d9C3bfB7079d4c542", } as const; /** * */ -export const piLicenseTemplateConfig = { - address: piLicenseTemplateAddress, - abi: piLicenseTemplateAbi, +export const licenseRegistryConfig = { + address: licenseRegistryAddress, + abi: licenseRegistryAbi, } as const; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// RoyaltyModule +// LicenseToken ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * */ -export const royaltyModuleAbi = [ +export const licenseTokenAbi = [ { type: "constructor", inputs: [ { name: "licensingModule", internalType: "address", type: "address" }, { name: "disputeModule", internalType: "address", type: "address" }, - { name: "licenseRegistry", internalType: "address", type: "address" }, ], stateMutability: "nonpayable", }, @@ -5580,196 +6018,238 @@ export const royaltyModuleAbi = [ name: "ERC1967InvalidImplementation", }, { type: "error", inputs: [], name: "ERC1967NonPayable" }, - { type: "error", inputs: [], name: "EnforcedPause" }, - { type: "error", inputs: [], name: "ExpectedPause" }, - { type: "error", inputs: [], name: "FailedInnerCall" }, - { type: "error", inputs: [], name: "InvalidInitialization" }, - { type: "error", inputs: [], name: "NotInitializing" }, - { type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" }, + { type: "error", inputs: [], name: "ERC721EnumerableForbiddenBatchMint" }, { type: "error", - inputs: [], - name: "RoyaltyModule__CanOnlyMintSelectedPolicy", + inputs: [ + { name: "sender", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + { name: "owner", internalType: "address", type: "address" }, + ], + name: "ERC721IncorrectOwner", }, { type: "error", - inputs: [], - name: "RoyaltyModule__IncompatibleRoyaltyPolicy", + inputs: [ + { name: "operator", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + ], + name: "ERC721InsufficientApproval", }, - { type: "error", inputs: [], name: "RoyaltyModule__IpIsExpired" }, - { type: "error", inputs: [], name: "RoyaltyModule__IpIsTagged" }, - { type: "error", inputs: [], name: "RoyaltyModule__NoParentsOnLinking" }, - { type: "error", inputs: [], name: "RoyaltyModule__NoRoyaltyPolicySet" }, - { type: "error", inputs: [], name: "RoyaltyModule__NotAllowedCaller" }, { type: "error", - inputs: [], - name: "RoyaltyModule__NotWhitelistedRoyaltyPolicy", + inputs: [{ name: "approver", internalType: "address", type: "address" }], + name: "ERC721InvalidApprover", }, { type: "error", - inputs: [], - name: "RoyaltyModule__NotWhitelistedRoyaltyToken", + inputs: [{ name: "operator", internalType: "address", type: "address" }], + name: "ERC721InvalidOperator", }, - { type: "error", inputs: [], name: "RoyaltyModule__ZeroAccessManager" }, - { type: "error", inputs: [], name: "RoyaltyModule__ZeroDisputeModule" }, - { type: "error", inputs: [], name: "RoyaltyModule__ZeroLicenseRegistry" }, - { type: "error", inputs: [], name: "RoyaltyModule__ZeroLicensingModule" }, - { type: "error", inputs: [], name: "RoyaltyModule__ZeroRoyaltyPolicy" }, - { type: "error", inputs: [], name: "RoyaltyModule__ZeroRoyaltyToken" }, - { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, { type: "error", - inputs: [{ name: "slot", internalType: "bytes32", type: "bytes32" }], - name: "UUPSUnsupportedProxiableUUID", + inputs: [{ name: "owner", internalType: "address", type: "address" }], + name: "ERC721InvalidOwner", }, { - type: "event", - anonymous: false, + type: "error", + inputs: [{ name: "receiver", internalType: "address", type: "address" }], + name: "ERC721InvalidReceiver", + }, + { + type: "error", + inputs: [{ name: "sender", internalType: "address", type: "address" }], + name: "ERC721InvalidSender", + }, + { + type: "error", + inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], + name: "ERC721NonexistentToken", + }, + { + type: "error", + inputs: [ + { name: "owner", internalType: "address", type: "address" }, + { name: "index", internalType: "uint256", type: "uint256" }, + ], + name: "ERC721OutOfBoundsIndex", + }, + { type: "error", inputs: [], name: "FailedInnerCall" }, + { type: "error", inputs: [], name: "InvalidInitialization" }, + { + type: "error", inputs: [ + { name: "licenseTemplate", internalType: "address", type: "address" }, { - name: "authority", + name: "anotherLicenseTemplate", internalType: "address", type: "address", - indexed: false, }, ], - name: "AuthorityUpdated", + name: "LicenseToken__AllLicenseTokensMustFromSameLicenseTemplate", }, { - type: "event", - anonymous: false, + type: "error", inputs: [ - { - name: "version", - internalType: "uint64", - type: "uint64", - indexed: false, - }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + { name: "caller", internalType: "address", type: "address" }, + { name: "childIpIp", internalType: "address", type: "address" }, + { name: "actualTokenOwner", internalType: "address", type: "address" }, ], - name: "Initialized", + name: "LicenseToken__CallerAndChildIPNotTokenOwner", + }, + { type: "error", inputs: [], name: "LicenseToken__CallerNotLicensingModule" }, + { type: "error", inputs: [], name: "LicenseToken__NotTransferable" }, + { + type: "error", + inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], + name: "LicenseToken__RevokedLicense", + }, + { type: "error", inputs: [], name: "LicenseToken__ZeroAccessManager" }, + { type: "error", inputs: [], name: "NotInitializing" }, + { + type: "error", + inputs: [ + { name: "value", internalType: "uint256", type: "uint256" }, + { name: "length", internalType: "uint256", type: "uint256" }, + ], + name: "StringsInsufficientHexLength", + }, + { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, + { + type: "error", + inputs: [{ name: "slot", internalType: "bytes32", type: "bytes32" }], + name: "UUPSUnsupportedProxiableUUID", }, { type: "event", anonymous: false, inputs: [ { - name: "receiverIpId", - internalType: "address", - type: "address", - indexed: false, - }, - { - name: "payerAddress", + name: "owner", internalType: "address", type: "address", - indexed: false, + indexed: true, }, { - name: "token", + name: "approved", internalType: "address", type: "address", - indexed: false, + indexed: true, }, { - name: "amount", + name: "tokenId", internalType: "uint256", type: "uint256", - indexed: false, + indexed: true, }, ], - name: "LicenseMintingFeePaid", + name: "Approval", }, { type: "event", anonymous: false, inputs: [ { - name: "account", + name: "owner", internalType: "address", type: "address", - indexed: false, + indexed: true, + }, + { + name: "operator", + internalType: "address", + type: "address", + indexed: true, }, + { name: "approved", internalType: "bool", type: "bool", indexed: false }, ], - name: "Paused", + name: "ApprovalForAll", }, { type: "event", anonymous: false, inputs: [ { - name: "receiverIpId", - internalType: "address", - type: "address", - indexed: false, - }, - { - name: "payerIpId", - internalType: "address", - type: "address", - indexed: false, - }, - { - name: "sender", + name: "authority", internalType: "address", type: "address", indexed: false, }, + ], + name: "AuthorityUpdated", + }, + { + type: "event", + anonymous: false, + inputs: [ { - name: "token", - internalType: "address", - type: "address", + name: "_fromTokenId", + internalType: "uint256", + type: "uint256", indexed: false, }, { - name: "amount", + name: "_toTokenId", internalType: "uint256", type: "uint256", indexed: false, }, ], - name: "RoyaltyPaid", + name: "BatchMetadataUpdate", }, { type: "event", anonymous: false, inputs: [ { - name: "royaltyPolicy", - internalType: "address", - type: "address", + name: "version", + internalType: "uint64", + type: "uint64", indexed: false, }, - { name: "allowed", internalType: "bool", type: "bool", indexed: false }, ], - name: "RoyaltyPolicyWhitelistUpdated", + name: "Initialized", }, { type: "event", anonymous: false, inputs: [ { - name: "token", + name: "minter", internalType: "address", type: "address", - indexed: false, + indexed: true, + }, + { + name: "receiver", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "tokenId", + internalType: "uint256", + type: "uint256", + indexed: true, }, - { name: "allowed", internalType: "bool", type: "bool", indexed: false }, ], - name: "RoyaltyTokenWhitelistUpdated", + name: "LicenseTokenMinted", }, { type: "event", anonymous: false, inputs: [ + { name: "from", internalType: "address", type: "address", indexed: true }, + { name: "to", internalType: "address", type: "address", indexed: true }, { - name: "account", - internalType: "address", - type: "address", - indexed: false, + name: "tokenId", + internalType: "uint256", + type: "uint256", + indexed: true, }, ], - name: "Unpaused", + name: "Transfer", }, { type: "event", @@ -5791,13 +6271,6 @@ export const royaltyModuleAbi = [ outputs: [{ name: "", internalType: "contract IDisputeModule", type: "address" }], stateMutability: "view", }, - { - type: "function", - inputs: [], - name: "LICENSE_REGISTRY", - outputs: [{ name: "", internalType: "contract ILicenseRegistry", type: "address" }], - stateMutability: "view", - }, { type: "function", inputs: [], @@ -5814,8 +6287,11 @@ export const royaltyModuleAbi = [ }, { type: "function", - inputs: [{ name: "accessManager", internalType: "address", type: "address" }], - name: "__ProtocolPausable_init", + inputs: [ + { name: "to", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + ], + name: "approve", outputs: [], stateMutability: "nonpayable", }, @@ -5828,106 +6304,136 @@ export const royaltyModuleAbi = [ }, { type: "function", - inputs: [{ name: "accessManager", internalType: "address", type: "address" }], - name: "initialize", - outputs: [], - stateMutability: "nonpayable", - }, + inputs: [{ name: "owner", internalType: "address", type: "address" }], + name: "balanceOf", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, { type: "function", - inputs: [], - name: "isConsumingScheduledOp", - outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], + inputs: [ + { name: "holder", internalType: "address", type: "address" }, + { name: "tokenIds", internalType: "uint256[]", type: "uint256[]" }, + ], + name: "burnLicenseTokens", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], + name: "getApproved", + outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "royaltyPolicy", internalType: "address", type: "address" }], - name: "isWhitelistedRoyaltyPolicy", - outputs: [{ name: "", internalType: "bool", type: "bool" }], + inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], + name: "getLicenseTemplate", + outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "token", internalType: "address", type: "address" }], - name: "isWhitelistedRoyaltyToken", - outputs: [{ name: "", internalType: "bool", type: "bool" }], + inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], + name: "getLicenseTermsId", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], stateMutability: "view", }, { type: "function", - inputs: [], - name: "name", - outputs: [{ name: "", internalType: "string", type: "string" }], + inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], + name: "getLicenseTokenMetadata", + outputs: [ + { + name: "", + internalType: "struct ILicenseToken.LicenseTokenMetadata", + type: "tuple", + components: [ + { name: "licensorIpId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { name: "transferable", internalType: "bool", type: "bool" }, + ], + }, + ], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], + name: "getLicensorIpId", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "licensorIpId", internalType: "address", type: "address" }], + name: "getTotalTokensByLicensor", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], stateMutability: "view", }, { type: "function", inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "royaltyPolicy", internalType: "address", type: "address" }, - { name: "licenseData", internalType: "bytes", type: "bytes" }, - { name: "externalData", internalType: "bytes", type: "bytes" }, + { name: "accessManager", internalType: "address", type: "address" }, + { name: "imageUrl", internalType: "string", type: "string" }, ], - name: "onLicenseMinting", + name: "initialize", outputs: [], stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "royaltyPolicy", internalType: "address", type: "address" }, - { name: "parentIpIds", internalType: "address[]", type: "address[]" }, - { name: "licenseData", internalType: "bytes[]", type: "bytes[]" }, - { name: "externalData", internalType: "bytes", type: "bytes" }, + { name: "owner", internalType: "address", type: "address" }, + { name: "operator", internalType: "address", type: "address" }, ], - name: "onLinkToParents", - outputs: [], - stateMutability: "nonpayable", + name: "isApprovedForAll", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", }, { type: "function", inputs: [], - name: "pause", - outputs: [], - stateMutability: "nonpayable", + name: "isConsumingScheduledOp", + outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], + stateMutability: "view", }, { type: "function", - inputs: [], - name: "paused", + inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], + name: "isLicenseTokenRevoked", outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "view", }, { type: "function", inputs: [ - { name: "receiverIpId", internalType: "address", type: "address" }, - { name: "payerAddress", internalType: "address", type: "address" }, - { - name: "licenseRoyaltyPolicy", - internalType: "address", - type: "address", - }, - { name: "token", internalType: "address", type: "address" }, + { name: "licensorIpId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, { name: "amount", internalType: "uint256", type: "uint256" }, + { name: "minter", internalType: "address", type: "address" }, + { name: "receiver", internalType: "address", type: "address" }, ], - name: "payLicenseMintingFee", - outputs: [], + name: "mintLicenseTokens", + outputs: [{ name: "startLicenseTokenId", internalType: "uint256", type: "uint256" }], stateMutability: "nonpayable", }, { type: "function", - inputs: [ - { name: "receiverIpId", internalType: "address", type: "address" }, - { name: "payerIpId", internalType: "address", type: "address" }, - { name: "token", internalType: "address", type: "address" }, - { name: "amount", internalType: "uint256", type: "uint256" }, - ], - name: "payRoyaltyOnBehalf", - outputs: [], - stateMutability: "nonpayable", + inputs: [], + name: "name", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], + name: "ownerOf", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", }, { type: "function", @@ -5938,10 +6444,36 @@ export const royaltyModuleAbi = [ }, { type: "function", - inputs: [{ name: "ipId", internalType: "address", type: "address" }], - name: "royaltyPolicies", - outputs: [{ name: "", internalType: "address", type: "address" }], - stateMutability: "view", + inputs: [ + { name: "from", internalType: "address", type: "address" }, + { name: "to", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + ], + name: "safeTransferFrom", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "from", internalType: "address", type: "address" }, + { name: "to", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + { name: "data", internalType: "bytes", type: "bytes" }, + ], + name: "safeTransferFrom", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "operator", internalType: "address", type: "address" }, + { name: "approved", internalType: "bool", type: "bool" }, + ], + name: "setApprovalForAll", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", @@ -5950,6 +6482,13 @@ export const royaltyModuleAbi = [ outputs: [], stateMutability: "nonpayable", }, + { + type: "function", + inputs: [{ name: "url", internalType: "string", type: "string" }], + name: "setLicensingImageUrl", + outputs: [], + stateMutability: "nonpayable", + }, { type: "function", inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }], @@ -5960,74 +6499,128 @@ export const royaltyModuleAbi = [ { type: "function", inputs: [], - name: "unpause", - outputs: [], - stateMutability: "nonpayable", + name: "symbol", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "index", internalType: "uint256", type: "uint256" }], + name: "tokenByIndex", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", }, { type: "function", inputs: [ - { name: "newImplementation", internalType: "address", type: "address" }, - { name: "data", internalType: "bytes", type: "bytes" }, + { name: "owner", internalType: "address", type: "address" }, + { name: "index", internalType: "uint256", type: "uint256" }, ], - name: "upgradeToAndCall", - outputs: [], - stateMutability: "payable", + name: "tokenOfOwnerByIndex", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "id", internalType: "uint256", type: "uint256" }], + name: "tokenURI", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "totalMintedTokens", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "totalSupply", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", }, { type: "function", inputs: [ - { name: "royaltyPolicy", internalType: "address", type: "address" }, - { name: "allowed", internalType: "bool", type: "bool" }, + { name: "from", internalType: "address", type: "address" }, + { name: "to", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, ], - name: "whitelistRoyaltyPolicy", + name: "transferFrom", outputs: [], stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "token", internalType: "address", type: "address" }, - { name: "allowed", internalType: "bool", type: "bool" }, + { name: "newImplementation", internalType: "address", type: "address" }, + { name: "data", internalType: "bytes", type: "bytes" }, ], - name: "whitelistRoyaltyToken", + name: "upgradeToAndCall", outputs: [], - stateMutability: "nonpayable", + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "caller", internalType: "address", type: "address" }, + { name: "childIpId", internalType: "address", type: "address" }, + { name: "tokenIds", internalType: "uint256[]", type: "uint256[]" }, + ], + name: "validateLicenseTokensForDerivative", + outputs: [ + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licensorIpIds", internalType: "address[]", type: "address[]" }, + { name: "licenseTermsIds", internalType: "uint256[]", type: "uint256[]" }, + ], + stateMutability: "view", }, ] as const; /** * */ -export const royaltyModuleAddress = { - 1513: "0x968beb5432c362c12b5Be6967a5d6F1ED5A63F01", +export const licenseTokenAddress = { + 1513: "0xd8aEF404432a2b3363479A6157285926B6B3b743", } as const; /** * */ -export const royaltyModuleConfig = { - address: royaltyModuleAddress, - abi: royaltyModuleAbi, +export const licenseTokenConfig = { + address: licenseTokenAddress, + abi: licenseTokenAbi, } as const; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// RoyaltyPolicyLAP +// LicensingModule ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * */ -export const royaltyPolicyLapAbi = [ +export const licensingModuleAbi = [ { type: "constructor", inputs: [ - { name: "royaltyModule", internalType: "address", type: "address" }, - { name: "licensingModule", internalType: "address", type: "address" }, - { name: "ipGraphAcl", internalType: "address", type: "address" }, + { name: "accessController", internalType: "address", type: "address" }, + { name: "ipAccountRegistry", internalType: "address", type: "address" }, + { name: "moduleRegistry", internalType: "address", type: "address" }, + { name: "royaltyModule", internalType: "address", type: "address" }, + { name: "licenseRegistry", internalType: "address", type: "address" }, + { name: "disputeModule", internalType: "address", type: "address" }, + { name: "licenseToken", internalType: "address", type: "address" }, ], stateMutability: "nonpayable", }, + { + type: "error", + inputs: [{ name: "ipAccount", internalType: "address", type: "address" }], + name: "AccessControlled__NotIpAccount", + }, + { type: "error", inputs: [], name: "AccessControlled__ZeroAddress" }, { type: "error", inputs: [{ name: "authority", internalType: "address", type: "address" }], @@ -6051,11 +6644,6 @@ export const royaltyPolicyLapAbi = [ 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" }], @@ -6066,36 +6654,67 @@ export const royaltyPolicyLapAbi = [ { type: "error", inputs: [], name: "ExpectedPause" }, { type: "error", inputs: [], name: "FailedInnerCall" }, { type: "error", inputs: [], name: "InvalidInitialization" }, - { type: "error", inputs: [], name: "NotInitializing" }, - { type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" }, - { type: "error", inputs: [], name: "RoyaltyPolicyLAP__AboveAncestorsLimit" }, - { type: "error", inputs: [], name: "RoyaltyPolicyLAP__AboveParentLimit" }, + { type: "error", inputs: [], name: "LicensingModule__DisputedIpId" }, { type: "error", - inputs: [], - name: "RoyaltyPolicyLAP__AboveRoyaltyStackLimit", + inputs: [ + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + ], + name: "LicensingModule__InvalidLicenseTermsId", }, { type: "error", - inputs: [], - name: "RoyaltyPolicyLAP__LastPositionNotAbleToMintLicense", + inputs: [{ name: "hook", internalType: "address", type: "address" }], + name: "LicensingModule__InvalidLicensingHook", }, - { type: "error", inputs: [], name: "RoyaltyPolicyLAP__NotRoyaltyModule" }, - { type: "error", inputs: [], name: "RoyaltyPolicyLAP__UnlinkableToParents" }, - { type: "error", inputs: [], name: "RoyaltyPolicyLAP__ZeroAccessManager" }, - { type: "error", inputs: [], name: "RoyaltyPolicyLAP__ZeroIPGraphACL" }, { type: "error", - inputs: [], - name: "RoyaltyPolicyLAP__ZeroIpRoyaltyVaultBeacon", + inputs: [ + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { name: "licensorIpId", internalType: "address", type: "address" }, + ], + name: "LicensingModule__LicenseDenyMintLicenseToken", }, - { type: "error", inputs: [], name: "RoyaltyPolicyLAP__ZeroLicensingModule" }, - { type: "error", inputs: [], name: "RoyaltyPolicyLAP__ZeroRoyaltyModule" }, { type: "error", - inputs: [{ name: "token", internalType: "address", type: "address" }], - name: "SafeERC20FailedOperation", + inputs: [{ name: "childIpId", internalType: "address", type: "address" }], + name: "LicensingModule__LicenseNotCompatibleForDerivative", + }, + { + type: "error", + inputs: [ + { name: "ipLength", internalType: "uint256", type: "uint256" }, + { name: "licenseTermsLength", internalType: "uint256", type: "uint256" }, + ], + name: "LicensingModule__LicenseTermsLengthMismatch", + }, + { + type: "error", + inputs: [ + { name: "childIpId", internalType: "address", type: "address" }, + { name: "licenseTokenIds", internalType: "uint256[]", type: "uint256[]" }, + ], + name: "LicensingModule__LicenseTokenNotCompatibleForDerivative", + }, + { + type: "error", + inputs: [], + name: "LicensingModule__LicensorIpNotRegistered", }, + { type: "error", inputs: [], name: "LicensingModule__MintAmountZero" }, + { type: "error", inputs: [], name: "LicensingModule__NoLicenseToken" }, + { type: "error", inputs: [], name: "LicensingModule__NoParentIp" }, + { type: "error", inputs: [], name: "LicensingModule__ReceiverZeroAddress" }, + { type: "error", inputs: [], name: "LicensingModule__ZeroAccessManager" }, + { type: "error", inputs: [], name: "LicensingModule__ZeroDisputeModule" }, + { type: "error", inputs: [], name: "LicensingModule__ZeroLicenseRegistry" }, + { type: "error", inputs: [], name: "LicensingModule__ZeroLicenseToken" }, + { type: "error", inputs: [], name: "LicensingModule__ZeroModuleRegistry" }, + { type: "error", inputs: [], name: "LicensingModule__ZeroRoyaltyModule" }, + { type: "error", inputs: [], name: "NotInitializing" }, + { type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" }, { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, { type: "error", @@ -6120,96 +6739,144 @@ export const royaltyPolicyLapAbi = [ anonymous: false, inputs: [ { - name: "version", - internalType: "uint64", - type: "uint64", + name: "caller", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "childIpId", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "licenseTokenIds", + internalType: "uint256[]", + type: "uint256[]", + indexed: false, + }, + { + name: "parentIpIds", + internalType: "address[]", + type: "address[]", + indexed: false, + }, + { + name: "licenseTermsIds", + internalType: "uint256[]", + type: "uint256[]", indexed: false, }, - ], - name: "Initialized", - }, - { - type: "event", - anonymous: false, - inputs: [ { - name: "beacon", + name: "licenseTemplate", internalType: "address", type: "address", indexed: false, }, ], - name: "IpRoyaltyVaultBeaconSet", + name: "DerivativeRegistered", }, { type: "event", anonymous: false, inputs: [ { - name: "account", - internalType: "address", - type: "address", + name: "version", + internalType: "uint64", + type: "uint64", indexed: false, }, ], - name: "Paused", + name: "Initialized", }, { type: "event", anonymous: false, inputs: [ { - name: "ipId", + name: "caller", internalType: "address", type: "address", - indexed: false, + indexed: true, }, + { name: "ipId", internalType: "address", type: "address", indexed: true }, { - name: "ipRoyaltyVault", + name: "licenseTemplate", internalType: "address", type: "address", indexed: false, }, { - name: "royaltyStack", - internalType: "uint32", - type: "uint32", + name: "licenseTermsId", + internalType: "uint256", + type: "uint256", indexed: false, }, ], - name: "PolicyInitialized", + name: "LicenseTermsAttached", }, { type: "event", anonymous: false, inputs: [ { - name: "token", + name: "caller", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "licensorIpId", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "licenseTemplate", internalType: "address", type: "address", indexed: false, }, { - name: "vault", + name: "licenseTermsId", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + { + name: "amount", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + { + name: "receiver", internalType: "address", type: "address", indexed: false, }, + { + name: "startLicenseTokenId", + internalType: "uint256", + type: "uint256", + indexed: false, + }, ], - name: "RevenueTokenAddedToVault", + name: "LicenseTokensMinted", }, { type: "event", anonymous: false, inputs: [ { - name: "interval", - internalType: "uint256", - type: "uint256", + name: "account", + internalType: "address", + type: "address", indexed: false, }, ], - name: "SnapshotIntervalSet", + name: "Paused", }, { type: "event", @@ -6240,50 +6907,56 @@ export const royaltyPolicyLapAbi = [ { type: "function", inputs: [], - name: "IP_GRAPH_ACL", - outputs: [{ name: "", internalType: "contract IPGraphACL", type: "address" }], + name: "ACCESS_CONTROLLER", + outputs: [{ name: "", internalType: "contract IAccessController", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "IP_GRAPH_CONTRACT", - outputs: [{ name: "", internalType: "address", type: "address" }], + name: "DISPUTE_MODULE", + outputs: [{ name: "", internalType: "contract IDisputeModule", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "LICENSING_MODULE", - outputs: [{ name: "", internalType: "address", type: "address" }], + name: "IP_ACCOUNT_REGISTRY", + outputs: [ + { + name: "", + internalType: "contract IIPAccountRegistry", + type: "address", + }, + ], stateMutability: "view", }, { type: "function", inputs: [], - name: "MAX_ANCESTORS", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + name: "LICENSE_NFT", + outputs: [{ name: "", internalType: "contract ILicenseToken", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "MAX_PARENTS", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + name: "LICENSE_REGISTRY", + outputs: [{ name: "", internalType: "contract ILicenseRegistry", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "ROYALTY_MODULE", - outputs: [{ name: "", internalType: "address", type: "address" }], + name: "MODULE_REGISTRY", + outputs: [{ name: "", internalType: "contract IModuleRegistry", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "TOTAL_RT_SUPPLY", - outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + name: "ROYALTY_MODULE", + outputs: [{ name: "", internalType: "contract RoyaltyModule", type: "address" }], stateMutability: "view", }, { @@ -6300,6 +6973,17 @@ export const royaltyPolicyLapAbi = [ outputs: [], stateMutability: "nonpayable", }, + { + type: "function", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + ], + name: "attachLicenseTerms", + outputs: [], + stateMutability: "nonpayable", + }, { type: "function", inputs: [], @@ -6307,101 +6991,103 @@ export const royaltyPolicyLapAbi = [ outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, + { + type: "function", + inputs: [{ name: "accessManager", internalType: "address", type: "address" }], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + }, { type: "function", inputs: [], - name: "getIpRoyaltyVaultBeacon", - outputs: [{ name: "", internalType: "address", type: "address" }], + name: "isConsumingScheduledOp", + outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "ipId", internalType: "address", type: "address" }], - name: "getRoyaltyData", - outputs: [ - { name: "", internalType: "bool", type: "bool" }, - { name: "", internalType: "address", type: "address" }, - { name: "", internalType: "uint32", type: "uint32" }, + inputs: [ + { name: "licensorIpId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { name: "amount", internalType: "uint256", type: "uint256" }, + { name: "receiver", internalType: "address", type: "address" }, + { name: "royaltyContext", internalType: "bytes", type: "bytes" }, ], - stateMutability: "view", + name: "mintLicenseTokens", + outputs: [{ name: "startLicenseTokenId", internalType: "uint256", type: "uint256" }], + stateMutability: "nonpayable", }, { type: "function", inputs: [], - name: "getSnapshotInterval", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + name: "name", + outputs: [{ name: "", internalType: "string", type: "string" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "accessManager", internalType: "address", type: "address" }], - name: "initialize", + inputs: [], + name: "pause", outputs: [], stateMutability: "nonpayable", }, { type: "function", inputs: [], - name: "isConsumingScheduledOp", - outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], + name: "paused", + outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "view", }, { type: "function", inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "licenseData", internalType: "bytes", type: "bytes" }, - { name: "externalData", internalType: "bytes", type: "bytes" }, + { name: "licensorIpId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { name: "amount", internalType: "uint256", type: "uint256" }, + { name: "receiver", internalType: "address", type: "address" }, + { name: "royaltyContext", internalType: "bytes", type: "bytes" }, ], - name: "onLicenseMinting", - outputs: [], - stateMutability: "nonpayable", + name: "predictMintingLicenseFee", + outputs: [ + { name: "currencyToken", internalType: "address", type: "address" }, + { name: "tokenAmount", internalType: "uint256", type: "uint256" }, + ], + stateMutability: "view", }, { type: "function", - inputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "parentIpIds", internalType: "address[]", type: "address[]" }, - { name: "licenseData", internalType: "bytes[]", type: "bytes[]" }, - { name: "externalData", internalType: "bytes", type: "bytes" }, - ], - name: "onLinkToParents", - outputs: [], - stateMutability: "nonpayable", + inputs: [], + name: "proxiableUUID", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view", }, { type: "function", inputs: [ - { name: "caller", internalType: "address", type: "address" }, - { name: "ipId", internalType: "address", type: "address" }, - { name: "token", internalType: "address", type: "address" }, - { name: "amount", internalType: "uint256", type: "uint256" }, + { name: "childIpId", internalType: "address", type: "address" }, + { name: "parentIpIds", internalType: "address[]", type: "address[]" }, + { name: "licenseTermsIds", internalType: "uint256[]", type: "uint256[]" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "royaltyContext", internalType: "bytes", type: "bytes" }, ], - name: "onRoyaltyPayment", + name: "registerDerivative", outputs: [], stateMutability: "nonpayable", }, { type: "function", - inputs: [], - name: "pause", + inputs: [ + { name: "childIpId", internalType: "address", type: "address" }, + { name: "licenseTokenIds", internalType: "uint256[]", type: "uint256[]" }, + { name: "royaltyContext", internalType: "bytes", type: "bytes" }, + ], + name: "registerDerivativeWithLicenseTokens", outputs: [], stateMutability: "nonpayable", }, - { - type: "function", - inputs: [], - name: "paused", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [], - name: "proxiableUUID", - outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], - stateMutability: "view", - }, { type: "function", inputs: [{ name: "newAuthority", internalType: "address", type: "address" }], @@ -6411,17 +7097,32 @@ export const royaltyPolicyLapAbi = [ }, { type: "function", - inputs: [{ name: "beacon", internalType: "address", type: "address" }], - name: "setIpRoyaltyVaultBeacon", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "licenseTemplate", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { + name: "licensingConfig", + internalType: "struct Licensing.LicensingConfig", + type: "tuple", + components: [ + { name: "isSet", internalType: "bool", type: "bool" }, + { name: "mintingFee", internalType: "uint256", type: "uint256" }, + { name: "licensingHook", internalType: "address", type: "address" }, + { name: "hookData", internalType: "bytes", type: "bytes" }, + ], + }, + ], + name: "setLicensingConfig", outputs: [], stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "timestampInterval", internalType: "uint256", type: "uint256" }], - name: "setSnapshotInterval", - outputs: [], - stateMutability: "nonpayable", + inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }], + name: "supportsInterface", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", }, { type: "function", @@ -6440,231 +7141,385 @@ export const royaltyPolicyLapAbi = [ outputs: [], stateMutability: "payable", }, - { - type: "function", - inputs: [{ name: "newVault", internalType: "address", type: "address" }], - name: "upgradeVaults", - outputs: [], - stateMutability: "nonpayable", - }, ] as const; /** * */ -export const royaltyPolicyLapAddress = { - 1513: "0x61A5c7570f5bDB118D65053Ba60DE87e050E664e", +export const licensingModuleAddress = { + 1513: "0xC8f165950411504eA130692B87A7148e469f7090", } as const; /** * */ -export const royaltyPolicyLapConfig = { - address: royaltyPolicyLapAddress, - abi: royaltyPolicyLapAbi, +export const licensingModuleConfig = { + address: licensingModuleAddress, + abi: licensingModuleAbi, } as const; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// SPG +// MockERC20 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * */ -export const spgAbi = [ +export const mockErc20Abi = [ + { type: "constructor", inputs: [], stateMutability: "nonpayable" }, { - type: "constructor", + type: "error", inputs: [ - { name: "accessController", internalType: "address", type: "address" }, - { name: "ipAssetRegistry", internalType: "address", type: "address" }, - { name: "licensingModule", internalType: "address", type: "address" }, - { name: "licenseRegistry", internalType: "address", type: "address" }, - { name: "royaltyModule", internalType: "address", type: "address" }, - { name: "coreMetadataModule", internalType: "address", type: "address" }, - { name: "pilTemplate", internalType: "address", type: "address" }, - { name: "licenseToken", internalType: "address", type: "address" }, + { name: "spender", internalType: "address", type: "address" }, + { name: "allowance", internalType: "uint256", type: "uint256" }, + { name: "needed", internalType: "uint256", type: "uint256" }, ], - stateMutability: "nonpayable", - }, - { - type: "error", - inputs: [{ name: "authority", internalType: "address", type: "address" }], - name: "AccessManagedInvalidAuthority", + name: "ERC20InsufficientAllowance", }, { type: "error", inputs: [ - { name: "caller", internalType: "address", type: "address" }, - { name: "delay", internalType: "uint32", type: "uint32" }, + { name: "sender", internalType: "address", type: "address" }, + { name: "balance", internalType: "uint256", type: "uint256" }, + { name: "needed", internalType: "uint256", type: "uint256" }, ], - 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", + name: "ERC20InsufficientBalance", }, { type: "error", - inputs: [{ name: "implementation", internalType: "address", type: "address" }], - name: "ERC1967InvalidImplementation", + inputs: [{ name: "approver", internalType: "address", type: "address" }], + name: "ERC20InvalidApprover", }, - { type: "error", inputs: [], name: "ERC1967NonPayable" }, - { type: "error", inputs: [], name: "FailedInnerCall" }, - { type: "error", inputs: [], name: "InvalidInitialization" }, - { type: "error", inputs: [], name: "NotInitializing" }, { type: "error", - inputs: [ - { name: "tokenId", internalType: "uint256", type: "uint256" }, - { name: "caller", internalType: "address", type: "address" }, - { name: "actualTokenOwner", internalType: "address", type: "address" }, - ], - name: "SPG__CallerAndNotTokenOwner", + inputs: [{ name: "receiver", internalType: "address", type: "address" }], + name: "ERC20InvalidReceiver", }, - { type: "error", inputs: [], name: "SPG__CallerNotMinterRole" }, - { type: "error", inputs: [], name: "SPG__EmptyLicenseTokens" }, - { type: "error", inputs: [], name: "SPG__ZeroAddressParam" }, { type: "error", - inputs: [{ name: "token", internalType: "address", type: "address" }], - name: "SafeERC20FailedOperation", + inputs: [{ name: "sender", internalType: "address", type: "address" }], + name: "ERC20InvalidSender", }, - { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, { type: "error", - inputs: [{ name: "slot", internalType: "bytes32", type: "bytes32" }], - name: "UUPSUnsupportedProxiableUUID", + inputs: [{ name: "spender", internalType: "address", type: "address" }], + name: "ERC20InvalidSpender", }, { type: "event", anonymous: false, inputs: [ { - name: "authority", + name: "owner", internalType: "address", type: "address", - indexed: false, + indexed: true, }, - ], - name: "AuthorityUpdated", - }, - { - type: "event", - anonymous: false, - inputs: [ { - name: "nftContract", + name: "spender", internalType: "address", type: "address", indexed: true, }, + { + name: "value", + internalType: "uint256", + type: "uint256", + indexed: false, + }, ], - name: "CollectionCreated", + name: "Approval", }, { type: "event", anonymous: false, inputs: [ + { name: "from", internalType: "address", type: "address", indexed: true }, + { name: "to", internalType: "address", type: "address", indexed: true }, { - name: "version", - internalType: "uint64", - type: "uint64", + name: "value", + internalType: "uint256", + type: "uint256", indexed: false, }, ], - name: "Initialized", + name: "Transfer", }, { - type: "event", - anonymous: false, + type: "function", inputs: [ - { - name: "implementation", - internalType: "address", - type: "address", - indexed: true, - }, + { name: "owner", internalType: "address", type: "address" }, + { name: "spender", internalType: "address", type: "address" }, ], - name: "Upgraded", + name: "allowance", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", }, { type: "function", - inputs: [], - name: "ACCESS_CONTROLLER", - outputs: [{ name: "", internalType: "contract IAccessController", type: "address" }], + inputs: [ + { name: "spender", internalType: "address", type: "address" }, + { name: "value", internalType: "uint256", type: "uint256" }, + ], + name: "approve", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "account", internalType: "address", type: "address" }], + name: "balanceOf", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], stateMutability: "view", }, { type: "function", - inputs: [], - name: "CORE_METADATA_MODULE", - outputs: [ - { - name: "", - internalType: "contract ICoreMetadataModule", - type: "address", - }, + inputs: [ + { name: "from", internalType: "address", type: "address" }, + { name: "amount", internalType: "uint256", type: "uint256" }, ], - stateMutability: "view", + name: "burn", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", inputs: [], - name: "IP_ASSET_REGISTRY", - outputs: [{ name: "", internalType: "contract IIPAssetRegistry", type: "address" }], + name: "decimals", + outputs: [{ name: "", internalType: "uint8", type: "uint8" }], stateMutability: "view", }, { type: "function", - inputs: [], - name: "LICENSE_REGISTRY", - outputs: [{ name: "", internalType: "contract ILicenseRegistry", type: "address" }], - stateMutability: "view", + inputs: [ + { name: "to", internalType: "address", type: "address" }, + { name: "amount", internalType: "uint256", type: "uint256" }, + ], + name: "mint", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", inputs: [], - name: "LICENSE_TOKEN", - outputs: [{ name: "", internalType: "contract ILicenseToken", type: "address" }], + name: "name", + outputs: [{ name: "", internalType: "string", type: "string" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "LICENSING_MODULE", - outputs: [{ name: "", internalType: "contract ILicensingModule", type: "address" }], + name: "symbol", + outputs: [{ name: "", internalType: "string", type: "string" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "PIL_TEMPLATE", - outputs: [ + name: "totalSupply", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "to", internalType: "address", type: "address" }, + { name: "value", internalType: "uint256", type: "uint256" }, + ], + name: "transfer", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "from", internalType: "address", type: "address" }, + { name: "to", internalType: "address", type: "address" }, + { name: "value", internalType: "uint256", type: "uint256" }, + ], + name: "transferFrom", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "nonpayable", + }, +] as const; + +/** + * + */ +export const mockErc20Address = { + 1513: "0x91f6F05B08c16769d3c85867548615d270C42fC7", +} as const; + +/** + * + */ +export const mockErc20Config = { + address: mockErc20Address, + abi: mockErc20Abi, +} as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// ModuleRegistry +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * + */ +export const moduleRegistryAbi = [ + { type: "constructor", inputs: [], 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: "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: "ModuleRegistry__InterfaceIdZero" }, + { + type: "error", + inputs: [], + name: "ModuleRegistry__ModuleAddressNotContract", + }, + { + type: "error", + inputs: [], + name: "ModuleRegistry__ModuleAddressZeroAddress", + }, + { + type: "error", + inputs: [], + name: "ModuleRegistry__ModuleAlreadyRegistered", + }, + { type: "error", inputs: [], name: "ModuleRegistry__ModuleNotRegistered" }, + { + type: "error", + inputs: [], + name: "ModuleRegistry__ModuleNotSupportExpectedModuleTypeInterfaceId", + }, + { + type: "error", + inputs: [], + name: "ModuleRegistry__ModuleTypeAlreadyRegistered", + }, + { type: "error", inputs: [], name: "ModuleRegistry__ModuleTypeEmptyString" }, + { + type: "error", + inputs: [], + name: "ModuleRegistry__ModuleTypeNotRegistered", + }, + { type: "error", inputs: [], name: "ModuleRegistry__NameAlreadyRegistered" }, + { type: "error", inputs: [], name: "ModuleRegistry__NameDoesNotMatch" }, + { type: "error", inputs: [], name: "ModuleRegistry__NameEmptyString" }, + { type: "error", inputs: [], name: "ModuleRegistry__ZeroAccessManager" }, + { type: "error", inputs: [], name: "NotInitializing" }, + { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, + { + type: "error", + inputs: [{ name: "slot", internalType: "bytes32", type: "bytes32" }], + name: "UUPSUnsupportedProxiableUUID", + }, + { + type: "event", + anonymous: false, + inputs: [ { - name: "", - internalType: "contract IPILicenseTemplate", + name: "authority", + internalType: "address", type: "address", + indexed: false, }, ], - stateMutability: "view", + name: "AuthorityUpdated", }, { - type: "function", - inputs: [], - name: "ROYALTY_MODULE", - outputs: [{ name: "", internalType: "contract IRoyaltyModule", type: "address" }], - stateMutability: "view", + type: "event", + anonymous: false, + inputs: [ + { + name: "version", + internalType: "uint64", + type: "uint64", + indexed: false, + }, + ], + name: "Initialized", + }, + { + type: "event", + anonymous: false, + inputs: [ + { name: "name", internalType: "string", type: "string", indexed: false }, + { + name: "module", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "moduleTypeInterfaceId", + internalType: "bytes4", + type: "bytes4", + indexed: true, + }, + { + name: "moduleType", + internalType: "string", + type: "string", + indexed: false, + }, + ], + name: "ModuleAdded", + }, + { + type: "event", + anonymous: false, + inputs: [ + { name: "name", internalType: "string", type: "string", indexed: false }, + { + name: "module", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "ModuleRemoved", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "implementation", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "Upgraded", }, { type: "function", @@ -6682,17 +7537,24 @@ export const spgAbi = [ }, { type: "function", - inputs: [ - { name: "name", internalType: "string", type: "string" }, - { name: "symbol", internalType: "string", type: "string" }, - { name: "maxSupply", internalType: "uint32", type: "uint32" }, - { name: "mintFee", internalType: "uint256", type: "uint256" }, - { name: "mintFeeToken", internalType: "address", type: "address" }, - { name: "owner", internalType: "address", type: "address" }, - ], - name: "createCollection", - outputs: [{ name: "nftContract", internalType: "address", type: "address" }], - stateMutability: "nonpayable", + inputs: [{ name: "name", internalType: "string", type: "string" }], + name: "getModule", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "moduleAddress", internalType: "address", type: "address" }], + name: "getModuleType", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "moduleType", internalType: "string", type: "string" }], + name: "getModuleTypeInterfaceId", + outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], + stateMutability: "view", }, { type: "function", @@ -6710,426 +7572,474 @@ export const spgAbi = [ }, { type: "function", - inputs: [ - { name: "nftContract", internalType: "address", type: "address" }, - { name: "recipient", internalType: "address", type: "address" }, - { - name: "ipMetadata", - internalType: "struct IStoryProtocolGateway.IPMetadata", - type: "tuple", - components: [ - { name: "ipMetadataURI", internalType: "string", type: "string" }, - { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, - { name: "nftMetadataURI", internalType: "string", type: "string" }, - { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, - ], - }, - ], - name: "mintAndRegisterIp", - outputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, - ], - stateMutability: "nonpayable", + inputs: [{ name: "moduleAddress", internalType: "address", type: "address" }], + name: "isRegistered", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", }, { type: "function", - inputs: [ - { name: "nftContract", internalType: "address", type: "address" }, - { name: "recipient", internalType: "address", type: "address" }, - { - name: "ipMetadata", - internalType: "struct IStoryProtocolGateway.IPMetadata", - type: "tuple", - components: [ - { name: "ipMetadataURI", internalType: "string", type: "string" }, - { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, - { name: "nftMetadataURI", internalType: "string", type: "string" }, - { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, - ], - }, - { - name: "terms", - internalType: "struct PILTerms", - type: "tuple", - components: [ - { name: "transferable", internalType: "bool", type: "bool" }, - { name: "royaltyPolicy", internalType: "address", type: "address" }, - { - name: "defaultMintingFee", - internalType: "uint256", - type: "uint256", - }, - { name: "expiration", internalType: "uint256", type: "uint256" }, - { name: "commercialUse", internalType: "bool", type: "bool" }, - { name: "commercialAttribution", internalType: "bool", type: "bool" }, - { - name: "commercializerChecker", - internalType: "address", - type: "address", - }, - { - name: "commercializerCheckerData", - internalType: "bytes", - type: "bytes", - }, - { - name: "commercialRevShare", - internalType: "uint32", - type: "uint32", - }, - { - name: "commercialRevCeiling", - internalType: "uint256", - type: "uint256", - }, - { name: "derivativesAllowed", internalType: "bool", type: "bool" }, - { - name: "derivativesAttribution", - internalType: "bool", - type: "bool", - }, - { name: "derivativesApproval", internalType: "bool", type: "bool" }, - { name: "derivativesReciprocal", internalType: "bool", type: "bool" }, - { - name: "derivativeRevCeiling", - internalType: "uint256", - type: "uint256", - }, - { name: "currency", internalType: "address", type: "address" }, - { name: "uri", internalType: "string", type: "string" }, - ], - }, - ], - name: "mintAndRegisterIpAndAttachPILTerms", - outputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + inputs: [], + name: "proxiableUUID", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "name", internalType: "string", type: "string" }, + { name: "moduleAddress", internalType: "address", type: "address" }, ], + name: "registerModule", + outputs: [], stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "nftContract", internalType: "address", type: "address" }, - { - name: "derivData", - internalType: "struct IStoryProtocolGateway.MakeDerivative", - type: "tuple", - components: [ - { name: "parentIpIds", internalType: "address[]", type: "address[]" }, - { name: "licenseTemplate", internalType: "address", type: "address" }, - { - name: "licenseTermsIds", - internalType: "uint256[]", - type: "uint256[]", - }, - { name: "royaltyContext", internalType: "bytes", type: "bytes" }, - ], - }, - { - name: "ipMetadata", - internalType: "struct IStoryProtocolGateway.IPMetadata", - type: "tuple", - components: [ - { name: "ipMetadataURI", internalType: "string", type: "string" }, - { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, - { name: "nftMetadataURI", internalType: "string", type: "string" }, - { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, - ], - }, - { name: "recipient", internalType: "address", type: "address" }, - ], - name: "mintAndRegisterIpAndMakeDerivative", - outputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, + { name: "name", internalType: "string", type: "string" }, + { name: "moduleAddress", internalType: "address", type: "address" }, + { name: "moduleType", internalType: "string", type: "string" }, ], + name: "registerModule", + outputs: [], stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "nftContract", internalType: "address", type: "address" }, - { name: "licenseTokenIds", internalType: "uint256[]", type: "uint256[]" }, - { name: "royaltyContext", internalType: "bytes", type: "bytes" }, - { - name: "ipMetadata", - internalType: "struct IStoryProtocolGateway.IPMetadata", - type: "tuple", - components: [ - { name: "ipMetadataURI", internalType: "string", type: "string" }, - { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, - { name: "nftMetadataURI", internalType: "string", type: "string" }, - { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, - ], - }, - { name: "recipient", internalType: "address", type: "address" }, - ], - name: "mintAndRegisterIpAndMakeDerivativeWithLicenseTokens", - outputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, + { name: "name", internalType: "string", type: "string" }, + { name: "interfaceId", internalType: "bytes4", type: "bytes4" }, ], + name: "registerModuleType", + outputs: [], stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "data", internalType: "bytes[]", type: "bytes[]" }], - name: "multicall", - outputs: [{ name: "results", internalType: "bytes[]", type: "bytes[]" }], + inputs: [{ name: "name", internalType: "string", type: "string" }], + name: "removeModule", + outputs: [], stateMutability: "nonpayable", }, { type: "function", - inputs: [ - { name: "", internalType: "address", type: "address" }, - { name: "", internalType: "address", type: "address" }, - { name: "", internalType: "uint256", type: "uint256" }, - { name: "", internalType: "bytes", type: "bytes" }, - ], - name: "onERC721Received", - outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], + inputs: [{ name: "name", internalType: "string", type: "string" }], + name: "removeModuleType", + outputs: [], stateMutability: "nonpayable", }, { type: "function", - inputs: [], - name: "proxiableUUID", - outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], - stateMutability: "view", + inputs: [{ name: "newAuthority", internalType: "address", type: "address" }], + name: "setAuthority", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "nftContract", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, - { - name: "ipMetadata", - internalType: "struct IStoryProtocolGateway.IPMetadata", - type: "tuple", - components: [ - { name: "ipMetadataURI", internalType: "string", type: "string" }, - { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, - { name: "nftMetadataURI", internalType: "string", type: "string" }, - { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, - ], - }, - { - name: "sigMetadata", - internalType: "struct IStoryProtocolGateway.SignatureData", - type: "tuple", - components: [ - { name: "signer", internalType: "address", type: "address" }, - { name: "deadline", internalType: "uint256", type: "uint256" }, - { name: "signature", internalType: "bytes", type: "bytes" }, - ], - }, + { name: "newImplementation", internalType: "address", type: "address" }, + { name: "data", internalType: "bytes", type: "bytes" }, + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + }, +] as const; + +/** + * + */ +export const moduleRegistryAddress = { + 1513: "0x47bEae573B73F8BF1B4fa4Af065c39743871003f", +} as const; + +/** + * + */ +export const moduleRegistryConfig = { + address: moduleRegistryAddress, + abi: moduleRegistryAbi, +} as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// PILicenseTemplate +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * + */ +export const piLicenseTemplateAbi = [ + { + type: "constructor", + inputs: [ + { name: "accessController", internalType: "address", type: "address" }, + { name: "ipAccountRegistry", internalType: "address", type: "address" }, + { name: "licenseRegistry", internalType: "address", type: "address" }, + { name: "royaltyModule", internalType: "address", type: "address" }, ], - name: "registerIp", - outputs: [{ name: "ipId", internalType: "address", type: "address" }], stateMutability: "nonpayable", }, { - type: "function", + type: "error", + inputs: [{ name: "ipAccount", internalType: "address", type: "address" }], + name: "AccessControlled__NotIpAccount", + }, + { type: "error", inputs: [], name: "AccessControlled__ZeroAddress" }, + { + type: "error", + inputs: [{ name: "authority", internalType: "address", type: "address" }], + name: "AccessManagedInvalidAuthority", + }, + { + type: "error", inputs: [ - { name: "nftContract", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, - { - name: "ipMetadata", - internalType: "struct IStoryProtocolGateway.IPMetadata", - type: "tuple", - components: [ - { name: "ipMetadataURI", internalType: "string", type: "string" }, - { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, - { name: "nftMetadataURI", internalType: "string", type: "string" }, - { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, - ], - }, - { - name: "terms", - internalType: "struct PILTerms", - type: "tuple", - components: [ - { name: "transferable", internalType: "bool", type: "bool" }, - { name: "royaltyPolicy", internalType: "address", type: "address" }, - { - name: "defaultMintingFee", - internalType: "uint256", - type: "uint256", - }, - { name: "expiration", internalType: "uint256", type: "uint256" }, - { name: "commercialUse", internalType: "bool", type: "bool" }, - { name: "commercialAttribution", internalType: "bool", type: "bool" }, - { - name: "commercializerChecker", - internalType: "address", - type: "address", - }, - { - name: "commercializerCheckerData", - internalType: "bytes", - type: "bytes", - }, - { - name: "commercialRevShare", - internalType: "uint32", - type: "uint32", - }, - { - name: "commercialRevCeiling", - internalType: "uint256", - type: "uint256", - }, - { name: "derivativesAllowed", internalType: "bool", type: "bool" }, - { - name: "derivativesAttribution", - internalType: "bool", - type: "bool", - }, - { name: "derivativesApproval", internalType: "bool", type: "bool" }, - { name: "derivativesReciprocal", internalType: "bool", type: "bool" }, - { - name: "derivativeRevCeiling", - internalType: "uint256", - type: "uint256", - }, - { name: "currency", internalType: "address", type: "address" }, - { name: "uri", internalType: "string", type: "string" }, - ], - }, - { - name: "sigMetadata", - internalType: "struct IStoryProtocolGateway.SignatureData", - type: "tuple", - components: [ - { name: "signer", internalType: "address", type: "address" }, - { name: "deadline", internalType: "uint256", type: "uint256" }, - { name: "signature", internalType: "bytes", type: "bytes" }, - ], - }, - { - name: "sigAttach", - internalType: "struct IStoryProtocolGateway.SignatureData", - type: "tuple", - components: [ - { name: "signer", internalType: "address", type: "address" }, - { name: "deadline", internalType: "uint256", type: "uint256" }, - { name: "signature", internalType: "bytes", type: "bytes" }, - ], - }, - ], - name: "registerIpAndAttachPILTerms", - outputs: [ - { name: "ipId", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { name: "caller", internalType: "address", type: "address" }, + { name: "delay", internalType: "uint32", type: "uint32" }, ], - stateMutability: "nonpayable", + name: "AccessManagedRequiredDelay", }, { - type: "function", + 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: "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: "PILicenseTemplate__CommercialDisabled_CantAddAttribution", + }, + { + type: "error", + inputs: [], + name: "PILicenseTemplate__CommercialDisabled_CantAddCommercializers", + }, + { + type: "error", + inputs: [], + name: "PILicenseTemplate__CommercialDisabled_CantAddDerivativeRevCeiling", + }, + { + type: "error", + inputs: [], + name: "PILicenseTemplate__CommercialDisabled_CantAddRevCeiling", + }, + { + type: "error", + inputs: [], + name: "PILicenseTemplate__CommercialDisabled_CantAddRevShare", + }, + { + type: "error", + inputs: [], + name: "PILicenseTemplate__CommercialDisabled_CantAddRoyaltyPolicy", + }, + { + type: "error", + inputs: [], + name: "PILicenseTemplate__CommercialEnabled_RoyaltyPolicyRequired", + }, + { + type: "error", + inputs: [{ name: "checker", internalType: "address", type: "address" }], + name: "PILicenseTemplate__CommercializerCheckerDoesNotSupportHook", + }, + { + type: "error", + inputs: [], + name: "PILicenseTemplate__CurrencyTokenNotWhitelisted", + }, + { + type: "error", + inputs: [], + name: "PILicenseTemplate__DerivativesDisabled_CantAddApproval", + }, + { + type: "error", + inputs: [], + name: "PILicenseTemplate__DerivativesDisabled_CantAddAttribution", + }, + { + type: "error", + inputs: [], + name: "PILicenseTemplate__DerivativesDisabled_CantAddDerivativeRevCeiling", + }, + { + type: "error", + inputs: [], + name: "PILicenseTemplate__DerivativesDisabled_CantAddReciprocal", + }, + { + type: "error", + inputs: [], + name: "PILicenseTemplate__RoyaltyPolicyNotWhitelisted", + }, + { + type: "error", + inputs: [], + name: "PILicenseTemplate__RoyaltyPolicyRequiresCurrencyToken", + }, + { type: "error", inputs: [], name: "PILicenseTemplate__ZeroAccessManager" }, + { type: "error", inputs: [], name: "PILicenseTemplate__ZeroLicenseRegistry" }, + { type: "error", inputs: [], name: "PILicenseTemplate__ZeroRoyaltyModule" }, + { type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" }, + { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, + { + type: "error", + inputs: [{ name: "slot", internalType: "bytes32", type: "bytes32" }], + name: "UUPSUnsupportedProxiableUUID", + }, + { + type: "event", + anonymous: false, inputs: [ - { name: "nftContract", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, { - name: "derivData", - internalType: "struct IStoryProtocolGateway.MakeDerivative", - type: "tuple", - components: [ - { name: "parentIpIds", internalType: "address[]", type: "address[]" }, - { name: "licenseTemplate", internalType: "address", type: "address" }, - { - name: "licenseTermsIds", - internalType: "uint256[]", - type: "uint256[]", - }, - { name: "royaltyContext", internalType: "bytes", type: "bytes" }, - ], + name: "authority", + internalType: "address", + type: "address", + indexed: false, }, + ], + name: "AuthorityUpdated", + }, + { + type: "event", + anonymous: false, + inputs: [ { - name: "ipMetadata", - internalType: "struct IStoryProtocolGateway.IPMetadata", - type: "tuple", - components: [ - { name: "ipMetadataURI", internalType: "string", type: "string" }, - { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, - { name: "nftMetadataURI", internalType: "string", type: "string" }, - { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, - ], + name: "licenseTermsId", + internalType: "uint256", + type: "uint256", + indexed: true, }, + { name: "ipId", internalType: "address", type: "address", indexed: true }, { - name: "sigMetadata", - internalType: "struct IStoryProtocolGateway.SignatureData", - type: "tuple", - components: [ - { name: "signer", internalType: "address", type: "address" }, - { name: "deadline", internalType: "uint256", type: "uint256" }, - { name: "signature", internalType: "bytes", type: "bytes" }, - ], + name: "caller", + internalType: "address", + type: "address", + indexed: true, }, + { name: "approved", internalType: "bool", type: "bool", indexed: false }, + ], + name: "DerivativeApproved", + }, + { + type: "event", + anonymous: false, + inputs: [ { - name: "sigRegister", - internalType: "struct IStoryProtocolGateway.SignatureData", - type: "tuple", - components: [ - { name: "signer", internalType: "address", type: "address" }, - { name: "deadline", internalType: "uint256", type: "uint256" }, - { name: "signature", internalType: "bytes", type: "bytes" }, - ], + name: "version", + internalType: "uint64", + type: "uint64", + indexed: false, }, ], - name: "registerIpAndMakeDerivative", - outputs: [{ name: "ipId", internalType: "address", type: "address" }], - stateMutability: "nonpayable", + name: "Initialized", }, { - type: "function", + type: "event", + anonymous: false, inputs: [ - { name: "nftContract", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, - { name: "licenseTokenIds", internalType: "uint256[]", type: "uint256[]" }, - { name: "royaltyContext", internalType: "bytes", type: "bytes" }, { - name: "ipMetadata", - internalType: "struct IStoryProtocolGateway.IPMetadata", - type: "tuple", - components: [ - { name: "ipMetadataURI", internalType: "string", type: "string" }, - { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, - { name: "nftMetadataURI", internalType: "string", type: "string" }, - { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, - ], + name: "licenseTermsId", + internalType: "uint256", + type: "uint256", + indexed: true, }, { - name: "sigMetadata", - internalType: "struct IStoryProtocolGateway.SignatureData", - type: "tuple", - components: [ - { name: "signer", internalType: "address", type: "address" }, - { name: "deadline", internalType: "uint256", type: "uint256" }, - { name: "signature", internalType: "bytes", type: "bytes" }, - ], + name: "licenseTemplate", + internalType: "address", + type: "address", + indexed: true, }, { - name: "sigRegister", - internalType: "struct IStoryProtocolGateway.SignatureData", + name: "licenseTerms", + internalType: "bytes", + type: "bytes", + indexed: false, + }, + ], + name: "LicenseTermsRegistered", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "implementation", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "Upgraded", + }, + { + type: "function", + inputs: [], + name: "ACCESS_CONTROLLER", + outputs: [{ name: "", internalType: "contract IAccessController", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "IP_ACCOUNT_REGISTRY", + outputs: [ + { + name: "", + internalType: "contract IIPAccountRegistry", + type: "address", + }, + ], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "LICENSE_REGISTRY", + outputs: [{ name: "", internalType: "contract ILicenseRegistry", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "ROYALTY_MODULE", + outputs: [{ name: "", internalType: "contract IRoyaltyModule", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "TERMS_RENDERER", + outputs: [{ name: "", internalType: "contract PILTermsRenderer", 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: "licenseTermsId", internalType: "uint256", type: "uint256" }], + name: "exists", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "licenseTermsIds", internalType: "uint256[]", type: "uint256[]" }, + { name: "start", internalType: "uint256", type: "uint256" }, + ], + name: "getEarlierExpireTime", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { name: "start", internalType: "uint256", type: "uint256" }, + ], + name: "getExpireTime", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { + name: "selectedLicenseTermsId", + internalType: "uint256", + type: "uint256", + }, + ], + name: "getLicenseTerms", + outputs: [ + { + name: "terms", + internalType: "struct PILTerms", type: "tuple", components: [ - { name: "signer", internalType: "address", type: "address" }, - { name: "deadline", internalType: "uint256", type: "uint256" }, - { name: "signature", internalType: "bytes", type: "bytes" }, + { name: "transferable", internalType: "bool", type: "bool" }, + { name: "royaltyPolicy", internalType: "address", type: "address" }, + { + name: "defaultMintingFee", + internalType: "uint256", + type: "uint256", + }, + { name: "expiration", internalType: "uint256", type: "uint256" }, + { name: "commercialUse", internalType: "bool", type: "bool" }, + { name: "commercialAttribution", internalType: "bool", type: "bool" }, + { + name: "commercializerChecker", + internalType: "address", + type: "address", + }, + { + name: "commercializerCheckerData", + internalType: "bytes", + type: "bytes", + }, + { + name: "commercialRevShare", + internalType: "uint32", + type: "uint32", + }, + { + name: "commercialRevCeiling", + internalType: "uint256", + type: "uint256", + }, + { name: "derivativesAllowed", internalType: "bool", type: "bool" }, + { + name: "derivativesAttribution", + internalType: "bool", + type: "bool", + }, + { name: "derivativesApproval", internalType: "bool", type: "bool" }, + { name: "derivativesReciprocal", internalType: "bool", type: "bool" }, + { + name: "derivativeRevCeiling", + internalType: "uint256", + type: "uint256", + }, + { name: "currency", internalType: "address", type: "address" }, + { name: "uri", internalType: "string", type: "string" }, ], }, ], - name: "registerIpAndMakeDerivativeWithLicenseTokens", - outputs: [{ name: "ipId", internalType: "address", type: "address" }], - stateMutability: "nonpayable", + stateMutability: "view", }, { type: "function", inputs: [ - { name: "ipId", internalType: "address", type: "address" }, { name: "terms", internalType: "struct PILTerms", @@ -7183,157 +8093,243 @@ export const spgAbi = [ ], }, ], - name: "registerPILTermsAndAttach", - outputs: [{ name: "licenseTermsId", internalType: "uint256", type: "uint256" }], - stateMutability: "nonpayable", + name: "getLicenseTermsId", + outputs: [ + { + name: "selectedLicenseTermsId", + internalType: "uint256", + type: "uint256", + }, + ], + stateMutability: "view", }, { type: "function", - inputs: [{ name: "newAuthority", internalType: "address", type: "address" }], - name: "setAuthority", - outputs: [], - stateMutability: "nonpayable", + inputs: [{ name: "licenseTermsId", internalType: "uint256", type: "uint256" }], + name: "getLicenseTermsURI", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "getMetadataURI", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "licenseTermsId", internalType: "uint256", type: "uint256" }], + name: "getRoyaltyPolicy", + outputs: [ + { name: "royaltyPolicy", internalType: "address", type: "address" }, + { name: "royaltyPercent", internalType: "uint32", type: "uint32" }, + { name: "mintingFee", internalType: "uint256", type: "uint256" }, + { name: "currency", internalType: "address", type: "address" }, + ], + stateMutability: "view", }, { type: "function", inputs: [ - { - name: "newNftContractBeacon", - internalType: "address", - type: "address", - }, + { name: "accessManager", internalType: "address", type: "address" }, + { name: "name", internalType: "string", type: "string" }, + { name: "metadataURI", internalType: "string", type: "string" }, ], - name: "setNftContractBeacon", + name: "initialize", outputs: [], stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "newNftContract", internalType: "address", type: "address" }], - name: "upgradeCollections", - outputs: [], - stateMutability: "nonpayable", + inputs: [], + name: "isConsumingScheduledOp", + outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], + stateMutability: "view", }, { type: "function", inputs: [ - { name: "newImplementation", internalType: "address", type: "address" }, - { name: "data", internalType: "bytes", type: "bytes" }, + { name: "parentIpId", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { name: "childIpId", internalType: "address", type: "address" }, ], - name: "upgradeToAndCall", - outputs: [], - stateMutability: "payable", - }, -] as const; - -/** - * - */ -export const spgAddress = { - 1513: "0x69415CE984A79a3Cfbe3F51024C63b6C107331e3", -} as const; - -/** - * - */ -export const spgConfig = { address: spgAddress, abi: spgAbi } as const; - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// SPGNFTBeacon -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -/** - * - */ -export const spgnftBeaconAbi = [ - { - type: "constructor", - inputs: [ - { name: "implementation_", internalType: "address", type: "address" }, - { name: "initialOwner", internalType: "address", type: "address" }, - ], - stateMutability: "nonpayable", + name: "isDerivativeApproved", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", }, { - type: "error", - inputs: [{ name: "implementation", internalType: "address", type: "address" }], - name: "BeaconInvalidImplementation", + type: "function", + inputs: [{ name: "licenseTermsId", internalType: "uint256", type: "uint256" }], + name: "isLicenseTransferable", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", }, { - type: "error", - inputs: [{ name: "owner", internalType: "address", type: "address" }], - name: "OwnableInvalidOwner", + type: "function", + inputs: [], + name: "name", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", }, { - type: "error", - inputs: [{ name: "account", internalType: "address", type: "address" }], - name: "OwnableUnauthorizedAccount", + type: "function", + inputs: [], + name: "proxiableUUID", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view", }, { - type: "event", - anonymous: false, + type: "function", inputs: [ { - name: "previousOwner", - internalType: "address", - type: "address", - indexed: true, - }, - { - name: "newOwner", - internalType: "address", - type: "address", - indexed: true, + name: "terms", + internalType: "struct PILTerms", + type: "tuple", + components: [ + { name: "transferable", internalType: "bool", type: "bool" }, + { name: "royaltyPolicy", internalType: "address", type: "address" }, + { + name: "defaultMintingFee", + internalType: "uint256", + type: "uint256", + }, + { name: "expiration", internalType: "uint256", type: "uint256" }, + { name: "commercialUse", internalType: "bool", type: "bool" }, + { name: "commercialAttribution", internalType: "bool", type: "bool" }, + { + name: "commercializerChecker", + internalType: "address", + type: "address", + }, + { + name: "commercializerCheckerData", + internalType: "bytes", + type: "bytes", + }, + { + name: "commercialRevShare", + internalType: "uint32", + type: "uint32", + }, + { + name: "commercialRevCeiling", + internalType: "uint256", + type: "uint256", + }, + { name: "derivativesAllowed", internalType: "bool", type: "bool" }, + { + name: "derivativesAttribution", + internalType: "bool", + type: "bool", + }, + { name: "derivativesApproval", internalType: "bool", type: "bool" }, + { name: "derivativesReciprocal", internalType: "bool", type: "bool" }, + { + name: "derivativeRevCeiling", + internalType: "uint256", + type: "uint256", + }, + { name: "currency", internalType: "address", type: "address" }, + { name: "uri", internalType: "string", type: "string" }, + ], }, ], - name: "OwnershipTransferred", + name: "registerLicenseTerms", + outputs: [{ name: "id", internalType: "uint256", type: "uint256" }], + stateMutability: "nonpayable", }, { - type: "event", - anonymous: false, + type: "function", inputs: [ - { - name: "implementation", - internalType: "address", - type: "address", - indexed: true, - }, + { name: "parentIpId", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { name: "childIpId", internalType: "address", type: "address" }, + { name: "approved", internalType: "bool", type: "bool" }, ], - name: "Upgraded", + name: "setApproval", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", - inputs: [], - name: "implementation", - outputs: [{ name: "", internalType: "address", type: "address" }], + inputs: [{ name: "newAuthority", internalType: "address", type: "address" }], + name: "setAuthority", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }], + name: "supportsInterface", + outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "view", }, { type: "function", - inputs: [], - name: "owner", - outputs: [{ name: "", internalType: "address", type: "address" }], + inputs: [{ name: "licenseTermsId", internalType: "uint256", type: "uint256" }], + name: "toJson", + outputs: [{ name: "", internalType: "string", type: "string" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "renounceOwnership", + name: "totalRegisteredLicenseTerms", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "newImplementation", internalType: "address", type: "address" }, + { name: "data", internalType: "bytes", type: "bytes" }, + ], + name: "upgradeToAndCall", outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "licenseTermsIds", internalType: "uint256[]", type: "uint256[]" }], + name: "verifyCompatibleLicenses", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { name: "licensee", internalType: "address", type: "address" }, + { name: "licensorIpId", internalType: "address", type: "address" }, + { name: "", internalType: "uint256", type: "uint256" }, + ], + name: "verifyMintLicenseToken", + outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "newOwner", internalType: "address", type: "address" }], - name: "transferOwnership", - outputs: [], + inputs: [ + { name: "childIpId", internalType: "address", type: "address" }, + { name: "parentIpId", internalType: "address", type: "address" }, + { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { name: "licensee", internalType: "address", type: "address" }, + ], + name: "verifyRegisterDerivative", + outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "newImplementation", internalType: "address", type: "address" }], - name: "upgradeTo", - outputs: [], + inputs: [ + { name: "childIpId", internalType: "address", type: "address" }, + { name: "parentIpIds", internalType: "address[]", type: "address[]" }, + { name: "licenseTermsIds", internalType: "uint256[]", type: "uint256[]" }, + { name: "childIpOwner", internalType: "address", type: "address" }, + ], + name: "verifyRegisterDerivativeForAllParents", + outputs: [{ name: "", internalType: "bool", type: "bool" }], stateMutability: "nonpayable", }, ] as const; @@ -7341,156 +8337,107 @@ export const spgnftBeaconAbi = [ /** * */ -export const spgnftBeaconAddress = { - 1513: "0x027D258659FBdda9033f9c008AF166239EBa67c1", +export const piLicenseTemplateAddress = { + 1513: "0xbB7ACFBE330C56aA9a3aEb84870743C3566992c3", } as const; /** * */ -export const spgnftBeaconConfig = { - address: spgnftBeaconAddress, - abi: spgnftBeaconAbi, +export const piLicenseTemplateConfig = { + address: piLicenseTemplateAddress, + abi: piLicenseTemplateAbi, } as const; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// SPGNFTImpl +// RegistrationWorkflows ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * */ -export const spgnftImplAbi = [ +export const registrationWorkflowsAbi = [ { type: "constructor", - inputs: [{ name: "spg", internalType: "address", type: "address" }], + inputs: [ + { name: "accessController", internalType: "address", type: "address" }, + { name: "coreMetadataModule", internalType: "address", type: "address" }, + { name: "ipAssetRegistry", internalType: "address", type: "address" }, + { name: "licenseRegistry", internalType: "address", type: "address" }, + { name: "licensingModule", internalType: "address", type: "address" }, + { name: "pilTemplate", internalType: "address", type: "address" }, + ], stateMutability: "nonpayable", }, - { type: "error", inputs: [], name: "AccessControlBadConfirmation" }, { type: "error", - inputs: [ - { name: "account", internalType: "address", type: "address" }, - { name: "neededRole", internalType: "bytes32", type: "bytes32" }, - ], - name: "AccessControlUnauthorizedAccount", + inputs: [{ name: "authority", internalType: "address", type: "address" }], + name: "AccessManagedInvalidAuthority", }, { type: "error", inputs: [ - { name: "sender", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, - { name: "owner", internalType: "address", type: "address" }, + { name: "caller", internalType: "address", type: "address" }, + { name: "delay", internalType: "uint32", type: "uint32" }, ], - name: "ERC721IncorrectOwner", + name: "AccessManagedRequiredDelay", }, { type: "error", - inputs: [ - { name: "operator", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, - ], - name: "ERC721InsufficientApproval", + inputs: [{ name: "caller", internalType: "address", type: "address" }], + name: "AccessManagedUnauthorized", }, { type: "error", - inputs: [{ name: "approver", internalType: "address", type: "address" }], - name: "ERC721InvalidApprover", + inputs: [{ name: "target", internalType: "address", type: "address" }], + name: "AddressEmptyCode", }, { type: "error", - inputs: [{ name: "operator", internalType: "address", type: "address" }], - name: "ERC721InvalidOperator", - }, - { - type: "error", - inputs: [{ name: "owner", internalType: "address", type: "address" }], - name: "ERC721InvalidOwner", - }, - { - type: "error", - inputs: [{ name: "receiver", internalType: "address", type: "address" }], - name: "ERC721InvalidReceiver", + 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: "sender", internalType: "address", type: "address" }], - name: "ERC721InvalidSender", + inputs: [], + name: "RegistrationWorkflows__ZeroAddressParam", }, + { type: "error", inputs: [], name: "UUPSUnauthorizedCallContext" }, { type: "error", - inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], - name: "ERC721NonexistentToken", + inputs: [{ name: "slot", internalType: "bytes32", type: "bytes32" }], + name: "UUPSUnsupportedProxiableUUID", }, - { type: "error", inputs: [], name: "InvalidInitialization" }, - { type: "error", inputs: [], name: "NotInitializing" }, - { type: "error", inputs: [], name: "SPGNFT_ZeroMaxSupply" }, - { type: "error", inputs: [], name: "SPGNFT__CallerNotSPG" }, - { type: "error", inputs: [], name: "SPGNFT__MaxSupplyReached" }, - { type: "error", inputs: [], name: "SPGNFT__ZeroAddressParam" }, + { type: "error", inputs: [], name: "Workflow__CallerNotAuthorizedToMint" }, { type: "event", anonymous: false, inputs: [ { - name: "owner", - internalType: "address", - type: "address", - indexed: true, - }, - { - name: "approved", + name: "authority", internalType: "address", type: "address", - indexed: true, - }, - { - name: "tokenId", - internalType: "uint256", - type: "uint256", - indexed: true, + indexed: false, }, ], - name: "Approval", + name: "AuthorityUpdated", }, { type: "event", anonymous: false, inputs: [ { - name: "owner", - internalType: "address", - type: "address", - indexed: true, - }, - { - name: "operator", + name: "spgNftContract", internalType: "address", type: "address", indexed: true, }, - { name: "approved", internalType: "bool", type: "bool", indexed: false }, - ], - name: "ApprovalForAll", - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "_fromTokenId", - internalType: "uint256", - type: "uint256", - indexed: false, - }, - { - name: "_toTokenId", - internalType: "uint256", - type: "uint256", - indexed: false, - }, ], - name: "BatchMetadataUpdate", + name: "CollectionCreated", }, { type: "event", @@ -7510,511 +8457,5990 @@ export const spgnftImplAbi = [ anonymous: false, inputs: [ { - name: "_tokenId", - internalType: "uint256", - type: "uint256", - indexed: false, - }, - ], - name: "MetadataUpdate", - }, - { - type: "event", - anonymous: false, - inputs: [ - { name: "role", internalType: "bytes32", type: "bytes32", indexed: true }, - { - name: "previousAdminRole", - internalType: "bytes32", - type: "bytes32", - indexed: true, - }, - { - name: "newAdminRole", - internalType: "bytes32", - type: "bytes32", - indexed: true, - }, - ], - name: "RoleAdminChanged", - }, - { - type: "event", - anonymous: false, - inputs: [ - { name: "role", internalType: "bytes32", type: "bytes32", indexed: true }, - { - name: "account", - internalType: "address", - type: "address", - indexed: true, - }, - { - name: "sender", + name: "implementation", internalType: "address", type: "address", indexed: true, }, ], - name: "RoleGranted", + name: "Upgraded", }, { - type: "event", - anonymous: false, - inputs: [ - { name: "role", internalType: "bytes32", type: "bytes32", indexed: true }, - { - name: "account", - internalType: "address", - type: "address", - indexed: true, - }, - { - name: "sender", - internalType: "address", - type: "address", - indexed: true, - }, - ], - name: "RoleRevoked", + type: "function", + inputs: [], + name: "ACCESS_CONTROLLER", + outputs: [{ name: "", internalType: "contract IAccessController", type: "address" }], + stateMutability: "view", }, { - type: "event", - anonymous: false, - inputs: [ - { name: "from", internalType: "address", type: "address", indexed: true }, - { name: "to", internalType: "address", type: "address", indexed: true }, + type: "function", + inputs: [], + name: "CORE_METADATA_MODULE", + outputs: [ { - name: "tokenId", - internalType: "uint256", - type: "uint256", - indexed: true, + name: "", + internalType: "contract ICoreMetadataModule", + type: "address", }, ], - name: "Transfer", + stateMutability: "view", }, { type: "function", inputs: [], - name: "DEFAULT_ADMIN_ROLE", - outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + name: "IP_ASSET_REGISTRY", + outputs: [{ name: "", internalType: "contract IIPAssetRegistry", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [], - name: "SPG_ADDRESS", - outputs: [{ name: "", internalType: "address", type: "address" }], + name: "LICENSE_REGISTRY", + outputs: [{ name: "", internalType: "contract ILicenseRegistry", type: "address" }], stateMutability: "view", }, { type: "function", - inputs: [ - { name: "to", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, - ], - name: "approve", - outputs: [], - stateMutability: "nonpayable", + inputs: [], + name: "LICENSING_MODULE", + outputs: [{ name: "", internalType: "contract ILicensingModule", type: "address" }], + stateMutability: "view", }, { type: "function", - inputs: [{ name: "owner", internalType: "address", type: "address" }], - name: "balanceOf", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + inputs: [], + name: "PIL_TEMPLATE", + outputs: [ + { + name: "", + internalType: "contract IPILicenseTemplate", + type: "address", + }, + ], stateMutability: "view", }, { type: "function", - inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], - name: "getApproved", - outputs: [{ name: "", internalType: "address", type: "address" }], + inputs: [], + name: "UPGRADE_INTERFACE_VERSION", + outputs: [{ name: "", internalType: "string", type: "string" }], stateMutability: "view", }, { type: "function", - inputs: [{ name: "role", internalType: "bytes32", type: "bytes32" }], - name: "getRoleAdmin", - outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + inputs: [], + name: "authority", + outputs: [{ name: "", internalType: "address", type: "address" }], stateMutability: "view", }, { type: "function", inputs: [ - { name: "role", internalType: "bytes32", type: "bytes32" }, - { name: "account", internalType: "address", type: "address" }, + { + name: "spgNftInitParams", + internalType: "struct ISPGNFT.InitParams", + type: "tuple", + components: [ + { 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" }, + { + name: "mintFeeRecipient", + internalType: "address", + type: "address", + }, + { name: "owner", internalType: "address", type: "address" }, + { name: "mintOpen", internalType: "bool", type: "bool" }, + { name: "isPublicMinting", internalType: "bool", type: "bool" }, + ], + }, ], - name: "grantRole", - outputs: [], + name: "createCollection", + outputs: [{ name: "spgNftContract", internalType: "address", type: "address" }], stateMutability: "nonpayable", }, { type: "function", - inputs: [ - { name: "role", internalType: "bytes32", type: "bytes32" }, - { name: "account", internalType: "address", type: "address" }, - ], - name: "hasRole", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "view", - }, - { - type: "function", - inputs: [ - { name: "name", internalType: "string", type: "string" }, - { name: "symbol", internalType: "string", type: "string" }, - { name: "maxSupply", internalType: "uint32", type: "uint32" }, - { name: "mintFee", internalType: "uint256", type: "uint256" }, - { name: "mintFeeToken", internalType: "address", type: "address" }, - { name: "owner", internalType: "address", type: "address" }, - ], + inputs: [{ name: "accessManager", internalType: "address", type: "address" }], name: "initialize", outputs: [], stateMutability: "nonpayable", }, { type: "function", - inputs: [ - { name: "owner", internalType: "address", type: "address" }, - { name: "operator", internalType: "address", type: "address" }, - ], - name: "isApprovedForAll", - outputs: [{ name: "", internalType: "bool", type: "bool" }], + inputs: [], + name: "isConsumingScheduledOp", + outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], stateMutability: "view", }, { type: "function", inputs: [ - { name: "to", internalType: "address", type: "address" }, - { name: "nftMetadataURI", internalType: "string", type: "string" }, + { name: "spgNftContract", internalType: "address", type: "address" }, + { name: "recipient", internalType: "address", type: "address" }, + { + name: "ipMetadata", + internalType: "struct WorkflowStructs.IPMetadata", + type: "tuple", + components: [ + { name: "ipMetadataURI", internalType: "string", type: "string" }, + { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, + { name: "nftMetadataURI", internalType: "string", type: "string" }, + { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, + ], + }, ], - name: "mint", - outputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], - stateMutability: "nonpayable", - }, - { - type: "function", - inputs: [ - { name: "to", internalType: "address", type: "address" }, - { name: "payer", internalType: "address", type: "address" }, - { name: "nftMetadataURI", internalType: "string", type: "string" }, + name: "mintAndRegisterIp", + outputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, ], - name: "mintBySPG", - outputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], stateMutability: "nonpayable", }, { type: "function", - inputs: [], - name: "mintFee", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - stateMutability: "view", + inputs: [{ name: "data", internalType: "bytes[]", type: "bytes[]" }], + name: "multicall", + outputs: [{ name: "results", internalType: "bytes[]", type: "bytes[]" }], + stateMutability: "nonpayable", }, { type: "function", inputs: [], - name: "mintFeeToken", - outputs: [{ name: "", internalType: "address", type: "address" }], + name: "proxiableUUID", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], stateMutability: "view", }, { type: "function", - inputs: [], - name: "name", - outputs: [{ name: "", internalType: "string", type: "string" }], - stateMutability: "view", + inputs: [ + { name: "nftContract", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + { + name: "ipMetadata", + internalType: "struct WorkflowStructs.IPMetadata", + type: "tuple", + components: [ + { name: "ipMetadataURI", internalType: "string", type: "string" }, + { name: "ipMetadataHash", internalType: "bytes32", type: "bytes32" }, + { name: "nftMetadataURI", internalType: "string", type: "string" }, + { name: "nftMetadataHash", internalType: "bytes32", type: "bytes32" }, + ], + }, + { + name: "sigMetadata", + internalType: "struct WorkflowStructs.SignatureData", + type: "tuple", + components: [ + { name: "signer", internalType: "address", type: "address" }, + { name: "deadline", internalType: "uint256", type: "uint256" }, + { name: "signature", internalType: "bytes", type: "bytes" }, + ], + }, + ], + name: "registerIp", + outputs: [{ name: "ipId", internalType: "address", type: "address" }], + stateMutability: "nonpayable", }, { type: "function", - inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], - name: "ownerOf", - outputs: [{ name: "", internalType: "address", type: "address" }], - stateMutability: "view", + inputs: [{ name: "newAuthority", internalType: "address", type: "address" }], + name: "setAuthority", + outputs: [], + stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "role", internalType: "bytes32", type: "bytes32" }, - { name: "callerConfirmation", internalType: "address", type: "address" }, + { + name: "newNftContractBeacon", + internalType: "address", + type: "address", + }, ], - name: "renounceRole", + name: "setNftContractBeacon", outputs: [], stateMutability: "nonpayable", }, { type: "function", - inputs: [ - { name: "role", internalType: "bytes32", type: "bytes32" }, - { name: "account", internalType: "address", type: "address" }, - ], - name: "revokeRole", + inputs: [{ name: "newNftContract", internalType: "address", type: "address" }], + name: "upgradeCollections", outputs: [], stateMutability: "nonpayable", }, { type: "function", inputs: [ - { name: "from", internalType: "address", type: "address" }, - { name: "to", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, + { name: "newImplementation", internalType: "address", type: "address" }, + { name: "data", internalType: "bytes", type: "bytes" }, ], - name: "safeTransferFrom", + name: "upgradeToAndCall", outputs: [], - stateMutability: "nonpayable", + stateMutability: "payable", }, +] as const; + +/** + * + */ +export const registrationWorkflowsAddress = { + 1513: "0xF403fcCAAE6C503D0CC1D25904A0B2cCd5B96C6F", +} as const; + +/** + * + */ +export const registrationWorkflowsConfig = { + address: registrationWorkflowsAddress, + abi: registrationWorkflowsAbi, +} as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// RoyaltyModule +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * + */ +export const royaltyModuleAbi = [ { - type: "function", + type: "constructor", inputs: [ - { name: "from", internalType: "address", type: "address" }, - { name: "to", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, - { name: "data", internalType: "bytes", type: "bytes" }, + { name: "licensingModule", internalType: "address", type: "address" }, + { name: "disputeModule", internalType: "address", type: "address" }, + { name: "licenseRegistry", internalType: "address", type: "address" }, + { name: "ipAssetRegistry", internalType: "address", type: "address" }, + { name: "ipGraph", internalType: "address", type: "address" }, ], - name: "safeTransferFrom", - outputs: [], stateMutability: "nonpayable", }, { - type: "function", + type: "error", + inputs: [{ name: "authority", internalType: "address", type: "address" }], + name: "AccessManagedInvalidAuthority", + }, + { + type: "error", inputs: [ - { name: "operator", internalType: "address", type: "address" }, - { name: "approved", internalType: "bool", type: "bool" }, + { name: "caller", internalType: "address", type: "address" }, + { name: "delay", internalType: "uint32", type: "uint32" }, ], - name: "setApprovalForAll", - outputs: [], - stateMutability: "nonpayable", + name: "AccessManagedRequiredDelay", }, { - type: "function", - inputs: [{ name: "fee", internalType: "uint256", type: "uint256" }], - name: "setMintFee", - outputs: [], - stateMutability: "nonpayable", + type: "error", + inputs: [{ name: "caller", internalType: "address", type: "address" }], + name: "AccessManagedUnauthorized", }, { - type: "function", - inputs: [{ name: "token", internalType: "address", type: "address" }], - name: "setMintFeeToken", - outputs: [], - stateMutability: "nonpayable", + type: "error", + inputs: [{ name: "target", internalType: "address", type: "address" }], + name: "AddressEmptyCode", }, { - type: "function", - inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }], - name: "supportsInterface", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - stateMutability: "view", + type: "error", + inputs: [{ name: "account", internalType: "address", type: "address" }], + name: "AddressInsufficientBalance", }, { - type: "function", + type: "error", + inputs: [{ name: "implementation", internalType: "address", type: "address" }], + name: "ERC1967InvalidImplementation", + }, + { type: "error", inputs: [], name: "ERC1967NonPayable" }, + { type: "error", inputs: [], name: "EnforcedPause" }, + { type: "error", inputs: [], name: "ExpectedPause" }, + { type: "error", inputs: [], name: "FailedInnerCall" }, + { type: "error", inputs: [], name: "InvalidInitialization" }, + { type: "error", inputs: [], name: "NotInitializing" }, + { type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" }, + { + type: "error", inputs: [], - name: "symbol", - outputs: [{ name: "", internalType: "string", type: "string" }], - stateMutability: "view", + name: "RoyaltyModule__AboveAccumulatedRoyaltyPoliciesLimit", }, + { type: "error", inputs: [], name: "RoyaltyModule__AboveAncestorsLimit" }, + { type: "error", inputs: [], name: "RoyaltyModule__AboveMaxPercent" }, + { type: "error", inputs: [], name: "RoyaltyModule__AboveParentLimit" }, + { type: "error", inputs: [], name: "RoyaltyModule__IpIsTagged" }, { - type: "function", - inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], - name: "tokenURI", - outputs: [{ name: "", internalType: "string", type: "string" }], - stateMutability: "view", + type: "error", + inputs: [], + name: "RoyaltyModule__LastPositionNotAbleToMintLicense", }, + { type: "error", inputs: [], name: "RoyaltyModule__NoParentsOnLinking" }, + { type: "error", inputs: [], name: "RoyaltyModule__NotAllowedCaller" }, { - type: "function", + type: "error", inputs: [], - name: "totalSupply", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - stateMutability: "view", + name: "RoyaltyModule__NotWhitelistedOrRegisteredRoyaltyPolicy", }, { - type: "function", + type: "error", + inputs: [], + name: "RoyaltyModule__NotWhitelistedRoyaltyToken", + }, + { + type: "error", + inputs: [], + name: "RoyaltyModule__PolicyAlreadyWhitelistedOrRegistered", + }, + { type: "error", inputs: [], name: "RoyaltyModule__UnlinkableToParents" }, + { type: "error", inputs: [], name: "RoyaltyModule__ZeroAccessManager" }, + { + type: "error", + inputs: [], + name: "RoyaltyModule__ZeroAccumulatedRoyaltyPoliciesLimit", + }, + { type: "error", inputs: [], name: "RoyaltyModule__ZeroAmount" }, + { type: "error", inputs: [], name: "RoyaltyModule__ZeroDisputeModule" }, + { type: "error", inputs: [], name: "RoyaltyModule__ZeroIpAssetRegistry" }, + { type: "error", inputs: [], name: "RoyaltyModule__ZeroLicenseRegistry" }, + { type: "error", inputs: [], name: "RoyaltyModule__ZeroLicensingModule" }, + { type: "error", inputs: [], name: "RoyaltyModule__ZeroMaxAncestors" }, + { type: "error", inputs: [], name: "RoyaltyModule__ZeroMaxParents" }, + { type: "error", inputs: [], name: "RoyaltyModule__ZeroParentIpId" }, + { type: "error", inputs: [], name: "RoyaltyModule__ZeroReceiverVault" }, + { type: "error", inputs: [], name: "RoyaltyModule__ZeroRoyaltyPolicy" }, + { type: "error", inputs: [], name: "RoyaltyModule__ZeroRoyaltyToken" }, + { type: "error", inputs: [], name: "RoyaltyModule__ZeroTreasury" }, + { + 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: "error", + inputs: [], + name: "VaultController__ZeroIpRoyaltyVaultBeacon", + }, + { + type: "event", + anonymous: false, inputs: [ - { name: "from", internalType: "address", type: "address" }, - { name: "to", internalType: "address", type: "address" }, - { name: "tokenId", internalType: "uint256", type: "uint256" }, + { + name: "authority", + internalType: "address", + type: "address", + indexed: false, + }, ], - name: "transferFrom", - outputs: [], - stateMutability: "nonpayable", + name: "AuthorityUpdated", }, { - type: "function", + type: "event", + anonymous: false, inputs: [ - { name: "token", internalType: "address", type: "address" }, - { name: "recipient", internalType: "address", type: "address" }, + { + name: "externalRoyaltyPolicy", + internalType: "address", + type: "address", + indexed: false, + }, ], - name: "withdrawToken", - outputs: [], - stateMutability: "nonpayable", + name: "ExternalRoyaltyPolicyRegistered", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "version", + internalType: "uint64", + type: "uint64", + indexed: false, + }, + ], + name: "Initialized", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "maxParents", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + { + name: "maxAncestors", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + { + name: "accumulatedRoyaltyPoliciesLimit", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + ], + name: "IpGraphLimitsUpdated", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "ipId", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "ipRoyaltyVault", + internalType: "address", + type: "address", + indexed: false, + }, + ], + name: "IpRoyaltyVaultDeployed", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "receiverIpId", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "payerAddress", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "token", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "amount", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + { + name: "amountAfterFee", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + ], + name: "LicenseMintingFeePaid", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "ipId", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "royaltyPolicy", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "licensePercent", + internalType: "uint32", + type: "uint32", + indexed: false, + }, + { + name: "externalData", + internalType: "bytes", + type: "bytes", + indexed: false, + }, + ], + name: "LicensedWithRoyalty", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "ipId", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "parentIpIds", + internalType: "address[]", + type: "address[]", + indexed: false, + }, + { + name: "licenseRoyaltyPolicies", + internalType: "address[]", + type: "address[]", + indexed: false, + }, + { + name: "licensesPercent", + internalType: "uint32[]", + type: "uint32[]", + indexed: false, + }, + { + name: "externalData", + internalType: "bytes", + type: "bytes", + indexed: false, + }, + ], + name: "LinkedToParents", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "account", + internalType: "address", + type: "address", + indexed: false, + }, + ], + name: "Paused", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "royaltyFeePercent", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + ], + name: "RoyaltyFeePercentSet", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "receiverIpId", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "payerIpId", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "sender", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "token", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "amount", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + { + name: "amountAfterFee", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + ], + name: "RoyaltyPaid", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "royaltyPolicy", + internalType: "address", + type: "address", + indexed: false, + }, + { name: "allowed", internalType: "bool", type: "bool", indexed: false }, + ], + name: "RoyaltyPolicyWhitelistUpdated", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "token", + internalType: "address", + type: "address", + indexed: false, + }, + { name: "allowed", internalType: "bool", type: "bool", indexed: false }, + ], + name: "RoyaltyTokenWhitelistUpdated", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "treasury", + internalType: "address", + type: "address", + indexed: false, + }, + ], + name: "TreasurySet", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "account", + internalType: "address", + type: "address", + indexed: false, + }, + ], + name: "Unpaused", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "implementation", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "Upgraded", + }, + { + type: "function", + inputs: [], + name: "DISPUTE_MODULE", + outputs: [{ name: "", internalType: "contract IDisputeModule", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "IP_ASSET_REGISTRY", + outputs: [ + { + name: "", + internalType: "contract IGroupIPAssetRegistry", + type: "address", + }, + ], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "IP_GRAPH", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "LICENSE_REGISTRY", + outputs: [{ name: "", internalType: "contract ILicenseRegistry", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "LICENSING_MODULE", + outputs: [{ name: "", internalType: "contract ILicensingModule", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "MAX_PERCENT", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "UPGRADE_INTERFACE_VERSION", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "accessManager", internalType: "address", type: "address" }], + name: "__ProtocolPausable_init", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "ipId", internalType: "address", type: "address" }], + name: "accumulatedRoyaltyPolicies", + outputs: [{ name: "", internalType: "address[]", type: "address[]" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "authority", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "ipId", internalType: "address", type: "address" }], + name: "getAncestorsCount", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "ipId", internalType: "address", type: "address" }], + name: "globalRoyaltyStack", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "ancestorIpId", internalType: "address", type: "address" }, + ], + name: "hasAncestorIp", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "accessManager", internalType: "address", type: "address" }, + { name: "parentLimit", internalType: "uint256", type: "uint256" }, + { name: "ancestorLimit", internalType: "uint256", type: "uint256" }, + { + name: "accumulatedRoyaltyPoliciesLimit", + internalType: "uint256", + type: "uint256", + }, + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "ipRoyaltyVaultBeacon", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "ipId", internalType: "address", type: "address" }], + name: "ipRoyaltyVaults", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "isConsumingScheduledOp", + outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "ipRoyaltyVault", internalType: "address", type: "address" }], + name: "isIpRoyaltyVault", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { + name: "externalRoyaltyPolicy", + internalType: "address", + type: "address", + }, + ], + name: "isRegisteredExternalRoyaltyPolicy", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "royaltyPolicy", internalType: "address", type: "address" }], + name: "isWhitelistedRoyaltyPolicy", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "token", internalType: "address", type: "address" }], + name: "isWhitelistedRoyaltyToken", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "maxAccumulatedRoyaltyPolicies", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "maxAncestors", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "maxParents", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "maxPercent", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "pure", + }, + { + type: "function", + inputs: [], + name: "name", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "royaltyPolicy", internalType: "address", type: "address" }, + { name: "licensePercent", internalType: "uint32", type: "uint32" }, + { name: "externalData", internalType: "bytes", type: "bytes" }, + ], + name: "onLicenseMinting", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "parentIpIds", internalType: "address[]", type: "address[]" }, + { + name: "licenseRoyaltyPolicies", + internalType: "address[]", + type: "address[]", + }, + { name: "licensesPercent", internalType: "uint32[]", type: "uint32[]" }, + { name: "externalData", internalType: "bytes", type: "bytes" }, + ], + name: "onLinkToParents", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "pause", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "paused", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "receiverIpId", internalType: "address", type: "address" }, + { name: "payerAddress", internalType: "address", type: "address" }, + { name: "token", internalType: "address", type: "address" }, + { name: "amount", internalType: "uint256", type: "uint256" }, + ], + name: "payLicenseMintingFee", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "receiverIpId", internalType: "address", type: "address" }, + { name: "payerIpId", internalType: "address", type: "address" }, + { name: "token", internalType: "address", type: "address" }, + { name: "amount", internalType: "uint256", type: "uint256" }, + ], + name: "payRoyaltyOnBehalf", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "proxiableUUID", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { + name: "externalRoyaltyPolicy", + internalType: "address", + type: "address", + }, + ], + name: "registerExternalRoyaltyPolicy", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "royaltyFeePercent", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "newAuthority", internalType: "address", type: "address" }], + name: "setAuthority", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "parentLimit", internalType: "uint256", type: "uint256" }, + { name: "ancestorLimit", internalType: "uint256", type: "uint256" }, + { + name: "accumulatedRoyaltyPoliciesLimit", + internalType: "uint256", + type: "uint256", + }, + ], + name: "setIpGraphLimits", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "beacon", internalType: "address", type: "address" }], + name: "setIpRoyaltyVaultBeacon", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "royaltyFeePercent", internalType: "uint32", type: "uint32" }], + name: "setRoyaltyFeePercent", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "timestampInterval", internalType: "uint256", type: "uint256" }], + name: "setSnapshotInterval", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "treasury", internalType: "address", type: "address" }], + name: "setTreasury", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "snapshotInterval", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }], + name: "supportsInterface", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "token", internalType: "address", type: "address" }, + ], + name: "totalRevenueTokensReceived", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "treasury", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "unpause", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "newImplementation", internalType: "address", type: "address" }, + { name: "data", internalType: "bytes", type: "bytes" }, + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "newVault", internalType: "address", type: "address" }], + name: "upgradeVaults", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "royaltyPolicy", internalType: "address", type: "address" }, + { name: "allowed", internalType: "bool", type: "bool" }, + ], + name: "whitelistRoyaltyPolicy", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "token", internalType: "address", type: "address" }, + { name: "allowed", internalType: "bool", type: "bool" }, + ], + name: "whitelistRoyaltyToken", + outputs: [], + stateMutability: "nonpayable", + }, +] as const; + +/** + * + */ +export const royaltyModuleAddress = { + 1513: "0xaCb5764E609aa3a5ED36bA74ba59679246Cb0963", +} as const; + +/** + * + */ +export const royaltyModuleConfig = { + address: royaltyModuleAddress, + abi: royaltyModuleAbi, +} as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// RoyaltyPolicyLAP +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * + */ +export const royaltyPolicyLapAbi = [ + { + type: "constructor", + inputs: [ + { name: "royaltyModule", internalType: "address", type: "address" }, + { name: "ipGraphAcl", internalType: "address", type: "address" }, + { name: "ipGraph", internalType: "address", type: "address" }, + ], + 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: "implementation", internalType: "address", type: "address" }], + name: "ERC1967InvalidImplementation", + }, + { type: "error", inputs: [], name: "ERC1967NonPayable" }, + { type: "error", inputs: [], name: "EnforcedPause" }, + { type: "error", inputs: [], name: "ExpectedPause" }, + { type: "error", inputs: [], name: "FailedInnerCall" }, + { type: "error", inputs: [], name: "InvalidInitialization" }, + { type: "error", inputs: [], name: "NotInitializing" }, + { type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" }, + { type: "error", inputs: [], name: "RoyaltyPolicyLAP__AboveMaxPercent" }, + { + type: "error", + inputs: [], + name: "RoyaltyPolicyLAP__ExceedsClaimableRoyalty", + }, + { type: "error", inputs: [], name: "RoyaltyPolicyLAP__NotRoyaltyModule" }, + { type: "error", inputs: [], name: "RoyaltyPolicyLAP__ZeroAccessManager" }, + { type: "error", inputs: [], name: "RoyaltyPolicyLAP__ZeroAmount" }, + { type: "error", inputs: [], name: "RoyaltyPolicyLAP__ZeroClaimableRoyalty" }, + { type: "error", inputs: [], name: "RoyaltyPolicyLAP__ZeroIPGraphACL" }, + { type: "error", inputs: [], name: "RoyaltyPolicyLAP__ZeroRoyaltyModule" }, + { + 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: "account", + internalType: "address", + type: "address", + indexed: false, + }, + ], + name: "Paused", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "ipId", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "ancestorIpId", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "token", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "amount", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + ], + name: "RevenueTransferredToVault", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "account", + internalType: "address", + type: "address", + indexed: false, + }, + ], + name: "Unpaused", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "implementation", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "Upgraded", + }, + { + type: "function", + inputs: [], + name: "IP_GRAPH", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "IP_GRAPH_ACL", + outputs: [{ name: "", internalType: "contract IPGraphACL", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "ROYALTY_MODULE", + outputs: [{ name: "", internalType: "contract IRoyaltyModule", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "UPGRADE_INTERFACE_VERSION", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "accessManager", internalType: "address", type: "address" }], + name: "__ProtocolPausable_init", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "authority", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "ancestorIpId", internalType: "address", type: "address" }, + ], + name: "getPolicyRoyalty", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "ipId", internalType: "address", type: "address" }], + name: "getPolicyRoyaltyStack", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "licensePercent", internalType: "uint32", type: "uint32" }, + ], + name: "getPolicyRtsRequiredToLink", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "ancestorIpId", internalType: "address", type: "address" }, + { name: "token", internalType: "address", type: "address" }, + ], + name: "getTransferredTokens", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "accessManager", 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: "ipId", internalType: "address", type: "address" }, + { name: "licensePercent", internalType: "uint32", type: "uint32" }, + { name: "", internalType: "bytes", type: "bytes" }, + ], + name: "onLicenseMinting", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "parentIpIds", internalType: "address[]", type: "address[]" }, + { + name: "licenseRoyaltyPolicies", + internalType: "address[]", + type: "address[]", + }, + { name: "licensesPercent", internalType: "uint32[]", type: "uint32[]" }, + { name: "", internalType: "bytes", type: "bytes" }, + ], + name: "onLinkToParents", + outputs: [{ name: "newRoyaltyStackLAP", internalType: "uint32", type: "uint32" }], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "pause", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "paused", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + 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: "ipId", internalType: "address", type: "address" }, + { name: "ancestorIpId", internalType: "address", type: "address" }, + { name: "token", internalType: "address", type: "address" }, + { name: "amount", internalType: "uint256", type: "uint256" }, + ], + name: "transferToVault", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "unpause", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "newImplementation", internalType: "address", type: "address" }, + { name: "data", internalType: "bytes", type: "bytes" }, + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + }, +] as const; + +/** + * + */ +export const royaltyPolicyLapAddress = { + 1513: "0x793Df8d32c12B0bE9985FFF6afB8893d347B6686", +} as const; + +/** + * + */ +export const royaltyPolicyLapConfig = { + address: royaltyPolicyLapAddress, + abi: royaltyPolicyLapAbi, +} as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// RoyaltyPolicyLRP +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * + */ +export const royaltyPolicyLrpAbi = [ + { + type: "constructor", + inputs: [ + { name: "royaltyModule", internalType: "address", type: "address" }, + { name: "ipGraphAcl", internalType: "address", type: "address" }, + { name: "ipGraph", internalType: "address", type: "address" }, + ], + 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: "implementation", internalType: "address", type: "address" }], + name: "ERC1967InvalidImplementation", + }, + { type: "error", inputs: [], name: "ERC1967NonPayable" }, + { type: "error", inputs: [], name: "EnforcedPause" }, + { type: "error", inputs: [], name: "ExpectedPause" }, + { type: "error", inputs: [], name: "FailedInnerCall" }, + { type: "error", inputs: [], name: "InvalidInitialization" }, + { type: "error", inputs: [], name: "NotInitializing" }, + { type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" }, + { type: "error", inputs: [], name: "RoyaltyPolicyLRP__AboveMaxPercent" }, + { + type: "error", + inputs: [], + name: "RoyaltyPolicyLRP__ExceedsClaimableRoyalty", + }, + { type: "error", inputs: [], name: "RoyaltyPolicyLRP__NotRoyaltyModule" }, + { type: "error", inputs: [], name: "RoyaltyPolicyLRP__ZeroAccessManager" }, + { type: "error", inputs: [], name: "RoyaltyPolicyLRP__ZeroAmount" }, + { type: "error", inputs: [], name: "RoyaltyPolicyLRP__ZeroClaimableRoyalty" }, + { type: "error", inputs: [], name: "RoyaltyPolicyLRP__ZeroIPGraphACL" }, + { type: "error", inputs: [], name: "RoyaltyPolicyLRP__ZeroRoyaltyModule" }, + { + 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: "account", + internalType: "address", + type: "address", + indexed: false, + }, + ], + name: "Paused", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "ipId", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "ancestorIpId", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "token", + internalType: "address", + type: "address", + indexed: false, + }, + { + name: "amount", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + ], + name: "RevenueTransferredToVault", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "account", + internalType: "address", + type: "address", + indexed: false, + }, + ], + name: "Unpaused", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "implementation", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "Upgraded", + }, + { + type: "function", + inputs: [], + name: "IP_GRAPH", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "IP_GRAPH_ACL", + outputs: [{ name: "", internalType: "contract IPGraphACL", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "ROYALTY_MODULE", + outputs: [{ name: "", internalType: "contract IRoyaltyModule", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "UPGRADE_INTERFACE_VERSION", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "accessManager", internalType: "address", type: "address" }], + name: "__ProtocolPausable_init", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "authority", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "ancestorIpId", internalType: "address", type: "address" }, + ], + name: "getPolicyRoyalty", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "ipId", internalType: "address", type: "address" }], + name: "getPolicyRoyaltyStack", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "licensePercent", internalType: "uint32", type: "uint32" }, + ], + name: "getPolicyRtsRequiredToLink", + outputs: [{ name: "", internalType: "uint32", type: "uint32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "ancestorIpId", internalType: "address", type: "address" }, + { name: "token", internalType: "address", type: "address" }, + ], + name: "getTransferredTokens", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "accessManager", 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: "ipId", internalType: "address", type: "address" }, + { name: "licensePercent", internalType: "uint32", type: "uint32" }, + { name: "", internalType: "bytes", type: "bytes" }, + ], + name: "onLicenseMinting", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "parentIpIds", internalType: "address[]", type: "address[]" }, + { + name: "licenseRoyaltyPolicies", + internalType: "address[]", + type: "address[]", + }, + { name: "licensesPercent", internalType: "uint32[]", type: "uint32[]" }, + { name: "", internalType: "bytes", type: "bytes" }, + ], + name: "onLinkToParents", + outputs: [{ name: "newRoyaltyStackLRP", internalType: "uint32", type: "uint32" }], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "pause", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "paused", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + 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: "ipId", internalType: "address", type: "address" }, + { name: "ancestorIpId", internalType: "address", type: "address" }, + { name: "token", internalType: "address", type: "address" }, + { name: "amount", internalType: "uint256", type: "uint256" }, + ], + name: "transferToVault", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "unpause", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "newImplementation", internalType: "address", type: "address" }, + { name: "data", internalType: "bytes", type: "bytes" }, + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + }, +] as const; + +/** + * + */ +export const royaltyPolicyLrpAddress = { + 1513: "0x1eF035c7054bd45e25B2a29A06a37b1350F50596", +} as const; + +/** + * + */ +export const royaltyPolicyLrpConfig = { + address: royaltyPolicyLrpAddress, + abi: royaltyPolicyLrpAbi, +} as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// RoyaltyWorkflows +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * + */ +export const royaltyWorkflowsAbi = [ + { + type: "constructor", + inputs: [{ name: "royaltyModule", internalType: "address", type: "address" }], + 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: "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: "RoyaltyWorkflows__ZeroAddressParam" }, + { 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: "ROYALTY_MODULE", + outputs: [{ name: "", internalType: "contract IRoyaltyModule", 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: "initialize", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "isConsumingScheduledOp", + outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "data", internalType: "bytes[]", type: "bytes[]" }], + name: "multicall", + outputs: [{ name: "results", internalType: "bytes[]", type: "bytes[]" }], + 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: "ipId", internalType: "address", type: "address" }, + { name: "claimer", internalType: "address", type: "address" }, + { + name: "unclaimedSnapshotIds", + internalType: "uint256[]", + type: "uint256[]", + }, + { name: "currencyTokens", internalType: "address[]", type: "address[]" }, + ], + name: "snapshotAndClaimBySnapshotBatch", + outputs: [ + { name: "snapshotId", internalType: "uint256", type: "uint256" }, + { name: "amountsClaimed", internalType: "uint256[]", type: "uint256[]" }, + ], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "ipId", internalType: "address", type: "address" }, + { name: "claimer", internalType: "address", type: "address" }, + { name: "currencyTokens", internalType: "address[]", type: "address[]" }, + ], + name: "snapshotAndClaimByTokenBatch", + outputs: [ + { name: "snapshotId", internalType: "uint256", type: "uint256" }, + { name: "amountsClaimed", internalType: "uint256[]", type: "uint256[]" }, + ], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "ancestorIpId", internalType: "address", type: "address" }, + { name: "claimer", internalType: "address", type: "address" }, + { + name: "unclaimedSnapshotIds", + internalType: "uint256[]", + type: "uint256[]", + }, + { + name: "royaltyClaimDetails", + internalType: "struct IRoyaltyWorkflows.RoyaltyClaimDetails[]", + type: "tuple[]", + components: [ + { name: "childIpId", internalType: "address", type: "address" }, + { name: "royaltyPolicy", internalType: "address", type: "address" }, + { name: "currencyToken", internalType: "address", type: "address" }, + { name: "amount", internalType: "uint256", type: "uint256" }, + ], + }, + ], + name: "transferToVaultAndSnapshotAndClaimBySnapshotBatch", + outputs: [ + { name: "snapshotId", internalType: "uint256", type: "uint256" }, + { name: "amountsClaimed", internalType: "uint256[]", type: "uint256[]" }, + ], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "ancestorIpId", internalType: "address", type: "address" }, + { name: "claimer", internalType: "address", type: "address" }, + { + name: "royaltyClaimDetails", + internalType: "struct IRoyaltyWorkflows.RoyaltyClaimDetails[]", + type: "tuple[]", + components: [ + { name: "childIpId", internalType: "address", type: "address" }, + { name: "royaltyPolicy", internalType: "address", type: "address" }, + { name: "currencyToken", internalType: "address", type: "address" }, + { name: "amount", internalType: "uint256", type: "uint256" }, + ], + }, + ], + name: "transferToVaultAndSnapshotAndClaimByTokenBatch", + outputs: [ + { name: "snapshotId", internalType: "uint256", type: "uint256" }, + { name: "amountsClaimed", internalType: "uint256[]", type: "uint256[]" }, + ], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "newImplementation", internalType: "address", type: "address" }, + { name: "data", internalType: "bytes", type: "bytes" }, + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + }, +] as const; + +/** + * + */ +export const royaltyWorkflowsAddress = { + 1513: "0xc757921ee0f7c8E935d44BFBDc2602786e0eda6C", +} as const; + +/** + * + */ +export const royaltyWorkflowsConfig = { + address: royaltyWorkflowsAddress, + abi: royaltyWorkflowsAbi, +} as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// SPGNFTBeacon +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * + */ +export const spgnftBeaconAbi = [ + { + type: "constructor", + inputs: [ + { name: "implementation_", internalType: "address", type: "address" }, + { name: "initialOwner", internalType: "address", type: "address" }, + ], + stateMutability: "nonpayable", + }, + { + type: "error", + inputs: [{ name: "implementation", internalType: "address", type: "address" }], + name: "BeaconInvalidImplementation", + }, + { + type: "error", + inputs: [{ name: "owner", internalType: "address", type: "address" }], + name: "OwnableInvalidOwner", + }, + { + type: "error", + inputs: [{ name: "account", internalType: "address", type: "address" }], + name: "OwnableUnauthorizedAccount", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "previousOwner", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "newOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipTransferred", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "implementation", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "Upgraded", + }, + { + type: "function", + inputs: [], + name: "implementation", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "owner", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "newOwner", internalType: "address", type: "address" }], + name: "transferOwnership", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "newImplementation", internalType: "address", type: "address" }], + name: "upgradeTo", + outputs: [], + stateMutability: "nonpayable", + }, +] as const; + +/** + * + */ +export const spgnftBeaconAddress = { + 1513: "0x02324ca8f369abB445F50c4cE79e956e49AC75d8", +} as const; + +/** + * + */ +export const spgnftBeaconConfig = { + address: spgnftBeaconAddress, + abi: spgnftBeaconAbi, +} as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// SPGNFTImpl +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * + */ +export const spgnftImplAbi = [ + { + type: "constructor", + inputs: [ + { name: "derivativeWorkflows", internalType: "address", type: "address" }, + { name: "groupingWorkflows", internalType: "address", type: "address" }, + { + name: "licenseAttachmentWorkflows", + internalType: "address", + type: "address", + }, + { + name: "registrationWorkflows", + internalType: "address", + type: "address", + }, + ], + stateMutability: "nonpayable", + }, + { type: "error", inputs: [], name: "AccessControlBadConfirmation" }, + { + type: "error", + inputs: [ + { name: "account", internalType: "address", type: "address" }, + { name: "neededRole", internalType: "bytes32", type: "bytes32" }, + ], + name: "AccessControlUnauthorizedAccount", + }, + { + type: "error", + inputs: [ + { name: "sender", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + { name: "owner", internalType: "address", type: "address" }, + ], + name: "ERC721IncorrectOwner", + }, + { + type: "error", + inputs: [ + { name: "operator", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + ], + name: "ERC721InsufficientApproval", + }, + { + type: "error", + inputs: [{ name: "approver", internalType: "address", type: "address" }], + name: "ERC721InvalidApprover", + }, + { + type: "error", + inputs: [{ name: "operator", internalType: "address", type: "address" }], + name: "ERC721InvalidOperator", + }, + { + type: "error", + inputs: [{ name: "owner", internalType: "address", type: "address" }], + name: "ERC721InvalidOwner", + }, + { + type: "error", + inputs: [{ name: "receiver", internalType: "address", type: "address" }], + name: "ERC721InvalidReceiver", + }, + { + type: "error", + inputs: [{ name: "sender", internalType: "address", type: "address" }], + name: "ERC721InvalidSender", + }, + { + type: "error", + inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], + name: "ERC721NonexistentToken", + }, + { type: "error", inputs: [], name: "InvalidInitialization" }, + { type: "error", inputs: [], name: "NotInitializing" }, + { type: "error", inputs: [], name: "SPGNFT__CallerNotFeeRecipient" }, + { type: "error", inputs: [], name: "SPGNFT__CallerNotPeripheryContract" }, + { type: "error", inputs: [], name: "SPGNFT__MaxSupplyReached" }, + { type: "error", inputs: [], name: "SPGNFT__MintingClosed" }, + { type: "error", inputs: [], name: "SPGNFT__MintingDenied" }, + { type: "error", inputs: [], name: "SPGNFT__ZeroAddressParam" }, + { type: "error", inputs: [], name: "SPGNFT__ZeroMaxSupply" }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "owner", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "approved", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "tokenId", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + ], + name: "Approval", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "owner", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "operator", + internalType: "address", + type: "address", + indexed: true, + }, + { name: "approved", internalType: "bool", type: "bool", indexed: false }, + ], + name: "ApprovalForAll", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "_fromTokenId", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + { + name: "_toTokenId", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + ], + name: "BatchMetadataUpdate", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "version", + internalType: "uint64", + type: "uint64", + indexed: false, + }, + ], + name: "Initialized", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "_tokenId", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + ], + name: "MetadataUpdate", + }, + { + type: "event", + anonymous: false, + inputs: [ + { name: "role", internalType: "bytes32", type: "bytes32", indexed: true }, + { + name: "previousAdminRole", + internalType: "bytes32", + type: "bytes32", + indexed: true, + }, + { + name: "newAdminRole", + internalType: "bytes32", + type: "bytes32", + indexed: true, + }, + ], + name: "RoleAdminChanged", + }, + { + type: "event", + anonymous: false, + inputs: [ + { name: "role", internalType: "bytes32", type: "bytes32", indexed: true }, + { + name: "account", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "sender", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "RoleGranted", + }, + { + type: "event", + anonymous: false, + inputs: [ + { name: "role", internalType: "bytes32", type: "bytes32", indexed: true }, + { + name: "account", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "sender", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "RoleRevoked", + }, + { + type: "event", + anonymous: false, + inputs: [ + { name: "from", internalType: "address", type: "address", indexed: true }, + { name: "to", internalType: "address", type: "address", indexed: true }, + { + name: "tokenId", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + ], + name: "Transfer", + }, + { + type: "function", + inputs: [], + name: "DEFAULT_ADMIN_ROLE", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "DERIVATIVE_WORKFLOWS_ADDRESS", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "GROUPING_WORKFLOWS_ADDRESS", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "LICENSE_ATTACHMENT_WORKFLOWS_ADDRESS", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "REGISTRATION_WORKFLOWS_ADDRESS", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "to", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + ], + name: "approve", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "owner", internalType: "address", type: "address" }], + name: "balanceOf", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "baseURI", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], + name: "getApproved", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "role", internalType: "bytes32", type: "bytes32" }], + name: "getRoleAdmin", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "role", internalType: "bytes32", type: "bytes32" }, + { name: "account", internalType: "address", type: "address" }, + ], + name: "grantRole", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "role", internalType: "bytes32", type: "bytes32" }, + { name: "account", internalType: "address", type: "address" }, + ], + name: "hasRole", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { + name: "initParams", + internalType: "struct ISPGNFT.InitParams", + type: "tuple", + components: [ + { name: "name", internalType: "string", type: "string" }, + { name: "symbol", internalType: "string", type: "string" }, + { name: "baseURI", internalType: "string", type: "string" }, + { name: "maxSupply", internalType: "uint32", type: "uint32" }, + { name: "mintFee", internalType: "uint256", type: "uint256" }, + { name: "mintFeeToken", internalType: "address", type: "address" }, + { + name: "mintFeeRecipient", + internalType: "address", + type: "address", + }, + { name: "owner", internalType: "address", type: "address" }, + { name: "mintOpen", internalType: "bool", type: "bool" }, + { name: "isPublicMinting", internalType: "bool", type: "bool" }, + ], + }, + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "owner", internalType: "address", type: "address" }, + { name: "operator", internalType: "address", type: "address" }, + ], + name: "isApprovedForAll", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "to", internalType: "address", type: "address" }, + { name: "nftMetadataURI", internalType: "string", type: "string" }, + ], + name: "mint", + outputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "to", internalType: "address", type: "address" }, + { name: "payer", internalType: "address", type: "address" }, + { name: "nftMetadataURI", internalType: "string", type: "string" }, + ], + name: "mintByPeriphery", + outputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "mintFee", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "mintFeeRecipient", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "mintFeeToken", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "mintOpen", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "name", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], + name: "ownerOf", + outputs: [{ name: "", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "publicMinting", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "role", internalType: "bytes32", type: "bytes32" }, + { name: "callerConfirmation", internalType: "address", type: "address" }, + ], + name: "renounceRole", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "role", internalType: "bytes32", type: "bytes32" }, + { name: "account", internalType: "address", type: "address" }, + ], + name: "revokeRole", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "from", internalType: "address", type: "address" }, + { name: "to", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + ], + name: "safeTransferFrom", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "from", internalType: "address", type: "address" }, + { name: "to", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + { name: "data", internalType: "bytes", type: "bytes" }, + ], + name: "safeTransferFrom", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "operator", internalType: "address", type: "address" }, + { name: "approved", internalType: "bool", type: "bool" }, + ], + name: "setApprovalForAll", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "baseURI", internalType: "string", type: "string" }], + name: "setBaseURI", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "fee", internalType: "uint256", type: "uint256" }], + name: "setMintFee", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "newFeeRecipient", internalType: "address", type: "address" }], + name: "setMintFeeRecipient", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "token", internalType: "address", type: "address" }], + name: "setMintFeeToken", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "mintOpen", internalType: "bool", type: "bool" }], + name: "setMintOpen", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "isPublicMinting", internalType: "bool", type: "bool" }], + name: "setPublicMinting", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }], + name: "supportsInterface", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "symbol", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], + name: "tokenURI", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "totalSupply", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "from", internalType: "address", type: "address" }, + { name: "to", internalType: "address", type: "address" }, + { name: "tokenId", internalType: "uint256", type: "uint256" }, + ], + name: "transferFrom", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [{ name: "token", internalType: "address", type: "address" }], + name: "withdrawToken", + outputs: [], + stateMutability: "nonpayable", }, ] as const; -/** - * - */ -export const spgnftImplAddress = { - 1513: "0xDb6480C00B570324A122A6B35F9CAC0F87BDb3e6", -} as const; +/** + * + */ +export const spgnftImplAddress = { + 1513: "0xC8E4376Da033cE244027B03f9b94dc0d7005D67E", +} as const; + +/** + * + */ +export const spgnftImplConfig = { + address: spgnftImplAddress, + abi: spgnftImplAbi, +} as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// SDK +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +// COMMON ============================================================= + +function getAddress(address: Record, chainId?: number): Address { + return address[chainId || 0] || "0x"; +} + +export type EncodedTxData = { to: Address; data: Hex }; + +export type SimpleWalletClient< + TChain extends Chain | undefined = Chain | undefined, + TAccount extends Account | undefined = Account | undefined, +> = { + account?: TAccount; + writeContract: < + const abi extends Abi | readonly unknown[], + functionName extends ContractFunctionName, + args extends ContractFunctionArgs, + TChainOverride extends Chain | undefined = undefined, + >( + args: WriteContractParameters, + ) => Promise; +}; + +// Contract AccessController ============================================================= + +/** + * AccessControllerPermissionSetEvent + * + * @param ipAccountOwner address + * @param ipAccount address + * @param signer address + * @param to address + * @param func bytes4 + * @param permission uint8 + */ +export type AccessControllerPermissionSetEvent = { + ipAccountOwner: Address; + ipAccount: Address; + signer: Address; + to: Address; + func: Hex; + permission: number; +}; + +/** + * AccessControllerSetAllPermissionsRequest + * + * @param ipAccount address + * @param signer address + * @param permission uint8 + */ +export type AccessControllerSetAllPermissionsRequest = { + ipAccount: Address; + signer: Address; + permission: number; +}; + +/** + * AccessControllerSetBatchPermissionsRequest + * + * @param permissions tuple[] + */ +export type AccessControllerSetBatchPermissionsRequest = { + permissions: { + ipAccount: Address; + signer: Address; + to: Address; + func: Hex; + permission: number; + }[]; +}; + +/** + * AccessControllerSetPermissionRequest + * + * @param ipAccount address + * @param signer address + * @param to address + * @param func bytes4 + * @param permission uint8 + */ +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], + }), + }; + } + + /** + * 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); + } + + /** + * 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], + }), + }; + } + + /** + * method onRaiseDispute for contract ArbitrationPolicySP + * + * @param request ArbitrationPolicySpOnRaiseDisputeRequest + * @return Promise + */ + public async onRaiseDispute( + request: ArbitrationPolicySpOnRaiseDisputeRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: arbitrationPolicySpAbi, + address: this.address, + functionName: "onRaiseDispute", + account: this.wallet.account, + args: [request.caller, request.data], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method onRaiseDispute for contract ArbitrationPolicySP with only encode + * + * @param request ArbitrationPolicySpOnRaiseDisputeRequest + * @return EncodedTxData + */ + public onRaiseDisputeEncode(request: ArbitrationPolicySpOnRaiseDisputeRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: arbitrationPolicySpAbi, + functionName: "onRaiseDispute", + args: [request.caller, request.data], + }), + }; + } + + /** + * 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); + } + + /** + * 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], + }), + }; + } + + /** + * method setAuthority for contract ArbitrationPolicySP + * + * @param request ArbitrationPolicySpSetAuthorityRequest + * @return Promise + */ + public async setAuthority( + request: ArbitrationPolicySpSetAuthorityRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: arbitrationPolicySpAbi, + address: this.address, + functionName: "setAuthority", + account: this.wallet.account, + args: [request.newAuthority], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setAuthority for contract ArbitrationPolicySP with only encode + * + * @param request ArbitrationPolicySpSetAuthorityRequest + * @return EncodedTxData + */ + public setAuthorityEncode(request: ArbitrationPolicySpSetAuthorityRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: arbitrationPolicySpAbi, + functionName: "setAuthority", + args: [request.newAuthority], + }), + }; + } + + /** + * method setTreasury for contract ArbitrationPolicySP + * + * @param request ArbitrationPolicySpSetTreasuryRequest + * @return Promise + */ + public async setTreasury( + request: ArbitrationPolicySpSetTreasuryRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: arbitrationPolicySpAbi, + address: this.address, + functionName: "setTreasury", + account: this.wallet.account, + args: [request.newTreasury], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setTreasury for contract ArbitrationPolicySP with only encode + * + * @param request ArbitrationPolicySpSetTreasuryRequest + * @return EncodedTxData + */ + public setTreasuryEncode(request: ArbitrationPolicySpSetTreasuryRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: arbitrationPolicySpAbi, + functionName: "setTreasury", + args: [request.newTreasury], + }), + }; + } + + /** + * method upgradeToAndCall for contract ArbitrationPolicySP + * + * @param request ArbitrationPolicySpUpgradeToAndCallRequest + * @return Promise + */ + public async upgradeToAndCall( + request: ArbitrationPolicySpUpgradeToAndCallRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: arbitrationPolicySpAbi, + address: this.address, + functionName: "upgradeToAndCall", + account: this.wallet.account, + args: [request.newImplementation, request.data], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method upgradeToAndCall for contract ArbitrationPolicySP with only encode + * + * @param request ArbitrationPolicySpUpgradeToAndCallRequest + * @return EncodedTxData + */ + public upgradeToAndCallEncode( + request: ArbitrationPolicySpUpgradeToAndCallRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: arbitrationPolicySpAbi, + functionName: "upgradeToAndCall", + args: [request.newImplementation, request.data], + }), + }; + } +} + +// Contract CoreMetadataModule ============================================================= + +/** + * CoreMetadataModuleAuthorityUpdatedEvent + * + * @param authority address + */ +export type CoreMetadataModuleAuthorityUpdatedEvent = { + authority: Address; +}; + +/** + * CoreMetadataModuleInitializedEvent + * + * @param version uint64 + */ +export type CoreMetadataModuleInitializedEvent = { + version: bigint; +}; + +/** + * CoreMetadataModuleMetadataFrozenEvent + * + * @param ipId address + */ +export type CoreMetadataModuleMetadataFrozenEvent = { + ipId: Address; +}; + +/** + * CoreMetadataModuleMetadataUriSetEvent + * + * @param ipId address + * @param metadataURI string + * @param metadataHash bytes32 + */ +export type CoreMetadataModuleMetadataUriSetEvent = { + ipId: Address; + metadataURI: string; + metadataHash: Hex; +}; + +/** + * CoreMetadataModuleNftTokenUriSetEvent + * + * @param ipId address + * @param nftTokenURI string + * @param nftMetadataHash bytes32 + */ +export type CoreMetadataModuleNftTokenUriSetEvent = { + ipId: Address; + nftTokenURI: string; + nftMetadataHash: Hex; +}; + +/** + * CoreMetadataModuleUpgradedEvent + * + * @param implementation address + */ +export type CoreMetadataModuleUpgradedEvent = { + implementation: Address; +}; + +export type CoreMetadataModuleAccessControllerResponse = Address; + +export type CoreMetadataModuleIpAccountRegistryResponse = Address; + +export type CoreMetadataModuleUpgradeInterfaceVersionResponse = string; + +export type CoreMetadataModuleAuthorityResponse = Address; + +export type CoreMetadataModuleIsConsumingScheduledOpResponse = Hex; + +/** + * CoreMetadataModuleIsMetadataFrozenRequest + * + * @param ipId address + */ +export type CoreMetadataModuleIsMetadataFrozenRequest = { + ipId: Address; +}; + +export type CoreMetadataModuleIsMetadataFrozenResponse = boolean; + +export type CoreMetadataModuleNameResponse = string; + +export type CoreMetadataModuleProxiableUuidResponse = Hex; + +/** + * CoreMetadataModuleSupportsInterfaceRequest + * + * @param interfaceId bytes4 + */ +export type CoreMetadataModuleSupportsInterfaceRequest = { + interfaceId: Hex; +}; + +export type CoreMetadataModuleSupportsInterfaceResponse = boolean; + +/** + * CoreMetadataModuleFreezeMetadataRequest + * + * @param ipId address + */ +export type CoreMetadataModuleFreezeMetadataRequest = { + ipId: Address; +}; + +/** + * CoreMetadataModuleInitializeRequest + * + * @param accessManager address + */ +export type CoreMetadataModuleInitializeRequest = { + accessManager: Address; +}; + +/** + * CoreMetadataModuleSetAllRequest + * + * @param ipId address + * @param metadataURI string + * @param metadataHash bytes32 + * @param nftMetadataHash bytes32 + */ +export type CoreMetadataModuleSetAllRequest = { + ipId: Address; + metadataURI: string; + metadataHash: Hex; + nftMetadataHash: Hex; +}; + +/** + * CoreMetadataModuleSetAuthorityRequest + * + * @param newAuthority address + */ +export type CoreMetadataModuleSetAuthorityRequest = { + newAuthority: Address; +}; + +/** + * CoreMetadataModuleSetMetadataUriRequest + * + * @param ipId address + * @param metadataURI string + * @param metadataHash bytes32 + */ +export type CoreMetadataModuleSetMetadataUriRequest = { + ipId: Address; + metadataURI: string; + metadataHash: Hex; +}; + +/** + * CoreMetadataModuleUpdateNftTokenUriRequest + * + * @param ipId address + * @param nftMetadataHash bytes32 + */ +export type CoreMetadataModuleUpdateNftTokenUriRequest = { + ipId: Address; + nftMetadataHash: Hex; +}; + +/** + * CoreMetadataModuleUpgradeToAndCallRequest + * + * @param newImplementation address + * @param data bytes + */ +export type CoreMetadataModuleUpgradeToAndCallRequest = { + newImplementation: Address; + data: Hex; +}; + +/** + * contract CoreMetadataModule event + */ +export class CoreMetadataModuleEventClient { + protected readonly rpcClient: PublicClient; + public readonly address: Address; + + constructor(rpcClient: PublicClient, address?: Address) { + this.address = address || getAddress(coreMetadataModuleAddress, rpcClient.chain?.id); + this.rpcClient = rpcClient; + } + + /** + * event AuthorityUpdated for contract CoreMetadataModule + */ + public watchAuthorityUpdatedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: coreMetadataModuleAbi, + address: this.address, + eventName: "AuthorityUpdated", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event AuthorityUpdated for contract CoreMetadataModule + */ + public parseTxAuthorityUpdatedEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: coreMetadataModuleAbi, + 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 CoreMetadataModule + */ + public watchInitializedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: coreMetadataModuleAbi, + address: this.address, + eventName: "Initialized", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event Initialized for contract CoreMetadataModule + */ + public parseTxInitializedEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: coreMetadataModuleAbi, + eventName: "Initialized", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "Initialized") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } + + /** + * event MetadataFrozen for contract CoreMetadataModule + */ + public watchMetadataFrozenEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: coreMetadataModuleAbi, + address: this.address, + eventName: "MetadataFrozen", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event MetadataFrozen for contract CoreMetadataModule + */ + public parseTxMetadataFrozenEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: coreMetadataModuleAbi, + eventName: "MetadataFrozen", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "MetadataFrozen") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } + + /** + * event MetadataURISet for contract CoreMetadataModule + */ + public watchMetadataUriSetEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: coreMetadataModuleAbi, + address: this.address, + eventName: "MetadataURISet", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event MetadataURISet for contract CoreMetadataModule + */ + public parseTxMetadataUriSetEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: coreMetadataModuleAbi, + eventName: "MetadataURISet", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "MetadataURISet") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } + + /** + * event NFTTokenURISet for contract CoreMetadataModule + */ + public watchNftTokenUriSetEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: coreMetadataModuleAbi, + address: this.address, + eventName: "NFTTokenURISet", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event NFTTokenURISet for contract CoreMetadataModule + */ + public parseTxNftTokenUriSetEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: coreMetadataModuleAbi, + eventName: "NFTTokenURISet", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "NFTTokenURISet") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } + + /** + * event Upgraded for contract CoreMetadataModule + */ + public watchUpgradedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: coreMetadataModuleAbi, + address: this.address, + eventName: "Upgraded", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event Upgraded for contract CoreMetadataModule + */ + public parseTxUpgradedEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: coreMetadataModuleAbi, + eventName: "Upgraded", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "Upgraded") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } +} + +/** + * contract CoreMetadataModule readonly method + */ +export class CoreMetadataModuleReadOnlyClient extends CoreMetadataModuleEventClient { + constructor(rpcClient: PublicClient, address?: Address) { + super(rpcClient, address); + } + + /** + * method ACCESS_CONTROLLER for contract CoreMetadataModule + * + * @param request CoreMetadataModuleAccessControllerRequest + * @return Promise + */ + public async accessController(): Promise { + return await this.rpcClient.readContract({ + abi: coreMetadataModuleAbi, + address: this.address, + functionName: "ACCESS_CONTROLLER", + }); + } + + /** + * method IP_ACCOUNT_REGISTRY for contract CoreMetadataModule + * + * @param request CoreMetadataModuleIpAccountRegistryRequest + * @return Promise + */ + public async ipAccountRegistry(): Promise { + return await this.rpcClient.readContract({ + abi: coreMetadataModuleAbi, + address: this.address, + functionName: "IP_ACCOUNT_REGISTRY", + }); + } + + /** + * method UPGRADE_INTERFACE_VERSION for contract CoreMetadataModule + * + * @param request CoreMetadataModuleUpgradeInterfaceVersionRequest + * @return Promise + */ + public async upgradeInterfaceVersion(): Promise { + return await this.rpcClient.readContract({ + abi: coreMetadataModuleAbi, + address: this.address, + functionName: "UPGRADE_INTERFACE_VERSION", + }); + } + + /** + * method authority for contract CoreMetadataModule + * + * @param request CoreMetadataModuleAuthorityRequest + * @return Promise + */ + public async authority(): Promise { + return await this.rpcClient.readContract({ + abi: coreMetadataModuleAbi, + address: this.address, + functionName: "authority", + }); + } + + /** + * method isConsumingScheduledOp for contract CoreMetadataModule + * + * @param request CoreMetadataModuleIsConsumingScheduledOpRequest + * @return Promise + */ + public async isConsumingScheduledOp(): Promise { + return await this.rpcClient.readContract({ + abi: coreMetadataModuleAbi, + address: this.address, + functionName: "isConsumingScheduledOp", + }); + } + + /** + * method isMetadataFrozen for contract CoreMetadataModule + * + * @param request CoreMetadataModuleIsMetadataFrozenRequest + * @return Promise + */ + public async isMetadataFrozen( + request: CoreMetadataModuleIsMetadataFrozenRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: coreMetadataModuleAbi, + address: this.address, + functionName: "isMetadataFrozen", + args: [request.ipId], + }); + } + + /** + * method name for contract CoreMetadataModule + * + * @param request CoreMetadataModuleNameRequest + * @return Promise + */ + public async name(): Promise { + return await this.rpcClient.readContract({ + abi: coreMetadataModuleAbi, + address: this.address, + functionName: "name", + }); + } + + /** + * method proxiableUUID for contract CoreMetadataModule + * + * @param request CoreMetadataModuleProxiableUuidRequest + * @return Promise + */ + public async proxiableUuid(): Promise { + return await this.rpcClient.readContract({ + abi: coreMetadataModuleAbi, + address: this.address, + functionName: "proxiableUUID", + }); + } + + /** + * method supportsInterface for contract CoreMetadataModule + * + * @param request CoreMetadataModuleSupportsInterfaceRequest + * @return Promise + */ + public async supportsInterface( + request: CoreMetadataModuleSupportsInterfaceRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: coreMetadataModuleAbi, + address: this.address, + functionName: "supportsInterface", + args: [request.interfaceId], + }); + } +} + +/** + * contract CoreMetadataModule write method + */ +export class CoreMetadataModuleClient extends CoreMetadataModuleReadOnlyClient { + protected readonly wallet: SimpleWalletClient; + + constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { + super(rpcClient, address); + this.wallet = wallet; + } + + /** + * method freezeMetadata for contract CoreMetadataModule + * + * @param request CoreMetadataModuleFreezeMetadataRequest + * @return Promise + */ + public async freezeMetadata( + request: CoreMetadataModuleFreezeMetadataRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: coreMetadataModuleAbi, + address: this.address, + functionName: "freezeMetadata", + account: this.wallet.account, + args: [request.ipId], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method freezeMetadata for contract CoreMetadataModule with only encode + * + * @param request CoreMetadataModuleFreezeMetadataRequest + * @return EncodedTxData + */ + public freezeMetadataEncode(request: CoreMetadataModuleFreezeMetadataRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: coreMetadataModuleAbi, + functionName: "freezeMetadata", + args: [request.ipId], + }), + }; + } + + /** + * method initialize for contract CoreMetadataModule + * + * @param request CoreMetadataModuleInitializeRequest + * @return Promise + */ + public async initialize( + request: CoreMetadataModuleInitializeRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: coreMetadataModuleAbi, + address: this.address, + functionName: "initialize", + account: this.wallet.account, + args: [request.accessManager], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method initialize for contract CoreMetadataModule with only encode + * + * @param request CoreMetadataModuleInitializeRequest + * @return EncodedTxData + */ + public initializeEncode(request: CoreMetadataModuleInitializeRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: coreMetadataModuleAbi, + functionName: "initialize", + args: [request.accessManager], + }), + }; + } + + /** + * method setAll for contract CoreMetadataModule + * + * @param request CoreMetadataModuleSetAllRequest + * @return Promise + */ + public async setAll(request: CoreMetadataModuleSetAllRequest): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: coreMetadataModuleAbi, + address: this.address, + functionName: "setAll", + account: this.wallet.account, + args: [request.ipId, request.metadataURI, request.metadataHash, request.nftMetadataHash], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setAll for contract CoreMetadataModule with only encode + * + * @param request CoreMetadataModuleSetAllRequest + * @return EncodedTxData + */ + public setAllEncode(request: CoreMetadataModuleSetAllRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: coreMetadataModuleAbi, + functionName: "setAll", + args: [request.ipId, request.metadataURI, request.metadataHash, request.nftMetadataHash], + }), + }; + } + + /** + * method setAuthority for contract CoreMetadataModule + * + * @param request CoreMetadataModuleSetAuthorityRequest + * @return Promise + */ + public async setAuthority( + request: CoreMetadataModuleSetAuthorityRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: coreMetadataModuleAbi, + address: this.address, + functionName: "setAuthority", + account: this.wallet.account, + args: [request.newAuthority], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setAuthority for contract CoreMetadataModule with only encode + * + * @param request CoreMetadataModuleSetAuthorityRequest + * @return EncodedTxData + */ + public setAuthorityEncode(request: CoreMetadataModuleSetAuthorityRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: coreMetadataModuleAbi, + functionName: "setAuthority", + args: [request.newAuthority], + }), + }; + } + + /** + * method setMetadataURI for contract CoreMetadataModule + * + * @param request CoreMetadataModuleSetMetadataUriRequest + * @return Promise + */ + public async setMetadataUri( + request: CoreMetadataModuleSetMetadataUriRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: coreMetadataModuleAbi, + address: this.address, + functionName: "setMetadataURI", + account: this.wallet.account, + args: [request.ipId, request.metadataURI, request.metadataHash], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setMetadataURI for contract CoreMetadataModule with only encode + * + * @param request CoreMetadataModuleSetMetadataUriRequest + * @return EncodedTxData + */ + public setMetadataUriEncode(request: CoreMetadataModuleSetMetadataUriRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: coreMetadataModuleAbi, + functionName: "setMetadataURI", + args: [request.ipId, request.metadataURI, request.metadataHash], + }), + }; + } + + /** + * method updateNftTokenURI for contract CoreMetadataModule + * + * @param request CoreMetadataModuleUpdateNftTokenUriRequest + * @return Promise + */ + public async updateNftTokenUri( + request: CoreMetadataModuleUpdateNftTokenUriRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: coreMetadataModuleAbi, + address: this.address, + functionName: "updateNftTokenURI", + account: this.wallet.account, + args: [request.ipId, request.nftMetadataHash], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method updateNftTokenURI for contract CoreMetadataModule with only encode + * + * @param request CoreMetadataModuleUpdateNftTokenUriRequest + * @return EncodedTxData + */ + public updateNftTokenUriEncode( + request: CoreMetadataModuleUpdateNftTokenUriRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: coreMetadataModuleAbi, + functionName: "updateNftTokenURI", + args: [request.ipId, request.nftMetadataHash], + }), + }; + } + + /** + * method upgradeToAndCall for contract CoreMetadataModule + * + * @param request CoreMetadataModuleUpgradeToAndCallRequest + * @return Promise + */ + public async upgradeToAndCall( + request: CoreMetadataModuleUpgradeToAndCallRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: coreMetadataModuleAbi, + address: this.address, + functionName: "upgradeToAndCall", + account: this.wallet.account, + args: [request.newImplementation, request.data], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method upgradeToAndCall for contract CoreMetadataModule with only encode + * + * @param request CoreMetadataModuleUpgradeToAndCallRequest + * @return EncodedTxData + */ + public upgradeToAndCallEncode(request: CoreMetadataModuleUpgradeToAndCallRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: coreMetadataModuleAbi, + functionName: "upgradeToAndCall", + args: [request.newImplementation, request.data], + }), + }; + } +} + +// Contract DerivativeWorkflows ============================================================= + +/** + * DerivativeWorkflowsMintAndRegisterIpAndMakeDerivativeRequest + * + * @param spgNftContract address + * @param derivData tuple + * @param ipMetadata tuple + * @param recipient address + */ +export type DerivativeWorkflowsMintAndRegisterIpAndMakeDerivativeRequest = { + spgNftContract: Address; + derivData: { + parentIpIds: readonly Address[]; + licenseTemplate: Address; + licenseTermsIds: readonly bigint[]; + royaltyContext: Hex; + }; + ipMetadata: { + ipMetadataURI: string; + ipMetadataHash: Hex; + nftMetadataURI: string; + nftMetadataHash: Hex; + }; + recipient: Address; +}; + +/** + * DerivativeWorkflowsMintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest + * + * @param spgNftContract address + * @param licenseTokenIds uint256[] + * @param royaltyContext bytes + * @param ipMetadata tuple + * @param recipient address + */ +export type DerivativeWorkflowsMintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest = { + spgNftContract: Address; + licenseTokenIds: readonly bigint[]; + royaltyContext: Hex; + ipMetadata: { + ipMetadataURI: string; + ipMetadataHash: Hex; + nftMetadataURI: string; + nftMetadataHash: Hex; + }; + recipient: Address; +}; + +/** + * DerivativeWorkflowsRegisterIpAndMakeDerivativeRequest + * + * @param nftContract address + * @param tokenId uint256 + * @param derivData tuple + * @param ipMetadata tuple + * @param sigMetadata tuple + * @param sigRegister tuple + */ +export type DerivativeWorkflowsRegisterIpAndMakeDerivativeRequest = { + nftContract: Address; + tokenId: bigint; + derivData: { + parentIpIds: readonly Address[]; + licenseTemplate: Address; + licenseTermsIds: readonly bigint[]; + royaltyContext: Hex; + }; + ipMetadata: { + ipMetadataURI: string; + ipMetadataHash: Hex; + nftMetadataURI: string; + nftMetadataHash: Hex; + }; + sigMetadata: { + signer: Address; + deadline: bigint; + signature: Hex; + }; + sigRegister: { + signer: Address; + deadline: bigint; + signature: Hex; + }; +}; + +/** + * DerivativeWorkflowsRegisterIpAndMakeDerivativeWithLicenseTokensRequest + * + * @param nftContract address + * @param tokenId uint256 + * @param licenseTokenIds uint256[] + * @param royaltyContext bytes + * @param ipMetadata tuple + * @param sigMetadata tuple + * @param sigRegister tuple + */ +export type DerivativeWorkflowsRegisterIpAndMakeDerivativeWithLicenseTokensRequest = { + nftContract: Address; + tokenId: bigint; + licenseTokenIds: readonly bigint[]; + royaltyContext: Hex; + ipMetadata: { + ipMetadataURI: string; + ipMetadataHash: Hex; + nftMetadataURI: string; + nftMetadataHash: Hex; + }; + sigMetadata: { + signer: Address; + deadline: bigint; + signature: Hex; + }; + sigRegister: { + signer: Address; + deadline: bigint; + signature: Hex; + }; +}; + +/** + * contract DerivativeWorkflows write method + */ +export class DerivativeWorkflowsClient { + protected readonly wallet: SimpleWalletClient; + protected readonly rpcClient: PublicClient; + public readonly address: Address; + + constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { + this.address = address || getAddress(derivativeWorkflowsAddress, rpcClient.chain?.id); + this.rpcClient = rpcClient; + this.wallet = wallet; + } + + /** + * method mintAndRegisterIpAndMakeDerivative for contract DerivativeWorkflows + * + * @param request DerivativeWorkflowsMintAndRegisterIpAndMakeDerivativeRequest + * @return Promise + */ + public async mintAndRegisterIpAndMakeDerivative( + request: DerivativeWorkflowsMintAndRegisterIpAndMakeDerivativeRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: derivativeWorkflowsAbi, + address: this.address, + functionName: "mintAndRegisterIpAndMakeDerivative", + account: this.wallet.account, + args: [request.spgNftContract, request.derivData, request.ipMetadata, request.recipient], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method mintAndRegisterIpAndMakeDerivative for contract DerivativeWorkflows with only encode + * + * @param request DerivativeWorkflowsMintAndRegisterIpAndMakeDerivativeRequest + * @return EncodedTxData + */ + public mintAndRegisterIpAndMakeDerivativeEncode( + request: DerivativeWorkflowsMintAndRegisterIpAndMakeDerivativeRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: derivativeWorkflowsAbi, + functionName: "mintAndRegisterIpAndMakeDerivative", + args: [request.spgNftContract, request.derivData, request.ipMetadata, request.recipient], + }), + }; + } + + /** + * method mintAndRegisterIpAndMakeDerivativeWithLicenseTokens for contract DerivativeWorkflows + * + * @param request DerivativeWorkflowsMintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest + * @return Promise + */ + public async mintAndRegisterIpAndMakeDerivativeWithLicenseTokens( + request: DerivativeWorkflowsMintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: derivativeWorkflowsAbi, + address: this.address, + functionName: "mintAndRegisterIpAndMakeDerivativeWithLicenseTokens", + account: this.wallet.account, + args: [ + request.spgNftContract, + request.licenseTokenIds, + request.royaltyContext, + request.ipMetadata, + request.recipient, + ], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method mintAndRegisterIpAndMakeDerivativeWithLicenseTokens for contract DerivativeWorkflows with only encode + * + * @param request DerivativeWorkflowsMintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest + * @return EncodedTxData + */ + public mintAndRegisterIpAndMakeDerivativeWithLicenseTokensEncode( + request: DerivativeWorkflowsMintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: derivativeWorkflowsAbi, + functionName: "mintAndRegisterIpAndMakeDerivativeWithLicenseTokens", + args: [ + request.spgNftContract, + request.licenseTokenIds, + request.royaltyContext, + request.ipMetadata, + request.recipient, + ], + }), + }; + } + + /** + * method registerIpAndMakeDerivative for contract DerivativeWorkflows + * + * @param request DerivativeWorkflowsRegisterIpAndMakeDerivativeRequest + * @return Promise + */ + public async registerIpAndMakeDerivative( + request: DerivativeWorkflowsRegisterIpAndMakeDerivativeRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: derivativeWorkflowsAbi, + address: this.address, + functionName: "registerIpAndMakeDerivative", + account: this.wallet.account, + args: [ + request.nftContract, + request.tokenId, + request.derivData, + request.ipMetadata, + request.sigMetadata, + request.sigRegister, + ], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method registerIpAndMakeDerivative for contract DerivativeWorkflows with only encode + * + * @param request DerivativeWorkflowsRegisterIpAndMakeDerivativeRequest + * @return EncodedTxData + */ + public registerIpAndMakeDerivativeEncode( + request: DerivativeWorkflowsRegisterIpAndMakeDerivativeRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: derivativeWorkflowsAbi, + functionName: "registerIpAndMakeDerivative", + args: [ + request.nftContract, + request.tokenId, + request.derivData, + request.ipMetadata, + request.sigMetadata, + request.sigRegister, + ], + }), + }; + } + + /** + * method registerIpAndMakeDerivativeWithLicenseTokens for contract DerivativeWorkflows + * + * @param request DerivativeWorkflowsRegisterIpAndMakeDerivativeWithLicenseTokensRequest + * @return Promise + */ + public async registerIpAndMakeDerivativeWithLicenseTokens( + request: DerivativeWorkflowsRegisterIpAndMakeDerivativeWithLicenseTokensRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: derivativeWorkflowsAbi, + address: this.address, + functionName: "registerIpAndMakeDerivativeWithLicenseTokens", + account: this.wallet.account, + args: [ + request.nftContract, + request.tokenId, + request.licenseTokenIds, + request.royaltyContext, + request.ipMetadata, + request.sigMetadata, + request.sigRegister, + ], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method registerIpAndMakeDerivativeWithLicenseTokens for contract DerivativeWorkflows with only encode + * + * @param request DerivativeWorkflowsRegisterIpAndMakeDerivativeWithLicenseTokensRequest + * @return EncodedTxData + */ + public registerIpAndMakeDerivativeWithLicenseTokensEncode( + request: DerivativeWorkflowsRegisterIpAndMakeDerivativeWithLicenseTokensRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: derivativeWorkflowsAbi, + functionName: "registerIpAndMakeDerivativeWithLicenseTokens", + args: [ + request.nftContract, + request.tokenId, + request.licenseTokenIds, + request.royaltyContext, + request.ipMetadata, + request.sigMetadata, + request.sigRegister, + ], + }), + }; + } +} + +// Contract DisputeModule ============================================================= + +/** + * DisputeModuleDisputeCancelledEvent + * + * @param disputeId uint256 + * @param data bytes + */ +export type DisputeModuleDisputeCancelledEvent = { + disputeId: bigint; + data: Hex; +}; + +/** + * DisputeModuleDisputeRaisedEvent + * + * @param disputeId uint256 + * @param targetIpId address + * @param disputeInitiator address + * @param arbitrationPolicy address + * @param disputeEvidenceHash bytes32 + * @param targetTag bytes32 + * @param data bytes + */ +export type DisputeModuleDisputeRaisedEvent = { + disputeId: bigint; + targetIpId: Address; + disputeInitiator: Address; + arbitrationPolicy: Address; + disputeEvidenceHash: Hex; + targetTag: Hex; + data: Hex; +}; + +/** + * DisputeModuleDisputeResolvedEvent + * + * @param disputeId uint256 + */ +export type DisputeModuleDisputeResolvedEvent = { + disputeId: bigint; +}; + +/** + * DisputeModuleCancelDisputeRequest + * + * @param disputeId uint256 + * @param data bytes + */ +export type DisputeModuleCancelDisputeRequest = { + disputeId: bigint; + data: Hex; +}; + +/** + * DisputeModuleRaiseDisputeRequest + * + * @param targetIpId address + * @param disputeEvidenceHash bytes32 + * @param targetTag bytes32 + * @param data bytes + */ +export type DisputeModuleRaiseDisputeRequest = { + targetIpId: Address; + disputeEvidenceHash: Hex; + targetTag: Hex; + data: Hex; +}; + +/** + * DisputeModuleResolveDisputeRequest + * + * @param disputeId uint256 + * @param data bytes + */ +export type DisputeModuleResolveDisputeRequest = { + disputeId: bigint; + data: Hex; +}; + +/** + * contract DisputeModule event + */ +export class DisputeModuleEventClient { + protected readonly rpcClient: PublicClient; + public readonly address: Address; + + constructor(rpcClient: PublicClient, address?: Address) { + this.address = address || getAddress(disputeModuleAddress, rpcClient.chain?.id); + this.rpcClient = rpcClient; + } + + /** + * event DisputeCancelled for contract DisputeModule + */ + public watchDisputeCancelledEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: disputeModuleAbi, + address: this.address, + eventName: "DisputeCancelled", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event DisputeCancelled for contract DisputeModule + */ + public parseTxDisputeCancelledEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: disputeModuleAbi, + eventName: "DisputeCancelled", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "DisputeCancelled") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } + + /** + * event DisputeRaised for contract DisputeModule + */ + public watchDisputeRaisedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: disputeModuleAbi, + address: this.address, + eventName: "DisputeRaised", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event DisputeRaised for contract DisputeModule + */ + public parseTxDisputeRaisedEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: disputeModuleAbi, + eventName: "DisputeRaised", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "DisputeRaised") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } + + /** + * event DisputeResolved for contract DisputeModule + */ + public watchDisputeResolvedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: disputeModuleAbi, + address: this.address, + eventName: "DisputeResolved", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event DisputeResolved for contract DisputeModule + */ + public parseTxDisputeResolvedEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: disputeModuleAbi, + eventName: "DisputeResolved", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "DisputeResolved") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } +} + +/** + * contract DisputeModule write method + */ +export class DisputeModuleClient extends DisputeModuleEventClient { + protected readonly wallet: SimpleWalletClient; + + constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { + super(rpcClient, address); + this.wallet = wallet; + } + + /** + * method cancelDispute for contract DisputeModule + * + * @param request DisputeModuleCancelDisputeRequest + * @return Promise + */ + public async cancelDispute( + request: DisputeModuleCancelDisputeRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: disputeModuleAbi, + address: this.address, + functionName: "cancelDispute", + account: this.wallet.account, + args: [request.disputeId, request.data], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method cancelDispute for contract DisputeModule with only encode + * + * @param request DisputeModuleCancelDisputeRequest + * @return EncodedTxData + */ + public cancelDisputeEncode(request: DisputeModuleCancelDisputeRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: disputeModuleAbi, + functionName: "cancelDispute", + args: [request.disputeId, request.data], + }), + }; + } + + /** + * method raiseDispute for contract DisputeModule + * + * @param request DisputeModuleRaiseDisputeRequest + * @return Promise + */ + public async raiseDispute( + request: DisputeModuleRaiseDisputeRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: disputeModuleAbi, + address: this.address, + functionName: "raiseDispute", + account: this.wallet.account, + args: [request.targetIpId, request.disputeEvidenceHash, request.targetTag, request.data], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method raiseDispute for contract DisputeModule with only encode + * + * @param request DisputeModuleRaiseDisputeRequest + * @return EncodedTxData + */ + public raiseDisputeEncode(request: DisputeModuleRaiseDisputeRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: disputeModuleAbi, + functionName: "raiseDispute", + args: [request.targetIpId, request.disputeEvidenceHash, request.targetTag, request.data], + }), + }; + } + + /** + * method resolveDispute for contract DisputeModule + * + * @param request DisputeModuleResolveDisputeRequest + * @return Promise + */ + public async resolveDispute( + request: DisputeModuleResolveDisputeRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: disputeModuleAbi, + address: this.address, + functionName: "resolveDispute", + account: this.wallet.account, + args: [request.disputeId, request.data], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method resolveDispute for contract DisputeModule with only encode + * + * @param request DisputeModuleResolveDisputeRequest + * @return EncodedTxData + */ + public resolveDisputeEncode(request: DisputeModuleResolveDisputeRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: disputeModuleAbi, + functionName: "resolveDispute", + args: [request.disputeId, request.data], + }), + }; + } +} + +// Contract EvenSplitGroupPool ============================================================= + +/** + * EvenSplitGroupPoolAuthorityUpdatedEvent + * + * @param authority address + */ +export type EvenSplitGroupPoolAuthorityUpdatedEvent = { + authority: Address; +}; + +/** + * EvenSplitGroupPoolInitializedEvent + * + * @param version uint64 + */ +export type EvenSplitGroupPoolInitializedEvent = { + version: bigint; +}; + +/** + * EvenSplitGroupPoolPausedEvent + * + * @param account address + */ +export type EvenSplitGroupPoolPausedEvent = { + account: Address; +}; + +/** + * EvenSplitGroupPoolUnpausedEvent + * + * @param account address + */ +export type EvenSplitGroupPoolUnpausedEvent = { + account: Address; +}; + +/** + * EvenSplitGroupPoolUpgradedEvent + * + * @param implementation address + */ +export type EvenSplitGroupPoolUpgradedEvent = { + implementation: Address; +}; + +export type EvenSplitGroupPoolGroupingModuleResponse = Address; + +export type EvenSplitGroupPoolGroupIpAssetRegistryResponse = Address; + +export type EvenSplitGroupPoolRoyaltyModuleResponse = Address; + +export type EvenSplitGroupPoolUpgradeInterfaceVersionResponse = string; + +export type EvenSplitGroupPoolAuthorityResponse = Address; + +/** + * EvenSplitGroupPoolGetAvailableRewardRequest + * + * @param groupId address + * @param token address + * @param ipIds address[] + */ +export type EvenSplitGroupPoolGetAvailableRewardRequest = { + groupId: Address; + token: Address; + ipIds: readonly Address[]; +}; + +export type EvenSplitGroupPoolGetAvailableRewardResponse = readonly bigint[]; + +/** + * EvenSplitGroupPoolGetIpAddedTimeRequest + * + * @param groupId address + * @param ipId address + */ +export type EvenSplitGroupPoolGetIpAddedTimeRequest = { + groupId: Address; + ipId: Address; +}; + +export type EvenSplitGroupPoolGetIpAddedTimeResponse = bigint; + +/** + * EvenSplitGroupPoolGetIpRewardDebtRequest + * + * @param groupId address + * @param token address + * @param ipId address + */ +export type EvenSplitGroupPoolGetIpRewardDebtRequest = { + groupId: Address; + token: Address; + ipId: Address; +}; + +export type EvenSplitGroupPoolGetIpRewardDebtResponse = bigint; + +/** + * EvenSplitGroupPoolGetTotalIpsRequest + * + * @param groupId address + */ +export type EvenSplitGroupPoolGetTotalIpsRequest = { + groupId: Address; +}; + +export type EvenSplitGroupPoolGetTotalIpsResponse = bigint; + +export type EvenSplitGroupPoolIsConsumingScheduledOpResponse = Hex; + +/** + * EvenSplitGroupPoolIsIpAddedRequest + * + * @param groupId address + * @param ipId address + */ +export type EvenSplitGroupPoolIsIpAddedRequest = { + groupId: Address; + ipId: Address; +}; + +export type EvenSplitGroupPoolIsIpAddedResponse = boolean; + +export type EvenSplitGroupPoolPausedResponse = boolean; + +export type EvenSplitGroupPoolProxiableUuidResponse = Hex; + +/** + * EvenSplitGroupPoolProtocolPausableInitRequest + * + * @param accessManager address + */ +export type EvenSplitGroupPoolProtocolPausableInitRequest = { + accessManager: Address; +}; + +/** + * EvenSplitGroupPoolAddIpRequest + * + * @param groupId address + * @param ipId address + */ +export type EvenSplitGroupPoolAddIpRequest = { + groupId: Address; + ipId: Address; +}; + +/** + * EvenSplitGroupPoolDepositRewardRequest + * + * @param groupId address + * @param token address + * @param amount uint256 + */ +export type EvenSplitGroupPoolDepositRewardRequest = { + groupId: Address; + token: Address; + amount: bigint; +}; + +/** + * EvenSplitGroupPoolDistributeRewardsRequest + * + * @param groupId address + * @param token address + * @param ipIds address[] + */ +export type EvenSplitGroupPoolDistributeRewardsRequest = { + groupId: Address; + token: Address; + ipIds: readonly Address[]; +}; + +/** + * EvenSplitGroupPoolInitializeRequest + * + * @param accessManager address + */ +export type EvenSplitGroupPoolInitializeRequest = { + accessManager: Address; +}; + +/** + * EvenSplitGroupPoolRemoveIpRequest + * + * @param groupId address + * @param ipId address + */ +export type EvenSplitGroupPoolRemoveIpRequest = { + groupId: Address; + ipId: Address; +}; + +/** + * EvenSplitGroupPoolSetAuthorityRequest + * + * @param newAuthority address + */ +export type EvenSplitGroupPoolSetAuthorityRequest = { + newAuthority: Address; +}; + +/** + * EvenSplitGroupPoolUpgradeToAndCallRequest + * + * @param newImplementation address + * @param data bytes + */ +export type EvenSplitGroupPoolUpgradeToAndCallRequest = { + newImplementation: Address; + data: Hex; +}; + +/** + * contract EvenSplitGroupPool event + */ +export class EvenSplitGroupPoolEventClient { + protected readonly rpcClient: PublicClient; + public readonly address: Address; + + constructor(rpcClient: PublicClient, address?: Address) { + this.address = address || getAddress(evenSplitGroupPoolAddress, rpcClient.chain?.id); + this.rpcClient = rpcClient; + } + + /** + * event AuthorityUpdated for contract EvenSplitGroupPool + */ + public watchAuthorityUpdatedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: evenSplitGroupPoolAbi, + address: this.address, + eventName: "AuthorityUpdated", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event AuthorityUpdated for contract EvenSplitGroupPool + */ + public parseTxAuthorityUpdatedEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: evenSplitGroupPoolAbi, + 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 EvenSplitGroupPool + */ + public watchInitializedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: evenSplitGroupPoolAbi, + address: this.address, + eventName: "Initialized", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event Initialized for contract EvenSplitGroupPool + */ + public parseTxInitializedEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: evenSplitGroupPoolAbi, + eventName: "Initialized", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "Initialized") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } + + /** + * event Paused for contract EvenSplitGroupPool + */ + public watchPausedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: evenSplitGroupPoolAbi, + address: this.address, + eventName: "Paused", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event Paused for contract EvenSplitGroupPool + */ + public parseTxPausedEvent(txReceipt: TransactionReceipt): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: evenSplitGroupPoolAbi, + eventName: "Paused", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "Paused") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } + + /** + * event Unpaused for contract EvenSplitGroupPool + */ + public watchUnpausedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: evenSplitGroupPoolAbi, + address: this.address, + eventName: "Unpaused", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event Unpaused for contract EvenSplitGroupPool + */ + public parseTxUnpausedEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: evenSplitGroupPoolAbi, + eventName: "Unpaused", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "Unpaused") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } + + /** + * event Upgraded for contract EvenSplitGroupPool + */ + public watchUpgradedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: evenSplitGroupPoolAbi, + address: this.address, + eventName: "Upgraded", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event Upgraded for contract EvenSplitGroupPool + */ + public parseTxUpgradedEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: evenSplitGroupPoolAbi, + eventName: "Upgraded", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "Upgraded") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } +} /** - * + * contract EvenSplitGroupPool readonly method */ -export const spgnftImplConfig = { - address: spgnftImplAddress, - abi: spgnftImplAbi, -} as const; - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// SDK -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +export class EvenSplitGroupPoolReadOnlyClient extends EvenSplitGroupPoolEventClient { + constructor(rpcClient: PublicClient, address?: Address) { + super(rpcClient, address); + } -// COMMON ============================================================= + /** + * method GROUPING_MODULE for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolGroupingModuleRequest + * @return Promise + */ + public async groupingModule(): Promise { + return await this.rpcClient.readContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "GROUPING_MODULE", + }); + } -function getAddress(address: Record, chainId?: number): Address { - return address[chainId || 0] || "0x"; -} + /** + * method GROUP_IP_ASSET_REGISTRY for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolGroupIpAssetRegistryRequest + * @return Promise + */ + public async groupIpAssetRegistry(): Promise { + return await this.rpcClient.readContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "GROUP_IP_ASSET_REGISTRY", + }); + } -export type EncodedTxData = { to: Address; data: Hex }; + /** + * method ROYALTY_MODULE for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolRoyaltyModuleRequest + * @return Promise + */ + public async royaltyModule(): Promise { + return await this.rpcClient.readContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "ROYALTY_MODULE", + }); + } -export type SimpleWalletClient< - TChain extends Chain | undefined = Chain | undefined, - TAccount extends Account | undefined = Account | undefined, -> = { - account?: TAccount; - writeContract: < - const abi extends Abi | readonly unknown[], - functionName extends ContractFunctionName, - args extends ContractFunctionArgs, - TChainOverride extends Chain | undefined = undefined, - >( - args: WriteContractParameters, - ) => Promise; -}; + /** + * method UPGRADE_INTERFACE_VERSION for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolUpgradeInterfaceVersionRequest + * @return Promise + */ + public async upgradeInterfaceVersion(): Promise { + return await this.rpcClient.readContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "UPGRADE_INTERFACE_VERSION", + }); + } -// Contract AccessController ============================================================= + /** + * method authority for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolAuthorityRequest + * @return Promise + */ + public async authority(): Promise { + return await this.rpcClient.readContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "authority", + }); + } -/** - * AccessControllerPermissionSetEvent - * - * @param ipAccountOwner address - * @param ipAccount address - * @param signer address - * @param to address - * @param func bytes4 - * @param permission uint8 - */ -export type AccessControllerPermissionSetEvent = { - ipAccountOwner: Address; - ipAccount: Address; - signer: Address; - to: Address; - func: Hex; - permission: number; -}; + /** + * method getAvailableReward for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolGetAvailableRewardRequest + * @return Promise + */ + public async getAvailableReward( + request: EvenSplitGroupPoolGetAvailableRewardRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "getAvailableReward", + args: [request.groupId, request.token, request.ipIds], + }); + } -/** - * AccessControllerSetAllPermissionsRequest - * - * @param ipAccount address - * @param signer address - * @param permission uint8 - */ -export type AccessControllerSetAllPermissionsRequest = { - ipAccount: Address; - signer: Address; - permission: number; -}; + /** + * method getIpAddedTime for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolGetIpAddedTimeRequest + * @return Promise + */ + public async getIpAddedTime( + request: EvenSplitGroupPoolGetIpAddedTimeRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "getIpAddedTime", + args: [request.groupId, request.ipId], + }); + } -/** - * AccessControllerSetBatchPermissionsRequest - * - * @param permissions tuple[] - */ -export type AccessControllerSetBatchPermissionsRequest = { - permissions: { - ipAccount: Address; - signer: Address; - to: Address; - func: Hex; - permission: number; - }[]; -}; + /** + * method getIpRewardDebt for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolGetIpRewardDebtRequest + * @return Promise + */ + public async getIpRewardDebt( + request: EvenSplitGroupPoolGetIpRewardDebtRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "getIpRewardDebt", + args: [request.groupId, request.token, request.ipId], + }); + } -/** - * AccessControllerSetPermissionRequest - * - * @param ipAccount address - * @param signer address - * @param to address - * @param func bytes4 - * @param permission uint8 - */ -export type AccessControllerSetPermissionRequest = { - ipAccount: Address; - signer: Address; - to: Address; - func: Hex; - permission: number; -}; + /** + * method getTotalIps for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolGetTotalIpsRequest + * @return Promise + */ + public async getTotalIps( + request: EvenSplitGroupPoolGetTotalIpsRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "getTotalIps", + args: [request.groupId], + }); + } -/** - * contract AccessController event - */ -export class AccessControllerEventClient { - protected readonly rpcClient: PublicClient; - public readonly address: Address; + /** + * method isConsumingScheduledOp for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolIsConsumingScheduledOpRequest + * @return Promise + */ + public async isConsumingScheduledOp(): Promise { + return await this.rpcClient.readContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "isConsumingScheduledOp", + }); + } - constructor(rpcClient: PublicClient, address?: Address) { - this.address = address || getAddress(accessControllerAddress, rpcClient.chain?.id); - this.rpcClient = rpcClient; + /** + * method isIPAdded for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolIsIpAddedRequest + * @return Promise + */ + public async isIpAdded( + request: EvenSplitGroupPoolIsIpAddedRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "isIPAdded", + args: [request.groupId, request.ipId], + }); } /** - * event PermissionSet for contract AccessController + * method paused for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolPausedRequest + * @return Promise */ - public watchPermissionSetEvent( - onLogs: (txHash: Hex, ev: Partial) => void, - ): WatchContractEventReturnType { - return this.rpcClient.watchContractEvent({ - abi: accessControllerAbi, + public async paused(): Promise { + return await this.rpcClient.readContract({ + abi: evenSplitGroupPoolAbi, address: this.address, - eventName: "PermissionSet", - onLogs: (evs) => { - evs.forEach((it) => onLogs(it.transactionHash, it.args)); - }, + functionName: "paused", }); } /** - * parse tx receipt event PermissionSet for contract AccessController + * method proxiableUUID for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolProxiableUuidRequest + * @return Promise */ - 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; + public async proxiableUuid(): Promise { + return await this.rpcClient.readContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "proxiableUUID", + }); } } /** - * contract AccessController write method + * contract EvenSplitGroupPool write method */ -export class AccessControllerClient extends AccessControllerEventClient { +export class EvenSplitGroupPoolClient extends EvenSplitGroupPoolReadOnlyClient { protected readonly wallet: SimpleWalletClient; constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { @@ -8023,315 +14449,814 @@ export class AccessControllerClient extends AccessControllerEventClient { } /** - * method setAllPermissions for contract AccessController + * method __ProtocolPausable_init for contract EvenSplitGroupPool * - * @param request AccessControllerSetAllPermissionsRequest + * @param request EvenSplitGroupPoolProtocolPausableInitRequest * @return Promise */ - public async setAllPermissions( - request: AccessControllerSetAllPermissionsRequest, + public async protocolPausableInit( + request: EvenSplitGroupPoolProtocolPausableInitRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: accessControllerAbi, + abi: evenSplitGroupPoolAbi, address: this.address, - functionName: "setAllPermissions", + functionName: "__ProtocolPausable_init", account: this.wallet.account, - args: [request.ipAccount, request.signer, request.permission], + args: [request.accessManager], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method setAllPermissions for contract AccessController with only encode + * method __ProtocolPausable_init for contract EvenSplitGroupPool with only encode * - * @param request AccessControllerSetAllPermissionsRequest + * @param request EvenSplitGroupPoolProtocolPausableInitRequest * @return EncodedTxData */ - public setAllPermissionsEncode(request: AccessControllerSetAllPermissionsRequest): EncodedTxData { + public protocolPausableInitEncode( + request: EvenSplitGroupPoolProtocolPausableInitRequest, + ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: accessControllerAbi, - functionName: "setAllPermissions", - args: [request.ipAccount, request.signer, request.permission], + abi: evenSplitGroupPoolAbi, + functionName: "__ProtocolPausable_init", + args: [request.accessManager], }), }; } /** - * method setBatchPermissions for contract AccessController + * method addIp for contract EvenSplitGroupPool * - * @param request AccessControllerSetBatchPermissionsRequest + * @param request EvenSplitGroupPoolAddIpRequest * @return Promise */ - public async setBatchPermissions( - request: AccessControllerSetBatchPermissionsRequest, + public async addIp(request: EvenSplitGroupPoolAddIpRequest): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "addIp", + account: this.wallet.account, + args: [request.groupId, request.ipId], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method addIp for contract EvenSplitGroupPool with only encode + * + * @param request EvenSplitGroupPoolAddIpRequest + * @return EncodedTxData + */ + public addIpEncode(request: EvenSplitGroupPoolAddIpRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: evenSplitGroupPoolAbi, + functionName: "addIp", + args: [request.groupId, request.ipId], + }), + }; + } + + /** + * method depositReward for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolDepositRewardRequest + * @return Promise + */ + public async depositReward( + request: EvenSplitGroupPoolDepositRewardRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: accessControllerAbi, + abi: evenSplitGroupPoolAbi, address: this.address, - functionName: "setBatchPermissions", + functionName: "depositReward", account: this.wallet.account, - args: [request.permissions], + args: [request.groupId, request.token, request.amount], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method setBatchPermissions for contract AccessController with only encode + * method depositReward for contract EvenSplitGroupPool with only encode * - * @param request AccessControllerSetBatchPermissionsRequest + * @param request EvenSplitGroupPoolDepositRewardRequest * @return EncodedTxData */ - public setBatchPermissionsEncode( - request: AccessControllerSetBatchPermissionsRequest, + public depositRewardEncode(request: EvenSplitGroupPoolDepositRewardRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: evenSplitGroupPoolAbi, + functionName: "depositReward", + args: [request.groupId, request.token, request.amount], + }), + }; + } + + /** + * method distributeRewards for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolDistributeRewardsRequest + * @return Promise + */ + public async distributeRewards( + request: EvenSplitGroupPoolDistributeRewardsRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "distributeRewards", + account: this.wallet.account, + args: [request.groupId, request.token, request.ipIds], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method distributeRewards for contract EvenSplitGroupPool with only encode + * + * @param request EvenSplitGroupPoolDistributeRewardsRequest + * @return EncodedTxData + */ + public distributeRewardsEncode( + request: EvenSplitGroupPoolDistributeRewardsRequest, ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: accessControllerAbi, - functionName: "setBatchPermissions", - args: [request.permissions], + abi: evenSplitGroupPoolAbi, + functionName: "distributeRewards", + args: [request.groupId, request.token, request.ipIds], }), }; } /** - * method setPermission for contract AccessController + * method initialize for contract EvenSplitGroupPool * - * @param request AccessControllerSetPermissionRequest + * @param request EvenSplitGroupPoolInitializeRequest * @return Promise */ - public async setPermission( - request: AccessControllerSetPermissionRequest, + public async initialize( + request: EvenSplitGroupPoolInitializeRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: accessControllerAbi, + abi: evenSplitGroupPoolAbi, address: this.address, - functionName: "setPermission", + functionName: "initialize", account: this.wallet.account, - args: [request.ipAccount, request.signer, request.to, request.func, request.permission], + args: [request.accessManager], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method setPermission for contract AccessController with only encode + * method initialize for contract EvenSplitGroupPool with only encode * - * @param request AccessControllerSetPermissionRequest + * @param request EvenSplitGroupPoolInitializeRequest + * @return EncodedTxData + */ + public initializeEncode(request: EvenSplitGroupPoolInitializeRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: evenSplitGroupPoolAbi, + functionName: "initialize", + args: [request.accessManager], + }), + }; + } + + /** + * method pause for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolPauseRequest + * @return Promise + */ + public async pause(): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "pause", + account: this.wallet.account, + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method pause for contract EvenSplitGroupPool with only encode + * + * @param request EvenSplitGroupPoolPauseRequest + * @return EncodedTxData + */ + public pauseEncode(): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: evenSplitGroupPoolAbi, + functionName: "pause", + }), + }; + } + + /** + * method removeIp for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolRemoveIpRequest + * @return Promise + */ + public async removeIp( + request: EvenSplitGroupPoolRemoveIpRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "removeIp", + account: this.wallet.account, + args: [request.groupId, request.ipId], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method removeIp for contract EvenSplitGroupPool with only encode + * + * @param request EvenSplitGroupPoolRemoveIpRequest + * @return EncodedTxData + */ + public removeIpEncode(request: EvenSplitGroupPoolRemoveIpRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: evenSplitGroupPoolAbi, + functionName: "removeIp", + args: [request.groupId, request.ipId], + }), + }; + } + + /** + * method setAuthority for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolSetAuthorityRequest + * @return Promise + */ + public async setAuthority( + request: EvenSplitGroupPoolSetAuthorityRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "setAuthority", + account: this.wallet.account, + args: [request.newAuthority], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setAuthority for contract EvenSplitGroupPool with only encode + * + * @param request EvenSplitGroupPoolSetAuthorityRequest + * @return EncodedTxData + */ + public setAuthorityEncode(request: EvenSplitGroupPoolSetAuthorityRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: evenSplitGroupPoolAbi, + functionName: "setAuthority", + args: [request.newAuthority], + }), + }; + } + + /** + * method unpause for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolUnpauseRequest + * @return Promise + */ + public async unpause(): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "unpause", + account: this.wallet.account, + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method unpause for contract EvenSplitGroupPool with only encode + * + * @param request EvenSplitGroupPoolUnpauseRequest + * @return EncodedTxData + */ + public unpauseEncode(): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: evenSplitGroupPoolAbi, + functionName: "unpause", + }), + }; + } + + /** + * method upgradeToAndCall for contract EvenSplitGroupPool + * + * @param request EvenSplitGroupPoolUpgradeToAndCallRequest + * @return Promise + */ + public async upgradeToAndCall( + request: EvenSplitGroupPoolUpgradeToAndCallRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: evenSplitGroupPoolAbi, + address: this.address, + functionName: "upgradeToAndCall", + account: this.wallet.account, + args: [request.newImplementation, request.data], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method upgradeToAndCall for contract EvenSplitGroupPool with only encode + * + * @param request EvenSplitGroupPoolUpgradeToAndCallRequest * @return EncodedTxData */ - public setPermissionEncode(request: AccessControllerSetPermissionRequest): EncodedTxData { + public upgradeToAndCallEncode(request: EvenSplitGroupPoolUpgradeToAndCallRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: accessControllerAbi, - functionName: "setPermission", - args: [request.ipAccount, request.signer, request.to, request.func, request.permission], + abi: evenSplitGroupPoolAbi, + functionName: "upgradeToAndCall", + args: [request.newImplementation, request.data], }), }; } } -// Contract CoreMetadataModule ============================================================= +// Contract GroupingModule ============================================================= /** - * CoreMetadataModuleAuthorityUpdatedEvent + * GroupingModuleAddedIpToGroupEvent + * + * @param groupId address + * @param ipIds address[] + */ +export type GroupingModuleAddedIpToGroupEvent = { + groupId: Address; + ipIds: readonly Address[]; +}; + +/** + * GroupingModuleAuthorityUpdatedEvent * * @param authority address */ -export type CoreMetadataModuleAuthorityUpdatedEvent = { +export type GroupingModuleAuthorityUpdatedEvent = { authority: Address; }; /** - * CoreMetadataModuleInitializedEvent + * GroupingModuleClaimedRewardEvent + * + * @param groupId address + * @param token address + * @param ipId address[] + * @param amount uint256[] + */ +export type GroupingModuleClaimedRewardEvent = { + groupId: Address; + token: Address; + ipId: readonly Address[]; + amount: readonly bigint[]; +}; + +/** + * GroupingModuleCollectedRoyaltiesToGroupPoolEvent + * + * @param groupId address + * @param token address + * @param pool address + * @param amount uint256 + * @param snapshots uint256[] + */ +export type GroupingModuleCollectedRoyaltiesToGroupPoolEvent = { + groupId: Address; + token: Address; + pool: Address; + amount: bigint; + snapshots: readonly bigint[]; +}; + +/** + * GroupingModuleIpGroupRegisteredEvent + * + * @param groupId address + * @param groupPool address + */ +export type GroupingModuleIpGroupRegisteredEvent = { + groupId: Address; + groupPool: Address; +}; + +/** + * GroupingModuleInitializedEvent * * @param version uint64 */ -export type CoreMetadataModuleInitializedEvent = { +export type GroupingModuleInitializedEvent = { version: bigint; }; /** - * CoreMetadataModuleMetadataFrozenEvent + * GroupingModulePausedEvent * - * @param ipId address + * @param account address */ -export type CoreMetadataModuleMetadataFrozenEvent = { - ipId: Address; +export type GroupingModulePausedEvent = { + account: Address; }; /** - * CoreMetadataModuleMetadataUriSetEvent + * GroupingModuleRemovedIpFromGroupEvent * - * @param ipId address - * @param metadataURI string - * @param metadataHash bytes32 + * @param groupId address + * @param ipIds address[] */ -export type CoreMetadataModuleMetadataUriSetEvent = { - ipId: Address; - metadataURI: string; - metadataHash: Hex; +export type GroupingModuleRemovedIpFromGroupEvent = { + groupId: Address; + ipIds: readonly Address[]; }; /** - * CoreMetadataModuleNftTokenUriSetEvent + * GroupingModuleUnpausedEvent * - * @param ipId address - * @param nftTokenURI string - * @param nftMetadataHash bytes32 + * @param account address */ -export type CoreMetadataModuleNftTokenUriSetEvent = { - ipId: Address; - nftTokenURI: string; - nftMetadataHash: Hex; +export type GroupingModuleUnpausedEvent = { + account: Address; }; /** - * CoreMetadataModuleUpgradedEvent + * GroupingModuleUpgradedEvent * * @param implementation address */ -export type CoreMetadataModuleUpgradedEvent = { +export type GroupingModuleUpgradedEvent = { implementation: Address; }; -export type CoreMetadataModuleAccessControllerResponse = Address; +export type GroupingModuleAccessControllerResponse = Address; -export type CoreMetadataModuleIpAccountRegistryResponse = Address; +export type GroupingModuleGroupIpAssetRegistryResponse = Address; -export type CoreMetadataModuleUpgradeInterfaceVersionResponse = string; +export type GroupingModuleGroupNftResponse = Address; -export type CoreMetadataModuleAuthorityResponse = Address; +export type GroupingModuleIpAccountRegistryResponse = Address; -export type CoreMetadataModuleIsConsumingScheduledOpResponse = Hex; +export type GroupingModuleLicenseRegistryResponse = Address; + +export type GroupingModuleLicenseTokenResponse = Address; + +export type GroupingModuleRoyaltyModuleResponse = Address; + +export type GroupingModuleUpgradeInterfaceVersionResponse = string; + +export type GroupingModuleAuthorityResponse = Address; /** - * CoreMetadataModuleIsMetadataFrozenRequest + * GroupingModuleGetClaimableRewardRequest * - * @param ipId address + * @param groupId address + * @param token address + * @param ipIds address[] */ -export type CoreMetadataModuleIsMetadataFrozenRequest = { - ipId: Address; +export type GroupingModuleGetClaimableRewardRequest = { + groupId: Address; + token: Address; + ipIds: readonly Address[]; }; -export type CoreMetadataModuleIsMetadataFrozenResponse = boolean; +export type GroupingModuleGetClaimableRewardResponse = readonly bigint[]; -export type CoreMetadataModuleNameResponse = string; +export type GroupingModuleIsConsumingScheduledOpResponse = Hex; -export type CoreMetadataModuleProxiableUuidResponse = Hex; +export type GroupingModuleNameResponse = string; + +export type GroupingModulePausedResponse = boolean; + +export type GroupingModuleProxiableUuidResponse = Hex; /** - * CoreMetadataModuleSupportsInterfaceRequest + * GroupingModuleSupportsInterfaceRequest * * @param interfaceId bytes4 */ -export type CoreMetadataModuleSupportsInterfaceRequest = { +export type GroupingModuleSupportsInterfaceRequest = { interfaceId: Hex; }; -export type CoreMetadataModuleSupportsInterfaceResponse = boolean; +export type GroupingModuleSupportsInterfaceResponse = boolean; /** - * CoreMetadataModuleFreezeMetadataRequest + * GroupingModuleProtocolPausableInitRequest * - * @param ipId address + * @param accessManager address */ -export type CoreMetadataModuleFreezeMetadataRequest = { - ipId: Address; +export type GroupingModuleProtocolPausableInitRequest = { + accessManager: Address; }; /** - * CoreMetadataModuleInitializeRequest + * GroupingModuleAddIpRequest * - * @param accessManager address + * @param groupIpId address + * @param ipIds address[] */ -export type CoreMetadataModuleInitializeRequest = { - accessManager: Address; +export type GroupingModuleAddIpRequest = { + groupIpId: Address; + ipIds: readonly Address[]; }; /** - * CoreMetadataModuleSetAllRequest + * GroupingModuleClaimRewardRequest * - * @param ipId address - * @param metadataURI string - * @param metadataHash bytes32 - * @param nftMetadataHash bytes32 + * @param groupId address + * @param token address + * @param ipIds address[] */ -export type CoreMetadataModuleSetAllRequest = { - ipId: Address; - metadataURI: string; - metadataHash: Hex; - nftMetadataHash: Hex; +export type GroupingModuleClaimRewardRequest = { + groupId: Address; + token: Address; + ipIds: readonly Address[]; }; /** - * CoreMetadataModuleSetAuthorityRequest + * GroupingModuleCollectRoyaltiesRequest * - * @param newAuthority address + * @param groupId address + * @param token address + * @param snapshotIds uint256[] */ -export type CoreMetadataModuleSetAuthorityRequest = { - newAuthority: Address; +export type GroupingModuleCollectRoyaltiesRequest = { + groupId: Address; + token: Address; + snapshotIds: readonly bigint[]; }; /** - * CoreMetadataModuleSetMetadataUriRequest + * GroupingModuleInitializeRequest * - * @param ipId address - * @param metadataURI string - * @param metadataHash bytes32 + * @param accessManager address */ -export type CoreMetadataModuleSetMetadataUriRequest = { - ipId: Address; - metadataURI: string; - metadataHash: Hex; +export type GroupingModuleInitializeRequest = { + accessManager: Address; }; /** - * CoreMetadataModuleUpdateNftTokenUriRequest + * GroupingModuleRegisterGroupRequest * - * @param ipId address - * @param nftMetadataHash bytes32 + * @param groupPool address */ -export type CoreMetadataModuleUpdateNftTokenUriRequest = { - ipId: Address; - nftMetadataHash: Hex; +export type GroupingModuleRegisterGroupRequest = { + groupPool: Address; }; /** - * CoreMetadataModuleUpgradeToAndCallRequest + * GroupingModuleRemoveIpRequest + * + * @param groupIpId address + * @param ipIds address[] + */ +export type GroupingModuleRemoveIpRequest = { + groupIpId: Address; + ipIds: readonly Address[]; +}; + +/** + * GroupingModuleSetAuthorityRequest + * + * @param newAuthority address + */ +export type GroupingModuleSetAuthorityRequest = { + newAuthority: Address; +}; + +/** + * GroupingModuleUpgradeToAndCallRequest * * @param newImplementation address * @param data bytes */ -export type CoreMetadataModuleUpgradeToAndCallRequest = { +export type GroupingModuleUpgradeToAndCallRequest = { newImplementation: Address; data: Hex; }; /** - * contract CoreMetadataModule event + * GroupingModuleWhitelistGroupRewardPoolRequest + * + * @param rewardPool address */ -export class CoreMetadataModuleEventClient { +export type GroupingModuleWhitelistGroupRewardPoolRequest = { + rewardPool: Address; +}; + +/** + * contract GroupingModule event + */ +export class GroupingModuleEventClient { protected readonly rpcClient: PublicClient; public readonly address: Address; - constructor(rpcClient: PublicClient, address?: Address) { - this.address = address || getAddress(coreMetadataModuleAddress, rpcClient.chain?.id); - this.rpcClient = rpcClient; + constructor(rpcClient: PublicClient, address?: Address) { + this.address = address || getAddress(groupingModuleAddress, rpcClient.chain?.id); + this.rpcClient = rpcClient; + } + + /** + * event AddedIpToGroup for contract GroupingModule + */ + public watchAddedIpToGroupEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: groupingModuleAbi, + address: this.address, + eventName: "AddedIpToGroup", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event AddedIpToGroup for contract GroupingModule + */ + public parseTxAddedIpToGroupEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: groupingModuleAbi, + eventName: "AddedIpToGroup", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "AddedIpToGroup") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } + + /** + * event AuthorityUpdated for contract GroupingModule + */ + public watchAuthorityUpdatedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: groupingModuleAbi, + address: this.address, + eventName: "AuthorityUpdated", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event AuthorityUpdated for contract GroupingModule + */ + public parseTxAuthorityUpdatedEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: groupingModuleAbi, + eventName: "AuthorityUpdated", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "AuthorityUpdated") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } + + /** + * event ClaimedReward for contract GroupingModule + */ + public watchClaimedRewardEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: groupingModuleAbi, + address: this.address, + eventName: "ClaimedReward", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event ClaimedReward for contract GroupingModule + */ + public parseTxClaimedRewardEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: groupingModuleAbi, + eventName: "ClaimedReward", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "ClaimedReward") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } + + /** + * event CollectedRoyaltiesToGroupPool for contract GroupingModule + */ + public watchCollectedRoyaltiesToGroupPoolEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: groupingModuleAbi, + address: this.address, + eventName: "CollectedRoyaltiesToGroupPool", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event CollectedRoyaltiesToGroupPool for contract GroupingModule + */ + public parseTxCollectedRoyaltiesToGroupPoolEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: groupingModuleAbi, + eventName: "CollectedRoyaltiesToGroupPool", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "CollectedRoyaltiesToGroupPool") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; } /** - * event AuthorityUpdated for contract CoreMetadataModule + * event IPGroupRegistered for contract GroupingModule */ - public watchAuthorityUpdatedEvent( - onLogs: (txHash: Hex, ev: Partial) => void, + public watchIpGroupRegisteredEvent( + onLogs: (txHash: Hex, ev: Partial) => void, ): WatchContractEventReturnType { return this.rpcClient.watchContractEvent({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, address: this.address, - eventName: "AuthorityUpdated", + eventName: "IPGroupRegistered", onLogs: (evs) => { evs.forEach((it) => onLogs(it.transactionHash, it.args)); }, @@ -8339,21 +15264,21 @@ export class CoreMetadataModuleEventClient { } /** - * parse tx receipt event AuthorityUpdated for contract CoreMetadataModule + * parse tx receipt event IPGroupRegistered for contract GroupingModule */ - public parseTxAuthorityUpdatedEvent( + public parseTxIpGroupRegisteredEvent( txReceipt: TransactionReceipt, - ): Array { - const targetLogs: Array = []; + ): Array { + const targetLogs: Array = []; for (const log of txReceipt.logs) { try { const event = decodeEventLog({ - abi: coreMetadataModuleAbi, - eventName: "AuthorityUpdated", + abi: groupingModuleAbi, + eventName: "IPGroupRegistered", data: log.data, topics: log.topics, }); - if (event.eventName === "AuthorityUpdated") { + if (event.eventName === "IPGroupRegistered") { targetLogs.push(event.args); } } catch (e) { @@ -8364,13 +15289,13 @@ export class CoreMetadataModuleEventClient { } /** - * event Initialized for contract CoreMetadataModule + * event Initialized for contract GroupingModule */ public watchInitializedEvent( - onLogs: (txHash: Hex, ev: Partial) => void, + onLogs: (txHash: Hex, ev: Partial) => void, ): WatchContractEventReturnType { return this.rpcClient.watchContractEvent({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, address: this.address, eventName: "Initialized", onLogs: (evs) => { @@ -8380,16 +15305,16 @@ export class CoreMetadataModuleEventClient { } /** - * parse tx receipt event Initialized for contract CoreMetadataModule + * parse tx receipt event Initialized for contract GroupingModule */ public parseTxInitializedEvent( txReceipt: TransactionReceipt, - ): Array { - const targetLogs: Array = []; + ): Array { + const targetLogs: Array = []; for (const log of txReceipt.logs) { try { const event = decodeEventLog({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, eventName: "Initialized", data: log.data, topics: log.topics, @@ -8405,15 +15330,15 @@ export class CoreMetadataModuleEventClient { } /** - * event MetadataFrozen for contract CoreMetadataModule + * event Paused for contract GroupingModule */ - public watchMetadataFrozenEvent( - onLogs: (txHash: Hex, ev: Partial) => void, + public watchPausedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, ): WatchContractEventReturnType { return this.rpcClient.watchContractEvent({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, address: this.address, - eventName: "MetadataFrozen", + eventName: "Paused", onLogs: (evs) => { evs.forEach((it) => onLogs(it.transactionHash, it.args)); }, @@ -8421,21 +15346,19 @@ export class CoreMetadataModuleEventClient { } /** - * parse tx receipt event MetadataFrozen for contract CoreMetadataModule + * parse tx receipt event Paused for contract GroupingModule */ - public parseTxMetadataFrozenEvent( - txReceipt: TransactionReceipt, - ): Array { - const targetLogs: Array = []; + public parseTxPausedEvent(txReceipt: TransactionReceipt): Array { + const targetLogs: Array = []; for (const log of txReceipt.logs) { try { const event = decodeEventLog({ - abi: coreMetadataModuleAbi, - eventName: "MetadataFrozen", + abi: groupingModuleAbi, + eventName: "Paused", data: log.data, topics: log.topics, }); - if (event.eventName === "MetadataFrozen") { + if (event.eventName === "Paused") { targetLogs.push(event.args); } } catch (e) { @@ -8446,15 +15369,15 @@ export class CoreMetadataModuleEventClient { } /** - * event MetadataURISet for contract CoreMetadataModule + * event RemovedIpFromGroup for contract GroupingModule */ - public watchMetadataUriSetEvent( - onLogs: (txHash: Hex, ev: Partial) => void, + public watchRemovedIpFromGroupEvent( + onLogs: (txHash: Hex, ev: Partial) => void, ): WatchContractEventReturnType { return this.rpcClient.watchContractEvent({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, address: this.address, - eventName: "MetadataURISet", + eventName: "RemovedIpFromGroup", onLogs: (evs) => { evs.forEach((it) => onLogs(it.transactionHash, it.args)); }, @@ -8462,21 +15385,21 @@ export class CoreMetadataModuleEventClient { } /** - * parse tx receipt event MetadataURISet for contract CoreMetadataModule + * parse tx receipt event RemovedIpFromGroup for contract GroupingModule */ - public parseTxMetadataUriSetEvent( + public parseTxRemovedIpFromGroupEvent( txReceipt: TransactionReceipt, - ): Array { - const targetLogs: Array = []; + ): Array { + const targetLogs: Array = []; for (const log of txReceipt.logs) { try { const event = decodeEventLog({ - abi: coreMetadataModuleAbi, - eventName: "MetadataURISet", + abi: groupingModuleAbi, + eventName: "RemovedIpFromGroup", data: log.data, topics: log.topics, }); - if (event.eventName === "MetadataURISet") { + if (event.eventName === "RemovedIpFromGroup") { targetLogs.push(event.args); } } catch (e) { @@ -8487,15 +15410,15 @@ export class CoreMetadataModuleEventClient { } /** - * event NFTTokenURISet for contract CoreMetadataModule + * event Unpaused for contract GroupingModule */ - public watchNftTokenUriSetEvent( - onLogs: (txHash: Hex, ev: Partial) => void, + public watchUnpausedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, ): WatchContractEventReturnType { return this.rpcClient.watchContractEvent({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, address: this.address, - eventName: "NFTTokenURISet", + eventName: "Unpaused", onLogs: (evs) => { evs.forEach((it) => onLogs(it.transactionHash, it.args)); }, @@ -8503,21 +15426,19 @@ export class CoreMetadataModuleEventClient { } /** - * parse tx receipt event NFTTokenURISet for contract CoreMetadataModule + * parse tx receipt event Unpaused for contract GroupingModule */ - public parseTxNftTokenUriSetEvent( - txReceipt: TransactionReceipt, - ): Array { - const targetLogs: Array = []; + public parseTxUnpausedEvent(txReceipt: TransactionReceipt): Array { + const targetLogs: Array = []; for (const log of txReceipt.logs) { try { const event = decodeEventLog({ - abi: coreMetadataModuleAbi, - eventName: "NFTTokenURISet", + abi: groupingModuleAbi, + eventName: "Unpaused", data: log.data, topics: log.topics, }); - if (event.eventName === "NFTTokenURISet") { + if (event.eventName === "Unpaused") { targetLogs.push(event.args); } } catch (e) { @@ -8528,13 +15449,13 @@ export class CoreMetadataModuleEventClient { } /** - * event Upgraded for contract CoreMetadataModule + * event Upgraded for contract GroupingModule */ public watchUpgradedEvent( - onLogs: (txHash: Hex, ev: Partial) => void, + onLogs: (txHash: Hex, ev: Partial) => void, ): WatchContractEventReturnType { return this.rpcClient.watchContractEvent({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, address: this.address, eventName: "Upgraded", onLogs: (evs) => { @@ -8544,16 +15465,14 @@ export class CoreMetadataModuleEventClient { } /** - * parse tx receipt event Upgraded for contract CoreMetadataModule + * parse tx receipt event Upgraded for contract GroupingModule */ - public parseTxUpgradedEvent( - txReceipt: TransactionReceipt, - ): Array { - const targetLogs: Array = []; + public parseTxUpgradedEvent(txReceipt: TransactionReceipt): Array { + const targetLogs: Array = []; for (const log of txReceipt.logs) { try { const event = decodeEventLog({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, eventName: "Upgraded", data: log.data, topics: log.topics, @@ -8570,274 +15489,534 @@ export class CoreMetadataModuleEventClient { } /** - * contract CoreMetadataModule readonly method + * contract GroupingModule readonly method */ -export class CoreMetadataModuleReadOnlyClient extends CoreMetadataModuleEventClient { +export class GroupingModuleReadOnlyClient extends GroupingModuleEventClient { constructor(rpcClient: PublicClient, address?: Address) { super(rpcClient, address); } /** - * method ACCESS_CONTROLLER for contract CoreMetadataModule + * method ACCESS_CONTROLLER for contract GroupingModule * - * @param request CoreMetadataModuleAccessControllerRequest - * @return Promise + * @param request GroupingModuleAccessControllerRequest + * @return Promise */ - public async accessController(): Promise { + public async accessController(): Promise { return await this.rpcClient.readContract({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, address: this.address, functionName: "ACCESS_CONTROLLER", }); } /** - * method IP_ACCOUNT_REGISTRY for contract CoreMetadataModule + * method GROUP_IP_ASSET_REGISTRY for contract GroupingModule * - * @param request CoreMetadataModuleIpAccountRegistryRequest - * @return Promise + * @param request GroupingModuleGroupIpAssetRegistryRequest + * @return Promise */ - public async ipAccountRegistry(): Promise { + public async groupIpAssetRegistry(): Promise { return await this.rpcClient.readContract({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, + address: this.address, + functionName: "GROUP_IP_ASSET_REGISTRY", + }); + } + + /** + * method GROUP_NFT for contract GroupingModule + * + * @param request GroupingModuleGroupNftRequest + * @return Promise + */ + public async groupNft(): Promise { + return await this.rpcClient.readContract({ + abi: groupingModuleAbi, + address: this.address, + functionName: "GROUP_NFT", + }); + } + + /** + * method IP_ACCOUNT_REGISTRY for contract GroupingModule + * + * @param request GroupingModuleIpAccountRegistryRequest + * @return Promise + */ + public async ipAccountRegistry(): Promise { + return await this.rpcClient.readContract({ + abi: groupingModuleAbi, address: this.address, functionName: "IP_ACCOUNT_REGISTRY", }); } /** - * method UPGRADE_INTERFACE_VERSION for contract CoreMetadataModule + * method LICENSE_REGISTRY for contract GroupingModule * - * @param request CoreMetadataModuleUpgradeInterfaceVersionRequest - * @return Promise + * @param request GroupingModuleLicenseRegistryRequest + * @return Promise */ - public async upgradeInterfaceVersion(): Promise { + public async licenseRegistry(): Promise { return await this.rpcClient.readContract({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, + address: this.address, + functionName: "LICENSE_REGISTRY", + }); + } + + /** + * method LICENSE_TOKEN for contract GroupingModule + * + * @param request GroupingModuleLicenseTokenRequest + * @return Promise + */ + public async licenseToken(): Promise { + return await this.rpcClient.readContract({ + abi: groupingModuleAbi, + address: this.address, + functionName: "LICENSE_TOKEN", + }); + } + + /** + * method ROYALTY_MODULE for contract GroupingModule + * + * @param request GroupingModuleRoyaltyModuleRequest + * @return Promise + */ + public async royaltyModule(): Promise { + return await this.rpcClient.readContract({ + abi: groupingModuleAbi, + address: this.address, + functionName: "ROYALTY_MODULE", + }); + } + + /** + * method UPGRADE_INTERFACE_VERSION for contract GroupingModule + * + * @param request GroupingModuleUpgradeInterfaceVersionRequest + * @return Promise + */ + public async upgradeInterfaceVersion(): Promise { + return await this.rpcClient.readContract({ + abi: groupingModuleAbi, + address: this.address, + functionName: "UPGRADE_INTERFACE_VERSION", + }); + } + + /** + * method authority for contract GroupingModule + * + * @param request GroupingModuleAuthorityRequest + * @return Promise + */ + public async authority(): Promise { + return await this.rpcClient.readContract({ + abi: groupingModuleAbi, + address: this.address, + functionName: "authority", + }); + } + + /** + * method getClaimableReward for contract GroupingModule + * + * @param request GroupingModuleGetClaimableRewardRequest + * @return Promise + */ + public async getClaimableReward( + request: GroupingModuleGetClaimableRewardRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: groupingModuleAbi, + address: this.address, + functionName: "getClaimableReward", + args: [request.groupId, request.token, request.ipIds], + }); + } + + /** + * method isConsumingScheduledOp for contract GroupingModule + * + * @param request GroupingModuleIsConsumingScheduledOpRequest + * @return Promise + */ + public async isConsumingScheduledOp(): Promise { + return await this.rpcClient.readContract({ + abi: groupingModuleAbi, + address: this.address, + functionName: "isConsumingScheduledOp", + }); + } + + /** + * method name for contract GroupingModule + * + * @param request GroupingModuleNameRequest + * @return Promise + */ + public async name(): Promise { + return await this.rpcClient.readContract({ + abi: groupingModuleAbi, + address: this.address, + functionName: "name", + }); + } + + /** + * method paused for contract GroupingModule + * + * @param request GroupingModulePausedRequest + * @return Promise + */ + public async paused(): Promise { + return await this.rpcClient.readContract({ + abi: groupingModuleAbi, + address: this.address, + functionName: "paused", + }); + } + + /** + * method proxiableUUID for contract GroupingModule + * + * @param request GroupingModuleProxiableUuidRequest + * @return Promise + */ + public async proxiableUuid(): Promise { + return await this.rpcClient.readContract({ + abi: groupingModuleAbi, + address: this.address, + functionName: "proxiableUUID", + }); + } + + /** + * method supportsInterface for contract GroupingModule + * + * @param request GroupingModuleSupportsInterfaceRequest + * @return Promise + */ + public async supportsInterface( + request: GroupingModuleSupportsInterfaceRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: groupingModuleAbi, + address: this.address, + functionName: "supportsInterface", + args: [request.interfaceId], + }); + } +} + +/** + * contract GroupingModule write method + */ +export class GroupingModuleClient extends GroupingModuleReadOnlyClient { + protected readonly wallet: SimpleWalletClient; + + constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { + super(rpcClient, address); + this.wallet = wallet; + } + + /** + * method __ProtocolPausable_init for contract GroupingModule + * + * @param request GroupingModuleProtocolPausableInitRequest + * @return Promise + */ + public async protocolPausableInit( + request: GroupingModuleProtocolPausableInitRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: groupingModuleAbi, + address: this.address, + functionName: "__ProtocolPausable_init", + account: this.wallet.account, + args: [request.accessManager], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method __ProtocolPausable_init for contract GroupingModule with only encode + * + * @param request GroupingModuleProtocolPausableInitRequest + * @return EncodedTxData + */ + public protocolPausableInitEncode( + request: GroupingModuleProtocolPausableInitRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: groupingModuleAbi, + functionName: "__ProtocolPausable_init", + args: [request.accessManager], + }), + }; + } + + /** + * method addIp for contract GroupingModule + * + * @param request GroupingModuleAddIpRequest + * @return Promise + */ + public async addIp(request: GroupingModuleAddIpRequest): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: groupingModuleAbi, address: this.address, - functionName: "UPGRADE_INTERFACE_VERSION", + functionName: "addIp", + account: this.wallet.account, + args: [request.groupIpId, request.ipIds], }); + return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method authority for contract CoreMetadataModule + * method addIp for contract GroupingModule with only encode * - * @param request CoreMetadataModuleAuthorityRequest - * @return Promise + * @param request GroupingModuleAddIpRequest + * @return EncodedTxData */ - public async authority(): Promise { - return await this.rpcClient.readContract({ - abi: coreMetadataModuleAbi, - address: this.address, - functionName: "authority", - }); + public addIpEncode(request: GroupingModuleAddIpRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: groupingModuleAbi, + functionName: "addIp", + args: [request.groupIpId, request.ipIds], + }), + }; } /** - * method isConsumingScheduledOp for contract CoreMetadataModule + * method claimReward for contract GroupingModule * - * @param request CoreMetadataModuleIsConsumingScheduledOpRequest - * @return Promise + * @param request GroupingModuleClaimRewardRequest + * @return Promise */ - public async isConsumingScheduledOp(): Promise { - return await this.rpcClient.readContract({ - abi: coreMetadataModuleAbi, + public async claimReward( + request: GroupingModuleClaimRewardRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: groupingModuleAbi, address: this.address, - functionName: "isConsumingScheduledOp", + functionName: "claimReward", + account: this.wallet.account, + args: [request.groupId, request.token, request.ipIds], }); + return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method isMetadataFrozen for contract CoreMetadataModule + * method claimReward for contract GroupingModule with only encode * - * @param request CoreMetadataModuleIsMetadataFrozenRequest - * @return Promise + * @param request GroupingModuleClaimRewardRequest + * @return EncodedTxData */ - public async isMetadataFrozen( - request: CoreMetadataModuleIsMetadataFrozenRequest, - ): Promise { - return await this.rpcClient.readContract({ - abi: coreMetadataModuleAbi, - address: this.address, - functionName: "isMetadataFrozen", - args: [request.ipId], - }); + public claimRewardEncode(request: GroupingModuleClaimRewardRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: groupingModuleAbi, + functionName: "claimReward", + args: [request.groupId, request.token, request.ipIds], + }), + }; } /** - * method name for contract CoreMetadataModule + * method collectRoyalties for contract GroupingModule * - * @param request CoreMetadataModuleNameRequest - * @return Promise + * @param request GroupingModuleCollectRoyaltiesRequest + * @return Promise */ - public async name(): Promise { - return await this.rpcClient.readContract({ - abi: coreMetadataModuleAbi, + public async collectRoyalties( + request: GroupingModuleCollectRoyaltiesRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: groupingModuleAbi, address: this.address, - functionName: "name", + functionName: "collectRoyalties", + account: this.wallet.account, + args: [request.groupId, request.token, request.snapshotIds], }); + return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method proxiableUUID for contract CoreMetadataModule + * method collectRoyalties for contract GroupingModule with only encode * - * @param request CoreMetadataModuleProxiableUuidRequest - * @return Promise + * @param request GroupingModuleCollectRoyaltiesRequest + * @return EncodedTxData */ - public async proxiableUuid(): Promise { - return await this.rpcClient.readContract({ - abi: coreMetadataModuleAbi, - address: this.address, - functionName: "proxiableUUID", - }); + public collectRoyaltiesEncode(request: GroupingModuleCollectRoyaltiesRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: groupingModuleAbi, + functionName: "collectRoyalties", + args: [request.groupId, request.token, request.snapshotIds], + }), + }; } /** - * method supportsInterface for contract CoreMetadataModule + * method initialize for contract GroupingModule * - * @param request CoreMetadataModuleSupportsInterfaceRequest - * @return Promise + * @param request GroupingModuleInitializeRequest + * @return Promise */ - public async supportsInterface( - request: CoreMetadataModuleSupportsInterfaceRequest, - ): Promise { - return await this.rpcClient.readContract({ - abi: coreMetadataModuleAbi, + public async initialize( + request: GroupingModuleInitializeRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: groupingModuleAbi, address: this.address, - functionName: "supportsInterface", - args: [request.interfaceId], + functionName: "initialize", + account: this.wallet.account, + args: [request.accessManager], }); + return await this.wallet.writeContract(call as WriteContractParameters); } -} - -/** - * contract CoreMetadataModule write method - */ -export class CoreMetadataModuleClient extends CoreMetadataModuleReadOnlyClient { - protected readonly wallet: SimpleWalletClient; - constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { - super(rpcClient, address); - this.wallet = wallet; + /** + * method initialize for contract GroupingModule with only encode + * + * @param request GroupingModuleInitializeRequest + * @return EncodedTxData + */ + public initializeEncode(request: GroupingModuleInitializeRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: groupingModuleAbi, + functionName: "initialize", + args: [request.accessManager], + }), + }; } /** - * method freezeMetadata for contract CoreMetadataModule + * method pause for contract GroupingModule * - * @param request CoreMetadataModuleFreezeMetadataRequest + * @param request GroupingModulePauseRequest * @return Promise */ - public async freezeMetadata( - request: CoreMetadataModuleFreezeMetadataRequest, - ): Promise { + public async pause(): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, address: this.address, - functionName: "freezeMetadata", + functionName: "pause", account: this.wallet.account, - args: [request.ipId], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method freezeMetadata for contract CoreMetadataModule with only encode + * method pause for contract GroupingModule with only encode * - * @param request CoreMetadataModuleFreezeMetadataRequest + * @param request GroupingModulePauseRequest * @return EncodedTxData */ - public freezeMetadataEncode(request: CoreMetadataModuleFreezeMetadataRequest): EncodedTxData { + public pauseEncode(): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: coreMetadataModuleAbi, - functionName: "freezeMetadata", - args: [request.ipId], + abi: groupingModuleAbi, + functionName: "pause", }), }; } /** - * method initialize for contract CoreMetadataModule + * method registerGroup for contract GroupingModule * - * @param request CoreMetadataModuleInitializeRequest + * @param request GroupingModuleRegisterGroupRequest * @return Promise */ - public async initialize( - request: CoreMetadataModuleInitializeRequest, + public async registerGroup( + request: GroupingModuleRegisterGroupRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, address: this.address, - functionName: "initialize", + functionName: "registerGroup", account: this.wallet.account, - args: [request.accessManager], + args: [request.groupPool], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method initialize for contract CoreMetadataModule with only encode + * method registerGroup for contract GroupingModule with only encode * - * @param request CoreMetadataModuleInitializeRequest + * @param request GroupingModuleRegisterGroupRequest * @return EncodedTxData */ - public initializeEncode(request: CoreMetadataModuleInitializeRequest): EncodedTxData { + public registerGroupEncode(request: GroupingModuleRegisterGroupRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: coreMetadataModuleAbi, - functionName: "initialize", - args: [request.accessManager], + abi: groupingModuleAbi, + functionName: "registerGroup", + args: [request.groupPool], }), }; } /** - * method setAll for contract CoreMetadataModule + * method removeIp for contract GroupingModule * - * @param request CoreMetadataModuleSetAllRequest + * @param request GroupingModuleRemoveIpRequest * @return Promise */ - public async setAll(request: CoreMetadataModuleSetAllRequest): Promise { + public async removeIp(request: GroupingModuleRemoveIpRequest): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, address: this.address, - functionName: "setAll", + functionName: "removeIp", account: this.wallet.account, - args: [request.ipId, request.metadataURI, request.metadataHash, request.nftMetadataHash], + args: [request.groupIpId, request.ipIds], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method setAll for contract CoreMetadataModule with only encode + * method removeIp for contract GroupingModule with only encode * - * @param request CoreMetadataModuleSetAllRequest + * @param request GroupingModuleRemoveIpRequest * @return EncodedTxData */ - public setAllEncode(request: CoreMetadataModuleSetAllRequest): EncodedTxData { + public removeIpEncode(request: GroupingModuleRemoveIpRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: coreMetadataModuleAbi, - functionName: "setAll", - args: [request.ipId, request.metadataURI, request.metadataHash, request.nftMetadataHash], + abi: groupingModuleAbi, + functionName: "removeIp", + args: [request.groupIpId, request.ipIds], }), }; } /** - * method setAuthority for contract CoreMetadataModule + * method setAuthority for contract GroupingModule * - * @param request CoreMetadataModuleSetAuthorityRequest + * @param request GroupingModuleSetAuthorityRequest * @return Promise */ public async setAuthority( - request: CoreMetadataModuleSetAuthorityRequest, + request: GroupingModuleSetAuthorityRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, address: this.address, functionName: "setAuthority", account: this.wallet.account, @@ -8847,16 +16026,16 @@ export class CoreMetadataModuleClient extends CoreMetadataModuleReadOnlyClient { } /** - * method setAuthority for contract CoreMetadataModule with only encode + * method setAuthority for contract GroupingModule with only encode * - * @param request CoreMetadataModuleSetAuthorityRequest + * @param request GroupingModuleSetAuthorityRequest * @return EncodedTxData */ - public setAuthorityEncode(request: CoreMetadataModuleSetAuthorityRequest): EncodedTxData { + public setAuthorityEncode(request: GroupingModuleSetAuthorityRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, functionName: "setAuthority", args: [request.newAuthority], }), @@ -8864,447 +16043,404 @@ export class CoreMetadataModuleClient extends CoreMetadataModuleReadOnlyClient { } /** - * method setMetadataURI for contract CoreMetadataModule + * method unpause for contract GroupingModule * - * @param request CoreMetadataModuleSetMetadataUriRequest + * @param request GroupingModuleUnpauseRequest * @return Promise */ - public async setMetadataUri( - request: CoreMetadataModuleSetMetadataUriRequest, - ): Promise { + public async unpause(): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, address: this.address, - functionName: "setMetadataURI", + functionName: "unpause", account: this.wallet.account, - args: [request.ipId, request.metadataURI, request.metadataHash], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method setMetadataURI for contract CoreMetadataModule with only encode + * method unpause for contract GroupingModule with only encode * - * @param request CoreMetadataModuleSetMetadataUriRequest + * @param request GroupingModuleUnpauseRequest * @return EncodedTxData */ - public setMetadataUriEncode(request: CoreMetadataModuleSetMetadataUriRequest): EncodedTxData { + public unpauseEncode(): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: coreMetadataModuleAbi, - functionName: "setMetadataURI", - args: [request.ipId, request.metadataURI, request.metadataHash], + abi: groupingModuleAbi, + functionName: "unpause", }), }; } /** - * method updateNftTokenURI for contract CoreMetadataModule + * method upgradeToAndCall for contract GroupingModule * - * @param request CoreMetadataModuleUpdateNftTokenUriRequest + * @param request GroupingModuleUpgradeToAndCallRequest * @return Promise */ - public async updateNftTokenUri( - request: CoreMetadataModuleUpdateNftTokenUriRequest, + public async upgradeToAndCall( + request: GroupingModuleUpgradeToAndCallRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, address: this.address, - functionName: "updateNftTokenURI", + functionName: "upgradeToAndCall", account: this.wallet.account, - args: [request.ipId, request.nftMetadataHash], + args: [request.newImplementation, request.data], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method updateNftTokenURI for contract CoreMetadataModule with only encode + * method upgradeToAndCall for contract GroupingModule with only encode * - * @param request CoreMetadataModuleUpdateNftTokenUriRequest + * @param request GroupingModuleUpgradeToAndCallRequest * @return EncodedTxData */ - public updateNftTokenUriEncode( - request: CoreMetadataModuleUpdateNftTokenUriRequest, - ): EncodedTxData { + public upgradeToAndCallEncode(request: GroupingModuleUpgradeToAndCallRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: coreMetadataModuleAbi, - functionName: "updateNftTokenURI", - args: [request.ipId, request.nftMetadataHash], + abi: groupingModuleAbi, + functionName: "upgradeToAndCall", + args: [request.newImplementation, request.data], }), }; } /** - * method upgradeToAndCall for contract CoreMetadataModule + * method whitelistGroupRewardPool for contract GroupingModule * - * @param request CoreMetadataModuleUpgradeToAndCallRequest + * @param request GroupingModuleWhitelistGroupRewardPoolRequest * @return Promise */ - public async upgradeToAndCall( - request: CoreMetadataModuleUpgradeToAndCallRequest, + public async whitelistGroupRewardPool( + request: GroupingModuleWhitelistGroupRewardPoolRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: coreMetadataModuleAbi, + abi: groupingModuleAbi, address: this.address, - functionName: "upgradeToAndCall", + functionName: "whitelistGroupRewardPool", account: this.wallet.account, - args: [request.newImplementation, request.data], + args: [request.rewardPool], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method upgradeToAndCall for contract CoreMetadataModule with only encode + * method whitelistGroupRewardPool for contract GroupingModule with only encode * - * @param request CoreMetadataModuleUpgradeToAndCallRequest + * @param request GroupingModuleWhitelistGroupRewardPoolRequest * @return EncodedTxData */ - public upgradeToAndCallEncode(request: CoreMetadataModuleUpgradeToAndCallRequest): EncodedTxData { + public whitelistGroupRewardPoolEncode( + request: GroupingModuleWhitelistGroupRewardPoolRequest, + ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: coreMetadataModuleAbi, - functionName: "upgradeToAndCall", - args: [request.newImplementation, request.data], + abi: groupingModuleAbi, + functionName: "whitelistGroupRewardPool", + args: [request.rewardPool], }), }; } } -// Contract DisputeModule ============================================================= - -/** - * DisputeModuleDisputeCancelledEvent - * - * @param disputeId uint256 - * @param data bytes - */ -export type DisputeModuleDisputeCancelledEvent = { - disputeId: bigint; - data: Hex; -}; - -/** - * DisputeModuleDisputeRaisedEvent - * - * @param disputeId uint256 - * @param targetIpId address - * @param disputeInitiator address - * @param arbitrationPolicy address - * @param linkToDisputeEvidence bytes32 - * @param targetTag bytes32 - * @param data bytes - */ -export type DisputeModuleDisputeRaisedEvent = { - disputeId: bigint; - targetIpId: Address; - disputeInitiator: Address; - arbitrationPolicy: Address; - linkToDisputeEvidence: Hex; - targetTag: Hex; - data: Hex; -}; +// Contract GroupingWorkflows ============================================================= /** - * DisputeModuleDisputeResolvedEvent + * GroupingWorkflowsMintAndRegisterIpAndAttachLicenseAndAddToGroupRequest * - * @param disputeId uint256 + * @param spgNftContract address + * @param groupId address + * @param recipient address + * @param licenseTemplate address + * @param licenseTermsId uint256 + * @param ipMetadata tuple + * @param sigAddToGroup tuple */ -export type DisputeModuleDisputeResolvedEvent = { - disputeId: bigint; +export type GroupingWorkflowsMintAndRegisterIpAndAttachLicenseAndAddToGroupRequest = { + spgNftContract: Address; + groupId: Address; + recipient: Address; + licenseTemplate: Address; + licenseTermsId: bigint; + ipMetadata: { + ipMetadataURI: string; + ipMetadataHash: Hex; + nftMetadataURI: string; + nftMetadataHash: Hex; + }; + sigAddToGroup: { + signer: Address; + deadline: bigint; + signature: Hex; + }; }; /** - * DisputeModuleCancelDisputeRequest + * GroupingWorkflowsRegisterGroupAndAttachLicenseRequest * - * @param disputeId uint256 - * @param data bytes + * @param groupPool address + * @param licenseTemplate address + * @param licenseTermsId uint256 */ -export type DisputeModuleCancelDisputeRequest = { - disputeId: bigint; - data: Hex; +export type GroupingWorkflowsRegisterGroupAndAttachLicenseRequest = { + groupPool: Address; + licenseTemplate: Address; + licenseTermsId: bigint; }; /** - * DisputeModuleRaiseDisputeRequest + * GroupingWorkflowsRegisterGroupAndAttachLicenseAndAddIpsRequest * - * @param targetIpId address - * @param linkToDisputeEvidence string - * @param targetTag bytes32 - * @param data bytes + * @param groupPool address + * @param ipIds address[] + * @param licenseTemplate address + * @param licenseTermsId uint256 */ -export type DisputeModuleRaiseDisputeRequest = { - targetIpId: Address; - linkToDisputeEvidence: string; - targetTag: Hex; - data: Hex; +export type GroupingWorkflowsRegisterGroupAndAttachLicenseAndAddIpsRequest = { + groupPool: Address; + ipIds: readonly Address[]; + licenseTemplate: Address; + licenseTermsId: bigint; }; /** - * DisputeModuleResolveDisputeRequest + * GroupingWorkflowsRegisterIpAndAttachLicenseAndAddToGroupRequest * - * @param disputeId uint256 - * @param data bytes + * @param nftContract address + * @param tokenId uint256 + * @param groupId address + * @param licenseTemplate address + * @param licenseTermsId uint256 + * @param ipMetadata tuple + * @param sigMetadataAndAttach tuple + * @param sigAddToGroup tuple */ -export type DisputeModuleResolveDisputeRequest = { - disputeId: bigint; - data: Hex; +export type GroupingWorkflowsRegisterIpAndAttachLicenseAndAddToGroupRequest = { + nftContract: Address; + tokenId: bigint; + groupId: Address; + licenseTemplate: Address; + licenseTermsId: bigint; + ipMetadata: { + ipMetadataURI: string; + ipMetadataHash: Hex; + nftMetadataURI: string; + nftMetadataHash: Hex; + }; + sigMetadataAndAttach: { + signer: Address; + deadline: bigint; + signature: Hex; + }; + sigAddToGroup: { + signer: Address; + deadline: bigint; + signature: Hex; + }; }; /** - * contract DisputeModule event + * contract GroupingWorkflows write method */ -export class DisputeModuleEventClient { +export class GroupingWorkflowsClient { + protected readonly wallet: SimpleWalletClient; protected readonly rpcClient: PublicClient; public readonly address: Address; - constructor(rpcClient: PublicClient, address?: Address) { - this.address = address || getAddress(disputeModuleAddress, rpcClient.chain?.id); + constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { + this.address = address || getAddress(groupingWorkflowsAddress, rpcClient.chain?.id); this.rpcClient = rpcClient; + this.wallet = wallet; } /** - * event DisputeCancelled for contract DisputeModule - */ - public watchDisputeCancelledEvent( - onLogs: (txHash: Hex, ev: Partial) => void, - ): WatchContractEventReturnType { - return this.rpcClient.watchContractEvent({ - abi: disputeModuleAbi, - address: this.address, - eventName: "DisputeCancelled", - onLogs: (evs) => { - evs.forEach((it) => onLogs(it.transactionHash, it.args)); - }, - }); - } - - /** - * parse tx receipt event DisputeCancelled for contract DisputeModule - */ - public parseTxDisputeCancelledEvent( - txReceipt: TransactionReceipt, - ): Array { - const targetLogs: Array = []; - for (const log of txReceipt.logs) { - try { - const event = decodeEventLog({ - abi: disputeModuleAbi, - eventName: "DisputeCancelled", - data: log.data, - topics: log.topics, - }); - if (event.eventName === "DisputeCancelled") { - targetLogs.push(event.args); - } - } catch (e) { - /* empty */ - } - } - return targetLogs; - } - - /** - * event DisputeRaised for contract DisputeModule - */ - public watchDisputeRaisedEvent( - onLogs: (txHash: Hex, ev: Partial) => void, - ): WatchContractEventReturnType { - return this.rpcClient.watchContractEvent({ - abi: disputeModuleAbi, - address: this.address, - eventName: "DisputeRaised", - onLogs: (evs) => { - evs.forEach((it) => onLogs(it.transactionHash, it.args)); - }, - }); - } - - /** - * parse tx receipt event DisputeRaised for contract DisputeModule - */ - public parseTxDisputeRaisedEvent( - txReceipt: TransactionReceipt, - ): Array { - const targetLogs: Array = []; - for (const log of txReceipt.logs) { - try { - const event = decodeEventLog({ - abi: disputeModuleAbi, - eventName: "DisputeRaised", - data: log.data, - topics: log.topics, - }); - if (event.eventName === "DisputeRaised") { - targetLogs.push(event.args); - } - } catch (e) { - /* empty */ - } - } - return targetLogs; - } - - /** - * event DisputeResolved for contract DisputeModule + * method mintAndRegisterIpAndAttachLicenseAndAddToGroup for contract GroupingWorkflows + * + * @param request GroupingWorkflowsMintAndRegisterIpAndAttachLicenseAndAddToGroupRequest + * @return Promise */ - public watchDisputeResolvedEvent( - onLogs: (txHash: Hex, ev: Partial) => void, - ): WatchContractEventReturnType { - return this.rpcClient.watchContractEvent({ - abi: disputeModuleAbi, + public async mintAndRegisterIpAndAttachLicenseAndAddToGroup( + request: GroupingWorkflowsMintAndRegisterIpAndAttachLicenseAndAddToGroupRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: groupingWorkflowsAbi, address: this.address, - eventName: "DisputeResolved", - onLogs: (evs) => { - evs.forEach((it) => onLogs(it.transactionHash, it.args)); - }, + functionName: "mintAndRegisterIpAndAttachLicenseAndAddToGroup", + account: this.wallet.account, + args: [ + request.spgNftContract, + request.groupId, + request.recipient, + request.licenseTemplate, + request.licenseTermsId, + request.ipMetadata, + request.sigAddToGroup, + ], }); + return await this.wallet.writeContract(call as WriteContractParameters); } /** - * parse tx receipt event DisputeResolved for contract DisputeModule + * method mintAndRegisterIpAndAttachLicenseAndAddToGroup for contract GroupingWorkflows with only encode + * + * @param request GroupingWorkflowsMintAndRegisterIpAndAttachLicenseAndAddToGroupRequest + * @return EncodedTxData */ - public parseTxDisputeResolvedEvent( - txReceipt: TransactionReceipt, - ): Array { - const targetLogs: Array = []; - for (const log of txReceipt.logs) { - try { - const event = decodeEventLog({ - abi: disputeModuleAbi, - eventName: "DisputeResolved", - data: log.data, - topics: log.topics, - }); - if (event.eventName === "DisputeResolved") { - targetLogs.push(event.args); - } - } catch (e) { - /* empty */ - } - } - return targetLogs; - } -} - -/** - * contract DisputeModule write method - */ -export class DisputeModuleClient extends DisputeModuleEventClient { - protected readonly wallet: SimpleWalletClient; - - constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { - super(rpcClient, address); - this.wallet = wallet; + public mintAndRegisterIpAndAttachLicenseAndAddToGroupEncode( + request: GroupingWorkflowsMintAndRegisterIpAndAttachLicenseAndAddToGroupRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: groupingWorkflowsAbi, + functionName: "mintAndRegisterIpAndAttachLicenseAndAddToGroup", + args: [ + request.spgNftContract, + request.groupId, + request.recipient, + request.licenseTemplate, + request.licenseTermsId, + request.ipMetadata, + request.sigAddToGroup, + ], + }), + }; } /** - * method cancelDispute for contract DisputeModule + * method registerGroupAndAttachLicense for contract GroupingWorkflows * - * @param request DisputeModuleCancelDisputeRequest + * @param request GroupingWorkflowsRegisterGroupAndAttachLicenseRequest * @return Promise */ - public async cancelDispute( - request: DisputeModuleCancelDisputeRequest, + public async registerGroupAndAttachLicense( + request: GroupingWorkflowsRegisterGroupAndAttachLicenseRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: disputeModuleAbi, + abi: groupingWorkflowsAbi, address: this.address, - functionName: "cancelDispute", + functionName: "registerGroupAndAttachLicense", account: this.wallet.account, - args: [request.disputeId, request.data], + args: [request.groupPool, request.licenseTemplate, request.licenseTermsId], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method cancelDispute for contract DisputeModule with only encode + * method registerGroupAndAttachLicense for contract GroupingWorkflows with only encode * - * @param request DisputeModuleCancelDisputeRequest + * @param request GroupingWorkflowsRegisterGroupAndAttachLicenseRequest * @return EncodedTxData */ - public cancelDisputeEncode(request: DisputeModuleCancelDisputeRequest): EncodedTxData { + public registerGroupAndAttachLicenseEncode( + request: GroupingWorkflowsRegisterGroupAndAttachLicenseRequest, + ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: disputeModuleAbi, - functionName: "cancelDispute", - args: [request.disputeId, request.data], + abi: groupingWorkflowsAbi, + functionName: "registerGroupAndAttachLicense", + args: [request.groupPool, request.licenseTemplate, request.licenseTermsId], }), }; } /** - * method raiseDispute for contract DisputeModule + * method registerGroupAndAttachLicenseAndAddIps for contract GroupingWorkflows * - * @param request DisputeModuleRaiseDisputeRequest + * @param request GroupingWorkflowsRegisterGroupAndAttachLicenseAndAddIpsRequest * @return Promise */ - public async raiseDispute( - request: DisputeModuleRaiseDisputeRequest, + public async registerGroupAndAttachLicenseAndAddIps( + request: GroupingWorkflowsRegisterGroupAndAttachLicenseAndAddIpsRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: disputeModuleAbi, + abi: groupingWorkflowsAbi, address: this.address, - functionName: "raiseDispute", + functionName: "registerGroupAndAttachLicenseAndAddIps", account: this.wallet.account, - args: [request.targetIpId, request.linkToDisputeEvidence, request.targetTag, request.data], + args: [request.groupPool, request.ipIds, request.licenseTemplate, request.licenseTermsId], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method raiseDispute for contract DisputeModule with only encode + * method registerGroupAndAttachLicenseAndAddIps for contract GroupingWorkflows with only encode * - * @param request DisputeModuleRaiseDisputeRequest + * @param request GroupingWorkflowsRegisterGroupAndAttachLicenseAndAddIpsRequest * @return EncodedTxData */ - public raiseDisputeEncode(request: DisputeModuleRaiseDisputeRequest): EncodedTxData { + public registerGroupAndAttachLicenseAndAddIpsEncode( + request: GroupingWorkflowsRegisterGroupAndAttachLicenseAndAddIpsRequest, + ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: disputeModuleAbi, - functionName: "raiseDispute", - args: [request.targetIpId, request.linkToDisputeEvidence, request.targetTag, request.data], + abi: groupingWorkflowsAbi, + functionName: "registerGroupAndAttachLicenseAndAddIps", + args: [request.groupPool, request.ipIds, request.licenseTemplate, request.licenseTermsId], }), }; } /** - * method resolveDispute for contract DisputeModule + * method registerIpAndAttachLicenseAndAddToGroup for contract GroupingWorkflows * - * @param request DisputeModuleResolveDisputeRequest + * @param request GroupingWorkflowsRegisterIpAndAttachLicenseAndAddToGroupRequest * @return Promise */ - public async resolveDispute( - request: DisputeModuleResolveDisputeRequest, + public async registerIpAndAttachLicenseAndAddToGroup( + request: GroupingWorkflowsRegisterIpAndAttachLicenseAndAddToGroupRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: disputeModuleAbi, + abi: groupingWorkflowsAbi, address: this.address, - functionName: "resolveDispute", + functionName: "registerIpAndAttachLicenseAndAddToGroup", account: this.wallet.account, - args: [request.disputeId, request.data], + args: [ + request.nftContract, + request.tokenId, + request.groupId, + request.licenseTemplate, + request.licenseTermsId, + request.ipMetadata, + request.sigMetadataAndAttach, + request.sigAddToGroup, + ], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method resolveDispute for contract DisputeModule with only encode + * method registerIpAndAttachLicenseAndAddToGroup for contract GroupingWorkflows with only encode * - * @param request DisputeModuleResolveDisputeRequest + * @param request GroupingWorkflowsRegisterIpAndAttachLicenseAndAddToGroupRequest * @return EncodedTxData */ - public resolveDisputeEncode(request: DisputeModuleResolveDisputeRequest): EncodedTxData { + public registerIpAndAttachLicenseAndAddToGroupEncode( + request: GroupingWorkflowsRegisterIpAndAttachLicenseAndAddToGroupRequest, + ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: disputeModuleAbi, - functionName: "resolveDispute", - args: [request.disputeId, request.data], + abi: groupingWorkflowsAbi, + functionName: "registerIpAndAttachLicenseAndAddToGroup", + args: [ + request.nftContract, + request.tokenId, + request.groupId, + request.licenseTemplate, + request.licenseTermsId, + request.ipMetadata, + request.sigMetadataAndAttach, + request.sigAddToGroup, + ], }), }; } @@ -9827,28 +16963,15 @@ export type IpRoyaltyVaultImplRevenueTokenClaimedEvent = { amount: bigint; }; -/** - * IpRoyaltyVaultImplRoyaltyTokensCollectedEvent - * - * @param ancestorIpId address - * @param royaltyTokensCollected uint256 - */ -export type IpRoyaltyVaultImplRoyaltyTokensCollectedEvent = { - ancestorIpId: Address; - royaltyTokensCollected: bigint; -}; - /** * IpRoyaltyVaultImplSnapshotCompletedEvent * * @param snapshotId uint256 * @param snapshotTimestamp uint256 - * @param unclaimedTokens uint32 */ export type IpRoyaltyVaultImplSnapshotCompletedEvent = { snapshotId: bigint; snapshotTimestamp: bigint; - unclaimedTokens: number; }; /** @@ -9869,34 +16992,16 @@ export type IpRoyaltyVaultImplClaimableRevenueResponse = bigint; export type IpRoyaltyVaultImplIpIdResponse = Address; /** - * IpRoyaltyVaultImplClaimRevenueBySnapshotBatchRequest + * IpRoyaltyVaultImplClaimRevenueOnBehalfBySnapshotBatchRequest * * @param snapshotIds uint256[] * @param token address + * @param claimer address */ -export type IpRoyaltyVaultImplClaimRevenueBySnapshotBatchRequest = { +export type IpRoyaltyVaultImplClaimRevenueOnBehalfBySnapshotBatchRequest = { snapshotIds: readonly bigint[]; token: Address; -}; - -/** - * IpRoyaltyVaultImplClaimRevenueByTokenBatchRequest - * - * @param snapshotId uint256 - * @param tokenList address[] - */ -export type IpRoyaltyVaultImplClaimRevenueByTokenBatchRequest = { - snapshotId: bigint; - tokenList: readonly Address[]; -}; - -/** - * IpRoyaltyVaultImplCollectRoyaltyTokensRequest - * - * @param ancestorIpId address - */ -export type IpRoyaltyVaultImplCollectRoyaltyTokensRequest = { - ancestorIpId: Address; + claimer: Address; }; /** @@ -9952,47 +17057,6 @@ export class IpRoyaltyVaultImplEventClient { return targetLogs; } - /** - * event RoyaltyTokensCollected for contract IpRoyaltyVaultImpl - */ - public watchRoyaltyTokensCollectedEvent( - onLogs: (txHash: Hex, ev: Partial) => void, - ): WatchContractEventReturnType { - return this.rpcClient.watchContractEvent({ - abi: ipRoyaltyVaultImplAbi, - address: this.address, - eventName: "RoyaltyTokensCollected", - onLogs: (evs) => { - evs.forEach((it) => onLogs(it.transactionHash, it.args)); - }, - }); - } - - /** - * parse tx receipt event RoyaltyTokensCollected for contract IpRoyaltyVaultImpl - */ - public parseTxRoyaltyTokensCollectedEvent( - txReceipt: TransactionReceipt, - ): Array { - const targetLogs: Array = []; - for (const log of txReceipt.logs) { - try { - const event = decodeEventLog({ - abi: ipRoyaltyVaultImplAbi, - eventName: "RoyaltyTokensCollected", - data: log.data, - topics: log.topics, - }); - if (event.eventName === "RoyaltyTokensCollected") { - targetLogs.push(event.args); - } - } catch (e) { - /* empty */ - } - } - return targetLogs; - } - /** * event SnapshotCompleted for contract IpRoyaltyVaultImpl */ @@ -10087,147 +17151,339 @@ export class IpRoyaltyVaultImplClient extends IpRoyaltyVaultImplReadOnlyClient { } /** - * method claimRevenueBySnapshotBatch for contract IpRoyaltyVaultImpl + * method claimRevenueOnBehalfBySnapshotBatch for contract IpRoyaltyVaultImpl * - * @param request IpRoyaltyVaultImplClaimRevenueBySnapshotBatchRequest + * @param request IpRoyaltyVaultImplClaimRevenueOnBehalfBySnapshotBatchRequest * @return Promise */ - public async claimRevenueBySnapshotBatch( - request: IpRoyaltyVaultImplClaimRevenueBySnapshotBatchRequest, + public async claimRevenueOnBehalfBySnapshotBatch( + request: IpRoyaltyVaultImplClaimRevenueOnBehalfBySnapshotBatchRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ abi: ipRoyaltyVaultImplAbi, address: this.address, - functionName: "claimRevenueBySnapshotBatch", + functionName: "claimRevenueOnBehalfBySnapshotBatch", account: this.wallet.account, - args: [request.snapshotIds, request.token], + args: [request.snapshotIds, request.token, request.claimer], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method claimRevenueBySnapshotBatch for contract IpRoyaltyVaultImpl with only encode + * method claimRevenueOnBehalfBySnapshotBatch for contract IpRoyaltyVaultImpl with only encode * - * @param request IpRoyaltyVaultImplClaimRevenueBySnapshotBatchRequest + * @param request IpRoyaltyVaultImplClaimRevenueOnBehalfBySnapshotBatchRequest * @return EncodedTxData */ - public claimRevenueBySnapshotBatchEncode( - request: IpRoyaltyVaultImplClaimRevenueBySnapshotBatchRequest, + public claimRevenueOnBehalfBySnapshotBatchEncode( + request: IpRoyaltyVaultImplClaimRevenueOnBehalfBySnapshotBatchRequest, ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ abi: ipRoyaltyVaultImplAbi, - functionName: "claimRevenueBySnapshotBatch", - args: [request.snapshotIds, request.token], + functionName: "claimRevenueOnBehalfBySnapshotBatch", + args: [request.snapshotIds, request.token, request.claimer], }), }; } /** - * method claimRevenueByTokenBatch for contract IpRoyaltyVaultImpl + * method snapshot for contract IpRoyaltyVaultImpl * - * @param request IpRoyaltyVaultImplClaimRevenueByTokenBatchRequest + * @param request IpRoyaltyVaultImplSnapshotRequest * @return Promise */ - public async claimRevenueByTokenBatch( - request: IpRoyaltyVaultImplClaimRevenueByTokenBatchRequest, - ): Promise { + public async snapshot(): Promise { const { request: call } = await this.rpcClient.simulateContract({ abi: ipRoyaltyVaultImplAbi, address: this.address, - functionName: "claimRevenueByTokenBatch", + functionName: "snapshot", account: this.wallet.account, - args: [request.snapshotId, request.tokenList], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method claimRevenueByTokenBatch for contract IpRoyaltyVaultImpl with only encode + * method snapshot for contract IpRoyaltyVaultImpl with only encode * - * @param request IpRoyaltyVaultImplClaimRevenueByTokenBatchRequest + * @param request IpRoyaltyVaultImplSnapshotRequest * @return EncodedTxData */ - public claimRevenueByTokenBatchEncode( - request: IpRoyaltyVaultImplClaimRevenueByTokenBatchRequest, - ): EncodedTxData { + public snapshotEncode(): EncodedTxData { return { to: this.address, data: encodeFunctionData({ abi: ipRoyaltyVaultImplAbi, - functionName: "claimRevenueByTokenBatch", - args: [request.snapshotId, request.tokenList], + functionName: "snapshot", + }), + }; + } +} + +// Contract LicenseAttachmentWorkflows ============================================================= + +/** + * LicenseAttachmentWorkflowsMintAndRegisterIpAndAttachPilTermsRequest + * + * @param spgNftContract address + * @param recipient address + * @param ipMetadata tuple + * @param terms tuple + */ +export type LicenseAttachmentWorkflowsMintAndRegisterIpAndAttachPilTermsRequest = { + spgNftContract: Address; + recipient: Address; + ipMetadata: { + ipMetadataURI: string; + ipMetadataHash: Hex; + nftMetadataURI: string; + nftMetadataHash: Hex; + }; + terms: { + transferable: boolean; + royaltyPolicy: Address; + defaultMintingFee: bigint; + expiration: bigint; + commercialUse: boolean; + commercialAttribution: boolean; + commercializerChecker: Address; + commercializerCheckerData: Hex; + commercialRevShare: number; + commercialRevCeiling: bigint; + derivativesAllowed: boolean; + derivativesAttribution: boolean; + derivativesApproval: boolean; + derivativesReciprocal: boolean; + derivativeRevCeiling: bigint; + currency: Address; + uri: string; + }; +}; + +/** + * LicenseAttachmentWorkflowsRegisterIpAndAttachPilTermsRequest + * + * @param nftContract address + * @param tokenId uint256 + * @param ipMetadata tuple + * @param terms tuple + * @param sigMetadata tuple + * @param sigAttach tuple + */ +export type LicenseAttachmentWorkflowsRegisterIpAndAttachPilTermsRequest = { + nftContract: Address; + tokenId: bigint; + ipMetadata: { + ipMetadataURI: string; + ipMetadataHash: Hex; + nftMetadataURI: string; + nftMetadataHash: Hex; + }; + terms: { + transferable: boolean; + royaltyPolicy: Address; + defaultMintingFee: bigint; + expiration: bigint; + commercialUse: boolean; + commercialAttribution: boolean; + commercializerChecker: Address; + commercializerCheckerData: Hex; + commercialRevShare: number; + commercialRevCeiling: bigint; + derivativesAllowed: boolean; + derivativesAttribution: boolean; + derivativesApproval: boolean; + derivativesReciprocal: boolean; + derivativeRevCeiling: bigint; + currency: Address; + uri: string; + }; + sigMetadata: { + signer: Address; + deadline: bigint; + signature: Hex; + }; + sigAttach: { + signer: Address; + deadline: bigint; + signature: Hex; + }; +}; + +/** + * LicenseAttachmentWorkflowsRegisterPilTermsAndAttachRequest + * + * @param ipId address + * @param terms tuple + * @param sigAttach tuple + */ +export type LicenseAttachmentWorkflowsRegisterPilTermsAndAttachRequest = { + ipId: Address; + terms: { + transferable: boolean; + royaltyPolicy: Address; + defaultMintingFee: bigint; + expiration: bigint; + commercialUse: boolean; + commercialAttribution: boolean; + commercializerChecker: Address; + commercializerCheckerData: Hex; + commercialRevShare: number; + commercialRevCeiling: bigint; + derivativesAllowed: boolean; + derivativesAttribution: boolean; + derivativesApproval: boolean; + derivativesReciprocal: boolean; + derivativeRevCeiling: bigint; + currency: Address; + uri: string; + }; + sigAttach: { + signer: Address; + deadline: bigint; + signature: Hex; + }; +}; + +/** + * contract LicenseAttachmentWorkflows write method + */ +export class LicenseAttachmentWorkflowsClient { + protected readonly wallet: SimpleWalletClient; + protected readonly rpcClient: PublicClient; + public readonly address: Address; + + constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { + this.address = address || getAddress(licenseAttachmentWorkflowsAddress, rpcClient.chain?.id); + this.rpcClient = rpcClient; + this.wallet = wallet; + } + + /** + * method mintAndRegisterIpAndAttachPILTerms for contract LicenseAttachmentWorkflows + * + * @param request LicenseAttachmentWorkflowsMintAndRegisterIpAndAttachPilTermsRequest + * @return Promise + */ + public async mintAndRegisterIpAndAttachPilTerms( + request: LicenseAttachmentWorkflowsMintAndRegisterIpAndAttachPilTermsRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: licenseAttachmentWorkflowsAbi, + address: this.address, + functionName: "mintAndRegisterIpAndAttachPILTerms", + account: this.wallet.account, + args: [request.spgNftContract, request.recipient, request.ipMetadata, request.terms], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method mintAndRegisterIpAndAttachPILTerms for contract LicenseAttachmentWorkflows with only encode + * + * @param request LicenseAttachmentWorkflowsMintAndRegisterIpAndAttachPilTermsRequest + * @return EncodedTxData + */ + public mintAndRegisterIpAndAttachPilTermsEncode( + request: LicenseAttachmentWorkflowsMintAndRegisterIpAndAttachPilTermsRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licenseAttachmentWorkflowsAbi, + functionName: "mintAndRegisterIpAndAttachPILTerms", + args: [request.spgNftContract, request.recipient, request.ipMetadata, request.terms], }), }; } /** - * method collectRoyaltyTokens for contract IpRoyaltyVaultImpl + * method registerIpAndAttachPILTerms for contract LicenseAttachmentWorkflows * - * @param request IpRoyaltyVaultImplCollectRoyaltyTokensRequest + * @param request LicenseAttachmentWorkflowsRegisterIpAndAttachPilTermsRequest * @return Promise */ - public async collectRoyaltyTokens( - request: IpRoyaltyVaultImplCollectRoyaltyTokensRequest, + public async registerIpAndAttachPilTerms( + request: LicenseAttachmentWorkflowsRegisterIpAndAttachPilTermsRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: ipRoyaltyVaultImplAbi, + abi: licenseAttachmentWorkflowsAbi, address: this.address, - functionName: "collectRoyaltyTokens", + functionName: "registerIpAndAttachPILTerms", account: this.wallet.account, - args: [request.ancestorIpId], + args: [ + request.nftContract, + request.tokenId, + request.ipMetadata, + request.terms, + request.sigMetadata, + request.sigAttach, + ], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method collectRoyaltyTokens for contract IpRoyaltyVaultImpl with only encode + * method registerIpAndAttachPILTerms for contract LicenseAttachmentWorkflows with only encode * - * @param request IpRoyaltyVaultImplCollectRoyaltyTokensRequest + * @param request LicenseAttachmentWorkflowsRegisterIpAndAttachPilTermsRequest * @return EncodedTxData */ - public collectRoyaltyTokensEncode( - request: IpRoyaltyVaultImplCollectRoyaltyTokensRequest, + public registerIpAndAttachPilTermsEncode( + request: LicenseAttachmentWorkflowsRegisterIpAndAttachPilTermsRequest, ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: ipRoyaltyVaultImplAbi, - functionName: "collectRoyaltyTokens", - args: [request.ancestorIpId], + abi: licenseAttachmentWorkflowsAbi, + functionName: "registerIpAndAttachPILTerms", + args: [ + request.nftContract, + request.tokenId, + request.ipMetadata, + request.terms, + request.sigMetadata, + request.sigAttach, + ], }), }; } /** - * method snapshot for contract IpRoyaltyVaultImpl + * method registerPILTermsAndAttach for contract LicenseAttachmentWorkflows * - * @param request IpRoyaltyVaultImplSnapshotRequest + * @param request LicenseAttachmentWorkflowsRegisterPilTermsAndAttachRequest * @return Promise */ - public async snapshot(): Promise { + public async registerPilTermsAndAttach( + request: LicenseAttachmentWorkflowsRegisterPilTermsAndAttachRequest, + ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: ipRoyaltyVaultImplAbi, + abi: licenseAttachmentWorkflowsAbi, address: this.address, - functionName: "snapshot", + functionName: "registerPILTermsAndAttach", account: this.wallet.account, + args: [request.ipId, request.terms, request.sigAttach], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method snapshot for contract IpRoyaltyVaultImpl with only encode + * method registerPILTermsAndAttach for contract LicenseAttachmentWorkflows with only encode * - * @param request IpRoyaltyVaultImplSnapshotRequest + * @param request LicenseAttachmentWorkflowsRegisterPilTermsAndAttachRequest * @return EncodedTxData */ - public snapshotEncode(): EncodedTxData { + public registerPilTermsAndAttachEncode( + request: LicenseAttachmentWorkflowsRegisterPilTermsAndAttachRequest, + ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: ipRoyaltyVaultImplAbi, - functionName: "snapshot", + abi: licenseAttachmentWorkflowsAbi, + functionName: "registerPILTermsAndAttach", + args: [request.ipId, request.terms, request.sigAttach], }), }; } @@ -10326,9 +17582,9 @@ export type LicenseRegistryDisputeModuleResponse = Address; export type LicenseRegistryExpirationTimeResponse = Hex; -export type LicenseRegistryIpGraphAclResponse = Address; +export type LicenseRegistryIpGraphResponse = Address; -export type LicenseRegistryIpGraphContractResponse = Address; +export type LicenseRegistryIpGraphAclResponse = Address; export type LicenseRegistryLicensingModuleResponse = Address; @@ -10486,6 +17742,28 @@ export type LicenseRegistryGetParentIpCountRequest = { export type LicenseRegistryGetParentIpCountResponse = bigint; +/** + * LicenseRegistryGetParentLicenseTermsRequest + * + * @param childIpId address + * @param parentIpId address + */ +export type LicenseRegistryGetParentLicenseTermsRequest = { + childIpId: Address; + parentIpId: Address; +}; + +/** + * LicenseRegistryGetParentLicenseTermsResponse + * + * @param licenseTemplate address + * @param licenseTermsId uint256 + */ +export type LicenseRegistryGetParentLicenseTermsResponse = { + licenseTemplate: Address; + licenseTermsId: bigint; +}; + /** * LicenseRegistryHasDerivativeIpsRequest * @@ -11075,30 +18353,30 @@ export class LicenseRegistryReadOnlyClient extends LicenseRegistryEventClient { } /** - * method IP_GRAPH_ACL for contract LicenseRegistry + * method IP_GRAPH for contract LicenseRegistry * - * @param request LicenseRegistryIpGraphAclRequest - * @return Promise + * @param request LicenseRegistryIpGraphRequest + * @return Promise */ - public async ipGraphAcl(): Promise { + public async ipGraph(): Promise { return await this.rpcClient.readContract({ abi: licenseRegistryAbi, address: this.address, - functionName: "IP_GRAPH_ACL", + functionName: "IP_GRAPH", }); } /** - * method IP_GRAPH_CONTRACT for contract LicenseRegistry + * method IP_GRAPH_ACL for contract LicenseRegistry * - * @param request LicenseRegistryIpGraphContractRequest - * @return Promise + * @param request LicenseRegistryIpGraphAclRequest + * @return Promise */ - public async ipGraphContract(): Promise { + public async ipGraphAcl(): Promise { return await this.rpcClient.readContract({ abi: licenseRegistryAbi, address: this.address, - functionName: "IP_GRAPH_CONTRACT", + functionName: "IP_GRAPH_ACL", }); } @@ -11325,6 +18603,27 @@ export class LicenseRegistryReadOnlyClient extends LicenseRegistryEventClient { }); } + /** + * method getParentLicenseTerms for contract LicenseRegistry + * + * @param request LicenseRegistryGetParentLicenseTermsRequest + * @return Promise + */ + public async getParentLicenseTerms( + request: LicenseRegistryGetParentLicenseTermsRequest, + ): Promise { + const result = await this.rpcClient.readContract({ + abi: licenseRegistryAbi, + address: this.address, + functionName: "getParentLicenseTerms", + args: [request.childIpId, request.parentIpId], + }); + return { + licenseTemplate: result[0], + licenseTermsId: result[1], + }; + } + /** * method hasDerivativeIps for contract LicenseRegistry * @@ -11614,403 +18913,870 @@ export class LicenseRegistryClient extends LicenseRegistryReadOnlyClient { } /** - * method registerLicenseTemplate for contract LicenseRegistry + * method registerLicenseTemplate for contract LicenseRegistry + * + * @param request LicenseRegistryRegisterLicenseTemplateRequest + * @return Promise + */ + public async registerLicenseTemplate( + request: LicenseRegistryRegisterLicenseTemplateRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: licenseRegistryAbi, + address: this.address, + functionName: "registerLicenseTemplate", + account: this.wallet.account, + args: [request.licenseTemplate], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method registerLicenseTemplate for contract LicenseRegistry with only encode + * + * @param request LicenseRegistryRegisterLicenseTemplateRequest + * @return EncodedTxData + */ + public registerLicenseTemplateEncode( + request: LicenseRegistryRegisterLicenseTemplateRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licenseRegistryAbi, + functionName: "registerLicenseTemplate", + args: [request.licenseTemplate], + }), + }; + } + + /** + * method setAuthority for contract LicenseRegistry + * + * @param request LicenseRegistrySetAuthorityRequest + * @return Promise + */ + public async setAuthority( + request: LicenseRegistrySetAuthorityRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: licenseRegistryAbi, + address: this.address, + functionName: "setAuthority", + account: this.wallet.account, + args: [request.newAuthority], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setAuthority for contract LicenseRegistry with only encode + * + * @param request LicenseRegistrySetAuthorityRequest + * @return EncodedTxData + */ + public setAuthorityEncode(request: LicenseRegistrySetAuthorityRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licenseRegistryAbi, + functionName: "setAuthority", + args: [request.newAuthority], + }), + }; + } + + /** + * method setDefaultLicenseTerms for contract LicenseRegistry + * + * @param request LicenseRegistrySetDefaultLicenseTermsRequest + * @return Promise + */ + public async setDefaultLicenseTerms( + request: LicenseRegistrySetDefaultLicenseTermsRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: licenseRegistryAbi, + address: this.address, + functionName: "setDefaultLicenseTerms", + account: this.wallet.account, + args: [request.newLicenseTemplate, request.newLicenseTermsId], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setDefaultLicenseTerms for contract LicenseRegistry with only encode + * + * @param request LicenseRegistrySetDefaultLicenseTermsRequest + * @return EncodedTxData + */ + public setDefaultLicenseTermsEncode( + request: LicenseRegistrySetDefaultLicenseTermsRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licenseRegistryAbi, + functionName: "setDefaultLicenseTerms", + args: [request.newLicenseTemplate, request.newLicenseTermsId], + }), + }; + } + + /** + * method setLicensingConfigForIp for contract LicenseRegistry + * + * @param request LicenseRegistrySetLicensingConfigForIpRequest + * @return Promise + */ + public async setLicensingConfigForIp( + request: LicenseRegistrySetLicensingConfigForIpRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: licenseRegistryAbi, + address: this.address, + functionName: "setLicensingConfigForIp", + account: this.wallet.account, + args: [request.ipId, request.licensingConfig], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setLicensingConfigForIp for contract LicenseRegistry with only encode + * + * @param request LicenseRegistrySetLicensingConfigForIpRequest + * @return EncodedTxData + */ + public setLicensingConfigForIpEncode( + request: LicenseRegistrySetLicensingConfigForIpRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licenseRegistryAbi, + functionName: "setLicensingConfigForIp", + args: [request.ipId, request.licensingConfig], + }), + }; + } + + /** + * method setLicensingConfigForLicense for contract LicenseRegistry + * + * @param request LicenseRegistrySetLicensingConfigForLicenseRequest + * @return Promise + */ + public async setLicensingConfigForLicense( + request: LicenseRegistrySetLicensingConfigForLicenseRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: licenseRegistryAbi, + address: this.address, + functionName: "setLicensingConfigForLicense", + account: this.wallet.account, + args: [ + request.ipId, + request.licenseTemplate, + request.licenseTermsId, + request.licensingConfig, + ], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setLicensingConfigForLicense for contract LicenseRegistry with only encode + * + * @param request LicenseRegistrySetLicensingConfigForLicenseRequest + * @return EncodedTxData + */ + public setLicensingConfigForLicenseEncode( + request: LicenseRegistrySetLicensingConfigForLicenseRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licenseRegistryAbi, + functionName: "setLicensingConfigForLicense", + args: [ + request.ipId, + request.licenseTemplate, + request.licenseTermsId, + request.licensingConfig, + ], + }), + }; + } + + /** + * method upgradeToAndCall for contract LicenseRegistry * - * @param request LicenseRegistryRegisterLicenseTemplateRequest + * @param request LicenseRegistryUpgradeToAndCallRequest * @return Promise */ - public async registerLicenseTemplate( - request: LicenseRegistryRegisterLicenseTemplateRequest, + public async upgradeToAndCall( + request: LicenseRegistryUpgradeToAndCallRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ abi: licenseRegistryAbi, address: this.address, - functionName: "registerLicenseTemplate", + functionName: "upgradeToAndCall", account: this.wallet.account, - args: [request.licenseTemplate], + args: [request.newImplementation, request.data], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method registerLicenseTemplate for contract LicenseRegistry with only encode + * method upgradeToAndCall for contract LicenseRegistry with only encode * - * @param request LicenseRegistryRegisterLicenseTemplateRequest + * @param request LicenseRegistryUpgradeToAndCallRequest * @return EncodedTxData */ - public registerLicenseTemplateEncode( - request: LicenseRegistryRegisterLicenseTemplateRequest, - ): EncodedTxData { + public upgradeToAndCallEncode(request: LicenseRegistryUpgradeToAndCallRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ abi: licenseRegistryAbi, - functionName: "registerLicenseTemplate", - args: [request.licenseTemplate], + functionName: "upgradeToAndCall", + args: [request.newImplementation, request.data], }), }; } +} + +// Contract LicenseToken ============================================================= + +/** + * LicenseTokenOwnerOfRequest + * + * @param tokenId uint256 + */ +export type LicenseTokenOwnerOfRequest = { + tokenId: bigint; +}; + +export type LicenseTokenOwnerOfResponse = Address; + +/** + * contract LicenseToken readonly method + */ +export class LicenseTokenReadOnlyClient { + protected readonly rpcClient: PublicClient; + public readonly address: Address; + + constructor(rpcClient: PublicClient, address?: Address) { + this.address = address || getAddress(licenseTokenAddress, rpcClient.chain?.id); + this.rpcClient = rpcClient; + } + + /** + * method ownerOf for contract LicenseToken + * + * @param request LicenseTokenOwnerOfRequest + * @return Promise + */ + public async ownerOf(request: LicenseTokenOwnerOfRequest): Promise { + return await this.rpcClient.readContract({ + abi: licenseTokenAbi, + address: this.address, + functionName: "ownerOf", + args: [request.tokenId], + }); + } +} + +// Contract LicensingModule ============================================================= + +/** + * LicensingModuleLicenseTermsAttachedEvent + * + * @param caller address + * @param ipId address + * @param licenseTemplate address + * @param licenseTermsId uint256 + */ +export type LicensingModuleLicenseTermsAttachedEvent = { + caller: Address; + ipId: Address; + licenseTemplate: Address; + licenseTermsId: bigint; +}; + +/** + * LicensingModuleLicenseTokensMintedEvent + * + * @param caller address + * @param licensorIpId address + * @param licenseTemplate address + * @param licenseTermsId uint256 + * @param amount uint256 + * @param receiver address + * @param startLicenseTokenId uint256 + */ +export type LicensingModuleLicenseTokensMintedEvent = { + caller: Address; + licensorIpId: Address; + licenseTemplate: Address; + licenseTermsId: bigint; + amount: bigint; + receiver: Address; + startLicenseTokenId: bigint; +}; + +/** + * LicensingModulePredictMintingLicenseFeeRequest + * + * @param licensorIpId address + * @param licenseTemplate address + * @param licenseTermsId uint256 + * @param amount uint256 + * @param receiver address + * @param royaltyContext bytes + */ +export type LicensingModulePredictMintingLicenseFeeRequest = { + licensorIpId: Address; + licenseTemplate: Address; + licenseTermsId: bigint; + amount: bigint; + receiver: Address; + royaltyContext: Hex; +}; + +/** + * LicensingModulePredictMintingLicenseFeeResponse + * + * @param currencyToken address + * @param tokenAmount uint256 + */ +export type LicensingModulePredictMintingLicenseFeeResponse = { + currencyToken: Address; + tokenAmount: bigint; +}; + +/** + * LicensingModuleAttachLicenseTermsRequest + * + * @param ipId address + * @param licenseTemplate address + * @param licenseTermsId uint256 + */ +export type LicensingModuleAttachLicenseTermsRequest = { + ipId: Address; + licenseTemplate: Address; + licenseTermsId: bigint; +}; + +/** + * LicensingModuleMintLicenseTokensRequest + * + * @param licensorIpId address + * @param licenseTemplate address + * @param licenseTermsId uint256 + * @param amount uint256 + * @param receiver address + * @param royaltyContext bytes + */ +export type LicensingModuleMintLicenseTokensRequest = { + licensorIpId: Address; + licenseTemplate: Address; + licenseTermsId: bigint; + amount: bigint; + receiver: Address; + royaltyContext: Hex; +}; + +/** + * LicensingModuleRegisterDerivativeRequest + * + * @param childIpId address + * @param parentIpIds address[] + * @param licenseTermsIds uint256[] + * @param licenseTemplate address + * @param royaltyContext bytes + */ +export type LicensingModuleRegisterDerivativeRequest = { + childIpId: Address; + parentIpIds: readonly Address[]; + licenseTermsIds: readonly bigint[]; + licenseTemplate: Address; + royaltyContext: Hex; +}; + +/** + * LicensingModuleRegisterDerivativeWithLicenseTokensRequest + * + * @param childIpId address + * @param licenseTokenIds uint256[] + * @param royaltyContext bytes + */ +export type LicensingModuleRegisterDerivativeWithLicenseTokensRequest = { + childIpId: Address; + licenseTokenIds: readonly bigint[]; + royaltyContext: Hex; +}; + +/** + * contract LicensingModule event + */ +export class LicensingModuleEventClient { + protected readonly rpcClient: PublicClient; + public readonly address: Address; + + constructor(rpcClient: PublicClient, address?: Address) { + this.address = address || getAddress(licensingModuleAddress, rpcClient.chain?.id); + this.rpcClient = rpcClient; + } + + /** + * event LicenseTermsAttached for contract LicensingModule + */ + public watchLicenseTermsAttachedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: licensingModuleAbi, + address: this.address, + eventName: "LicenseTermsAttached", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } + + /** + * parse tx receipt event LicenseTermsAttached for contract LicensingModule + */ + public parseTxLicenseTermsAttachedEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: licensingModuleAbi, + eventName: "LicenseTermsAttached", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "LicenseTermsAttached") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } + + /** + * event LicenseTokensMinted for contract LicensingModule + */ + public watchLicenseTokensMintedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: licensingModuleAbi, + address: this.address, + eventName: "LicenseTokensMinted", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } /** - * method setAuthority for contract LicenseRegistry - * - * @param request LicenseRegistrySetAuthorityRequest - * @return Promise + * parse tx receipt event LicenseTokensMinted for contract LicensingModule */ - public async setAuthority( - request: LicenseRegistrySetAuthorityRequest, - ): Promise { - const { request: call } = await this.rpcClient.simulateContract({ - abi: licenseRegistryAbi, - address: this.address, - functionName: "setAuthority", - account: this.wallet.account, - args: [request.newAuthority], - }); - return await this.wallet.writeContract(call as WriteContractParameters); + public parseTxLicenseTokensMintedEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: licensingModuleAbi, + eventName: "LicenseTokensMinted", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "LicenseTokensMinted") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } +} + +/** + * contract LicensingModule readonly method + */ +export class LicensingModuleReadOnlyClient extends LicensingModuleEventClient { + constructor(rpcClient: PublicClient, address?: Address) { + super(rpcClient, address); } /** - * method setAuthority for contract LicenseRegistry with only encode + * method predictMintingLicenseFee for contract LicensingModule * - * @param request LicenseRegistrySetAuthorityRequest - * @return EncodedTxData + * @param request LicensingModulePredictMintingLicenseFeeRequest + * @return Promise */ - public setAuthorityEncode(request: LicenseRegistrySetAuthorityRequest): EncodedTxData { + public async predictMintingLicenseFee( + request: LicensingModulePredictMintingLicenseFeeRequest, + ): Promise { + const result = await this.rpcClient.readContract({ + abi: licensingModuleAbi, + address: this.address, + functionName: "predictMintingLicenseFee", + args: [ + request.licensorIpId, + request.licenseTemplate, + request.licenseTermsId, + request.amount, + request.receiver, + request.royaltyContext, + ], + }); return { - to: this.address, - data: encodeFunctionData({ - abi: licenseRegistryAbi, - functionName: "setAuthority", - args: [request.newAuthority], - }), + currencyToken: result[0], + tokenAmount: result[1], }; } +} + +/** + * contract LicensingModule write method + */ +export class LicensingModuleClient extends LicensingModuleReadOnlyClient { + protected readonly wallet: SimpleWalletClient; + + constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { + super(rpcClient, address); + this.wallet = wallet; + } /** - * method setDefaultLicenseTerms for contract LicenseRegistry + * method attachLicenseTerms for contract LicensingModule * - * @param request LicenseRegistrySetDefaultLicenseTermsRequest + * @param request LicensingModuleAttachLicenseTermsRequest * @return Promise */ - public async setDefaultLicenseTerms( - request: LicenseRegistrySetDefaultLicenseTermsRequest, + public async attachLicenseTerms( + request: LicensingModuleAttachLicenseTermsRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: licenseRegistryAbi, + abi: licensingModuleAbi, address: this.address, - functionName: "setDefaultLicenseTerms", + functionName: "attachLicenseTerms", account: this.wallet.account, - args: [request.newLicenseTemplate, request.newLicenseTermsId], + args: [request.ipId, request.licenseTemplate, request.licenseTermsId], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method setDefaultLicenseTerms for contract LicenseRegistry with only encode + * method attachLicenseTerms for contract LicensingModule with only encode * - * @param request LicenseRegistrySetDefaultLicenseTermsRequest + * @param request LicensingModuleAttachLicenseTermsRequest * @return EncodedTxData */ - public setDefaultLicenseTermsEncode( - request: LicenseRegistrySetDefaultLicenseTermsRequest, + public attachLicenseTermsEncode( + request: LicensingModuleAttachLicenseTermsRequest, ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: licenseRegistryAbi, - functionName: "setDefaultLicenseTerms", - args: [request.newLicenseTemplate, request.newLicenseTermsId], + abi: licensingModuleAbi, + functionName: "attachLicenseTerms", + args: [request.ipId, request.licenseTemplate, request.licenseTermsId], }), }; } /** - * method setLicensingConfigForIp for contract LicenseRegistry + * method mintLicenseTokens for contract LicensingModule * - * @param request LicenseRegistrySetLicensingConfigForIpRequest + * @param request LicensingModuleMintLicenseTokensRequest * @return Promise */ - public async setLicensingConfigForIp( - request: LicenseRegistrySetLicensingConfigForIpRequest, + public async mintLicenseTokens( + request: LicensingModuleMintLicenseTokensRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: licenseRegistryAbi, + abi: licensingModuleAbi, address: this.address, - functionName: "setLicensingConfigForIp", + functionName: "mintLicenseTokens", account: this.wallet.account, - args: [request.ipId, request.licensingConfig], + args: [ + request.licensorIpId, + request.licenseTemplate, + request.licenseTermsId, + request.amount, + request.receiver, + request.royaltyContext, + ], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method setLicensingConfigForIp for contract LicenseRegistry with only encode + * method mintLicenseTokens for contract LicensingModule with only encode * - * @param request LicenseRegistrySetLicensingConfigForIpRequest + * @param request LicensingModuleMintLicenseTokensRequest * @return EncodedTxData */ - public setLicensingConfigForIpEncode( - request: LicenseRegistrySetLicensingConfigForIpRequest, - ): EncodedTxData { + public mintLicenseTokensEncode(request: LicensingModuleMintLicenseTokensRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: licenseRegistryAbi, - functionName: "setLicensingConfigForIp", - args: [request.ipId, request.licensingConfig], + abi: licensingModuleAbi, + functionName: "mintLicenseTokens", + args: [ + request.licensorIpId, + request.licenseTemplate, + request.licenseTermsId, + request.amount, + request.receiver, + request.royaltyContext, + ], }), }; } /** - * method setLicensingConfigForLicense for contract LicenseRegistry + * method registerDerivative for contract LicensingModule * - * @param request LicenseRegistrySetLicensingConfigForLicenseRequest + * @param request LicensingModuleRegisterDerivativeRequest * @return Promise */ - public async setLicensingConfigForLicense( - request: LicenseRegistrySetLicensingConfigForLicenseRequest, + public async registerDerivative( + request: LicensingModuleRegisterDerivativeRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: licenseRegistryAbi, + abi: licensingModuleAbi, address: this.address, - functionName: "setLicensingConfigForLicense", + functionName: "registerDerivative", account: this.wallet.account, args: [ - request.ipId, + request.childIpId, + request.parentIpIds, + request.licenseTermsIds, request.licenseTemplate, - request.licenseTermsId, - request.licensingConfig, + request.royaltyContext, ], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method setLicensingConfigForLicense for contract LicenseRegistry with only encode + * method registerDerivative for contract LicensingModule with only encode * - * @param request LicenseRegistrySetLicensingConfigForLicenseRequest + * @param request LicensingModuleRegisterDerivativeRequest * @return EncodedTxData */ - public setLicensingConfigForLicenseEncode( - request: LicenseRegistrySetLicensingConfigForLicenseRequest, + public registerDerivativeEncode( + request: LicensingModuleRegisterDerivativeRequest, ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: licenseRegistryAbi, - functionName: "setLicensingConfigForLicense", + abi: licensingModuleAbi, + functionName: "registerDerivative", args: [ - request.ipId, + request.childIpId, + request.parentIpIds, + request.licenseTermsIds, request.licenseTemplate, - request.licenseTermsId, - request.licensingConfig, + request.royaltyContext, ], }), }; } /** - * method upgradeToAndCall for contract LicenseRegistry + * method registerDerivativeWithLicenseTokens for contract LicensingModule * - * @param request LicenseRegistryUpgradeToAndCallRequest + * @param request LicensingModuleRegisterDerivativeWithLicenseTokensRequest * @return Promise */ - public async upgradeToAndCall( - request: LicenseRegistryUpgradeToAndCallRequest, + public async registerDerivativeWithLicenseTokens( + request: LicensingModuleRegisterDerivativeWithLicenseTokensRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: licenseRegistryAbi, + abi: licensingModuleAbi, address: this.address, - functionName: "upgradeToAndCall", + functionName: "registerDerivativeWithLicenseTokens", account: this.wallet.account, - args: [request.newImplementation, request.data], + args: [request.childIpId, request.licenseTokenIds, request.royaltyContext], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method upgradeToAndCall for contract LicenseRegistry with only encode + * method registerDerivativeWithLicenseTokens for contract LicensingModule with only encode * - * @param request LicenseRegistryUpgradeToAndCallRequest + * @param request LicensingModuleRegisterDerivativeWithLicenseTokensRequest * @return EncodedTxData */ - public upgradeToAndCallEncode(request: LicenseRegistryUpgradeToAndCallRequest): EncodedTxData { + public registerDerivativeWithLicenseTokensEncode( + request: LicensingModuleRegisterDerivativeWithLicenseTokensRequest, + ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: licenseRegistryAbi, - functionName: "upgradeToAndCall", - args: [request.newImplementation, request.data], + abi: licensingModuleAbi, + functionName: "registerDerivativeWithLicenseTokens", + args: [request.childIpId, request.licenseTokenIds, request.royaltyContext], }), }; } } -// Contract LicenseToken ============================================================= +// Contract MockERC20 ============================================================= /** - * LicenseTokenOwnerOfRequest + * MockErc20ApprovalEvent * - * @param tokenId uint256 + * @param owner address + * @param spender address + * @param value uint256 */ -export type LicenseTokenOwnerOfRequest = { - tokenId: bigint; +export type MockErc20ApprovalEvent = { + owner: Address; + spender: Address; + value: bigint; }; -export type LicenseTokenOwnerOfResponse = Address; - /** - * contract LicenseToken readonly method + * MockErc20TransferEvent + * + * @param from address + * @param to address + * @param value uint256 */ -export class LicenseTokenReadOnlyClient { - protected readonly rpcClient: PublicClient; - public readonly address: Address; - - constructor(rpcClient: PublicClient, address?: Address) { - this.address = address || getAddress(licenseTokenAddress, rpcClient.chain?.id); - this.rpcClient = rpcClient; - } +export type MockErc20TransferEvent = { + from: Address; + to: Address; + value: bigint; +}; - /** - * method ownerOf for contract LicenseToken - * - * @param request LicenseTokenOwnerOfRequest - * @return Promise - */ - public async ownerOf(request: LicenseTokenOwnerOfRequest): Promise { - return await this.rpcClient.readContract({ - abi: licenseTokenAbi, - address: this.address, - functionName: "ownerOf", - args: [request.tokenId], - }); - } -} +/** + * MockErc20AllowanceRequest + * + * @param owner address + * @param spender address + */ +export type MockErc20AllowanceRequest = { + owner: Address; + spender: Address; +}; -// Contract LicensingModule ============================================================= +export type MockErc20AllowanceResponse = bigint; /** - * LicensingModuleLicenseTermsAttachedEvent + * MockErc20BalanceOfRequest * - * @param caller address - * @param ipId address - * @param licenseTemplate address - * @param licenseTermsId uint256 + * @param account address */ -export type LicensingModuleLicenseTermsAttachedEvent = { - caller: Address; - ipId: Address; - licenseTemplate: Address; - licenseTermsId: bigint; +export type MockErc20BalanceOfRequest = { + account: Address; }; +export type MockErc20BalanceOfResponse = bigint; + +export type MockErc20DecimalsResponse = number; + +export type MockErc20NameResponse = string; + +export type MockErc20SymbolResponse = string; + +export type MockErc20TotalSupplyResponse = bigint; + /** - * LicensingModuleLicenseTokensMintedEvent + * MockErc20ApproveRequest * - * @param caller address - * @param licensorIpId address - * @param licenseTemplate address - * @param licenseTermsId uint256 - * @param amount uint256 - * @param receiver address - * @param startLicenseTokenId uint256 + * @param spender address + * @param value uint256 */ -export type LicensingModuleLicenseTokensMintedEvent = { - caller: Address; - licensorIpId: Address; - licenseTemplate: Address; - licenseTermsId: bigint; - amount: bigint; - receiver: Address; - startLicenseTokenId: bigint; +export type MockErc20ApproveRequest = { + spender: Address; + value: bigint; }; /** - * LicensingModuleAttachLicenseTermsRequest + * MockErc20BurnRequest * - * @param ipId address - * @param licenseTemplate address - * @param licenseTermsId uint256 + * @param from address + * @param amount uint256 */ -export type LicensingModuleAttachLicenseTermsRequest = { - ipId: Address; - licenseTemplate: Address; - licenseTermsId: bigint; +export type MockErc20BurnRequest = { + from: Address; + amount: bigint; }; /** - * LicensingModuleMintLicenseTokensRequest + * MockErc20MintRequest * - * @param licensorIpId address - * @param licenseTemplate address - * @param licenseTermsId uint256 + * @param to address * @param amount uint256 - * @param receiver address - * @param royaltyContext bytes */ -export type LicensingModuleMintLicenseTokensRequest = { - licensorIpId: Address; - licenseTemplate: Address; - licenseTermsId: bigint; +export type MockErc20MintRequest = { + to: Address; amount: bigint; - receiver: Address; - royaltyContext: Hex; }; /** - * LicensingModuleRegisterDerivativeRequest + * MockErc20TransferRequest * - * @param childIpId address - * @param parentIpIds address[] - * @param licenseTermsIds uint256[] - * @param licenseTemplate address - * @param royaltyContext bytes + * @param to address + * @param value uint256 */ -export type LicensingModuleRegisterDerivativeRequest = { - childIpId: Address; - parentIpIds: readonly Address[]; - licenseTermsIds: readonly bigint[]; - licenseTemplate: Address; - royaltyContext: Hex; +export type MockErc20TransferRequest = { + to: Address; + value: bigint; }; /** - * LicensingModuleRegisterDerivativeWithLicenseTokensRequest + * MockErc20TransferFromRequest * - * @param childIpId address - * @param licenseTokenIds uint256[] - * @param royaltyContext bytes + * @param from address + * @param to address + * @param value uint256 */ -export type LicensingModuleRegisterDerivativeWithLicenseTokensRequest = { - childIpId: Address; - licenseTokenIds: readonly bigint[]; - royaltyContext: Hex; +export type MockErc20TransferFromRequest = { + from: Address; + to: Address; + value: bigint; }; /** - * contract LicensingModule event + * contract MockERC20 event */ -export class LicensingModuleEventClient { +export class MockErc20EventClient { protected readonly rpcClient: PublicClient; public readonly address: Address; constructor(rpcClient: PublicClient, address?: Address) { - this.address = address || getAddress(licensingModuleAddress, rpcClient.chain?.id); + this.address = address || getAddress(mockErc20Address, rpcClient.chain?.id); this.rpcClient = rpcClient; } /** - * event LicenseTermsAttached for contract LicensingModule + * event Approval for contract MockERC20 */ - public watchLicenseTermsAttachedEvent( - onLogs: (txHash: Hex, ev: Partial) => void, + public watchApprovalEvent( + onLogs: (txHash: Hex, ev: Partial) => void, ): WatchContractEventReturnType { return this.rpcClient.watchContractEvent({ - abi: licensingModuleAbi, + abi: mockErc20Abi, address: this.address, - eventName: "LicenseTermsAttached", + eventName: "Approval", onLogs: (evs) => { evs.forEach((it) => onLogs(it.transactionHash, it.args)); }, @@ -12018,21 +19784,19 @@ export class LicensingModuleEventClient { } /** - * parse tx receipt event LicenseTermsAttached for contract LicensingModule + * parse tx receipt event Approval for contract MockERC20 */ - public parseTxLicenseTermsAttachedEvent( - txReceipt: TransactionReceipt, - ): Array { - const targetLogs: Array = []; + public parseTxApprovalEvent(txReceipt: TransactionReceipt): Array { + const targetLogs: Array = []; for (const log of txReceipt.logs) { try { const event = decodeEventLog({ - abi: licensingModuleAbi, - eventName: "LicenseTermsAttached", + abi: mockErc20Abi, + eventName: "Approval", data: log.data, topics: log.topics, }); - if (event.eventName === "LicenseTermsAttached") { + if (event.eventName === "Approval") { targetLogs.push(event.args); } } catch (e) { @@ -12043,15 +19807,15 @@ export class LicensingModuleEventClient { } /** - * event LicenseTokensMinted for contract LicensingModule + * event Transfer for contract MockERC20 */ - public watchLicenseTokensMintedEvent( - onLogs: (txHash: Hex, ev: Partial) => void, + public watchTransferEvent( + onLogs: (txHash: Hex, ev: Partial) => void, ): WatchContractEventReturnType { return this.rpcClient.watchContractEvent({ - abi: licensingModuleAbi, + abi: mockErc20Abi, address: this.address, - eventName: "LicenseTokensMinted", + eventName: "Transfer", onLogs: (evs) => { evs.forEach((it) => onLogs(it.transactionHash, it.args)); }, @@ -12059,21 +19823,19 @@ export class LicensingModuleEventClient { } /** - * parse tx receipt event LicenseTokensMinted for contract LicensingModule + * parse tx receipt event Transfer for contract MockERC20 */ - public parseTxLicenseTokensMintedEvent( - txReceipt: TransactionReceipt, - ): Array { - const targetLogs: Array = []; + public parseTxTransferEvent(txReceipt: TransactionReceipt): Array { + const targetLogs: Array = []; for (const log of txReceipt.logs) { try { const event = decodeEventLog({ - abi: licensingModuleAbi, - eventName: "LicenseTokensMinted", + abi: mockErc20Abi, + eventName: "Transfer", data: log.data, topics: log.topics, }); - if (event.eventName === "LicenseTokensMinted") { + if (event.eventName === "Transfer") { targetLogs.push(event.args); } } catch (e) { @@ -12085,9 +19847,104 @@ export class LicensingModuleEventClient { } /** - * contract LicensingModule write method + * contract MockERC20 readonly method + */ +export class MockErc20ReadOnlyClient extends MockErc20EventClient { + constructor(rpcClient: PublicClient, address?: Address) { + super(rpcClient, address); + } + + /** + * method allowance for contract MockERC20 + * + * @param request MockErc20AllowanceRequest + * @return Promise + */ + public async allowance(request: MockErc20AllowanceRequest): Promise { + return await this.rpcClient.readContract({ + abi: mockErc20Abi, + address: this.address, + functionName: "allowance", + args: [request.owner, request.spender], + }); + } + + /** + * method balanceOf for contract MockERC20 + * + * @param request MockErc20BalanceOfRequest + * @return Promise + */ + public async balanceOf(request: MockErc20BalanceOfRequest): Promise { + return await this.rpcClient.readContract({ + abi: mockErc20Abi, + address: this.address, + functionName: "balanceOf", + args: [request.account], + }); + } + + /** + * method decimals for contract MockERC20 + * + * @param request MockErc20DecimalsRequest + * @return Promise + */ + public async decimals(): Promise { + return await this.rpcClient.readContract({ + abi: mockErc20Abi, + address: this.address, + functionName: "decimals", + }); + } + + /** + * method name for contract MockERC20 + * + * @param request MockErc20NameRequest + * @return Promise + */ + public async name(): Promise { + return await this.rpcClient.readContract({ + abi: mockErc20Abi, + address: this.address, + functionName: "name", + }); + } + + /** + * method symbol for contract MockERC20 + * + * @param request MockErc20SymbolRequest + * @return Promise + */ + public async symbol(): Promise { + return await this.rpcClient.readContract({ + abi: mockErc20Abi, + address: this.address, + functionName: "symbol", + }); + } + + /** + * method totalSupply for contract MockERC20 + * + * @param request MockErc20TotalSupplyRequest + * @return Promise + */ + public async totalSupply(): Promise { + return await this.rpcClient.readContract({ + abi: mockErc20Abi, + address: this.address, + functionName: "totalSupply", + }); + } +} + +/** + * contract MockERC20 write method */ -export class LicensingModuleClient extends LicensingModuleEventClient { +export class MockErc20Client extends MockErc20ReadOnlyClient { protected readonly wallet: SimpleWalletClient; constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { @@ -12096,177 +19953,173 @@ export class LicensingModuleClient extends LicensingModuleEventClient { } /** - * method attachLicenseTerms for contract LicensingModule + * method approve for contract MockERC20 * - * @param request LicensingModuleAttachLicenseTermsRequest + * @param request MockErc20ApproveRequest * @return Promise */ - public async attachLicenseTerms( - request: LicensingModuleAttachLicenseTermsRequest, - ): Promise { + public async approve(request: MockErc20ApproveRequest): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: licensingModuleAbi, + abi: mockErc20Abi, address: this.address, - functionName: "attachLicenseTerms", + functionName: "approve", account: this.wallet.account, - args: [request.ipId, request.licenseTemplate, request.licenseTermsId], + args: [request.spender, request.value], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method attachLicenseTerms for contract LicensingModule with only encode + * method approve for contract MockERC20 with only encode * - * @param request LicensingModuleAttachLicenseTermsRequest + * @param request MockErc20ApproveRequest * @return EncodedTxData */ - public attachLicenseTermsEncode( - request: LicensingModuleAttachLicenseTermsRequest, - ): EncodedTxData { + public approveEncode(request: MockErc20ApproveRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: licensingModuleAbi, - functionName: "attachLicenseTerms", - args: [request.ipId, request.licenseTemplate, request.licenseTermsId], + abi: mockErc20Abi, + functionName: "approve", + args: [request.spender, request.value], }), }; } /** - * method mintLicenseTokens for contract LicensingModule + * method burn for contract MockERC20 * - * @param request LicensingModuleMintLicenseTokensRequest + * @param request MockErc20BurnRequest * @return Promise */ - public async mintLicenseTokens( - request: LicensingModuleMintLicenseTokensRequest, - ): Promise { + public async burn(request: MockErc20BurnRequest): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: licensingModuleAbi, + abi: mockErc20Abi, address: this.address, - functionName: "mintLicenseTokens", + functionName: "burn", account: this.wallet.account, - args: [ - request.licensorIpId, - request.licenseTemplate, - request.licenseTermsId, - request.amount, - request.receiver, - request.royaltyContext, - ], + args: [request.from, request.amount], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method mintLicenseTokens for contract LicensingModule with only encode + * method burn for contract MockERC20 with only encode * - * @param request LicensingModuleMintLicenseTokensRequest + * @param request MockErc20BurnRequest * @return EncodedTxData */ - public mintLicenseTokensEncode(request: LicensingModuleMintLicenseTokensRequest): EncodedTxData { + public burnEncode(request: MockErc20BurnRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: licensingModuleAbi, - functionName: "mintLicenseTokens", - args: [ - request.licensorIpId, - request.licenseTemplate, - request.licenseTermsId, - request.amount, - request.receiver, - request.royaltyContext, - ], + abi: mockErc20Abi, + functionName: "burn", + args: [request.from, request.amount], + }), + }; + } + + /** + * method mint for contract MockERC20 + * + * @param request MockErc20MintRequest + * @return Promise + */ + public async mint(request: MockErc20MintRequest): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: mockErc20Abi, + address: this.address, + functionName: "mint", + account: this.wallet.account, + args: [request.to, request.amount], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method mint for contract MockERC20 with only encode + * + * @param request MockErc20MintRequest + * @return EncodedTxData + */ + public mintEncode(request: MockErc20MintRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: mockErc20Abi, + functionName: "mint", + args: [request.to, request.amount], }), }; } /** - * method registerDerivative for contract LicensingModule + * method transfer for contract MockERC20 * - * @param request LicensingModuleRegisterDerivativeRequest + * @param request MockErc20TransferRequest * @return Promise */ - public async registerDerivative( - request: LicensingModuleRegisterDerivativeRequest, - ): Promise { + public async transfer(request: MockErc20TransferRequest): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: licensingModuleAbi, + abi: mockErc20Abi, address: this.address, - functionName: "registerDerivative", + functionName: "transfer", account: this.wallet.account, - args: [ - request.childIpId, - request.parentIpIds, - request.licenseTermsIds, - request.licenseTemplate, - request.royaltyContext, - ], + args: [request.to, request.value], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method registerDerivative for contract LicensingModule with only encode + * method transfer for contract MockERC20 with only encode * - * @param request LicensingModuleRegisterDerivativeRequest + * @param request MockErc20TransferRequest * @return EncodedTxData */ - public registerDerivativeEncode( - request: LicensingModuleRegisterDerivativeRequest, - ): EncodedTxData { + public transferEncode(request: MockErc20TransferRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: licensingModuleAbi, - functionName: "registerDerivative", - args: [ - request.childIpId, - request.parentIpIds, - request.licenseTermsIds, - request.licenseTemplate, - request.royaltyContext, - ], + abi: mockErc20Abi, + functionName: "transfer", + args: [request.to, request.value], }), }; } /** - * method registerDerivativeWithLicenseTokens for contract LicensingModule + * method transferFrom for contract MockERC20 * - * @param request LicensingModuleRegisterDerivativeWithLicenseTokensRequest + * @param request MockErc20TransferFromRequest * @return Promise */ - public async registerDerivativeWithLicenseTokens( - request: LicensingModuleRegisterDerivativeWithLicenseTokensRequest, + public async transferFrom( + request: MockErc20TransferFromRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: licensingModuleAbi, + abi: mockErc20Abi, address: this.address, - functionName: "registerDerivativeWithLicenseTokens", + functionName: "transferFrom", account: this.wallet.account, - args: [request.childIpId, request.licenseTokenIds, request.royaltyContext], + args: [request.from, request.to, request.value], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method registerDerivativeWithLicenseTokens for contract LicensingModule with only encode + * method transferFrom for contract MockERC20 with only encode * - * @param request LicensingModuleRegisterDerivativeWithLicenseTokensRequest + * @param request MockErc20TransferFromRequest * @return EncodedTxData */ - public registerDerivativeWithLicenseTokensEncode( - request: LicensingModuleRegisterDerivativeWithLicenseTokensRequest, - ): EncodedTxData { + public transferFromEncode(request: MockErc20TransferFromRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: licensingModuleAbi, - functionName: "registerDerivativeWithLicenseTokens", - args: [request.childIpId, request.licenseTokenIds, request.royaltyContext], + abi: mockErc20Abi, + functionName: "transferFrom", + args: [request.from, request.to, request.value], }), }; } @@ -12521,13 +20374,13 @@ export type PiLicenseTemplateGetRoyaltyPolicyRequest = { * PiLicenseTemplateGetRoyaltyPolicyResponse * * @param royaltyPolicy address - * @param royaltyData bytes + * @param royaltyPercent uint32 * @param mintingFee uint256 * @param currency address */ export type PiLicenseTemplateGetRoyaltyPolicyResponse = { royaltyPolicy: Address; - royaltyData: Hex; + royaltyPercent: number; mintingFee: bigint; currency: Address; }; @@ -13182,7 +21035,7 @@ export class PiLicenseTemplateReadOnlyClient extends PiLicenseTemplateEventClien }); return { royaltyPolicy: result[0], - royaltyData: result[1], + royaltyPercent: result[1], mintingFee: result[2], currency: result[3], }; @@ -13251,1010 +21104,1450 @@ export class PiLicenseTemplateReadOnlyClient extends PiLicenseTemplateEventClien } /** - * method proxiableUUID for contract PILicenseTemplate + * method proxiableUUID for contract PILicenseTemplate + * + * @param request PiLicenseTemplateProxiableUuidRequest + * @return Promise + */ + public async proxiableUuid(): Promise { + return await this.rpcClient.readContract({ + abi: piLicenseTemplateAbi, + address: this.address, + functionName: "proxiableUUID", + }); + } + + /** + * method supportsInterface for contract PILicenseTemplate + * + * @param request PiLicenseTemplateSupportsInterfaceRequest + * @return Promise + */ + public async supportsInterface( + request: PiLicenseTemplateSupportsInterfaceRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: piLicenseTemplateAbi, + address: this.address, + functionName: "supportsInterface", + args: [request.interfaceId], + }); + } + + /** + * method toJson for contract PILicenseTemplate + * + * @param request PiLicenseTemplateToJsonRequest + * @return Promise + */ + public async toJson( + request: PiLicenseTemplateToJsonRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: piLicenseTemplateAbi, + address: this.address, + functionName: "toJson", + args: [request.licenseTermsId], + }); + } + + /** + * method totalRegisteredLicenseTerms for contract PILicenseTemplate + * + * @param request PiLicenseTemplateTotalRegisteredLicenseTermsRequest + * @return Promise + */ + public async totalRegisteredLicenseTerms(): Promise { + return await this.rpcClient.readContract({ + abi: piLicenseTemplateAbi, + address: this.address, + functionName: "totalRegisteredLicenseTerms", + }); + } + + /** + * method verifyCompatibleLicenses for contract PILicenseTemplate + * + * @param request PiLicenseTemplateVerifyCompatibleLicensesRequest + * @return Promise + */ + public async verifyCompatibleLicenses( + request: PiLicenseTemplateVerifyCompatibleLicensesRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: piLicenseTemplateAbi, + address: this.address, + functionName: "verifyCompatibleLicenses", + args: [request.licenseTermsIds], + }); + } +} + +/** + * contract PILicenseTemplate write method + */ +export class PiLicenseTemplateClient extends PiLicenseTemplateReadOnlyClient { + protected readonly wallet: SimpleWalletClient; + + constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { + super(rpcClient, address); + this.wallet = wallet; + } + + /** + * method initialize for contract PILicenseTemplate + * + * @param request PiLicenseTemplateInitializeRequest + * @return Promise + */ + public async initialize( + request: PiLicenseTemplateInitializeRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: piLicenseTemplateAbi, + address: this.address, + functionName: "initialize", + account: this.wallet.account, + args: [request.accessManager, request.name, request.metadataURI], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method initialize for contract PILicenseTemplate with only encode + * + * @param request PiLicenseTemplateInitializeRequest + * @return EncodedTxData + */ + public initializeEncode(request: PiLicenseTemplateInitializeRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: piLicenseTemplateAbi, + functionName: "initialize", + args: [request.accessManager, request.name, request.metadataURI], + }), + }; + } + + /** + * method registerLicenseTerms for contract PILicenseTemplate + * + * @param request PiLicenseTemplateRegisterLicenseTermsRequest + * @return Promise + */ + public async registerLicenseTerms( + request: PiLicenseTemplateRegisterLicenseTermsRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: piLicenseTemplateAbi, + address: this.address, + functionName: "registerLicenseTerms", + account: this.wallet.account, + args: [request.terms], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method registerLicenseTerms for contract PILicenseTemplate with only encode + * + * @param request PiLicenseTemplateRegisterLicenseTermsRequest + * @return EncodedTxData + */ + public registerLicenseTermsEncode( + request: PiLicenseTemplateRegisterLicenseTermsRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: piLicenseTemplateAbi, + functionName: "registerLicenseTerms", + args: [request.terms], + }), + }; + } + + /** + * method setApproval for contract PILicenseTemplate + * + * @param request PiLicenseTemplateSetApprovalRequest + * @return Promise + */ + public async setApproval( + request: PiLicenseTemplateSetApprovalRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: piLicenseTemplateAbi, + address: this.address, + functionName: "setApproval", + account: this.wallet.account, + args: [request.parentIpId, request.licenseTermsId, request.childIpId, request.approved], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setApproval for contract PILicenseTemplate with only encode + * + * @param request PiLicenseTemplateSetApprovalRequest + * @return EncodedTxData + */ + public setApprovalEncode(request: PiLicenseTemplateSetApprovalRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: piLicenseTemplateAbi, + functionName: "setApproval", + args: [request.parentIpId, request.licenseTermsId, request.childIpId, request.approved], + }), + }; + } + + /** + * method setAuthority for contract PILicenseTemplate * - * @param request PiLicenseTemplateProxiableUuidRequest - * @return Promise + * @param request PiLicenseTemplateSetAuthorityRequest + * @return Promise */ - public async proxiableUuid(): Promise { - return await this.rpcClient.readContract({ + public async setAuthority( + request: PiLicenseTemplateSetAuthorityRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ abi: piLicenseTemplateAbi, address: this.address, - functionName: "proxiableUUID", + functionName: "setAuthority", + account: this.wallet.account, + args: [request.newAuthority], }); + return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method supportsInterface for contract PILicenseTemplate + * method setAuthority for contract PILicenseTemplate with only encode * - * @param request PiLicenseTemplateSupportsInterfaceRequest - * @return Promise + * @param request PiLicenseTemplateSetAuthorityRequest + * @return EncodedTxData */ - public async supportsInterface( - request: PiLicenseTemplateSupportsInterfaceRequest, - ): Promise { - return await this.rpcClient.readContract({ - abi: piLicenseTemplateAbi, - address: this.address, - functionName: "supportsInterface", - args: [request.interfaceId], - }); + public setAuthorityEncode(request: PiLicenseTemplateSetAuthorityRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: piLicenseTemplateAbi, + functionName: "setAuthority", + args: [request.newAuthority], + }), + }; } /** - * method toJson for contract PILicenseTemplate + * method upgradeToAndCall for contract PILicenseTemplate * - * @param request PiLicenseTemplateToJsonRequest - * @return Promise + * @param request PiLicenseTemplateUpgradeToAndCallRequest + * @return Promise */ - public async toJson( - request: PiLicenseTemplateToJsonRequest, - ): Promise { - return await this.rpcClient.readContract({ + public async upgradeToAndCall( + request: PiLicenseTemplateUpgradeToAndCallRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ abi: piLicenseTemplateAbi, address: this.address, - functionName: "toJson", - args: [request.licenseTermsId], + functionName: "upgradeToAndCall", + account: this.wallet.account, + args: [request.newImplementation, request.data], }); + return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method totalRegisteredLicenseTerms for contract PILicenseTemplate + * method upgradeToAndCall for contract PILicenseTemplate with only encode * - * @param request PiLicenseTemplateTotalRegisteredLicenseTermsRequest - * @return Promise + * @param request PiLicenseTemplateUpgradeToAndCallRequest + * @return EncodedTxData */ - public async totalRegisteredLicenseTerms(): Promise { - return await this.rpcClient.readContract({ - abi: piLicenseTemplateAbi, - address: this.address, - functionName: "totalRegisteredLicenseTerms", - }); + public upgradeToAndCallEncode(request: PiLicenseTemplateUpgradeToAndCallRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: piLicenseTemplateAbi, + functionName: "upgradeToAndCall", + args: [request.newImplementation, request.data], + }), + }; } /** - * method verifyCompatibleLicenses for contract PILicenseTemplate + * method verifyMintLicenseToken for contract PILicenseTemplate * - * @param request PiLicenseTemplateVerifyCompatibleLicensesRequest - * @return Promise + * @param request PiLicenseTemplateVerifyMintLicenseTokenRequest + * @return Promise */ - public async verifyCompatibleLicenses( - request: PiLicenseTemplateVerifyCompatibleLicensesRequest, - ): Promise { - return await this.rpcClient.readContract({ + public async verifyMintLicenseToken( + request: PiLicenseTemplateVerifyMintLicenseTokenRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ abi: piLicenseTemplateAbi, address: this.address, - functionName: "verifyCompatibleLicenses", - args: [request.licenseTermsIds], + functionName: "verifyMintLicenseToken", + account: this.wallet.account, + args: [request[0], request[1], request[2], request[3]], }); + return await this.wallet.writeContract(call as WriteContractParameters); } -} - -/** - * contract PILicenseTemplate write method - */ -export class PiLicenseTemplateClient extends PiLicenseTemplateReadOnlyClient { - protected readonly wallet: SimpleWalletClient; - constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { - super(rpcClient, address); - this.wallet = wallet; + /** + * method verifyMintLicenseToken for contract PILicenseTemplate with only encode + * + * @param request PiLicenseTemplateVerifyMintLicenseTokenRequest + * @return EncodedTxData + */ + public verifyMintLicenseTokenEncode( + request: PiLicenseTemplateVerifyMintLicenseTokenRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: piLicenseTemplateAbi, + functionName: "verifyMintLicenseToken", + args: [request[0], request[1], request[2], request[3]], + }), + }; } /** - * method initialize for contract PILicenseTemplate + * method verifyRegisterDerivative for contract PILicenseTemplate * - * @param request PiLicenseTemplateInitializeRequest + * @param request PiLicenseTemplateVerifyRegisterDerivativeRequest * @return Promise */ - public async initialize( - request: PiLicenseTemplateInitializeRequest, + public async verifyRegisterDerivative( + request: PiLicenseTemplateVerifyRegisterDerivativeRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ abi: piLicenseTemplateAbi, address: this.address, - functionName: "initialize", + functionName: "verifyRegisterDerivative", account: this.wallet.account, - args: [request.accessManager, request.name, request.metadataURI], + args: [request.childIpId, request.parentIpId, request.licenseTermsId, request.licensee], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method initialize for contract PILicenseTemplate with only encode + * method verifyRegisterDerivative for contract PILicenseTemplate with only encode * - * @param request PiLicenseTemplateInitializeRequest + * @param request PiLicenseTemplateVerifyRegisterDerivativeRequest * @return EncodedTxData */ - public initializeEncode(request: PiLicenseTemplateInitializeRequest): EncodedTxData { + public verifyRegisterDerivativeEncode( + request: PiLicenseTemplateVerifyRegisterDerivativeRequest, + ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ abi: piLicenseTemplateAbi, - functionName: "initialize", - args: [request.accessManager, request.name, request.metadataURI], + functionName: "verifyRegisterDerivative", + args: [request.childIpId, request.parentIpId, request.licenseTermsId, request.licensee], }), }; } /** - * method registerLicenseTerms for contract PILicenseTemplate + * method verifyRegisterDerivativeForAllParents for contract PILicenseTemplate * - * @param request PiLicenseTemplateRegisterLicenseTermsRequest + * @param request PiLicenseTemplateVerifyRegisterDerivativeForAllParentsRequest * @return Promise */ - public async registerLicenseTerms( - request: PiLicenseTemplateRegisterLicenseTermsRequest, + public async verifyRegisterDerivativeForAllParents( + request: PiLicenseTemplateVerifyRegisterDerivativeForAllParentsRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ abi: piLicenseTemplateAbi, address: this.address, - functionName: "registerLicenseTerms", + functionName: "verifyRegisterDerivativeForAllParents", account: this.wallet.account, - args: [request.terms], + args: [request.childIpId, request.parentIpIds, request.licenseTermsIds, request.childIpOwner], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method verifyRegisterDerivativeForAllParents for contract PILicenseTemplate with only encode + * + * @param request PiLicenseTemplateVerifyRegisterDerivativeForAllParentsRequest + * @return EncodedTxData + */ + public verifyRegisterDerivativeForAllParentsEncode( + request: PiLicenseTemplateVerifyRegisterDerivativeForAllParentsRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: piLicenseTemplateAbi, + functionName: "verifyRegisterDerivativeForAllParents", + args: [ + request.childIpId, + request.parentIpIds, + request.licenseTermsIds, + request.childIpOwner, + ], + }), + }; + } +} + +// Contract RegistrationWorkflows ============================================================= + +/** + * RegistrationWorkflowsCollectionCreatedEvent + * + * @param spgNftContract address + */ +export type RegistrationWorkflowsCollectionCreatedEvent = { + spgNftContract: Address; +}; + +/** + * RegistrationWorkflowsCreateCollectionRequest + * + * @param spgNftInitParams tuple + */ +export type RegistrationWorkflowsCreateCollectionRequest = { + spgNftInitParams: { + name: string; + symbol: string; + baseURI: string; + contractURI: string; + maxSupply: number; + mintFee: bigint; + mintFeeToken: Address; + mintFeeRecipient: Address; + owner: Address; + mintOpen: boolean; + isPublicMinting: boolean; + }; +}; + +/** + * RegistrationWorkflowsMintAndRegisterIpRequest + * + * @param spgNftContract address + * @param recipient address + * @param ipMetadata tuple + */ +export type RegistrationWorkflowsMintAndRegisterIpRequest = { + spgNftContract: Address; + recipient: Address; + ipMetadata: { + ipMetadataURI: string; + ipMetadataHash: Hex; + nftMetadataURI: string; + nftMetadataHash: Hex; + }; +}; + +/** + * RegistrationWorkflowsRegisterIpRequest + * + * @param nftContract address + * @param tokenId uint256 + * @param ipMetadata tuple + * @param sigMetadata tuple + */ +export type RegistrationWorkflowsRegisterIpRequest = { + nftContract: Address; + tokenId: bigint; + ipMetadata: { + ipMetadataURI: string; + ipMetadataHash: Hex; + nftMetadataURI: string; + nftMetadataHash: Hex; + }; + sigMetadata: { + signer: Address; + deadline: bigint; + signature: Hex; + }; +}; + +/** + * contract RegistrationWorkflows event + */ +export class RegistrationWorkflowsEventClient { + protected readonly rpcClient: PublicClient; + public readonly address: Address; + + constructor(rpcClient: PublicClient, address?: Address) { + this.address = address || getAddress(registrationWorkflowsAddress, rpcClient.chain?.id); + this.rpcClient = rpcClient; + } + + /** + * event CollectionCreated for contract RegistrationWorkflows + */ + public watchCollectionCreatedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: registrationWorkflowsAbi, + address: this.address, + eventName: "CollectionCreated", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, }); - return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method registerLicenseTerms for contract PILicenseTemplate with only encode - * - * @param request PiLicenseTemplateRegisterLicenseTermsRequest - * @return EncodedTxData + * parse tx receipt event CollectionCreated for contract RegistrationWorkflows */ - public registerLicenseTermsEncode( - request: PiLicenseTemplateRegisterLicenseTermsRequest, - ): EncodedTxData { - return { - to: this.address, - data: encodeFunctionData({ - abi: piLicenseTemplateAbi, - functionName: "registerLicenseTerms", - args: [request.terms], - }), - }; + public parseTxCollectionCreatedEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: registrationWorkflowsAbi, + eventName: "CollectionCreated", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "CollectionCreated") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } +} + +/** + * contract RegistrationWorkflows write method + */ +export class RegistrationWorkflowsClient extends RegistrationWorkflowsEventClient { + protected readonly wallet: SimpleWalletClient; + + constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { + super(rpcClient, address); + this.wallet = wallet; } /** - * method setApproval for contract PILicenseTemplate + * method createCollection for contract RegistrationWorkflows * - * @param request PiLicenseTemplateSetApprovalRequest + * @param request RegistrationWorkflowsCreateCollectionRequest * @return Promise */ - public async setApproval( - request: PiLicenseTemplateSetApprovalRequest, + public async createCollection( + request: RegistrationWorkflowsCreateCollectionRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: piLicenseTemplateAbi, + abi: registrationWorkflowsAbi, address: this.address, - functionName: "setApproval", + functionName: "createCollection", account: this.wallet.account, - args: [request.parentIpId, request.licenseTermsId, request.childIpId, request.approved], + args: [request.spgNftInitParams], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method setApproval for contract PILicenseTemplate with only encode + * method createCollection for contract RegistrationWorkflows with only encode * - * @param request PiLicenseTemplateSetApprovalRequest + * @param request RegistrationWorkflowsCreateCollectionRequest * @return EncodedTxData */ - public setApprovalEncode(request: PiLicenseTemplateSetApprovalRequest): EncodedTxData { + public createCollectionEncode( + request: RegistrationWorkflowsCreateCollectionRequest, + ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: piLicenseTemplateAbi, - functionName: "setApproval", - args: [request.parentIpId, request.licenseTermsId, request.childIpId, request.approved], + abi: registrationWorkflowsAbi, + functionName: "createCollection", + args: [request.spgNftInitParams], }), }; } /** - * method setAuthority for contract PILicenseTemplate + * method mintAndRegisterIp for contract RegistrationWorkflows * - * @param request PiLicenseTemplateSetAuthorityRequest + * @param request RegistrationWorkflowsMintAndRegisterIpRequest * @return Promise */ - public async setAuthority( - request: PiLicenseTemplateSetAuthorityRequest, + public async mintAndRegisterIp( + request: RegistrationWorkflowsMintAndRegisterIpRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: piLicenseTemplateAbi, + abi: registrationWorkflowsAbi, address: this.address, - functionName: "setAuthority", + functionName: "mintAndRegisterIp", account: this.wallet.account, - args: [request.newAuthority], + args: [request.spgNftContract, request.recipient, request.ipMetadata], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method setAuthority for contract PILicenseTemplate with only encode + * method mintAndRegisterIp for contract RegistrationWorkflows with only encode * - * @param request PiLicenseTemplateSetAuthorityRequest + * @param request RegistrationWorkflowsMintAndRegisterIpRequest * @return EncodedTxData */ - public setAuthorityEncode(request: PiLicenseTemplateSetAuthorityRequest): EncodedTxData { + public mintAndRegisterIpEncode( + request: RegistrationWorkflowsMintAndRegisterIpRequest, + ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: piLicenseTemplateAbi, - functionName: "setAuthority", - args: [request.newAuthority], + abi: registrationWorkflowsAbi, + functionName: "mintAndRegisterIp", + args: [request.spgNftContract, request.recipient, request.ipMetadata], }), }; } /** - * method upgradeToAndCall for contract PILicenseTemplate + * method registerIp for contract RegistrationWorkflows * - * @param request PiLicenseTemplateUpgradeToAndCallRequest + * @param request RegistrationWorkflowsRegisterIpRequest * @return Promise */ - public async upgradeToAndCall( - request: PiLicenseTemplateUpgradeToAndCallRequest, + public async registerIp( + request: RegistrationWorkflowsRegisterIpRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: piLicenseTemplateAbi, + abi: registrationWorkflowsAbi, address: this.address, - functionName: "upgradeToAndCall", + functionName: "registerIp", account: this.wallet.account, - args: [request.newImplementation, request.data], + args: [request.nftContract, request.tokenId, request.ipMetadata, request.sigMetadata], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method upgradeToAndCall for contract PILicenseTemplate with only encode + * method registerIp for contract RegistrationWorkflows with only encode * - * @param request PiLicenseTemplateUpgradeToAndCallRequest + * @param request RegistrationWorkflowsRegisterIpRequest * @return EncodedTxData */ - public upgradeToAndCallEncode(request: PiLicenseTemplateUpgradeToAndCallRequest): EncodedTxData { + public registerIpEncode(request: RegistrationWorkflowsRegisterIpRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: piLicenseTemplateAbi, - functionName: "upgradeToAndCall", - args: [request.newImplementation, request.data], + abi: registrationWorkflowsAbi, + functionName: "registerIp", + args: [request.nftContract, request.tokenId, request.ipMetadata, request.sigMetadata], }), }; } +} + +// Contract RoyaltyModule ============================================================= + +/** + * RoyaltyModuleIpRoyaltyVaultsRequest + * + * @param ipId address + */ +export type RoyaltyModuleIpRoyaltyVaultsRequest = { + ipId: Address; +}; + +export type RoyaltyModuleIpRoyaltyVaultsResponse = Address; + +/** + * RoyaltyModuleIsWhitelistedRoyaltyPolicyRequest + * + * @param royaltyPolicy address + */ +export type RoyaltyModuleIsWhitelistedRoyaltyPolicyRequest = { + royaltyPolicy: Address; +}; + +export type RoyaltyModuleIsWhitelistedRoyaltyPolicyResponse = boolean; + +/** + * RoyaltyModuleIsWhitelistedRoyaltyTokenRequest + * + * @param token address + */ +export type RoyaltyModuleIsWhitelistedRoyaltyTokenRequest = { + token: Address; +}; + +export type RoyaltyModuleIsWhitelistedRoyaltyTokenResponse = boolean; + +/** + * RoyaltyModulePayRoyaltyOnBehalfRequest + * + * @param receiverIpId address + * @param payerIpId address + * @param token address + * @param amount uint256 + */ +export type RoyaltyModulePayRoyaltyOnBehalfRequest = { + receiverIpId: Address; + payerIpId: Address; + token: Address; + amount: bigint; +}; + +/** + * contract RoyaltyModule readonly method + */ +export class RoyaltyModuleReadOnlyClient { + protected readonly rpcClient: PublicClient; + public readonly address: Address; + + constructor(rpcClient: PublicClient, address?: Address) { + this.address = address || getAddress(royaltyModuleAddress, rpcClient.chain?.id); + this.rpcClient = rpcClient; + } /** - * method verifyMintLicenseToken for contract PILicenseTemplate + * method ipRoyaltyVaults for contract RoyaltyModule * - * @param request PiLicenseTemplateVerifyMintLicenseTokenRequest - * @return Promise + * @param request RoyaltyModuleIpRoyaltyVaultsRequest + * @return Promise */ - public async verifyMintLicenseToken( - request: PiLicenseTemplateVerifyMintLicenseTokenRequest, - ): Promise { - const { request: call } = await this.rpcClient.simulateContract({ - abi: piLicenseTemplateAbi, + public async ipRoyaltyVaults( + request: RoyaltyModuleIpRoyaltyVaultsRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: royaltyModuleAbi, address: this.address, - functionName: "verifyMintLicenseToken", - account: this.wallet.account, - args: [request[0], request[1], request[2], request[3]], + functionName: "ipRoyaltyVaults", + args: [request.ipId], }); - return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method verifyMintLicenseToken for contract PILicenseTemplate with only encode + * method isWhitelistedRoyaltyPolicy for contract RoyaltyModule * - * @param request PiLicenseTemplateVerifyMintLicenseTokenRequest - * @return EncodedTxData + * @param request RoyaltyModuleIsWhitelistedRoyaltyPolicyRequest + * @return Promise */ - public verifyMintLicenseTokenEncode( - request: PiLicenseTemplateVerifyMintLicenseTokenRequest, - ): EncodedTxData { - return { - to: this.address, - data: encodeFunctionData({ - abi: piLicenseTemplateAbi, - functionName: "verifyMintLicenseToken", - args: [request[0], request[1], request[2], request[3]], - }), - }; + public async isWhitelistedRoyaltyPolicy( + request: RoyaltyModuleIsWhitelistedRoyaltyPolicyRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: royaltyModuleAbi, + address: this.address, + functionName: "isWhitelistedRoyaltyPolicy", + args: [request.royaltyPolicy], + }); } /** - * method verifyRegisterDerivative for contract PILicenseTemplate + * method isWhitelistedRoyaltyToken for contract RoyaltyModule * - * @param request PiLicenseTemplateVerifyRegisterDerivativeRequest - * @return Promise + * @param request RoyaltyModuleIsWhitelistedRoyaltyTokenRequest + * @return Promise */ - public async verifyRegisterDerivative( - request: PiLicenseTemplateVerifyRegisterDerivativeRequest, - ): Promise { - const { request: call } = await this.rpcClient.simulateContract({ - abi: piLicenseTemplateAbi, + public async isWhitelistedRoyaltyToken( + request: RoyaltyModuleIsWhitelistedRoyaltyTokenRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: royaltyModuleAbi, address: this.address, - functionName: "verifyRegisterDerivative", - account: this.wallet.account, - args: [request.childIpId, request.parentIpId, request.licenseTermsId, request.licensee], + functionName: "isWhitelistedRoyaltyToken", + args: [request.token], }); - return await this.wallet.writeContract(call as WriteContractParameters); } +} - /** - * method verifyRegisterDerivative for contract PILicenseTemplate with only encode - * - * @param request PiLicenseTemplateVerifyRegisterDerivativeRequest - * @return EncodedTxData - */ - public verifyRegisterDerivativeEncode( - request: PiLicenseTemplateVerifyRegisterDerivativeRequest, - ): EncodedTxData { - return { - to: this.address, - data: encodeFunctionData({ - abi: piLicenseTemplateAbi, - functionName: "verifyRegisterDerivative", - args: [request.childIpId, request.parentIpId, request.licenseTermsId, request.licensee], - }), - }; +/** + * contract RoyaltyModule write method + */ +export class RoyaltyModuleClient extends RoyaltyModuleReadOnlyClient { + protected readonly wallet: SimpleWalletClient; + + constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { + super(rpcClient, address); + this.wallet = wallet; } /** - * method verifyRegisterDerivativeForAllParents for contract PILicenseTemplate + * method payRoyaltyOnBehalf for contract RoyaltyModule * - * @param request PiLicenseTemplateVerifyRegisterDerivativeForAllParentsRequest + * @param request RoyaltyModulePayRoyaltyOnBehalfRequest * @return Promise - */ - public async verifyRegisterDerivativeForAllParents( - request: PiLicenseTemplateVerifyRegisterDerivativeForAllParentsRequest, + */ + public async payRoyaltyOnBehalf( + request: RoyaltyModulePayRoyaltyOnBehalfRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: piLicenseTemplateAbi, + abi: royaltyModuleAbi, address: this.address, - functionName: "verifyRegisterDerivativeForAllParents", + functionName: "payRoyaltyOnBehalf", account: this.wallet.account, - args: [request.childIpId, request.parentIpIds, request.licenseTermsIds, request.childIpOwner], + args: [request.receiverIpId, request.payerIpId, request.token, request.amount], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method verifyRegisterDerivativeForAllParents for contract PILicenseTemplate with only encode + * method payRoyaltyOnBehalf for contract RoyaltyModule with only encode * - * @param request PiLicenseTemplateVerifyRegisterDerivativeForAllParentsRequest + * @param request RoyaltyModulePayRoyaltyOnBehalfRequest * @return EncodedTxData */ - public verifyRegisterDerivativeForAllParentsEncode( - request: PiLicenseTemplateVerifyRegisterDerivativeForAllParentsRequest, - ): EncodedTxData { + public payRoyaltyOnBehalfEncode(request: RoyaltyModulePayRoyaltyOnBehalfRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: piLicenseTemplateAbi, - functionName: "verifyRegisterDerivativeForAllParents", - args: [ - request.childIpId, - request.parentIpIds, - request.licenseTermsIds, - request.childIpOwner, - ], + abi: royaltyModuleAbi, + functionName: "payRoyaltyOnBehalf", + args: [request.receiverIpId, request.payerIpId, request.token, request.amount], }), }; } } -// Contract RoyaltyModule ============================================================= +// Contract RoyaltyPolicyLAP ============================================================= + +// Contract RoyaltyPolicyLRP ============================================================= /** - * RoyaltyModuleIsWhitelistedRoyaltyPolicyRequest + * RoyaltyPolicyLrpAuthorityUpdatedEvent * - * @param royaltyPolicy address + * @param authority address */ -export type RoyaltyModuleIsWhitelistedRoyaltyPolicyRequest = { - royaltyPolicy: Address; +export type RoyaltyPolicyLrpAuthorityUpdatedEvent = { + authority: Address; }; -export type RoyaltyModuleIsWhitelistedRoyaltyPolicyResponse = boolean; +/** + * RoyaltyPolicyLrpInitializedEvent + * + * @param version uint64 + */ +export type RoyaltyPolicyLrpInitializedEvent = { + version: bigint; +}; /** - * RoyaltyModuleIsWhitelistedRoyaltyTokenRequest + * RoyaltyPolicyLrpPausedEvent + * + * @param account address + */ +export type RoyaltyPolicyLrpPausedEvent = { + account: Address; +}; + +/** + * RoyaltyPolicyLrpRevenueTransferredToVaultEvent * + * @param ipId address + * @param ancestorIpId address * @param token address + * @param amount uint256 */ -export type RoyaltyModuleIsWhitelistedRoyaltyTokenRequest = { +export type RoyaltyPolicyLrpRevenueTransferredToVaultEvent = { + ipId: Address; + ancestorIpId: Address; token: Address; + amount: bigint; }; -export type RoyaltyModuleIsWhitelistedRoyaltyTokenResponse = boolean; +/** + * RoyaltyPolicyLrpUnpausedEvent + * + * @param account address + */ +export type RoyaltyPolicyLrpUnpausedEvent = { + account: Address; +}; /** - * RoyaltyModulePayRoyaltyOnBehalfRequest + * RoyaltyPolicyLrpUpgradedEvent * - * @param receiverIpId address - * @param payerIpId address + * @param implementation address + */ +export type RoyaltyPolicyLrpUpgradedEvent = { + implementation: Address; +}; + +export type RoyaltyPolicyLrpIpGraphResponse = Address; + +export type RoyaltyPolicyLrpIpGraphAclResponse = Address; + +export type RoyaltyPolicyLrpRoyaltyModuleResponse = Address; + +export type RoyaltyPolicyLrpUpgradeInterfaceVersionResponse = string; + +export type RoyaltyPolicyLrpAuthorityResponse = Address; + +/** + * RoyaltyPolicyLrpGetPolicyRoyaltyStackRequest + * + * @param ipId address + */ +export type RoyaltyPolicyLrpGetPolicyRoyaltyStackRequest = { + ipId: Address; +}; + +export type RoyaltyPolicyLrpGetPolicyRoyaltyStackResponse = number; + +/** + * RoyaltyPolicyLrpGetPolicyRtsRequiredToLinkRequest + * + * @param ipId address + * @param licensePercent uint32 + */ +export type RoyaltyPolicyLrpGetPolicyRtsRequiredToLinkRequest = { + ipId: Address; + licensePercent: number; +}; + +export type RoyaltyPolicyLrpGetPolicyRtsRequiredToLinkResponse = number; + +/** + * RoyaltyPolicyLrpGetTransferredTokensRequest + * + * @param ipId address + * @param ancestorIpId address + * @param token address + */ +export type RoyaltyPolicyLrpGetTransferredTokensRequest = { + ipId: Address; + ancestorIpId: Address; + token: Address; +}; + +export type RoyaltyPolicyLrpGetTransferredTokensResponse = bigint; + +export type RoyaltyPolicyLrpIsConsumingScheduledOpResponse = Hex; + +export type RoyaltyPolicyLrpPausedResponse = boolean; + +export type RoyaltyPolicyLrpProxiableUuidResponse = Hex; + +/** + * RoyaltyPolicyLrpProtocolPausableInitRequest + * + * @param accessManager address + */ +export type RoyaltyPolicyLrpProtocolPausableInitRequest = { + accessManager: Address; +}; + +/** + * RoyaltyPolicyLrpGetPolicyRoyaltyRequest + * + * @param ipId address + * @param ancestorIpId address + */ +export type RoyaltyPolicyLrpGetPolicyRoyaltyRequest = { + ipId: Address; + ancestorIpId: Address; +}; + +/** + * RoyaltyPolicyLrpInitializeRequest + * + * @param accessManager address + */ +export type RoyaltyPolicyLrpInitializeRequest = { + accessManager: Address; +}; + +/** + * RoyaltyPolicyLrpOnLicenseMintingRequest + * + * @param 0 address + * @param 1 uint32 + * @param 2 bytes + */ +export type RoyaltyPolicyLrpOnLicenseMintingRequest = readonly [Address, number, Hex]; + +/** + * RoyaltyPolicyLrpOnLinkToParentsRequest + * + * @param 0 address + * @param 1 address[] + * @param 2 address[] + * @param 3 uint32[] + * @param 4 bytes + */ +export type RoyaltyPolicyLrpOnLinkToParentsRequest = readonly [ + Address, + readonly Address[], + readonly Address[], + readonly number[], + Hex, +]; + +/** + * RoyaltyPolicyLrpSetAuthorityRequest + * + * @param newAuthority address + */ +export type RoyaltyPolicyLrpSetAuthorityRequest = { + newAuthority: Address; +}; + +/** + * RoyaltyPolicyLrpTransferToVaultRequest + * + * @param ipId address + * @param ancestorIpId address * @param token address * @param amount uint256 */ -export type RoyaltyModulePayRoyaltyOnBehalfRequest = { - receiverIpId: Address; - payerIpId: Address; +export type RoyaltyPolicyLrpTransferToVaultRequest = { + ipId: Address; + ancestorIpId: Address; token: Address; amount: bigint; }; /** - * contract RoyaltyModule readonly method + * RoyaltyPolicyLrpUpgradeToAndCallRequest + * + * @param newImplementation address + * @param data bytes */ -export class RoyaltyModuleReadOnlyClient { +export type RoyaltyPolicyLrpUpgradeToAndCallRequest = { + newImplementation: Address; + data: Hex; +}; + +/** + * contract RoyaltyPolicyLRP event + */ +export class RoyaltyPolicyLrpEventClient { protected readonly rpcClient: PublicClient; public readonly address: Address; constructor(rpcClient: PublicClient, address?: Address) { - this.address = address || getAddress(royaltyModuleAddress, rpcClient.chain?.id); + this.address = address || getAddress(royaltyPolicyLrpAddress, rpcClient.chain?.id); this.rpcClient = rpcClient; } /** - * method isWhitelistedRoyaltyPolicy for contract RoyaltyModule - * - * @param request RoyaltyModuleIsWhitelistedRoyaltyPolicyRequest - * @return Promise + * event AuthorityUpdated for contract RoyaltyPolicyLRP */ - public async isWhitelistedRoyaltyPolicy( - request: RoyaltyModuleIsWhitelistedRoyaltyPolicyRequest, - ): Promise { - return await this.rpcClient.readContract({ - abi: royaltyModuleAbi, + public watchAuthorityUpdatedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: royaltyPolicyLrpAbi, address: this.address, - functionName: "isWhitelistedRoyaltyPolicy", - args: [request.royaltyPolicy], + eventName: "AuthorityUpdated", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, }); } /** - * method isWhitelistedRoyaltyToken for contract RoyaltyModule - * - * @param request RoyaltyModuleIsWhitelistedRoyaltyTokenRequest - * @return Promise + * parse tx receipt event AuthorityUpdated for contract RoyaltyPolicyLRP */ - public async isWhitelistedRoyaltyToken( - request: RoyaltyModuleIsWhitelistedRoyaltyTokenRequest, - ): Promise { - return await this.rpcClient.readContract({ - abi: royaltyModuleAbi, + public parseTxAuthorityUpdatedEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: royaltyPolicyLrpAbi, + 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 RoyaltyPolicyLRP + */ + public watchInitializedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: royaltyPolicyLrpAbi, address: this.address, - functionName: "isWhitelistedRoyaltyToken", - args: [request.token], + eventName: "Initialized", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, }); } -} - -/** - * contract RoyaltyModule write method - */ -export class RoyaltyModuleClient extends RoyaltyModuleReadOnlyClient { - protected readonly wallet: SimpleWalletClient; - constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { - super(rpcClient, address); - this.wallet = wallet; + /** + * parse tx receipt event Initialized for contract RoyaltyPolicyLRP + */ + public parseTxInitializedEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: royaltyPolicyLrpAbi, + eventName: "Initialized", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "Initialized") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; } /** - * method payRoyaltyOnBehalf for contract RoyaltyModule - * - * @param request RoyaltyModulePayRoyaltyOnBehalfRequest - * @return Promise + * event Paused for contract RoyaltyPolicyLRP */ - public async payRoyaltyOnBehalf( - request: RoyaltyModulePayRoyaltyOnBehalfRequest, - ): Promise { - const { request: call } = await this.rpcClient.simulateContract({ - abi: royaltyModuleAbi, + public watchPausedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: royaltyPolicyLrpAbi, address: this.address, - functionName: "payRoyaltyOnBehalf", - account: this.wallet.account, - args: [request.receiverIpId, request.payerIpId, request.token, request.amount], + eventName: "Paused", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, }); - return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method payRoyaltyOnBehalf for contract RoyaltyModule with only encode - * - * @param request RoyaltyModulePayRoyaltyOnBehalfRequest - * @return EncodedTxData + * parse tx receipt event Paused for contract RoyaltyPolicyLRP */ - public payRoyaltyOnBehalfEncode(request: RoyaltyModulePayRoyaltyOnBehalfRequest): EncodedTxData { - return { - to: this.address, - data: encodeFunctionData({ - abi: royaltyModuleAbi, - functionName: "payRoyaltyOnBehalf", - args: [request.receiverIpId, request.payerIpId, request.token, request.amount], - }), - }; - } -} - -// Contract RoyaltyPolicyLAP ============================================================= - -/** - * RoyaltyPolicyLapGetRoyaltyDataRequest - * - * @param ipId address - */ -export type RoyaltyPolicyLapGetRoyaltyDataRequest = { - ipId: Address; -}; - -/** - * RoyaltyPolicyLapGetRoyaltyDataResponse - * - * @param 0 bool - * @param 1 address - * @param 2 uint32 - */ -export type RoyaltyPolicyLapGetRoyaltyDataResponse = readonly [boolean, Address, number]; - -/** - * RoyaltyPolicyLapOnRoyaltyPaymentRequest - * - * @param caller address - * @param ipId address - * @param token address - * @param amount uint256 - */ -export type RoyaltyPolicyLapOnRoyaltyPaymentRequest = { - caller: Address; - ipId: Address; - token: Address; - amount: bigint; -}; - -/** - * contract RoyaltyPolicyLAP readonly method - */ -export class RoyaltyPolicyLapReadOnlyClient { - protected readonly rpcClient: PublicClient; - public readonly address: Address; - - constructor(rpcClient: PublicClient, address?: Address) { - this.address = address || getAddress(royaltyPolicyLapAddress, rpcClient.chain?.id); - this.rpcClient = rpcClient; + public parseTxPausedEvent(txReceipt: TransactionReceipt): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: royaltyPolicyLrpAbi, + eventName: "Paused", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "Paused") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; } /** - * method getRoyaltyData for contract RoyaltyPolicyLAP - * - * @param request RoyaltyPolicyLapGetRoyaltyDataRequest - * @return Promise + * event RevenueTransferredToVault for contract RoyaltyPolicyLRP */ - public async getRoyaltyData( - request: RoyaltyPolicyLapGetRoyaltyDataRequest, - ): Promise { - return await this.rpcClient.readContract({ - abi: royaltyPolicyLapAbi, + public watchRevenueTransferredToVaultEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: royaltyPolicyLrpAbi, address: this.address, - functionName: "getRoyaltyData", - args: [request.ipId], + eventName: "RevenueTransferredToVault", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, }); } -} - -/** - * contract RoyaltyPolicyLAP write method - */ -export class RoyaltyPolicyLapClient extends RoyaltyPolicyLapReadOnlyClient { - protected readonly wallet: SimpleWalletClient; - constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { - super(rpcClient, address); - this.wallet = wallet; + /** + * parse tx receipt event RevenueTransferredToVault for contract RoyaltyPolicyLRP + */ + public parseTxRevenueTransferredToVaultEvent( + txReceipt: TransactionReceipt, + ): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: royaltyPolicyLrpAbi, + eventName: "RevenueTransferredToVault", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "RevenueTransferredToVault") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; } /** - * method onRoyaltyPayment for contract RoyaltyPolicyLAP - * - * @param request RoyaltyPolicyLapOnRoyaltyPaymentRequest - * @return Promise + * event Unpaused for contract RoyaltyPolicyLRP */ - public async onRoyaltyPayment( - request: RoyaltyPolicyLapOnRoyaltyPaymentRequest, - ): Promise { - const { request: call } = await this.rpcClient.simulateContract({ - abi: royaltyPolicyLapAbi, + public watchUnpausedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: royaltyPolicyLrpAbi, address: this.address, - functionName: "onRoyaltyPayment", - account: this.wallet.account, - args: [request.caller, request.ipId, request.token, request.amount], + eventName: "Unpaused", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, }); - return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method onRoyaltyPayment for contract RoyaltyPolicyLAP with only encode - * - * @param request RoyaltyPolicyLapOnRoyaltyPaymentRequest - * @return EncodedTxData + * parse tx receipt event Unpaused for contract RoyaltyPolicyLRP */ - public onRoyaltyPaymentEncode(request: RoyaltyPolicyLapOnRoyaltyPaymentRequest): EncodedTxData { - return { - to: this.address, - data: encodeFunctionData({ - abi: royaltyPolicyLapAbi, - functionName: "onRoyaltyPayment", - args: [request.caller, request.ipId, request.token, request.amount], - }), - }; + public parseTxUnpausedEvent(txReceipt: TransactionReceipt): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: royaltyPolicyLrpAbi, + eventName: "Unpaused", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "Unpaused") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; } -} - -// Contract SPG ============================================================= - -/** - * SpgCollectionCreatedEvent - * - * @param nftContract address - */ -export type SpgCollectionCreatedEvent = { - nftContract: Address; -}; - -/** - * SpgCreateCollectionRequest - * - * @param name string - * @param symbol string - * @param maxSupply uint32 - * @param mintFee uint256 - * @param mintFeeToken address - * @param owner address - */ -export type SpgCreateCollectionRequest = { - name: string; - symbol: string; - maxSupply: number; - mintFee: bigint; - mintFeeToken: Address; - owner: Address; -}; - -/** - * SpgMintAndRegisterIpRequest - * - * @param nftContract address - * @param recipient address - * @param ipMetadata tuple - */ -export type SpgMintAndRegisterIpRequest = { - nftContract: Address; - recipient: Address; - ipMetadata: { - ipMetadataURI: string; - ipMetadataHash: Hex; - nftMetadataURI: string; - nftMetadataHash: Hex; - }; -}; -/** - * SpgMintAndRegisterIpAndAttachPilTermsRequest - * - * @param nftContract address - * @param recipient address - * @param ipMetadata tuple - * @param terms tuple - */ -export type SpgMintAndRegisterIpAndAttachPilTermsRequest = { - nftContract: Address; - recipient: Address; - ipMetadata: { - ipMetadataURI: string; - ipMetadataHash: Hex; - nftMetadataURI: string; - nftMetadataHash: Hex; - }; - terms: { - transferable: boolean; - royaltyPolicy: Address; - defaultMintingFee: bigint; - expiration: bigint; - commercialUse: boolean; - commercialAttribution: boolean; - commercializerChecker: Address; - commercializerCheckerData: Hex; - commercialRevShare: number; - commercialRevCeiling: bigint; - derivativesAllowed: boolean; - derivativesAttribution: boolean; - derivativesApproval: boolean; - derivativesReciprocal: boolean; - derivativeRevCeiling: bigint; - currency: Address; - uri: string; - }; -}; + /** + * event Upgraded for contract RoyaltyPolicyLRP + */ + public watchUpgradedEvent( + onLogs: (txHash: Hex, ev: Partial) => void, + ): WatchContractEventReturnType { + return this.rpcClient.watchContractEvent({ + abi: royaltyPolicyLrpAbi, + address: this.address, + eventName: "Upgraded", + onLogs: (evs) => { + evs.forEach((it) => onLogs(it.transactionHash, it.args)); + }, + }); + } -/** - * SpgMintAndRegisterIpAndMakeDerivativeRequest - * - * @param nftContract address - * @param derivData tuple - * @param ipMetadata tuple - * @param recipient address - */ -export type SpgMintAndRegisterIpAndMakeDerivativeRequest = { - nftContract: Address; - derivData: { - parentIpIds: readonly Address[]; - licenseTemplate: Address; - licenseTermsIds: readonly bigint[]; - royaltyContext: Hex; - }; - ipMetadata: { - ipMetadataURI: string; - ipMetadataHash: Hex; - nftMetadataURI: string; - nftMetadataHash: Hex; - }; - recipient: Address; -}; + /** + * parse tx receipt event Upgraded for contract RoyaltyPolicyLRP + */ + public parseTxUpgradedEvent(txReceipt: TransactionReceipt): Array { + const targetLogs: Array = []; + for (const log of txReceipt.logs) { + try { + const event = decodeEventLog({ + abi: royaltyPolicyLrpAbi, + eventName: "Upgraded", + data: log.data, + topics: log.topics, + }); + if (event.eventName === "Upgraded") { + targetLogs.push(event.args); + } + } catch (e) { + /* empty */ + } + } + return targetLogs; + } +} /** - * SpgMintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest - * - * @param nftContract address - * @param licenseTokenIds uint256[] - * @param royaltyContext bytes - * @param ipMetadata tuple - * @param recipient address + * contract RoyaltyPolicyLRP readonly method */ -export type SpgMintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest = { - nftContract: Address; - licenseTokenIds: readonly bigint[]; - royaltyContext: Hex; - ipMetadata: { - ipMetadataURI: string; - ipMetadataHash: Hex; - nftMetadataURI: string; - nftMetadataHash: Hex; - }; - recipient: Address; -}; +export class RoyaltyPolicyLrpReadOnlyClient extends RoyaltyPolicyLrpEventClient { + constructor(rpcClient: PublicClient, address?: Address) { + super(rpcClient, address); + } -/** - * SpgRegisterIpRequest - * - * @param nftContract address - * @param tokenId uint256 - * @param ipMetadata tuple - * @param sigMetadata tuple - */ -export type SpgRegisterIpRequest = { - nftContract: Address; - tokenId: bigint; - ipMetadata: { - ipMetadataURI: string; - ipMetadataHash: Hex; - nftMetadataURI: string; - nftMetadataHash: Hex; - }; - sigMetadata: { - signer: Address; - deadline: bigint; - signature: Hex; - }; -}; + /** + * method IP_GRAPH for contract RoyaltyPolicyLRP + * + * @param request RoyaltyPolicyLrpIpGraphRequest + * @return Promise + */ + public async ipGraph(): Promise { + return await this.rpcClient.readContract({ + abi: royaltyPolicyLrpAbi, + address: this.address, + functionName: "IP_GRAPH", + }); + } -/** - * SpgRegisterIpAndAttachPilTermsRequest - * - * @param nftContract address - * @param tokenId uint256 - * @param ipMetadata tuple - * @param terms tuple - * @param sigMetadata tuple - * @param sigAttach tuple - */ -export type SpgRegisterIpAndAttachPilTermsRequest = { - nftContract: Address; - tokenId: bigint; - ipMetadata: { - ipMetadataURI: string; - ipMetadataHash: Hex; - nftMetadataURI: string; - nftMetadataHash: Hex; - }; - terms: { - transferable: boolean; - royaltyPolicy: Address; - defaultMintingFee: bigint; - expiration: bigint; - commercialUse: boolean; - commercialAttribution: boolean; - commercializerChecker: Address; - commercializerCheckerData: Hex; - commercialRevShare: number; - commercialRevCeiling: bigint; - derivativesAllowed: boolean; - derivativesAttribution: boolean; - derivativesApproval: boolean; - derivativesReciprocal: boolean; - derivativeRevCeiling: bigint; - currency: Address; - uri: string; - }; - sigMetadata: { - signer: Address; - deadline: bigint; - signature: Hex; - }; - sigAttach: { - signer: Address; - deadline: bigint; - signature: Hex; - }; -}; + /** + * method IP_GRAPH_ACL for contract RoyaltyPolicyLRP + * + * @param request RoyaltyPolicyLrpIpGraphAclRequest + * @return Promise + */ + public async ipGraphAcl(): Promise { + return await this.rpcClient.readContract({ + abi: royaltyPolicyLrpAbi, + address: this.address, + functionName: "IP_GRAPH_ACL", + }); + } -/** - * SpgRegisterIpAndMakeDerivativeRequest - * - * @param nftContract address - * @param tokenId uint256 - * @param derivData tuple - * @param ipMetadata tuple - * @param sigMetadata tuple - * @param sigRegister tuple - */ -export type SpgRegisterIpAndMakeDerivativeRequest = { - nftContract: Address; - tokenId: bigint; - derivData: { - parentIpIds: readonly Address[]; - licenseTemplate: Address; - licenseTermsIds: readonly bigint[]; - royaltyContext: Hex; - }; - ipMetadata: { - ipMetadataURI: string; - ipMetadataHash: Hex; - nftMetadataURI: string; - nftMetadataHash: Hex; - }; - sigMetadata: { - signer: Address; - deadline: bigint; - signature: Hex; - }; - sigRegister: { - signer: Address; - deadline: bigint; - signature: Hex; - }; -}; + /** + * method ROYALTY_MODULE for contract RoyaltyPolicyLRP + * + * @param request RoyaltyPolicyLrpRoyaltyModuleRequest + * @return Promise + */ + public async royaltyModule(): Promise { + return await this.rpcClient.readContract({ + abi: royaltyPolicyLrpAbi, + address: this.address, + functionName: "ROYALTY_MODULE", + }); + } -/** - * SpgRegisterIpAndMakeDerivativeWithLicenseTokensRequest - * - * @param nftContract address - * @param tokenId uint256 - * @param licenseTokenIds uint256[] - * @param royaltyContext bytes - * @param ipMetadata tuple - * @param sigMetadata tuple - * @param sigRegister tuple - */ -export type SpgRegisterIpAndMakeDerivativeWithLicenseTokensRequest = { - nftContract: Address; - tokenId: bigint; - licenseTokenIds: readonly bigint[]; - royaltyContext: Hex; - ipMetadata: { - ipMetadataURI: string; - ipMetadataHash: Hex; - nftMetadataURI: string; - nftMetadataHash: Hex; - }; - sigMetadata: { - signer: Address; - deadline: bigint; - signature: Hex; - }; - sigRegister: { - signer: Address; - deadline: bigint; - signature: Hex; - }; -}; + /** + * method UPGRADE_INTERFACE_VERSION for contract RoyaltyPolicyLRP + * + * @param request RoyaltyPolicyLrpUpgradeInterfaceVersionRequest + * @return Promise + */ + public async upgradeInterfaceVersion(): Promise { + return await this.rpcClient.readContract({ + abi: royaltyPolicyLrpAbi, + address: this.address, + functionName: "UPGRADE_INTERFACE_VERSION", + }); + } -/** - * SpgRegisterPilTermsAndAttachRequest - * - * @param ipId address - * @param terms tuple - */ -export type SpgRegisterPilTermsAndAttachRequest = { - ipId: Address; - terms: { - transferable: boolean; - royaltyPolicy: Address; - defaultMintingFee: bigint; - expiration: bigint; - commercialUse: boolean; - commercialAttribution: boolean; - commercializerChecker: Address; - commercializerCheckerData: Hex; - commercialRevShare: number; - commercialRevCeiling: bigint; - derivativesAllowed: boolean; - derivativesAttribution: boolean; - derivativesApproval: boolean; - derivativesReciprocal: boolean; - derivativeRevCeiling: bigint; - currency: Address; - uri: string; - }; -}; + /** + * method authority for contract RoyaltyPolicyLRP + * + * @param request RoyaltyPolicyLrpAuthorityRequest + * @return Promise + */ + public async authority(): Promise { + return await this.rpcClient.readContract({ + abi: royaltyPolicyLrpAbi, + address: this.address, + functionName: "authority", + }); + } -/** - * contract SPG event - */ -export class SpgEventClient { - protected readonly rpcClient: PublicClient; - public readonly address: Address; + /** + * method getPolicyRoyaltyStack for contract RoyaltyPolicyLRP + * + * @param request RoyaltyPolicyLrpGetPolicyRoyaltyStackRequest + * @return Promise + */ + public async getPolicyRoyaltyStack( + request: RoyaltyPolicyLrpGetPolicyRoyaltyStackRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: royaltyPolicyLrpAbi, + address: this.address, + functionName: "getPolicyRoyaltyStack", + args: [request.ipId], + }); + } + + /** + * method getPolicyRtsRequiredToLink for contract RoyaltyPolicyLRP + * + * @param request RoyaltyPolicyLrpGetPolicyRtsRequiredToLinkRequest + * @return Promise + */ + public async getPolicyRtsRequiredToLink( + request: RoyaltyPolicyLrpGetPolicyRtsRequiredToLinkRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: royaltyPolicyLrpAbi, + address: this.address, + functionName: "getPolicyRtsRequiredToLink", + args: [request.ipId, request.licensePercent], + }); + } + + /** + * method getTransferredTokens for contract RoyaltyPolicyLRP + * + * @param request RoyaltyPolicyLrpGetTransferredTokensRequest + * @return Promise + */ + public async getTransferredTokens( + request: RoyaltyPolicyLrpGetTransferredTokensRequest, + ): Promise { + return await this.rpcClient.readContract({ + abi: royaltyPolicyLrpAbi, + address: this.address, + functionName: "getTransferredTokens", + args: [request.ipId, request.ancestorIpId, request.token], + }); + } - constructor(rpcClient: PublicClient, address?: Address) { - this.address = address || getAddress(spgAddress, rpcClient.chain?.id); - this.rpcClient = rpcClient; + /** + * method isConsumingScheduledOp for contract RoyaltyPolicyLRP + * + * @param request RoyaltyPolicyLrpIsConsumingScheduledOpRequest + * @return Promise + */ + public async isConsumingScheduledOp(): Promise { + return await this.rpcClient.readContract({ + abi: royaltyPolicyLrpAbi, + address: this.address, + functionName: "isConsumingScheduledOp", + }); } /** - * event CollectionCreated for contract SPG + * method paused for contract RoyaltyPolicyLRP + * + * @param request RoyaltyPolicyLrpPausedRequest + * @return Promise */ - public watchCollectionCreatedEvent( - onLogs: (txHash: Hex, ev: Partial) => void, - ): WatchContractEventReturnType { - return this.rpcClient.watchContractEvent({ - abi: spgAbi, + public async paused(): Promise { + return await this.rpcClient.readContract({ + abi: royaltyPolicyLrpAbi, address: this.address, - eventName: "CollectionCreated", - onLogs: (evs) => { - evs.forEach((it) => onLogs(it.transactionHash, it.args)); - }, + functionName: "paused", }); } /** - * parse tx receipt event CollectionCreated for contract SPG + * method proxiableUUID for contract RoyaltyPolicyLRP + * + * @param request RoyaltyPolicyLrpProxiableUuidRequest + * @return Promise */ - public parseTxCollectionCreatedEvent( - txReceipt: TransactionReceipt, - ): Array { - const targetLogs: Array = []; - for (const log of txReceipt.logs) { - try { - const event = decodeEventLog({ - abi: spgAbi, - eventName: "CollectionCreated", - data: log.data, - topics: log.topics, - }); - if (event.eventName === "CollectionCreated") { - targetLogs.push(event.args); - } - } catch (e) { - /* empty */ - } - } - return targetLogs; + public async proxiableUuid(): Promise { + return await this.rpcClient.readContract({ + abi: royaltyPolicyLrpAbi, + address: this.address, + functionName: "proxiableUUID", + }); } } /** - * contract SPG write method + * contract RoyaltyPolicyLRP write method */ -export class SpgClient extends SpgEventClient { +export class RoyaltyPolicyLrpClient extends RoyaltyPolicyLrpReadOnlyClient { protected readonly wallet: SimpleWalletClient; constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { @@ -14263,443 +22556,600 @@ export class SpgClient extends SpgEventClient { } /** - * method createCollection for contract SPG + * method __ProtocolPausable_init for contract RoyaltyPolicyLRP * - * @param request SpgCreateCollectionRequest + * @param request RoyaltyPolicyLrpProtocolPausableInitRequest * @return Promise */ - public async createCollection( - request: SpgCreateCollectionRequest, + public async protocolPausableInit( + request: RoyaltyPolicyLrpProtocolPausableInitRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: spgAbi, + abi: royaltyPolicyLrpAbi, address: this.address, - functionName: "createCollection", + functionName: "__ProtocolPausable_init", account: this.wallet.account, - args: [ - request.name, - request.symbol, - request.maxSupply, - request.mintFee, - request.mintFeeToken, - request.owner, - ], + args: [request.accessManager], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method createCollection for contract SPG with only encode + * method __ProtocolPausable_init for contract RoyaltyPolicyLRP with only encode * - * @param request SpgCreateCollectionRequest + * @param request RoyaltyPolicyLrpProtocolPausableInitRequest * @return EncodedTxData */ - public createCollectionEncode(request: SpgCreateCollectionRequest): EncodedTxData { + public protocolPausableInitEncode( + request: RoyaltyPolicyLrpProtocolPausableInitRequest, + ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: spgAbi, - functionName: "createCollection", - args: [ - request.name, - request.symbol, - request.maxSupply, - request.mintFee, - request.mintFeeToken, - request.owner, - ], + abi: royaltyPolicyLrpAbi, + functionName: "__ProtocolPausable_init", + args: [request.accessManager], }), }; } /** - * method mintAndRegisterIp for contract SPG + * method getPolicyRoyalty for contract RoyaltyPolicyLRP * - * @param request SpgMintAndRegisterIpRequest + * @param request RoyaltyPolicyLrpGetPolicyRoyaltyRequest * @return Promise */ - public async mintAndRegisterIp( - request: SpgMintAndRegisterIpRequest, + public async getPolicyRoyalty( + request: RoyaltyPolicyLrpGetPolicyRoyaltyRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: spgAbi, + abi: royaltyPolicyLrpAbi, address: this.address, - functionName: "mintAndRegisterIp", + functionName: "getPolicyRoyalty", account: this.wallet.account, - args: [request.nftContract, request.recipient, request.ipMetadata], + args: [request.ipId, request.ancestorIpId], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method mintAndRegisterIp for contract SPG with only encode + * method getPolicyRoyalty for contract RoyaltyPolicyLRP with only encode * - * @param request SpgMintAndRegisterIpRequest + * @param request RoyaltyPolicyLrpGetPolicyRoyaltyRequest * @return EncodedTxData */ - public mintAndRegisterIpEncode(request: SpgMintAndRegisterIpRequest): EncodedTxData { + public getPolicyRoyaltyEncode(request: RoyaltyPolicyLrpGetPolicyRoyaltyRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: spgAbi, - functionName: "mintAndRegisterIp", - args: [request.nftContract, request.recipient, request.ipMetadata], + abi: royaltyPolicyLrpAbi, + functionName: "getPolicyRoyalty", + args: [request.ipId, request.ancestorIpId], }), }; } /** - * method mintAndRegisterIpAndAttachPILTerms for contract SPG + * method initialize for contract RoyaltyPolicyLRP * - * @param request SpgMintAndRegisterIpAndAttachPilTermsRequest + * @param request RoyaltyPolicyLrpInitializeRequest * @return Promise */ - public async mintAndRegisterIpAndAttachPilTerms( - request: SpgMintAndRegisterIpAndAttachPilTermsRequest, + public async initialize( + request: RoyaltyPolicyLrpInitializeRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: spgAbi, + abi: royaltyPolicyLrpAbi, address: this.address, - functionName: "mintAndRegisterIpAndAttachPILTerms", + functionName: "initialize", account: this.wallet.account, - args: [request.nftContract, request.recipient, request.ipMetadata, request.terms], + args: [request.accessManager], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method mintAndRegisterIpAndAttachPILTerms for contract SPG with only encode + * method initialize for contract RoyaltyPolicyLRP with only encode * - * @param request SpgMintAndRegisterIpAndAttachPilTermsRequest + * @param request RoyaltyPolicyLrpInitializeRequest * @return EncodedTxData */ - public mintAndRegisterIpAndAttachPilTermsEncode( - request: SpgMintAndRegisterIpAndAttachPilTermsRequest, - ): EncodedTxData { + public initializeEncode(request: RoyaltyPolicyLrpInitializeRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: spgAbi, - functionName: "mintAndRegisterIpAndAttachPILTerms", - args: [request.nftContract, request.recipient, request.ipMetadata, request.terms], + abi: royaltyPolicyLrpAbi, + functionName: "initialize", + args: [request.accessManager], }), }; } /** - * method mintAndRegisterIpAndMakeDerivative for contract SPG + * method onLicenseMinting for contract RoyaltyPolicyLRP * - * @param request SpgMintAndRegisterIpAndMakeDerivativeRequest + * @param request RoyaltyPolicyLrpOnLicenseMintingRequest * @return Promise */ - public async mintAndRegisterIpAndMakeDerivative( - request: SpgMintAndRegisterIpAndMakeDerivativeRequest, + public async onLicenseMinting( + request: RoyaltyPolicyLrpOnLicenseMintingRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: spgAbi, + abi: royaltyPolicyLrpAbi, address: this.address, - functionName: "mintAndRegisterIpAndMakeDerivative", + functionName: "onLicenseMinting", account: this.wallet.account, - args: [request.nftContract, request.derivData, request.ipMetadata, request.recipient], + args: [request[0], request[1], request[2]], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method mintAndRegisterIpAndMakeDerivative for contract SPG with only encode + * method onLicenseMinting for contract RoyaltyPolicyLRP with only encode * - * @param request SpgMintAndRegisterIpAndMakeDerivativeRequest + * @param request RoyaltyPolicyLrpOnLicenseMintingRequest * @return EncodedTxData */ - public mintAndRegisterIpAndMakeDerivativeEncode( - request: SpgMintAndRegisterIpAndMakeDerivativeRequest, - ): EncodedTxData { + public onLicenseMintingEncode(request: RoyaltyPolicyLrpOnLicenseMintingRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: spgAbi, - functionName: "mintAndRegisterIpAndMakeDerivative", - args: [request.nftContract, request.derivData, request.ipMetadata, request.recipient], + abi: royaltyPolicyLrpAbi, + functionName: "onLicenseMinting", + args: [request[0], request[1], request[2]], }), }; } /** - * method mintAndRegisterIpAndMakeDerivativeWithLicenseTokens for contract SPG + * method onLinkToParents for contract RoyaltyPolicyLRP * - * @param request SpgMintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest + * @param request RoyaltyPolicyLrpOnLinkToParentsRequest * @return Promise */ - public async mintAndRegisterIpAndMakeDerivativeWithLicenseTokens( - request: SpgMintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest, + public async onLinkToParents( + request: RoyaltyPolicyLrpOnLinkToParentsRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: spgAbi, + abi: royaltyPolicyLrpAbi, address: this.address, - functionName: "mintAndRegisterIpAndMakeDerivativeWithLicenseTokens", + functionName: "onLinkToParents", account: this.wallet.account, - args: [ - request.nftContract, - request.licenseTokenIds, - request.royaltyContext, - request.ipMetadata, - request.recipient, - ], + args: [request[0], request[1], request[2], request[3], request[4]], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method mintAndRegisterIpAndMakeDerivativeWithLicenseTokens for contract SPG with only encode + * method onLinkToParents for contract RoyaltyPolicyLRP with only encode * - * @param request SpgMintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest + * @param request RoyaltyPolicyLrpOnLinkToParentsRequest * @return EncodedTxData */ - public mintAndRegisterIpAndMakeDerivativeWithLicenseTokensEncode( - request: SpgMintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest, - ): EncodedTxData { + public onLinkToParentsEncode(request: RoyaltyPolicyLrpOnLinkToParentsRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: spgAbi, - functionName: "mintAndRegisterIpAndMakeDerivativeWithLicenseTokens", - args: [ - request.nftContract, - request.licenseTokenIds, - request.royaltyContext, - request.ipMetadata, - request.recipient, - ], + abi: royaltyPolicyLrpAbi, + functionName: "onLinkToParents", + args: [request[0], request[1], request[2], request[3], request[4]], }), }; } /** - * method registerIp for contract SPG + * method pause for contract RoyaltyPolicyLRP * - * @param request SpgRegisterIpRequest + * @param request RoyaltyPolicyLrpPauseRequest * @return Promise */ - public async registerIp(request: SpgRegisterIpRequest): Promise { + public async pause(): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: spgAbi, + abi: royaltyPolicyLrpAbi, address: this.address, - functionName: "registerIp", + functionName: "pause", account: this.wallet.account, - args: [request.nftContract, request.tokenId, request.ipMetadata, request.sigMetadata], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method registerIp for contract SPG with only encode + * method pause for contract RoyaltyPolicyLRP with only encode * - * @param request SpgRegisterIpRequest + * @param request RoyaltyPolicyLrpPauseRequest * @return EncodedTxData */ - public registerIpEncode(request: SpgRegisterIpRequest): EncodedTxData { + public pauseEncode(): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: spgAbi, - functionName: "registerIp", - args: [request.nftContract, request.tokenId, request.ipMetadata, request.sigMetadata], + abi: royaltyPolicyLrpAbi, + functionName: "pause", }), }; } /** - * method registerIpAndAttachPILTerms for contract SPG + * method setAuthority for contract RoyaltyPolicyLRP * - * @param request SpgRegisterIpAndAttachPilTermsRequest + * @param request RoyaltyPolicyLrpSetAuthorityRequest * @return Promise */ - public async registerIpAndAttachPilTerms( - request: SpgRegisterIpAndAttachPilTermsRequest, + public async setAuthority( + request: RoyaltyPolicyLrpSetAuthorityRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: spgAbi, + abi: royaltyPolicyLrpAbi, address: this.address, - functionName: "registerIpAndAttachPILTerms", + functionName: "setAuthority", account: this.wallet.account, - args: [ - request.nftContract, - request.tokenId, - request.ipMetadata, - request.terms, - request.sigMetadata, - request.sigAttach, - ], + args: [request.newAuthority], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setAuthority for contract RoyaltyPolicyLRP with only encode + * + * @param request RoyaltyPolicyLrpSetAuthorityRequest + * @return EncodedTxData + */ + public setAuthorityEncode(request: RoyaltyPolicyLrpSetAuthorityRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: royaltyPolicyLrpAbi, + functionName: "setAuthority", + args: [request.newAuthority], + }), + }; + } + + /** + * method transferToVault for contract RoyaltyPolicyLRP + * + * @param request RoyaltyPolicyLrpTransferToVaultRequest + * @return Promise + */ + public async transferToVault( + request: RoyaltyPolicyLrpTransferToVaultRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: royaltyPolicyLrpAbi, + address: this.address, + functionName: "transferToVault", + account: this.wallet.account, + args: [request.ipId, request.ancestorIpId, request.token, request.amount], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method transferToVault for contract RoyaltyPolicyLRP with only encode + * + * @param request RoyaltyPolicyLrpTransferToVaultRequest + * @return EncodedTxData + */ + public transferToVaultEncode(request: RoyaltyPolicyLrpTransferToVaultRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: royaltyPolicyLrpAbi, + functionName: "transferToVault", + args: [request.ipId, request.ancestorIpId, request.token, request.amount], + }), + }; + } + + /** + * method unpause for contract RoyaltyPolicyLRP + * + * @param request RoyaltyPolicyLrpUnpauseRequest + * @return Promise + */ + public async unpause(): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: royaltyPolicyLrpAbi, + address: this.address, + functionName: "unpause", + account: this.wallet.account, + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method unpause for contract RoyaltyPolicyLRP with only encode + * + * @param request RoyaltyPolicyLrpUnpauseRequest + * @return EncodedTxData + */ + public unpauseEncode(): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: royaltyPolicyLrpAbi, + functionName: "unpause", + }), + }; + } + + /** + * method upgradeToAndCall for contract RoyaltyPolicyLRP + * + * @param request RoyaltyPolicyLrpUpgradeToAndCallRequest + * @return Promise + */ + public async upgradeToAndCall( + request: RoyaltyPolicyLrpUpgradeToAndCallRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: royaltyPolicyLrpAbi, + address: this.address, + functionName: "upgradeToAndCall", + account: this.wallet.account, + args: [request.newImplementation, request.data], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method upgradeToAndCall for contract RoyaltyPolicyLRP with only encode + * + * @param request RoyaltyPolicyLrpUpgradeToAndCallRequest + * @return EncodedTxData + */ + public upgradeToAndCallEncode(request: RoyaltyPolicyLrpUpgradeToAndCallRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: royaltyPolicyLrpAbi, + functionName: "upgradeToAndCall", + args: [request.newImplementation, request.data], + }), + }; + } +} + +// Contract RoyaltyWorkflows ============================================================= + +/** + * RoyaltyWorkflowsSnapshotAndClaimBySnapshotBatchRequest + * + * @param ipId address + * @param claimer address + * @param unclaimedSnapshotIds uint256[] + * @param currencyTokens address[] + */ +export type RoyaltyWorkflowsSnapshotAndClaimBySnapshotBatchRequest = { + ipId: Address; + claimer: Address; + unclaimedSnapshotIds: readonly bigint[]; + currencyTokens: readonly Address[]; +}; + +/** + * RoyaltyWorkflowsSnapshotAndClaimByTokenBatchRequest + * + * @param ipId address + * @param claimer address + * @param currencyTokens address[] + */ +export type RoyaltyWorkflowsSnapshotAndClaimByTokenBatchRequest = { + ipId: Address; + claimer: Address; + currencyTokens: readonly Address[]; +}; + +/** + * RoyaltyWorkflowsTransferToVaultAndSnapshotAndClaimBySnapshotBatchRequest + * + * @param ancestorIpId address + * @param claimer address + * @param unclaimedSnapshotIds uint256[] + * @param royaltyClaimDetails tuple[] + */ +export type RoyaltyWorkflowsTransferToVaultAndSnapshotAndClaimBySnapshotBatchRequest = { + ancestorIpId: Address; + claimer: Address; + unclaimedSnapshotIds: readonly bigint[]; + royaltyClaimDetails: { + childIpId: Address; + royaltyPolicy: Address; + currencyToken: Address; + amount: bigint; + }[]; +}; + +/** + * RoyaltyWorkflowsTransferToVaultAndSnapshotAndClaimByTokenBatchRequest + * + * @param ancestorIpId address + * @param claimer address + * @param royaltyClaimDetails tuple[] + */ +export type RoyaltyWorkflowsTransferToVaultAndSnapshotAndClaimByTokenBatchRequest = { + ancestorIpId: Address; + claimer: Address; + royaltyClaimDetails: { + childIpId: Address; + royaltyPolicy: Address; + currencyToken: Address; + amount: bigint; + }[]; +}; + +/** + * contract RoyaltyWorkflows write method + */ +export class RoyaltyWorkflowsClient { + protected readonly wallet: SimpleWalletClient; + protected readonly rpcClient: PublicClient; + public readonly address: Address; + + constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, address?: Address) { + this.address = address || getAddress(royaltyWorkflowsAddress, rpcClient.chain?.id); + this.rpcClient = rpcClient; + this.wallet = wallet; + } + + /** + * method snapshotAndClaimBySnapshotBatch for contract RoyaltyWorkflows + * + * @param request RoyaltyWorkflowsSnapshotAndClaimBySnapshotBatchRequest + * @return Promise + */ + public async snapshotAndClaimBySnapshotBatch( + request: RoyaltyWorkflowsSnapshotAndClaimBySnapshotBatchRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: royaltyWorkflowsAbi, + address: this.address, + functionName: "snapshotAndClaimBySnapshotBatch", + account: this.wallet.account, + args: [request.ipId, request.claimer, request.unclaimedSnapshotIds, request.currencyTokens], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method registerIpAndAttachPILTerms for contract SPG with only encode + * method snapshotAndClaimBySnapshotBatch for contract RoyaltyWorkflows with only encode * - * @param request SpgRegisterIpAndAttachPilTermsRequest + * @param request RoyaltyWorkflowsSnapshotAndClaimBySnapshotBatchRequest * @return EncodedTxData */ - public registerIpAndAttachPilTermsEncode( - request: SpgRegisterIpAndAttachPilTermsRequest, + public snapshotAndClaimBySnapshotBatchEncode( + request: RoyaltyWorkflowsSnapshotAndClaimBySnapshotBatchRequest, ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: spgAbi, - functionName: "registerIpAndAttachPILTerms", - args: [ - request.nftContract, - request.tokenId, - request.ipMetadata, - request.terms, - request.sigMetadata, - request.sigAttach, - ], + abi: royaltyWorkflowsAbi, + functionName: "snapshotAndClaimBySnapshotBatch", + args: [request.ipId, request.claimer, request.unclaimedSnapshotIds, request.currencyTokens], }), }; } /** - * method registerIpAndMakeDerivative for contract SPG + * method snapshotAndClaimByTokenBatch for contract RoyaltyWorkflows * - * @param request SpgRegisterIpAndMakeDerivativeRequest + * @param request RoyaltyWorkflowsSnapshotAndClaimByTokenBatchRequest * @return Promise */ - public async registerIpAndMakeDerivative( - request: SpgRegisterIpAndMakeDerivativeRequest, + public async snapshotAndClaimByTokenBatch( + request: RoyaltyWorkflowsSnapshotAndClaimByTokenBatchRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: spgAbi, + abi: royaltyWorkflowsAbi, address: this.address, - functionName: "registerIpAndMakeDerivative", + functionName: "snapshotAndClaimByTokenBatch", account: this.wallet.account, - args: [ - request.nftContract, - request.tokenId, - request.derivData, - request.ipMetadata, - request.sigMetadata, - request.sigRegister, - ], + args: [request.ipId, request.claimer, request.currencyTokens], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method registerIpAndMakeDerivative for contract SPG with only encode + * method snapshotAndClaimByTokenBatch for contract RoyaltyWorkflows with only encode * - * @param request SpgRegisterIpAndMakeDerivativeRequest + * @param request RoyaltyWorkflowsSnapshotAndClaimByTokenBatchRequest * @return EncodedTxData */ - public registerIpAndMakeDerivativeEncode( - request: SpgRegisterIpAndMakeDerivativeRequest, + public snapshotAndClaimByTokenBatchEncode( + request: RoyaltyWorkflowsSnapshotAndClaimByTokenBatchRequest, ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: spgAbi, - functionName: "registerIpAndMakeDerivative", - args: [ - request.nftContract, - request.tokenId, - request.derivData, - request.ipMetadata, - request.sigMetadata, - request.sigRegister, - ], + abi: royaltyWorkflowsAbi, + functionName: "snapshotAndClaimByTokenBatch", + args: [request.ipId, request.claimer, request.currencyTokens], }), }; } /** - * method registerIpAndMakeDerivativeWithLicenseTokens for contract SPG + * method transferToVaultAndSnapshotAndClaimBySnapshotBatch for contract RoyaltyWorkflows * - * @param request SpgRegisterIpAndMakeDerivativeWithLicenseTokensRequest + * @param request RoyaltyWorkflowsTransferToVaultAndSnapshotAndClaimBySnapshotBatchRequest * @return Promise */ - public async registerIpAndMakeDerivativeWithLicenseTokens( - request: SpgRegisterIpAndMakeDerivativeWithLicenseTokensRequest, + public async transferToVaultAndSnapshotAndClaimBySnapshotBatch( + request: RoyaltyWorkflowsTransferToVaultAndSnapshotAndClaimBySnapshotBatchRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: spgAbi, + abi: royaltyWorkflowsAbi, address: this.address, - functionName: "registerIpAndMakeDerivativeWithLicenseTokens", + functionName: "transferToVaultAndSnapshotAndClaimBySnapshotBatch", account: this.wallet.account, args: [ - request.nftContract, - request.tokenId, - request.licenseTokenIds, - request.royaltyContext, - request.ipMetadata, - request.sigMetadata, - request.sigRegister, + request.ancestorIpId, + request.claimer, + request.unclaimedSnapshotIds, + request.royaltyClaimDetails, ], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method registerIpAndMakeDerivativeWithLicenseTokens for contract SPG with only encode + * method transferToVaultAndSnapshotAndClaimBySnapshotBatch for contract RoyaltyWorkflows with only encode * - * @param request SpgRegisterIpAndMakeDerivativeWithLicenseTokensRequest + * @param request RoyaltyWorkflowsTransferToVaultAndSnapshotAndClaimBySnapshotBatchRequest * @return EncodedTxData */ - public registerIpAndMakeDerivativeWithLicenseTokensEncode( - request: SpgRegisterIpAndMakeDerivativeWithLicenseTokensRequest, + public transferToVaultAndSnapshotAndClaimBySnapshotBatchEncode( + request: RoyaltyWorkflowsTransferToVaultAndSnapshotAndClaimBySnapshotBatchRequest, ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: spgAbi, - functionName: "registerIpAndMakeDerivativeWithLicenseTokens", + abi: royaltyWorkflowsAbi, + functionName: "transferToVaultAndSnapshotAndClaimBySnapshotBatch", args: [ - request.nftContract, - request.tokenId, - request.licenseTokenIds, - request.royaltyContext, - request.ipMetadata, - request.sigMetadata, - request.sigRegister, + request.ancestorIpId, + request.claimer, + request.unclaimedSnapshotIds, + request.royaltyClaimDetails, ], }), }; } /** - * method registerPILTermsAndAttach for contract SPG + * method transferToVaultAndSnapshotAndClaimByTokenBatch for contract RoyaltyWorkflows * - * @param request SpgRegisterPilTermsAndAttachRequest + * @param request RoyaltyWorkflowsTransferToVaultAndSnapshotAndClaimByTokenBatchRequest * @return Promise */ - public async registerPilTermsAndAttach( - request: SpgRegisterPilTermsAndAttachRequest, + public async transferToVaultAndSnapshotAndClaimByTokenBatch( + request: RoyaltyWorkflowsTransferToVaultAndSnapshotAndClaimByTokenBatchRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ - abi: spgAbi, + abi: royaltyWorkflowsAbi, address: this.address, - functionName: "registerPILTermsAndAttach", + functionName: "transferToVaultAndSnapshotAndClaimByTokenBatch", account: this.wallet.account, - args: [request.ipId, request.terms], + args: [request.ancestorIpId, request.claimer, request.royaltyClaimDetails], }); return await this.wallet.writeContract(call as WriteContractParameters); } /** - * method registerPILTermsAndAttach for contract SPG with only encode + * method transferToVaultAndSnapshotAndClaimByTokenBatch for contract RoyaltyWorkflows with only encode * - * @param request SpgRegisterPilTermsAndAttachRequest + * @param request RoyaltyWorkflowsTransferToVaultAndSnapshotAndClaimByTokenBatchRequest * @return EncodedTxData */ - public registerPilTermsAndAttachEncode( - request: SpgRegisterPilTermsAndAttachRequest, + public transferToVaultAndSnapshotAndClaimByTokenBatchEncode( + request: RoyaltyWorkflowsTransferToVaultAndSnapshotAndClaimByTokenBatchRequest, ): EncodedTxData { return { to: this.address, data: encodeFunctionData({ - abi: spgAbi, - functionName: "registerPILTermsAndAttach", - args: [request.ipId, request.terms], + abi: royaltyWorkflowsAbi, + functionName: "transferToVaultAndSnapshotAndClaimByTokenBatch", + args: [request.ancestorIpId, request.claimer, request.royaltyClaimDetails], }), }; } @@ -15104,7 +23554,13 @@ export type SpgnftImplTransferEvent = { export type SpgnftImplDefaultAdminRoleResponse = Hex; -export type SpgnftImplSpgAddressResponse = Address; +export type SpgnftImplDerivativeWorkflowsAddressResponse = Address; + +export type SpgnftImplGroupingWorkflowsAddressResponse = Address; + +export type SpgnftImplLicenseAttachmentWorkflowsAddressResponse = Address; + +export type SpgnftImplRegistrationWorkflowsAddressResponse = Address; /** * SpgnftImplBalanceOfRequest @@ -15117,6 +23573,8 @@ export type SpgnftImplBalanceOfRequest = { export type SpgnftImplBalanceOfResponse = bigint; +export type SpgnftImplBaseUriResponse = string; + /** * SpgnftImplGetApprovedRequest * @@ -15167,8 +23625,12 @@ export type SpgnftImplIsApprovedForAllResponse = boolean; export type SpgnftImplMintFeeResponse = bigint; +export type SpgnftImplMintFeeRecipientResponse = Address; + export type SpgnftImplMintFeeTokenResponse = Address; +export type SpgnftImplMintOpenResponse = boolean; + export type SpgnftImplNameResponse = string; /** @@ -15182,6 +23644,8 @@ export type SpgnftImplOwnerOfRequest = { export type SpgnftImplOwnerOfResponse = Address; +export type SpgnftImplPublicMintingResponse = boolean; + /** * SpgnftImplSupportsInterfaceRequest * @@ -15233,20 +23697,21 @@ export type SpgnftImplGrantRoleRequest = { /** * SpgnftImplInitializeRequest * - * @param name string - * @param symbol string - * @param maxSupply uint32 - * @param mintFee uint256 - * @param mintFeeToken address - * @param owner address + * @param initParams tuple */ export type SpgnftImplInitializeRequest = { - name: string; - symbol: string; - maxSupply: number; - mintFee: bigint; - mintFeeToken: Address; - owner: Address; + initParams: { + name: string; + symbol: string; + baseURI: string; + maxSupply: number; + mintFee: bigint; + mintFeeToken: Address; + mintFeeRecipient: Address; + owner: Address; + mintOpen: boolean; + isPublicMinting: boolean; + }; }; /** @@ -15261,13 +23726,13 @@ export type SpgnftImplMintRequest = { }; /** - * SpgnftImplMintBySpgRequest + * SpgnftImplMintByPeripheryRequest * * @param to address * @param payer address * @param nftMetadataURI string */ -export type SpgnftImplMintBySpgRequest = { +export type SpgnftImplMintByPeripheryRequest = { to: Address; payer: Address; nftMetadataURI: string; @@ -15334,6 +23799,15 @@ export type SpgnftImplSetApprovalForAllRequest = { approved: boolean; }; +/** + * SpgnftImplSetBaseUriRequest + * + * @param baseURI string + */ +export type SpgnftImplSetBaseUriRequest = { + baseURI: string; +}; + /** * SpgnftImplSetMintFeeRequest * @@ -15343,6 +23817,15 @@ export type SpgnftImplSetMintFeeRequest = { fee: bigint; }; +/** + * SpgnftImplSetMintFeeRecipientRequest + * + * @param newFeeRecipient address + */ +export type SpgnftImplSetMintFeeRecipientRequest = { + newFeeRecipient: Address; +}; + /** * SpgnftImplSetMintFeeTokenRequest * @@ -15352,6 +23835,24 @@ export type SpgnftImplSetMintFeeTokenRequest = { token: Address; }; +/** + * SpgnftImplSetMintOpenRequest + * + * @param mintOpen bool + */ +export type SpgnftImplSetMintOpenRequest = { + mintOpen: boolean; +}; + +/** + * SpgnftImplSetPublicMintingRequest + * + * @param isPublicMinting bool + */ +export type SpgnftImplSetPublicMintingRequest = { + isPublicMinting: boolean; +}; + /** * SpgnftImplTransferFromRequest * @@ -15369,11 +23870,9 @@ export type SpgnftImplTransferFromRequest = { * SpgnftImplWithdrawTokenRequest * * @param token address - * @param recipient address */ export type SpgnftImplWithdrawTokenRequest = { token: Address; - recipient: Address; }; /** @@ -15771,16 +24270,58 @@ export class SpgnftImplReadOnlyClient extends SpgnftImplEventClient { } /** - * method SPG_ADDRESS for contract SPGNFTImpl + * method DERIVATIVE_WORKFLOWS_ADDRESS for contract SPGNFTImpl + * + * @param request SpgnftImplDerivativeWorkflowsAddressRequest + * @return Promise + */ + public async derivativeWorkflowsAddress(): Promise { + return await this.rpcClient.readContract({ + abi: spgnftImplAbi, + address: this.address, + functionName: "DERIVATIVE_WORKFLOWS_ADDRESS", + }); + } + + /** + * method GROUPING_WORKFLOWS_ADDRESS for contract SPGNFTImpl * - * @param request SpgnftImplSpgAddressRequest - * @return Promise + * @param request SpgnftImplGroupingWorkflowsAddressRequest + * @return Promise */ - public async spgAddress(): Promise { + public async groupingWorkflowsAddress(): Promise { return await this.rpcClient.readContract({ abi: spgnftImplAbi, address: this.address, - functionName: "SPG_ADDRESS", + functionName: "GROUPING_WORKFLOWS_ADDRESS", + }); + } + + /** + * method LICENSE_ATTACHMENT_WORKFLOWS_ADDRESS for contract SPGNFTImpl + * + * @param request SpgnftImplLicenseAttachmentWorkflowsAddressRequest + * @return Promise + */ + public async licenseAttachmentWorkflowsAddress(): Promise { + return await this.rpcClient.readContract({ + abi: spgnftImplAbi, + address: this.address, + functionName: "LICENSE_ATTACHMENT_WORKFLOWS_ADDRESS", + }); + } + + /** + * method REGISTRATION_WORKFLOWS_ADDRESS for contract SPGNFTImpl + * + * @param request SpgnftImplRegistrationWorkflowsAddressRequest + * @return Promise + */ + public async registrationWorkflowsAddress(): Promise { + return await this.rpcClient.readContract({ + abi: spgnftImplAbi, + address: this.address, + functionName: "REGISTRATION_WORKFLOWS_ADDRESS", }); } @@ -15801,6 +24342,20 @@ export class SpgnftImplReadOnlyClient extends SpgnftImplEventClient { }); } + /** + * method baseURI for contract SPGNFTImpl + * + * @param request SpgnftImplBaseUriRequest + * @return Promise + */ + public async baseUri(): Promise { + return await this.rpcClient.readContract({ + abi: spgnftImplAbi, + address: this.address, + functionName: "baseURI", + }); + } + /** * method getApproved for contract SPGNFTImpl * @@ -15881,6 +24436,20 @@ export class SpgnftImplReadOnlyClient extends SpgnftImplEventClient { }); } + /** + * method mintFeeRecipient for contract SPGNFTImpl + * + * @param request SpgnftImplMintFeeRecipientRequest + * @return Promise + */ + public async mintFeeRecipient(): Promise { + return await this.rpcClient.readContract({ + abi: spgnftImplAbi, + address: this.address, + functionName: "mintFeeRecipient", + }); + } + /** * method mintFeeToken for contract SPGNFTImpl * @@ -15895,6 +24464,20 @@ export class SpgnftImplReadOnlyClient extends SpgnftImplEventClient { }); } + /** + * method mintOpen for contract SPGNFTImpl + * + * @param request SpgnftImplMintOpenRequest + * @return Promise + */ + public async mintOpen(): Promise { + return await this.rpcClient.readContract({ + abi: spgnftImplAbi, + address: this.address, + functionName: "mintOpen", + }); + } + /** * method name for contract SPGNFTImpl * @@ -15924,6 +24507,20 @@ export class SpgnftImplReadOnlyClient extends SpgnftImplEventClient { }); } + /** + * method publicMinting for contract SPGNFTImpl + * + * @param request SpgnftImplPublicMintingRequest + * @return Promise + */ + public async publicMinting(): Promise { + return await this.rpcClient.readContract({ + abi: spgnftImplAbi, + address: this.address, + functionName: "publicMinting", + }); + } + /** * method supportsInterface for contract SPGNFTImpl * @@ -16076,14 +24673,7 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { address: this.address, functionName: "initialize", account: this.wallet.account, - args: [ - request.name, - request.symbol, - request.maxSupply, - request.mintFee, - request.mintFeeToken, - request.owner, - ], + args: [request.initParams], }); return await this.wallet.writeContract(call as WriteContractParameters); } @@ -16100,14 +24690,7 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { data: encodeFunctionData({ abi: spgnftImplAbi, functionName: "initialize", - args: [ - request.name, - request.symbol, - request.maxSupply, - request.mintFee, - request.mintFeeToken, - request.owner, - ], + args: [request.initParams], }), }; } @@ -16147,16 +24730,18 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { } /** - * method mintBySPG for contract SPGNFTImpl + * method mintByPeriphery for contract SPGNFTImpl * - * @param request SpgnftImplMintBySpgRequest + * @param request SpgnftImplMintByPeripheryRequest * @return Promise */ - public async mintBySpg(request: SpgnftImplMintBySpgRequest): Promise { + public async mintByPeriphery( + request: SpgnftImplMintByPeripheryRequest, + ): Promise { const { request: call } = await this.rpcClient.simulateContract({ abi: spgnftImplAbi, address: this.address, - functionName: "mintBySPG", + functionName: "mintByPeriphery", account: this.wallet.account, args: [request.to, request.payer, request.nftMetadataURI], }); @@ -16164,17 +24749,17 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { } /** - * method mintBySPG for contract SPGNFTImpl with only encode + * method mintByPeriphery for contract SPGNFTImpl with only encode * - * @param request SpgnftImplMintBySpgRequest + * @param request SpgnftImplMintByPeripheryRequest * @return EncodedTxData */ - public mintBySpgEncode(request: SpgnftImplMintBySpgRequest): EncodedTxData { + public mintByPeripheryEncode(request: SpgnftImplMintByPeripheryRequest): EncodedTxData { return { to: this.address, data: encodeFunctionData({ abi: spgnftImplAbi, - functionName: "mintBySPG", + functionName: "mintByPeriphery", args: [request.to, request.payer, request.nftMetadataURI], }), }; @@ -16358,6 +24943,40 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { }; } + /** + * method setBaseURI for contract SPGNFTImpl + * + * @param request SpgnftImplSetBaseUriRequest + * @return Promise + */ + public async setBaseUri(request: SpgnftImplSetBaseUriRequest): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: spgnftImplAbi, + address: this.address, + functionName: "setBaseURI", + account: this.wallet.account, + args: [request.baseURI], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setBaseURI for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplSetBaseUriRequest + * @return EncodedTxData + */ + public setBaseUriEncode(request: SpgnftImplSetBaseUriRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "setBaseURI", + args: [request.baseURI], + }), + }; + } + /** * method setMintFee for contract SPGNFTImpl * @@ -16392,6 +25011,42 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { }; } + /** + * method setMintFeeRecipient for contract SPGNFTImpl + * + * @param request SpgnftImplSetMintFeeRecipientRequest + * @return Promise + */ + public async setMintFeeRecipient( + request: SpgnftImplSetMintFeeRecipientRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: spgnftImplAbi, + address: this.address, + functionName: "setMintFeeRecipient", + account: this.wallet.account, + args: [request.newFeeRecipient], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setMintFeeRecipient for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplSetMintFeeRecipientRequest + * @return EncodedTxData + */ + public setMintFeeRecipientEncode(request: SpgnftImplSetMintFeeRecipientRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "setMintFeeRecipient", + args: [request.newFeeRecipient], + }), + }; + } + /** * method setMintFeeToken for contract SPGNFTImpl * @@ -16428,6 +25083,78 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { }; } + /** + * method setMintOpen for contract SPGNFTImpl + * + * @param request SpgnftImplSetMintOpenRequest + * @return Promise + */ + public async setMintOpen( + request: SpgnftImplSetMintOpenRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: spgnftImplAbi, + address: this.address, + functionName: "setMintOpen", + account: this.wallet.account, + args: [request.mintOpen], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setMintOpen for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplSetMintOpenRequest + * @return EncodedTxData + */ + public setMintOpenEncode(request: SpgnftImplSetMintOpenRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "setMintOpen", + args: [request.mintOpen], + }), + }; + } + + /** + * method setPublicMinting for contract SPGNFTImpl + * + * @param request SpgnftImplSetPublicMintingRequest + * @return Promise + */ + public async setPublicMinting( + request: SpgnftImplSetPublicMintingRequest, + ): Promise { + const { request: call } = await this.rpcClient.simulateContract({ + abi: spgnftImplAbi, + address: this.address, + functionName: "setPublicMinting", + account: this.wallet.account, + args: [request.isPublicMinting], + }); + return await this.wallet.writeContract(call as WriteContractParameters); + } + + /** + * method setPublicMinting for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplSetPublicMintingRequest + * @return EncodedTxData + */ + public setPublicMintingEncode(request: SpgnftImplSetPublicMintingRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "setPublicMinting", + args: [request.isPublicMinting], + }), + }; + } + /** * method transferFrom for contract SPGNFTImpl * @@ -16478,7 +25205,7 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { address: this.address, functionName: "withdrawToken", account: this.wallet.account, - args: [request.token, request.recipient], + args: [request.token], }); return await this.wallet.writeContract(call as WriteContractParameters); } @@ -16495,7 +25222,7 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { data: encodeFunctionData({ abi: spgnftImplAbi, functionName: "withdrawToken", - args: [request.token, request.recipient], + args: [request.token], }), }; } diff --git a/packages/core-sdk/src/client.ts b/packages/core-sdk/src/client.ts index 6cd6daad..b1b2fcf2 100644 --- a/packages/core-sdk/src/client.ts +++ b/packages/core-sdk/src/client.ts @@ -15,6 +15,7 @@ import { IPAccountClient } from "./resources/ipAccount"; import { chainStringToViemChain } from "./utils/utils"; import { RoyaltyClient } from "./resources/royalty"; import { NftClient } from "./resources/nftClient"; +import { GroupClient } from "./resources/group"; import { SimpleWalletClient } from "./abi/generated"; if (typeof process !== "undefined") { @@ -34,6 +35,7 @@ export class StoryClient { private _ipAccount: IPAccountClient | null = null; private _royalty: RoyaltyClient | null = null; private _nftClient: NftClient | null = null; + private _group: GroupClient | null = null; /** * @param config - the configuration for the SDK client @@ -141,7 +143,7 @@ export class StoryClient { */ public get license(): LicenseClient { if (this._license === null) { - this._license = new LicenseClient(this.rpcClient, this.wallet); + this._license = new LicenseClient(this.rpcClient, this.wallet, this.config.chainId); } return this._license; @@ -202,4 +204,18 @@ export class StoryClient { return this._nftClient; } + + /** + * Getter for the group client. The client is lazily created when + * this method is called. + * + * @returns the GroupClient instance + */ + public get groupClient(): GroupClient { + if (this._group === null) { + this._group = new GroupClient(this.rpcClient, this.wallet, this.config.chainId); + } + + return this._group; + } } diff --git a/packages/core-sdk/src/index.ts b/packages/core-sdk/src/index.ts index 0a0bd365..d4d08a15 100644 --- a/packages/core-sdk/src/index.ts +++ b/packages/core-sdk/src/index.ts @@ -8,6 +8,7 @@ export { DisputeClient } from "./resources/dispute"; export { NftClient } from "./resources/nftClient"; export { IPAccountClient } from "./resources/ipAccount"; export { RoyaltyClient } from "./resources/royalty"; +export { GroupClient } from "./resources/group"; export type { StoryConfig, SupportedChainIds } from "./types/config"; @@ -35,6 +36,11 @@ export type { IpMedia, IPRobotTerms, StoryProtocolApp, + MintAndRegisterIpRequest, + RegisterPilTermsAndAttachRequest, + RegisterPilTermsAndAttachResponse, + MintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest, + RegisterIpAndMakeDerivativeWithLicenseTokensRequest, } from "./types/resources/ipAsset"; export type { @@ -52,16 +58,20 @@ export type { export { PIL_TYPE } from "./types/resources/license"; export type { - CollectRoyaltyTokensRequest, - CollectRoyaltyTokensResponse, PayRoyaltyOnBehalfRequest, PayRoyaltyOnBehalfResponse, SnapshotRequest, SnapshotResponse, ClaimableRevenueRequest, ClaimableRevenueResponse, - ClaimRevenueRequest, - ClaimRevenueResponse, + SnapshotAndClaimBySnapshotBatchRequest, + SnapshotAndClaimBySnapshotBatchResponse, + SnapshotAndClaimByTokenBatchRequest, + SnapshotAndClaimByTokenBatchResponse, + TransferToVaultAndSnapshotAndClaimBySnapshotBatchRequest, + TransferToVaultAndSnapshotAndClaimBySnapshotBatchResponse, + TransferToVaultAndSnapshotAndClaimByTokenBatchRequest, + TransferToVaultAndSnapshotAndClaimByTokenBatchResponse, } from "./types/resources/royalty"; export type { @@ -71,6 +81,8 @@ export type { SetAllPermissionsRequest, SetBatchPermissionsRequest, CreateBatchPermissionSignatureRequest, + PermissionSignatureRequest, + PermissionSignatureResponse, } from "./types/resources/permission"; export { AccessPermission } from "./types/resources/permission"; export type { @@ -96,6 +108,18 @@ export type { CreateNFTCollectionResponse, } from "./types/resources/nftClient"; +export type { + RegisterGroupRequest, + RegisterGroupResponse, + RegisterGroupAndAttachLicenseRequest, + RegisterGroupAndAttachLicenseResponse, + RegisterGroupAndAttachLicenseAndAddIpsRequest, + RegisterGroupAndAttachLicenseAndAddIpsResponse, + MintAndRegisterIpAndAttachLicenseAndAddToGroupRequest, + MintAndRegisterIpAndAttachLicenseAndAddToGroupResponse, + RegisterIpAndAttachLicenseAndAddToGroupRequest, + RegisterIpAndAttachLicenseAndAddToGroupResponse, +} from "./types/resources/group"; export type { PiLicenseTemplateGetLicenseTermsResponse, IpAccountImplStateResponse, @@ -103,4 +127,3 @@ export type { } from "./abi/generated"; export { getPermissionSignature } from "./utils/sign"; -export type { PermissionSignatureRequest, PermissionSignatureResponse } from "./types/common"; diff --git a/packages/core-sdk/src/resources/dispute.ts b/packages/core-sdk/src/resources/dispute.ts index fe2b1786..bddb2096 100644 --- a/packages/core-sdk/src/resources/dispute.ts +++ b/packages/core-sdk/src/resources/dispute.ts @@ -24,12 +24,11 @@ export class DisputeClient { /** * Raises a dispute on a given ipId * @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.arbitrationPolicy - The address of the arbitration policy. - * @param request.linkToDisputeEvidence - The link to the dispute evidence. - * @param request.targetTag - The target tag of the dispute. - * @param request.calldata - Optional calldata to initialize the policy. - * @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property. + * @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.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. * @throws `NotRegisteredIpId` if targetIpId is not registered in the IPA Registry. * @throws `NotWhitelistedDisputeTag` if targetTag is not whitelisted. @@ -41,9 +40,9 @@ export class DisputeClient { try { const req = { targetIpId: getAddress(request.targetIpId, "request.targetIpId"), - linkToDisputeEvidence: request.linkToDisputeEvidence, targetTag: stringToHex(request.targetTag, { size: 32 }), - data: request.calldata || "0x", + data: request.data || "0x", + disputeEvidenceHash: request.disputeEvidenceHash, }; if (request.txOptions?.encodedTxDataOnly) { @@ -73,7 +72,7 @@ export class DisputeClient { * Cancels an ongoing dispute * @param request - The request object containing details to cancel the dispute. * @param request.disputeId The ID of the dispute to be cancelled. - * @param request.calldata Optional additional data used in the cancellation process. + * @param request.data [Optional] additional data used in the cancellation process. * @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property. * @returns A Promise that resolves to a CancelDisputeResponse containing the transaction hash. * @throws NotInDisputeState, if the currentTag of the Dispute is not being disputed @@ -86,7 +85,7 @@ export class DisputeClient { try { const req = { disputeId: BigInt(request.disputeId), - data: request.calldata ? request.calldata : "0x", + data: request.data ? request.data : "0x", }; if (request.txOptions?.encodedTxDataOnly) { return { encodedTxData: this.disputeModuleClient.cancelDisputeEncode(req) }; diff --git a/packages/core-sdk/src/resources/group.ts b/packages/core-sdk/src/resources/group.ts new file mode 100644 index 00000000..b4a56457 --- /dev/null +++ b/packages/core-sdk/src/resources/group.ts @@ -0,0 +1,424 @@ +import { PublicClient, WalletClient, toHex, zeroHash } from "viem"; + +import { + CoreMetadataModuleClient, + GroupingModuleClient, + GroupingModuleEventClient, + GroupingModuleRegisterGroupRequest, + GroupingWorkflowsClient, + GroupingWorkflowsMintAndRegisterIpAndAttachLicenseAndAddToGroupRequest, + GroupingWorkflowsRegisterGroupAndAttachLicenseAndAddIpsRequest, + GroupingWorkflowsRegisterIpAndAttachLicenseAndAddToGroupRequest, + IpAccountImplClient, + IpAssetRegistryClient, + LicenseRegistryReadOnlyClient, + LicenseTokenReadOnlyClient, + LicensingModuleClient, + PiLicenseTemplateClient, + SimpleWalletClient, +} from "../abi/generated"; +import { AccessPermission } from "../types/resources/permission"; +import { handleError } from "../utils/errors"; +import { getPermissionSignature, getDeadline } from "../utils/sign"; +import { chain, getAddress } from "../utils/utils"; +import { SupportedChainIds } from "../types/config"; +import { + MintAndRegisterIpAndAttachLicenseAndAddToGroupRequest, + MintAndRegisterIpAndAttachLicenseAndAddToGroupResponse, + RegisterGroupAndAttachLicenseAndAddIpsRequest, + RegisterGroupAndAttachLicenseAndAddIpsResponse, + RegisterGroupAndAttachLicenseRequest, + RegisterGroupAndAttachLicenseResponse, + RegisterGroupRequest, + RegisterGroupResponse, + RegisterIpAndAttachLicenseAndAddToGroupRequest, + RegisterIpAndAttachLicenseAndAddToGroupResponse, +} from "../types/resources/group"; + +export class GroupClient { + public groupingWorkflowsClient: GroupingWorkflowsClient; + public groupingModuleEventClient: GroupingModuleEventClient; + public groupingModuleClient: GroupingModuleClient; + public licenseTemplateClient: PiLicenseTemplateClient; + public licenseTokenReadOnlyClient: LicenseTokenReadOnlyClient; + public ipAssetRegistryClient: IpAssetRegistryClient; + public coreMetadataModuleClient: CoreMetadataModuleClient; + public licensingModuleClient: LicensingModuleClient; + public licenseRegistryReadOnlyClient: LicenseRegistryReadOnlyClient; + + private readonly rpcClient: PublicClient; + private readonly wallet: SimpleWalletClient; + private readonly chainId: SupportedChainIds; + + constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, chainId: SupportedChainIds) { + this.rpcClient = rpcClient; + this.wallet = wallet; + this.chainId = chainId; + this.groupingWorkflowsClient = new GroupingWorkflowsClient(rpcClient, wallet); + this.groupingModuleEventClient = new GroupingModuleEventClient(rpcClient); + this.licenseTemplateClient = new PiLicenseTemplateClient(rpcClient, wallet); + this.licenseTokenReadOnlyClient = new LicenseTokenReadOnlyClient(rpcClient); + this.ipAssetRegistryClient = new IpAssetRegistryClient(rpcClient, wallet); + this.groupingModuleClient = new GroupingModuleClient(rpcClient, wallet); + this.coreMetadataModuleClient = new CoreMetadataModuleClient(rpcClient, wallet); + this.licensingModuleClient = new LicensingModuleClient(rpcClient, wallet); + this.licenseRegistryReadOnlyClient = new LicenseRegistryReadOnlyClient(rpcClient); + } + /** Registers a Group IPA. + * @param request - The request object containing necessary data to register group. + * @param request.groupPool The address specifying how royalty will be split amongst the pool of IPs in the group. + * @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 group id. + * @emits PGroupRegistered (groupId, groupPool); + */ + public async registerGroup(request: RegisterGroupRequest): Promise { + try { + const object: GroupingModuleRegisterGroupRequest = { + groupPool: getAddress(request.groupPool, "request.groupPool"), + }; + if (request.txOptions?.encodedTxDataOnly) { + return { + encodedTxData: this.groupingModuleClient.registerGroupEncode(object), + }; + } else { + const txHash = await this.groupingModuleClient.registerGroup(object); + if (request.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ + ...request.txOptions, + hash: txHash, + }); + const { groupId } = + this.groupingModuleEventClient.parseTxIpGroupRegisteredEvent(txReceipt)[0]; + return { txHash, groupId: groupId }; + } + return { txHash }; + } + } catch (error) { + handleError(error, "Failed to register group"); + } + } + /** Mint an NFT from a SPGNFT collection, register it with metadata as an IP, attach license terms to the registered IP, and add it to a group IP. + * @param request - The request object containing necessary data to mint and register Ip and attach license and add to group. + * @param request.nftContract The address of the NFT collection. + * @param request.groupId The ID of the group IP to add the newly registered IP. + * @param request.licenseTermsId The ID of the registered license terms that will be attached to the new IP. + * @param request.recipient [Optional] The address of the recipient of the minted NFT,default value is your wallet address. + * @param request.licenseTemplate [Optional] The address of the license template to be attached to the new group IP,default value is Programmable IP License. + * . @param request.deadline [Optional] The deadline for the signature in milliseconds,default value is 1000ms. + * @param request.ipMetadata - [Optional] The desired metadata for the newly minted NFT and newly registered IP. + * @param request.ipMetadata.ipMetadataURI [Optional] The URI of the metadata for the IP. + * @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.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 IP ID, token ID. + * @emits IPRegistered (ipId, chainId, tokenContract, tokenId, resolverAddr, metadataProviderAddress, metadata) + */ + public async mintAndRegisterIpAndAttachLicenseAndAddToGroup( + request: MintAndRegisterIpAndAttachLicenseAndAddToGroupRequest, + ): Promise { + try { + const { groupId, recipient, spgNftContract, deadline, licenseTemplate } = request; + const isRegistered = await this.ipAssetRegistryClient.isRegistered({ + id: getAddress(groupId, "groupId"), + }); + if (!isRegistered) { + throw new Error(`Group IP ${groupId} is not registered.`); + } + const ipAccount = new IpAccountImplClient(this.rpcClient, this.wallet, groupId); + const { result: state } = await ipAccount.state(); + const calculatedDeadline = getDeadline(deadline); + const sigAddToGroupSignature = await getPermissionSignature({ + ipId: groupId, + deadline: calculatedDeadline, + state, + wallet: this.wallet as WalletClient, + chainId: chain[this.chainId], + permissions: [ + { + ipId: groupId, + signer: getAddress(this.groupingWorkflowsClient.address, "groupingWorkflowsClient"), + to: getAddress(this.groupingModuleClient.address, "groupingModuleClient"), + permission: AccessPermission.ALLOW, + func: "function addIp(address,address[])", + }, + ], + }); + + const object: GroupingWorkflowsMintAndRegisterIpAndAttachLicenseAndAddToGroupRequest = { + ...request, + spgNftContract: getAddress(spgNftContract, "request.spgNftContract"), + recipient: + (recipient && getAddress(recipient, "request.recipient")) || this.wallet.account!.address, + licenseTemplate: + (licenseTemplate && getAddress(licenseTemplate, "request.licenseTemplate")) || + this.licenseTemplateClient.address, + licenseTermsId: BigInt(request.licenseTermsId), + ipMetadata: { + ipMetadataURI: request.ipMetadata?.ipMetadataURI || "", + ipMetadataHash: request.ipMetadata?.ipMetadataHash || zeroHash, + nftMetadataURI: request.ipMetadata?.nftMetadataURI || "", + nftMetadataHash: request.ipMetadata?.nftMetadataHash || zeroHash, + }, + sigAddToGroup: { + signer: getAddress(this.wallet.account!.address, "wallet.account.address"), + deadline: calculatedDeadline, + signature: sigAddToGroupSignature, + }, + }; + if (request.txOptions?.encodedTxDataOnly) { + return { + encodedTxData: + this.groupingWorkflowsClient.mintAndRegisterIpAndAttachLicenseAndAddToGroupEncode( + object, + ), + }; + } else { + const txHash = + await this.groupingWorkflowsClient.mintAndRegisterIpAndAttachLicenseAndAddToGroup(object); + if (request.txOptions?.waitForTransaction) { + const receipt = await this.rpcClient.waitForTransactionReceipt({ + ...request.txOptions, + hash: txHash, + }); + const log = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(receipt)[0]; + return { txHash, ipId: log.ipId, tokenId: log.tokenId }; + } + return { txHash }; + } + } catch (error) { + handleError(error, "Failed to mint and register IP and attach license and add to group"); + } + } + /** Register an NFT as IP with metadata, attach license terms to the registered IP, and add it to a group IP. + * @param request - The request object containing necessary data to register ip and attach license and add to group. + * @param request.spgNftContract The address of the NFT collection. + * @param request.tokenId The ID of the NFT. + * @param request.groupId The ID of the group IP to add the newly registered IP. + * @param request.licenseTermsId The ID of the registered license terms that will be attached to the new IP. + * @param request.licenseTemplate [Optional] The address of the license template to be attached to the new group IP,default value is Programmable IP License. + * . @param request.deadline [Optional] The deadline for the signature in milliseconds,default is 1000ms. + * @param request.ipMetadata - [Optional] The desired metadata for the newly minted NFT and newly registered IP. + * @param request.ipMetadata.ipMetadataURI [Optional] The URI of the metadata for the IP. + * @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.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 IP ID, token ID. + * @emits IPRegistered (ipId, chainId, tokenContract, tokenId, resolverAddr, metadataProviderAddress, metadata) + */ + public async registerIpAndAttachLicenseAndAddToGroup( + request: RegisterIpAndAttachLicenseAndAddToGroupRequest, + ): Promise { + try { + const ipIdAddress = await this.ipAssetRegistryClient.ipId({ + chainId: chain[this.chainId], + tokenContract: getAddress(request.nftContract, "nftContract"), + tokenId: BigInt(request.tokenId), + }); + const isRegistered = await this.ipAssetRegistryClient.isRegistered({ + id: getAddress(request.groupId, "request.groupId"), + }); + if (!isRegistered) { + throw new Error(`Group IP ${request.groupId} is not registered.`); + } + const ipAccount = new IpAccountImplClient(this.rpcClient, this.wallet, request.groupId); + const { result: state } = await ipAccount.state(); + const calculatedDeadline = getDeadline(request.deadline); + const object: GroupingWorkflowsRegisterIpAndAttachLicenseAndAddToGroupRequest = { + nftContract: getAddress(request.nftContract, "request.nftContract"), + groupId: request.groupId, + licenseTemplate: + (request.licenseTemplate && + getAddress(request.licenseTemplate, "request.licenseTemplate")) || + this.licenseTemplateClient.address, + licenseTermsId: BigInt(request.licenseTermsId), + ipMetadata: { + ipMetadataURI: request.ipMetadata?.ipMetadataURI || "", + ipMetadataHash: request.ipMetadata?.ipMetadataHash || zeroHash, + nftMetadataURI: request.ipMetadata?.nftMetadataURI || "", + nftMetadataHash: request.ipMetadata?.nftMetadataHash || zeroHash, + }, + tokenId: BigInt(request.tokenId), + sigAddToGroup: { + signer: getAddress(this.wallet.account!.address, "wallet.account.address"), + deadline: calculatedDeadline, + signature: await getPermissionSignature({ + ipId: getAddress(request.groupId, "request.groupId"), + deadline: calculatedDeadline, + state, + wallet: this.wallet as WalletClient, + chainId: chain[this.chainId], + permissions: [ + { + ipId: getAddress(request.groupId, "request.groupId"), + signer: getAddress(this.groupingWorkflowsClient.address, "groupingWorkflowsClient"), + to: getAddress(this.groupingModuleClient.address, "groupingModuleClient"), + permission: AccessPermission.ALLOW, + func: "function addIp(address,address[])", + }, + ], + }), + }, + sigMetadataAndAttach: { + signer: getAddress(this.wallet.account!.address, "wallet.account.address"), + deadline: calculatedDeadline, + signature: await getPermissionSignature({ + ipId: ipIdAddress, + deadline: calculatedDeadline, + state: toHex(0, { size: 32 }), + wallet: this.wallet as WalletClient, + permissionFunc: "setBatchPermissions", + chainId: chain[this.chainId], + permissions: [ + { + ipId: ipIdAddress, + signer: getAddress(this.groupingWorkflowsClient.address, "groupingWorkflowsClient"), + to: getAddress(this.coreMetadataModuleClient.address, "coreMetadataModuleAddress"), + permission: AccessPermission.ALLOW, + func: "function setAll(address,string,bytes32,bytes32)", + }, + { + ipId: ipIdAddress, + signer: getAddress(this.groupingWorkflowsClient.address, "groupingWorkflowsClient"), + to: getAddress(this.licensingModuleClient.address, "licensingModuleAddress"), + permission: AccessPermission.ALLOW, + func: "function attachLicenseTerms(address,address,uint256)", + }, + ], + }), + }, + }; + if (request.txOptions?.encodedTxDataOnly) { + return { + encodedTxData: + this.groupingWorkflowsClient.registerIpAndAttachLicenseAndAddToGroupEncode(object), + }; + } + const txHash = await this.groupingWorkflowsClient.registerIpAndAttachLicenseAndAddToGroup( + object, + ); + if (request.txOptions?.waitForTransaction) { + const receipt = await this.rpcClient.waitForTransactionReceipt({ + ...request.txOptions, + hash: txHash, + }); + const log = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(receipt)[0]; + return { txHash, ipId: log.ipId, tokenId: log.tokenId }; + } + return { txHash }; + } catch (error) { + handleError(error, "Failed to register IP and attach license and add to group"); + } + } + /** Register a group IP with a group reward pool and attach license terms to the group IP. + * @param request - The request object containing necessary data to register group and attach license. + * @param request.groupPool The address specifying how royalty will be split amongst the pool of IPs in the group. + * @param request.licenseTermsId The ID of the registered license terms that will be attached to the new group IP. + * @param request.licenseTemplate [Optional] The address of the license template to be attached to the new group IP, default value is Programmable IP License. + * @param request.txOptions [Optional] transaction. 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 group id. + * @emits PGroupRegistered (groupId, groupPool); + */ + public async registerGroupAndAttachLicense( + request: RegisterGroupAndAttachLicenseRequest, + ): Promise { + try { + const object = { + groupPool: getAddress(request.groupPool, "request.groupPool"), + licenseTemplate: + (request.licenseTemplate && + getAddress(request.licenseTemplate, "request.licenseTemplate")) || + this.licenseTemplateClient.address, + licenseTermsId: BigInt(request.licenseTermsId), + }; + if (request.txOptions?.encodedTxDataOnly) { + return { + encodedTxData: this.groupingWorkflowsClient.registerGroupAndAttachLicenseEncode(object), + }; + } + const txHash = await this.groupingWorkflowsClient.registerGroupAndAttachLicense(object); + if (request.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ + ...request.txOptions, + hash: txHash, + }); + const { groupId } = + this.groupingModuleEventClient.parseTxIpGroupRegisteredEvent(txReceipt)[0]; + return { txHash, groupId: groupId }; + } + return { txHash }; + } catch (error) { + handleError(error, "Failed to register group and attach license"); + } + } + /** Register a group IP with a group reward pool, attach license terms to the group IP, and add individual IPs to the group IP. + * @param request - The request object containing necessary data to register group and attach license and add ips. + * @param request.pIds must have the same PIL terms as the group IP. + * @param request.groupPool The address specifying how royalty will be split amongst the pool of IPs in the group. + * @param request.licenseTermsId The ID of the registered license terms that will be attached to the new group IP. + * @param request.licenseTemplate [Optional] The address of the license template to be attached to the new group IP,default value is Programmable IP License. + * @param request.txOptions [Optional] transaction. 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 group id. + * @emits PGroupRegistered (groupId, groupPool); + */ + public async registerGroupAndAttachLicenseAndAddIps( + request: RegisterGroupAndAttachLicenseAndAddIpsRequest, + ): Promise { + try { + for (let i = 0; i < request.ipIds.length; i++) { + const isRegistered = await this.ipAssetRegistryClient.isRegistered({ + id: getAddress(request.ipIds[i], `request.ipIds${i}`), + }); + if (!isRegistered) { + throw new Error(`IP ${request.ipIds[i]} is not registered.`); + } + } + + request.licenseTemplate = + (request.licenseTemplate && + getAddress(request.licenseTemplate, "request.licenseTemplate")) || + this.licenseTemplateClient.address; + for (let i = 0; i < request.ipIds.length; i++) { + const isAttachedLicenseTerms = + await this.licenseRegistryReadOnlyClient.hasIpAttachedLicenseTerms({ + ipId: request.ipIds[i], + licenseTemplate: request.licenseTemplate, + licenseTermsId: BigInt(request.licenseTermsId), + }); + if (!isAttachedLicenseTerms) { + throw new Error( + `License terms must be attached to IP ${request.ipIds[i]} before adding to group.`, + ); + } + } + const object: GroupingWorkflowsRegisterGroupAndAttachLicenseAndAddIpsRequest = { + groupPool: getAddress(request.groupPool, "request.groupPool"), + ipIds: request.ipIds, + licenseTemplate: request.licenseTemplate, + licenseTermsId: BigInt(request.licenseTermsId), + }; + if (request.txOptions?.encodedTxDataOnly) { + return { + encodedTxData: + this.groupingWorkflowsClient.registerGroupAndAttachLicenseAndAddIpsEncode(object), + }; + } + const txHash = await this.groupingWorkflowsClient.registerGroupAndAttachLicenseAndAddIps( + object, + ); + if (request.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ + ...request.txOptions, + hash: txHash, + }); + const { groupId } = + this.groupingModuleEventClient.parseTxIpGroupRegisteredEvent(txReceipt)[0]; + return { txHash, groupId: groupId }; + } + return { txHash }; + } catch (error) { + handleError(error, "Failed to register group and attach license and add ips"); + } + } +} diff --git a/packages/core-sdk/src/resources/ipAsset.ts b/packages/core-sdk/src/resources/ipAsset.ts index 1a561161..9bd5d4ec 100644 --- a/packages/core-sdk/src/resources/ipAsset.ts +++ b/packages/core-sdk/src/resources/ipAsset.ts @@ -24,6 +24,8 @@ import { IpCreator, IpMetadata, MintAndRegisterIpAndMakeDerivativeRequest, + MintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest, + MintAndRegisterIpRequest, RegisterDerivativeRequest, RegisterDerivativeResponse, RegisterDerivativeWithLicenseTokensRequest, @@ -32,29 +34,39 @@ import { RegisterIpAndAttachPilTermsResponse, RegisterIpAndMakeDerivativeRequest, RegisterIpAndMakeDerivativeResponse, + RegisterIpAndMakeDerivativeWithLicenseTokensRequest, RegisterIpResponse, + RegisterPilTermsAndAttachRequest, + RegisterPilTermsAndAttachResponse, RegisterRequest, } from "../types/resources/ipAsset"; import { AccessControllerClient, CoreMetadataModuleClient, + DerivativeWorkflowsClient, + DerivativeWorkflowsMintAndRegisterIpAndMakeDerivativeRequest, + DerivativeWorkflowsMintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest, + DerivativeWorkflowsRegisterIpAndMakeDerivativeRequest, + DerivativeWorkflowsRegisterIpAndMakeDerivativeWithLicenseTokensRequest, + IpAccountImplClient, IpAssetRegistryClient, + LicenseAttachmentWorkflowsClient, + LicenseAttachmentWorkflowsMintAndRegisterIpAndAttachPilTermsRequest, + LicenseAttachmentWorkflowsRegisterIpAndAttachPilTermsRequest, + LicenseAttachmentWorkflowsRegisterPilTermsAndAttachRequest, LicenseRegistryReadOnlyClient, LicenseTokenReadOnlyClient, LicensingModuleClient, PiLicenseTemplateClient, - RoyaltyPolicyLapClient, + RegistrationWorkflowsClient, + RegistrationWorkflowsMintAndRegisterIpRequest, + RegistrationWorkflowsRegisterIpRequest, SimpleWalletClient, - SpgClient, - SpgMintAndRegisterIpAndAttachPilTermsRequest, - SpgMintAndRegisterIpAndMakeDerivativeRequest, - SpgRegisterIpAndAttachPilTermsRequest, - SpgRegisterIpAndMakeDerivativeRequest, - SpgRegisterIpRequest, accessControllerAbi, ipAccountImplAbi, + royaltyPolicyLapAddress, } from "../abi/generated"; -import { getLicenseTermByType } from "../utils/getLicenseTermsByType"; +import { getLicenseTermByType, validateLicenseTerms } from "../utils/licenseTermsHelper"; import { getDeadline, getPermissionSignature } from "../utils/sign"; import { AccessPermission, SetPermissionsRequest } from "../types/resources/permission"; @@ -64,10 +76,12 @@ export class IPAssetClient { public licenseTemplateClient: PiLicenseTemplateClient; public licenseRegistryReadOnlyClient: LicenseRegistryReadOnlyClient; public licenseTokenReadOnlyClient: LicenseTokenReadOnlyClient; - public royaltyPolicyLAPClient: RoyaltyPolicyLapClient; public accessControllerClient: AccessControllerClient; public coreMetadataModuleClient: CoreMetadataModuleClient; - public spgClient: SpgClient; + public registrationWorkflowsClient: RegistrationWorkflowsClient; + public licenseAttachmentWorkflowsClient: LicenseAttachmentWorkflowsClient; + public derivativeWorkflowsClient: DerivativeWorkflowsClient; + private readonly rpcClient: PublicClient; private readonly wallet: SimpleWalletClient; private readonly chainId: SupportedChainIds; @@ -78,10 +92,11 @@ export class IPAssetClient { this.licenseTemplateClient = new PiLicenseTemplateClient(rpcClient, wallet); this.licenseRegistryReadOnlyClient = new LicenseRegistryReadOnlyClient(rpcClient); this.licenseTokenReadOnlyClient = new LicenseTokenReadOnlyClient(rpcClient); - this.royaltyPolicyLAPClient = new RoyaltyPolicyLapClient(rpcClient, wallet); this.accessControllerClient = new AccessControllerClient(rpcClient, wallet); this.coreMetadataModuleClient = new CoreMetadataModuleClient(rpcClient, wallet); - this.spgClient = new SpgClient(rpcClient, wallet); + this.registrationWorkflowsClient = new RegistrationWorkflowsClient(rpcClient, wallet); + this.licenseAttachmentWorkflowsClient = new LicenseAttachmentWorkflowsClient(rpcClient, wallet); + this.derivativeWorkflowsClient = new DerivativeWorkflowsClient(rpcClient, wallet); this.rpcClient = rpcClient; this.wallet = wallet; this.chainId = chainId; @@ -190,7 +205,7 @@ export class IPAssetClient { app, tags, robotTerms, - ...additionalProperties, // Include any additional properties + ...additionalProperties, }; } @@ -205,8 +220,8 @@ export class IPAssetClient { * @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.deadline [Optional] The deadline for the signature in milliseconds, default is 1000ms. - * @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. + * @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 IP ID, token ID. * @emits IPRegistered (ipId, chainId, tokenContract, tokenId, resolverAddr, metadataProviderAddress, metadata) */ public async register(request: RegisterRequest): Promise { @@ -217,7 +232,7 @@ export class IPAssetClient { if (isRegistered) { return { ipId: ipIdAddress }; } - const object: SpgRegisterIpRequest = { + const object: RegistrationWorkflowsRegisterIpRequest = { tokenId, nftContract: getAddress(request.nftContract, "request.nftContract"), ipMetadata: { @@ -234,7 +249,7 @@ export class IPAssetClient { }; if (request.txOptions?.encodedTxDataOnly) { if (request.ipMetadata) { - return { encodedTxData: this.spgClient.registerIpEncode(object) }; + return { encodedTxData: this.registrationWorkflowsClient.registerIpEncode(object) }; } else { return { encodedTxData: this.ipAssetRegistryClient.registerEncode({ @@ -257,7 +272,10 @@ export class IPAssetClient { permissions: [ { ipId: ipIdAddress, - signer: getAddress(this.spgClient.address, "spgAddress"), + signer: getAddress( + this.registrationWorkflowsClient.address, + "registrationWorkflowsClient", + ), to: getAddress(this.coreMetadataModuleClient.address, "coreMetadataModuleAddress"), permission: AccessPermission.ALLOW, func: "function setAll(address,string,bytes32,bytes32)", @@ -269,7 +287,7 @@ export class IPAssetClient { deadline: calculatedDeadline, signature, }; - txHash = await this.spgClient.registerIp(object); + txHash = await this.registrationWorkflowsClient.registerIp(object); } else { txHash = await this.ipAssetRegistryClient.register({ tokenContract: object.nftContract, @@ -283,7 +301,7 @@ export class IPAssetClient { hash: txHash, }); const targetLogs = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(txReceipt); - return { txHash: txHash, ipId: targetLogs[0].ipId }; + return { txHash: txHash, ipId: targetLogs[0].ipId, tokenId: targetLogs[0].tokenId }; } else { return { txHash: txHash }; } @@ -387,15 +405,7 @@ export class IPAssetClient { if (!isChildIpIdRegistered) { throw new Error(`The child IP with id ${request.childIpId} is not registered.`); } - request.licenseTokenIds = request.licenseTokenIds.map((id) => BigInt(id)); - for (const licenseTokenId of request.licenseTokenIds) { - const tokenOwnerAddress = await this.licenseTokenReadOnlyClient.ownerOf({ - tokenId: licenseTokenId, - }); - if (!tokenOwnerAddress) { - throw new Error(`License token id ${licenseTokenId} must be owned by the caller.`); - } - } + request.licenseTokenIds = await this.validateLicenseTokenIds(request.licenseTokenIds); const req = { childIpId: getAddress(request.childIpId, "request.childIpId"), licenseTokenIds: request.licenseTokenIds, @@ -425,19 +435,19 @@ export class IPAssetClient { /** * Mint an NFT from a collection and register it as an IP. * @param request - The request object that contains all data needed to mint and register ip. - * @param request.nftContract The address of the NFT collection. + * @param request.spgNftContract The address of the NFT collection. * @param request.pilType The type of the PIL. * @param request.ipMetadata - [Optional] The desired metadata for the newly minted NFT and newly registered IP. * @param request.ipMetadata.ipMetadataURI [Optional] The URI of the metadata for the IP. * @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.recipient [Optional] The address of the recipient of the minted NFT. + * @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. * @param request.currency [Optional] The ERC20 token to be used to pay the minting fee. the token must be registered in story protocol. - * @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, Token ID, License Terms Id if waitForTxn is set to true. + * @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 IP ID, Token ID, License Terms Id. * @emits IPRegistered (ipId, chainId, tokenContract, tokenId, name, uri, registrationDate) * @emits LicenseTermsAttached (caller, ipId, licenseTemplate, licenseTermsId) */ @@ -451,11 +461,14 @@ export class IPAssetClient { const licenseTerm = getLicenseTermByType(request.pilType, { defaultMintingFee: request.mintingFee, currency: request.currency, - royaltyPolicyLAPAddress: this.royaltyPolicyLAPClient.address, commercialRevShare: request.commercialRevShare, + royaltyPolicyLAPAddress: + royaltyPolicyLapAddress[ + chain[this.chainId] as unknown as keyof typeof royaltyPolicyLapAddress + ], }); - const object: SpgMintAndRegisterIpAndAttachPilTermsRequest = { - nftContract: getAddress(request.nftContract, "request.nftContract"), + const object: LicenseAttachmentWorkflowsMintAndRegisterIpAndAttachPilTermsRequest = { + spgNftContract: getAddress(request.spgNftContract, "request.spgNftContract"), recipient: (request.recipient && getAddress(request.recipient, "request.recipient")) || this.wallet.account!.address, @@ -469,9 +482,13 @@ export class IPAssetClient { }, }; if (request.txOptions?.encodedTxDataOnly) { - return { encodedTxData: this.spgClient.mintAndRegisterIpAndAttachPilTermsEncode(object) }; + return { + encodedTxData: + this.licenseAttachmentWorkflowsClient.mintAndRegisterIpAndAttachPilTermsEncode(object), + }; } else { - const txHash = await this.spgClient.mintAndRegisterIpAndAttachPilTerms(object); + const txHash = + await this.licenseAttachmentWorkflowsClient.mintAndRegisterIpAndAttachPilTerms(object); if (request.txOptions?.waitForTransaction) { const txReceipt = await this.rpcClient.waitForTransactionReceipt({ ...request.txOptions, @@ -527,7 +544,10 @@ export class IPAssetClient { const licenseTerm = getLicenseTermByType(request.pilType, { defaultMintingFee: request.mintingFee, currency: request.currency, - royaltyPolicyLAPAddress: this.royaltyPolicyLAPClient.address, + royaltyPolicyLAPAddress: + royaltyPolicyLapAddress[ + chain[this.chainId] as unknown as keyof typeof royaltyPolicyLapAddress + ], commercialRevShare: request.commercialRevShare, }); const calculatedDeadline = getDeadline(request.deadline); @@ -537,7 +557,10 @@ export class IPAssetClient { deadline: calculatedDeadline, state: this.getSigSignatureState({ ipId: ipIdAddress, - signer: getAddress(this.spgClient.address, "spgAddress"), + signer: getAddress( + this.licenseAttachmentWorkflowsClient.address, + "licenseAttachmentWorkflowsClient", + ), to: getAddress(this.coreMetadataModuleClient.address, "coreMetadataModuleAddress"), permission: AccessPermission.ALLOW, func: "function setAll(address,string,bytes32,bytes32)", @@ -547,14 +570,37 @@ export class IPAssetClient { permissions: [ { ipId: ipIdAddress, - signer: getAddress(this.spgClient.address, "spgAddress"), + signer: getAddress( + this.licenseAttachmentWorkflowsClient.address, + "licenseAttachmentWorkflowsClient", + ), to: getAddress(this.licensingModuleClient.address, "licensingModuleAddress"), permission: AccessPermission.ALLOW, func: "function attachLicenseTerms(address,address,uint256)", }, ], }); - const object: SpgRegisterIpAndAttachPilTermsRequest = { + const sigMetadataSignature = await getPermissionSignature({ + ipId: ipIdAddress, + deadline: calculatedDeadline, + state: toHex(0, { size: 32 }), + wallet: this.wallet as WalletClient, + chainId: chain[this.chainId], + permissions: [ + { + ipId: ipIdAddress, + signer: getAddress( + this.licenseAttachmentWorkflowsClient.address, + "licenseAttachmentWorkflowsClient", + ), + to: getAddress(this.coreMetadataModuleClient.address, "coreMetadataModuleAddress"), + permission: AccessPermission.ALLOW, + func: "function setAll(address,string,bytes32,bytes32)", + }, + ], + }); + + const object: LicenseAttachmentWorkflowsRegisterIpAndAttachPilTermsRequest = { nftContract: getAddress(request.nftContract, "request.nftContract"), tokenId: request.tokenId, terms: licenseTerm, @@ -565,9 +611,9 @@ export class IPAssetClient { nftMetadataHash: request.ipMetadata?.nftMetadataHash || zeroHash, }, sigMetadata: { - signer: zeroAddress, - deadline: BigInt(0), - signature: zeroHash, + signer: getAddress(this.wallet.account!.address, "wallet.account.address"), + deadline: calculatedDeadline, + signature: sigMetadataSignature, }, sigAttach: { signer: getAddress(this.wallet.account!.address, "wallet.account.address"), @@ -575,31 +621,16 @@ export class IPAssetClient { signature: sigAttachSignature, }, }; - const sigMetadataSignature = await getPermissionSignature({ - ipId: ipIdAddress, - deadline: calculatedDeadline, - state: toHex(0, { size: 32 }), - wallet: this.wallet as WalletClient, - chainId: chain[this.chainId], - permissions: [ - { - ipId: ipIdAddress, - signer: getAddress(this.spgClient.address, "spgAddress"), - to: getAddress(this.coreMetadataModuleClient.address, "coreMetadataModuleAddress"), - permission: AccessPermission.ALLOW, - func: "function setAll(address,string,bytes32,bytes32)", - }, - ], - }); - object.sigMetadata = { - signer: getAddress(this.wallet.account!.address, "wallet.account.address"), - deadline: calculatedDeadline, - signature: sigMetadataSignature, - }; + if (request.txOptions?.encodedTxDataOnly) { - return { encodedTxData: this.spgClient.registerIpAndAttachPilTermsEncode(object) }; + return { + encodedTxData: + this.licenseAttachmentWorkflowsClient.registerIpAndAttachPilTermsEncode(object), + }; } else { - const txHash = await this.spgClient.registerIpAndAttachPilTerms(object); + const txHash = await this.licenseAttachmentWorkflowsClient.registerIpAndAttachPilTerms( + object, + ); if (request.txOptions?.waitForTransaction) { const txReceipt = await this.rpcClient.waitForTransactionReceipt({ ...request.txOptions, @@ -673,7 +704,7 @@ export class IPAssetClient { deadline: calculatedDeadline, state: this.getSigSignatureState({ ipId: ipIdAddress, - signer: getAddress(this.spgClient.address, "spgAddress"), + signer: getAddress(this.derivativeWorkflowsClient.address, "derivativeWorkflowsClient"), to: getAddress(this.coreMetadataModuleClient.address, "coreMetadataModuleAddress"), permission: AccessPermission.ALLOW, func: "function setAll(address,string,bytes32,bytes32)", @@ -683,14 +714,14 @@ export class IPAssetClient { permissions: [ { ipId: ipIdAddress, - signer: getAddress(this.spgClient.address, "spgAddress"), + signer: getAddress(this.derivativeWorkflowsClient.address, "derivativeWorkflowsClient"), to: getAddress(this.licensingModuleClient.address, "licensingModuleAddress"), permission: AccessPermission.ALLOW, func: "function registerDerivative(address,address[],uint256[],address,bytes)", }, ], }); - const object: SpgRegisterIpAndMakeDerivativeRequest = { + const object: DerivativeWorkflowsRegisterIpAndMakeDerivativeRequest = { nftContract: getAddress(request.nftContract, "request.nftContract"), tokenId: BigInt(request.tokenId), derivData: { @@ -730,7 +761,7 @@ export class IPAssetClient { permissions: [ { ipId: ipIdAddress, - signer: getAddress(this.spgClient.address, "spgAddress"), + signer: getAddress(this.derivativeWorkflowsClient.address, "derivativeWorkflowsClient"), to: getAddress(this.coreMetadataModuleClient.address, "coreMetadataModuleAddress"), permission: AccessPermission.ALLOW, func: "function setAll(address,string,bytes32,bytes32)", @@ -743,9 +774,11 @@ export class IPAssetClient { signature: sigMetadataSignature, }; if (request.txOptions?.encodedTxDataOnly) { - return { encodedTxData: this.spgClient.registerIpAndMakeDerivativeEncode(object) }; + return { + encodedTxData: this.derivativeWorkflowsClient.registerIpAndMakeDerivativeEncode(object), + }; } else { - const txHash = await this.spgClient.registerIpAndMakeDerivative(object); + const txHash = await this.derivativeWorkflowsClient.registerIpAndMakeDerivative(object); if (request.txOptions?.waitForTransaction) { const receipt = await this.rpcClient.waitForTransactionReceipt({ ...request.txOptions, @@ -764,7 +797,7 @@ export class IPAssetClient { /** * Mint an NFT from a collection and register it as a derivative IP without license tokens. * @param request - The request object that contains all data needed to mint and register ip and make derivative. - * @param request.nftContract The address of the NFT collection. + * @param request.spgNftContract The address of the NFT collection. * @param request.derivData The derivative data to be used for registerDerivative. * @param request.derivData.parentIpIds The IDs of the parent IPs to link the registered derivative IP. * @param request.derivData.licenseTermsIds The IDs of the license terms to be used for the linking. @@ -773,8 +806,8 @@ export class IPAssetClient { * @param request.ipMetadata.ipMetadataURI [Optional] The URI of the metadata for the IP. * @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.recipient [Optional] The address of the recipient of the minted NFT. + * @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. * @emits IPRegistered (ipId, chainId, tokenContract, tokenId, name, uri, registrationDate) @@ -805,7 +838,7 @@ export class IPAssetClient { ); } } - const object: SpgMintAndRegisterIpAndMakeDerivativeRequest = { + const object: DerivativeWorkflowsMintAndRegisterIpAndMakeDerivativeRequest = { ...request, derivData: { ...request.derivData, @@ -824,9 +857,14 @@ export class IPAssetClient { this.wallet.account!.address, }; if (request.txOptions?.encodedTxDataOnly) { - return { encodedTxData: this.spgClient.mintAndRegisterIpAndMakeDerivativeEncode(object) }; + return { + encodedTxData: + this.derivativeWorkflowsClient.mintAndRegisterIpAndMakeDerivativeEncode(object), + }; } else { - const txHash = await this.spgClient.mintAndRegisterIpAndMakeDerivative(object); + const txHash = await this.derivativeWorkflowsClient.mintAndRegisterIpAndMakeDerivative( + object, + ); if (request.txOptions?.waitForTransaction) { const receipt = await this.rpcClient.waitForTransactionReceipt({ ...request.txOptions, @@ -841,6 +879,319 @@ export class IPAssetClient { handleError(error, "Failed to mint and register IP and make derivative"); } } + /** + * Mint an NFT from a SPGNFT collection and register it with metadata as an IP. + * @param request - The request object that contains all data needed to attach license terms. + * @param request.spgNftContract The address of the SPGNFT collection. + * @param request.recipient The address of the recipient of the minted NFT,default value is your wallet address. + * @param request.ipMetadata - [Optional] The desired metadata for the newly minted NFT and newly registered IP. + * @param request.ipMetadata.ipMetadataURI [Optional] The URI of the metadata for the IP. + * @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.txOptions - [Optional] transaction. 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, or if waitForTransaction is true, includes IP ID and Token ID. + * @emits IPRegistered (ipId, chainId, tokenContract, tokenId, name, uri, registrationDate) + */ + public async mintAndRegisterIp(request: MintAndRegisterIpRequest): Promise { + try { + const object: RegistrationWorkflowsMintAndRegisterIpRequest = { + spgNftContract: getAddress(request.spgNftContract, "request.spgNftContract"), + recipient: + (request.recipient && getAddress(request.recipient, "request.recipient")) || + this.wallet.account!.address, + ipMetadata: { + ipMetadataURI: request.ipMetadata?.ipMetadataURI || "", + ipMetadataHash: request.ipMetadata?.ipMetadataHash || zeroHash, + nftMetadataURI: request.ipMetadata?.nftMetadataURI || "", + nftMetadataHash: request.ipMetadata?.nftMetadataHash || zeroHash, + }, + }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: this.registrationWorkflowsClient.mintAndRegisterIpEncode(object) }; + } else { + const txHash = await this.registrationWorkflowsClient.mintAndRegisterIp(object); + if (request.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ + ...request.txOptions, + hash: txHash, + }); + const ipRegisterEvent = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(txReceipt); + return { txHash, ipId: ipRegisterEvent[0].ipId, tokenId: ipRegisterEvent[0].tokenId }; + } + return { txHash }; + } + } catch (error) { + handleError(error, "Failed to mint and register IP"); + } + } + /** + * Register Programmable IP License Terms (if unregistered) and attach it to IP. + * @param request - The request object that contains all data needed to attach license terms. + * @param request.ipId The ID of the IP. + * @param request.terms The PIL terms to be registered. + * @param request.terms.transferable Indicates whether the license is transferable or not. + * @param request.terms.royaltyPolicy The address of the royalty policy contract which required to StoryProtocol in advance. + * @param request.terms.mintingFee The fee to be paid when minting a license. + * @param request.terms.expiration The expiration period of the license. + * @param request.terms.commercialUse Indicates whether the work can be used commercially or not. + * @param request.terms.commercialAttribution Whether attribution is required when reproducing the work commercially or not. + * @param request.terms.commercializerChecker Commercializers that are allowed to commercially exploit the work. If zero address, then no restrictions is enforced. + * @param request.terms.commercializerCheckerData The data to be passed to the commercializer checker contract. + * @param request.terms.commercialRevShare Percentage of revenue that must be shared with the licensor. + * @param request.terms.commercialRevCeiling The maximum revenue that can be generated from the commercial use of the work. + * @param request.terms.derivativesAllowed Indicates whether the licensee can create derivatives of his work or not. + * @param request.terms.derivativesAttribution Indicates whether attribution is required for derivatives of the work or not. + * @param request.terms.derivativesApproval Indicates whether the licensor must approve derivatives of the work before they can be linked to the licensor IP ID or not. + * @param request.terms.derivativesReciprocal Indicates whether the licensee must license derivatives of the work under the same terms or not. + * @param request.terms.derivativeRevCeiling The maximum revenue that can be generated from the derivative use of the work. + * @param request.terms.currency The ERC20 token to be used to pay the minting fee. the token must be registered in story protocol. + * @param request.terms.uri The URI of the license terms, which can be used to fetch the offchain license terms. + * @param request.deadline [Optional] The deadline for the signature in milliseconds,default is 1000ms. + * @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 license terms id. + * @emits LicenseTermsAttached (caller, ipId, licenseTemplate, licenseTermsId) + */ + public async registerPilTermsAndAttach( + request: RegisterPilTermsAndAttachRequest, + ): Promise { + try { + const { ipId, terms } = request; + const isRegistered = await this.isRegistered(ipId); + if (!isRegistered) { + throw new Error(`The IP with id ${ipId} is not registered.`); + } + const licenseTerms = await validateLicenseTerms(terms, this.rpcClient); + const licenseRes = await this.licenseTemplateClient.getLicenseTermsId({ + terms: licenseTerms, + }); + const calculatedDeadline = getDeadline(request.deadline); + const ipAccount = new IpAccountImplClient(this.rpcClient, this.wallet, ipId); + const { result: state } = await ipAccount.state(); + const sigAttachSignature = await getPermissionSignature({ + ipId: ipId, + deadline: calculatedDeadline, + state, + wallet: this.wallet as WalletClient, + chainId: chain[this.chainId], + permissions: [ + { + ipId: ipId, + signer: getAddress( + this.licenseAttachmentWorkflowsClient.address, + "licenseAttachmentWorkflowsClient", + ), + to: getAddress(this.licensingModuleClient.address, "licensingModuleAddress"), + permission: AccessPermission.ALLOW, + func: "function attachLicenseTerms(address,address,uint256)", + }, + ], + }); + const object: LicenseAttachmentWorkflowsRegisterPilTermsAndAttachRequest = { + ipId: ipId, + terms: licenseTerms, + sigAttach: { + signer: getAddress(this.wallet.account!.address, "wallet.account.address"), + deadline: calculatedDeadline, + signature: sigAttachSignature, + }, + }; + if (request.txOptions?.encodedTxDataOnly) { + return { + encodedTxData: + this.licenseAttachmentWorkflowsClient.registerPilTermsAndAttachEncode(object), + }; + } else { + const txHash = await this.licenseAttachmentWorkflowsClient.registerPilTermsAndAttach( + object, + ); + if (request.txOptions?.waitForTransaction) { + await this.rpcClient.waitForTransactionReceipt({ + ...request.txOptions, + hash: txHash, + }); + return { txHash, licenseTermsId: licenseRes.selectedLicenseTermsId }; + } else { + return { txHash }; + } + } + } catch (error) { + handleError(error, "Failed to register PIL terms and attach"); + } + } + /** + * Mint an NFT from a collection and register it as a derivative IP using license tokens + * @param request - The request object that contains all data needed to mint and register ip and make derivative with license tokens. + * @param request.spgNftContract The address of the NFT collection. + * @param request.licenseTokenIds The IDs of the license tokens to be burned for linking the IP to parent IPs. + * @param request.ipMetadata - [Optional] The desired metadata for the newly minted NFT and newly registered IP. + * @param request.ipMetadata.ipMetadataURI [Optional] The URI of the metadata for the IP. + * @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.recipient - [Optional] The address to receive 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 a transaction hash, and if encodedTxDataOnly is true, includes encoded transaction data, or if waitForTransaction is true, includes IP ID and Token ID. + * @emits IPRegistered (ipId, chainId, tokenContract, tokenId, name, uri, registrationDate) + */ + public async mintAndRegisterIpAndMakeDerivativeWithLicenseTokens( + request: MintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest, + ): Promise { + try { + const licenseTokenIds = await this.validateLicenseTokenIds(request.licenseTokenIds); + const object: DerivativeWorkflowsMintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest = + { + spgNftContract: getAddress(request.spgNftContract, "request.spgNftContract"), + recipient: + (request.recipient && getAddress(request.recipient, "request.recipient")) || + this.wallet.account!.address, + ipMetadata: { + ipMetadataURI: request.ipMetadata?.ipMetadataURI || "", + ipMetadataHash: request.ipMetadata?.ipMetadataHash || zeroHash, + nftMetadataURI: request.ipMetadata?.nftMetadataURI || "", + nftMetadataHash: request.ipMetadata?.nftMetadataHash || zeroHash, + }, + licenseTokenIds: licenseTokenIds, + royaltyContext: zeroAddress, + }; + if (request.txOptions?.encodedTxDataOnly) { + return { + encodedTxData: + this.derivativeWorkflowsClient.mintAndRegisterIpAndMakeDerivativeWithLicenseTokensEncode( + object, + ), + }; + } else { + const txHash = + await this.derivativeWorkflowsClient.mintAndRegisterIpAndMakeDerivativeWithLicenseTokens( + object, + ); + if (request.txOptions?.waitForTransaction) { + const receipt = await this.rpcClient.waitForTransactionReceipt({ + ...request.txOptions, + hash: txHash, + }); + const log = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(receipt)[0]; + return { txHash, ipId: log.ipId, tokenId: log.tokenId }; + } + return { txHash }; + } + } catch (error) { + handleError(error, "Failed to mint and register IP and make derivative with license tokens"); + } + } + /** + * Register the given NFT as a derivative IP using license tokens. + * @param request - The request object that contains all data needed to register ip and make derivative with license tokens. + * @param request.nftContract The address of the NFT collection. + * @param request.licenseTokenIds The IDs of the license tokens to be burned for linking the IP to parent IPs. + * @param request.tokenId The ID of the NFT. + * @param request.deadline [Optional] The deadline for the signature in milliseconds, default is 1000ms. + * @param request.ipMetadata - [Optional] The desired metadata for the newly minted NFT and newly registered IP. + * @param request.ipMetadata.ipMetadataURI [Optional] The URI of the metadata for the IP. + * @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.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, or if waitForTransaction is true, includes IP ID. + */ + public async registerIpAndMakeDerivativeWithLicenseTokens( + request: RegisterIpAndMakeDerivativeWithLicenseTokensRequest, + ): Promise { + try { + const tokenId = BigInt(request.tokenId); + const ipIdAddress = await this.getIpIdAddress(request.nftContract, tokenId); + const isRegistered = await this.isRegistered(ipIdAddress); + if (isRegistered) { + throw new Error(`The NFT with id ${tokenId} is already registered as IP.`); + } + const licenseTokenIds = await this.validateLicenseTokenIds(request.licenseTokenIds); + const calculatedDeadline = getDeadline(request.deadline); + const sigMetadataSignature = await getPermissionSignature({ + ipId: ipIdAddress, + deadline: calculatedDeadline, + state: toHex(0, { size: 32 }), + wallet: this.wallet as WalletClient, + chainId: chain[this.chainId], + permissions: [ + { + ipId: ipIdAddress, + signer: getAddress(this.derivativeWorkflowsClient.address, "derivativeWorkflowsClient"), + to: getAddress(this.coreMetadataModuleClient.address, "coreMetadataModuleAddress"), + permission: AccessPermission.ALLOW, + func: "function setAll(address,string,bytes32,bytes32)", + }, + ], + }); + const sigRegisterSignature = await getPermissionSignature({ + ipId: ipIdAddress, + deadline: calculatedDeadline, + state: this.getSigSignatureState({ + ipId: ipIdAddress, + signer: getAddress(this.derivativeWorkflowsClient.address, "derivativeWorkflowsClient"), + to: getAddress(this.coreMetadataModuleClient.address, "coreMetadataModuleAddress"), + permission: AccessPermission.ALLOW, + func: "function setAll(address,string,bytes32,bytes32)", + }), + wallet: this.wallet as WalletClient, + chainId: chain[this.chainId], + permissions: [ + { + ipId: ipIdAddress, + signer: getAddress(this.derivativeWorkflowsClient.address, "derivativeWorkflowsClient"), + to: getAddress(this.licensingModuleClient.address, "licensingModuleAddress"), + permission: AccessPermission.ALLOW, + func: "function registerDerivativeWithLicenseTokens(address,uint256[],bytes)", + }, + ], + }); + const object: DerivativeWorkflowsRegisterIpAndMakeDerivativeWithLicenseTokensRequest = { + ...request, + tokenId, + licenseTokenIds, + royaltyContext: zeroAddress, + ipMetadata: { + ipMetadataURI: request.ipMetadata?.ipMetadataURI || "", + ipMetadataHash: request.ipMetadata?.ipMetadataHash || zeroHash, + nftMetadataURI: request.ipMetadata?.nftMetadataURI || "", + nftMetadataHash: request.ipMetadata?.nftMetadataHash || zeroHash, + }, + sigMetadata: { + signer: getAddress(this.wallet.account!.address, "wallet.account.address"), + deadline: calculatedDeadline, + signature: sigMetadataSignature, + }, + sigRegister: { + signer: getAddress(this.wallet.account!.address, "wallet.account.address"), + deadline: calculatedDeadline, + signature: sigRegisterSignature, + }, + }; + if (request.txOptions?.encodedTxDataOnly) { + return { + encodedTxData: + this.derivativeWorkflowsClient.registerIpAndMakeDerivativeWithLicenseTokensEncode( + object, + ), + }; + } else { + const txHash = + await this.derivativeWorkflowsClient.registerIpAndMakeDerivativeWithLicenseTokens(object); + if (request.txOptions?.waitForTransaction) { + const receipt = await this.rpcClient.waitForTransactionReceipt({ + ...request.txOptions, + hash: txHash, + }); + const log = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(receipt)[0]; + return { txHash, ipId: log.ipId }; + } + return { txHash }; + } + } catch (error) { + handleError(error, "Failed to register IP and make derivative with license tokens"); + } + } + private async getIpIdAddress( nftContract: Address, tokenId: bigint | string | number, @@ -900,4 +1251,22 @@ export class IPAssetClient { } return licenseTermsId; } + + private async validateLicenseTokenIds( + licenseTokenIds: string[] | bigint[] | number[], + ): Promise { + if (licenseTokenIds.length === 0) { + throw new Error("License token IDs must be provided."); + } + const newLicenseTokenIds = licenseTokenIds.map((id) => BigInt(id)); + for (const licenseTokenId of newLicenseTokenIds) { + const tokenOwnerAddress = await this.licenseTokenReadOnlyClient.ownerOf({ + tokenId: licenseTokenId, + }); + if (!tokenOwnerAddress) { + throw new Error(`License token id ${licenseTokenId} must be owned by the caller.`); + } + } + return newLicenseTokenIds; + } } diff --git a/packages/core-sdk/src/resources/license.ts b/packages/core-sdk/src/resources/license.ts index 9a4e84a7..f9d3d5f5 100644 --- a/packages/core-sdk/src/resources/license.ts +++ b/packages/core-sdk/src/resources/license.ts @@ -8,9 +8,8 @@ import { PiLicenseTemplateClient, PiLicenseTemplateGetLicenseTermsResponse, PiLicenseTemplateReadOnlyClient, - RoyaltyModuleReadOnlyClient, - RoyaltyPolicyLapClient, SimpleWalletClient, + royaltyPolicyLapAddress, } from "../abi/generated"; import { LicenseTerms, @@ -28,8 +27,9 @@ import { RegisterPILTermsRequest, } from "../types/resources/license"; import { handleError } from "../utils/errors"; -import { getLicenseTermByType } from "../utils/getLicenseTermsByType"; -import { getAddress } from "../utils/utils"; +import { getLicenseTermByType, validateLicenseTerms } from "../utils/licenseTermsHelper"; +import { chain, getAddress } from "../utils/utils"; +import { SupportedChainIds } from "../types/config"; export class LicenseClient { public licenseRegistryClient: LicenseRegistryEventClient; @@ -37,23 +37,21 @@ export class LicenseClient { public ipAssetRegistryClient: IpAssetRegistryClient; public piLicenseTemplateReadOnlyClient: PiLicenseTemplateReadOnlyClient; public licenseTemplateClient: PiLicenseTemplateClient; - public royaltyPolicyLAPClient: RoyaltyPolicyLapClient; - public royaltyModuleReadOnlyClient: RoyaltyModuleReadOnlyClient; public licenseRegistryReadOnlyClient: LicenseRegistryReadOnlyClient; private readonly rpcClient: PublicClient; private readonly wallet: SimpleWalletClient; + private readonly chainId: SupportedChainIds; - constructor(rpcClient: PublicClient, wallet: SimpleWalletClient) { + constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, chainId: SupportedChainIds) { this.licensingModuleClient = new LicensingModuleClient(rpcClient, wallet); this.licenseRegistryClient = new LicenseRegistryEventClient(rpcClient); this.piLicenseTemplateReadOnlyClient = new PiLicenseTemplateReadOnlyClient(rpcClient); this.licenseTemplateClient = new PiLicenseTemplateClient(rpcClient, wallet); - this.royaltyPolicyLAPClient = new RoyaltyPolicyLapClient(rpcClient, wallet); - this.royaltyModuleReadOnlyClient = new RoyaltyModuleReadOnlyClient(rpcClient); this.licenseRegistryReadOnlyClient = new LicenseRegistryReadOnlyClient(rpcClient); this.ipAssetRegistryClient = new IpAssetRegistryClient(rpcClient, wallet); this.rpcClient = rpcClient; this.wallet = wallet; + this.chainId = chainId; } /** * Registers new license terms and return the ID of the newly registered license terms. @@ -81,40 +79,7 @@ export class LicenseClient { */ public async registerPILTerms(request: RegisterPILTermsRequest): Promise { try { - const { royaltyPolicy, currency } = request; - if (getAddress(royaltyPolicy, "request.royaltyPolicy") !== zeroAddress) { - const isWhitelistedArbitrationPolicy = - await this.royaltyModuleReadOnlyClient.isWhitelistedRoyaltyPolicy({ royaltyPolicy }); - if (!isWhitelistedArbitrationPolicy) { - throw new Error("The royalty policy is not whitelisted."); - } - } - if (getAddress(currency, "request.currency") !== zeroAddress) { - const isWhitelistedRoyaltyToken = - await this.royaltyModuleReadOnlyClient.isWhitelistedRoyaltyToken({ - token: currency, - }); - if (!isWhitelistedRoyaltyToken) { - throw new Error("The currency token is not whitelisted."); - } - } - if (royaltyPolicy !== zeroAddress && currency === zeroAddress) { - throw new Error("Royalty policy requires currency token."); - } - const object = { - ...request, - defaultMintingFee: BigInt(request.defaultMintingFee), - expiration: BigInt(request.expiration), - commercialRevCeiling: BigInt(request.commercialRevCeiling), - derivativeRevCeiling: BigInt(request.derivativeRevCeiling), - }; - this.verifyCommercialUse(object); - this.verifyDerivatives(object); - if (object.commercialRevShare < 0 || object.commercialRevShare > 100) { - throw new Error("CommercialRevShare should be between 0 and 100."); - } else { - object.commercialRevShare = (object.commercialRevShare / 100) * 100000000; - } + const object = await validateLicenseTerms(request, this.rpcClient); const licenseTermsId = await this.getLicenseTermsId(object); if (licenseTermsId !== 0n) { return { licenseTermsId: licenseTermsId }; @@ -203,7 +168,10 @@ export class LicenseClient { const licenseTerms = getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE, { defaultMintingFee: request.defaultMintingFee, currency: request.currency, - royaltyPolicyLAPAddress: this.royaltyPolicyLAPClient.address, + royaltyPolicyLAPAddress: + royaltyPolicyLapAddress[ + chain[this.chainId] as unknown as keyof typeof royaltyPolicyLapAddress + ], }); const licenseTermsId = await this.getLicenseTermsId(licenseTerms); if (licenseTermsId !== 0n) { @@ -252,7 +220,10 @@ export class LicenseClient { const licenseTerms = getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { defaultMintingFee: request.defaultMintingFee, currency: request.currency, - royaltyPolicyLAPAddress: this.royaltyPolicyLAPClient.address, + royaltyPolicyLAPAddress: + royaltyPolicyLapAddress[ + chain[this.chainId] as unknown as keyof typeof royaltyPolicyLapAddress + ], commercialRevShare: request.commercialRevShare, }); const licenseTermsId = await this.getLicenseTermsId(licenseTerms); @@ -458,49 +429,4 @@ export class LicenseClient { const licenseRes = await this.licenseTemplateClient.getLicenseTermsId({ terms: request }); return licenseRes.selectedLicenseTermsId; } - private verifyCommercialUse(terms: LicenseTerms) { - if (!terms.commercialUse) { - if (terms.commercialAttribution) { - throw new Error("Cannot add commercial attribution when commercial use is disabled."); - } - if (terms.commercializerChecker !== zeroAddress) { - throw new Error("Cannot add commercializerChecker when commercial use is disabled."); - } - if (terms.commercialRevShare > 0) { - throw new Error("Cannot add commercial revenue share when commercial use is disabled."); - } - if (terms.commercialRevCeiling > 0) { - throw new Error("Cannot add commercial revenue ceiling when commercial use is disabled."); - } - if (terms.derivativeRevCeiling > 0) { - throw new Error( - "Cannot add derivative revenue ceiling share when commercial use is disabled.", - ); - } - if (terms.royaltyPolicy !== zeroAddress) { - throw new Error("Cannot add commercial royalty policy when commercial use is disabled."); - } - } else { - if (terms.royaltyPolicy === zeroAddress) { - throw new Error("Royalty policy is required when commercial use is enabled."); - } - } - } - - private verifyDerivatives(terms: LicenseTerms) { - if (!terms.derivativesAllowed) { - if (terms.derivativesAttribution) { - throw new Error("Cannot add derivative attribution when derivative use is disabled."); - } - if (terms.derivativesApproval) { - throw new Error("Cannot add derivative approval when derivative use is disabled."); - } - if (terms.derivativesReciprocal) { - throw new Error("Cannot add derivative reciprocal when derivative use is disabled."); - } - if (terms.derivativeRevCeiling > 0) { - throw new Error("Cannot add derivative revenue ceiling when derivative use is disabled."); - } - } - } } diff --git a/packages/core-sdk/src/resources/nftClient.ts b/packages/core-sdk/src/resources/nftClient.ts index 0d18a813..0cd7646e 100644 --- a/packages/core-sdk/src/resources/nftClient.ts +++ b/packages/core-sdk/src/resources/nftClient.ts @@ -1,6 +1,10 @@ import { PublicClient, isAddress, maxUint32, zeroAddress } from "viem"; -import { SimpleWalletClient, SpgClient } from "../abi/generated"; +import { + RegistrationWorkflowsClient, + RegistrationWorkflowsCreateCollectionRequest, + SimpleWalletClient, +} from "../abi/generated"; import { CreateNFTCollectionRequest, CreateNFTCollectionResponse, @@ -9,14 +13,14 @@ import { handleError } from "../utils/errors"; import { getAddress } from "../utils/utils"; export class NftClient { - public spgClient: SpgClient; + public registrationWorkflowsClient: RegistrationWorkflowsClient; private readonly rpcClient: PublicClient; private readonly wallet: SimpleWalletClient; constructor(rpcClient: PublicClient, wallet: SimpleWalletClient) { this.rpcClient = rpcClient; this.wallet = wallet; - this.spgClient = new SpgClient(rpcClient, wallet); + this.registrationWorkflowsClient = new RegistrationWorkflowsClient(rpcClient, wallet); } /** @@ -24,13 +28,18 @@ export class NftClient { * @param request - The request object containing necessary data to create a SPG NFT Collection. * @param request.name - The name of the collection. * @param request.symbol - The symbol of the collection. - * @param request.maxSupply - The maximum supply of the collection. - * @param request.mintFee - The cost to mint a token. - * @param request.mintFeeToken - The token to mint. - * @param request.owner - The owner of the collection. - * @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property. - * @returns A Promise that resolves to a CreateNFTCollectionResponse containing the transaction hash and collection address. - * @emits CollectionCreated (nftContract); + * @param request.isPublicMinting - If true, anyone can mint from the collection. If false, only the addresses with the minter role can mint. + * @param request.mintOpen Whether the collection is open for minting on creation. + * @param request.mintFeeRecipient - The address to receive mint fees. + * @param request.mintFeeRecipient - The contract URI for the collection. Follows ERC-7572 standard. See https://eips.ethereum.org/EIPS/eip-7572 + * @param request.baseURI - [Optional] The base URI for the collection. If baseURI is not empty, tokenURI will be either baseURI + token ID (if nftMetadataURI is empty) or baseURI + nftMetadataURI. + * @param request.maxSupply - [Optional] The maximum supply of the collection. + * @param request.mintFee - [Optional] The cost to mint a token. + * @param request.mintFeeToken - [Optional] The token to mint. + * @param request.owner - [Optional] The owner of the collection. + * @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 spg nft contract address. + * @emits CollectionCreated (spgNftContract); */ public async createNFTCollection( request: CreateNFTCollectionRequest, @@ -43,30 +52,40 @@ export class NftClient { throw new Error("Invalid mint fee token address, mint fee is greater than 0."); } - const req = { - name: request.name, - symbol: request.symbol, - maxSupply: request.maxSupply ?? Number(maxUint32), - mintFee: request.mintFee ?? 0n, - mintFeeToken: request.mintFeeToken ?? zeroAddress, - owner: - (request.owner && getAddress(request.owner, "request.owner")) || - this.wallet.account!.address, + const object: RegistrationWorkflowsCreateCollectionRequest = { + spgNftInitParams: { + name: request.name, + symbol: request.symbol, + baseURI: request.baseURI ?? "", + maxSupply: request.maxSupply ?? Number(maxUint32), + mintFee: request.mintFee ?? 0n, + mintFeeToken: request.mintFeeToken ?? zeroAddress, + owner: + (request.owner && getAddress(request.owner, "request.owner")) || + this.wallet.account!.address, + mintFeeRecipient: getAddress(request.mintFeeRecipient, "request.mintFeeRecipient"), + mintOpen: request.mintOpen, + isPublicMinting: request.isPublicMinting, + contractURI: request.contractURI, + }, }; if (request.txOptions?.encodedTxDataOnly) { - return { encodedTxData: this.spgClient.createCollectionEncode(req) }; + return { + encodedTxData: this.registrationWorkflowsClient.createCollectionEncode(object), + }; } else { - const txHash = await this.spgClient.createCollection(req); + const txHash = await this.registrationWorkflowsClient.createCollection(object); if (request.txOptions?.waitForTransaction) { const txReceipt = await this.rpcClient.waitForTransactionReceipt({ ...request.txOptions, hash: txHash, }); - const targetLogs = this.spgClient.parseTxCollectionCreatedEvent(txReceipt); + const targetLogs = + this.registrationWorkflowsClient.parseTxCollectionCreatedEvent(txReceipt); return { txHash: txHash, - nftContract: targetLogs[0].nftContract, + spgNftContract: targetLogs[0].spgNftContract, }; } return { txHash: txHash }; diff --git a/packages/core-sdk/src/resources/permission.ts b/packages/core-sdk/src/resources/permission.ts index c79b61d4..5f01e81f 100644 --- a/packages/core-sdk/src/resources/permission.ts +++ b/packages/core-sdk/src/resources/permission.ts @@ -16,7 +16,6 @@ import { IpAccountImplClient, IpAssetRegistryClient, SimpleWalletClient, - SpgClient, } from "../abi/generated"; import { chain, getAddress } from "../utils/utils"; import { SupportedChainIds } from "../types/config"; @@ -26,7 +25,6 @@ import { getDeadline, getPermissionSignature } from "../utils/sign"; export class PermissionClient { public accessControllerClient: AccessControllerClient; public ipAssetRegistryClient: IpAssetRegistryClient; - public spgClient: SpgClient; public coreMetadataModuleClient: CoreMetadataModuleClient; private readonly wallet: SimpleWalletClient; private readonly rpcClient: PublicClient; @@ -38,7 +36,6 @@ export class PermissionClient { this.chainId = chainId; this.accessControllerClient = new AccessControllerClient(this.rpcClient, this.wallet); this.ipAssetRegistryClient = new IpAssetRegistryClient(this.rpcClient, this.wallet); - this.spgClient = new SpgClient(this.rpcClient, this.wallet); this.coreMetadataModuleClient = new CoreMetadataModuleClient(this.rpcClient, this.wallet); } diff --git a/packages/core-sdk/src/resources/royalty.ts b/packages/core-sdk/src/resources/royalty.ts index 3c1fa78f..ac43df9d 100644 --- a/packages/core-sdk/src/resources/royalty.ts +++ b/packages/core-sdk/src/resources/royalty.ts @@ -4,20 +4,31 @@ import { handleError } from "../utils/errors"; import { ClaimableRevenueRequest, ClaimableRevenueResponse, - CollectRoyaltyTokensRequest, - CollectRoyaltyTokensResponse, PayRoyaltyOnBehalfRequest, PayRoyaltyOnBehalfResponse, SnapshotRequest, SnapshotResponse, + TransferToVaultAndSnapshotAndClaimByTokenBatchRequest, + TransferToVaultAndSnapshotAndClaimBySnapshotBatchRequest, + SnapshotAndClaimByTokenBatchRequest, + SnapshotAndClaimBySnapshotBatchRequest, ClaimRevenueRequest, ClaimRevenueResponse, + SnapshotAndClaimBySnapshotBatchResponse, + TransferToVaultAndSnapshotAndClaimBySnapshotBatchResponse, + TransferToVaultAndSnapshotAndClaimByTokenBatchResponse, + SnapshotAndClaimByTokenBatchResponse, } from "../types/resources/royalty"; import { IpAssetRegistryClient, IpRoyaltyVaultImplClient, + IpRoyaltyVaultImplEventClient, RoyaltyModuleClient, - RoyaltyPolicyLapClient, + RoyaltyWorkflowsClient, + RoyaltyWorkflowsSnapshotAndClaimBySnapshotBatchRequest, + RoyaltyWorkflowsSnapshotAndClaimByTokenBatchRequest, + RoyaltyWorkflowsTransferToVaultAndSnapshotAndClaimBySnapshotBatchRequest, + RoyaltyWorkflowsTransferToVaultAndSnapshotAndClaimByTokenBatchRequest, SimpleWalletClient, ipRoyaltyVaultImplAbi, } from "../abi/generated"; @@ -25,75 +36,26 @@ import { IPAccountClient } from "./ipAccount"; import { getAddress } from "../utils/utils"; export class RoyaltyClient { - public royaltyPolicyLapClient: RoyaltyPolicyLapClient; public royaltyModuleClient: RoyaltyModuleClient; public ipAssetRegistryClient: IpAssetRegistryClient; public ipAccountClient: IPAccountClient; + public royaltyWorkflowsClient: RoyaltyWorkflowsClient; + public ipRoyaltyVaultImplClient: IpRoyaltyVaultImplClient; + public ipRoyaltyVaultImplEventClient: IpRoyaltyVaultImplEventClient; private readonly rpcClient: PublicClient; private readonly wallet: SimpleWalletClient; constructor(rpcClient: PublicClient, wallet: SimpleWalletClient) { - this.royaltyPolicyLapClient = new RoyaltyPolicyLapClient(rpcClient, wallet); this.royaltyModuleClient = new RoyaltyModuleClient(rpcClient, wallet); this.ipAssetRegistryClient = new IpAssetRegistryClient(rpcClient, wallet); + this.royaltyWorkflowsClient = new RoyaltyWorkflowsClient(rpcClient, wallet); + this.ipRoyaltyVaultImplClient = new IpRoyaltyVaultImplClient(rpcClient, wallet); + this.ipRoyaltyVaultImplEventClient = new IpRoyaltyVaultImplEventClient(rpcClient); this.ipAccountClient = new IPAccountClient(rpcClient, wallet); this.rpcClient = rpcClient; this.wallet = wallet; } - /** - * Allows ancestors to claim the royalty tokens and any accrued revenue tokens - * @param request - The request object that contains all data needed to collect royalty tokens. - * @param request.parentIpId The ip id of the ancestor to whom the royalty tokens belong to. - * @param request.royaltyVaultIpId The id of the royalty vault. - * @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 the amount of royalty tokens collected if waitForTxn is set to true. - * @emits RoyaltyTokensCollected (ancestorIpId, royaltyTokensCollected) - */ - public async collectRoyaltyTokens( - request: CollectRoyaltyTokensRequest, - ): Promise { - try { - const isParentIpIdRegistered = await this.ipAssetRegistryClient.isRegistered({ - id: getAddress(request.parentIpId, "request.parentIpId"), - }); - if (!isParentIpIdRegistered) { - throw new Error(`The parent IP with id ${request.parentIpId} is not registered.`); - } - const proxyAddress = await this.getRoyaltyVaultAddress( - getAddress(request.royaltyVaultIpId, "request.royaltyVaultIpId"), - ); - const ipRoyaltyVault = new IpRoyaltyVaultImplClient( - this.rpcClient, - this.wallet, - proxyAddress, - ); - const req = { - ancestorIpId: request.parentIpId, - }; - if (request.txOptions?.encodedTxDataOnly) { - return { encodedTxData: ipRoyaltyVault.collectRoyaltyTokensEncode(req) }; - } else { - const txHash = await ipRoyaltyVault.collectRoyaltyTokens(req); - if (request.txOptions?.waitForTransaction) { - const txReceipt = await this.rpcClient.waitForTransactionReceipt({ - ...request.txOptions, - hash: txHash, - }); - const targetLogs = ipRoyaltyVault.parseTxRoyaltyTokensCollectedEvent(txReceipt); - return { - txHash: txHash, - royaltyTokensCollected: targetLogs[0].royaltyTokensCollected, - }; - } else { - return { txHash: txHash }; - } - } - } catch (error) { - handleError(error, "Failed to collect royalty tokens"); - } - } - /** * Allows the function caller to pay royalties to the receiver IP asset on behalf of the payer IP asset. * @param request - The request object that contains all data needed to pay royalty on behalf. @@ -178,7 +140,6 @@ export class RoyaltyClient { handleError(error, "Failed to calculate claimable revenue"); } } - /** * Allows token holders to claim by a list of snapshot ids based on the token balance at certain snapshot * @param request - The request object that contains all data needed to claim revenue. @@ -210,8 +171,8 @@ export class RoyaltyClient { txOptions: request.txOptions, data: encodeFunctionData({ abi: ipRoyaltyVaultImplAbi, - functionName: "claimRevenueBySnapshotBatch", - args: [request.snapshotIds, request.token], + functionName: "claimRevenueOnBehalfBySnapshotBatch", + args: [request.snapshotIds, request.token, this.wallet.account!.address], }), }); if (request.txOptions?.encodedTxDataOnly) { @@ -222,11 +183,12 @@ export class RoyaltyClient { const req = { snapshotIds: request.snapshotIds, token: getAddress(request.token, "request.token"), + claimer: this.wallet.account!.address, }; if (request.txOptions?.encodedTxDataOnly) { - return { encodedTxData: ipRoyaltyVault.claimRevenueBySnapshotBatchEncode(req) }; + return { encodedTxData: ipRoyaltyVault.claimRevenueOnBehalfBySnapshotBatchEncode(req) }; } else { - txHash = await ipRoyaltyVault.claimRevenueBySnapshotBatch(req); + txHash = await ipRoyaltyVault.claimRevenueOnBehalfBySnapshotBatch(req); } } if (request.txOptions?.waitForTransaction) { @@ -293,12 +255,281 @@ export class RoyaltyClient { if (!isRoyaltyVaultIpIdRegistered) { throw new Error(`The royalty vault IP with id ${royaltyVaultIpId} is not registered.`); } - const data = await this.royaltyPolicyLapClient.getRoyaltyData({ - ipId: royaltyVaultIpId, - }); - if (!data[1] || data[1] === "0x") { - throw new Error(`The royalty vault IP with id ${royaltyVaultIpId} address is not set.`); + return await this.royaltyModuleClient.ipRoyaltyVaults({ ipId: royaltyVaultIpId }); + } + /** + * Transfers royalties from royalty policy to the ancestor IP's royalty vault, takes a snapshot, and claims revenue on that snapshot for each specified currency token. + * @param request - The request object that contains all data needed to transfer to vault and snapshot and claim by token batch. + * @param request.ancestorIpId The address of the ancestor IP. + * @param request.royaltyClaimDetails The details of the royalty claim from child IPs + * @param request.royaltyClaimDetails - The details of the royalty claim from child IPs + * @param request.royaltyClaimDetails.childIpId The address of the child IP. + * @param request.royaltyClaimDetails.royaltyPolicy The address of the royalty policy. + * @param request.royaltyClaimDetails.currencyToken The address of the currency (revenue) token to claim. + * @param request.claimer [Optional] The address of the claimer of the revenue tokens (must be a royalty token holder), default value is wallet address. + * @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, or if waitForTransaction is true, includes snapshot ID and amounts claimed. + * @emits SnapshotCompleted (snapshotId, snapshotTimestamp, unclaimedTokens). + * @emits RevenueTokenClaimed (claimer, token, amount). + */ + public async transferToVaultAndSnapshotAndClaimByTokenBatch( + request: TransferToVaultAndSnapshotAndClaimByTokenBatchRequest, + ): Promise { + try { + if (request.royaltyClaimDetails.length === 0) { + throw new Error("The royaltyClaimDetails must provide at least one item."); + } + const isAncestorIpIdRegistered = await this.ipAssetRegistryClient.isRegistered({ + id: getAddress(request.ancestorIpId, "request.ancestorIpId"), + }); + if (!isAncestorIpIdRegistered) { + throw new Error(`The ancestor IP with id ${request.ancestorIpId} is not registered.`); + } + const object: RoyaltyWorkflowsTransferToVaultAndSnapshotAndClaimByTokenBatchRequest = { + ancestorIpId: getAddress(request.ancestorIpId, "request.ancestorIpId"), + royaltyClaimDetails: request.royaltyClaimDetails.map((item) => ({ + childIpId: getAddress(item.childIpId, "item.childIpId"), + royaltyPolicy: getAddress(item.royaltyPolicy, "item.royaltyPolicy"), + currencyToken: getAddress(item.currencyToken, "item.currencyToken"), + amount: BigInt(item.amount), + })), + claimer: + (request.claimer && getAddress(request.claimer, "request.claimer")) || + this.wallet.account!.address, + }; + if (request.txOptions?.encodedTxDataOnly) { + return { + encodedTxData: + this.royaltyWorkflowsClient.transferToVaultAndSnapshotAndClaimByTokenBatchEncode( + object, + ), + }; + } else { + const txHash = + await this.royaltyWorkflowsClient.transferToVaultAndSnapshotAndClaimByTokenBatch(object); + if (request.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ + ...request.txOptions, + hash: txHash, + }); + const revenueTokenClaimedLog = + this.ipRoyaltyVaultImplEventClient.parseTxRevenueTokenClaimedEvent(txReceipt); + const snapshotCompletedLog = + this.ipRoyaltyVaultImplEventClient.parseTxSnapshotCompletedEvent(txReceipt); + return { + txHash, + snapshotId: snapshotCompletedLog[0].snapshotId, + amountsClaimed: revenueTokenClaimedLog[0].amount, + }; + } else { + return { txHash }; + } + } + } catch (error) { + handleError(error, "Failed to transfer to vault and snapshot and claim by token batch"); + } + } + /** + * Transfers royalties to the ancestor IP's royalty vault, takes a snapshot, claims revenue for each + * specified currency token both on the new snapshot and on each specified unclaimed snapshots. + * @param request - The request object that contains all data needed to transfer to vault and snapshot and claim by snapshot batch. + * @param request.ancestorIpId The address of the ancestor IP. + * @param request.unclaimedSnapshotIds The IDs of unclaimed snapshots to include in the claim. + * @param request.royaltyClaimDetails The details of the royalty claim from child IPs + * @param request.royaltyClaimDetails - The details of the royalty claim from child IPs + * @param request.royaltyClaimDetails.childIpId The address of the child IP. + * @param request.royaltyClaimDetails.royaltyPolicy The address of the royalty policy. + * @param request.royaltyClaimDetails.currencyToken The address of the currency (revenue) token to claim. + * @param request.claimer [Optional] The address of the claimer of the revenue tokens (must be a royalty token holder), default value is wallet address. + * @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, or if waitForTransaction is true, includes snapshot ID and amounts claimed. + * @emits SnapshotCompleted (snapshotId, snapshotTimestamp, unclaimedTokens). + * @emits RevenueTokenClaimed (claimer, token, amount). + */ + public async transferToVaultAndSnapshotAndClaimBySnapshotBatch( + request: TransferToVaultAndSnapshotAndClaimBySnapshotBatchRequest, + ): Promise { + try { + if (request.royaltyClaimDetails.length === 0) { + throw new Error("The royaltyClaimDetails must provide at least one item."); + } + const isAncestorIpIdRegistered = await this.ipAssetRegistryClient.isRegistered({ + id: getAddress(request.ancestorIpId, "request.ancestorIpId"), + }); + if (!isAncestorIpIdRegistered) { + throw new Error(`The ancestor IP with id ${request.ancestorIpId} is not registered.`); + } + const object: RoyaltyWorkflowsTransferToVaultAndSnapshotAndClaimBySnapshotBatchRequest = { + ancestorIpId: getAddress(request.ancestorIpId, "request.ancestorIpId"), + royaltyClaimDetails: request.royaltyClaimDetails.map((item) => ({ + childIpId: getAddress(item.childIpId, "item.childIpId"), + royaltyPolicy: getAddress(item.royaltyPolicy, "item.royaltyPolicy"), + currencyToken: getAddress(item.currencyToken, "item.currencyToken"), + amount: BigInt(item.amount), + })), + claimer: + (request.claimer && getAddress(request.claimer, "request.claimer")) || + this.wallet.account!.address, + unclaimedSnapshotIds: request.unclaimedSnapshotIds.map((item) => BigInt(item)), + }; + if (request.txOptions?.encodedTxDataOnly) { + return { + encodedTxData: + this.royaltyWorkflowsClient.transferToVaultAndSnapshotAndClaimBySnapshotBatchEncode( + object, + ), + }; + } else { + const txHash = + await this.royaltyWorkflowsClient.transferToVaultAndSnapshotAndClaimBySnapshotBatch( + object, + ); + if (request.txOptions?.waitForTransaction) { + await this.rpcClient.waitForTransactionReceipt({ + ...request.txOptions, + hash: txHash, + }); + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ + ...request.txOptions, + hash: txHash, + }); + const revenueTokenClaimedLog = + this.ipRoyaltyVaultImplEventClient.parseTxRevenueTokenClaimedEvent(txReceipt); + const snapshotCompletedLog = + this.ipRoyaltyVaultImplEventClient.parseTxSnapshotCompletedEvent(txReceipt); + return { + txHash, + snapshotId: snapshotCompletedLog[0].snapshotId, + amountsClaimed: revenueTokenClaimedLog[0].amount, + }; + } else { + return { txHash }; + } + } + } catch (error) { + handleError(error, "Failed to transfer to vault and snapshot and claim by snapshot batch"); + } + } + /** + * Takes a snapshot of the IP's royalty vault and claims revenue on that snapshot for each + * @param request - The request object that contains all data needed to snapshot and claim by token batch. + * @param request.royaltyVaultIpId The address of the IP. + * @param request.currencyTokens The addresses of the currency (revenue) tokens to claim. + * @param request.claimer [Optional] The address of the claimer of the revenue tokens (must be a royalty token holder), default value is wallet address. + * @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, or if waitForTransaction is true, includes snapshot ID and amounts claimed. + * @emits SnapshotCompleted (snapshotId, snapshotTimestamp, unclaimedTokens). + * @emits RevenueTokenClaimed (claimer, token, amount). + */ + public async snapshotAndClaimByTokenBatch( + request: SnapshotAndClaimByTokenBatchRequest, + ): Promise { + try { + const isRegister = await this.ipAssetRegistryClient.isRegistered({ + id: getAddress(request.royaltyVaultIpId, "request.royaltyVaultIpId"), + }); + if (!isRegister) { + throw new Error( + `The royalty vault IP with id ${request.royaltyVaultIpId} is not registered.`, + ); + } + const object: RoyaltyWorkflowsSnapshotAndClaimByTokenBatchRequest = { + ipId: getAddress(request.royaltyVaultIpId, "request.ipId"), + currencyTokens: request.currencyTokens.map((item) => + getAddress(item, "item.currencyTokens"), + ), + claimer: + (request.claimer && getAddress(request.claimer, "request.claimer")) || + this.wallet.account!.address, + }; + if (request.txOptions?.encodedTxDataOnly) { + return { + encodedTxData: this.royaltyWorkflowsClient.snapshotAndClaimByTokenBatchEncode(object), + }; + } else { + const txHash = await this.royaltyWorkflowsClient.snapshotAndClaimByTokenBatch(object); + if (request.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ + ...request.txOptions, + hash: txHash, + }); + const revenueTokenClaimedLog = + this.ipRoyaltyVaultImplEventClient.parseTxRevenueTokenClaimedEvent(txReceipt); + const snapshotCompletedLog = + this.ipRoyaltyVaultImplEventClient.parseTxSnapshotCompletedEvent(txReceipt); + return { + txHash, + snapshotId: snapshotCompletedLog[0].snapshotId, + amountsClaimed: revenueTokenClaimedLog[0].amount, + }; + } else { + return { txHash }; + } + } + } catch (error) { + handleError(error, "Failed to snapshot and claim by token batch"); + } + } + /** + * Takes a snapshot of the IP's royalty vault and claims revenue for each specified currency token + * @param request - The request object that contains all data needed to snapshot and claim by snapshot batch. + * @param request.royaltyVaultIpId The address of the IP. + * @param request.unclaimedSnapshotIds The IDs of unclaimed snapshots to include in the claim. + * @param request.currencyTokens The addresses of the currency (revenue) tokens to claim. + * @param request.claimer [Optional] The address of the claimer of the revenue tokens (must be a royalty token holder), default value is wallet address. + * @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, or if waitForTransaction is true, includes snapshot ID and amounts claimed. + * @emits SnapshotCompleted (snapshotId, snapshotTimestamp, unclaimedTokens). + * @emits RevenueTokenClaimed (claimer, token, amount). + */ + public async snapshotAndClaimBySnapshotBatch( + request: SnapshotAndClaimBySnapshotBatchRequest, + ): Promise { + try { + const isRegister = await this.ipAssetRegistryClient.isRegistered({ + id: getAddress(request.royaltyVaultIpId, "request.royaltyVaultIpId"), + }); + if (!isRegister) { + throw new Error( + `The royalty vault IP with id ${request.royaltyVaultIpId} is not registered.`, + ); + } + const object: RoyaltyWorkflowsSnapshotAndClaimBySnapshotBatchRequest = { + ipId: request.royaltyVaultIpId, + claimer: + (request.claimer && getAddress(request.claimer, "request.claimer")) || + this.wallet.account!.address, + currencyTokens: request.currencyTokens.map((item) => + getAddress(item, "item.currencyTokens"), + ), + unclaimedSnapshotIds: request.unclaimedSnapshotIds.map((item) => BigInt(item)), + }; + if (request.txOptions?.encodedTxDataOnly) { + return { + encodedTxData: this.royaltyWorkflowsClient.snapshotAndClaimBySnapshotBatchEncode(object), + }; + } else { + const txHash = await this.royaltyWorkflowsClient.snapshotAndClaimBySnapshotBatch(object); + if (request.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ + ...request.txOptions, + hash: txHash, + }); + const revenueTokenClaimedLog = + this.ipRoyaltyVaultImplEventClient.parseTxRevenueTokenClaimedEvent(txReceipt); + const snapshotCompletedLog = + this.ipRoyaltyVaultImplEventClient.parseTxSnapshotCompletedEvent(txReceipt); + return { + txHash, + snapshotId: snapshotCompletedLog[0].snapshotId, + amountsClaimed: revenueTokenClaimedLog[0].amount, + }; + } else { + return { txHash }; + } + } + } catch (error) { + handleError(error, "Failed to snapshot and claim by snapshot batch"); } - return data[1]; } } diff --git a/packages/core-sdk/src/types/common.ts b/packages/core-sdk/src/types/common.ts index 5014ad6f..078e3d1e 100644 --- a/packages/core-sdk/src/types/common.ts +++ b/packages/core-sdk/src/types/common.ts @@ -1,20 +1,18 @@ -import { Address, Hex, WalletClient } from "viem"; +import { Hex } from "viem"; -import { SetPermissionsRequest } from "./resources/permission"; +import { TxOptions } from "./options"; export type TypedData = { - interface: string; // i.e. "(address,uint256)" + interface: string; data: unknown[]; }; -export type PermissionSignatureRequest = { - ipId: Address; - state: Hex; - deadline: string | number | bigint; - wallet: WalletClient; - chainId: string | number | bigint; - permissions: Omit[]; - permissionFunc?: "setPermission" | "setBatchPermissions"; +export type IpMetadataAndTxOption = { + ipMetadata?: { + ipMetadataURI?: string; + ipMetadataHash?: Hex; + nftMetadataURI?: string; + nftMetadataHash?: Hex; + }; + txOptions?: TxOptions; }; - -export type PermissionSignatureResponse = Hex; diff --git a/packages/core-sdk/src/types/resources/dispute.ts b/packages/core-sdk/src/types/resources/dispute.ts index f779d5fc..cd88b601 100644 --- a/packages/core-sdk/src/types/resources/dispute.ts +++ b/packages/core-sdk/src/types/resources/dispute.ts @@ -1,14 +1,13 @@ -import { Address } from "viem"; +import { Address, Hex } from "viem"; import { TxOptions } from "../options"; import { EncodedTxData } from "../../abi/generated"; export type RaiseDisputeRequest = { targetIpId: Address; - arbitrationPolicy: Address; - linkToDisputeEvidence: string; + disputeEvidenceHash: Hex; targetTag: string; - calldata?: Address; + data?: Address; txOptions?: TxOptions; }; @@ -20,7 +19,7 @@ export type RaiseDisputeResponse = { export type CancelDisputeRequest = { disputeId: number | string | bigint; - calldata?: Address; + data?: Address; txOptions?: TxOptions; }; diff --git a/packages/core-sdk/src/types/resources/group.ts b/packages/core-sdk/src/types/resources/group.ts new file mode 100644 index 00000000..a61b02e4 --- /dev/null +++ b/packages/core-sdk/src/types/resources/group.ts @@ -0,0 +1,73 @@ +import { Address } from "viem"; + +import { TxOptions } from "../options"; +import { EncodedTxData } from "../../abi/generated"; +import { IpMetadataAndTxOption } from "../common"; + +export type MintAndRegisterIpAndAttachLicenseAndAddToGroupRequest = { + spgNftContract: Address; + licenseTermsId: string | bigint | number; + groupId: Address; + recipient?: Address; + licenseTemplate?: Address; + deadline?: string | number | bigint; +} & IpMetadataAndTxOption; + +export type MintAndRegisterIpAndAttachLicenseAndAddToGroupResponse = { + txHash?: string; + encodedTxData?: EncodedTxData; + ipId?: Address; + tokenId?: bigint; +}; +export type RegisterGroupRequest = { + groupPool: Address; + txOptions?: TxOptions; +}; + +export type RegisterGroupResponse = { + txHash?: string; + encodedTxData?: EncodedTxData; + groupId?: Address; +}; + +export type RegisterIpAndAttachLicenseAndAddToGroupRequest = { + nftContract: Address; + tokenId: bigint | string | number; + groupId: Address; + licenseTermsId: bigint | string | number; + licenseTemplate?: Address; + deadline?: bigint; +} & IpMetadataAndTxOption; + +export type RegisterIpAndAttachLicenseAndAddToGroupResponse = { + txHash?: string; + encodedTxData?: EncodedTxData; + ipId?: Address; + tokenId?: bigint; +}; +export type RegisterGroupAndAttachLicenseRequest = { + groupPool: Address; + licenseTermsId: bigint | string | number; + licenseTemplate?: Address; + txOptions?: TxOptions; +}; + +export type RegisterGroupAndAttachLicenseResponse = { + txHash?: string; + encodedTxData?: EncodedTxData; + groupId?: Address; +}; + +export type RegisterGroupAndAttachLicenseAndAddIpsRequest = { + groupPool: Address; + ipIds: Address[]; + licenseTermsId: bigint | string | number; + licenseTemplate?: Address; + txOptions?: TxOptions; +}; + +export type RegisterGroupAndAttachLicenseAndAddIpsResponse = { + txHash?: string; + encodedTxData?: EncodedTxData; + groupId?: Address; +}; diff --git a/packages/core-sdk/src/types/resources/ipAsset.ts b/packages/core-sdk/src/types/resources/ipAsset.ts index 9acc7352..4b25b2d0 100644 --- a/packages/core-sdk/src/types/resources/ipAsset.ts +++ b/packages/core-sdk/src/types/resources/ipAsset.ts @@ -1,23 +1,15 @@ -import { Address, Hex } from "viem"; +import { Address } from "viem"; import { TxOptions } from "../options"; -import { PIL_TYPE } from "./license"; +import { PIL_TYPE, RegisterPILTermsRequest } from "./license"; import { EncodedTxData } from "../../abi/generated"; - -type IpMetadataAndTxOption = { - ipMetadata?: { - ipMetadataURI?: string; - ipMetadataHash?: Hex; - nftMetadataURI?: string; - nftMetadataHash?: Hex; - }; - txOptions?: TxOptions; -}; +import { IpMetadataAndTxOption } from "../common"; export type RegisterIpResponse = { txHash?: string; encodedTxData?: EncodedTxData; ipId?: Address; + tokenId?: bigint; }; export type RegisterRequest = { @@ -52,7 +44,7 @@ export type RegisterDerivativeResponse = { }; export type CreateIpAssetWithPilTermsRequest = { - nftContract: Address; + spgNftContract: Address; pilType: PIL_TYPE; currency?: Address; mintingFee?: string | number | bigint; @@ -103,7 +95,7 @@ export type RegisterIpAndAttachPilTermsResponse = { }; export type MintAndRegisterIpAndMakeDerivativeRequest = { - nftContract: Address; + spgNftContract: Address; derivData: { parentIpIds: Address[]; licenseTermsIds: string[] | bigint[] | number[]; @@ -194,3 +186,34 @@ export type IpMetadata = { robotTerms?: IPRobotTerms; [key: string]: unknown; }; + +export type MintAndRegisterIpRequest = { + spgNftContract: Address; + recipient?: Address; +} & IpMetadataAndTxOption; + +export type RegisterPilTermsAndAttachRequest = { + ipId: Address; + terms: RegisterPILTermsRequest; + deadline?: string | number | bigint; + txOptions?: TxOptions; +}; + +export type RegisterPilTermsAndAttachResponse = { + txHash?: string; + encodedTxData?: EncodedTxData; + licenseTermsId?: bigint; +}; + +export type MintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest = { + spgNftContract: Address; + licenseTokenIds: string[] | bigint[] | number[]; + recipient?: Address; +} & IpMetadataAndTxOption; + +export type RegisterIpAndMakeDerivativeWithLicenseTokensRequest = { + nftContract: Address; + tokenId: string | number | bigint; + licenseTokenIds: string[] | bigint[] | number[]; + deadline?: string | number | bigint; +} & IpMetadataAndTxOption; diff --git a/packages/core-sdk/src/types/resources/nftClient.ts b/packages/core-sdk/src/types/resources/nftClient.ts index 880295d0..b06165c3 100644 --- a/packages/core-sdk/src/types/resources/nftClient.ts +++ b/packages/core-sdk/src/types/resources/nftClient.ts @@ -1,4 +1,4 @@ -import { Hex } from "viem"; +import { Address, Hex } from "viem"; import { TxOptions } from "../options"; import { EncodedTxData } from "../../abi/generated"; @@ -6,6 +6,11 @@ import { EncodedTxData } from "../../abi/generated"; export type CreateNFTCollectionRequest = { name: string; symbol: string; + isPublicMinting: boolean; + mintOpen: boolean; + mintFeeRecipient: Address; + contractURI: string; + baseURI?: string; maxSupply?: number; mintFee?: bigint; mintFeeToken?: Hex; @@ -16,5 +21,5 @@ export type CreateNFTCollectionRequest = { export type CreateNFTCollectionResponse = { txHash?: string; encodedTxData?: EncodedTxData; - nftContract?: Hex; + spgNftContract?: Address; }; diff --git a/packages/core-sdk/src/types/resources/permission.ts b/packages/core-sdk/src/types/resources/permission.ts index 2767c6f6..474dab78 100644 --- a/packages/core-sdk/src/types/resources/permission.ts +++ b/packages/core-sdk/src/types/resources/permission.ts @@ -1,4 +1,4 @@ -import { Address } from "viem"; +import { Address, Hex, WalletClient } from "viem"; import { TxOptions } from "../options"; import { EncodedTxData } from "../../abi/generated"; @@ -50,3 +50,15 @@ export type CreateBatchPermissionSignatureRequest = { ipId: Address; deadline?: bigint | number | string; } & SetBatchPermissionsRequest; + +export type PermissionSignatureRequest = { + ipId: Address; + state: Hex; + deadline: string | number | bigint; + wallet: WalletClient; + chainId: string | number | bigint; + permissions: Omit[]; + permissionFunc?: "setPermission" | "setBatchPermissions"; +}; + +export type PermissionSignatureResponse = Hex; diff --git a/packages/core-sdk/src/types/resources/royalty.ts b/packages/core-sdk/src/types/resources/royalty.ts index ae03166b..e762b25c 100644 --- a/packages/core-sdk/src/types/resources/royalty.ts +++ b/packages/core-sdk/src/types/resources/royalty.ts @@ -22,18 +22,6 @@ export type RoyaltyContext = { parentAncestorsRoyalties2: number[]; }; -export type CollectRoyaltyTokensRequest = { - parentIpId: Address; - royaltyVaultIpId: Address; - txOptions?: TxOptions; -}; - -export type CollectRoyaltyTokensResponse = { - txHash?: string; - encodedTxData?: EncodedTxData; - royaltyTokensCollected?: bigint; -}; - export type RoyaltyData = [ isUnlinkableToParents: boolean, ipRoyaltyVault: Address, @@ -82,9 +70,65 @@ export type ClaimRevenueResponse = { encodedTxData?: EncodedTxData; claimableToken?: bigint; }; - export type SnapshotResponse = { txHash?: string; encodedTxData?: EncodedTxData; snapshotId?: bigint; }; +type RoyaltyClaimDetail = { + childIpId: Address; + royaltyPolicy: Address; + currencyToken: Address; + amount: bigint | string | number; +}; +export type TransferToVaultAndSnapshotAndClaimByTokenBatchRequest = { + ancestorIpId: Address; + royaltyClaimDetails: RoyaltyClaimDetail[]; + claimer?: Address; + txOptions?: TxOptions; +}; +export type TransferToVaultAndSnapshotAndClaimByTokenBatchResponse = { + txHash?: string; + encodedTxData?: EncodedTxData; + snapshotId?: bigint; + amountsClaimed?: bigint; +}; +export type TransferToVaultAndSnapshotAndClaimBySnapshotBatchRequest = { + ancestorIpId: Address; + unclaimedSnapshotIds: bigint[] | number[] | string[]; + claimer?: Address; + royaltyClaimDetails: RoyaltyClaimDetail[]; + txOptions?: TxOptions; +}; +export type TransferToVaultAndSnapshotAndClaimBySnapshotBatchResponse = { + txHash?: string; + encodedTxData?: EncodedTxData; + snapshotId?: bigint; + amountsClaimed?: bigint; +}; +export type SnapshotAndClaimByTokenBatchRequest = { + royaltyVaultIpId: Address; + currencyTokens: Address[]; + claimer?: Address; + txOptions?: TxOptions; +}; +export type SnapshotAndClaimByTokenBatchResponse = { + txHash?: string; + encodedTxData?: EncodedTxData; + snapshotId?: bigint; + amountsClaimed?: bigint; +}; +export type SnapshotAndClaimBySnapshotBatchRequest = { + royaltyVaultIpId: Address; + unclaimedSnapshotIds: bigint[] | number[] | string[]; + currencyTokens: Address[]; + claimer?: Address; + txOptions?: TxOptions; +}; + +export type SnapshotAndClaimBySnapshotBatchResponse = { + txHash?: string; + encodedTxData?: EncodedTxData; + snapshotId?: bigint; + amountsClaimed?: bigint; +}; diff --git a/packages/core-sdk/src/utils/getLicenseTermsByType.ts b/packages/core-sdk/src/utils/getLicenseTermsByType.ts deleted file mode 100644 index 9f14e657..00000000 --- a/packages/core-sdk/src/utils/getLicenseTermsByType.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { Hex, getAddress, zeroAddress } from "viem"; - -import { PIL_TYPE, LicenseTerms } from "../types/resources/license"; - -export function getLicenseTermByType( - type: PIL_TYPE, - term?: { - defaultMintingFee?: string | number | bigint; - currency?: Hex; - royaltyPolicyLAPAddress: Hex; - commercialRevShare?: number; - }, -): LicenseTerms { - const licenseTerms: LicenseTerms = { - transferable: true, - royaltyPolicy: zeroAddress, - defaultMintingFee: BigInt(0), - expiration: BigInt(0), - commercialUse: false, - commercialAttribution: false, - commercializerChecker: zeroAddress, - commercializerCheckerData: zeroAddress, - commercialRevShare: 0, - commercialRevCeiling: BigInt(0), - derivativesAllowed: true, - derivativesAttribution: true, - derivativesApproval: false, - derivativesReciprocal: true, - derivativeRevCeiling: BigInt(0), - currency: zeroAddress, - uri: "", - }; - if (type === PIL_TYPE.NON_COMMERCIAL_REMIX) { - licenseTerms.commercializerCheckerData = "0x"; - return licenseTerms; - } else if (type === PIL_TYPE.COMMERCIAL_USE) { - if (!term || term.defaultMintingFee === undefined || term.currency === undefined) { - throw new Error("MintingFee currency are required for commercial use PIL."); - } - licenseTerms.royaltyPolicy = getAddress(term.royaltyPolicyLAPAddress); - licenseTerms.defaultMintingFee = BigInt(term.defaultMintingFee); - licenseTerms.commercialUse = true; - licenseTerms.commercialAttribution = true; - licenseTerms.derivativesReciprocal = false; - licenseTerms.currency = getAddress(term.currency); - return licenseTerms; - } else { - if ( - !term || - term.defaultMintingFee === undefined || - term.currency === undefined || - term.commercialRevShare === undefined - ) { - throw new Error( - "MintingFee, currency and commercialRevShare are required for commercial remix PIL.", - ); - } - if (term.commercialRevShare < 0 || term.commercialRevShare > 100) { - throw new Error("CommercialRevShare should be between 0 and 100."); - } - licenseTerms.royaltyPolicy = getAddress(term.royaltyPolicyLAPAddress); - licenseTerms.defaultMintingFee = BigInt(term.defaultMintingFee); - licenseTerms.commercialUse = true; - licenseTerms.commercialAttribution = true; - - licenseTerms.commercialRevShare = (term.commercialRevShare / 100) * 100000000; - licenseTerms.derivativesReciprocal = true; - licenseTerms.currency = getAddress(term.currency); - return licenseTerms; - } -} diff --git a/packages/core-sdk/src/utils/licenseTermsHelper.ts b/packages/core-sdk/src/utils/licenseTermsHelper.ts new file mode 100644 index 00000000..f81f3aeb --- /dev/null +++ b/packages/core-sdk/src/utils/licenseTermsHelper.ts @@ -0,0 +1,166 @@ +import { Hex, PublicClient, zeroAddress } from "viem"; + +import { PIL_TYPE, LicenseTerms, RegisterPILTermsRequest } from "../types/resources/license"; +import { getAddress } from "./utils"; +import { RoyaltyModuleReadOnlyClient } from "../abi/generated"; + +export function getLicenseTermByType( + type: PIL_TYPE, + term?: { + defaultMintingFee?: string | number | bigint; + currency?: Hex; + royaltyPolicyLAPAddress: Hex; + commercialRevShare?: number; + }, +): LicenseTerms { + const licenseTerms: LicenseTerms = { + transferable: true, + royaltyPolicy: zeroAddress, + defaultMintingFee: BigInt(0), + expiration: BigInt(0), + commercialUse: false, + commercialAttribution: false, + commercializerChecker: zeroAddress, + commercializerCheckerData: zeroAddress, + commercialRevShare: 0, + commercialRevCeiling: BigInt(0), + derivativesAllowed: true, + derivativesAttribution: true, + derivativesApproval: false, + derivativesReciprocal: true, + derivativeRevCeiling: BigInt(0), + currency: zeroAddress, + uri: "", + }; + if (type === PIL_TYPE.NON_COMMERCIAL_REMIX) { + licenseTerms.commercializerCheckerData = "0x"; + return licenseTerms; + } else if (type === PIL_TYPE.COMMERCIAL_USE) { + if (!term || term.defaultMintingFee === undefined || term.currency === undefined) { + throw new Error("DefaultMintingFee, currency are required for commercial use PIL."); + } + licenseTerms.royaltyPolicy = getAddress( + term.royaltyPolicyLAPAddress, + "term.royaltyPolicyLAPAddress", + ); + licenseTerms.defaultMintingFee = BigInt(term.defaultMintingFee); + licenseTerms.commercialUse = true; + licenseTerms.commercialAttribution = true; + licenseTerms.derivativesReciprocal = false; + licenseTerms.currency = getAddress(term.currency, "term.currency"); + return licenseTerms; + } else { + if ( + !term || + term.defaultMintingFee === undefined || + term.currency === undefined || + term.commercialRevShare === undefined + ) { + throw new Error( + "DefaultMintingFee, currency and commercialRevShare are required for commercial remix PIL.", + ); + } + if (term.commercialRevShare < 0 || term.commercialRevShare > 100) { + throw new Error("CommercialRevShare should be between 0 and 100."); + } + licenseTerms.royaltyPolicy = getAddress( + term.royaltyPolicyLAPAddress, + "term.royaltyPolicyLAPAddress", + ); + licenseTerms.defaultMintingFee = BigInt(term.defaultMintingFee); + licenseTerms.commercialUse = true; + licenseTerms.commercialAttribution = true; + + licenseTerms.commercialRevShare = (term.commercialRevShare / 100) * 100000000; + licenseTerms.derivativesReciprocal = true; + licenseTerms.currency = getAddress(term.currency, "term.currency"); + return licenseTerms; + } +} + +export async function validateLicenseTerms( + params: RegisterPILTermsRequest, + rpcClient: PublicClient, +): Promise { + const { royaltyPolicy, currency } = params; + const royaltyModuleReadOnlyClient = new RoyaltyModuleReadOnlyClient(rpcClient); + if (getAddress(royaltyPolicy, "params.royaltyPolicy") !== zeroAddress) { + const isWhitelistedArbitrationPolicy = + await royaltyModuleReadOnlyClient.isWhitelistedRoyaltyPolicy({ royaltyPolicy }); + if (!isWhitelistedArbitrationPolicy) { + throw new Error("The royalty policy is not whitelisted."); + } + } + if (getAddress(currency, "params.currency") !== zeroAddress) { + const isWhitelistedRoyaltyToken = await royaltyModuleReadOnlyClient.isWhitelistedRoyaltyToken({ + token: currency, + }); + if (!isWhitelistedRoyaltyToken) { + throw new Error("The currency token is not whitelisted."); + } + } + if (royaltyPolicy !== zeroAddress && currency === zeroAddress) { + throw new Error("Royalty policy requires currency token."); + } + const object = { + ...params, + defaultMintingFee: BigInt(params.defaultMintingFee), + expiration: BigInt(params.expiration), + commercialRevCeiling: BigInt(params.commercialRevCeiling), + derivativeRevCeiling: BigInt(params.derivativeRevCeiling), + }; + verifyCommercialUse(object); + verifyDerivatives(object); + if (object.commercialRevShare < 0 || object.commercialRevShare > 100) { + throw new Error("CommercialRevShare should be between 0 and 100."); + } else { + object.commercialRevShare = (object.commercialRevShare / 100) * 100000000; + } + return object; +} + +const verifyCommercialUse = (terms: LicenseTerms) => { + if (!terms.commercialUse) { + if (terms.commercialAttribution) { + throw new Error("Cannot add commercial attribution when commercial use is disabled."); + } + if (terms.commercializerChecker !== zeroAddress) { + throw new Error("Cannot add commercializerChecker when commercial use is disabled."); + } + if (terms.commercialRevShare > 0) { + throw new Error("Cannot add commercial revenue share when commercial use is disabled."); + } + if (terms.commercialRevCeiling > 0) { + throw new Error("Cannot add commercial revenue ceiling when commercial use is disabled."); + } + if (terms.derivativeRevCeiling > 0) { + throw new Error( + "Cannot add derivative revenue ceiling share when commercial use is disabled.", + ); + } + if (terms.royaltyPolicy !== zeroAddress) { + throw new Error("Cannot add commercial royalty policy when commercial use is disabled."); + } + } else { + if (terms.royaltyPolicy === zeroAddress) { + throw new Error("Royalty policy is required when commercial use is enabled."); + } + } +}; + +const verifyDerivatives = (terms: LicenseTerms) => { + if (!terms.derivativesAllowed) { + if (terms.derivativesAttribution) { + throw new Error("Cannot add derivative attribution when derivative use is disabled."); + } + if (terms.derivativesApproval) { + throw new Error("Cannot add derivative approval when derivative use is disabled."); + } + if (terms.derivativesReciprocal) { + throw new Error("Cannot add derivative reciprocal when derivative use is disabled."); + } + if (terms.derivativeRevCeiling > 0) { + throw new Error("Cannot add derivative revenue ceiling when derivative use is disabled."); + } + } +}; diff --git a/packages/core-sdk/src/utils/sign.ts b/packages/core-sdk/src/utils/sign.ts index 6eae23c8..9662b042 100644 --- a/packages/core-sdk/src/utils/sign.ts +++ b/packages/core-sdk/src/utils/sign.ts @@ -3,7 +3,10 @@ import { encodeAbiParameters, encodeFunctionData, keccak256, toFunctionSelector import { accessControllerAbi, accessControllerAddress, ipAccountImplAbi } from "../abi/generated"; import { getAddress } from "./utils"; import { defaultFunctionSelector } from "../constants/common"; -import { PermissionSignatureRequest, PermissionSignatureResponse } from "../types/common"; +import { + PermissionSignatureRequest, + PermissionSignatureResponse, +} from "../types/resources/permission"; /** * Get the signature for setting permissions. @@ -68,6 +71,7 @@ export const getPermissionSignature = async ( ], ), ); + return await wallet.signTypedData({ account: wallet.account, domain: { diff --git a/packages/core-sdk/test/integration/dispute.test.ts b/packages/core-sdk/test/integration/dispute.test.ts index 131dcbab..72fb322d 100644 --- a/packages/core-sdk/test/integration/dispute.test.ts +++ b/packages/core-sdk/test/integration/dispute.test.ts @@ -1,16 +1,17 @@ import chai from "chai"; import { StoryClient } from "../../src"; import { CancelDisputeRequest, RaiseDisputeRequest } from "../../src/index"; -import { mockERC721, getStoryClient, getTokenId } from "./utils/util"; +import { mockERC721, getStoryClient, getTokenId, iliadChainId } 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; - -const arbitrationPolicyAddress = "0xcaEC2bD1B1fD57bC47357F688f97d57387E68E25"; -describe("Dispute Functions", () => { +//Because of IPFS issue, so currently we can't test this function +const arbitrationPolicyAddress = arbitrationPolicySpAddress[iliadChainId]; +describe.skip("Dispute Functions", () => { let clientA: StoryClient; let clientB: StoryClient; let disputeId: bigint; @@ -37,8 +38,7 @@ describe("Dispute Functions", () => { it("should not throw error when raise a dispute", async () => { const raiseDisputeRequest: RaiseDisputeRequest = { targetIpId: ipIdB, - arbitrationPolicy: arbitrationPolicyAddress, - linkToDisputeEvidence: "foo", + disputeEvidenceHash: "0xb7b94ecbd1f9f8cb209909e5785fb2858c9a8c4b220c017995a75346ad1b5db5", targetTag: "PLAGIARISM", txOptions: { waitForTransaction: true, diff --git a/packages/core-sdk/test/integration/group.test.ts b/packages/core-sdk/test/integration/group.test.ts new file mode 100644 index 00000000..edbbfe79 --- /dev/null +++ b/packages/core-sdk/test/integration/group.test.ts @@ -0,0 +1,111 @@ +import chai from "chai"; +import chaiAsPromised from "chai-as-promised"; +import { Address } from "viem"; +import { getStoryClient, iliadChainId, 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]; + +chai.use(chaiAsPromised); +const expect = chai.expect; +describe("Group Functions", () => { + let groupId: Address = "0xd275eCFe9b4754Ed7D80a6d667E15Ef5bb6F68e8"; + let client: StoryClient; + let spgNftContract: Address; + let licenseTermsId: bigint; + let ipId: Address; + before(async () => { + client = getStoryClient(); + spgNftContract = ( + await client.nftClient.createNFTCollection({ + name: "test-collection", + symbol: "TEST", + maxSupply: 100, + isPublicMinting: true, + mintOpen: true, + mintFeeRecipient: process.env.TEST_WALLET_ADDRESS! as Address, + contractURI: "test-uri", + txOptions: { + waitForTransaction: true, + }, + }) + ).spgNftContract!; + const result = await client.ipAsset.mintAndRegisterIpAssetWithPilTerms({ + spgNftContract: spgNftContract, + pilType: PIL_TYPE.COMMERCIAL_USE, + commercialRevShare: 10, + mintingFee: "0", + currency: MockERC20.address, + txOptions: { + waitForTransaction: true, + }, + }); + licenseTermsId = result.licenseTermsId!; + ipId = result.ipId!; + }); + + it("should success when register group", async () => { + const result = await client.groupClient.registerGroup({ + groupPool: groupPoolAddress, + txOptions: { + waitForTransaction: true, + }, + }); + groupId = result.groupId!; + expect(result.txHash).to.be.a("string").and.not.empty; + expect(result.groupId).to.be.a("string").and.not.empty; + }); + it("should success when mint and register ip and attach license and add to group", async () => { + const result = await client.groupClient.mintAndRegisterIpAndAttachLicenseAndAddToGroup({ + groupId, + spgNftContract: spgNftContract, + licenseTermsId: licenseTermsId!, + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).to.be.a("string").and.not.empty; + expect(result.ipId).to.be.a("string").and.not.empty; + }); + it("should success when register ip and attach license and add to group", async () => { + const tokenId = await mintBySpg(spgNftContract, "test-metadata"); + const result = await client.groupClient.registerIpAndAttachLicenseAndAddToGroup({ + groupId, + nftContract: spgNftContract, + tokenId: tokenId!, + licenseTermsId: licenseTermsId!, + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).to.be.a("string").and.not.empty; + expect(result.ipId).to.be.a("string").and.not.empty; + }); + + it("should success when register group and attach license", async () => { + const result = await client.groupClient.registerGroupAndAttachLicense({ + groupPool: groupPoolAddress, + licenseTermsId: licenseTermsId!, + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).to.be.a("string").and.not.empty; + expect(result.groupId).to.be.a("string").and.not.empty; + }); + + it("should success when register group and attach license and add ips", async () => { + const result = await client.groupClient.registerGroupAndAttachLicenseAndAddIps({ + groupPool: groupPoolAddress, + ipIds: [ipId], + licenseTermsId: licenseTermsId!, + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).to.be.a("string").and.not.empty; + expect(result.groupId).to.be.a("string").and.not.empty; + }); +}); diff --git a/packages/core-sdk/test/integration/ipAsset.test.ts b/packages/core-sdk/test/integration/ipAsset.test.ts index f20d4aba..37bc350d 100644 --- a/packages/core-sdk/test/integration/ipAsset.test.ts +++ b/packages/core-sdk/test/integration/ipAsset.test.ts @@ -1,33 +1,38 @@ import chai from "chai"; import { StoryClient, PIL_TYPE } from "../../src"; -import { Hex, toHex } from "viem"; +import { Address, Hex, toHex, zeroAddress } from "viem"; import chaiAsPromised from "chai-as-promised"; -import { mockERC721, getStoryClient, getTokenId, mintBySpg, iliadChainId } from "./utils/util"; +import { + mockERC721, + getStoryClient, + getTokenId, + mintBySpg, + iliadChainId, + approveForLicenseToken, +} from "./utils/util"; import { MockERC20 } from "./utils/mockERC20"; -import { spgAddress } from "../../src/abi/generated"; +import { derivativeWorkflowsAddress, spgnftImplAddress } from "../../src/abi/generated"; chai.use(chaiAsPromised); const expect = chai.expect; describe("IP Asset Functions ", () => { let client: StoryClient; + let noCommercialLicenseTermsId: bigint; before(async () => { client = getStoryClient(); + const res = await client.license.registerNonComSocialRemixingPIL({ + txOptions: { + waitForTransaction: true, + }, + }); + noCommercialLicenseTermsId = res.licenseTermsId!; }); describe("Create IP Asset", async () => { let parentIpId: Hex; let childIpId: Hex; - let noCommercialLicenseTermsId: bigint; - before(async () => { - const res = await client.license.registerNonComSocialRemixingPIL({ - txOptions: { - waitForTransaction: true, - }, - }); - noCommercialLicenseTermsId = res.licenseTermsId!; - }); - it("should not throw error when registering a IP Asset", async () => { + it("should not throw error when register a IP Asset", async () => { const tokenId = await getTokenId(); const waitForTransaction: boolean = true; const response = await expect( @@ -45,7 +50,7 @@ describe("IP Asset Functions ", () => { } }); - it("should not throw error when registering derivative", async () => { + it("should not throw error when register derivative", async () => { const tokenId = await getTokenId(); parentIpId = ( await client.ipAsset.register({ @@ -74,7 +79,7 @@ describe("IP Asset Functions ", () => { expect(response.txHash).to.be.a("string").and.not.empty; }); - it("should not throw error when registering derivative with license tokens", async () => { + it("should not throw error when register derivative with license tokens", async () => { const tokenId = await getTokenId(); const ipId = ( await client.ipAsset.register({ @@ -107,22 +112,27 @@ 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({ name: "test-collection", symbol: "TEST", maxSupply: 100, + isPublicMinting: true, + mintOpen: true, + contractURI: "test-uri", + mintFeeRecipient: process.env.TEST_WALLET_ADDRESS! as Address, txOptions: { waitForTransaction: true, }, }); - expect(txData.nftContract).to.be.a("string").and.not.empty; - nftContract = txData.nftContract!; - const mockERC20 = new MockERC20(); - await mockERC20.approve(spgAddress[iliadChainId as keyof typeof spgAddress]); + expect(txData.spgNftContract).to.be.a("string").and.not.empty; + nftContract = txData.spgNftContract!; + const result = await client.ipAsset.mintAndRegisterIpAssetWithPilTerms({ - nftContract, + spgNftContract: nftContract, pilType: PIL_TYPE.COMMERCIAL_REMIX, commercialRevShare: 10, mintingFee: "100", @@ -138,7 +148,7 @@ describe("IP Asset Functions ", () => { describe("should not throw error when mint and register ip and attach pil terms", async () => { it("Non-Commercial Remix", async () => { const result = await client.ipAsset.mintAndRegisterIpAssetWithPilTerms({ - nftContract, + spgNftContract: nftContract, pilType: PIL_TYPE.NON_COMMERCIAL_REMIX, ipMetadata: { ipMetadataURI: "test-uri", @@ -152,7 +162,7 @@ describe("IP Asset Functions ", () => { }); it("Commercial Use", async () => { const result = await client.ipAsset.mintAndRegisterIpAssetWithPilTerms({ - nftContract, + spgNftContract: nftContract, pilType: PIL_TYPE.COMMERCIAL_USE, commercialRevShare: 10, mintingFee: "100", @@ -171,7 +181,7 @@ describe("IP Asset Functions ", () => { it("Commercial Remix", async () => { const result = await client.ipAsset.mintAndRegisterIpAssetWithPilTerms({ - nftContract, + spgNftContract: nftContract, pilType: PIL_TYPE.COMMERCIAL_REMIX, commercialRevShare: 10, mintingFee: "100", @@ -189,7 +199,7 @@ describe("IP Asset Functions ", () => { }); it("should get the related log when createIpAssetWithPilTerms given waitForTransaction is true ", async () => { const result = await client.ipAsset.mintAndRegisterIpAssetWithPilTerms({ - nftContract, + spgNftContract: nftContract, pilType: PIL_TYPE.COMMERCIAL_REMIX, commercialRevShare: 10, mintingFee: "100", @@ -204,7 +214,7 @@ describe("IP Asset Functions ", () => { expect(result.licenseTermsId).to.be.a("bigint"); }); }); - it("should not throw error when registering a IP Asset given metadata", async () => { + it("should not throw error when register a IP Asset given metadata", async () => { const tokenId = await mintBySpg(nftContract, "test-metadata"); const response = await client.ipAsset.register({ nftContract, @@ -221,7 +231,7 @@ describe("IP Asset Functions ", () => { }); expect(response.ipId).to.be.a("string").and.not.empty; }); - it("should not throw error when register registerDerivativeIp", async () => { + it("should not throw error when register derivative ip", async () => { const tokenChildId = await mintBySpg(nftContract, "test-metadata"); const result = await client.ipAsset.registerDerivativeIp({ nftContract: nftContract, @@ -239,7 +249,7 @@ describe("IP Asset Functions ", () => { expect(result.ipId).to.be.a("string").and.not.empty; }); - it("should not throw error when register registerIpAndAttachPilTerms", async () => { + it("should not throw error when register ip and attach pil terms", async () => { const tokenId = await mintBySpg(nftContract, "test-metadata"); const deadline = 1000n; const result = await client.ipAsset.registerIpAndAttachPilTerms({ @@ -258,9 +268,9 @@ describe("IP Asset Functions ", () => { expect(result.licenseTermsId).to.be.a("bigint"); }); - it("should not throw error when call mintAndRegisterIpAndMakeDerivative", async () => { + it("should not throw error when mint and register ip and make derivative", async () => { const result = await client.ipAsset.mintAndRegisterIpAndMakeDerivative({ - nftContract: nftContract, + spgNftContract: nftContract, derivData: { parentIpIds: [parentIpId!], licenseTermsIds: [licenseTermsId!], @@ -272,5 +282,121 @@ describe("IP Asset Functions ", () => { expect(result.txHash).to.be.a("string").and.not.empty; expect(result.childIpId).to.be.a("string").and.not.empty; }); + + it("should not throw error when mint and register ip", async () => { + const result = await client.ipAsset.mintAndRegisterIp({ + spgNftContract: nftContract, + ipMetadata: { + ipMetadataURI: "test-uri", + ipMetadataHash: toHex("test-metadata-hash", { size: 32 }), + nftMetadataHash: toHex("test-nft-metadata-hash", { size: 32 }), + }, + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).to.be.a("string").and.not.empty; + expect(result.ipId).to.be.a("string").and.not.empty; + }); + it("should not throw error when call register pil terms and attach", async () => { + const tokenId = await getTokenId(); + const ipId = ( + await client.ipAsset.register({ + nftContract: mockERC721, + tokenId: tokenId!, + txOptions: { + waitForTransaction: true, + }, + }) + ).ipId!; + const result = await client.ipAsset.registerPilTermsAndAttach({ + ipId: parentIpId, + terms: { + transferable: true, + royaltyPolicy: zeroAddress, + defaultMintingFee: BigInt(1), + expiration: BigInt(0), + commercialUse: false, + commercialAttribution: false, + commercializerChecker: zeroAddress, + commercializerCheckerData: zeroAddress, + commercialRevShare: 0, + commercialRevCeiling: BigInt(0), + derivativesAllowed: true, + derivativesAttribution: true, + derivativesApproval: false, + derivativesReciprocal: true, + derivativeRevCeiling: BigInt(0), + currency: MockERC20.address, + uri: "", + }, + deadline: 1000n, + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).to.be.a("string").and.not.empty; + }); + + 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, + txOptions: { + waitForTransaction: true, + }, + }); + await approveForLicenseToken( + derivativeWorkflowsAddress[iliadChainId], + mintLicenseTokensResult.licenseTokenIds![0], + ); + const result = await client.ipAsset.mintAndRegisterIpAndMakeDerivativeWithLicenseTokens({ + spgNftContract: nftContract, + licenseTokenIds: [mintLicenseTokensResult.licenseTokenIds![0]], + ipMetadata: { + ipMetadataURI: "test-uri", + ipMetadataHash: toHex("test-metadata-hash", { size: 32 }), + nftMetadataHash: toHex("test-nft-metadata-hash", { size: 32 }), + }, + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).to.be.a("string").and.not.empty; + expect(result.ipId).to.be.a("string").and.not.empty; + expect(result.tokenId).to.be.a("bigint"); + }); + + it("should not throw error when call register ip and make derivative with license tokens", async () => { + const tokenId = await mintBySpg(nftContract, "test-metadata"); + const mintLicenseTokensResult = await client.license.mintLicenseTokens({ + licenseTermsId: noCommercialLicenseTermsId, + licensorIpId: parentIpId, + txOptions: { + waitForTransaction: true, + }, + }); + await approveForLicenseToken( + derivativeWorkflowsAddress[iliadChainId], + mintLicenseTokensResult.licenseTokenIds![0], + ); + const result = await client.ipAsset.registerIpAndMakeDerivativeWithLicenseTokens({ + nftContract: nftContract, + tokenId: tokenId!, + licenseTokenIds: [mintLicenseTokensResult.licenseTokenIds![0]], + ipMetadata: { + ipMetadataURI: "test-uri", + ipMetadataHash: toHex("test-metadata-hash", { size: 32 }), + nftMetadataHash: toHex("test-nft-metadata-hash", { size: 32 }), + }, + deadline: 1000n, + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).to.be.a("string").and.not.empty; + expect(result.ipId).to.be.a("string").and.not.empty; + }); }); }); diff --git a/packages/core-sdk/test/integration/license.test.ts b/packages/core-sdk/test/integration/license.test.ts index e10ef3c7..f2d00331 100644 --- a/packages/core-sdk/test/integration/license.test.ts +++ b/packages/core-sdk/test/integration/license.test.ts @@ -15,8 +15,8 @@ describe("License Functions", () => { before(() => { client = getStoryClient(); }); - describe("registering license with different types", async () => { - it("should not throw error when registering license ", async () => { + describe("register license with different types", async () => { + it("should not throw error when register license ", async () => { const result = await client.license.registerPILTerms({ defaultMintingFee: "1", currency: MockERC20.address, @@ -41,7 +41,7 @@ describe("License Functions", () => { }); expect(result.licenseTermsId).to.be.a("bigint"); }); - it("should not throw error when registering license with non commercial social remixing PIL", async () => { + it("should not throw error when register license with non commercial social remixing PIL", async () => { const result = await client.license.registerNonComSocialRemixingPIL({ txOptions: { waitForTransaction: true, @@ -49,7 +49,7 @@ describe("License Functions", () => { }); expect(result.licenseTermsId).to.be.a("bigint"); }); - it("should not throw error when registering license with commercial use", async () => { + it("should not throw error when register license with commercial use", async () => { const result = await client.license.registerCommercialUsePIL({ defaultMintingFee: "1", currency: MockERC20.address, @@ -60,7 +60,7 @@ describe("License Functions", () => { expect(result.licenseTermsId).to.be.a("bigint"); }); - it("should not throw error when registering license with commercial Remix use", async () => { + it("should not throw error when register license with commercial Remix use", async () => { const result = await client.license.registerCommercialRemixPIL({ defaultMintingFee: "1", commercialRevShare: 100, @@ -113,7 +113,7 @@ describe("License Functions", () => { expect(result.txHash).to.be.a("string").and.not.empty; }); - it("should not throw error when minting license tokens", async () => { + it("should not throw error when mint license tokens", async () => { const result = await client.license.mintLicenseTokens({ licenseTermsId: licenseId, licensorIpId: ipId, diff --git a/packages/core-sdk/test/integration/nftClient.test.ts b/packages/core-sdk/test/integration/nftClient.test.ts index 15289986..c443b468 100644 --- a/packages/core-sdk/test/integration/nftClient.test.ts +++ b/packages/core-sdk/test/integration/nftClient.test.ts @@ -1,6 +1,7 @@ import { expect } from "chai"; import { StoryClient } from "../../src"; import { getStoryClient } from "./utils/util"; +import { Address } from "viem"; describe("nftClient Functions", () => { let client: StoryClient; @@ -12,10 +13,14 @@ describe("nftClient Functions", () => { name: "test-collection", symbol: "TEST", maxSupply: 100, + isPublicMinting: true, + mintFeeRecipient: process.env.TEST_WALLET_ADDRESS as Address, + mintOpen: true, + contractURI: "test-uri", txOptions: { waitForTransaction: true, }, }); - expect(txData.nftContract).to.be.a("string").and.not.empty; + expect(txData.spgNftContract).to.be.a("string").and.not.empty; }); }); diff --git a/packages/core-sdk/test/integration/permission.test.ts b/packages/core-sdk/test/integration/permission.test.ts index 95a29dc8..3aa99cf6 100644 --- a/packages/core-sdk/test/integration/permission.test.ts +++ b/packages/core-sdk/test/integration/permission.test.ts @@ -26,7 +26,7 @@ describe("Permission Functions", () => { }) ).ipId!; }); - it("should not throw error when call setPermission", async () => { + it("should not throw error when set permission", async () => { const response = await client.permission.setPermission({ ipId: ipId, signer: process.env.TEST_WALLET_ADDRESS as Address, @@ -40,7 +40,7 @@ describe("Permission Functions", () => { expect(response.success).to.be.a("boolean").and.to.equal(true); }); - it("should not throw error when call setAllPermissions", async () => { + it("should not throw error when set all permissions", async () => { const response = await client.permission.setAllPermissions({ ipId: ipId, signer: process.env.TEST_WALLET_ADDRESS as Address, @@ -54,7 +54,7 @@ describe("Permission Functions", () => { expect(response.success).to.be.a("boolean").and.to.equal(true); }); - it("should not throw error when call createSetPermissionSignature", async () => { + it("should not throw error when create set permission signature", async () => { const response = await client.permission.createSetPermissionSignature({ ipId, signer: process.env.TEST_WALLET_ADDRESS as Address, @@ -71,7 +71,7 @@ describe("Permission Functions", () => { expect(response.success).to.be.a("boolean").and.to.equal(true); }); - it("should not throw error when call setBatchPermissions", async () => { + it("should not throw error when set batch permissions", async () => { const response = await client.permission.setBatchPermissions({ permissions: [ { @@ -98,7 +98,7 @@ describe("Permission Functions", () => { expect(response.success).to.be.a("boolean").and.to.equal(true); }); - it("should not throw error when call createBatchPermissionSignature", async () => { + it("should not throw error when create batch permission signature", async () => { const response = await client.permission.createBatchPermissionSignature({ ipId: ipId, permissions: [ diff --git a/packages/core-sdk/test/integration/royalty.test.ts b/packages/core-sdk/test/integration/royalty.test.ts index e8fc72d7..5f0835ef 100644 --- a/packages/core-sdk/test/integration/royalty.test.ts +++ b/packages/core-sdk/test/integration/royalty.test.ts @@ -1,6 +1,6 @@ import chai from "chai"; import { StoryClient } from "../../src"; -import { Hex, encodeFunctionData } from "viem"; +import { Address, Hex, encodeFunctionData } from "viem"; import chaiAsPromised from "chai-as-promised"; import { mockERC721, getTokenId, getStoryClient, iliadChainId } from "./utils/util"; import { MockERC20 } from "./utils/mockERC20"; @@ -12,12 +12,14 @@ let snapshotId: bigint; describe("Test royalty Functions", () => { let client: StoryClient; - before(() => { + before(async () => { client = getStoryClient(); }); describe("Royalty Functions", async () => { - let ipId1: Hex; - let ipId2: Hex; + let parentIpId: Hex; + let childIpId: Hex; + let licenseTermsId: bigint; + let parentIpIdRoyaltyAddress: Address; const getIpId = async (): Promise => { const tokenId = await getTokenId(); const response = await client.ipAsset.register({ @@ -31,9 +33,9 @@ describe("Test royalty Functions", () => { }; const getCommercialPolicyId = async (): Promise => { const response = await client.license.registerCommercialRemixPIL({ - defaultMintingFee: "1", + defaultMintingFee: "100000", currency: MockERC20.address, - commercialRevShare: 100, + commercialRevShare: 10, txOptions: { waitForTransaction: true, }, @@ -51,53 +53,81 @@ describe("Test royalty Functions", () => { }); }; - before(async () => { - ipId1 = await getIpId(); - ipId2 = await getIpId(); - const licenseTermsId = await getCommercialPolicyId(); - await attachLicenseTerms(ipId1, licenseTermsId); - const mockERC20 = new MockERC20(); - await mockERC20.approve( - royaltyPolicyLapAddress[Number(iliadChainId) as keyof typeof royaltyPolicyLapAddress], - ); - await client.ipAsset.registerDerivative({ - childIpId: ipId2, - parentIpIds: [ipId1], - licenseTermsIds: [licenseTermsId], + const transferToken = async () => { + parentIpIdRoyaltyAddress = await client.royalty.getRoyaltyVaultAddress(parentIpId); + //transfer revenue token to eoa + await client.ipAccount.execute({ + to: parentIpIdRoyaltyAddress, + value: 0, + ipId: parentIpId, txOptions: { waitForTransaction: true, }, + data: encodeFunctionData({ + abi: [ + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + ], + functionName: "transfer", + args: [process.env.TEST_WALLET_ADDRESS as Hex, BigInt(10 * 10 ** 6)], + }), }); - }); - - it("should not throw error when collect royalty tokens", async () => { - const response = await client.royalty.collectRoyaltyTokens({ - parentIpId: ipId1, - royaltyVaultIpId: ipId2, + }; + before(async () => { + parentIpId = await getIpId(); + childIpId = await getIpId(); + licenseTermsId = await getCommercialPolicyId(); + await attachLicenseTerms(parentIpId, licenseTermsId); + const mockERC20 = new MockERC20(); + await mockERC20.approve(client.royalty.royaltyModuleClient.address); + await client.ipAsset.registerDerivative({ + childIpId: childIpId, + parentIpIds: [parentIpId], + licenseTermsIds: [licenseTermsId], txOptions: { waitForTransaction: true, }, }); - expect(response.txHash).to.be.a("string").not.empty; - expect(response.royaltyTokensCollected).to.be.a("bigint"); + await transferToken(); }); it("should not throw error when pay royalty on behalf", async () => { const response = await client.royalty.payRoyaltyOnBehalf({ - receiverIpId: ipId1, - payerIpId: ipId2, + receiverIpId: parentIpId, + payerIpId: childIpId, token: MockERC20.address, - amount: "10", + amount: 10 * 10 ** 2, txOptions: { waitForTransaction: true, }, }); expect(response.txHash).to.be.a("string").not.empty; }); - // Because of the snapshot interval is long, so we can't get the snapshotId in the same test case. Let's skip the related test case. - it.skip("should not throw error when snapshot", async () => { + it("should not throw error when snapshot", async () => { const response = await client.royalty.snapshot({ - royaltyVaultIpId: ipId1, + royaltyVaultIpId: parentIpId, txOptions: { waitForTransaction: true, }, @@ -106,21 +136,20 @@ describe("Test royalty Functions", () => { expect(response.snapshotId).to.be.a("bigint"); snapshotId = response.snapshotId!; }); - it.skip("should not throw error when claimable revenue", async () => { + it("should not throw error when claimable revenue", async () => { const response = await client.royalty.claimableRevenue({ - royaltyVaultIpId: ipId1, - account: ipId1, + royaltyVaultIpId: parentIpId, + account: parentIpId, snapshotId: snapshotId.toString(), token: MockERC20.address, }); expect(response).to.be.a("bigint"); }); - - it.skip("should not throw error when claim revenue by ipAccount", async () => { + it("should not throw error when claim revenue by ipAccount", async () => { const response = await client.royalty.claimRevenue({ - royaltyVaultIpId: ipId1, + royaltyVaultIpId: parentIpId, snapshotIds: [snapshotId.toString()], - account: ipId1, + account: parentIpId, token: MockERC20.address, txOptions: { waitForTransaction: true, @@ -129,64 +158,22 @@ describe("Test royalty Functions", () => { expect(response.claimableToken).to.be.a("bigint"); }); - it.skip("should not throw error when claim revenue by ipAccount by EOA", async () => { - const proxyAddress = await client.royalty.getRoyaltyVaultAddress(ipId1); - //1.transfer token to eoa - await client.ipAccount.execute({ - to: proxyAddress, - value: 0, - ipId: ipId1, - txOptions: { - waitForTransaction: true, - }, - data: encodeFunctionData({ - abi: [ - { - inputs: [ - { - internalType: "address", - name: "to", - type: "address", - }, - { - internalType: "uint256", - name: "value", - type: "uint256", - }, - ], - name: "transfer", - outputs: [ - { - internalType: "bool", - name: "", - type: "bool", - }, - ], - stateMutability: "nonpayable", - type: "function", - }, - ], - functionName: "transfer", - args: [process.env.TEST_WALLET_ADDRESS as Hex, BigInt(10 * 10 ** 6)], - }), - }); - //2. transfer token to royaltyVault,revenue token + it("should not throw error when claim revenue by ipAccount by EOA", async () => { await client.royalty.payRoyaltyOnBehalf({ - receiverIpId: ipId1, - payerIpId: ipId2, + receiverIpId: parentIpId, + payerIpId: childIpId, token: MockERC20.address, - amount: "10", + amount: 10 * 10 ** 2, txOptions: { waitForTransaction: true, }, }); const snapshotId = await client.royalty.snapshot({ - royaltyVaultIpId: ipId1, + royaltyVaultIpId: parentIpId, txOptions: { waitForTransaction: true }, }); - const response = await client.royalty.claimRevenue({ - royaltyVaultIpId: ipId1, + royaltyVaultIpId: parentIpId, snapshotIds: [snapshotId.snapshotId!], token: MockERC20.address, txOptions: { @@ -195,5 +182,165 @@ describe("Test royalty Functions", () => { }); expect(response.claimableToken).to.be.a("bigint"); }); + describe("royalty workflow", async () => { + it("should not throw error when snapshot and claim by token batch", async () => { + await client.royalty.payRoyaltyOnBehalf({ + receiverIpId: parentIpId, + payerIpId: childIpId, + token: MockERC20.address, + amount: 10, + txOptions: { + waitForTransaction: true, + }, + }); + const response = await client.royalty.snapshotAndClaimByTokenBatch({ + royaltyVaultIpId: parentIpId, + currencyTokens: [MockERC20.address], + txOptions: { + waitForTransaction: true, + }, + }); + expect(response.txHash).to.be.a("string").not.empty; + expect(response.snapshotId).to.be.a("bigint"); + expect(response.amountsClaimed).to.be.a("bigint"); + }); + + it("should not throw error when snapshot and claim by snapshot batch", async () => { + await transferToken(); + await client.royalty.payRoyaltyOnBehalf({ + receiverIpId: parentIpId, + payerIpId: childIpId, + token: MockERC20.address, + amount: 10, + txOptions: { + waitForTransaction: true, + }, + }); + const { snapshotId } = await client.royalty.snapshot({ + royaltyVaultIpId: parentIpId, + txOptions: { + waitForTransaction: true, + }, + }); + await client.royalty.payRoyaltyOnBehalf({ + receiverIpId: parentIpId, + payerIpId: childIpId, + token: MockERC20.address, + amount: 10, + txOptions: { + waitForTransaction: true, + }, + }); + const response = await client.royalty.snapshotAndClaimBySnapshotBatch({ + royaltyVaultIpId: parentIpId, + unclaimedSnapshotIds: [snapshotId!], + currencyTokens: [MockERC20.address], + txOptions: { + waitForTransaction: true, + }, + }); + expect(response.txHash).to.be.a("string").not.empty; + expect(response.snapshotId).to.be.a("bigint"); + expect(response.amountsClaimed).to.be.a("bigint"); + }); + it("should not throw error when transfer to vault and snapshot and claim by snapshot batch", async () => { + // // await transferToken(); + // //revenue token + await client.royalty.payRoyaltyOnBehalf({ + receiverIpId: parentIpId, + payerIpId: childIpId, + token: MockERC20.address, + amount: 100000, + txOptions: { + waitForTransaction: true, + }, + }); + const { snapshotId } = await client.royalty.snapshot({ + royaltyVaultIpId: parentIpId, + txOptions: { + waitForTransaction: true, + }, + }); + // await client.royalty.payRoyaltyOnBehalf({ + // receiverIpId: parentIpId, + // payerIpId: childIpId, + // token: MockERC20.address, + // amount: 100000, + // txOptions: { + // waitForTransaction: true, + // }, + // }); + + const child2IpId = await getIpId(); + await client.ipAsset.registerDerivative({ + childIpId: child2IpId, + parentIpIds: [childIpId], + licenseTermsIds: [licenseTermsId], + txOptions: { + waitForTransaction: true, + }, + }); + await client.license.mintLicenseTokens({ + licenseTermsId: licenseTermsId, + licensorIpId: parentIpId, + txOptions: { + waitForTransaction: true, + }, + }); + const response = await client.royalty.transferToVaultAndSnapshotAndClaimBySnapshotBatch({ + ancestorIpId: parentIpId, + royaltyClaimDetails: [ + { + childIpId: childIpId, + royaltyPolicy: royaltyPolicyLapAddress[iliadChainId], + currencyToken: MockERC20.address, + amount: BigInt(1), + }, + ], + unclaimedSnapshotIds: [snapshotId!], + txOptions: { + waitForTransaction: true, + }, + }); + expect(response.txHash).to.be.a("string").not.empty; + expect(response.snapshotId).to.be.a("bigint"); + expect(response.amountsClaimed).to.be.a("bigint"); + }); + it("should not throw error when transfer to vault and snapshot and claim by token batch", async () => { + const child2IpId = await getIpId(); + await client.ipAsset.registerDerivative({ + childIpId: child2IpId, + parentIpIds: [childIpId], + licenseTermsIds: [licenseTermsId], + txOptions: { + waitForTransaction: true, + }, + }); + await client.license.mintLicenseTokens({ + licenseTermsId: licenseTermsId, + licensorIpId: parentIpId, + txOptions: { + waitForTransaction: true, + }, + }); + const response = await client.royalty.transferToVaultAndSnapshotAndClaimByTokenBatch({ + ancestorIpId: parentIpId, + royaltyClaimDetails: [ + { + childIpId: childIpId, + royaltyPolicy: royaltyPolicyLapAddress[iliadChainId], + currencyToken: MockERC20.address, + amount: BigInt(1), + }, + ], + txOptions: { + waitForTransaction: true, + }, + }); + expect(response.txHash).to.be.a("string").not.empty; + expect(response.snapshotId).to.be.a("bigint"); + expect(response.amountsClaimed).to.be.a("bigint"); + }); + }); }); }); diff --git a/packages/core-sdk/test/integration/utils/mockERC20.ts b/packages/core-sdk/test/integration/utils/mockERC20.ts index e61f832f..c0a3d896 100644 --- a/packages/core-sdk/test/integration/utils/mockERC20.ts +++ b/packages/core-sdk/test/integration/utils/mockERC20.ts @@ -9,12 +9,13 @@ import { } from "viem"; import { privateKeyToAccount } from "viem/accounts"; import { chainStringToViemChain, waitTx } from "../../../src/utils/utils"; -import { RPC } from "./util"; +import { RPC, iliadChainId } from "./util"; +import { mockErc20Address } from "../../../src/abi/generated"; export class MockERC20 { private publicClient: PublicClient; private walletClient: WalletClient; - static address: Hex = "0x91f6F05B08c16769d3c85867548615d270C42fC7"; + static address: Hex = mockErc20Address[iliadChainId]; constructor() { const baseConfig = { diff --git a/packages/core-sdk/test/integration/utils/util.ts b/packages/core-sdk/test/integration/utils/util.ts index ba831a49..f6c7a68e 100644 --- a/packages/core-sdk/test/integration/utils/util.ts +++ b/packages/core-sdk/test/integration/utils/util.ts @@ -1,12 +1,18 @@ import { privateKeyToAccount } from "viem/accounts"; -import { chainStringToViemChain } from "../../../src/utils/utils"; +import { chainStringToViemChain, waitTx } from "../../../src/utils/utils"; import { http, createPublicClient, createWalletClient, Hex, Address } from "viem"; import { StoryClient, StoryConfig } from "../../../src"; -import { spgnftBeaconAddress } from "../../../src/abi/generated"; -export const RPC = "https://testnet.storyrpc.io"; +import { + licenseTokenAbi, + licenseTokenAddress, + spgnftBeaconAddress, +} from "../../../src/abi/generated"; +export const RPC = "https://story-testnet.aura.network"; export const iliadChainId = 1513; export const mockERC721 = "0x322813fd9a801c5507c9de605d63cea4f2ce6c44"; +export const licenseToken = + licenseTokenAddress[Number(iliadChainId) as keyof typeof licenseTokenAddress]; export const spgNftBeacon = spgnftBeaconAddress[Number(iliadChainId) as keyof typeof spgnftBeaconAddress]; @@ -85,6 +91,18 @@ export const mintBySpg = async (nftContract: Hex, nftMetadata: string) => { return parseInt(logs[0].topics[3], 16); } }; + +export const approveForLicenseToken = async (address: Address, tokenId: bigint) => { + const { request: call } = await publicClient.simulateContract({ + abi: licenseTokenAbi, + address: licenseToken, + functionName: "approve", + account: walletClient.account, + args: [address, tokenId], + }); + const hash = await walletClient.writeContract(call); + await waitTx(publicClient, hash); +}; export const getStoryClient = (): StoryClient => { const config: StoryConfig = { chainId: "iliad", diff --git a/packages/core-sdk/test/unit/client.test.ts b/packages/core-sdk/test/unit/client.test.ts index bbeb7ed9..e933bd26 100644 --- a/packages/core-sdk/test/unit/client.test.ts +++ b/packages/core-sdk/test/unit/client.test.ts @@ -83,6 +83,7 @@ describe("Test StoryClient", () => { expect(client.dispute).to.not.equal(null).and.to.not.equal(undefined); expect(client.royalty).to.not.equal(null).and.to.not.equal(undefined); expect(client.nftClient).to.not.equal(null).and.to.not.equal(undefined); + expect(client.groupClient).to.not.equal(null).and.to.not.equal(undefined); }); }); }); diff --git a/packages/core-sdk/test/unit/resources/dispute.test.ts b/packages/core-sdk/test/unit/resources/dispute.test.ts index a28b60c1..23ec9274 100644 --- a/packages/core-sdk/test/unit/resources/dispute.test.ts +++ b/packages/core-sdk/test/unit/resources/dispute.test.ts @@ -6,14 +6,13 @@ import { PublicClient, WalletClient } from "viem"; import { DisputeClient } from "../../../src"; chai.use(chaiAsPromised); +const txHash = "0x063834efe214f4199b1ad7181ce8c5ced3e15d271c8e866da7c89e86ee629cfb"; describe("Test DisputeClient", () => { let disputeClient: DisputeClient; let rpcMock: PublicClient; let walletMock: WalletClient; - const txHash = "0x063834efe214f4199b1ad7181ce8c5ced3e15d271c8e866da7c89e86ee629cfb"; - beforeEach(() => { rpcMock = createMock(); walletMock = createMock(); @@ -29,8 +28,7 @@ describe("Test DisputeClient", () => { try { await disputeClient.raiseDispute({ targetIpId: "0x", - arbitrationPolicy: "0x", - linkToDisputeEvidence: "link", + disputeEvidenceHash: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", targetTag: "tag", }); } catch (e) { @@ -44,8 +42,7 @@ describe("Test DisputeClient", () => { sinon.stub(disputeClient.disputeModuleClient, "raiseDispute").resolves(txHash); const result = await disputeClient.raiseDispute({ targetIpId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", - arbitrationPolicy: "0x", - linkToDisputeEvidence: "link", + disputeEvidenceHash: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", targetTag: "tag", }); @@ -60,15 +57,14 @@ describe("Test DisputeClient", () => { targetIpId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", disputeInitiator: "0x", arbitrationPolicy: "0x", - linkToDisputeEvidence: "0x", + disputeEvidenceHash: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", targetTag: "0x", data: "0x", }, ]); const result = await disputeClient.raiseDispute({ targetIpId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", - arbitrationPolicy: "0x", - linkToDisputeEvidence: "link", + disputeEvidenceHash: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", targetTag: "tag", txOptions: { waitForTransaction: true }, }); @@ -76,6 +72,17 @@ describe("Test DisputeClient", () => { expect(result.txHash).equal(txHash); expect(result.disputeId).equal(1n); }); + + it("should return encodedTxData when call raiseDispute successfully with encodedTxDataOnly", async () => { + const result = await disputeClient.raiseDispute({ + targetIpId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + disputeEvidenceHash: "0xb7b94ecbd1f9f8cb209909e5785fb2858c9a8c4b220c017995a75346ad1b5db5", + targetTag: "tag", + txOptions: { encodedTxDataOnly: true }, + }); + + expect(result.encodedTxData?.data).to.be.a("string").and.not.empty; + }); }); describe("Test cancelDispute", () => { @@ -94,7 +101,7 @@ describe("Test DisputeClient", () => { sinon.stub(disputeClient.disputeModuleClient, "cancelDispute").resolves(txHash); const result = await disputeClient.cancelDispute({ disputeId: 1, - calldata: "0x", + data: "0x", }); expect(result.txHash).equal(txHash); @@ -109,6 +116,15 @@ describe("Test DisputeClient", () => { expect(result.txHash).equal(txHash); }); + + it("should return encodedTxData when call cancelDispute successfully with encodedTxDataOnly", async () => { + const result = await disputeClient.cancelDispute({ + disputeId: 1, + txOptions: { encodedTxDataOnly: true }, + }); + + expect(result.encodedTxData?.data).to.be.a("string").and.not.empty; + }); }); describe("Test resolveDispute", () => { @@ -144,5 +160,15 @@ describe("Test DisputeClient", () => { expect(result.txHash).equal(txHash); }); + + it("should return encodedTxData when call resolveDispute successfully with encodedTxDataOnly", async () => { + const result = await disputeClient.resolveDispute({ + disputeId: 1, + data: "0x", + txOptions: { encodedTxDataOnly: true }, + }); + + expect(result.encodedTxData?.data).to.be.a("string").and.not.empty; + }); }); }); diff --git a/packages/core-sdk/test/unit/resources/group.test.ts b/packages/core-sdk/test/unit/resources/group.test.ts new file mode 100644 index 00000000..8f80f58a --- /dev/null +++ b/packages/core-sdk/test/unit/resources/group.test.ts @@ -0,0 +1,455 @@ +import chai from "chai"; +import { createMock } from "../testUtils"; +import * as sinon from "sinon"; +import { PublicClient, WalletClient, Account } from "viem"; +import chaiAsPromised from "chai-as-promised"; +import { GroupClient } from "../../../src"; +const { IpAccountImplClient } = require("../../../src/abi/generated"); + +chai.use(chaiAsPromised); +const expect = chai.expect; +const txHash = "0x2e778894d11b5308e4153f094e190496c1e0609652c19f8b87e5176484b9a56e"; +describe("Test IpAssetClient", () => { + let groupClient: GroupClient; + let rpcMock: PublicClient; + let walletMock: WalletClient; + + beforeEach(() => { + rpcMock = createMock(); + walletMock = createMock(); + const accountMock = createMock(); + walletMock.account = accountMock; + walletMock.signTypedData = sinon + .stub() + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + groupClient = new GroupClient(rpcMock, walletMock, "1513"); + (groupClient.groupingWorkflowsClient as any).address = + "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; + (groupClient.groupingModuleClient as any).address = + "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; + (groupClient.coreMetadataModuleClient as any).address = + "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; + (groupClient.licensingModuleClient as any).address = + "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; + sinon + .stub(IpAccountImplClient.prototype, "state") + .resolves({ result: "0x2e778894d11b5308e4153f094e190496c1e0609652c19f8b87e5176484b9a56e" }); + }); + + afterEach(() => { + sinon.restore(); + }); + describe("Test groupClient.registerGroup", async () => { + it("should throw groupPool address is invalid error when groupPool is invalid", async () => { + try { + await groupClient.registerGroup({ + groupPool: "0x123", + }); + } catch (err) { + expect((err as Error).message).equal( + "Failed to register group: request.groupPool address is invalid: 0x123, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.", + ); + } + }); + + it("should return txHash when call registerGroup successfully", async () => { + sinon.stub(groupClient.groupingModuleClient, "registerGroup").resolves(txHash); + const result = await groupClient.registerGroup({ + groupPool: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }); + expect(result.txHash).equal(txHash); + }); + + it("should return txHash when call registerGroup successfully with waitForTransaction of true", async () => { + sinon.stub(groupClient.groupingModuleClient, "registerGroup").resolves(txHash); + sinon.stub(groupClient.groupingModuleEventClient, "parseTxIpGroupRegisteredEvent").returns([ + { + groupId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + groupPool: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }, + ]); + const result = await groupClient.registerGroup({ + groupPool: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).equal(txHash); + }); + + it("should return encodedData when call registerGroup successfully with encodedTxDataOnly of true", async () => { + const result = await groupClient.registerGroup({ + groupPool: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + txOptions: { + encodedTxDataOnly: true, + }, + }); + expect(result.encodedTxData!.data).to.be.a("string").and.not.empty; + }); + }); + describe("Test groupClient.registerGroupAndAttachLicense", async () => { + it("should throw licenseTemplate error when call registerGroupAndAttachLicense given licenseTemplate is invalid", async () => { + try { + await groupClient.registerGroupAndAttachLicense({ + groupPool: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + licenseTermsId: "0x123", + licenseTemplate: "0x123", + }); + } catch (err) { + expect((err as Error).message).equal( + "Failed to register group and attach license: request.licenseTemplate address is invalid: 0x123, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.", + ); + } + }); + it("should return txHash when call registerGroupAndAttachLicense successfully", async () => { + sinon + .stub(groupClient.groupingWorkflowsClient, "registerGroupAndAttachLicense") + .resolves(txHash); + const result = await groupClient.registerGroupAndAttachLicense({ + groupPool: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + licenseTermsId: "100", + }); + expect(result.txHash).equal(txHash); + }); + + it("should return txHash when call registerGroupAndAttachLicense successfully with waitForTransaction of true", async () => { + sinon + .stub(groupClient.groupingWorkflowsClient, "registerGroupAndAttachLicense") + .resolves(txHash); + sinon.stub(groupClient.groupingModuleEventClient, "parseTxIpGroupRegisteredEvent").returns([ + { + groupId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + groupPool: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }, + ]); + const result = await groupClient.registerGroupAndAttachLicense({ + groupPool: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + licenseTermsId: "100", + licenseTemplate: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).equal(txHash); + expect(result.groupId).equal("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); + }); + + it("should return encodedData when call registerGroupAndAttachLicense successfully with encodedTxDataOnly of true", async () => { + const result = await groupClient.registerGroupAndAttachLicense({ + groupPool: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + licenseTermsId: "100", + licenseTemplate: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + txOptions: { + encodedTxDataOnly: true, + }, + }); + expect(result.encodedTxData!.data).to.be.a("string").and.not.empty; + }); + }); + describe("Test groupClient.registerGroupAndAttachLicenseAndAddIps", async () => { + it("should throw group id register error when call registerGroupAndAttachLicenseAndAddIps given ip id is not registered", async () => { + try { + sinon + .stub(groupClient.licenseRegistryReadOnlyClient, "hasIpAttachedLicenseTerms") + .resolves(true); + sinon.stub(groupClient.ipAssetRegistryClient, "isRegistered").resolves(false); + await groupClient.registerGroupAndAttachLicenseAndAddIps({ + groupPool: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + ipIds: ["0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"], + licenseTermsId: "100", + licenseTemplate: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }); + } catch (err) { + expect((err as Error).message).equal( + "Failed to register group and attach license and add ips: IP 0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c is not registered.", + ); + } + }); + it("should throw not attach between license terms and ip id when call registerGroupAndAttachLicenseAndAddIps given ipIds is not attach license terms", async () => { + try { + sinon + .stub(groupClient.licenseRegistryReadOnlyClient, "hasIpAttachedLicenseTerms") + .resolves(false); + sinon.stub(groupClient.ipAssetRegistryClient, "isRegistered").resolves(true); + await groupClient.registerGroupAndAttachLicenseAndAddIps({ + groupPool: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + ipIds: ["0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"], + licenseTermsId: "100", + licenseTemplate: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }); + } catch (err) { + expect((err as Error).message).equal( + "Failed to register group and attach license and add ips: License terms must be attached to IP 0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c before adding to group.", + ); + } + }); + + it("should return encodedData when call registerGroupAndAttachLicenseAndAddIps successfully with encodedTxDataOnly of true", async () => { + sinon + .stub(groupClient.licenseRegistryReadOnlyClient, "hasIpAttachedLicenseTerms") + .resolves(true); + sinon.stub(groupClient.ipAssetRegistryClient, "isRegistered").resolves(true); + + const result = await groupClient.registerGroupAndAttachLicenseAndAddIps({ + groupPool: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + ipIds: ["0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"], + licenseTermsId: "100", + licenseTemplate: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + txOptions: { + encodedTxDataOnly: true, + }, + }); + expect(result.encodedTxData!.data).to.be.a("string").and.not.empty; + }); + it("should return txHash when call registerGroupAndAttachLicenseAndAddIps given correct args", async () => { + sinon + .stub(groupClient.licenseRegistryReadOnlyClient, "hasIpAttachedLicenseTerms") + .resolves(true); + sinon.stub(groupClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(groupClient.groupingWorkflowsClient, "registerGroupAndAttachLicenseAndAddIps") + .resolves(txHash); + const result = await groupClient.registerGroupAndAttachLicenseAndAddIps({ + groupPool: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + ipIds: ["0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"], + licenseTermsId: "100", + }); + expect(result.txHash).equal(txHash); + }); + + it("should return txHash when call registerGroupAndAttachLicenseAndAddIps given correct args with waitForTransaction of true", async () => { + sinon + .stub(groupClient.licenseRegistryReadOnlyClient, "hasIpAttachedLicenseTerms") + .resolves(true); + sinon.stub(groupClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(groupClient.groupingWorkflowsClient, "registerGroupAndAttachLicenseAndAddIps") + .resolves(txHash); + sinon.stub(groupClient.groupingModuleEventClient, "parseTxIpGroupRegisteredEvent").returns([ + { + groupId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + groupPool: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }, + ]); + const result = await groupClient.registerGroupAndAttachLicenseAndAddIps({ + groupPool: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + ipIds: ["0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"], + licenseTermsId: "100", + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).equal(txHash); + }); + }); + + describe("Test groupClient.mintAndRegisterIpAndAttachLicenseAndAddToGroup", async () => { + beforeEach(() => {}); + it("should throw group id register error when call mintAndRegisterIpAndAttachLicenseAndAddToGroup given group id is not registered", async () => { + sinon.stub(groupClient.ipAssetRegistryClient, "isRegistered").resolves(false); + try { + await groupClient.mintAndRegisterIpAndAttachLicenseAndAddToGroup({ + groupId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + spgNftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + licenseTermsId: "100", + }); + } catch (err) { + expect((err as Error).message).equal( + "Failed to mint and register IP and attach license and add to group: Group IP 0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c is not registered.", + ); + } + }); + + it("should return txHash when call mintAndRegisterIpAndAttachLicenseAndAddToGroup given correct args", async () => { + sinon.stub(groupClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(groupClient.groupingWorkflowsClient, "mintAndRegisterIpAndAttachLicenseAndAddToGroup") + .resolves(txHash); + + const result = await groupClient.mintAndRegisterIpAndAttachLicenseAndAddToGroup({ + groupId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + spgNftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + licenseTermsId: "100", + }); + expect(result.txHash).equal(txHash); + }); + + it("should return txHash when call mintAndRegisterIpAndAttachLicenseAndAddToGroup given correct args with waitForTransaction of true", async () => { + sinon.stub(groupClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(groupClient.groupingWorkflowsClient, "mintAndRegisterIpAndAttachLicenseAndAddToGroup") + .resolves(txHash); + sinon.stub(groupClient.ipAssetRegistryClient, "parseTxIpRegisteredEvent").returns([ + { + ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + chainId: 0n, + tokenContract: "0x", + tokenId: 0n, + name: "", + uri: "", + registrationDate: 0n, + }, + ]); + const result = await groupClient.mintAndRegisterIpAndAttachLicenseAndAddToGroup({ + groupId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + spgNftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + licenseTermsId: "100", + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).equal(txHash); + expect(result.ipId).equal("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); + expect(result.tokenId).equal(0n); + }); + + it("should return encodedData when call mintAndRegisterIpAndAttachLicenseAndAddToGroup successfully with encodedTxDataOnly of true", async () => { + sinon.stub(groupClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub( + groupClient.groupingWorkflowsClient, + "mintAndRegisterIpAndAttachLicenseAndAddToGroupEncode", + ) + .returns({ + data: "0x11111111111111111111111111111", + to: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }); + + const result = await groupClient.mintAndRegisterIpAndAttachLicenseAndAddToGroup({ + groupId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + spgNftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + licenseTermsId: "100", + recipient: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + licenseTemplate: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + ipMetadata: { + ipMetadataHash: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + ipMetadataURI: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + nftMetadataHash: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + nftMetadataURI: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }, + txOptions: { + encodedTxDataOnly: true, + }, + }); + expect(result.encodedTxData!.data).to.be.a("string").and.not.empty; + }); + }); + + describe("Test groupClient.registerIpAndAttachLicenseAndAddToGroup", async () => { + it("should throw group id register error when call registerIpAndAttachLicenseAndAddToGroup given ip id is not registered", async () => { + sinon + .stub(groupClient.ipAssetRegistryClient, "ipId") + .resolves("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); + sinon.stub(groupClient.ipAssetRegistryClient, "isRegistered").resolves(false); + try { + await groupClient.registerIpAndAttachLicenseAndAddToGroup({ + groupId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + nftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + tokenId: "100", + licenseTermsId: "100", + }); + } catch (err) { + expect((err as Error).message).equal( + "Failed to register IP and attach license and add to group: Group IP 0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c is not registered.", + ); + } + }); + it("should throw nft contract error when call registerIpAndAttachLicenseAndAddToGroup given nft contract address is invalid", async () => { + sinon + .stub(groupClient.ipAssetRegistryClient, "ipId") + .resolves("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); + sinon.stub(groupClient.ipAssetRegistryClient, "isRegistered").resolves(true); + try { + await groupClient.registerIpAndAttachLicenseAndAddToGroup({ + groupId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + nftContract: "0x", + tokenId: "100", + licenseTermsId: "100", + }); + } catch (err) { + expect((err as Error).message).equal( + "Failed to register IP and attach license and add to group: nftContract address is invalid: 0x, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.", + ); + } + }); + + it("should return txHash when call registerIpAndAttachLicenseAndAddToGroup given correct args", async () => { + sinon + .stub(groupClient.ipAssetRegistryClient, "ipId") + .resolves("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); + sinon.stub(groupClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(groupClient.groupingWorkflowsClient, "registerIpAndAttachLicenseAndAddToGroup") + .resolves(txHash); + const result = await groupClient.registerIpAndAttachLicenseAndAddToGroup({ + groupId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + nftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + tokenId: "100", + licenseTermsId: "100", + }); + expect(result.txHash).equal(txHash); + }); + + it("should return txHash when call registerIpAndAttachLicenseAndAddToGroup given correct args with waitForTransaction of true", async () => { + sinon + .stub(groupClient.ipAssetRegistryClient, "ipId") + .resolves("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); + sinon.stub(groupClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(groupClient.groupingWorkflowsClient, "registerIpAndAttachLicenseAndAddToGroup") + .resolves(txHash); + sinon.stub(groupClient.ipAssetRegistryClient, "parseTxIpRegisteredEvent").returns([ + { + ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + chainId: 0n, + tokenContract: "0x", + tokenId: 0n, + name: "", + uri: "", + registrationDate: 0n, + }, + ]); + const result = await groupClient.registerIpAndAttachLicenseAndAddToGroup({ + groupId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + nftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + tokenId: "100", + licenseTermsId: "100", + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).equal(txHash); + expect(result.ipId).equal("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); + }); + + it("should return encodedData when call registerIpAndAttachLicenseAndAddToGroup successfully with encodedTxDataOnly of true", async () => { + sinon + .stub(groupClient.ipAssetRegistryClient, "ipId") + .resolves("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); + sinon.stub(groupClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(groupClient.groupingWorkflowsClient, "registerIpAndAttachLicenseAndAddToGroupEncode") + .returns({ + data: "0x11111111111111111111111111111", + to: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }); + const result = await groupClient.registerIpAndAttachLicenseAndAddToGroup({ + groupId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + nftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + tokenId: "100", + licenseTermsId: "100", + licenseTemplate: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + ipMetadata: { + ipMetadataHash: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + ipMetadataURI: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + nftMetadataHash: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + nftMetadataURI: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }, + txOptions: { + encodedTxDataOnly: true, + }, + }); + expect(result.encodedTxData!.data).to.be.a("string").and.not.empty; + }); + }); +}); diff --git a/packages/core-sdk/test/unit/resources/ipAccount.test.ts b/packages/core-sdk/test/unit/resources/ipAccount.test.ts index 1e299591..bdcb28ce 100644 --- a/packages/core-sdk/test/unit/resources/ipAccount.test.ts +++ b/packages/core-sdk/test/unit/resources/ipAccount.test.ts @@ -4,7 +4,7 @@ import * as sinon from "sinon"; import { IPAccountClient } from "../../../src/resources/ipAccount"; import { IPAccountExecuteRequest, IPAccountExecuteWithSigRequest } from "../../../src"; import * as utils from "../../../src/utils/utils"; -import { Account, PublicClient, WalletClient, zeroAddress, parseUnits } from "viem"; +import { Account, PublicClient, WalletClient, zeroAddress } from "viem"; const { IpAccountImplClient } = require("../../../src/abi/generated"); describe("Test IPAccountClient", () => { @@ -18,6 +18,12 @@ describe("Test IPAccountClient", () => { const accountMock = createMock(); walletMock.account = accountMock; ipAccountClient = new IPAccountClient(rpcMock, walletMock); + sinon.stub(IpAccountImplClient.prototype, "execute").resolves(txHash); + sinon.stub(IpAccountImplClient.prototype, "executeEncode").returns({ data: "0x", to: "0x" }); + sinon.stub(IpAccountImplClient.prototype, "executeWithSig").resolves(txHash); + sinon + .stub(IpAccountImplClient.prototype, "state") + .resolves({ result: "0x73fcb515cee99e4991465ef586cfe2b072ebb512" }); }); afterEach(() => { @@ -45,7 +51,6 @@ describe("Test IPAccountClient", () => { }); it("should return txHash when call execute successfully", async () => { - IpAccountImplClient.prototype.execute = sinon.stub().resolves(txHash); const result = await ipAccountClient.execute({ ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", to: zeroAddress, @@ -57,7 +62,6 @@ describe("Test IPAccountClient", () => { }); it("should return txHash when call execute successfully with waitForTransaction", async () => { - IpAccountImplClient.prototype.execute = sinon.stub().resolves(txHash); sinon.stub(utils, "waitTx").resolves(); const result = await ipAccountClient.execute({ ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", @@ -73,10 +77,6 @@ describe("Test IPAccountClient", () => { }); it("should return encodedTxData when call execute successfully with encodedTxDataOnly", async () => { - IpAccountImplClient.prototype.execute = sinon.stub().resolves(txHash); - IpAccountImplClient.prototype.executeEncode = sinon - .stub() - .returns("0x11111111111111111111111111111"); const result = await ipAccountClient.execute({ ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", to: zeroAddress, @@ -87,7 +87,7 @@ describe("Test IPAccountClient", () => { }, }); - expect(result.encodedTxData).to.equal("0x11111111111111111111111111111"); + expect(result.encodedTxData?.data).to.be.a("string").and.not.empty; }); }); @@ -112,7 +112,6 @@ describe("Test IPAccountClient", () => { }); it("should return txHash when call executeWithSig successfully", async () => { - IpAccountImplClient.prototype.executeWithSig = sinon.stub().resolves(txHash); const result = await ipAccountClient.executeWithSig({ ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", to: zeroAddress, @@ -127,7 +126,6 @@ describe("Test IPAccountClient", () => { }); it("should return txHash when call executeWithSig successfully with waitForTransaction", async () => { - IpAccountImplClient.prototype.executeWithSig = sinon.stub().resolves(txHash); sinon.stub(utils, "waitTx").resolves(); const result = await ipAccountClient.executeWithSig({ ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", @@ -146,10 +144,6 @@ describe("Test IPAccountClient", () => { }); it("should return encodedTxData when call executeWithSig successfully with encodedTxDataOnly", async () => { - IpAccountImplClient.prototype.executeWithSig = sinon.stub().resolves(txHash); - IpAccountImplClient.prototype.executeWithSigEncode = sinon - .stub() - .returns("0x11111111111111111111111111111"); const result = await ipAccountClient.executeWithSig({ ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", to: zeroAddress, @@ -163,7 +157,7 @@ describe("Test IPAccountClient", () => { }, }); - expect(result.encodedTxData).to.equal("0x11111111111111111111111111111"); + expect(result.encodedTxData?.data).to.be.a("string").and.not.empty; }); }); @@ -178,9 +172,6 @@ describe("Test IPAccountClient", () => { } }); it("should return the state of the IP Account", async () => { - sinon - .stub(IpAccountImplClient.prototype, "state") - .resolves({ result: "0x73fcb515cee99e4991465ef586cfe2b072ebb512" }); const state = await ipAccountClient.getIpAccountNonce( "0x73fcb515cee99e4991465ef586cfe2b072ebb512", ); diff --git a/packages/core-sdk/test/unit/resources/ipAsset.test.ts b/packages/core-sdk/test/unit/resources/ipAsset.test.ts index d893adf7..53c836dc 100644 --- a/packages/core-sdk/test/unit/resources/ipAsset.test.ts +++ b/packages/core-sdk/test/unit/resources/ipAsset.test.ts @@ -1,7 +1,12 @@ import chai from "chai"; import { createMock } from "../testUtils"; import * as sinon from "sinon"; -import { CreateIpAssetWithPilTermsRequest, IPAssetClient, PIL_TYPE } from "../../../src"; +import { + CreateIpAssetWithPilTermsRequest, + IPAssetClient, + LicenseTerms, + PIL_TYPE, +} from "../../../src"; import { PublicClient, WalletClient, @@ -11,10 +16,13 @@ import { LocalAccount, zeroAddress, Address, - parseUnits, } from "viem"; import chaiAsPromised from "chai-as-promised"; import { RegisterIpAndAttachPilTermsRequest } from "../../../src/types/resources/ipAsset"; +import { MockERC20 } from "../../integration/utils/mockERC20"; +const { RoyaltyModuleReadOnlyClient } = require("../../../src/abi/generated"); +const { IpAccountImplClient } = require("../../../src/abi/generated"); + chai.use(chaiAsPromised); const expect = chai.expect; @@ -22,7 +30,7 @@ describe("Test IpAssetClient", () => { let ipAssetClient: IPAssetClient; let rpcMock: PublicClient; let walletMock: WalletClient; - const nftContract = "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; + const spgNftContract = "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; beforeEach(() => { rpcMock = createMock(); @@ -33,14 +41,17 @@ describe("Test IpAssetClient", () => { walletMock.signTypedData = sinon .stub() .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); - (ipAssetClient.spgClient as any).address = "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; + (ipAssetClient.derivativeWorkflowsClient as any).address = + "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; (ipAssetClient.accessControllerClient as any).address = "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; (ipAssetClient.coreMetadataModuleClient as any).address = "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; (ipAssetClient.licensingModuleClient as any).address = "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; - (ipAssetClient.royaltyPolicyLAPClient as any).address = + (ipAssetClient.registrationWorkflowsClient as any).address = + "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; + (ipAssetClient.licenseAttachmentWorkflowsClient as any).address = "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; }); @@ -163,7 +174,7 @@ describe("Test IpAssetClient", () => { sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(true); const res = await ipAssetClient.register({ - nftContract, + nftContract: spgNftContract, tokenId: "3", }); @@ -179,7 +190,7 @@ describe("Test IpAssetClient", () => { try { await ipAssetClient.register({ - nftContract, + nftContract: spgNftContract, tokenId: "3", deadline: "error", ipMetadata: { @@ -196,7 +207,8 @@ describe("Test IpAssetClient", () => { const walletMock = createMock(); walletMock.account = createMock(); ipAssetClient = new IPAssetClient(rpcMock, walletMock, "iliad"); - (ipAssetClient.spgClient as any).address = "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; + (ipAssetClient.registrationWorkflowsClient as any).address = + "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; (ipAssetClient.coreMetadataModuleClient as any).address = "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; sinon @@ -206,7 +218,7 @@ describe("Test IpAssetClient", () => { const waitForTransaction: boolean = true; try { await ipAssetClient.register({ - nftContract, + nftContract: spgNftContract, tokenId: "3", deadline: "12321", ipMetadata: { @@ -233,7 +245,7 @@ describe("Test IpAssetClient", () => { .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); const res = await ipAssetClient.register({ - nftContract, + nftContract: spgNftContract, tokenId: "3", }); @@ -263,7 +275,7 @@ describe("Test IpAssetClient", () => { ]); const response = await ipAssetClient.register({ - nftContract, + nftContract: spgNftContract, tokenId: "3", txOptions: { waitForTransaction: true, @@ -282,7 +294,7 @@ describe("Test IpAssetClient", () => { .resolves("0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"); sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(false); sinon - .stub(ipAssetClient.spgClient, "registerIp") + .stub(ipAssetClient.registrationWorkflowsClient, "registerIp") .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); sinon.stub(ipAssetClient.ipAssetRegistryClient, "parseTxIpRegisteredEvent").returns([ { @@ -296,7 +308,7 @@ describe("Test IpAssetClient", () => { }, ]); const response = await ipAssetClient.register({ - nftContract, + nftContract: spgNftContract, tokenId: "3", ipMetadata: { ipMetadataURI: "", @@ -320,7 +332,7 @@ describe("Test IpAssetClient", () => { .resolves("0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"); sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(false); sinon - .stub(ipAssetClient.spgClient, "registerIp") + .stub(ipAssetClient.registrationWorkflowsClient, "registerIp") .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); sinon.stub(ipAssetClient.ipAssetRegistryClient, "parseTxIpRegisteredEvent").returns([ { @@ -357,7 +369,7 @@ describe("Test IpAssetClient", () => { sinon.stub(ipAssetClient.ipAssetRegistryClient, "register").throws(new Error("revert error")); try { await ipAssetClient.register({ - nftContract, + nftContract: spgNftContract, tokenId: "3", txOptions: { waitForTransaction: true, @@ -367,6 +379,36 @@ describe("Test IpAssetClient", () => { expect((err as Error).message).equal("Failed to register IP: revert error"); } }); + + it("should return encoded tx data when register a IP given correct args, encodedTxDataOnly is true and metadata", async () => { + sinon + .stub(ipAssetClient.ipAssetRegistryClient, "ipId") + .resolves("0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"); + sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(false); + sinon + .stub(ipAssetClient.registrationWorkflowsClient, "registerIp") + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + sinon.stub(ipAssetClient.ipAssetRegistryClient, "parseTxIpRegisteredEvent").returns([ + { + ipId: "0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4", + chainId: 0n, + tokenContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + tokenId: 0n, + name: "", + uri: "", + registrationDate: 0n, + }, + ]); + const response = await ipAssetClient.register({ + nftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + tokenId: "3", + txOptions: { + encodedTxDataOnly: true, + }, + }); + + expect(response.encodedTxData!.data).to.be.a("string").and.not.empty; + }); }); describe("Test ipAssetClient.registerDerivative", async () => { @@ -652,7 +694,7 @@ describe("Test IpAssetClient", () => { it("throw PIL_TYPE error when createIpAssetWithPilTerms given PIL_TYPE is not match", async () => { try { await ipAssetClient.mintAndRegisterIpAssetWithPilTerms({ - nftContract, + spgNftContract, } as unknown as CreateIpAssetWithPilTermsRequest); } catch (err) { expect((err as Error).message).equal( @@ -661,28 +703,30 @@ describe("Test IpAssetClient", () => { } }); - it("should throw address error when createIpAssetWithPilTerms given nftContract is wrong address", async () => { + it("should throw address error when createIpAssetWithPilTerms given spgNftContract is wrong address", async () => { sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(false); try { await ipAssetClient.mintAndRegisterIpAssetWithPilTerms({ - nftContract: "0x", + spgNftContract: "0x", pilType: PIL_TYPE.COMMERCIAL_USE, mintingFee: "100", currency: zeroAddress, }); } catch (err) { expect((err as Error).message).equal( - `Failed to mint and register IP and attach PIL terms: request.nftContract address is invalid: 0x, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.`, + `Failed to mint and register IP and attach PIL terms: request.spgNftContract address is invalid: 0x, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.`, ); } }); it("should return txHash when createIpAssetWithPilTerms given correct args", async () => { const hash = "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"; - sinon.stub(ipAssetClient.spgClient, "mintAndRegisterIpAndAttachPilTerms").resolves(hash); + sinon + .stub(ipAssetClient.licenseAttachmentWorkflowsClient, "mintAndRegisterIpAndAttachPilTerms") + .resolves(hash); const result = await ipAssetClient.mintAndRegisterIpAssetWithPilTerms({ - nftContract, + spgNftContract, pilType: PIL_TYPE.COMMERCIAL_USE, mintingFee: "100", currency: zeroAddress, @@ -698,7 +742,9 @@ describe("Test IpAssetClient", () => { it("should return ipId, tokenId, licenseTermsId,txHash when createIpAssetWithPilTerms given correct args and waitForTransaction of true", async () => { const hash = "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"; - sinon.stub(ipAssetClient.spgClient, "mintAndRegisterIpAndAttachPilTerms").resolves(hash); + sinon + .stub(ipAssetClient.licenseAttachmentWorkflowsClient, "mintAndRegisterIpAndAttachPilTerms") + .resolves(hash); sinon.stub(ipAssetClient.ipAssetRegistryClient, "parseTxIpRegisteredEvent").returns([ { ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", @@ -719,7 +765,7 @@ describe("Test IpAssetClient", () => { }, ]); const result = await ipAssetClient.mintAndRegisterIpAssetWithPilTerms({ - nftContract, + spgNftContract, pilType: PIL_TYPE.COMMERCIAL_USE, mintingFee: "100", currency: zeroAddress, @@ -739,9 +785,11 @@ describe("Test IpAssetClient", () => { it("should return encoded tx data when createIpAssetWithPilTerms given correct args and encodedTxDataOnly is true", async () => { const hash = "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"; - sinon.stub(ipAssetClient.spgClient, "mintAndRegisterIpAndAttachPilTerms").resolves(hash); + sinon + .stub(ipAssetClient.licenseAttachmentWorkflowsClient, "mintAndRegisterIpAndAttachPilTerms") + .resolves(hash); const result = await ipAssetClient.mintAndRegisterIpAssetWithPilTerms({ - nftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + spgNftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", pilType: 0, mintingFee: "100", currency: zeroAddress, @@ -768,7 +816,7 @@ describe("Test IpAssetClient", () => { try { await ipAssetClient.registerDerivativeIp({ - nftContract, + nftContract: spgNftContract, tokenId: "3", derivData: { parentIpIds: ["0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"], @@ -790,7 +838,7 @@ describe("Test IpAssetClient", () => { try { await ipAssetClient.registerDerivativeIp({ - nftContract, + nftContract: spgNftContract, tokenId: "3", derivData: { parentIpIds: ["0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"], @@ -815,7 +863,7 @@ describe("Test IpAssetClient", () => { try { await ipAssetClient.registerDerivativeIp({ - nftContract, + nftContract: spgNftContract, tokenId: "3", derivData: { parentIpIds: ["0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"], @@ -838,11 +886,11 @@ describe("Test IpAssetClient", () => { .stub(ipAssetClient.licenseRegistryReadOnlyClient, "hasIpAttachedLicenseTerms") .resolves(true); sinon - .stub(ipAssetClient.spgClient, "registerIpAndMakeDerivative") + .stub(ipAssetClient.derivativeWorkflowsClient, "registerIpAndMakeDerivative") .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); const res = await ipAssetClient.registerDerivativeIp({ - nftContract, + nftContract: spgNftContract, tokenId: "3", derivData: { parentIpIds: ["0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"], @@ -867,11 +915,11 @@ describe("Test IpAssetClient", () => { .stub(ipAssetClient.licenseRegistryReadOnlyClient, "hasIpAttachedLicenseTerms") .resolves(true); sinon - .stub(ipAssetClient.spgClient, "registerIpAndMakeDerivative") + .stub(ipAssetClient.derivativeWorkflowsClient, "registerIpAndMakeDerivative") .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); const res = await ipAssetClient.registerDerivativeIp({ - nftContract, + nftContract: spgNftContract, tokenId: "3", derivData: { parentIpIds: ["0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"], @@ -898,7 +946,7 @@ describe("Test IpAssetClient", () => { .stub(ipAssetClient.licenseRegistryReadOnlyClient, "hasIpAttachedLicenseTerms") .resolves(true); sinon - .stub(ipAssetClient.spgClient, "registerIpAndMakeDerivative") + .stub(ipAssetClient.derivativeWorkflowsClient, "registerIpAndMakeDerivative") .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); sinon.stub(ipAssetClient.ipAssetRegistryClient, "parseTxIpRegisteredEvent").returns([ { @@ -913,7 +961,7 @@ describe("Test IpAssetClient", () => { ]); const res = await ipAssetClient.registerDerivativeIp({ - nftContract, + nftContract: spgNftContract, tokenId: "3", derivData: { parentIpIds: ["0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"], @@ -943,7 +991,7 @@ describe("Test IpAssetClient", () => { .stub(ipAssetClient.licenseRegistryReadOnlyClient, "hasIpAttachedLicenseTerms") .resolves(true); sinon - .stub(ipAssetClient.spgClient, "registerIpAndMakeDerivative") + .stub(ipAssetClient.derivativeWorkflowsClient, "registerIpAndMakeDerivative") .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); sinon.stub(ipAssetClient.ipAssetRegistryClient, "parseTxIpRegisteredEvent").returns([ { @@ -987,7 +1035,7 @@ describe("Test IpAssetClient", () => { try { await ipAssetClient.registerIpAndAttachPilTerms({ - nftContract, + nftContract: spgNftContract, tokenId: "3", ipMetadata: { ipMetadataURI: "https://", @@ -1007,7 +1055,7 @@ describe("Test IpAssetClient", () => { it("should throw PIL_TYPE error when registerIpAndAttachPilTerms given PIL_TYPE is not match", async () => { try { await ipAssetClient.registerIpAndAttachPilTerms({ - nftContract, + spgNftContract, tokenId: "3", } as unknown as RegisterIpAndAttachPilTermsRequest); } catch (err) { @@ -1018,14 +1066,17 @@ describe("Test IpAssetClient", () => { }); it("should called with initial metadata when registerIpAndAttachPilTerms given empty ipMetadataURI", async () => { - const stub = sinon.stub(ipAssetClient.spgClient, "registerIpAndAttachPilTerms"); + const stub = sinon.stub( + ipAssetClient.licenseAttachmentWorkflowsClient, + "registerIpAndAttachPilTerms", + ); sinon .stub(ipAssetClient.ipAssetRegistryClient, "ipId") .resolves("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(false); await ipAssetClient.registerIpAndAttachPilTerms({ - nftContract, + nftContract: spgNftContract, tokenId: "3", ipMetadata: { ipMetadataHash: toHex(0, { size: 32 }), @@ -1044,14 +1095,16 @@ describe("Test IpAssetClient", () => { }); it("should return hash when registerIpAndAttachPilTerms given correct args", async () => { const hash = "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"; - sinon.stub(ipAssetClient.spgClient, "registerIpAndAttachPilTerms").resolves(hash); + sinon + .stub(ipAssetClient.licenseAttachmentWorkflowsClient, "registerIpAndAttachPilTerms") + .resolves(hash); sinon .stub(ipAssetClient.ipAssetRegistryClient, "ipId") .resolves("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(false); const result = await ipAssetClient.registerIpAndAttachPilTerms({ - nftContract, + nftContract: spgNftContract, tokenId: "3", ipMetadata: { ipMetadataHash: toHex(0, { size: 32 }), @@ -1071,7 +1124,9 @@ describe("Test IpAssetClient", () => { .resolves("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(false); - sinon.stub(ipAssetClient.spgClient, "registerIpAndAttachPilTerms").resolves(hash); + sinon + .stub(ipAssetClient.licenseAttachmentWorkflowsClient, "registerIpAndAttachPilTerms") + .resolves(hash); sinon .stub(ipAssetClient.licensingModuleClient, "parseTxLicenseTermsAttachedEvent") .returns([]); @@ -1091,7 +1146,7 @@ describe("Test IpAssetClient", () => { licenseTermsId: 5n, }); const result = await ipAssetClient.registerIpAndAttachPilTerms({ - nftContract, + nftContract: spgNftContract, tokenId: "3", ipMetadata: { ipMetadataURI: "https://", @@ -1116,7 +1171,9 @@ describe("Test IpAssetClient", () => { .resolves("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(false); - sinon.stub(ipAssetClient.spgClient, "registerIpAndAttachPilTerms").resolves(hash); + sinon + .stub(ipAssetClient.licenseAttachmentWorkflowsClient, "registerIpAndAttachPilTerms") + .resolves(hash); sinon.stub(ipAssetClient.licensingModuleClient, "parseTxLicenseTermsAttachedEvent").returns([ { ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", @@ -1152,7 +1209,7 @@ describe("Test IpAssetClient", () => { try { await ipAssetClient.mintAndRegisterIpAndMakeDerivative({ - nftContract, + spgNftContract, derivData: { parentIpIds: ["0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"], licenseTermsIds: ["1", "2"], @@ -1176,7 +1233,7 @@ describe("Test IpAssetClient", () => { try { await ipAssetClient.mintAndRegisterIpAndMakeDerivative({ - nftContract, + spgNftContract, derivData: { parentIpIds: ["0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"], licenseTermsIds: ["1"], @@ -1198,11 +1255,11 @@ describe("Test IpAssetClient", () => { .stub(ipAssetClient.licenseRegistryReadOnlyClient, "hasIpAttachedLicenseTerms") .resolves(true); sinon - .stub(ipAssetClient.spgClient, "mintAndRegisterIpAndMakeDerivative") + .stub(ipAssetClient.derivativeWorkflowsClient, "mintAndRegisterIpAndMakeDerivative") .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); const res = await ipAssetClient.mintAndRegisterIpAndMakeDerivative({ - nftContract, + spgNftContract, derivData: { parentIpIds: ["0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"], licenseTermsIds: ["1"], @@ -1226,7 +1283,7 @@ describe("Test IpAssetClient", () => { .stub(ipAssetClient.licenseRegistryReadOnlyClient, "hasIpAttachedLicenseTerms") .resolves(true); sinon - .stub(ipAssetClient.spgClient, "mintAndRegisterIpAndMakeDerivative") + .stub(ipAssetClient.derivativeWorkflowsClient, "mintAndRegisterIpAndMakeDerivative") .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); sinon.stub(ipAssetClient.ipAssetRegistryClient, "parseTxIpRegisteredEvent").returns([ { @@ -1241,7 +1298,8 @@ describe("Test IpAssetClient", () => { ]); const res = await ipAssetClient.mintAndRegisterIpAndMakeDerivative({ - nftContract, + spgNftContract, + recipient: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", derivData: { parentIpIds: ["0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"], licenseTermsIds: ["1"], @@ -1270,7 +1328,7 @@ describe("Test IpAssetClient", () => { .stub(ipAssetClient.licenseRegistryReadOnlyClient, "hasIpAttachedLicenseTerms") .resolves(true); sinon - .stub(ipAssetClient.spgClient, "mintAndRegisterIpAndMakeDerivative") + .stub(ipAssetClient.derivativeWorkflowsClient, "mintAndRegisterIpAndMakeDerivative") .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); sinon.stub(ipAssetClient.ipAssetRegistryClient, "parseTxIpRegisteredEvent").returns([ { @@ -1285,7 +1343,7 @@ describe("Test IpAssetClient", () => { ]); const res = await ipAssetClient.mintAndRegisterIpAndMakeDerivative({ - nftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + spgNftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", derivData: { parentIpIds: ["0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"], licenseTermsIds: ["1"], @@ -1303,4 +1361,469 @@ describe("Test IpAssetClient", () => { expect(res.encodedTxData!.data).to.be.a("string").and.not.empty; }); }); + describe("Test ipAssetClient.mintAndRegisterIp", async () => { + it("should throw spgNftContract error when mintAndRegisterIp given spgNftContract is wrong address", async () => { + try { + await ipAssetClient.mintAndRegisterIp({ + spgNftContract: "0x", + ipMetadata: { + ipMetadataURI: "", + ipMetadataHash: toHex(0, { size: 32 }), + }, + }); + } catch (err) { + expect((err as Error).message).equal( + `Failed to mint and register IP: request.spgNftContract address is invalid: 0x, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.`, + ); + } + }); + + it("should throw recipient error when mintAndRegisterIp given recipient is wrong address", async () => { + try { + await ipAssetClient.mintAndRegisterIp({ + spgNftContract, + recipient: "0x", + ipMetadata: { + ipMetadataURI: "", + ipMetadataHash: toHex(0, { size: 32 }), + }, + }); + } catch (err) { + expect((err as Error).message).equal( + `Failed to mint and register IP: request.recipient address is invalid: 0x, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.`, + ); + } + }); + + it("should return txHash when mintAndRegisterIp given correct args", async () => { + const hash = "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"; + sinon.stub(ipAssetClient.registrationWorkflowsClient, "mintAndRegisterIp").resolves(hash); + + const result = await ipAssetClient.mintAndRegisterIp({ + spgNftContract, + ipMetadata: { + ipMetadataURI: "", + ipMetadataHash: toHex(0, { size: 32 }), + }, + }); + + expect(result.txHash).to.equal(hash); + }); + + it("should return ipId,txHash when mintAndRegisterIp given correct args and waitForTransaction of true", async () => { + const hash = "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"; + sinon.stub(ipAssetClient.registrationWorkflowsClient, "mintAndRegisterIp").resolves(hash); + sinon.stub(ipAssetClient.ipAssetRegistryClient, "parseTxIpRegisteredEvent").returns([ + { + ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + chainId: 0n, + tokenContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + tokenId: 1n, + name: "", + uri: "", + registrationDate: 0n, + }, + ]); + + const result = await ipAssetClient.mintAndRegisterIp({ + spgNftContract, + ipMetadata: { + ipMetadataURI: "", + ipMetadataHash: toHex(0, { size: 32 }), + }, + txOptions: { + waitForTransaction: true, + }, + }); + + expect(result.txHash).to.equal(hash); + expect(result.ipId).to.equal("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); + }); + + it("should return encoded tx data when mintAndRegisterIp given correct args and encodedTxDataOnly of true", async () => { + const hash = "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"; + sinon.stub(ipAssetClient.registrationWorkflowsClient, "mintAndRegisterIp").resolves(hash); + + const result = await ipAssetClient.mintAndRegisterIp({ + spgNftContract, + recipient: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + ipMetadata: { + ipMetadataURI: "", + }, + txOptions: { + encodedTxDataOnly: true, + }, + }); + + expect(result.encodedTxData!.data).to.be.a("string").and.not.empty; + }); + }); + + describe("Test ipAssetClient.registerPilTermsAndAttach", async () => { + beforeEach(() => { + RoyaltyModuleReadOnlyClient.prototype.isWhitelistedRoyaltyPolicy = sinon + .stub() + .resolves(true); + RoyaltyModuleReadOnlyClient.prototype.isWhitelistedRoyaltyToken = sinon.stub().resolves(true); + sinon + .stub(IpAccountImplClient.prototype, "state") + .resolves({ result: "0x2e778894d11b5308e4153f094e190496c1e0609652c19f8b87e5176484b9a56e" }); + }); + const licenseTerms: LicenseTerms = { + defaultMintingFee: 1513n, + currency: MockERC20.address, + royaltyPolicy: zeroAddress, + transferable: false, + expiration: 0n, + commercialUse: false, + commercialAttribution: false, + commercializerChecker: zeroAddress, + commercializerCheckerData: "0x", + commercialRevShare: 0, + commercialRevCeiling: 0n, + derivativesAllowed: false, + derivativesAttribution: false, + derivativesApproval: false, + derivativesReciprocal: false, + derivativeRevCeiling: 0n, + uri: "", + }; + it("should throw ipId error when registerPilTermsAndAttach given ipId is wrong address", async () => { + try { + await ipAssetClient.registerPilTermsAndAttach({ + ipId: "0x", + terms: licenseTerms, + }); + } catch (err) { + expect((err as Error).message).equal( + `Failed to register PIL terms and attach: ipId address is invalid: 0x, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.`, + ); + } + }); + + it("should throw ipId have not registered error when registerPilTermsAndAttach given ipId have not registered", async () => { + sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(false); + + try { + await ipAssetClient.registerPilTermsAndAttach({ + ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + terms: licenseTerms, + }); + } catch (err) { + expect((err as Error).message).equal( + "Failed to register PIL terms and attach: The IP with id 0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c is not registered.", + ); + } + }); + + it("should return encoded tx data when registerPilTermsAndAttach given correct args and encodedTxDataOnly of true", async () => { + sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(ipAssetClient.licenseTemplateClient, "getLicenseTermsId") + .resolves({ selectedLicenseTermsId: 0n }); + + const result = await ipAssetClient.registerPilTermsAndAttach({ + ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + terms: licenseTerms, + txOptions: { + encodedTxDataOnly: true, + }, + }); + + expect(result.encodedTxData!.data).to.be.a("string").and.not.empty; + }); + + it("should return txHash when registerPilTermsAndAttach given correct args", async () => { + const hash = "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"; + sinon + .stub(ipAssetClient.licenseAttachmentWorkflowsClient, "registerPilTermsAndAttach") + .resolves(hash); + sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(ipAssetClient.licenseTemplateClient, "getLicenseTermsId") + .resolves({ selectedLicenseTermsId: 0n }); + const result = await ipAssetClient.registerPilTermsAndAttach({ + ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + terms: licenseTerms, + }); + + expect(result.txHash).to.equal(hash); + }); + + it("should return txHash and licenseTermsId when registerPilTermsAndAttach given correct args and waitForTransaction of true", async () => { + const hash = "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"; + sinon + .stub(ipAssetClient.licenseAttachmentWorkflowsClient, "registerPilTermsAndAttach") + .resolves(hash); + sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(ipAssetClient.licenseTemplateClient, "getLicenseTermsId") + .resolves({ selectedLicenseTermsId: 0n }); + sinon.stub(ipAssetClient.licensingModuleClient, "parseTxLicenseTermsAttachedEvent").returns([ + { + ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + caller: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + licenseTemplate: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + licenseTermsId: 0n, + }, + ]); + + const result = await ipAssetClient.registerPilTermsAndAttach({ + ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + terms: licenseTerms, + txOptions: { + waitForTransaction: true, + }, + }); + + expect(result.txHash).to.equal(hash); + expect(result.licenseTermsId).to.equal(0n); + }); + }); + + describe("Test ipAssetClient.mintAndRegisterIpAndMakeDerivativeWithLicenseTokens", async () => { + it("should throw licenseTokens error when mintAndRegisterIpAndMakeDerivativeWithLicenseTokens given licenseTokens empty", async () => { + try { + await ipAssetClient.mintAndRegisterIpAndMakeDerivativeWithLicenseTokens({ + spgNftContract, + licenseTokenIds: [], + }); + } catch (err) { + expect((err as Error).message).equal( + "Failed to mint and register IP and make derivative with license tokens: License token IDs must be provided.", + ); + } + }); + + it("should throw licenseTokens is not owned by caller error when mintAndRegisterIpAndMakeDerivativeWithLicenseTokens given wrong licenseTokens", async () => { + sinon.stub(ipAssetClient.licenseTokenReadOnlyClient, "ownerOf").resolves(undefined); + + try { + await ipAssetClient.mintAndRegisterIpAndMakeDerivativeWithLicenseTokens({ + spgNftContract, + licenseTokenIds: ["0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"], + }); + } catch (err) { + expect((err as Error).message).equal( + "Failed to mint and register IP and make derivative with license tokens: License token id 169371642198122114185371466690533487013299380860 must be owned by the caller.", + ); + } + }); + it("should return txHash when mintAndRegisterIpAndMakeDerivativeWithLicenseTokens given correct args", async () => { + sinon + .stub(ipAssetClient.licenseTokenReadOnlyClient, "ownerOf") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); + sinon + .stub( + ipAssetClient.derivativeWorkflowsClient, + "mintAndRegisterIpAndMakeDerivativeWithLicenseTokens", + ) + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + + const result = await ipAssetClient.mintAndRegisterIpAndMakeDerivativeWithLicenseTokens({ + spgNftContract, + licenseTokenIds: ["0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"], + ipMetadata: { + ipMetadataURI: "", + ipMetadataHash: toHex(0, { size: 32 }), + nftMetadataHash: toHex("nftMetadata", { size: 32 }), + nftMetadataURI: "", + }, + recipient: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + }); + + expect(result.txHash).to.equal( + "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997", + ); + }); + + it("should return txHash and ipId when mintAndRegisterIpAndMakeDerivativeWithLicenseTokens given correct args and waitForTransaction of true", async () => { + sinon + .stub(ipAssetClient.licenseTokenReadOnlyClient, "ownerOf") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); + sinon + .stub( + ipAssetClient.derivativeWorkflowsClient, + "mintAndRegisterIpAndMakeDerivativeWithLicenseTokens", + ) + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + sinon.stub(ipAssetClient.ipAssetRegistryClient, "parseTxIpRegisteredEvent").returns([ + { + ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + chainId: 0n, + tokenContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + tokenId: 1n, + name: "", + uri: "", + registrationDate: 0n, + }, + ]); + + const result = await ipAssetClient.mintAndRegisterIpAndMakeDerivativeWithLicenseTokens({ + spgNftContract, + licenseTokenIds: ["0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"], + txOptions: { + waitForTransaction: true, + }, + }); + + expect(result.txHash).to.equal( + "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997", + ); + expect(result.ipId).to.equal("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); + expect(result.tokenId).to.equal(1n); + }); + + it("should return encoded tx data when mintAndRegisterIpAndMakeDerivativeWithLicenseTokens given correct args and encodedTxDataOnly of true", async () => { + sinon + .stub(ipAssetClient.licenseTokenReadOnlyClient, "ownerOf") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); + sinon + .stub( + ipAssetClient.derivativeWorkflowsClient, + "mintAndRegisterIpAndMakeDerivativeWithLicenseTokens", + ) + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + + const result = await ipAssetClient.mintAndRegisterIpAndMakeDerivativeWithLicenseTokens({ + spgNftContract, + licenseTokenIds: ["0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"], + ipMetadata: { + ipMetadataURI: "", + ipMetadataHash: toHex(0, { size: 32 }), + nftMetadataHash: toHex("nftMetadata", { size: 32 }), + nftMetadataURI: "", + }, + txOptions: { + encodedTxDataOnly: true, + }, + }); + + expect(result.encodedTxData!.data).to.be.a("string").and.not.empty; + }); + }); + + describe("Test ipAssetClient.registerIpAndMakeDerivativeWithLicenseTokens", async () => { + beforeEach(() => { + sinon + .stub(ipAssetClient.ipAssetRegistryClient, "ipId") + .resolves("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); + }); + it("should throw tokenId error when registerIpAndMakeDerivativeWithLicenseTokens given tokenId is registered", async () => { + sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(true); + + try { + await ipAssetClient.registerIpAndMakeDerivativeWithLicenseTokens({ + nftContract: spgNftContract, + tokenId: "3", + licenseTokenIds: ["0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"], + }); + } catch (err) { + expect((err as Error).message).equal( + "Failed to register IP and make derivative with license tokens: The NFT with id 3 is already registered as IP.", + ); + } + }); + + it("should throw licenseTokens error when registerIpAndMakeDerivativeWithLicenseTokens given licenseTokens is not owner of caller", async () => { + sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(false); + sinon.stub(ipAssetClient.licenseTokenReadOnlyClient, "ownerOf").resolves(undefined); + + try { + await ipAssetClient.registerIpAndMakeDerivativeWithLicenseTokens({ + nftContract: spgNftContract, + tokenId: "3", + licenseTokenIds: ["0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"], + }); + } catch (err) { + expect((err as Error).message).equal( + "Failed to register IP and make derivative with license tokens: License token id 169371642198122114185371466690533487013299380860 must be owned by the caller.", + ); + } + }); + it("should return txHash when registerIpAndMakeDerivativeWithLicenseTokens given correct args", async () => { + sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(false); + sinon + .stub(ipAssetClient.licenseTokenReadOnlyClient, "ownerOf") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); + sinon + .stub( + ipAssetClient.derivativeWorkflowsClient, + "registerIpAndMakeDerivativeWithLicenseTokens", + ) + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + const result = await ipAssetClient.registerIpAndMakeDerivativeWithLicenseTokens({ + nftContract: spgNftContract, + tokenId: "3", + licenseTokenIds: ["0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"], + ipMetadata: { + ipMetadataURI: "", + ipMetadataHash: toHex(0, { size: 32 }), + }, + }); + expect(result.txHash).to.be.a("string").and.not.empty; + }); + + it("should return txHash and ipId when registerIpAndMakeDerivativeWithLicenseTokens given correct args and waitForTransaction of true", async () => { + sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(false); + sinon + .stub(ipAssetClient.licenseTokenReadOnlyClient, "ownerOf") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); + sinon + .stub( + ipAssetClient.derivativeWorkflowsClient, + "registerIpAndMakeDerivativeWithLicenseTokens", + ) + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + sinon.stub(ipAssetClient.ipAssetRegistryClient, "parseTxIpRegisteredEvent").returns([ + { + ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + chainId: 0n, + tokenContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + tokenId: 1n, + name: "", + uri: "", + registrationDate: 0n, + }, + ]); + const result = await ipAssetClient.registerIpAndMakeDerivativeWithLicenseTokens({ + nftContract: spgNftContract, + tokenId: "3", + licenseTokenIds: ["0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"], + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).to.be.a("string").and.not.empty; + expect(result.ipId).to.equal("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); + }); + + it("should return encoded tx data when registerIpAndMakeDerivativeWithLicenseTokens given correct args and encodedTxDataOnly of true", async () => { + sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(false); + sinon + .stub(ipAssetClient.licenseTokenReadOnlyClient, "ownerOf") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); + sinon + .stub( + ipAssetClient.derivativeWorkflowsClient, + "registerIpAndMakeDerivativeWithLicenseTokens", + ) + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + const result = await ipAssetClient.registerIpAndMakeDerivativeWithLicenseTokens({ + nftContract: spgNftContract, + tokenId: "3", + licenseTokenIds: ["0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"], + ipMetadata: { + ipMetadataURI: "", + ipMetadataHash: toHex(0, { size: 32 }), + nftMetadataHash: toHex("nftMetadata", { size: 32 }), + nftMetadataURI: "", + }, + txOptions: { + encodedTxDataOnly: true, + }, + }); + expect(result.encodedTxData!.data).to.be.a("string").and.not.empty; + }); + }); }); diff --git a/packages/core-sdk/test/unit/resources/license.test.ts b/packages/core-sdk/test/unit/resources/license.test.ts index a9544384..576064c9 100644 --- a/packages/core-sdk/test/unit/resources/license.test.ts +++ b/packages/core-sdk/test/unit/resources/license.test.ts @@ -4,12 +4,11 @@ import * as sinon from "sinon"; import { LicenseClient } from "../../../src"; import { PublicClient, WalletClient, Account, zeroAddress, Hex } from "viem"; import chaiAsPromised from "chai-as-promised"; -import { - PiLicenseTemplateGetLicenseTermsResponse, - RoyaltyPolicyLapClient, -} from "../../../src/abi/generated"; +import { PiLicenseTemplateGetLicenseTermsResponse } from "../../../src/abi/generated"; import { LicenseTerms } from "../../../src/types/resources/license"; import { MockERC20 } from "../../integration/utils/mockERC20"; +const { RoyaltyModuleReadOnlyClient } = require("../../../src/abi/generated"); + chai.use(chaiAsPromised); const expect = chai.expect; const txHash = "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"; @@ -25,12 +24,7 @@ describe("Test LicenseClient", () => { const accountMock = createMock(); accountMock.address = "0x73fcb515cee99e4991465ef586cfe2b072ebb512"; walletMock.account = accountMock; - licenseClient = new LicenseClient(rpcMock, walletMock); - licenseClient.royaltyPolicyLAPClient = new RoyaltyPolicyLapClient( - rpcMock, - walletMock, - zeroAddress, - ); + licenseClient = new LicenseClient(rpcMock, walletMock, "1513"); }); afterEach(() => { @@ -38,6 +32,12 @@ describe("Test LicenseClient", () => { }); describe("Test licenseClient.registerPILTerms", async () => { + beforeEach(() => { + RoyaltyModuleReadOnlyClient.prototype.isWhitelistedRoyaltyPolicy = sinon + .stub() + .resolves(true); + RoyaltyModuleReadOnlyClient.prototype.isWhitelistedRoyaltyToken = sinon.stub().resolves(true); + }); const licenseTerms: LicenseTerms = { defaultMintingFee: 1513n, currency: MockERC20.address, @@ -57,251 +57,7 @@ describe("Test LicenseClient", () => { derivativeRevCeiling: 0n, uri: "", }; - - it("should throw royalty error when call registerRILTerms with invalid royalty policy address", async () => { - await expect( - licenseClient.registerPILTerms({ - ...licenseTerms, - royaltyPolicy: "0x", - }), - ).to.be.rejectedWith( - "Failed to register license terms: request.royaltyPolicy address is invalid: 0x, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.", - ); - }); - - it("should throw royalty whitelist error when call registerRILTerms with invalid royalty whitelist address", async () => { - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyPolicy") - .resolves(false); - await expect( - licenseClient.registerPILTerms({ - ...licenseTerms, - royaltyPolicy: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", - }), - ).to.be.rejectedWith( - "Failed to register license terms: The royalty policy is not whitelisted.", - ); - }); - - it("should throw currency error when call registerRILTerms with invalid currency address", async () => { - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyPolicy") - .resolves(true); - await expect( - licenseClient.registerPILTerms({ - ...licenseTerms, - currency: "0x", - }), - ).to.be.rejectedWith( - "Failed to register license terms: request.currency address is invalid: 0x, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.", - ); - }); - - it("should throw currency whitelist error when call registerRILTerms with invalid currency whitelist address", async () => { - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyPolicy") - .resolves(true); - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyToken") - .resolves(false); - await expect( - licenseClient.registerPILTerms({ - ...licenseTerms, - currency: MockERC20.address, - }), - ).to.be.rejectedWith( - "Failed to register license terms: The currency token is not whitelisted.", - ); - }); - - it("should throw royalty policy requires currency token error when call registerRILTerms given royaltyPolicy is not zero address and current is zero address", async () => { - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyPolicy") - .resolves(true); - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyToken") - .resolves(true); - await expect( - licenseClient.registerPILTerms({ - ...licenseTerms, - currency: zeroAddress, - royaltyPolicy: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", - }), - ).to.be.rejectedWith( - "Failed to register license terms: Royalty policy requires currency token.", - ); - }); - - describe("verify commercial use", () => { - beforeEach(() => { - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyPolicy") - .resolves(true); - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyToken") - .resolves(true); - }); - it("should throw commercialAttribution error when call registerRILTerms given commercialUse is false and commercialAttribution is true", async () => { - await expect( - licenseClient.registerPILTerms({ - ...licenseTerms, - commercialUse: false, - commercialAttribution: true, - }), - ).to.be.rejectedWith( - "Failed to register license terms: Cannot add commercial attribution when commercial use is disabled.", - ); - }); - - it("should throw commercializerChecker error when call registerRILTerms given commercialUse is false and commercialChecker is not zero address", async () => { - await expect( - licenseClient.registerPILTerms({ - ...licenseTerms, - commercialUse: false, - commercializerChecker: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", - }), - ).to.be.rejectedWith( - "Failed to register license terms: Cannot add commercializerChecker when commercial use is disabled.", - ); - }); - it("should throw commercialRevShare error when call registerRILTerms given commercialUse is false and commercialRevShare is more than 0 ", async () => { - await expect( - licenseClient.registerPILTerms({ - ...licenseTerms, - commercialUse: false, - commercializerChecker: zeroAddress, - commercialRevShare: 1, - }), - ).to.be.rejectedWith( - "Failed to register license terms: Cannot add commercial revenue share when commercial use is disabled.", - ); - }); - - it("should throw commercialRevCeiling error when call registerRILTerms given commercialUse is false and commercialRevCeiling is more than 0", async () => { - await expect( - licenseClient.registerPILTerms({ - ...licenseTerms, - commercialUse: false, - commercialRevCeiling: 1, - commercializerChecker: zeroAddress, - }), - ).to.be.rejectedWith( - "Failed to register license terms: Cannot add commercial revenue ceiling when commercial use is disabled.", - ); - }); - - it("should throw derivativeRevCeiling error when call registerRILTerms given commercialUse is false and derivativeRevCeiling is more than 0", async () => { - await expect( - licenseClient.registerPILTerms({ - ...licenseTerms, - commercialUse: false, - derivativeRevCeiling: 1, - commercializerChecker: zeroAddress, - }), - ).to.be.rejectedWith( - "Failed to register license terms: Cannot add derivative revenue ceiling share when commercial use is disabled.", - ); - }); - - it("should throw royaltyPolicy error when call registerRILTerms given commercialUse is false and royaltyPolicy is not zero address", async () => { - await expect( - licenseClient.registerPILTerms({ - ...licenseTerms, - commercialUse: false, - royaltyPolicy: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", - commercializerChecker: zeroAddress, - }), - ).to.be.rejectedWith( - "Failed to register license terms: Cannot add commercial royalty policy when commercial use is disabled.", - ); - }); - - it("should throw royaltyPolicy error when call registerRILTerms given commercialUse is true and royaltyPolicy is zero address", async () => { - await expect( - licenseClient.registerPILTerms({ - ...licenseTerms, - commercialUse: true, - royaltyPolicy: zeroAddress, - }), - ).to.be.rejectedWith( - "Failed to register license terms: Royalty policy is required when commercial use is enabled.", - ); - }); - }); - - describe("verify derivatives", () => { - beforeEach(() => { - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyPolicy") - .resolves(true); - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyToken") - .resolves(true); - }); - it("should throw derivativesAttribution error when call registerRILTerms given derivativesAllowed is false and derivativesAttribution is true", async () => { - await expect( - licenseClient.registerPILTerms({ - ...licenseTerms, - commercialUse: true, - derivativesAllowed: false, - derivativesAttribution: true, - royaltyPolicy: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", - }), - ).to.be.rejectedWith( - "Failed to register license terms: Cannot add derivative attribution when derivative use is disabled.", - ); - }); - - it("should throw derivativesApproval error when call registerRILTerms given derivativesAllowed is false and derivativesApproval is true", async () => { - await expect( - licenseClient.registerPILTerms({ - ...licenseTerms, - commercialUse: true, - derivativesAllowed: false, - derivativesApproval: true, - royaltyPolicy: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", - }), - ).to.be.rejectedWith( - "Failed to register license terms: Cannot add derivative approval when derivative use is disabled.", - ); - }); - - it("should throw derivativesReciprocal error when call registerRILTerms given derivativesAllowed is false and derivativesReciprocal is true", async () => { - await expect( - licenseClient.registerPILTerms({ - ...licenseTerms, - commercialUse: true, - derivativesAllowed: false, - derivativesReciprocal: true, - royaltyPolicy: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", - }), - ).to.be.rejectedWith( - "Failed to register license terms: Cannot add derivative reciprocal when derivative use is disabled.", - ); - }); - - it("should throw derivativeRevCeiling error when call registerRILTerms given derivativesAllowed is false and derivativeRevCeiling is more than 0", async () => { - await expect( - licenseClient.registerPILTerms({ - ...licenseTerms, - commercialUse: true, - derivativesAllowed: false, - derivativeRevCeiling: 1, - royaltyPolicy: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", - }), - ).to.be.rejectedWith( - "Failed to register license terms: Cannot add derivative revenue ceiling when derivative use is disabled.", - ); - }); - }); - it("should return directly licenseTermsId when call registerPILTerms given request have already registered", async () => { - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyPolicy") - .resolves(true); - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyToken") - .resolves(true); sinon .stub(licenseClient.licenseTemplateClient, "getLicenseTermsId") .resolves({ selectedLicenseTermsId: BigInt(1) }); @@ -313,12 +69,6 @@ describe("Test LicenseClient", () => { }); it("should throw commercialRevShare error when call registerPILTerms given commercialRevShare is more than 100", async () => { - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyPolicy") - .resolves(true); - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyToken") - .resolves(true); sinon .stub(licenseClient.licenseTemplateClient, "getLicenseTermsId") .resolves({ selectedLicenseTermsId: BigInt(0) }); @@ -336,12 +86,6 @@ describe("Test LicenseClient", () => { ); }); it("should throw commercialRevShare error when call registerPILTerms given commercialRevShare is less than 0", async () => { - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyPolicy") - .resolves(true); - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyToken") - .resolves(true); sinon .stub(licenseClient.licenseTemplateClient, "getLicenseTermsId") .resolves({ selectedLicenseTermsId: BigInt(0) }); @@ -359,12 +103,6 @@ describe("Test LicenseClient", () => { ); }); it("should return encodedTxData when call registerPILTerms given txOptions.encodedTxDataOnly of true and args is correct", async () => { - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyPolicy") - .resolves(true); - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyToken") - .resolves(true); sinon .stub(licenseClient.licenseTemplateClient, "getLicenseTermsId") .resolves({ selectedLicenseTermsId: BigInt(0) }); @@ -385,12 +123,6 @@ describe("Test LicenseClient", () => { }); it("should return txHash when call registerPILTerms given args is correct", async () => { - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyPolicy") - .resolves(true); - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyToken") - .resolves(true); sinon .stub(licenseClient.licenseTemplateClient, "getLicenseTermsId") .resolves({ selectedLicenseTermsId: BigInt(0) }); @@ -413,12 +145,6 @@ describe("Test LicenseClient", () => { }); it("should return txHash when call registerPILTerms given args is correct and waitForTransaction of true", async () => { - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyPolicy") - .resolves(true); - sinon - .stub(licenseClient.royaltyModuleReadOnlyClient, "isWhitelistedRoyaltyToken") - .resolves(true); sinon .stub(licenseClient.licenseTemplateClient, "getLicenseTermsId") .resolves({ selectedLicenseTermsId: BigInt(0) }); @@ -513,6 +239,26 @@ describe("Test LicenseClient", () => { ); } }); + + it("should return encodedTxData when call registerNonComSocialRemixingPIL given txOptions.encodedTxDataOnly of true and args is correct", async () => { + sinon + .stub(licenseClient.licenseTemplateClient, "getLicenseTermsId") + .resolves({ selectedLicenseTermsId: BigInt(0) }); + sinon + .stub(licenseClient.licenseTemplateClient, "registerLicenseTermsEncode") + .returns({ to: zeroAddress, data: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c" }); + + const result = await licenseClient.registerNonComSocialRemixingPIL({ + txOptions: { + encodedTxDataOnly: true, + }, + }); + + expect(result.encodedTxData).to.deep.equal({ + to: zeroAddress, + data: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }); + }); }); describe("Test licenseClient.registerCommercialUsePIL", async () => { @@ -589,6 +335,28 @@ describe("Test LicenseClient", () => { ); } }); + + it("should return encodedTxData when call registerCommercialUsePIL given txOptions.encodedTxDataOnly of true and args is correct", async () => { + sinon + .stub(licenseClient.licenseTemplateClient, "getLicenseTermsId") + .resolves({ selectedLicenseTermsId: BigInt(0) }); + sinon + .stub(licenseClient.licenseTemplateClient, "registerLicenseTermsEncode") + .returns({ to: zeroAddress, data: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c" }); + + const result = await licenseClient.registerCommercialUsePIL({ + defaultMintingFee: "1", + currency: zeroAddress, + txOptions: { + encodedTxDataOnly: true, + }, + }); + + expect(result.encodedTxData).to.deep.equal({ + to: zeroAddress, + data: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }); + }); }); describe("Test licenseClient.registerCommercialRemixPIL", async () => { @@ -669,6 +437,29 @@ describe("Test LicenseClient", () => { ); } }); + + it("should return encodedTxData when call registerCommercialRemixPIL given txOptions.encodedTxDataOnly of true and args is correct", async () => { + sinon + .stub(licenseClient.licenseTemplateClient, "getLicenseTermsId") + .resolves({ selectedLicenseTermsId: BigInt(0) }); + sinon + .stub(licenseClient.licenseTemplateClient, "registerLicenseTermsEncode") + .returns({ to: zeroAddress, data: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c" }); + + const result = await licenseClient.registerCommercialRemixPIL({ + defaultMintingFee: "1", + commercialRevShare: 100, + currency: zeroAddress, + txOptions: { + encodedTxDataOnly: true, + }, + }); + + expect(result.encodedTxData).to.deep.equal({ + to: zeroAddress, + data: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }); + }); }); describe("Test licenseClient.attachLicenseTerms", async () => { @@ -772,6 +563,30 @@ describe("Test LicenseClient", () => { expect(result.txHash).to.equal(txHash); }); + + it("should return encodedTxData when call attachLicenseTerms 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.licenseRegistryReadOnlyClient, "hasIpAttachedLicenseTerms") + .resolves(false); + sinon + .stub(licenseClient.licensingModuleClient, "attachLicenseTermsEncode") + .returns({ to: zeroAddress, data: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c" }); + + const result = await licenseClient.attachLicenseTerms({ + ipId: zeroAddress, + licenseTermsId: "1", + txOptions: { + encodedTxDataOnly: true, + }, + }); + + expect(result.encodedTxData).to.deep.equal({ + to: zeroAddress, + data: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }); + }); }); describe("Test licenseClient.mintLicenseTokens", async () => { @@ -940,6 +755,30 @@ describe("Test LicenseClient", () => { expect(result.txHash).to.equal(txHash); expect(result.licenseTokenIds).to.deep.equal([1n, 2n, 3n, 4n, 5n]); }); + + it("should return encodedTxData when call mintLicenseTokens 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.licenseRegistryReadOnlyClient, "hasIpAttachedLicenseTerms") + .resolves(true); + sinon + .stub(licenseClient.licensingModuleClient, "mintLicenseTokensEncode") + .returns({ to: zeroAddress, data: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c" }); + + const result = await licenseClient.mintLicenseTokens({ + licensorIpId: zeroAddress, + licenseTermsId: "1", + txOptions: { + encodedTxDataOnly: true, + }, + }); + + expect(result.encodedTxData).to.deep.equal({ + to: zeroAddress, + data: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }); + }); }); describe("Test licenseClient.getLicenseTerms", async () => { diff --git a/packages/core-sdk/test/unit/resources/nftClient.test.ts b/packages/core-sdk/test/unit/resources/nftClient.test.ts index 3698bc23..11350150 100644 --- a/packages/core-sdk/test/unit/resources/nftClient.test.ts +++ b/packages/core-sdk/test/unit/resources/nftClient.test.ts @@ -1,9 +1,9 @@ import chai, { expect } from "chai"; import chaiAsPromised from "chai-as-promised"; import * as sinon from "sinon"; -import { Hex, PublicClient, WalletClient } from "viem"; +import { PublicClient, WalletClient } from "viem"; -import { CreateNFTCollectionRequest, NftClient } from "../../../src"; +import { NftClient } from "../../../src"; import { createMock } from "../testUtils"; chai.use(chaiAsPromised); @@ -33,6 +33,10 @@ describe("Test NftClient", () => { symbol: "symbol", maxSupply: 1, mintFee: -1n, + isPublicMinting: true, + mintOpen: true, + mintFeeRecipient: "0x", + contractURI: "test-uri", }); } catch (e) { expect((e as Error).message).equal( @@ -48,6 +52,10 @@ describe("Test NftClient", () => { symbol: "symbol", maxSupply: 1, mintFee: 1n, + isPublicMinting: true, + mintOpen: true, + mintFeeRecipient: "0x", + contractURI: "test-uri", }); } catch (e) { expect((e as Error).message).equal( @@ -57,33 +65,67 @@ describe("Test NftClient", () => { }); it("should return txHash when call createNFTCollection successfully", async () => { - sinon.stub(nftClient.spgClient, "createCollection").resolves(txHash); + sinon.stub(nftClient.registrationWorkflowsClient, "createCollection").resolves(txHash); const result = await nftClient.createNFTCollection({ name: "name", symbol: "symbol", maxSupply: 1, mintFee: 1n, mintFeeToken: mintFeeToken, + isPublicMinting: true, + contractURI: "test-uri", + mintOpen: true, + mintFeeRecipient: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", }); expect(result.txHash).equal(txHash); }); it("should return txHash when call createNFTCollection successfully with waitForTransaction", async () => { - const nftContract = "0x73fcb515cee99e4991465ef586cfe2b072ebb512"; - sinon.stub(nftClient.spgClient, "createCollection").resolves(txHash); - sinon.stub(nftClient.spgClient, "parseTxCollectionCreatedEvent").returns([{ nftContract }]); + const spgNftContract = "0x73fcb515cee99e4991465ef586cfe2b072ebb512"; + sinon.stub(nftClient.registrationWorkflowsClient, "createCollection").resolves(txHash); + sinon + .stub(nftClient.registrationWorkflowsClient, "parseTxCollectionCreatedEvent") + .returns([{ spgNftContract }]); const result = await nftClient.createNFTCollection({ name: "name", symbol: "symbol", owner: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + isPublicMinting: true, + mintOpen: true, + contractURI: "test-uri", + mintFeeRecipient: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", txOptions: { waitForTransaction: true, }, }); expect(result.txHash).equal(txHash); - expect(result.nftContract).equal(nftContract); + expect(result.spgNftContract).equal(spgNftContract); + }); + + it("should return encodedTxData when call createNFTCollection successfully with encodedTxDataOnly", async () => { + sinon.stub(nftClient.registrationWorkflowsClient, "createCollectionEncode").returns({ + data: "0x", + to: "0x", + }); + + const result = await nftClient.createNFTCollection({ + name: "name", + symbol: "symbol", + maxSupply: 1, + mintFee: 1n, + mintFeeToken: mintFeeToken, + isPublicMinting: true, + contractURI: "test-uri", + mintOpen: true, + mintFeeRecipient: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + txOptions: { + encodedTxDataOnly: true, + }, + }); + + expect(result.encodedTxData?.data).to.be.a("string").and.not.empty; }); }); }); diff --git a/packages/core-sdk/test/unit/resources/permission.test.ts b/packages/core-sdk/test/unit/resources/permission.test.ts index 86d714dd..23055567 100644 --- a/packages/core-sdk/test/unit/resources/permission.test.ts +++ b/packages/core-sdk/test/unit/resources/permission.test.ts @@ -21,9 +21,14 @@ describe("Test Permission", () => { .stub() .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); permissionClient = new PermissionClient(rpcMock, walletMock, "iliad"); - IpAccountImplClient.prototype.state = sinon - .stub() - .resolves({ result: "0x2e778894d11b5308e4153f094e190496c1e0609652c19f8b87e5176484b9a56e" }); + sinon + .stub(IpAccountImplClient.prototype, "state") + .resolves({ result: "0x2e778894d11b5308e4153f094e190496c1e0609652c19f8b87e5176484b9a5e" }); + sinon.stub(IpAccountImplClient.prototype, "executeWithSig").resolves(txHash); + sinon.stub(IpAccountImplClient.prototype, "executeWithSigEncode").returns({ + data: "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997", + to: "0x", + }); (permissionClient.accessControllerClient as any).address = "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"; }); @@ -84,6 +89,22 @@ describe("Test Permission", () => { expect(res.txHash).to.equal(txHash); expect(res.success).to.equal(true); }); + + it("should return encodedTxData when call setPermission given correct args and encodedTxDataOnly of true", async () => { + sinon.stub(permissionClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon.stub(permissionClient.accessControllerClient, "setPermission").resolves(txHash); + + const res = await permissionClient.setPermission({ + ipId: AddressZero, + signer: AddressZero, + to: AddressZero, + permission: AccessPermission.ALLOW, + txOptions: { + encodedTxDataOnly: true, + }, + }); + expect(res.encodedTxData?.data).to.be.a("string").and.not.empty; + }); }); describe("Test permission.setAllPermissions", async () => { @@ -133,6 +154,21 @@ describe("Test Permission", () => { expect(res.txHash).to.equal(txHash); expect(res.success).to.equal(true); }); + + it("should return encodedTxData when call setAllPermissions given correct args and encodedTxDataOnly of true", async () => { + sinon.stub(permissionClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon.stub(permissionClient.accessControllerClient, "setAllPermissions").resolves(txHash); + + const res = await permissionClient.setAllPermissions({ + ipId: AddressZero, + signer: AddressZero, + permission: AccessPermission.ALLOW, + txOptions: { + encodedTxDataOnly: true, + }, + }); + expect(res.encodedTxData?.data).to.be.a("string").and.not.empty; + }); }); describe("Test permission.createSetPermissionSignature", async () => { @@ -211,7 +247,6 @@ describe("Test Permission", () => { it("should return hash when call createSetPermissionSignature given correct args", async () => { sinon.stub(permissionClient.ipAssetRegistryClient, "isRegistered").resolves(true); - IpAccountImplClient.prototype.executeWithSig = sinon.stub().resolves(txHash); const res = await permissionClient.createSetPermissionSignature({ ipId: AddressZero, @@ -226,7 +261,6 @@ describe("Test Permission", () => { it("should return txHash and success when call createSetPermissionSignature given correct args and waitForTransaction of true", async () => { sinon.stub(permissionClient.ipAssetRegistryClient, "isRegistered").resolves(true); - IpAccountImplClient.prototype.executeWithSig = sinon.stub().resolves(txHash); const res = await permissionClient.createSetPermissionSignature({ ipId: AddressZero, @@ -242,6 +276,21 @@ describe("Test Permission", () => { expect(res.txHash).to.equal(txHash); expect(res.success).to.equal(true); }); + + it("should return encodedTxData when call createSetPermissionSignature given correct args and encodedTxDataOnly of true", async () => { + sinon.stub(permissionClient.ipAssetRegistryClient, "isRegistered").resolves(true); + + const res = await permissionClient.createSetPermissionSignature({ + ipId: AddressZero, + signer: AddressZero, + to: AddressZero, + permission: AccessPermission.ALLOW, + txOptions: { + encodedTxDataOnly: true, + }, + }); + expect(res.encodedTxData?.data).to.be.a("string").and.not.empty; + }); }); describe("Test permission.setBatchPermissions", async () => { @@ -304,6 +353,26 @@ describe("Test Permission", () => { expect(res.txHash).to.equal(txHash); expect(res.success).to.equal(true); }); + + it("should return encodedTxData when call setBatchPermissions given correct args and encodedTxDataOnly of true", async () => { + sinon.stub(permissionClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon.stub(permissionClient.accessControllerClient, "setBatchPermissions").resolves(txHash); + + const res = await permissionClient.setBatchPermissions({ + permissions: [ + { + ipId: AddressZero, + signer: AddressZero, + to: AddressZero, + permission: AccessPermission.ALLOW, + }, + ], + txOptions: { + encodedTxDataOnly: true, + }, + }); + expect(res.encodedTxData?.data).to.be.a("string").and.not.empty; + }); }); describe("Test permission.createSetBatchPermissionsSignature", async () => { @@ -331,7 +400,6 @@ describe("Test Permission", () => { it("should return hash when call createSetBatchPermissionsSignature given correct args", async () => { sinon.stub(permissionClient.ipAssetRegistryClient, "isRegistered").resolves(true); - IpAccountImplClient.prototype.executeWithSig = sinon.stub().resolves(txHash); const res = await permissionClient.createBatchPermissionSignature({ ipId: AddressZero, @@ -350,8 +418,6 @@ describe("Test Permission", () => { it("should return txHash and success when call createSetBatchPermissionsSignature given correct args and waitForTransaction of true", async () => { sinon.stub(permissionClient.ipAssetRegistryClient, "isRegistered").resolves(true); - IpAccountImplClient.prototype.executeWithSig = sinon.stub().resolves(txHash); - const res = await permissionClient.createBatchPermissionSignature({ ipId: AddressZero, deadline: 2000, @@ -371,5 +437,24 @@ describe("Test Permission", () => { expect(res.txHash).to.equal(txHash); expect(res.success).to.equal(true); }); + + it("should return encodedTxData when call createSetBatchPermissionsSignature given correct args and encodedTxDataOnly of true", async () => { + sinon.stub(permissionClient.ipAssetRegistryClient, "isRegistered").resolves(true); + const res = await permissionClient.createBatchPermissionSignature({ + ipId: AddressZero, + permissions: [ + { + ipId: AddressZero, + signer: AddressZero, + to: AddressZero, + permission: AccessPermission.ALLOW, + }, + ], + txOptions: { + encodedTxDataOnly: true, + }, + }); + expect(res.encodedTxData?.data).to.be.a("string").and.not.empty; + }); }); }); diff --git a/packages/core-sdk/test/unit/resources/royalty.test.ts b/packages/core-sdk/test/unit/resources/royalty.test.ts index 274d5f91..be0fc76c 100644 --- a/packages/core-sdk/test/unit/resources/royalty.test.ts +++ b/packages/core-sdk/test/unit/resources/royalty.test.ts @@ -4,7 +4,6 @@ import * as sinon from "sinon"; import { PublicClient, WalletClient, Account } from "viem"; import chaiAsPromised from "chai-as-promised"; import { RoyaltyClient } from "../../../src/resources/royalty"; -import { RoyaltyPolicyLapGetRoyaltyDataResponse } from "../../../src/abi/generated"; const { IpRoyaltyVaultImplClient } = require("../../../src/abi/generated"); chai.use(chaiAsPromised); const expect = chai.expect; @@ -29,114 +28,6 @@ describe("Test RoyaltyClient", () => { sinon.restore(); }); - describe("Test royaltyClient.collectRoyaltyTokens", async () => { - it("should throw parentIpId error when call collectRoyaltyTokens given parentIpId is not registered", async () => { - sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(false); - - try { - await royaltyClient.collectRoyaltyTokens({ - parentIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", - royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", - }); - } catch (err) { - expect((err as Error).message).equals( - "Failed to collect royalty tokens: The parent IP with id 0x73fcb515cee99e4991465ef586cfe2b072ebb512 is not registered.", - ); - } - }); - - it("should throw royaltyVaultIpId error when call collectRoyaltyTokens given royaltyVaultIpId is not registered", async () => { - sinon - .stub(royaltyClient.ipAssetRegistryClient, "isRegistered") - .onFirstCall() - .resolves(true) - .onSecondCall() - .resolves(false); - - try { - await royaltyClient.collectRoyaltyTokens({ - parentIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", - royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", - }); - } catch (err) { - expect((err as Error).message).equals( - "Failed to collect royalty tokens: The royalty vault IP with id 0x73fCB515cEE99e4991465ef586CfE2B072EbB512 is not registered.", - ); - } - }); - - it("should throw royaltyVaultAddress error when call collectRoyaltyTokens given royalty vault address is empty", async () => { - sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); - sinon - .stub(royaltyClient.royaltyPolicyLapClient, "getRoyaltyData") - .resolves([] as unknown as RoyaltyPolicyLapGetRoyaltyDataResponse); - - try { - await royaltyClient.collectRoyaltyTokens({ - parentIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", - royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", - }); - } catch (err) { - expect((err as Error).message).equals( - "Failed to collect royalty tokens: The royalty vault IP with id 0x73fCB515cEE99e4991465ef586CfE2B072EbB512 address is not set.", - ); - } - }); - - it("should throw royaltyVaultAddress error when call collectRoyaltyTokens given royalty vault address is 0x", async () => { - sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); - sinon.stub(royaltyClient.royaltyPolicyLapClient, "getRoyaltyData").resolves([true, "0x", 1]); - - try { - await royaltyClient.collectRoyaltyTokens({ - parentIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", - royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", - }); - } catch (err) { - expect((err as Error).message).equals( - "Failed to collect royalty tokens: The royalty vault IP with id 0x73fCB515cEE99e4991465ef586CfE2B072EbB512 address is not set.", - ); - } - }); - - it("should return txHash when call collectRoyaltyTokens given correct args", async () => { - sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); - sinon - .stub(royaltyClient.royaltyPolicyLapClient, "getRoyaltyData") - .resolves([true, "0x73fcb515cee99e4991465ef586cfe2b072ebb512", 1]); - sinon.stub(IpRoyaltyVaultImplClient.prototype, "collectRoyaltyTokens").resolves(txHash); - - const result = await royaltyClient.collectRoyaltyTokens({ - parentIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", - royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", - }); - - expect(result.txHash).equals(txHash); - }); - - it("should return txHash when call collectRoyaltyTokens given given correct args and waitForTransaction is true", async () => { - sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); - sinon - .stub(royaltyClient.royaltyPolicyLapClient, "getRoyaltyData") - .resolves([true, "0x73fcb515cee99e4991465ef586cfe2b072ebb512", 1]); - sinon.stub(IpRoyaltyVaultImplClient.prototype, "collectRoyaltyTokens").resolves(txHash); - sinon.stub(IpRoyaltyVaultImplClient.prototype, "parseTxRoyaltyTokensCollectedEvent").returns([ - { - ancestorIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", - royaltyTokensCollected: 1, - }, - ]); - const result = await royaltyClient.collectRoyaltyTokens({ - parentIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", - royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", - txOptions: { waitForTransaction: true }, - }); - - expect(result.txHash).equals(txHash); - expect(result.royaltyTokensCollected).equals(1); - }); - }); - describe("Test royaltyClient.payRoyaltyOnBehalf", async () => { it("should throw receiverIpId error when call payRoyaltyOnBehalf given receiverIpId is not registered", async () => { sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(false); @@ -205,6 +96,24 @@ describe("Test RoyaltyClient", () => { expect(result.txHash).equals(txHash); }); + + it("should return encodedData when call payRoyaltyOnBehalf given correct args and encodedTxDataOnly is true", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon.stub(royaltyClient.royaltyModuleClient, "payRoyaltyOnBehalfEncode").returns({ + data: "0x", + to: "0x", + }); + + const result = await royaltyClient.payRoyaltyOnBehalf({ + receiverIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + payerIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + token: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + amount: 1, + txOptions: { encodedTxDataOnly: true }, + }); + + expect(result.encodedTxData?.data).to.be.a("string").and.not.empty; + }); }); describe("Test royaltyClient.claimableRevenue", async () => { @@ -226,18 +135,20 @@ describe("Test RoyaltyClient", () => { }); it("should throw royaltyVaultAddress error when call claimableRevenue given royalty vault address is 0x", async () => { - sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); - sinon.stub(royaltyClient.royaltyPolicyLapClient, "getRoyaltyData").resolves([true, "0x", 1]); + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(false); + sinon + .stub(royaltyClient.royaltyModuleClient, "ipRoyaltyVaults") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); try { await royaltyClient.claimableRevenue({ - royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + royaltyVaultIpId: "0x", account: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", snapshotId: 1, token: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", }); } catch (err) { expect((err as Error).message).equals( - "Failed to calculate claimable revenue: The royalty vault IP with id 0x73fCB515cEE99e4991465ef586CfE2B072EbB512 address is not set.", + "Failed to calculate claimable revenue: request.royaltyVaultIpId address is invalid: 0x, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.", ); } }); @@ -245,8 +156,8 @@ describe("Test RoyaltyClient", () => { it("should return txHash when call claimableRevenue given correct args", async () => { sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); sinon - .stub(royaltyClient.royaltyPolicyLapClient, "getRoyaltyData") - .resolves([true, "0x73fcb515cee99e4991465ef586cfe2b072ebb512", 1]); + .stub(royaltyClient.royaltyModuleClient, "ipRoyaltyVaults") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); sinon.stub(IpRoyaltyVaultImplClient.prototype, "claimableRevenue").resolves(1); const result = await royaltyClient.claimableRevenue({ @@ -280,27 +191,45 @@ describe("Test RoyaltyClient", () => { it("should throw royaltyVaultAddress error when call claimRevenue given royalty vault address is 0x", async () => { sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); sinon - .stub(royaltyClient.royaltyPolicyLapClient, "getRoyaltyData") - .resolves([true, "0x73fcb515cee99e4991465ef586cfe2b072ebb512", 1]); + .stub(royaltyClient.royaltyModuleClient, "ipRoyaltyVaults") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); try { await royaltyClient.claimRevenue({ account: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", snapshotIds: [1], token: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", - royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + royaltyVaultIpId: "0x", }); } catch (err) { expect((err as Error).message).equals( - "Failed to claim revenue: The royalty vault IP with id 0x73fCB515cEE99e4991465ef586CfE2B072EbB512 address is not set.", + "Failed to claim revenue: request.royaltyVaultIpId address is invalid: 0x, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.", ); } }); + it("should return encodedData when call claimRevenue given correct args and encodedTxDataOnly is true", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(royaltyClient.royaltyModuleClient, "ipRoyaltyVaults") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); + sinon + .stub(royaltyClient.ipAccountClient, "execute") + .resolves({ encodedTxData: { data: "0x", to: "0x" } }); + + const result = await royaltyClient.claimRevenue({ + account: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + snapshotIds: [1], + token: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + txOptions: { encodedTxDataOnly: true }, + }); + expect(result.encodedTxData?.data).to.be.a("string").and.not.empty; + }); it("should return txHash when call claimRevenue given correct args", async () => { sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); sinon - .stub(royaltyClient.royaltyPolicyLapClient, "getRoyaltyData") - .resolves([true, "0x73fcb515cee99e4991465ef586cfe2b072ebb512", 1]); + .stub(royaltyClient.royaltyModuleClient, "ipRoyaltyVaults") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); sinon.stub(royaltyClient.ipAccountClient, "execute").resolves({ txHash }); const result = await royaltyClient.claimRevenue({ account: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", @@ -314,10 +243,10 @@ describe("Test RoyaltyClient", () => { it("should return txHash when call claimRevenue given correct args and waitForTransaction is true by ip account", async () => { sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); sinon - .stub(royaltyClient.royaltyPolicyLapClient, "getRoyaltyData") - .resolves([true, "0x73fcb515cee99e4991465ef586cfe2b072ebb512", 1]); + .stub(royaltyClient.royaltyModuleClient, "ipRoyaltyVaults") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); sinon - .stub(IpRoyaltyVaultImplClient.prototype, "claimRevenueBySnapshotBatch") + .stub(IpRoyaltyVaultImplClient.prototype, "claimRevenueOnBehalfBySnapshotBatch") .resolves(txHash); sinon.stub(royaltyClient.ipAccountClient, "execute").resolves({ txHash }); sinon.stub(IpRoyaltyVaultImplClient.prototype, "parseTxRevenueTokenClaimedEvent").returns([ @@ -343,10 +272,10 @@ describe("Test RoyaltyClient", () => { it("should return txHash when call claimRevenue given correct args and waitForTransaction is true by EOA", async () => { sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); sinon - .stub(royaltyClient.royaltyPolicyLapClient, "getRoyaltyData") - .resolves([true, "0x73fcb515cee99e4991465ef586cfe2b072ebb512", 1]); + .stub(royaltyClient.royaltyModuleClient, "ipRoyaltyVaults") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); sinon - .stub(IpRoyaltyVaultImplClient.prototype, "claimRevenueBySnapshotBatch") + .stub(IpRoyaltyVaultImplClient.prototype, "claimRevenueOnBehalfBySnapshotBatch") .resolves(txHash); sinon.stub(royaltyClient.ipAccountClient, "execute").resolves({ txHash }); sinon.stub(IpRoyaltyVaultImplClient.prototype, "parseTxRevenueTokenClaimedEvent").returns([ @@ -367,6 +296,24 @@ describe("Test RoyaltyClient", () => { expect(result.txHash).equals(txHash); expect(result.claimableToken).equals(1); }); + it("should return encodedData when call claimRevenue given correct args and encodedTxDataOnly is true by EOA", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(royaltyClient.royaltyModuleClient, "ipRoyaltyVaults") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); + sinon + .stub(IpRoyaltyVaultImplClient.prototype, "claimRevenueOnBehalfBySnapshotBatchEncode") + .returns({ data: "0x", to: "0x" }); + + const result = await royaltyClient.claimRevenue({ + snapshotIds: [1], + token: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + txOptions: { encodedTxDataOnly: true }, + }); + + expect(result.encodedTxData?.data).to.be.a("string").and.not.empty; + }); }); describe("Test royaltyClient.snapshot", async () => { @@ -386,14 +333,16 @@ describe("Test RoyaltyClient", () => { it("should throw royaltyVaultAddress error when call snapshot given royalty vault address is 0x", async () => { sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); - sinon.stub(royaltyClient.royaltyPolicyLapClient, "getRoyaltyData").resolves([true, "0x", 1]); + sinon + .stub(royaltyClient.royaltyModuleClient, "ipRoyaltyVaults") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); try { await royaltyClient.snapshot({ - royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + royaltyVaultIpId: "0x", }); } catch (err) { expect((err as Error).message).equals( - "Failed to snapshot: The royalty vault IP with id 0x73fCB515cEE99e4991465ef586CfE2B072EbB512 address is not set.", + "Failed to snapshot: request.royaltyVaultIpId address is invalid: 0x, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.", ); } }); @@ -401,8 +350,8 @@ describe("Test RoyaltyClient", () => { it("should return txHash when call snapshot given correct args", async () => { sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); sinon - .stub(royaltyClient.royaltyPolicyLapClient, "getRoyaltyData") - .resolves([true, "0x73fcb515cee99e4991465ef586cfe2b072ebb512", 1]); + .stub(royaltyClient.royaltyModuleClient, "ipRoyaltyVaults") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); sinon.stub(IpRoyaltyVaultImplClient.prototype, "snapshot").resolves(txHash); const result = await royaltyClient.snapshot({ @@ -414,8 +363,8 @@ describe("Test RoyaltyClient", () => { it("should return txHash when call snapshot given correct args and waitForTransaction is true", async () => { sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); sinon - .stub(royaltyClient.royaltyPolicyLapClient, "getRoyaltyData") - .resolves([true, "0x73fcb515cee99e4991465ef586cfe2b072ebb512", 1]); + .stub(royaltyClient.royaltyModuleClient, "ipRoyaltyVaults") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); sinon.stub(IpRoyaltyVaultImplClient.prototype, "snapshot").resolves(txHash); sinon.stub(IpRoyaltyVaultImplClient.prototype, "parseTxSnapshotCompletedEvent").returns([ { @@ -433,5 +382,445 @@ describe("Test RoyaltyClient", () => { expect(result.txHash).equals(txHash); expect(result.snapshotId).equals(1); }); + + it("should return encodedData when call snapshot given correct args and encodedTxDataOnly is true", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(royaltyClient.royaltyModuleClient, "ipRoyaltyVaults") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); + sinon + .stub(IpRoyaltyVaultImplClient.prototype, "snapshotEncode") + .returns({ data: "0x", to: "0x" }); + + const result = await royaltyClient.snapshot({ + royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + txOptions: { encodedTxDataOnly: true }, + }); + + expect(result.encodedTxData?.data).to.be.a("string").and.not.empty; + }); + }); + + describe("Test royaltyClient.snapshotAndClaimBySnapshotBatch", async () => { + it("it should throw royaltyVaultIpId error when call snapshotAndClaimBySnapshotBatch given royaltyVaultIpId is not registered", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(false); + + try { + await royaltyClient.snapshotAndClaimBySnapshotBatch({ + royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + unclaimedSnapshotIds: [1], + currencyTokens: ["0x73fcb515cee99e4991465ef586cfe2b072ebb512"], + }); + } catch (err) { + expect((err as Error).message).equals( + "Failed to snapshot and claim by snapshot batch: The royalty vault IP with id 0x73fcb515cee99e4991465ef586cfe2b072ebb512 is not registered.", + ); + } + }); + it("should return encodedData when call snapshotAndClaimBySnapshotBatch given correct args and encodedTxDataOnly is true", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(royaltyClient.royaltyModuleClient, "ipRoyaltyVaults") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); + sinon.stub(royaltyClient.ipAccountClient, "execute").resolves({ txHash }); + + const result = await royaltyClient.snapshotAndClaimBySnapshotBatch({ + royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + unclaimedSnapshotIds: [1], + currencyTokens: ["0x73fcb515cee99e4991465ef586cfe2b072ebb512"], + txOptions: { encodedTxDataOnly: true }, + }); + + expect(result.encodedTxData?.data).to.be.a("string").and.not.empty; + }); + it("should return txHash when call snapshotAndClaimBySnapshotBatch given correct args", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(royaltyClient.royaltyWorkflowsClient, "snapshotAndClaimBySnapshotBatch") + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + + const result = await royaltyClient.snapshotAndClaimBySnapshotBatch({ + royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + unclaimedSnapshotIds: [1], + currencyTokens: ["0x73fcb515cee99e4991465ef586cfe2b072ebb512"], + }); + + expect(result.txHash).equals(txHash); + }); + + it("should return txHash when call snapshotAndClaimBySnapshotBatch given correct args and waitForTransaction is true", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(royaltyClient.royaltyWorkflowsClient, "snapshotAndClaimBySnapshotBatch") + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + sinon + .stub(royaltyClient.ipRoyaltyVaultImplEventClient, "parseTxRevenueTokenClaimedEvent") + .returns([ + { + claimer: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + token: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + amount: 1n, + }, + ]); + sinon + .stub(royaltyClient.ipRoyaltyVaultImplEventClient, "parseTxSnapshotCompletedEvent") + .returns([ + { + snapshotId: 1n, + snapshotTimestamp: 1n, + }, + ]); + + const result = await royaltyClient.snapshotAndClaimBySnapshotBatch({ + royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + unclaimedSnapshotIds: [1], + currencyTokens: ["0x73fcb515cee99e4991465ef586cfe2b072ebb512"], + claimer: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + txOptions: { waitForTransaction: true }, + }); + + expect(result.txHash).equals(txHash); + expect(result.snapshotId).equals(1n); + expect(result.amountsClaimed).equals(1n); + }); + }); + + describe("Test royaltyClient.transferToVaultAndSnapshotAndClaimByTokenBatch", async () => { + it("should throw royaltyClaimDetails error when call transferToVaultAndSnapshotAndClaimByTokenBatch given royaltyClaimDetails is empty", async () => { + try { + await royaltyClient.transferToVaultAndSnapshotAndClaimByTokenBatch({ + royaltyClaimDetails: [], + ancestorIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + }); + } catch (err) { + expect((err as Error).message).equals( + "Failed to transfer to vault and snapshot and claim by token batch: The royaltyClaimDetails must provide at least one item.", + ); + } + }); + + it("should throw ancestorIpId error when call transferToVaultAndSnapshotAndClaimByTokenBatch given ancestorIpId is not registered", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(false); + + try { + await royaltyClient.transferToVaultAndSnapshotAndClaimByTokenBatch({ + royaltyClaimDetails: [ + { + childIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + royaltyPolicy: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + currencyToken: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + amount: 1, + }, + ], + ancestorIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + }); + } catch (err) { + expect((err as Error).message).equals( + "Failed to transfer to vault and snapshot and claim by token batch: The ancestor IP with id 0x73fcb515cee99e4991465ef586cfe2b072ebb512 is not registered.", + ); + } + }); + + it("should return encodedData when call transferToVaultAndSnapshotAndClaimByTokenBatch given correct args and encodedTxDataOnly is true", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub( + royaltyClient.royaltyWorkflowsClient, + "transferToVaultAndSnapshotAndClaimByTokenBatchEncode", + ) + .returns({ data: "0x", to: "0x" }); + const result = await royaltyClient.transferToVaultAndSnapshotAndClaimByTokenBatch({ + royaltyClaimDetails: [ + { + childIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + royaltyPolicy: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + currencyToken: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + amount: 1, + }, + ], + ancestorIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + claimer: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + txOptions: { encodedTxDataOnly: true }, + }); + + expect(result.encodedTxData?.data).equals("0x"); + }); + + it("should return txHash when call transferToVaultAndSnapshotAndClaimByTokenBatch given correct args", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub( + royaltyClient.royaltyWorkflowsClient, + "transferToVaultAndSnapshotAndClaimByTokenBatch", + ) + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + + const result = await royaltyClient.transferToVaultAndSnapshotAndClaimByTokenBatch({ + royaltyClaimDetails: [ + { + childIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + royaltyPolicy: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + currencyToken: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + amount: 1, + }, + ], + ancestorIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + }); + + expect(result.txHash).equals(txHash); + }); + + it("should return txHash when call transferToVaultAndSnapshotAndClaimByTokenBatch given correct args and waitForTransaction is true", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub( + royaltyClient.royaltyWorkflowsClient, + "transferToVaultAndSnapshotAndClaimByTokenBatch", + ) + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + sinon + .stub(royaltyClient.ipRoyaltyVaultImplEventClient, "parseTxRevenueTokenClaimedEvent") + .returns([ + { + claimer: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + token: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + amount: 1n, + }, + ]); + sinon + .stub(royaltyClient.ipRoyaltyVaultImplEventClient, "parseTxSnapshotCompletedEvent") + .returns([ + { + snapshotId: 1n, + snapshotTimestamp: 1n, + }, + ]); + const result = await royaltyClient.transferToVaultAndSnapshotAndClaimByTokenBatch({ + royaltyClaimDetails: [ + { + childIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + royaltyPolicy: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + currencyToken: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + amount: 1, + }, + ], + ancestorIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + txOptions: { waitForTransaction: true }, + }); + + expect(result.txHash).equals(txHash); + expect(result.snapshotId).equals(1n); + expect(result.amountsClaimed).equals(1n); + }); + }); + + describe("Test royaltyClient.transferToVaultAndSnapshotAndClaimBySnapshotBatch", async () => { + it("should throw royaltyClaimDetails error when call transferToVaultAndSnapshotAndClaimBySnapshotBatch given royaltyClaimDetails is empty", async () => { + try { + await royaltyClient.transferToVaultAndSnapshotAndClaimBySnapshotBatch({ + royaltyClaimDetails: [], + ancestorIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + unclaimedSnapshotIds: [1], + }); + } catch (err) { + expect((err as Error).message).equals( + "Failed to transfer to vault and snapshot and claim by snapshot batch: The royaltyClaimDetails must provide at least one item.", + ); + } + }); + + it("should throw ancestorIpId error when call transferToVaultAndSnapshotAndClaimBySnapshotBatch given ancestorIpId is not registered", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(false); + + try { + await royaltyClient.transferToVaultAndSnapshotAndClaimBySnapshotBatch({ + royaltyClaimDetails: [ + { + childIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + royaltyPolicy: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + currencyToken: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + amount: 1, + }, + ], + ancestorIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + unclaimedSnapshotIds: [1], + }); + } catch (err) { + expect((err as Error).message).equals( + "Failed to transfer to vault and snapshot and claim by snapshot batch: The ancestor IP with id 0x73fcb515cee99e4991465ef586cfe2b072ebb512 is not registered.", + ); + } + }); + + it("should return encodedData when call transferToVaultAndSnapshotAndClaimBySnapshotBatch given correct args and encodedTxDataOnly is true", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub( + royaltyClient.royaltyWorkflowsClient, + "transferToVaultAndSnapshotAndClaimBySnapshotBatchEncode", + ) + .returns({ data: "0x", to: "0x" }); + const result = await royaltyClient.transferToVaultAndSnapshotAndClaimBySnapshotBatch({ + royaltyClaimDetails: [ + { + childIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + royaltyPolicy: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + currencyToken: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + amount: 1, + }, + ], + ancestorIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + unclaimedSnapshotIds: [1], + txOptions: { encodedTxDataOnly: true }, + }); + expect(result.encodedTxData?.data).equals("0x"); + }); + + it("should return txHash when call transferToVaultAndSnapshotAndClaimBySnapshotBatch given correct args", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub( + royaltyClient.royaltyWorkflowsClient, + "transferToVaultAndSnapshotAndClaimBySnapshotBatch", + ) + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + + const result = await royaltyClient.transferToVaultAndSnapshotAndClaimBySnapshotBatch({ + royaltyClaimDetails: [ + { + childIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + royaltyPolicy: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + currencyToken: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + amount: 1, + }, + ], + ancestorIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + unclaimedSnapshotIds: [1], + claimer: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + }); + + expect(result.txHash).equals(txHash); + }); + + it("should return txHash when call transferToVaultAndSnapshotAndClaimBySnapshotBatch given correct args and waitForTransaction is true", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub( + royaltyClient.royaltyWorkflowsClient, + "transferToVaultAndSnapshotAndClaimBySnapshotBatch", + ) + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + sinon + .stub(royaltyClient.ipRoyaltyVaultImplEventClient, "parseTxRevenueTokenClaimedEvent") + .returns([ + { + claimer: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + token: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + amount: 1n, + }, + ]); + sinon + .stub(royaltyClient.ipRoyaltyVaultImplEventClient, "parseTxSnapshotCompletedEvent") + .returns([ + { + snapshotId: 1n, + snapshotTimestamp: 1n, + }, + ]); + + const result = await royaltyClient.transferToVaultAndSnapshotAndClaimBySnapshotBatch({ + royaltyClaimDetails: [ + { + childIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + royaltyPolicy: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + currencyToken: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + amount: 1, + }, + ], + ancestorIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + unclaimedSnapshotIds: [1], + txOptions: { waitForTransaction: true }, + }); + }); + }); + + describe("Test royaltyClient.snapshotAndClaimByTokenBatch", async () => { + it("should throw ip register error when call snapshotAndClaimByTokenBatch given ip is not registered", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(false); + + try { + await royaltyClient.snapshotAndClaimByTokenBatch({ + royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + currencyTokens: ["0x73fcb515cee99e4991465ef586cfe2b072ebb512"], + }); + } catch (err) { + expect((err as Error).message).equals( + "Failed to snapshot and claim by token batch: The royalty vault IP with id 0x73fcb515cee99e4991465ef586cfe2b072ebb512 is not registered.", + ); + } + }); + + it("should return txHash when call snapshotAndClaimByTokenBatch given correct args", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(royaltyClient.royaltyWorkflowsClient, "snapshotAndClaimByTokenBatch") + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + + const result = await royaltyClient.snapshotAndClaimByTokenBatch({ + royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + currencyTokens: ["0x73fcb515cee99e4991465ef586cfe2b072ebb512"], + }); + + expect(result.txHash).equals(txHash); + }); + + it("should return txHash when call snapshotAndClaimByTokenBatch given correct args and waitForTransaction is true", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(royaltyClient.royaltyWorkflowsClient, "snapshotAndClaimByTokenBatch") + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + sinon + .stub(royaltyClient.ipRoyaltyVaultImplEventClient, "parseTxRevenueTokenClaimedEvent") + .returns([ + { + claimer: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + token: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + amount: 1n, + }, + ]); + sinon + .stub(royaltyClient.ipRoyaltyVaultImplEventClient, "parseTxSnapshotCompletedEvent") + .returns([ + { + snapshotId: 1n, + snapshotTimestamp: 1n, + }, + ]); + + const result = await royaltyClient.snapshotAndClaimByTokenBatch({ + royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + currencyTokens: ["0x73fcb515cee99e4991465ef586cfe2b072ebb512"], + claimer: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + txOptions: { waitForTransaction: true }, + }); + + expect(result.txHash).equals(txHash); + expect(result.snapshotId).equals(1n); + expect(result.amountsClaimed).equals(1n); + }); + + it("should return encodedData when call snapshotAndClaimByTokenBatch given correct args and encodedTxDataOnly is true", async () => { + sinon.stub(royaltyClient.ipAssetRegistryClient, "isRegistered").resolves(true); + sinon + .stub(royaltyClient.royaltyWorkflowsClient, "snapshotAndClaimByTokenBatchEncode") + .returns({ data: "0x", to: "0x" }); + const result = await royaltyClient.snapshotAndClaimByTokenBatch({ + royaltyVaultIpId: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + currencyTokens: ["0x73fcb515cee99e4991465ef586cfe2b072ebb512"], + txOptions: { encodedTxDataOnly: true }, + }); + + expect(result.encodedTxData?.data).equals("0x"); + }); }); }); diff --git a/packages/core-sdk/test/unit/utils/getLicenseTermsByType.test.ts b/packages/core-sdk/test/unit/utils/getLicenseTermsByType.test.ts deleted file mode 100644 index 84ee0f97..00000000 --- a/packages/core-sdk/test/unit/utils/getLicenseTermsByType.test.ts +++ /dev/null @@ -1,208 +0,0 @@ -import { Hex, zeroAddress } from "viem"; -import { PIL_TYPE } from "../../../src/types/resources/license"; -import { getLicenseTermByType } from "../../../src/utils/getLicenseTermsByType"; -import { expect } from "chai"; - -describe("Get License Terms By Type", () => { - it("it should return no commercial license terms when call getLicenseTermByType given NON_COMMERCIAL_REMIX", async () => { - const result = getLicenseTermByType(PIL_TYPE.NON_COMMERCIAL_REMIX); - expect(result).to.deep.include({ - transferable: true, - commercialAttribution: false, - commercialRevCeiling: 0n, - commercialRevShare: 0, - commercialUse: false, - commercializerChecker: "0x0000000000000000000000000000000000000000", - commercializerCheckerData: "0x", - currency: "0x0000000000000000000000000000000000000000", - derivativeRevCeiling: 0n, - derivativesAllowed: true, - derivativesApproval: false, - derivativesAttribution: true, - derivativesReciprocal: true, - expiration: 0n, - defaultMintingFee: 0n, - royaltyPolicy: "0x0000000000000000000000000000000000000000", - uri: "", - }); - }); - - describe("Get Commercial License Terms", () => { - it("it should throw when call getLicenseTermByType given COMMERCIAL_USE without terms", async () => { - expect(() => getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE)).to.throw( - "MintingFee currency are required for commercial use PIL.", - ); - }); - - it("it should throw when call getLicenseTermByType given COMMERCIAL_USE without mintFee", async () => { - expect(() => - getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE, { - currency: zeroAddress, - royaltyPolicyLAPAddress: zeroAddress, - }), - ).to.throw("MintingFee currency are required for commercial use PIL."); - }); - - it("it should throw when call getLicenseTermByType given COMMERCIAL_USE without currency", async () => { - expect(() => - getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE, { - royaltyPolicyLAPAddress: zeroAddress, - defaultMintingFee: "1", - }), - ).to.throw("MintingFee currency are required for commercial use PIL."); - }); - - it("it should throw when call getLicenseTermByType given COMMERCIAL_USE and wrong royaltyAddress", async () => { - expect(() => - getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE, { - royaltyPolicyLAPAddress: "wrong" as Hex, - defaultMintingFee: "1", - currency: zeroAddress, - }), - ).to.throw(`Address "wrong" is invalid.`); - }); - - 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, - defaultMintingFee: "1", - currency: zeroAddress, - }); - expect(result).to.deep.contain({ - commercialAttribution: true, - commercialRevCeiling: 0n, - commercialRevShare: 0, - commercialUse: true, - commercializerChecker: "0x0000000000000000000000000000000000000000", - commercializerCheckerData: "0x0000000000000000000000000000000000000000", - currency: "0x0000000000000000000000000000000000000000", - derivativeRevCeiling: 0n, - derivativesAllowed: true, - derivativesApproval: false, - derivativesAttribution: true, - derivativesReciprocal: false, - expiration: 0n, - defaultMintingFee: 1n, - royaltyPolicy: "0x0000000000000000000000000000000000000000", - transferable: true, - uri: "", - }); - }); - }); - - describe("Get Commercial remix License Terms", () => { - it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX without terms", async () => { - expect(() => getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX)).to.throw( - "MintingFee, currency and commercialRevShare are required for commercial remix PIL.", - ); - }); - - it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX without mintFee", async () => { - expect(() => - getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { - currency: zeroAddress, - royaltyPolicyLAPAddress: zeroAddress, - commercialRevShare: 100, - }), - ).to.throw( - "MintingFee, currency and commercialRevShare are required for commercial remix PIL.", - ); - }); - - it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX without currency", async () => { - expect(() => - getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { - royaltyPolicyLAPAddress: zeroAddress, - defaultMintingFee: "1", - commercialRevShare: 100, - }), - ).to.throw( - "MintingFee, currency and commercialRevShare are required for commercial remix PIL.", - ); - }); - - it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX and wrong royaltyAddress", async () => { - expect(() => - getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { - royaltyPolicyLAPAddress: "wrong" as Hex, - defaultMintingFee: "1", - currency: zeroAddress, - commercialRevShare: 100, - }), - ).to.throw(`Address "wrong" is invalid.`); - }); - - it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX without commercialRevShare ", async () => { - expect(() => - getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { - royaltyPolicyLAPAddress: "wrong" as Hex, - defaultMintingFee: "1", - currency: zeroAddress, - }), - ).to.throw( - `MintingFee, currency and commercialRevShare are required for commercial remix PIL.`, - ); - }); - - 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, - defaultMintingFee: "1", - currency: zeroAddress, - commercialRevShare: 100, - }); - expect(result).to.deep.contain({ - commercialAttribution: true, - commercialRevCeiling: 0n, - commercialRevShare: 100000000, - commercialUse: true, - commercializerChecker: "0x0000000000000000000000000000000000000000", - commercializerCheckerData: "0x0000000000000000000000000000000000000000", - currency: "0x0000000000000000000000000000000000000000", - derivativeRevCeiling: 0n, - derivativesAllowed: true, - derivativesApproval: false, - derivativesAttribution: true, - derivativesReciprocal: true, - expiration: 0n, - defaultMintingFee: 1n, - royaltyPolicy: "0x0000000000000000000000000000000000000000", - transferable: true, - uri: "", - }); - }); - 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, - defaultMintingFee: "1", - currency: zeroAddress, - commercialRevShare: -8, - }), - ).to.throw(`CommercialRevShare should be between 0 and 100.`); - }); - - 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, - defaultMintingFee: "1", - currency: zeroAddress, - commercialRevShare: 105, - }), - ).to.throw(`CommercialRevShare should be between 0 and 100.`); - }); - - 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, - defaultMintingFee: "1", - currency: zeroAddress, - commercialRevShare: 10, - }); - expect(result).to.contains({ - commercialRevShare: 10000000, - }); - }); - }); -}); diff --git a/packages/core-sdk/test/unit/utils/licenseTermsHelper.test.ts b/packages/core-sdk/test/unit/utils/licenseTermsHelper.test.ts new file mode 100644 index 00000000..dd47dbb3 --- /dev/null +++ b/packages/core-sdk/test/unit/utils/licenseTermsHelper.test.ts @@ -0,0 +1,509 @@ +import { Hex, PublicClient, zeroAddress } from "viem"; +import { LicenseTerms, PIL_TYPE } from "../../../src/types/resources/license"; +import { getLicenseTermByType, validateLicenseTerms } from "../../../src/utils/licenseTermsHelper"; +import { expect } from "chai"; +import { MockERC20 } from "../../integration/utils/mockERC20"; +import sinon from "sinon"; +import { createMock } from "../testUtils"; +const { RoyaltyModuleReadOnlyClient } = require("../../../src/abi/generated"); + +describe("License Terms Helper", () => { + describe("getLicenseTermByType", () => { + it("it should return no commercial license terms when call getLicenseTermByType given NON_COMMERCIAL_REMIX", async () => { + const result = getLicenseTermByType(PIL_TYPE.NON_COMMERCIAL_REMIX); + expect(result).to.deep.include({ + transferable: true, + commercialAttribution: false, + commercialRevCeiling: 0n, + commercialRevShare: 0, + commercialUse: false, + commercializerChecker: "0x0000000000000000000000000000000000000000", + commercializerCheckerData: "0x", + currency: "0x0000000000000000000000000000000000000000", + derivativeRevCeiling: 0n, + derivativesAllowed: true, + derivativesApproval: false, + derivativesAttribution: true, + derivativesReciprocal: true, + expiration: 0n, + defaultMintingFee: 0n, + royaltyPolicy: "0x0000000000000000000000000000000000000000", + uri: "", + }); + }); + + describe("Get Commercial License Terms", () => { + it("it should throw when call getLicenseTermByType given COMMERCIAL_USE without terms", async () => { + expect(() => getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE)).to.throw( + "DefaultMintingFee, currency are required for commercial use PIL.", + ); + }); + + it("it should throw when call getLicenseTermByType given COMMERCIAL_USE without mintFee", async () => { + expect(() => + getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE, { + currency: zeroAddress, + royaltyPolicyLAPAddress: zeroAddress, + }), + ).to.throw("DefaultMintingFee, currency are required for commercial use PIL."); + }); + + it("it should throw when call getLicenseTermByType given COMMERCIAL_USE without currency", async () => { + expect(() => + getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE, { + royaltyPolicyLAPAddress: zeroAddress, + defaultMintingFee: "1", + }), + ).to.throw("DefaultMintingFee, currency are required for commercial use PIL."); + }); + + it("it should throw when call getLicenseTermByType given COMMERCIAL_USE and wrong royaltyAddress", async () => { + expect(() => + getLicenseTermByType(PIL_TYPE.COMMERCIAL_USE, { + royaltyPolicyLAPAddress: "wrong" as Hex, + defaultMintingFee: "1", + currency: zeroAddress, + }), + ).to.throw( + `term.royaltyPolicyLAPAddress address is invalid: wrong, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.`, + ); + }); + + 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, + defaultMintingFee: "1", + currency: zeroAddress, + }); + expect(result).to.deep.contain({ + commercialAttribution: true, + commercialRevCeiling: 0n, + commercialRevShare: 0, + commercialUse: true, + commercializerChecker: "0x0000000000000000000000000000000000000000", + commercializerCheckerData: "0x0000000000000000000000000000000000000000", + currency: "0x0000000000000000000000000000000000000000", + derivativeRevCeiling: 0n, + derivativesAllowed: true, + derivativesApproval: false, + derivativesAttribution: true, + derivativesReciprocal: false, + expiration: 0n, + defaultMintingFee: 1n, + royaltyPolicy: "0x0000000000000000000000000000000000000000", + transferable: true, + uri: "", + }); + }); + }); + + describe("Get Commercial remix License Terms", () => { + it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX without terms", async () => { + expect(() => getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX)).to.throw( + "MintingFee, currency and commercialRevShare are required for commercial remix PIL.", + ); + }); + + it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX without mintFee", async () => { + expect(() => + getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { + currency: zeroAddress, + royaltyPolicyLAPAddress: zeroAddress, + commercialRevShare: 100, + }), + ).to.throw( + "MintingFee, currency and commercialRevShare are required for commercial remix PIL.", + ); + }); + + it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX without currency", async () => { + expect(() => + getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { + royaltyPolicyLAPAddress: zeroAddress, + defaultMintingFee: "1", + commercialRevShare: 100, + }), + ).to.throw( + "MintingFee, currency and commercialRevShare are required for commercial remix PIL.", + ); + }); + + it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX and wrong royaltyAddress", async () => { + expect(() => + getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { + royaltyPolicyLAPAddress: "wrong" as Hex, + defaultMintingFee: "1", + currency: zeroAddress, + commercialRevShare: 100, + }), + ).to.throw( + `term.royaltyPolicyLAPAddress address is invalid: wrong, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.`, + ); + }); + + it("it should throw when call getLicenseTermByType given COMMERCIAL_REMIX without commercialRevShare ", async () => { + expect(() => + getLicenseTermByType(PIL_TYPE.COMMERCIAL_REMIX, { + royaltyPolicyLAPAddress: "wrong" as Hex, + defaultMintingFee: "1", + currency: zeroAddress, + }), + ).to.throw( + `MintingFee, currency and commercialRevShare are required for commercial remix PIL.`, + ); + }); + + 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, + defaultMintingFee: "1", + currency: zeroAddress, + commercialRevShare: 100, + }); + expect(result).to.deep.contain({ + commercialAttribution: true, + commercialRevCeiling: 0n, + commercialRevShare: 100000000, + commercialUse: true, + commercializerChecker: "0x0000000000000000000000000000000000000000", + commercializerCheckerData: "0x0000000000000000000000000000000000000000", + currency: "0x0000000000000000000000000000000000000000", + derivativeRevCeiling: 0n, + derivativesAllowed: true, + derivativesApproval: false, + derivativesAttribution: true, + derivativesReciprocal: true, + expiration: 0n, + defaultMintingFee: 1n, + royaltyPolicy: "0x0000000000000000000000000000000000000000", + transferable: true, + uri: "", + }); + }); + 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, + defaultMintingFee: "1", + currency: zeroAddress, + commercialRevShare: -8, + }), + ).to.throw(`CommercialRevShare should be between 0 and 100.`); + }); + + 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, + defaultMintingFee: "1", + currency: zeroAddress, + commercialRevShare: 105, + }), + ).to.throw(`CommercialRevShare should be between 0 and 100.`); + }); + + 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, + defaultMintingFee: "1", + currency: zeroAddress, + commercialRevShare: 10, + }); + expect(result).to.contains({ + commercialRevShare: 10000000, + }); + }); + }); + }); + + describe("validateLicenseTerms", () => { + let rpcMock: PublicClient; + beforeEach(() => { + rpcMock = createMock(); + }); + const licenseTerms: LicenseTerms = { + defaultMintingFee: 1513n, + currency: MockERC20.address, + royaltyPolicy: zeroAddress, + transferable: false, + expiration: 0n, + commercialUse: false, + commercialAttribution: false, + commercializerChecker: zeroAddress, + commercializerCheckerData: "0x", + commercialRevShare: 0, + commercialRevCeiling: 0n, + derivativesAllowed: false, + derivativesAttribution: false, + derivativesApproval: false, + derivativesReciprocal: false, + derivativeRevCeiling: 0n, + uri: "", + }; + + it("should throw royalty error when call registerRILTerms with invalid royalty policy address", async () => { + await expect( + validateLicenseTerms( + { + ...licenseTerms, + royaltyPolicy: "0x", + }, + rpcMock, + ), + ).to.be.rejectedWith( + "params.royaltyPolicy address is invalid: 0x, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.", + ); + }); + + it("should throw royalty whitelist error when call registerRILTerms with invalid royalty whitelist address", async () => { + RoyaltyModuleReadOnlyClient.prototype.isWhitelistedRoyaltyPolicy = sinon + .stub() + .resolves(false); + await expect( + validateLicenseTerms( + { + ...licenseTerms, + royaltyPolicy: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }, + rpcMock, + ), + ).to.be.rejectedWith("The royalty policy is not whitelisted."); + }); + + it("should throw currency error when call registerRILTerms with invalid currency address", async () => { + RoyaltyModuleReadOnlyClient.prototype.isWhitelistedRoyaltyPolicy = sinon + .stub() + .resolves(false); + await expect( + validateLicenseTerms( + { + ...licenseTerms, + currency: "0x", + }, + rpcMock, + ), + ).to.be.rejectedWith( + "params.currency address is invalid: 0x, Address must be a hex value of 20 bytes (40 hex characters) and match its checksum counterpart.", + ); + }); + + it("should throw currency whitelist error when call registerRILTerms with invalid currency whitelist address", async () => { + RoyaltyModuleReadOnlyClient.prototype.isWhitelistedRoyaltyPolicy = sinon + .stub() + .resolves(false); + RoyaltyModuleReadOnlyClient.prototype.isWhitelistedRoyaltyToken = sinon + .stub() + .resolves(false); + await expect( + validateLicenseTerms( + { + ...licenseTerms, + currency: MockERC20.address, + }, + rpcMock, + ), + ).to.be.rejectedWith("The currency token is not whitelisted."); + }); + + it("should throw royalty policy requires currency token error when call registerRILTerms given royaltyPolicy is not zero address and current is zero address", async () => { + RoyaltyModuleReadOnlyClient.prototype.isWhitelistedRoyaltyPolicy = sinon + .stub() + .resolves(true); + RoyaltyModuleReadOnlyClient.prototype.isWhitelistedRoyaltyToken = sinon.stub().resolves(true); + await expect( + validateLicenseTerms( + { + ...licenseTerms, + currency: zeroAddress, + royaltyPolicy: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }, + rpcMock, + ), + ).to.be.rejectedWith("Royalty policy requires currency token."); + }); + + describe("verify commercial use", () => { + beforeEach(() => { + RoyaltyModuleReadOnlyClient.prototype.isWhitelistedRoyaltyPolicy = sinon + .stub() + .resolves(true); + RoyaltyModuleReadOnlyClient.prototype.isWhitelistedRoyaltyToken = sinon + .stub() + .resolves(true); + }); + it("should throw commercialAttribution error when call registerRILTerms given commercialUse is false and commercialAttribution is true", async () => { + await expect( + validateLicenseTerms( + { + ...licenseTerms, + commercialUse: false, + commercialAttribution: true, + }, + rpcMock, + ), + ).to.be.rejectedWith("Cannot add commercial attribution when commercial use is disabled."); + }); + + it("should throw commercializerChecker error when call registerRILTerms given commercialUse is false and commercialChecker is not zero address", async () => { + await expect( + validateLicenseTerms( + { + ...licenseTerms, + commercialUse: false, + commercializerChecker: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }, + rpcMock, + ), + ).to.be.rejectedWith("Cannot add commercializerChecker when commercial use is disabled."); + }); + it("should throw commercialRevShare error when call registerRILTerms given commercialUse is false and commercialRevShare is more than 0 ", async () => { + await expect( + validateLicenseTerms( + { + ...licenseTerms, + commercialUse: false, + commercializerChecker: zeroAddress, + commercialRevShare: 1, + }, + rpcMock, + ), + ).to.be.rejectedWith( + "Cannot add commercial revenue share when commercial use is disabled.", + ); + }); + + it("should throw commercialRevCeiling error when call registerRILTerms given commercialUse is false and commercialRevCeiling is more than 0", async () => { + await expect( + validateLicenseTerms( + { + ...licenseTerms, + commercialUse: false, + commercialRevCeiling: 1, + commercializerChecker: zeroAddress, + }, + rpcMock, + ), + ).to.be.rejectedWith( + "Cannot add commercial revenue ceiling when commercial use is disabled.", + ); + }); + + it("should throw derivativeRevCeiling error when call registerRILTerms given commercialUse is false and derivativeRevCeiling is more than 0", async () => { + await expect( + validateLicenseTerms( + { + ...licenseTerms, + commercialUse: false, + derivativeRevCeiling: 1, + commercializerChecker: zeroAddress, + }, + rpcMock, + ), + ).to.be.rejectedWith( + "Cannot add derivative revenue ceiling share when commercial use is disabled.", + ); + }); + + it("should throw royaltyPolicy error when call registerRILTerms given commercialUse is false and royaltyPolicy is not zero address", async () => { + await expect( + validateLicenseTerms( + { + ...licenseTerms, + commercialUse: false, + royaltyPolicy: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + commercializerChecker: zeroAddress, + }, + rpcMock, + ), + ).to.be.rejectedWith( + "Cannot add commercial royalty policy when commercial use is disabled.", + ); + }); + + it("should throw royaltyPolicy error when call registerRILTerms given commercialUse is true and royaltyPolicy is zero address", async () => { + await expect( + validateLicenseTerms( + { + ...licenseTerms, + commercialUse: true, + royaltyPolicy: zeroAddress, + }, + rpcMock, + ), + ).to.be.rejectedWith("Royalty policy is required when commercial use is enabled."); + }); + }); + + describe("verify derivatives", () => { + beforeEach(() => { + RoyaltyModuleReadOnlyClient.prototype.isWhitelistedRoyaltyPolicy = sinon + .stub() + .resolves(true); + RoyaltyModuleReadOnlyClient.prototype.isWhitelistedRoyaltyToken = sinon + .stub() + .resolves(true); + }); + it("should throw derivativesAttribution error when call registerRILTerms given derivativesAllowed is false and derivativesAttribution is true", async () => { + await expect( + validateLicenseTerms( + { + ...licenseTerms, + commercialUse: true, + derivativesAllowed: false, + derivativesAttribution: true, + royaltyPolicy: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }, + rpcMock, + ), + ).to.be.rejectedWith("Cannot add derivative attribution when derivative use is disabled."); + }); + + it("should throw derivativesApproval error when call registerRILTerms given derivativesAllowed is false and derivativesApproval is true", async () => { + await expect( + validateLicenseTerms( + { + ...licenseTerms, + commercialUse: true, + derivativesAllowed: false, + derivativesApproval: true, + royaltyPolicy: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }, + rpcMock, + ), + ).to.be.rejectedWith("Cannot add derivative approval when derivative use is disabled."); + }); + + it("should throw derivativesReciprocal error when call registerRILTerms given derivativesAllowed is false and derivativesReciprocal is true", async () => { + await expect( + validateLicenseTerms( + { + ...licenseTerms, + commercialUse: true, + derivativesAllowed: false, + derivativesReciprocal: true, + royaltyPolicy: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }, + rpcMock, + ), + ).to.be.rejectedWith("Cannot add derivative reciprocal when derivative use is disabled."); + }); + + it("should throw derivativeRevCeiling error when call registerRILTerms given derivativesAllowed is false and derivativeRevCeiling is more than 0", async () => { + await expect( + validateLicenseTerms( + { + ...licenseTerms, + commercialUse: true, + derivativesAllowed: false, + derivativeRevCeiling: 1, + royaltyPolicy: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }, + rpcMock, + ), + ).to.be.rejectedWith( + "Cannot add derivative revenue ceiling when derivative use is disabled.", + ); + }); + }); + }); +}); diff --git a/packages/wagmi-generator/wagmi.config.ts b/packages/wagmi-generator/wagmi.config.ts index fb2fbea3..094a9a65 100644 --- a/packages/wagmi-generator/wagmi.config.ts +++ b/packages/wagmi-generator/wagmi.config.ts @@ -12,97 +12,151 @@ export default defineConfig(async () => { { name: "AccessController", address: { - [iliadChainId]: "0x01d470c28822d3701Db6325333cEE9737524776E", + [iliadChainId]: "0xbcaD7EA76Ee68Cc507874e9050a7E7D7ff07BB09", }, }, { name: "DisputeModule", address: { - [iliadChainId]: "0xDae11663438a0958E7075F604E3a5eEe77FD3878", + [iliadChainId]: "0x26525b4A1c2261A27B9ee89D512c2f7DceF85f4a", }, }, { name: "IPAccountImpl", address: { - [iliadChainId]: "0x8F763c16753e830a8020c80f9F0131Eb8Ef52879", + [iliadChainId]: "0xaE2D8F01920DB2328BEd676652154c9D2Cb863fa", }, }, { name: "IPAssetRegistry", address: { - [iliadChainId]: "0xe34A78B3d658aF7ad69Ff1EFF9012ECa025a14Be", + [iliadChainId]: "0x14CAB45705Fe73EC6d126518E59Fe3C61a181E40", }, }, { name: "IpRoyaltyVaultImpl", address: { - [iliadChainId]: "0xfb5b5B61c9a437E06Ba87367aaBf3766d091E3D1", + [iliadChainId]: "0x604dc8E58f720DEB345B2F3e08B2B354eA6CE498", }, }, { name: "LicenseRegistry", address: { - [iliadChainId]: "0xF542AF9a5A6E4A85a4f084D38B322516ec336097", + [iliadChainId]: "0x4D71a082DE74B40904c1d89d9C3bfB7079d4c542", }, }, { name: "LicenseToken", address: { - [iliadChainId]: "0xB31FE33De46A1FA5d4Ec669EDB049892E0A1EB4C", + [iliadChainId]: "0xd8aEF404432a2b3363479A6157285926B6B3b743", }, }, { name: "LicensingModule", address: { - [iliadChainId]: "0xf49da534215DA7b48E57A41d41dac25C912FCC60", + [iliadChainId]: "0xC8f165950411504eA130692B87A7148e469f7090", }, }, { name: "PILicenseTemplate", address: { - [iliadChainId]: "0x8BB1ADE72E21090Fc891e1d4b88AC5E57b27cB31", + [iliadChainId]: "0xbB7ACFBE330C56aA9a3aEb84870743C3566992c3", }, }, { name: "ModuleRegistry", address: { - [iliadChainId]: "0x008ac202A8545D10f25707439bE4c139Be4Df75F", + [iliadChainId]: "0x47bEae573B73F8BF1B4fa4Af065c39743871003f", }, }, { name: "RoyaltyModule", address: { - [iliadChainId]: "0x968beb5432c362c12b5Be6967a5d6F1ED5A63F01", + [iliadChainId]: "0xaCb5764E609aa3a5ED36bA74ba59679246Cb0963", }, }, { name: "RoyaltyPolicyLAP", address: { - [iliadChainId]: "0x61A5c7570f5bDB118D65053Ba60DE87e050E664e", + [iliadChainId]: "0x793Df8d32c12B0bE9985FFF6afB8893d347B6686", }, }, { - name: "SPG", + name: "RoyaltyPolicyLRP", address: { - [iliadChainId]: "0x69415CE984A79a3Cfbe3F51024C63b6C107331e3", + [iliadChainId]: "0x1eF035c7054bd45e25B2a29A06a37b1350F50596", }, }, { name: "SPGNFTBeacon", address: { - [iliadChainId]: "0x027D258659FBdda9033f9c008AF166239EBa67c1", + [iliadChainId]: "0x02324ca8f369abB445F50c4cE79e956e49AC75d8", }, }, { name: "SPGNFTImpl", address: { - [iliadChainId]: "0xDb6480C00B570324A122A6B35F9CAC0F87BDb3e6", + [iliadChainId]: "0xC8E4376Da033cE244027B03f9b94dc0d7005D67E", }, }, { name: "CoreMetadataModule", address: { - [iliadChainId]: "0x290F414EA46b361ECFB6b430F98346CB593D02b9", + [iliadChainId]: "0xa71Bd7aff91Da5E27A6f96c546D489F6e0870E45", + }, + }, + { + name: "DerivativeWorkflows", + address: { + [iliadChainId]: "0xC022C70DA8c23Ae8e36B3de9039Ed24E4E42a127", + }, + }, + { + name: "GroupingWorkflows", + address: { + [iliadChainId]: "0x426fF4F7E9Debe565F5Fe6F53334Ad3982295E20", + }, + }, + { + name: "RegistrationWorkflows", + address: { + [iliadChainId]: "0xF403fcCAAE6C503D0CC1D25904A0B2cCd5B96C6F", + }, + }, + { + name: "RoyaltyWorkflows", + address: { + [iliadChainId]: "0xc757921ee0f7c8E935d44BFBDc2602786e0eda6C", + }, + }, + { + name: "LicenseAttachmentWorkflows", + address: { + [iliadChainId]: "0x1B95144b62B4566501482e928aa435Dd205fE71B", + }, + }, + { + name: "GroupingModule", + address: { + [iliadChainId]: "0xaB7a16Ad9e46656C59e6071d920feeE7A3416ECf", + }, + }, + { + name: "EvenSplitGroupPool", + address: { + [iliadChainId]: "0xA1dB7AB14900Cd9eF9A7eBA931A206250F403a14", + }, + }, + { + name: "ArbitrationPolicySP", + address: { + [iliadChainId]: "0x8038697357F63415e848785e45B00eB60BcD797b", + }, + }, + { + name: "MockERC20", + address: { + [iliadChainId]: "0x91f6F05B08c16769d3c85867548615d270C42fC7", }, }, ]; @@ -146,7 +200,6 @@ export default defineConfig(async () => { "IPAccountRegistered", ], IpRoyaltyVaultImpl: [ - "claimRevenueBySnapshotBatch", "claimRevenueByTokenBatch", "claimableRevenue", "collectRoyaltyTokens", @@ -155,6 +208,7 @@ export default defineConfig(async () => { "snapshot", "SnapshotCompleted", "RevenueTokenClaimed", + "claimRevenueOnBehalfBySnapshotBatch", ], PiLicenseTemplate: [ "getLicenseTermsId", @@ -172,21 +226,44 @@ export default defineConfig(async () => { "predictMintingLicenseFee", ], ModuleRegistry: ["isRegistered", "getDefaultLicenseTerms"], - RoyaltyModule: ["payRoyaltyOnBehalf", "isWhitelistedRoyaltyPolicy","isWhitelistedRoyaltyToken"], + RoyaltyModule: [ + "payRoyaltyOnBehalf", + "isWhitelistedRoyaltyPolicy", + "isWhitelistedRoyaltyToken", + "ipRoyaltyVaults", + ], RoyaltyPolicyLAP: ["onRoyaltyPayment", "getRoyaltyData"], LicenseToken: ["ownerOf"], - SPG: [ + SPG: ["CollectionCreated"], + GroupingWorkflows: [ + "mintAndRegisterIpAndAttachLicenseAndAddToGroup", + "registerIpAndAttachLicenseAndAddToGroup", + "registerGroupAndAttachLicense", + "registerGroupAndAttachLicenseAndAddIps", + ], + DerivativeWorkflows: [ + "mintAndRegisterIpAndMakeDerivativeWithLicenseTokens", + "registerIpAndMakeDerivative", + "mintAndRegisterIpAndMakeDerivative", + "registerIpAndMakeDerivativeWithLicenseTokens", + "mintAndRegisterIpAndMakeDerivativeWithLicenseTokens", + ], + RegistrationWorkflows: [ "createCollection", - "CollectionCreated", "mintAndRegisterIp", + "registerIp", + "CollectionCreated", + ], + LicenseAttachmentWorkflows: [ "registerPILTermsAndAttach", - "mintAndRegisterIpAndAttachPILTerms", "registerIpAndAttachPILTerms", - "mintAndRegisterIpAndMakeDerivative", - "registerIpAndMakeDerivative", - "mintAndRegisterIpAndMakeDerivativeWithLicenseTokens", - "registerIpAndMakeDerivativeWithLicenseTokens", - "registerIp", + "mintAndRegisterIpAndAttachPILTerms", + ], + RoyaltyWorkflows: [ + "transferToVaultAndSnapshotAndClaimByTokenBatch", + "transferToVaultAndSnapshotAndClaimBySnapshotBatch", + "snapshotAndClaimByTokenBatch", + "snapshotAndClaimBySnapshotBatch", ], }, }),