Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support distributing royalty token on registration #328

Merged
merged 16 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update mintAndRegisterIpAndAttachPILTerms to accept array of terms
  • Loading branch information
bonnie57 committed Nov 25, 2024
commit 9297c1c6f1d22bd6bdb60c059053cec0319eeb1f
4 changes: 2 additions & 2 deletions packages/core-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export type {
RegisterDerivativeRequest,
RegisterDerivativeWithLicenseTokensRequest,
RegisterDerivativeWithLicenseTokensResponse,
CreateIpAssetWithPilTermsRequest,
CreateIpAssetWithPilTermsResponse,
MintAndRegisterIpAssetWithPilTermsRequest,
MintAndRegisterIpAssetWithPilTermsResponse,
RegisterIpAndMakeDerivativeRequest,
RegisterIpAndMakeDerivativeResponse,
RegisterIpAndAttachPilTermsRequest,
Expand Down
127 changes: 60 additions & 67 deletions packages/core-sdk/src/resources/ipAsset.ts

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions packages/core-sdk/src/types/resources/ipAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ export type RegisterDerivativeResponse = {
encodedTxData?: EncodedTxData;
};

export type CreateIpAssetWithPilTermsRequest = {
export type MintAndRegisterIpAssetWithPilTermsRequest = {
spgNftContract: Address;
pilType: PIL_TYPE;
pilTypes: PIL_TYPE[];
currency?: Address;
mintingFee?: string | number | bigint;
recipient?: Address;
commercialRevShare?: number;
royaltyPolicyAddress?: Address;
} & IpMetadataAndTxOption;

export type CreateIpAssetWithPilTermsResponse = {
export type MintAndRegisterIpAssetWithPilTermsResponse = {
txHash?: Hex;
encodedTxData?: EncodedTxData;
ipId?: Address;
tokenId?: bigint;
licenseTermsId?: bigint;
licenseTermsIds?: bigint[];
};

export type RegisterIpAndMakeDerivativeRequest = {
Expand Down Expand Up @@ -228,13 +228,13 @@ export type RegisterIpAndMakeDerivativeWithLicenseTokensRequest = {
} & IpMetadataAndTxOption;

export type BatchMintAndRegisterIpAssetWithPilTermsRequest = {
args: Omit<CreateIpAssetWithPilTermsRequest, "txOptions">[];
args: Omit<MintAndRegisterIpAssetWithPilTermsRequest, "txOptions">[];
txOptions?: Omit<TxOptions, "EncodedTxData">;
};

export type BatchMintAndRegisterIpAssetWithPilTermsResponse = {
txHash: Hex;
results?: Omit<RegisterIpResponse, "encodedTxData">[];
results?: { ipId: Address; tokenId: bigint; licenseTermsIds: bigint[] }[];
};

export type BatchRegisterDerivativeRequest = {
Expand Down
4 changes: 2 additions & 2 deletions packages/core-sdk/test/integration/group.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ describe("Group Functions", () => {
).spgNftContract!;
const result = await client.ipAsset.mintAndRegisterIpAssetWithPilTerms({
spgNftContract: spgNftContract,
pilType: PIL_TYPE.COMMERCIAL_USE,
pilTypes: [PIL_TYPE.COMMERCIAL_USE],
commercialRevShare: 10,
mintingFee: "0",
currency: MockERC20.address,
txOptions: {
waitForTransaction: true,
},
});
licenseTermsId = result.licenseTermsId!;
licenseTermsId = result.licenseTermsIds![0];
ipId = result.ipId!;
});

Expand Down
39 changes: 23 additions & 16 deletions packages/core-sdk/test/integration/ipAsset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe("IP Asset Functions ", () => {

const result = await client.ipAsset.mintAndRegisterIpAssetWithPilTerms({
spgNftContract: nftContract,
pilType: PIL_TYPE.COMMERCIAL_REMIX,
pilTypes: [PIL_TYPE.COMMERCIAL_REMIX],
commercialRevShare: 10,
mintingFee: "100",
currency: MockERC20.address,
Expand All @@ -151,17 +151,17 @@ describe("IP Asset Functions ", () => {
},
});
parentIpId = result.ipId!;
licenseTermsId = result.licenseTermsId!;
licenseTermsId = result.licenseTermsIds![0];
const mockERC20 = new MockERC20();
await mockERC20.approve(derivativeWorkflowsAddress[odyssey]);
await mockERC20.mint();
});

describe.skip("should not throw error when mint and register ip and attach pil terms", async () => {
it("Non-Commercial Remix", async () => {
describe("should not throw error when mint and register ip and attach pil terms", async () => {
it.skip("Non-Commercial Remix", async () => {
const result = await client.ipAsset.mintAndRegisterIpAssetWithPilTerms({
spgNftContract: nftContract,
pilType: PIL_TYPE.NON_COMMERCIAL_REMIX,
pilTypes: [PIL_TYPE.NON_COMMERCIAL_REMIX],
ipMetadata: {
ipMetadataURI: "test-uri",
ipMetadataHash: toHex("test-metadata-hash", { size: 32 }),
Expand All @@ -172,10 +172,10 @@ describe("IP Asset Functions ", () => {
});
expect(result.txHash).to.be.a("string").and.not.empty;
});
it("Commercial Use", async () => {
it.skip("Commercial Use", async () => {
const result = await client.ipAsset.mintAndRegisterIpAssetWithPilTerms({
spgNftContract: nftContract,
pilType: PIL_TYPE.COMMERCIAL_USE,
pilTypes: [PIL_TYPE.COMMERCIAL_USE],
commercialRevShare: 10,
mintingFee: "100",
currency: MockERC20.address,
Expand All @@ -189,12 +189,15 @@ describe("IP Asset Functions ", () => {
},
});
expect(result.txHash).to.be.a("string").and.not.empty;
expect(result.ipId).to.be.a("string").and.not.empty;
expect(result.licenseTermsIds).to.be.an("array").and.not.empty;
expect(result.tokenId).to.be.a("bigint");
});

it("Commercial Remix", async () => {
it.skip("Commercial Remix", async () => {
const result = await client.ipAsset.mintAndRegisterIpAssetWithPilTerms({
spgNftContract: nftContract,
pilType: PIL_TYPE.COMMERCIAL_REMIX,
pilTypes: [PIL_TYPE.COMMERCIAL_REMIX],
commercialRevShare: 10,
mintingFee: "100",
currency: MockERC20.address,
Expand All @@ -208,11 +211,14 @@ describe("IP Asset Functions ", () => {
},
});
expect(result.txHash).to.be.a("string").and.not.empty;
expect(result.ipId).to.be.a("string").and.not.empty;
expect(result.licenseTermsIds).to.be.an("array").and.not.empty;
expect(result.tokenId).to.be.a("bigint");
});
it("should get the related log when createIpAssetWithPilTerms given waitForTransaction is true ", async () => {
it("Multiple pilTypes", async () => {
const result = await client.ipAsset.mintAndRegisterIpAssetWithPilTerms({
spgNftContract: nftContract,
pilType: PIL_TYPE.COMMERCIAL_REMIX,
pilTypes: [PIL_TYPE.COMMERCIAL_REMIX, PIL_TYPE.COMMERCIAL_USE],
commercialRevShare: 10,
mintingFee: "100",
currency: MockERC20.address,
Expand All @@ -222,8 +228,8 @@ describe("IP Asset Functions ", () => {
});
expect(result.txHash).to.be.a("string").and.not.empty;
expect(result.ipId).to.be.a("string").and.not.empty;
expect(result.licenseTermsIds).to.be.an("array").length(2);
expect(result.tokenId).to.be.a("bigint");
expect(result.licenseTermsId).to.be.a("bigint");
});
});
it.skip("should not throw error when register a IP Asset given metadata", async () => {
Expand Down Expand Up @@ -311,7 +317,7 @@ describe("IP Asset Functions ", () => {
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 () => {
it.skip("should not throw error when call register pil terms and attach", async () => {
const tokenId = await getTokenId();
const ipId = (
await client.ipAsset.register({
Expand Down Expand Up @@ -434,7 +440,7 @@ describe("IP Asset Functions ", () => {
});
});

describe.skip("Multicall", () => {
describe("Multicall", () => {
let nftContract: Hex;
beforeEach(async () => {
const txData = await client.nftClient.createNFTCollection({
Expand Down Expand Up @@ -496,14 +502,14 @@ describe("IP Asset Functions ", () => {
args: [
{
spgNftContract: nftContract,
pilType: PIL_TYPE.COMMERCIAL_REMIX,
pilTypes: [PIL_TYPE.COMMERCIAL_REMIX, PIL_TYPE.COMMERCIAL_USE],
commercialRevShare: 10,
mintingFee: "100",
currency: MockERC20.address,
},
{
spgNftContract: nftContract,
pilType: PIL_TYPE.COMMERCIAL_REMIX,
pilTypes: [PIL_TYPE.COMMERCIAL_REMIX],
commercialRevShare: 10,
mintingFee: "100",
currency: MockERC20.address,
Expand All @@ -515,6 +521,7 @@ describe("IP Asset Functions ", () => {
});
expect(result.txHash).to.be.a("string").and.not.empty;
expect(result.results).to.be.an("array").and.not.empty;
expect(result.results![0].licenseTermsIds).to.be.an("array").and.length(2);
});

it("should not throw error when call batch mint and register ip asset and make derivative", async () => {
Expand Down
Loading