Skip to content

Commit b3ca827

Browse files
authored
Update the related methods (#383)
* Update methods for new signature * Update ipAsset signature and unit tests * Fix group tests * Refactor the code
1 parent e76f3b6 commit b3ca827

File tree

21 files changed

+3667
-4722
lines changed

21 files changed

+3667
-4722
lines changed

packages/core-sdk/src/abi/generated.ts

Lines changed: 1900 additions & 3607 deletions
Large diffs are not rendered by default.

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

Lines changed: 109 additions & 68 deletions
Large diffs are not rendered by default.

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

Lines changed: 422 additions & 482 deletions
Large diffs are not rendered by default.

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ export class PermissionClient {
300300
permissions,
301301
chainId: chain[this.chainId],
302302
wallet: this.wallet as WalletClient,
303-
permissionFunc: "setBatchPermissions",
304303
});
305304
const req = {
306305
to: getAddress(this.accessControllerClient.address, "accessControllerAddress"),
Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
1-
import { Hex } from "viem";
1+
import { Address, Hex } from "viem";
22

33
import { TxOptions } from "./options";
4+
import { IpMetadataForWorkflow } from "../utils/getIpMetadataForWorkflow";
45

56
export type TypedData = {
67
interface: string;
78
data: unknown[];
89
};
910

1011
export type IpMetadataAndTxOption = {
11-
ipMetadata?: {
12-
ipMetadataURI?: string;
13-
ipMetadataHash?: Hex;
14-
nftMetadataURI?: string;
15-
nftMetadataHash?: Hex;
16-
};
12+
ipMetadata?: Partial<IpMetadataForWorkflow>;
1713
txOptions?: TxOptions;
1814
};
15+
16+
export type LicensingConfig = {
17+
isSet: boolean;
18+
mintingFee: bigint | string | number;
19+
licensingHook: Address;
20+
hookData: Hex;
21+
commercialRevShare: number | string;
22+
disabled: boolean;
23+
expectMinimumGroupRewardShare: number | string;
24+
expectGroupRewardPool: Address;
25+
};
26+
27+
export type InnerLicensingConfig = {
28+
mintingFee: bigint;
29+
commercialRevShare: number;
30+
expectMinimumGroupRewardShare: number;
31+
} & LicensingConfig;

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

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,27 @@ import { Address } from "viem";
22

33
import { TxOptions } from "../options";
44
import { EncodedTxData } from "../../abi/generated";
5-
import { IpMetadataAndTxOption } from "../common";
5+
import { InnerLicensingConfig, IpMetadataAndTxOption, LicensingConfig } from "../common";
6+
7+
export type LicenseData = {
8+
licenseTermsId: string | bigint | number;
9+
licensingConfig: LicensingConfig;
10+
licenseTemplate?: Address;
11+
};
12+
13+
export type InnerLicenseData = {
14+
licenseTermsId: bigint;
15+
licensingConfig: InnerLicensingConfig;
16+
licenseTemplate: Address;
17+
};
618

719
export type MintAndRegisterIpAndAttachLicenseAndAddToGroupRequest = {
820
spgNftContract: Address;
9-
licenseTermsId: string | bigint | number;
1021
groupId: Address;
22+
allowDuplicates: boolean;
1123
recipient?: Address;
12-
licenseTemplate?: Address;
1324
deadline?: string | number | bigint;
25+
licenseData: LicenseData[];
1426
} & IpMetadataAndTxOption;
1527

1628
export type MintAndRegisterIpAndAttachLicenseAndAddToGroupResponse = {
@@ -34,9 +46,8 @@ export type RegisterIpAndAttachLicenseAndAddToGroupRequest = {
3446
nftContract: Address;
3547
tokenId: bigint | string | number;
3648
groupId: Address;
37-
licenseTermsId: bigint | string | number;
38-
licenseTemplate?: Address;
3949
deadline?: bigint;
50+
licenseData: LicenseData[];
4051
} & IpMetadataAndTxOption;
4152

4253
export type RegisterIpAndAttachLicenseAndAddToGroupResponse = {
@@ -47,8 +58,7 @@ export type RegisterIpAndAttachLicenseAndAddToGroupResponse = {
4758
};
4859
export type RegisterGroupAndAttachLicenseRequest = {
4960
groupPool: Address;
50-
licenseTermsId: bigint | string | number;
51-
licenseTemplate?: Address;
61+
licenseData: LicenseData;
5262
txOptions?: TxOptions;
5363
};
5464

@@ -61,8 +71,7 @@ export type RegisterGroupAndAttachLicenseResponse = {
6171
export type RegisterGroupAndAttachLicenseAndAddIpsRequest = {
6272
groupPool: Address;
6373
ipIds: Address[];
64-
licenseTermsId: bigint | string | number;
65-
licenseTemplate?: Address;
74+
licenseData: LicenseData;
6675
txOptions?: TxOptions;
6776
};
6877

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

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { Address, Hex } from "viem";
33
import { TxOptions } from "../options";
44
import { RegisterPILTermsRequest } from "./license";
55
import { EncodedTxData } from "../../abi/generated";
6-
import { IpMetadataAndTxOption } from "../common";
6+
import { IpMetadataAndTxOption, LicensingConfig } from "../common";
7+
import { IpMetadataForWorkflow } from "../../utils/getIpMetadataForWorkflow";
78

89
export type DerivativeData = {
910
parentIpIds: Address[];
@@ -56,10 +57,14 @@ export type RegisterDerivativeResponse = {
5657
txHash?: Hex;
5758
encodedTxData?: EncodedTxData;
5859
};
59-
60+
export type LicenseTermsData<T, U> = {
61+
terms: T;
62+
licensingConfig: U;
63+
};
6064
export type MintAndRegisterIpAssetWithPilTermsRequest = {
6165
spgNftContract: Address;
62-
terms: RegisterPILTermsRequest[];
66+
allowDuplicates: boolean;
67+
licenseTermsData: LicenseTermsData<RegisterPILTermsRequest, LicensingConfig>[];
6368
recipient?: Address;
6469
royaltyPolicyAddress?: Address;
6570
} & IpMetadataAndTxOption;
@@ -76,10 +81,11 @@ export type RegisterIpAndMakeDerivativeRequest = {
7681
nftContract: Address;
7782
tokenId: string | number | bigint;
7883
deadline?: string | number | bigint;
79-
derivData: {
80-
parentIpIds: Address[];
81-
licenseTermsIds: string[] | bigint[] | number[];
82-
licenseTemplate?: Address;
84+
derivData: DerivativeData;
85+
sigMetadataAndRegister?: {
86+
signer: Address;
87+
deadline: bigint | string | number;
88+
signature: Hex;
8389
};
8490
} & IpMetadataAndTxOption;
8591

@@ -93,7 +99,7 @@ export type RegisterIpAndMakeDerivativeResponse = {
9399
export type RegisterIpAndAttachPilTermsRequest = {
94100
nftContract: Address;
95101
tokenId: bigint | string | number;
96-
terms: RegisterPILTermsRequest[];
102+
licenseTermsData: LicenseTermsData<RegisterPILTermsRequest, LicensingConfig>[];
97103
deadline?: bigint | number | string;
98104
} & IpMetadataAndTxOption;
99105

@@ -107,12 +113,9 @@ export type RegisterIpAndAttachPilTermsResponse = {
107113

108114
export type MintAndRegisterIpAndMakeDerivativeRequest = {
109115
spgNftContract: Address;
110-
derivData: {
111-
parentIpIds: Address[];
112-
licenseTermsIds: string[] | bigint[] | number[];
113-
licenseTemplate?: Address;
114-
};
116+
derivData: DerivativeData;
115117
recipient?: Address;
118+
allowDuplicates: boolean;
116119
} & IpMetadataAndTxOption;
117120

118121
export type MintAndRegisterIpAndMakeDerivativeResponse = {
@@ -216,11 +219,12 @@ export type IpMetadata = {
216219
export type MintAndRegisterIpRequest = {
217220
spgNftContract: Address;
218221
recipient?: Address;
222+
allowDuplicates: boolean;
219223
} & IpMetadataAndTxOption;
220224

221225
export type RegisterPilTermsAndAttachRequest = {
222226
ipId: Address;
223-
terms: RegisterPILTermsRequest[];
227+
licenseTermsData: LicenseTermsData<RegisterPILTermsRequest, LicensingConfig>[];
224228
deadline?: string | number | bigint;
225229
txOptions?: TxOptions;
226230
};
@@ -235,13 +239,16 @@ export type MintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest = {
235239
spgNftContract: Address;
236240
licenseTokenIds: string[] | bigint[] | number[];
237241
recipient?: Address;
242+
maxRts: number | string;
243+
allowDuplicates: boolean;
238244
} & IpMetadataAndTxOption;
239245

240246
export type RegisterIpAndMakeDerivativeWithLicenseTokensRequest = {
241247
nftContract: Address;
242248
tokenId: string | number | bigint;
243249
licenseTokenIds: string[] | bigint[] | number[];
244250
deadline?: string | number | bigint;
251+
maxRts: number | string;
245252
} & IpMetadataAndTxOption;
246253

247254
export type BatchMintAndRegisterIpAssetWithPilTermsRequest = {
@@ -290,7 +297,7 @@ export type BatchRegisterResponse = {
290297
export type RegisterIPAndAttachLicenseTermsAndDistributeRoyaltyTokensRequest = {
291298
nftContract: Address;
292299
tokenId: bigint | string | number;
293-
terms: RegisterPILTermsRequest[];
300+
licenseTermsData: LicenseTermsData<RegisterPILTermsRequest, LicensingConfig>[];
294301
deadline?: string | number | bigint;
295302
royaltyShares: RoyaltyShare[];
296303
txOptions?: Omit<TxOptions, "encodedTxDataOnly">;
@@ -324,8 +331,9 @@ export type RegisterDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensReq
324331
deadline?: string | number | bigint;
325332
derivData: DerivativeData;
326333
royaltyShares: RoyaltyShare[];
334+
ipMetadata?: IpMetadataForWorkflow;
327335
txOptions?: Omit<TxOptions, "encodedTxDataOnly">;
328-
} & IPMetadataInfo;
336+
};
329337

330338
export type RegisterDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensResponse = {
331339
registerDerivativeIpAndAttachLicenseTermsAndDistributeRoyaltyTokensTxHash: Address;
@@ -337,7 +345,11 @@ export type RegisterDerivativeAndAttachLicenseTermsAndDistributeRoyaltyTokensRes
337345

338346
export type MintAndRegisterIpAndAttachPILTermsAndDistributeRoyaltyTokensRequest = {
339347
spgNftContract: Address;
340-
terms: RegisterPILTermsRequest[];
348+
allowDuplicates: boolean;
349+
licenseTermsData: {
350+
terms: RegisterPILTermsRequest;
351+
licensingConfig: LicensingConfig;
352+
}[];
341353
royaltyShares: RoyaltyShare[];
342354
recipient?: Address;
343355
txOptions?: Omit<TxOptions, "encodedTxDataOnly">;

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { Address, Hex } from "viem";
1+
import { Address } from "viem";
22

33
import { TxOptions } from "../options";
44
import { EncodedTxData } from "../../abi/generated";
5+
import { LicensingConfig } from "../common";
56

67
export type LicenseApiResponse = {
78
data: License;
@@ -137,19 +138,15 @@ export type PredictMintingLicenseFeeRequest = {
137138
txOptions?: TxOptions;
138139
};
139140

141+
export type InnerLicensingConfig = {
142+
mintingFee: bigint;
143+
commercialRevShare: number;
144+
expectMinimumGroupRewardShare: number;
145+
} & LicensingConfig;
140146
export type SetLicensingConfigRequest = {
141147
ipId: Address;
142148
licenseTermsId: string | number | bigint;
143-
licensingConfig: {
144-
isSet: boolean;
145-
mintingFee: bigint | string | number;
146-
licensingHook: Address;
147-
hookData: Hex;
148-
commercialRevShare: number | string;
149-
disabled: boolean;
150-
expectMinimumGroupRewardShare: number | string;
151-
expectGroupRewardPool: Address;
152-
};
149+
licensingConfig: LicensingConfig;
153150
licenseTemplate: Address;
154151
txOptions?: TxOptions;
155152
};

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export type PermissionSignatureRequest = {
5858
wallet: WalletClient;
5959
chainId: string | number | bigint;
6060
permissions: Omit<SetPermissionsRequest, "txOptions">[];
61-
permissionFunc?: "setPermission" | "setBatchPermissions";
6261
};
6362

6463
export type SignatureRequest = {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Hex, zeroHash } from "viem";
2+
3+
export type IpMetadataForWorkflow = {
4+
ipMetadataURI: string;
5+
ipMetadataHash: Hex;
6+
nftMetadataURI: string;
7+
nftMetadataHash: Hex;
8+
};
9+
10+
export const getIpMetadataForWorkflow = (
11+
metadata?: Partial<IpMetadataForWorkflow>,
12+
): IpMetadataForWorkflow => {
13+
return {
14+
ipMetadataURI: metadata?.ipMetadataURI || "",
15+
ipMetadataHash: metadata?.ipMetadataHash || zeroHash,
16+
nftMetadataURI: metadata?.nftMetadataURI || "",
17+
nftMetadataHash: metadata?.nftMetadataHash || zeroHash,
18+
};
19+
};

0 commit comments

Comments
 (0)