Skip to content

Commit

Permalink
Bump up sdk version to 1.2.0-rc.2 (#317)
Browse files Browse the repository at this point in the history
* Feat/make isRegistered public (#311)

* make isRegistered public

* make isRegistered public

* [feat] add codeowners for pr review (#316)

* Implement multicall  (#314)

* Add batchMintAndRegisterIpAssetWithPilTerms method

* Add batchRegisterDerivative method

* Enhance batchMintAndRegisterIpAssetWithPilTerms including unit tests and annotation

* Add batchMintAndRegisterIpAndMakeDerivative method

* Add batch register method

* Fix issue about Invalid signature

* Refactor code

* Add unit tests

* Fix unit test

* Export getSignature method

* Add batchRegisterWithIpMetadata method

* Enhance code

* Refactor multicall about protocol core

* Remove integration test in command

* Refactor getDeadline method

* Bump up sdk to 1.2.0-rc.2

---------

Co-authored-by: Don <100505855+DonFungible@users.noreply.github.com>
Co-authored-by: Andy Wu <bwu2sfu@gmail.com>
  • Loading branch information
3 people committed Dec 3, 2024
1 parent b18d633 commit 4caea31
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 2 deletions.
1 change: 0 additions & 1 deletion packages/core-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,4 @@ export type {
} from "./abi/generated";

export { getPermissionSignature, getSignature } from "./utils/sign";

export { convertCIDtoHashIPFS, convertHashIPFStoCID } from "./utils/ipfs";
3 changes: 2 additions & 1 deletion packages/core-sdk/src/resources/ipAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -133,6 +134,7 @@ export class IPAssetClient {
this.rpcClient = rpcClient;
this.wallet = wallet;
this.chainId = chainId;
void this.getDefaultLicenseTerms();
}

/**
Expand Down Expand Up @@ -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,
Expand Down
162 changes: 162 additions & 0 deletions packages/core-sdk/test/integration/ipAsset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});
});

0 comments on commit 4caea31

Please sign in to comment.