Skip to content

Commit e76f3b6

Browse files
authored
Merge pull request #380 from storyprotocol/bonnie/SDK-39
Integrate v1.3 smart contract
2 parents e2d628b + 4bfaad1 commit e76f3b6

29 files changed

+5540
-3674
lines changed

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

Lines changed: 3999 additions & 1777 deletions
Large diffs are not rendered by default.

packages/core-sdk/src/constants/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ export const AddressZero = "0x0000000000000000000000000000000000000000";
44
export const HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
55
export const defaultFunctionSelector: Hex = "0x00000000";
66
export const royaltySharesTotalSupply: number = 100000000;
7+
export const MAX_ROYALTY_TOKEN = 100000000;

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

Lines changed: 53 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import { PublicClient, WalletClient, toHex, zeroHash } from "viem";
22

33
import {
4+
coreMetadataModuleAbi,
45
CoreMetadataModuleClient,
6+
groupingModuleAbi,
57
GroupingModuleClient,
68
GroupingModuleEventClient,
79
GroupingModuleRegisterGroupRequest,
810
GroupingWorkflowsClient,
9-
GroupingWorkflowsMintAndRegisterIpAndAttachLicenseAndAddToGroupRequest,
10-
GroupingWorkflowsRegisterGroupAndAttachLicenseAndAddIpsRequest,
11-
GroupingWorkflowsRegisterIpAndAttachLicenseAndAddToGroupRequest,
11+
GroupingWorkflowsMintAndRegisterIpAndAttachLicenseAndAddToGroup2Request,
12+
GroupingWorkflowsRegisterGroupAndAttachLicenseAndAddIps2Request,
13+
GroupingWorkflowsRegisterIpAndAttachLicenseAndAddToGroup2Request,
1214
IpAccountImplClient,
1315
IpAssetRegistryClient,
1416
LicenseRegistryReadOnlyClient,
1517
LicenseTokenReadOnlyClient,
18+
licensingModuleAbi,
1619
LicensingModuleClient,
1720
PiLicenseTemplateClient,
1821
SimpleWalletClient,
@@ -34,6 +37,7 @@ import {
3437
RegisterIpAndAttachLicenseAndAddToGroupRequest,
3538
RegisterIpAndAttachLicenseAndAddToGroupResponse,
3639
} from "../types/resources/group";
40+
import { getFunctionSignature } from "../utils/getFunctionSignature";
3741

3842
export class GroupClient {
3943
public groupingWorkflowsClient: GroupingWorkflowsClient;
@@ -97,19 +101,20 @@ export class GroupClient {
97101
handleError(error, "Failed to register group");
98102
}
99103
}
100-
/** Mint an NFT from a SPGNFT collection, register it with metadata as an IP, attach license terms to the registered IP, and add it to a group IP.
104+
/** @deprecated This method is deprecated and will be removed in a future version */
105+
/** Mint an NFT from a SPGNFT collection, register it with metadata as an IP, attach license terms to the registered IP, and add it to a group IP.
101106
* @param request - The request object containing necessary data to mint and register Ip and attach license and add to group.
102107
* @param request.nftContract The address of the NFT collection.
103108
* @param request.groupId The ID of the group IP to add the newly registered IP.
104109
* @param request.licenseTermsId The ID of the registered license terms that will be attached to the new IP.
105110
* @param request.recipient [Optional] The address of the recipient of the minted NFT,default value is your wallet address.
106-
* @param request.licenseTemplate [Optional] The address of the license template to be attached to the new group IP,default value is Programmable IP License.
111+
* @param request.licenseTemplate [Optional] The address of the license template to be attached to the new group IP, default value is Programmable IP License.
107112
* . @param request.deadline [Optional] The deadline for the signature in seconds, default value is 1000s.
108-
* @param request.ipMetadata - [Optional] The desired metadata for the newly minted NFT and newly registered IP.
109-
* @param request.ipMetadata.ipMetadataURI [Optional] The URI of the metadata for the IP.
110-
* @param request.ipMetadata.ipMetadataHash [Optional] The hash of the metadata for the IP.
111-
* @param request.ipMetadata.nftMetadataURI [Optional] The URI of the metadata for the NFT.
112-
* @param request.ipMetadata.nftMetadataHash [Optional] The hash of the metadata for the IP NFT.
113+
* @param {Object} request.ipMetadata - [Optional] The desired metadata for the newly minted NFT and newly registered IP.
114+
* @param request.ipMetadata.ipMetadataURI [Optional] The URI of the metadata for the IP.
115+
* @param request.ipMetadata.ipMetadataHash [Optional] The hash of the metadata for the IP.
116+
* @param request.ipMetadata.nftMetadataURI [Optional] The URI of the metadata for the NFT.
117+
* @param request.ipMetadata.nftMetadataHash [Optional] The hash of the metadata for the IP NFT.
113118
* @param request.txOptions [Optional] This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property.
114119
* @returns A Promise that resolves to a transaction hash, and if encodedTxDataOnly is true, includes encoded transaction data, and if waitForTransaction is true, includes IP ID, token ID.
115120
* @emits IPRegistered (ipId, chainId, tokenContract, tokenId, resolverAddr, metadataProviderAddress, metadata)
@@ -141,12 +146,12 @@ export class GroupClient {
141146
signer: getAddress(this.groupingWorkflowsClient.address, "groupingWorkflowsClient"),
142147
to: getAddress(this.groupingModuleClient.address, "groupingModuleClient"),
143148
permission: AccessPermission.ALLOW,
144-
func: "function addIp(address,address[])",
149+
func: getFunctionSignature(groupingModuleAbi, "addIp"),
145150
},
146151
],
147152
});
148153

149-
const object: GroupingWorkflowsMintAndRegisterIpAndAttachLicenseAndAddToGroupRequest = {
154+
const object: GroupingWorkflowsMintAndRegisterIpAndAttachLicenseAndAddToGroup2Request = {
150155
...request,
151156
spgNftContract: getAddress(spgNftContract, "request.spgNftContract"),
152157
recipient:
@@ -170,13 +175,15 @@ export class GroupClient {
170175
if (request.txOptions?.encodedTxDataOnly) {
171176
return {
172177
encodedTxData:
173-
this.groupingWorkflowsClient.mintAndRegisterIpAndAttachLicenseAndAddToGroupEncode(
178+
this.groupingWorkflowsClient.mintAndRegisterIpAndAttachLicenseAndAddToGroup2Encode(
174179
object,
175180
),
176181
};
177182
} else {
178183
const txHash =
179-
await this.groupingWorkflowsClient.mintAndRegisterIpAndAttachLicenseAndAddToGroup(object);
184+
await this.groupingWorkflowsClient.mintAndRegisterIpAndAttachLicenseAndAddToGroup2(
185+
object,
186+
);
180187
if (request.txOptions?.waitForTransaction) {
181188
const receipt = await this.rpcClient.waitForTransactionReceipt({
182189
...request.txOptions,
@@ -191,19 +198,20 @@ export class GroupClient {
191198
handleError(error, "Failed to mint and register IP and attach license and add to group");
192199
}
193200
}
201+
/** @deprecated This method is deprecated and will be removed in a future version */
194202
/** Register an NFT as IP with metadata, attach license terms to the registered IP, and add it to a group IP.
195203
* @param request - The request object containing necessary data to register ip and attach license and add to group.
196204
* @param request.spgNftContract The address of the NFT collection.
197205
* @param request.tokenId The ID of the NFT.
198206
* @param request.groupId The ID of the group IP to add the newly registered IP.
199207
* @param request.licenseTermsId The ID of the registered license terms that will be attached to the new IP.
200-
* @param request.licenseTemplate [Optional] The address of the license template to be attached to the new group IP,default value is Programmable IP License.
208+
* @param request.licenseTemplate [Optional] The address of the license template to be attached to the new group IP, default value is Programmable IP License.
201209
* . @param request.deadline [Optional] The deadline for the signature in seconds, default is 1000s.
202-
* @param request.ipMetadata - [Optional] The desired metadata for the newly minted NFT and newly registered IP.
203-
* @param request.ipMetadata.ipMetadataURI [Optional] The URI of the metadata for the IP.
204-
* @param request.ipMetadata.ipMetadataHash [Optional] The hash of the metadata for the IP.
205-
* @param request.ipMetadata.nftMetadataURI [Optional] The URI of the metadata for the NFT.
206-
* @param request.ipMetadata.nftMetadataHash [Optional] The hash of the metadata for the IP NFT.
210+
* @param {Object} request.ipMetadata - [Optional] The desired metadata for the newly minted NFT and newly registered IP.
211+
* @param request.ipMetadata.ipMetadataURI [Optional] The URI of the metadata for the IP.
212+
* @param request.ipMetadata.ipMetadataHash [Optional] The hash of the metadata for the IP.
213+
* @param request.ipMetadata.nftMetadataURI [Optional] The URI of the metadata for the NFT.
214+
* @param request.ipMetadata.nftMetadataHash [Optional] The hash of the metadata for the IP NFT.
207215
* @param request.txOptions [Optional] This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property.
208216
* @returns A Promise that resolves to a transaction hash, and if encodedTxDataOnly is true, includes encoded transaction data, and if waitForTransaction is true, includes IP ID, token ID.
209217
* @emits IPRegistered (ipId, chainId, tokenContract, tokenId, resolverAddr, metadataProviderAddress, metadata)
@@ -227,6 +235,7 @@ export class GroupClient {
227235
const { result: state } = await ipAccount.state();
228236
const blockTimestamp = (await this.rpcClient.getBlock()).timestamp;
229237
const calculatedDeadline = getDeadline(blockTimestamp, request.deadline);
238+
230239
const { signature: sigAddToGroupSignature } = await getPermissionSignature({
231240
ipId: getAddress(request.groupId, "request.groupId"),
232241
deadline: calculatedDeadline,
@@ -236,10 +245,10 @@ export class GroupClient {
236245
permissions: [
237246
{
238247
ipId: getAddress(request.groupId, "request.groupId"),
239-
signer: getAddress(this.groupingWorkflowsClient.address, "groupingWorkflowsClient"),
240-
to: getAddress(this.groupingModuleClient.address, "groupingModuleClient"),
248+
signer: this.groupingWorkflowsClient.address,
249+
to: this.groupingModuleClient.address,
241250
permission: AccessPermission.ALLOW,
242-
func: "function addIp(address,address[])",
251+
func: getFunctionSignature(groupingModuleAbi, "addIp"),
243252
},
244253
],
245254
});
@@ -253,21 +262,28 @@ export class GroupClient {
253262
permissions: [
254263
{
255264
ipId: ipIdAddress,
256-
signer: getAddress(this.groupingWorkflowsClient.address, "groupingWorkflowsClient"),
265+
signer: this.groupingWorkflowsClient.address,
257266
to: getAddress(this.coreMetadataModuleClient.address, "coreMetadataModuleAddress"),
258267
permission: AccessPermission.ALLOW,
259-
func: "function setAll(address,string,bytes32,bytes32)",
268+
func: getFunctionSignature(coreMetadataModuleAbi, "setAll"),
260269
},
261270
{
262271
ipId: ipIdAddress,
263-
signer: getAddress(this.groupingWorkflowsClient.address, "groupingWorkflowsClient"),
272+
signer: this.groupingWorkflowsClient.address,
264273
to: getAddress(this.licensingModuleClient.address, "licensingModuleAddress"),
265274
permission: AccessPermission.ALLOW,
266-
func: "function attachLicenseTerms(address,address,uint256)",
275+
func: getFunctionSignature(licensingModuleAbi, "attachLicenseTerms"),
276+
},
277+
{
278+
ipId: ipIdAddress,
279+
signer: this.groupingWorkflowsClient.address,
280+
to: getAddress(this.licensingModuleClient.address, "licensingModuleAddress"),
281+
permission: AccessPermission.ALLOW,
282+
func: getFunctionSignature(licensingModuleAbi, "setLicensingConfig"),
267283
},
268284
],
269285
});
270-
const object: GroupingWorkflowsRegisterIpAndAttachLicenseAndAddToGroupRequest = {
286+
const object: GroupingWorkflowsRegisterIpAndAttachLicenseAndAddToGroup2Request = {
271287
nftContract: getAddress(request.nftContract, "request.nftContract"),
272288
groupId: request.groupId,
273289
licenseTemplate:
@@ -287,7 +303,7 @@ export class GroupClient {
287303
deadline: calculatedDeadline,
288304
signature: sigAddToGroupSignature,
289305
},
290-
sigMetadataAndAttach: {
306+
sigMetadataAndAttachAndConfig: {
291307
signer: getAddress(this.wallet.account!.address, "wallet.account.address"),
292308
deadline: calculatedDeadline,
293309
signature: sigMetadataAndAttachSignature,
@@ -296,10 +312,10 @@ export class GroupClient {
296312
if (request.txOptions?.encodedTxDataOnly) {
297313
return {
298314
encodedTxData:
299-
this.groupingWorkflowsClient.registerIpAndAttachLicenseAndAddToGroupEncode(object),
315+
this.groupingWorkflowsClient.registerIpAndAttachLicenseAndAddToGroup2Encode(object),
300316
};
301317
}
302-
const txHash = await this.groupingWorkflowsClient.registerIpAndAttachLicenseAndAddToGroup(
318+
const txHash = await this.groupingWorkflowsClient.registerIpAndAttachLicenseAndAddToGroup2(
303319
object,
304320
);
305321
if (request.txOptions?.waitForTransaction) {
@@ -356,12 +372,13 @@ export class GroupClient {
356372
handleError(error, "Failed to register group and attach license");
357373
}
358374
}
375+
/** @deprecated This method is deprecated and will be removed in a future version */
359376
/** Register a group IP with a group reward pool, attach license terms to the group IP, and add individual IPs to the group IP.
360377
* @param request - The request object containing necessary data to register group and attach license and add ips.
361-
* @param request.pIds must have the same PIL terms as the group IP.
378+
* @param request.ipIds The IP IDs of the IPs to be added to the group.
362379
* @param request.groupPool The address specifying how royalty will be split amongst the pool of IPs in the group.
363380
* @param request.licenseTermsId The ID of the registered license terms that will be attached to the new group IP.
364-
* @param request.licenseTemplate [Optional] The address of the license template to be attached to the new group IP,default value is Programmable IP License.
381+
* @param request.licenseTemplate [Optional] The address of the license template to be attached to the new group IP, default value is Programmable IP License.
365382
* @param request.txOptions [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property.
366383
* @returns A Promise that resolves to a transaction hash, and if encodedTxDataOnly is true, includes encoded transaction data, and if waitForTransaction is true, includes group id.
367384
* @emits PGroupRegistered (groupId, groupPool);
@@ -396,7 +413,7 @@ export class GroupClient {
396413
);
397414
}
398415
}
399-
const object: GroupingWorkflowsRegisterGroupAndAttachLicenseAndAddIpsRequest = {
416+
const object: GroupingWorkflowsRegisterGroupAndAttachLicenseAndAddIps2Request = {
400417
groupPool: getAddress(request.groupPool, "request.groupPool"),
401418
ipIds: request.ipIds,
402419
licenseTemplate: request.licenseTemplate,
@@ -405,10 +422,10 @@ export class GroupClient {
405422
if (request.txOptions?.encodedTxDataOnly) {
406423
return {
407424
encodedTxData:
408-
this.groupingWorkflowsClient.registerGroupAndAttachLicenseAndAddIpsEncode(object),
425+
this.groupingWorkflowsClient.registerGroupAndAttachLicenseAndAddIps2Encode(object),
409426
};
410427
}
411-
const txHash = await this.groupingWorkflowsClient.registerGroupAndAttachLicenseAndAddIps(
428+
const txHash = await this.groupingWorkflowsClient.registerGroupAndAttachLicenseAndAddIps2(
412429
object,
413430
);
414431
if (request.txOptions?.waitForTransaction) {

0 commit comments

Comments
 (0)