diff --git a/.github/workflows/pr-external.yaml b/.github/workflows/pr-external.yaml index 43bcf309..95446203 100644 --- a/.github/workflows/pr-external.yaml +++ b/.github/workflows/pr-external.yaml @@ -1,4 +1,4 @@ -name: Workflow for External PRs +name: Workflow for External PRs with Unit Tests on: pull_request_target: @@ -21,10 +21,10 @@ jobs: Timestamp_PR_APPROVED: needs: [authorize] uses: storyprotocol/gha-workflows/.github/workflows/reusable-timestamp.yml@main - + build_and_test: needs: [authorize, Timestamp_PR_APPROVED] - uses: storyprotocol/gha-workflows/.github/workflows/reusable-build-test-workflow.yml@main + uses: storyprotocol/gha-workflows/.github/workflows/reusable-build-unit-test-workflow.yml@main with: sha: ${{ github.event.pull_request.head.sha }} ENVIRONMENT: "beta-sepolia" diff --git a/.github/workflows/pr-internal.yml b/.github/workflows/pr-internal.yml index 5be39c8a..3ce7a4ea 100644 --- a/.github/workflows/pr-internal.yml +++ b/.github/workflows/pr-internal.yml @@ -1,14 +1,12 @@ -name: Workflow for internal PRs +name: Conditional Workflow on: - push: + pull_request: branches: - main - dev - - pull_request: + push: branches: - - main - dev jobs: @@ -16,12 +14,23 @@ jobs: if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} uses: storyprotocol/gha-workflows/.github/workflows/reusable-timestamp.yml@main - build_and_test: + pr_build_and_test: + if: github.event_name == 'pull_request' needs: [Timestamp] - uses: storyprotocol/gha-workflows/.github/workflows/reusable-build-test-workflow.yml@main + uses: storyprotocol/gha-workflows/.github/workflows/reusable-build-unit-test-workflow.yml@main with: sha: ${{ github.event.pull_request.head.sha }} ENVIRONMENT: "beta-sepolia" secrets: WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }} TEST_WALLET_ADDRESS: ${{ secrets.TEST_WALLET_ADDRESS }} + + push_build_and_test: + if: github.event_name == 'push' + uses: storyprotocol/gha-workflows/.github/workflows/reusable-build-integration-test-workflow.yml@main + with: + sha: ${{ github.sha }} + ENVIRONMENT: "beta-sepolia" + secrets: + WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }} + TEST_WALLET_ADDRESS: ${{ secrets.TEST_WALLET_ADDRESS }} diff --git a/package.json b/package.json index f27634e6..e5efa862 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "lint": "turbo run lint", "fix": "turbo run fix", "test": "turbo run test --no-cache --concurrency=1", + "test:integration": "turbo run test:integration --no-cache", "prepare": "husky install" }, "devDependencies": { diff --git a/packages/core-sdk/package.json b/packages/core-sdk/package.json index 73c2ac66..189c8b65 100644 --- a/packages/core-sdk/package.json +++ b/packages/core-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@story-protocol/core-sdk", - "version": "1.2.0-rc.3", + "version": "1.2.0-rc.4", "description": "Story Protocol Core SDK", "main": "dist/story-protocol-core-sdk.cjs.js", "module": "dist/story-protocol-core-sdk.esm.js", diff --git a/packages/core-sdk/src/abi/generated.ts b/packages/core-sdk/src/abi/generated.ts index 4722b808..67967dde 100644 --- a/packages/core-sdk/src/abi/generated.ts +++ b/packages/core-sdk/src/abi/generated.ts @@ -10946,8 +10946,8 @@ export const royaltyTokenDistributionWorkflowsAbi = [ }, { name: "terms", - internalType: "struct PILTerms", - type: "tuple", + internalType: "struct PILTerms[]", + type: "tuple[]", components: [ { name: "transferable", internalType: "bool", type: "bool" }, { name: "royaltyPolicy", internalType: "address", type: "address" }, @@ -11010,7 +11010,7 @@ export const royaltyTokenDistributionWorkflowsAbi = [ outputs: [ { name: "ipId", internalType: "address", type: "address" }, { name: "tokenId", internalType: "uint256", type: "uint256" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { name: "licenseTermsIds", internalType: "uint256[]", type: "uint256[]" }, ], stateMutability: "nonpayable", }, @@ -11094,8 +11094,8 @@ export const royaltyTokenDistributionWorkflowsAbi = [ }, { name: "terms", - internalType: "struct PILTerms", - type: "tuple", + internalType: "struct PILTerms[]", + type: "tuple[]", components: [ { name: "transferable", internalType: "bool", type: "bool" }, { name: "royaltyPolicy", internalType: "address", type: "address" }, @@ -11168,7 +11168,7 @@ export const royaltyTokenDistributionWorkflowsAbi = [ name: "registerIpAndAttachPILTermsAndDeployRoyaltyVault", outputs: [ { name: "ipId", internalType: "address", type: "address" }, - { name: "licenseTermsId", internalType: "uint256", type: "uint256" }, + { name: "licenseTermsIds", internalType: "uint256[]", type: "uint256[]" }, { name: "ipRoyaltyVault", internalType: "address", type: "address" }, ], stateMutability: "nonpayable", @@ -23809,7 +23809,7 @@ export type RoyaltyTokenDistributionWorkflowsDistributeRoyaltyTokensRequest = { * @param spgNftContract address * @param recipient address * @param ipMetadata tuple - * @param terms tuple + * @param terms tuple[] * @param royaltyShares tuple[] */ export type RoyaltyTokenDistributionWorkflowsMintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokensRequest = @@ -23840,7 +23840,7 @@ export type RoyaltyTokenDistributionWorkflowsMintAndRegisterIpAndAttachPilTermsA derivativeRevCeiling: bigint; currency: Address; uri: string; - }; + }[]; royaltyShares: { author: Address; percentage: number; @@ -23884,7 +23884,7 @@ export type RoyaltyTokenDistributionWorkflowsMintAndRegisterIpAndMakeDerivativeA * @param nftContract address * @param tokenId uint256 * @param ipMetadata tuple - * @param terms tuple + * @param terms tuple[] * @param sigMetadata tuple * @param sigAttach tuple */ @@ -23916,7 +23916,7 @@ export type RoyaltyTokenDistributionWorkflowsRegisterIpAndAttachPilTermsAndDeplo derivativeRevCeiling: bigint; currency: Address; uri: string; - }; + }[]; sigMetadata: { signer: Address; deadline: bigint; diff --git a/packages/core-sdk/src/index.ts b/packages/core-sdk/src/index.ts index 3506acc3..a1ee2ef0 100644 --- a/packages/core-sdk/src/index.ts +++ b/packages/core-sdk/src/index.ts @@ -65,6 +65,7 @@ export type { RegisterNonComSocialRemixingPILRequest, RegisterCommercialUsePILRequest, RegisterCommercialRemixPILRequest, + RegisterPILTermsRequest, RegisterPILResponse, AttachLicenseTermsRequest, AttachLicenseTermsResponse, @@ -156,3 +157,5 @@ export type { export { getPermissionSignature, getSignature } from "./utils/sign"; export { convertCIDtoHashIPFS, convertHashIPFStoCID } from "./utils/ipfs"; + +export type { TxOptions } from "./types/options"; diff --git a/packages/core-sdk/src/resources/ipAsset.ts b/packages/core-sdk/src/resources/ipAsset.ts index 4006a57a..32769d0a 100644 --- a/packages/core-sdk/src/resources/ipAsset.ts +++ b/packages/core-sdk/src/resources/ipAsset.ts @@ -1524,12 +1524,12 @@ export class IPAssetClient { } } /** - * Register the given NFT and attach license terms and distribute royalty tokens. In order to successfully distribute royalty tokens, the license terms attached to the IP must be + * Register the given NFT and attach license terms and distribute royalty tokens. In order to successfully distribute royalty tokens, the first license terms attached to the IP must be * a commercial license. * @param request - The request object that contains all data needed to register ip and attach license terms and distribute royalty tokens. * @param request.nftContract The address of the NFT collection. * @param request.tokenId The ID of the NFT. - * @param request.terms The array of license terms to be attached. + * @param {Array} request.terms The array of license terms to be attached. * @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. @@ -1557,7 +1557,7 @@ export class IPAssetClient { * @param request.royaltyShares.percentage The percentage of the royalty share, 10 represents 10%. * @param request.deadline [Optional] The deadline for the signature in seconds, default is 1000s. * @param request.txOptions [Optional] This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property, without encodedTxData option. - * @returns A Promise that resolves to a transaction hashes, IP ID, License terms ID, and IP royalty vault. + * @returns A Promise that resolves to a transaction hashes, IP ID, IP royalty vault and an array containing the license terms ID. * @emits IPRegistered (ipId, chainId, tokenContract, tokenId, name, uri, registrationDate) * @emits IpRoyaltyVaultDeployed (ipId, ipRoyaltyVault) */ @@ -1565,11 +1565,16 @@ export class IPAssetClient { request: RegisterIPAndAttachLicenseTermsAndDistributeRoyaltyTokensRequest, ): Promise { try { - if (!request.terms.commercialUse) { - throw new Error("Commercial use is required to deploy a royalty vault."); - } const { royaltyShares, totalAmount } = this.getRoyaltyShares(request.royaltyShares); - const licenseTerm = await validateLicenseTerms(request.terms, this.rpcClient); + const licenseTerms: LicenseTerms[] = []; + for (let i = 0; i < request.terms.length; i++) { + const term = request.terms[i]; + if (i === 0 && !term.commercialUse) { + throw new Error("The first license term must be a commercial license."); + } + const licenseTerm = await validateLicenseTerms(term, this.rpcClient); + licenseTerms.push(licenseTerm); + } const blockTimestamp = (await this.rpcClient.getBlock()).timestamp; const calculatedDeadline = getDeadline(blockTimestamp, request.deadline); const ipIdAddress = await this.getIpIdAddress( @@ -1629,7 +1634,7 @@ export class IPAssetClient { nftMetadataURI: request.ipMetadata?.nftMetadataURI || "", nftMetadataHash: request.ipMetadata?.nftMetadataHash || zeroHash, }, - terms: licenseTerm, + terms: licenseTerms, sigMetadata: { signer: this.wallet.account!.address, deadline: calculatedDeadline, @@ -1647,7 +1652,7 @@ export class IPAssetClient { hash: registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash, }); const { ipId } = this.getIpIdAndTokenIdsFromEvent(txReceipt)[0]; - const licenseTermsId = await this.getLicenseTermsId([licenseTerm]); + const licenseTermsIds = await this.getLicenseTermsId(licenseTerms); const { ipRoyaltyVault } = this.royaltyModuleEventClient.parseTxIpRoyaltyVaultDeployedEvent(txReceipt)[0]; const distributeRoyaltyTokensTxHash = await this.distributeRoyaltyTokens({ @@ -1669,7 +1674,7 @@ export class IPAssetClient { registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash, distributeRoyaltyTokensTxHash, ipId, - licenseTermsId: licenseTermsId[0], + licenseTermsIds, ipRoyaltyVault, }; } catch (error) { @@ -1703,7 +1708,7 @@ export class IPAssetClient { * @emits IPRegistered (ipId, chainId, tokenContract, tokenId, name, uri, registrationDate) * @emits IpRoyaltyVaultDeployed (ipId, ipRoyaltyVault) */ - public async registerDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokens( + public async registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens( request: RegisterDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensRequest, ): Promise { try { @@ -1806,7 +1811,7 @@ export class IPAssetClient { }); } return { - registerDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensTxHash: txHash, + registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokensTxHash: txHash, distributeRoyaltyTokensTxHash, ipId, tokenId, @@ -1821,11 +1826,11 @@ export class IPAssetClient { } /** - * Mint an NFT and register the IP, attach PIL terms, and distribute royalty tokens. In order to successfully distribute royalty tokens, the license terms attached to the IP must be + * Mint an NFT and register the IP, attach PIL terms, and distribute royalty tokens. In order to successfully distribute royalty tokens, First the license terms attached to the IP must be * a commercial license. * @param request - The request object that contains all data needed to mint an NFT and register the IP, attach PIL terms, and distribute royalty tokens. * @param request.spgNftContract The address of the SPG NFT contract. - * @param request.terms The array of license terms to be attached. + * @param {Array} request.terms The array of license terms to be attached. * @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. @@ -1853,17 +1858,23 @@ export class IPAssetClient { * @param request.royaltyShares.percentage The percentage of the royalty share, 10 represents 10%. * @param request.recipient - [Optional] The address to receive the minted NFT,default value is your wallet address. * @param request.txOptions [Optional] This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property, without encodedTxData option. - * @returns A Promise that resolves to a transaction hash, IP ID, License terms ID, and IP royalty vault, Token ID. + * @returns A Promise that resolves to a transaction hash, IP ID, IP royalty vault, Token ID, and an array containing the license terms ID. * @emits IPRegistered (ipId, chainId, tokenContract, tokenId, name, uri, registrationDate) + * @emits IpRoyaltyVaultDeployed (ipId, ipRoyaltyVault) */ public async mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens( request: MintAndRegisterIpAndAttachPILTermsAndDistributeRoyaltyTokensRequest, ): Promise { try { - if (!request.terms.commercialUse) { - throw new Error("Commercial use is required to deploy a royalty vault."); + const licenseTerms: LicenseTerms[] = []; + for (let i = 0; i < request.terms.length; i++) { + const term = request.terms[i]; + if (i === 0 && !term.commercialUse) { + throw new Error("First license term must be a commercial license."); + } + const licenseTerm = await validateLicenseTerms(term, this.rpcClient); + licenseTerms.push(licenseTerm); } - const licenseTerm = await validateLicenseTerms(request.terms, this.rpcClient); const { royaltyShares } = this.getRoyaltyShares(request.royaltyShares); const txHash = await this.royaltyTokenDistributionWorkflowsClient.mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens( @@ -1878,7 +1889,7 @@ export class IPAssetClient { nftMetadataURI: request.ipMetadata?.nftMetadataURI || "", nftMetadataHash: request.ipMetadata?.nftMetadataHash || zeroHash, }, - terms: licenseTerm, + terms: licenseTerms, royaltyShares, }, ); @@ -1888,13 +1899,13 @@ export class IPAssetClient { hash: txHash, }); const { ipId, tokenId } = this.getIpIdAndTokenIdsFromEvent(txReceipt)[0]; - const licenseTermsId = await this.getLicenseTermsId([licenseTerm]); + const licenseTermsIds = await this.getLicenseTermsId(licenseTerms); const { ipRoyaltyVault } = this.royaltyModuleEventClient.parseTxIpRoyaltyVaultDeployedEvent(txReceipt)[0]; return { txHash, ipId, - licenseTermsId: licenseTermsId[0], + licenseTermsIds, ipRoyaltyVault, tokenId, }; diff --git a/packages/core-sdk/src/types/resources/ipAsset.ts b/packages/core-sdk/src/types/resources/ipAsset.ts index acb0089b..b1f82fe2 100644 --- a/packages/core-sdk/src/types/resources/ipAsset.ts +++ b/packages/core-sdk/src/types/resources/ipAsset.ts @@ -275,7 +275,7 @@ export type BatchRegisterResponse = { export type RegisterIPAndAttachLicenseTermsAndDistributeRoyaltyTokensRequest = { nftContract: Address; tokenId: bigint | string | number; - terms: RegisterPILTermsRequest; + terms: RegisterPILTermsRequest[]; deadline?: string | number | bigint; royaltyShares: RoyaltyShare[]; txOptions?: Omit; @@ -284,7 +284,7 @@ export type RegisterIPAndAttachLicenseTermsAndDistributeRoyaltyTokensResponse = registerIpAndAttachPilTermsAndDeployRoyaltyVaultTxHash: Hex; distributeRoyaltyTokensTxHash: Hex; ipId: Address; - licenseTermsId: bigint; + licenseTermsIds: bigint[]; ipRoyaltyVault: Address; }; export type DistributeRoyaltyTokens = { @@ -318,7 +318,7 @@ export type RegisterDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensReq } & IPMetadataInfo; export type RegisterDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensResponse = { - registerDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensTxHash: Address; + registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokensTxHash: Address; distributeRoyaltyTokensTxHash: Address; ipId: Address; tokenId: bigint; @@ -327,7 +327,7 @@ export type RegisterDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensRes export type MintAndRegisterIpAndAttachPILTermsAndDistributeRoyaltyTokensRequest = { spgNftContract: Address; - terms: RegisterPILTermsRequest; + terms: RegisterPILTermsRequest[]; royaltyShares: { author: Address; percentage: number; @@ -339,7 +339,7 @@ export type MintAndRegisterIpAndAttachPILTermsAndDistributeRoyaltyTokensRequest export type MintAndRegisterIpAndAttachPILTermsAndDistributeRoyaltyTokensResponse = { txHash: Hex; ipId?: Address; - licenseTermsId?: bigint; + licenseTermsIds?: bigint[]; ipRoyaltyVault?: Address; tokenId?: bigint; }; diff --git a/packages/core-sdk/test/integration/ipAsset.test.ts b/packages/core-sdk/test/integration/ipAsset.test.ts index cefb6ad4..f0c06693 100644 --- a/packages/core-sdk/test/integration/ipAsset.test.ts +++ b/packages/core-sdk/test/integration/ipAsset.test.ts @@ -428,25 +428,27 @@ describe("IP Asset Functions ", () => { { nftContract: nftContract, tokenId: tokenId!, - terms: { - transferable: true, - royaltyPolicy: royaltyPolicyLapAddress[odyssey], - defaultMintingFee: BigInt(10000), - expiration: BigInt(1000), - commercialUse: true, - 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: "test case", - }, + terms: [ + { + transferable: true, + royaltyPolicy: royaltyPolicyLapAddress[odyssey], + defaultMintingFee: BigInt(10000), + expiration: BigInt(1000), + commercialUse: true, + 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: "test case", + }, + ], ipMetadata: { ipMetadataURI: "test-uri", ipMetadataHash: toHex("test-metadata-hash", { size: 32 }), @@ -467,13 +469,13 @@ describe("IP Asset Functions ", () => { .not.empty; expect(result.distributeRoyaltyTokensTxHash).to.be.a("string").and.not.empty; expect(result.ipId).to.be.a("string").and.not.empty; - expect(result.licenseTermsId).to.be.a("bigint"); + expect(result.licenseTermsIds).to.be.an("array").and.not.empty; }); it("should not throw error when call register derivative and attach license terms and distribute royalty tokens", async () => { const tokenId = await getTokenId(); const result = - await client.ipAsset.registerDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokens({ + await client.ipAsset.registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens({ nftContract: mockERC721, tokenId: tokenId!, derivData: { @@ -488,7 +490,7 @@ describe("IP Asset Functions ", () => { ], }); expect( - result.registerDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensTxHash, + result.registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokensTxHash, ).to.be.a("string"); expect(result.distributeRoyaltyTokensTxHash).to.be.a("string"); expect(result.ipId).to.be.a("string"); @@ -499,25 +501,27 @@ describe("IP Asset Functions ", () => { const result = await client.ipAsset.mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens({ spgNftContract: nftContract, - terms: { - transferable: true, - royaltyPolicy: royaltyPolicyLapAddress[odyssey], - defaultMintingFee: BigInt(10000), - expiration: BigInt(1000), - commercialUse: true, - 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: "test case", - }, + terms: [ + { + transferable: true, + royaltyPolicy: royaltyPolicyLapAddress[odyssey], + defaultMintingFee: BigInt(10000), + expiration: BigInt(1000), + commercialUse: true, + 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: "test case", + }, + ], ipMetadata: { ipMetadataURI: "test-uri", ipMetadataHash: toHex("test-metadata-hash", { size: 32 }), @@ -535,7 +539,7 @@ describe("IP Asset Functions ", () => { }); expect(result.txHash).to.be.a("string"); expect(result.ipId).to.be.a("string"); - expect(result.licenseTermsId).to.be.a("bigint"); + expect(result.licenseTermsIds).to.be.an("array").and.not.empty; expect(result.tokenId).to.be.a("bigint"); }); it("should not throw error when call mint and register ip and make derivative and distribute royalty tokens", async () => { diff --git a/packages/core-sdk/test/unit/resources/ipAsset.test.ts b/packages/core-sdk/test/unit/resources/ipAsset.test.ts index b70e78f5..3c1961d2 100644 --- a/packages/core-sdk/test/unit/resources/ipAsset.test.ts +++ b/packages/core-sdk/test/unit/resources/ipAsset.test.ts @@ -2195,7 +2195,7 @@ describe("Test IpAssetClient", () => { await ipAssetClient.registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens({ nftContract: spgNftContract, tokenId: "1", - terms: licenseTerms, + terms: [licenseTerms], royaltyShares: [ { author: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", @@ -2215,10 +2215,12 @@ describe("Test IpAssetClient", () => { await ipAssetClient.registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens({ nftContract: spgNftContract, tokenId: "1", - terms: { - ...licenseTerms, - commercialUse: false, - }, + terms: [ + { + ...licenseTerms, + commercialUse: false, + }, + ], royaltyShares: [ { author: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", @@ -2228,7 +2230,7 @@ describe("Test IpAssetClient", () => { }); } catch (err) { expect((err as Error).message).equal( - "Failed to register IP and attach license terms and distribute royalty tokens: Commercial use is required to deploy a royalty vault.", + "Failed to register IP and attach license terms and distribute royalty tokens: The first license term must be a commercial license.", ); } }); @@ -2239,7 +2241,7 @@ describe("Test IpAssetClient", () => { await ipAssetClient.registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens({ nftContract: spgNftContract, tokenId: "1", - terms: licenseTerms, + terms: [licenseTerms], royaltyShares: [{ author: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", percentage: -1 }], }); } catch (err) { @@ -2255,7 +2257,7 @@ describe("Test IpAssetClient", () => { await ipAssetClient.registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens({ nftContract: spgNftContract, tokenId: "1", - terms: licenseTerms, + terms: [licenseTerms], royaltyShares: [ { author: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", percentage: 101 }, ], @@ -2274,7 +2276,7 @@ describe("Test IpAssetClient", () => { await ipAssetClient.registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens({ nftContract: spgNftContract, tokenId: "1", - terms: licenseTerms, + terms: [licenseTerms], royaltyShares: [ { author: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", percentage: 10 }, { author: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", percentage: 100 }, @@ -2325,7 +2327,7 @@ describe("Test IpAssetClient", () => { const result = await ipAssetClient.registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens({ nftContract: spgNftContract, tokenId: "1", - terms: licenseTerms, + terms: [licenseTerms], royaltyShares: [{ author: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", percentage: 100 }], }); expect(result).to.deep.equal({ @@ -2333,7 +2335,7 @@ describe("Test IpAssetClient", () => { "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997", distributeRoyaltyTokensTxHash: txHash, ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", - licenseTermsId: 8n, + licenseTermsIds: [8n], ipRoyaltyVault: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", }); }); @@ -2379,7 +2381,7 @@ describe("Test IpAssetClient", () => { await ipAssetClient.registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens({ nftContract: spgNftContract, tokenId: "1", - terms: licenseTerms, + terms: [licenseTerms], royaltyShares: [ { author: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", percentage: 100 }, ], @@ -2430,7 +2432,7 @@ describe("Test IpAssetClient", () => { const result = await ipAssetClient.registerIPAndAttachLicenseTermsAndDistributeRoyaltyTokens({ nftContract: spgNftContract, tokenId: "1", - terms: licenseTerms, + terms: [licenseTerms, licenseTerms], royaltyShares: [{ author: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", percentage: 100 }], ipMetadata: { ipMetadataURI: "", @@ -2447,7 +2449,7 @@ describe("Test IpAssetClient", () => { "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997", distributeRoyaltyTokensTxHash: txHash, ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", - licenseTermsId: 8n, + licenseTermsIds: [8n, 8n], ipRoyaltyVault: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", }); }); @@ -2460,7 +2462,7 @@ describe("Test IpAssetClient", () => { .stub(ipAssetClient.ipAssetRegistryClient, "ipId") .resolves("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); try { - await ipAssetClient.registerDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokens({ + await ipAssetClient.registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens({ derivData: { parentIpIds: ["0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"], licenseTermsIds: [1n], @@ -2515,7 +2517,7 @@ describe("Test IpAssetClient", () => { }, ]); const result = - await ipAssetClient.registerDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokens({ + await ipAssetClient.registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens({ derivData: { parentIpIds: ["0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"], licenseTermsIds: [1n], @@ -2527,7 +2529,7 @@ describe("Test IpAssetClient", () => { tokenId: "1", }); expect(result).to.deep.equal({ - registerDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensTxHash: + registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokensTxHash: "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997", distributeRoyaltyTokensTxHash: txHash, ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", @@ -2573,7 +2575,7 @@ describe("Test IpAssetClient", () => { }, ]); const result = - await ipAssetClient.registerDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokens({ + await ipAssetClient.registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokens({ derivData: { parentIpIds: ["0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"], licenseTermsIds: [1n], @@ -2594,7 +2596,7 @@ describe("Test IpAssetClient", () => { }, }); expect(result).to.deep.equal({ - registerDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensTxHash: + registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokensTxHash: "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997", distributeRoyaltyTokensTxHash: txHash, ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", @@ -2609,10 +2611,12 @@ describe("Test IpAssetClient", () => { try { await ipAssetClient.mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens({ spgNftContract, - terms: { - ...licenseTerms, - commercialUse: false, - }, + terms: [ + { + ...licenseTerms, + commercialUse: false, + }, + ], royaltyShares: [ { author: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", @@ -2622,7 +2626,7 @@ describe("Test IpAssetClient", () => { }); } catch (err) { expect((err as Error).message).equal( - "Failed to mint and register IP and attach PIL terms and distribute royalty tokens: Commercial use is required to deploy a royalty vault.", + "Failed to mint and register IP and attach PIL terms and distribute royalty tokens: First license term must be a commercial license.", ); } }); @@ -2637,7 +2641,7 @@ describe("Test IpAssetClient", () => { const result = await ipAssetClient.mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens({ spgNftContract, - terms: licenseTerms, + terms: [licenseTerms], royaltyShares: [ { author: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", percentage: 100 }, ], @@ -2685,7 +2689,7 @@ describe("Test IpAssetClient", () => { const result = await ipAssetClient.mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens({ spgNftContract, - terms: licenseTerms, + terms: [licenseTerms], royaltyShares: [ { author: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", @@ -2700,7 +2704,7 @@ describe("Test IpAssetClient", () => { txHash: txHash, ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", tokenId: 0n, - licenseTermsId: 5n, + licenseTermsIds: [5n], ipRoyaltyVault: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", }); }); diff --git a/turbo.json b/turbo.json index 755de908..253fd5c5 100644 --- a/turbo.json +++ b/turbo.json @@ -11,10 +11,11 @@ "lint": {}, "lint:fix": {}, "test": {}, + "test:integration": {}, "dev": { "cache": false, "persistent": true } }, "globalEnv": ["TEST_WALLET_ADDRESS", "WALLET_PRIVATE_KEY"] -} +} \ No newline at end of file