Skip to content

Commit

Permalink
Update logic to check the first license terms of commercial
Browse files Browse the repository at this point in the history
  • Loading branch information
bonnie57 committed Dec 17, 2024
1 parent 8c97d53 commit 1cea5b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions packages/core-sdk/src/resources/ipAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,7 @@ 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.
Expand Down Expand Up @@ -1569,8 +1569,8 @@ export class IPAssetClient {
const licenseTerms: LicenseTerms[] = [];
for (let i = 0; i < request.terms.length; i++) {
const term = request.terms[i];
if (!term.commercialUse) {
throw new Error("Commercial use is required to deploy a royalty vault.");
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);
Expand Down Expand Up @@ -1826,7 +1826,7 @@ 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.
Expand Down Expand Up @@ -1869,8 +1869,8 @@ export class IPAssetClient {
const licenseTerms: LicenseTerms[] = [];
for (let i = 0; i < request.terms.length; i++) {
const term = request.terms[i];
if (!term.commercialUse) {
throw new Error("Commercial use is required to deploy a royalty vault.");
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);
Expand Down
4 changes: 2 additions & 2 deletions packages/core-sdk/test/unit/resources/ipAsset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2230,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.",
);
}
});
Expand Down Expand Up @@ -2626,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.",
);
}
});
Expand Down

0 comments on commit 1cea5b2

Please sign in to comment.