Skip to content

Commit fe0bb1e

Browse files
authored
Merge pull request #429 from storyprotocol/feat/make-allow-duplicates-optional
Update allowDuplicates optional
2 parents 1402f8d + 5926906 commit fe0bb1e

File tree

12 files changed

+288
-46
lines changed

12 files changed

+288
-46
lines changed

packages/core-sdk/src/resources/group.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ export class GroupClient {
145145
});
146146
const object: GroupingWorkflowsMintAndRegisterIpAndAttachLicenseAndAddToGroupRequest = {
147147
...request,
148+
allowDuplicates: request.allowDuplicates || true,
148149
spgNftContract: getAddress(spgNftContract, "request.spgNftContract"),
149150
recipient:
150151
(recipient && getAddress(recipient, "request.recipient")) || this.wallet.account!.address,

packages/core-sdk/src/resources/ipAsset.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ export class IPAssetClient {
664664
(request.recipient && getAddress(request.recipient, "request.recipient")) ||
665665
this.wallet.account!.address,
666666
licenseTermsData,
667-
allowDuplicates: request.allowDuplicates,
667+
allowDuplicates: request.allowDuplicates || true,
668668
ipMetadata: getIpMetadataForWorkflow(request.ipMetadata),
669669
};
670670

@@ -983,7 +983,7 @@ export class IPAssetClient {
983983
derivData,
984984
ipMetadata: getIpMetadataForWorkflow(request.ipMetadata),
985985
recipient,
986-
allowDuplicates: request.allowDuplicates,
986+
allowDuplicates: request.allowDuplicates || true,
987987
spgNftContract,
988988
};
989989
const encodedTxData =
@@ -1086,7 +1086,7 @@ export class IPAssetClient {
10861086
(request.recipient && getAddress(request.recipient, "request.recipient")) ||
10871087
this.wallet.account!.address,
10881088
ipMetadata: getIpMetadataForWorkflow(request.ipMetadata),
1089-
allowDuplicates: request.allowDuplicates,
1089+
allowDuplicates: request.allowDuplicates || true,
10901090
};
10911091
const encodedTxData = this.registrationWorkflowsClient.mintAndRegisterIpEncode(object);
10921092
if (request.txOptions?.encodedTxDataOnly) {
@@ -1225,7 +1225,7 @@ export class IPAssetClient {
12251225
licenseTokenIds: licenseTokenIds,
12261226
royaltyContext: zeroAddress,
12271227
maxRts: Number(request.maxRts),
1228-
allowDuplicates: request.allowDuplicates,
1228+
allowDuplicates: request.allowDuplicates || true,
12291229
};
12301230
this.validateMaxRts(object.maxRts);
12311231

@@ -1592,7 +1592,7 @@ export class IPAssetClient {
15921592
ipMetadata: getIpMetadataForWorkflow(request.ipMetadata),
15931593
licenseTermsData,
15941594
royaltyShares,
1595-
allowDuplicates: request.allowDuplicates,
1595+
allowDuplicates: request.allowDuplicates || true,
15961596
};
15971597
const encodedTxData =
15981598
this.royaltyTokenDistributionWorkflowsClient.mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokensEncode(
@@ -1653,7 +1653,7 @@ export class IPAssetClient {
16531653
ipMetadata: getIpMetadataForWorkflow(request.ipMetadata),
16541654
derivData,
16551655
royaltyShares: royaltyShares,
1656-
allowDuplicates: request.allowDuplicates,
1656+
allowDuplicates: request.allowDuplicates || true,
16571657
};
16581658

16591659
const encodedTxData =

packages/core-sdk/src/types/resources/group.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ export type MintAndRegisterIpAndAttachLicenseAndAddToGroupRequest = {
1919
spgNftContract: Address;
2020
/** The ID of the group IP to add the newly registered IP. */
2121
groupId: Address;
22-
/** Set to true to allow minting an NFT with a duplicate metadata hash. */
23-
allowDuplicates: boolean;
22+
/**
23+
* Set to true to allow minting an NFT with a duplicate metadata hash.
24+
* @default true
25+
*/
26+
allowDuplicates?: boolean;
2427
/** The maximum reward share percentage that can be allocated to each member IP. */
2528
maxAllowedRewardShare: number | string;
2629
/** The data of the license and its configuration to be attached to the new group IP. */

packages/core-sdk/src/types/resources/ipAsset.ts

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,11 @@ export type ValidatedLicenseTermsData = Omit<
8383

8484
export type MintAndRegisterIpAssetWithPilTermsRequest = {
8585
spgNftContract: Address;
86-
/** Indicates whether the license terms can be attached to the same IP ID or not. */
87-
allowDuplicates: boolean;
86+
/**
87+
* Set to true to allow minting an NFT with a duplicate metadata hash.
88+
* @default true
89+
*/
90+
allowDuplicates?: boolean;
8891
/** The data of the license and its configuration to be attached to the IP. */
8992
licenseTermsData: LicenseTermsData[];
9093
/** The address to receive the minted NFT. If not provided, the function will use the user's own wallet address. */
@@ -147,8 +150,11 @@ export type MintAndRegisterIpAndMakeDerivativeRequest = {
147150
derivData: DerivativeData;
148151
/** The address to receive the minted NFT. If not provided, the function will use the user's own wallet address. */
149152
recipient?: Address;
150-
/** Set to true to allow minting an NFT with a duplicate metadata hash. */
151-
allowDuplicates: boolean;
153+
/**
154+
* Set to true to allow minting an NFT with a duplicate metadata hash.
155+
* @default true
156+
*/
157+
allowDuplicates?: boolean;
152158
} & IpMetadataAndTxOptions &
153159
WithWipOptions;
154160

@@ -252,7 +258,11 @@ export type MintAndRegisterIpRequest = IpMetadataAndTxOptions &
252258
WithWipOptions & {
253259
spgNftContract: Address;
254260
recipient?: Address;
255-
allowDuplicates: boolean;
261+
/**
262+
* Set to true to allow minting an NFT with a duplicate metadata hash.
263+
* @default true
264+
*/
265+
allowDuplicates?: boolean;
256266
};
257267
export type RegisterPilTermsAndAttachRequest = {
258268
ipId: Address;
@@ -276,7 +286,11 @@ export type MintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest = {
276286
licenseTokenIds: string[] | bigint[] | number[];
277287
recipient?: Address;
278288
maxRts: number | string;
279-
allowDuplicates: boolean;
289+
/**
290+
* Set to true to allow minting an NFT with a duplicate metadata hash.
291+
* @default true
292+
*/
293+
allowDuplicates?: boolean;
280294
} & IpMetadataAndTxOptions &
281295
WithWipOptions;
282296

@@ -401,8 +415,11 @@ export type RegisterDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensRes
401415
export type MintAndRegisterIpAndAttachPILTermsAndDistributeRoyaltyTokensRequest = {
402416
/** The address of the SPG NFT contract. */
403417
spgNftContract: Address;
404-
/** Set to true to allow minting an NFT with a duplicate metadata hash. */
405-
allowDuplicates: boolean;
418+
/**
419+
* Set to true to allow minting an NFT with a duplicate metadata hash.
420+
* @default true
421+
*/
422+
allowDuplicates?: boolean;
406423
/** The data of the license and its configuration to be attached to the new group IP. */
407424
licenseTermsData: LicenseTermsData[];
408425
/** Authors of the IP and their shares of the royalty tokens */
@@ -427,8 +444,11 @@ export type MintAndRegisterIpAndMakeDerivativeAndDistributeRoyaltyTokensRequest
427444
derivData: DerivativeData;
428445
/** Authors of the IP and their shares of the royalty tokens. */
429446
royaltyShares: RoyaltyShare[];
430-
/** Set to true to allow minting an NFT with a duplicate metadata hash. */
431-
allowDuplicates: boolean;
447+
/**
448+
* Set to true to allow minting an NFT with a duplicate metadata hash.
449+
* @default true
450+
*/
451+
allowDuplicates?: boolean;
432452
/** The address to receive the minted NFT. If not provided, the function will use the user's own wallet address. */
433453
recipient?: Address;
434454
txOptions?: Omit<TxOptions, "encodedTxDataOnly">;

packages/core-sdk/test/integration/dispute.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ describe("Dispute Functions", () => {
273273
maxRts: 5 * 10 ** 6,
274274
maxRevenueShare: 100,
275275
},
276-
allowDuplicates: true,
277276
txOptions: { waitForTransaction: true },
278277
});
279278
childIpId = derivativeIpIdResponse1.ipId!;
@@ -288,7 +287,6 @@ describe("Dispute Functions", () => {
288287
maxRts: 5 * 10 ** 6,
289288
maxRevenueShare: 100,
290289
},
291-
allowDuplicates: true,
292290
txOptions: { waitForTransaction: true },
293291
});
294292
childIpId2 = derivativeIpIdResponse2.ipId!;

packages/core-sdk/test/integration/group.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ describe("Group Functions", () => {
167167
},
168168
},
169169
],
170-
allowDuplicates: true,
171170
maxAllowedRewardShare: 5,
172171
txOptions: { waitForTransaction: true },
173172
});

packages/core-sdk/test/integration/ipAsset.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ describe("IP Asset Functions", () => {
419419
maxRts: 5 * 10 ** 6,
420420
maxRevenueShare: 100,
421421
},
422-
allowDuplicates: true,
423422
txOptions: { waitForTransaction: true },
424423
});
425424
expect(result.txHash).to.be.a("string").and.not.empty;
@@ -503,7 +502,6 @@ describe("IP Asset Functions", () => {
503502
spgNftContract: nftContract,
504503
licenseTokenIds: [mintLicenseTokensResult.licenseTokenIds![0]],
505504
maxRts: 5 * 10 ** 6,
506-
allowDuplicates: true,
507505
ipMetadata: {
508506
ipMetadataURI: "test-uri",
509507
ipMetadataHash: toHex("test-metadata-hash", { size: 32 }),
@@ -938,7 +936,6 @@ describe("IP Asset Functions", () => {
938936
const result =
939937
await client.ipAsset.mintAndRegisterIpAndAttachPilTermsAndDistributeRoyaltyTokens({
940938
spgNftContract: nftContract,
941-
allowDuplicates: true,
942939
licenseTermsData: [
943940
{
944941
terms: {
@@ -1009,7 +1006,6 @@ describe("IP Asset Functions", () => {
10091006
// create parent ip with minting fee
10101007
const result = await client.ipAsset.mintAndRegisterIpAssetWithPilTerms({
10111008
spgNftContract: nftContractWithMintingFee,
1012-
allowDuplicates: true,
10131009
licenseTermsData: [
10141010
{
10151011
terms: {
@@ -1066,7 +1062,6 @@ describe("IP Asset Functions", () => {
10661062
nftMetadataURI: "test",
10671063
nftMetadataHash: zeroHash,
10681064
},
1069-
allowDuplicates: true,
10701065
txOptions: { waitForTransaction: true },
10711066
});
10721067
expect(rsp.txHash).to.be.a("string").and.not.empty;
@@ -1098,7 +1093,6 @@ describe("IP Asset Functions", () => {
10981093
spgNftContract: nftContractWithMintingFee,
10991094
licenseTokenIds: licenseTokenIds!,
11001095
maxRts: MAX_ROYALTY_TOKEN,
1101-
allowDuplicates: true,
11021096
ipMetadata: {
11031097
ipMetadataURI: "test",
11041098
ipMetadataHash: zeroHash,
@@ -1144,7 +1138,6 @@ describe("IP Asset Functions", () => {
11441138
maxRts: MAX_ROYALTY_TOKEN,
11451139
maxRevenueShare: 100,
11461140
},
1147-
allowDuplicates: true,
11481141
ipMetadata: {
11491142
ipMetadataURI: "test",
11501143
ipMetadataHash: zeroHash,
@@ -1211,7 +1204,6 @@ describe("IP Asset Functions", () => {
12111204
maxRts: MAX_ROYALTY_TOKEN,
12121205
maxRevenueShare: 100,
12131206
},
1214-
allowDuplicates: true,
12151207
ipMetadata: {
12161208
ipMetadataURI: "test",
12171209
ipMetadataHash: zeroHash,
@@ -1336,7 +1328,6 @@ describe("IP Asset Functions", () => {
13361328
},
13371329
},
13381330
],
1339-
allowDuplicates: true,
13401331
},
13411332
{
13421333
spgNftContract: nftContract,
@@ -1373,7 +1364,6 @@ describe("IP Asset Functions", () => {
13731364
},
13741365
},
13751366
],
1376-
allowDuplicates: true,
13771367
},
13781368
],
13791369
txOptions: { waitForTransaction: true },
@@ -1397,7 +1387,6 @@ describe("IP Asset Functions", () => {
13971387
maxRts: 5 * 10 ** 6,
13981388
maxRevenueShare: "0",
13991389
},
1400-
allowDuplicates: true,
14011390
},
14021391
{
14031392
spgNftContract: nftContract,
@@ -1408,7 +1397,6 @@ describe("IP Asset Functions", () => {
14081397
maxRts: 5 * 10 ** 6,
14091398
maxRevenueShare: "0",
14101399
},
1411-
allowDuplicates: true,
14121400
},
14131401
],
14141402
txOptions: { waitForTransaction: true },

packages/core-sdk/test/integration/royalty.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ describe("Royalty Functions", () => {
240240

241241
const retA = await client.ipAsset.mintAndRegisterIpAssetWithPilTerms({
242242
spgNftContract,
243-
allowDuplicates: true,
244243
licenseTermsData: [
245244
{
246245
terms: {
@@ -281,7 +280,6 @@ describe("Royalty Functions", () => {
281280

282281
const retB = await client.ipAsset.mintAndRegisterIpAndMakeDerivative({
283282
spgNftContract,
284-
allowDuplicates: true,
285283
derivData: {
286284
parentIpIds: [ipA!],
287285
licenseTermsIds: [licenseTermsId!],
@@ -295,7 +293,6 @@ describe("Royalty Functions", () => {
295293

296294
const retC = await client.ipAsset.mintAndRegisterIpAndMakeDerivative({
297295
spgNftContract,
298-
allowDuplicates: true,
299296
derivData: {
300297
parentIpIds: [ipB!],
301298
licenseTermsIds: [licenseTermsId!],
@@ -309,7 +306,6 @@ describe("Royalty Functions", () => {
309306

310307
const retD = await client.ipAsset.mintAndRegisterIpAndMakeDerivative({
311308
spgNftContract,
312-
allowDuplicates: true,
313309
derivData: {
314310
parentIpIds: [ipC!],
315311
licenseTermsIds: [licenseTermsId!],

packages/core-sdk/test/unit/mockData.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export const txHash = "0x063834efe214f4199b1ad7181ce8c5ced3e15d271c8e866da7c89e8
22
export const ipId = "0x73fcb515cee99e4991465ef586cfe2b072ebb512";
33
export const aeneid = 13_15;
44
export const mockERC20 = "0x73fcb515cee99e4991465ef586cfe2b072ebb512";
5+
export const walletAddress = "0x73fcb515cee99e4991465ef586cfe2b072ebb512";

packages/core-sdk/test/unit/resources/group.test.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import chai from "chai";
22
import { createMock } from "../testUtils";
33
import * as sinon from "sinon";
4-
import { PublicClient, WalletClient, Account, zeroAddress } from "viem";
4+
import { PublicClient, WalletClient, Account, zeroAddress, toHex, zeroHash, zeroHash } from "viem";
55
import chaiAsPromised from "chai-as-promised";
66
import { GroupClient } from "../../../src";
77
import { LicenseData } from "../../../src/types/resources/group";
8+
import { walletAddress } from "../mockData";
89
const { IpAccountImplClient } = require("../../../src/abi/generated");
910

1011
chai.use(chaiAsPromised);
@@ -376,6 +377,34 @@ describe("Test IpAssetClient", () => {
376377
});
377378
expect(result.encodedTxData!.data).to.be.a("string").and.not.empty;
378379
});
380+
381+
it("should call with default values when mintAndRegisterIpAndAttachLicenseAndAddToGroup without providing allowDuplicates, ipMetadata, recipient", async () => {
382+
sinon.stub(groupClient.ipAssetRegistryClient, "isRegistered").resolves(true);
383+
const mintAndRegisterIpAndAttachLicenseAndAddToGroupStub = sinon
384+
.stub(groupClient.groupingWorkflowsClient, "mintAndRegisterIpAndAttachLicenseAndAddToGroup")
385+
.resolves(txHash);
386+
await groupClient.mintAndRegisterIpAndAttachLicenseAndAddToGroup({
387+
groupId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c",
388+
maxAllowedRewardShare: 5,
389+
spgNftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c",
390+
licenseData: [mockLicenseData],
391+
});
392+
393+
expect(
394+
mintAndRegisterIpAndAttachLicenseAndAddToGroupStub.args[0][0].allowDuplicates,
395+
).to.equal(true);
396+
expect(
397+
mintAndRegisterIpAndAttachLicenseAndAddToGroupStub.args[0][0].ipMetadata,
398+
).to.deep.equal({
399+
ipMetadataURI: "",
400+
ipMetadataHash: zeroHash,
401+
nftMetadataURI: "",
402+
nftMetadataHash: zeroHash,
403+
});
404+
expect(mintAndRegisterIpAndAttachLicenseAndAddToGroupStub.args[0][0].recipient).to.equal(
405+
walletAddress,
406+
);
407+
});
379408
});
380409

381410
describe("Test groupClient.registerIpAndAttachLicenseAndAddToGroup", async () => {

0 commit comments

Comments
 (0)