diff --git a/packages/core-sdk/src/index.ts b/packages/core-sdk/src/index.ts index 3506acc3..a2faea90 100644 --- a/packages/core-sdk/src/index.ts +++ b/packages/core-sdk/src/index.ts @@ -154,5 +154,4 @@ export type { } from "./abi/generated"; export { getPermissionSignature, getSignature } from "./utils/sign"; - export { convertCIDtoHashIPFS, convertHashIPFStoCID } from "./utils/ipfs"; diff --git a/packages/core-sdk/src/resources/ipAsset.ts b/packages/core-sdk/src/resources/ipAsset.ts index 4006a57a..ed8db0ed 100644 --- a/packages/core-sdk/src/resources/ipAsset.ts +++ b/packages/core-sdk/src/resources/ipAsset.ts @@ -112,6 +112,7 @@ export class IPAssetClient { private readonly rpcClient: PublicClient; private readonly wallet: SimpleWalletClient; private readonly chainId: SupportedChainIds; + private defaultLicenseTermsId!: bigint; constructor(rpcClient: PublicClient, wallet: SimpleWalletClient, chainId: SupportedChainIds) { this.licensingModuleClient = new LicensingModuleClient(rpcClient, wallet); @@ -133,6 +134,7 @@ export class IPAssetClient { this.rpcClient = rpcClient; this.wallet = wallet; this.chainId = chainId; + void this.getDefaultLicenseTerms(); } /** @@ -747,7 +749,6 @@ export class IPAssetClient { calldata.push(result.encodedTxData!.data); } const txHash = await this.licenseAttachmentWorkflowsClient.multicall({ data: calldata }); - if (request.txOptions?.waitForTransaction) { const txReceipt = await this.rpcClient.waitForTransactionReceipt({ ...request.txOptions, diff --git a/packages/core-sdk/test/integration/ipAsset.test.ts b/packages/core-sdk/test/integration/ipAsset.test.ts index cefb6ad4..07da974d 100644 --- a/packages/core-sdk/test/integration/ipAsset.test.ts +++ b/packages/core-sdk/test/integration/ipAsset.test.ts @@ -778,4 +778,166 @@ describe("IP Asset Functions ", () => { expect(result.txHash).to.be.a("string").and.not.empty; }); }); + + describe("Multicall", () => { + let nftContract: Hex; + beforeEach(async () => { + 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, + }, + }); + nftContract = txData.spgNftContract!; + }); + it("should not throw error when call batch register derivative", async () => { + const childTokenId = await getTokenId(); + const childIpId = ( + await client.ipAsset.register({ + nftContract: mockERC721, + tokenId: childTokenId!, + txOptions: { + waitForTransaction: true, + }, + }) + ).ipId!; + const childTokenId2 = await getTokenId(); + const childIpId2 = ( + await client.ipAsset.register({ + nftContract: mockERC721, + tokenId: childTokenId2!, + txOptions: { + waitForTransaction: true, + }, + }) + ).ipId!; + const result = await client.ipAsset.batchRegisterDerivative({ + args: [ + { + childIpId: childIpId, + parentIpIds: [parentIpId], + licenseTermsIds: [noCommercialLicenseTermsId], + }, + { + childIpId: childIpId2, + parentIpIds: [parentIpId], + licenseTermsIds: [noCommercialLicenseTermsId], + }, + ], + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).to.be.a("string").and.not.empty; + }); + it("should not throw error when call batch mint and register ip asset with pil terms", async () => { + const result = await client.ipAsset.batchMintAndRegisterIpAssetWithPilTerms({ + args: [ + { + spgNftContract: nftContract, + pilType: PIL_TYPE.COMMERCIAL_REMIX, + commercialRevShare: 10, + mintingFee: "100", + currency: MockERC20.address, + }, + { + spgNftContract: nftContract, + pilType: PIL_TYPE.COMMERCIAL_REMIX, + commercialRevShare: 10, + mintingFee: "100", + currency: MockERC20.address, + }, + ], + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).to.be.a("string").and.not.empty; + expect(result.results).to.be.an("array").and.not.empty; + }); + + it("should not throw error when call batch mint and register ip asset and make derivative", async () => { + const tokenId2 = await getTokenId(); + const parentIpId2 = ( + await client.ipAsset.register({ + nftContract: mockERC721, + tokenId: tokenId2!, + txOptions: { + waitForTransaction: true, + }, + }) + ).ipId!; + const result = await client.ipAsset.batchMintAndRegisterIpAndMakeDerivative({ + args: [ + { + spgNftContract: nftContract, + derivData: { + parentIpIds: [parentIpId!], + licenseTermsIds: [noCommercialLicenseTermsId!], + }, + }, + { + spgNftContract: nftContract, + derivData: { + parentIpIds: [parentIpId2!], + licenseTermsIds: [noCommercialLicenseTermsId!], + }, + }, + ], + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.txHash).to.be.a("string").and.not.empty; + expect(result.results).to.be.an("array").and.not.empty; + }); + + it("should not throw error when call batch register giving parameters without ipMetadata", async () => { + const tokenId = await getTokenId(); + const tokenId2 = await getTokenId(); + const spgTokenId1 = await mintBySpg(nftContract, "test-metadata"); + const spgTokenId2 = await mintBySpg(nftContract, "test-metadata"); + const result = await client.ipAsset.batchRegister({ + args: [ + { + nftContract: mockERC721, + tokenId: tokenId!, + }, + { + nftContract: mockERC721, + tokenId: tokenId2!, + }, + { + nftContract, + tokenId: spgTokenId1!, + ipMetadata: { + ipMetadataURI: "test-uri2", + ipMetadataHash: toHex("test-metadata-hash2", { size: 32 }), + nftMetadataHash: toHex("test-nft-metadata-hash2", { size: 32 }), + }, + }, + { + nftContract, + tokenId: spgTokenId2!, + ipMetadata: { + ipMetadataURI: "test-uri", + ipMetadataHash: toHex("test-metadata-hash", { size: 32 }), + nftMetadataHash: toHex("test-nft-metadata-hash", { size: 32 }), + }, + }, + ], + txOptions: { + waitForTransaction: true, + }, + }); + expect(result.results).to.be.an("array").and.not.empty; + expect(result.txHash).to.be.a("string").and.not.empty; + }); + }); });