Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5,776 changes: 3,999 additions & 1,777 deletions packages/core-sdk/src/abi/generated.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/core-sdk/src/constants/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export const AddressZero = "0x0000000000000000000000000000000000000000";
export const HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
export const defaultFunctionSelector: Hex = "0x00000000";
export const royaltySharesTotalSupply: number = 100000000;
export const MAX_ROYALTY_TOKEN = 100000000;
89 changes: 53 additions & 36 deletions packages/core-sdk/src/resources/group.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { PublicClient, WalletClient, toHex, zeroHash } from "viem";

import {
coreMetadataModuleAbi,
CoreMetadataModuleClient,
groupingModuleAbi,
GroupingModuleClient,
GroupingModuleEventClient,
GroupingModuleRegisterGroupRequest,
GroupingWorkflowsClient,
GroupingWorkflowsMintAndRegisterIpAndAttachLicenseAndAddToGroupRequest,
GroupingWorkflowsRegisterGroupAndAttachLicenseAndAddIpsRequest,
GroupingWorkflowsRegisterIpAndAttachLicenseAndAddToGroupRequest,
GroupingWorkflowsMintAndRegisterIpAndAttachLicenseAndAddToGroup2Request,
GroupingWorkflowsRegisterGroupAndAttachLicenseAndAddIps2Request,
GroupingWorkflowsRegisterIpAndAttachLicenseAndAddToGroup2Request,
IpAccountImplClient,
IpAssetRegistryClient,
LicenseRegistryReadOnlyClient,
LicenseTokenReadOnlyClient,
licensingModuleAbi,
LicensingModuleClient,
PiLicenseTemplateClient,
SimpleWalletClient,
Expand All @@ -34,6 +37,7 @@ import {
RegisterIpAndAttachLicenseAndAddToGroupRequest,
RegisterIpAndAttachLicenseAndAddToGroupResponse,
} from "../types/resources/group";
import { getFunctionSignature } from "../utils/getFunctionSignature";

export class GroupClient {
public groupingWorkflowsClient: GroupingWorkflowsClient;
Expand Down Expand Up @@ -97,19 +101,20 @@ export class GroupClient {
handleError(error, "Failed to register group");
}
}
/** 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.
/** @deprecated This method is deprecated and will be removed in a future version */
/** 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.
* @param request - The request object containing necessary data to mint and register Ip and attach license and add to group.
* @param request.nftContract The address of the NFT collection.
* @param request.groupId The ID of the group IP to add the newly registered IP.
* @param request.licenseTermsId The ID of the registered license terms that will be attached to the new IP.
* @param request.recipient [Optional] The address of the recipient of the minted NFT,default value is your wallet address.
* @param request.licenseTemplate [Optional] The address of the license template to be attached to the new group IP,default value is Programmable IP License.
* @param request.licenseTemplate [Optional] The address of the license template to be attached to the new group IP, default value is Programmable IP License.
* . @param request.deadline [Optional] The deadline for the signature in seconds, default value is 1000s.
* @param request.ipMetadata - [Optional] The desired metadata for the newly minted NFT and newly registered IP.
* @param request.ipMetadata.ipMetadataURI [Optional] The URI of the metadata for the IP.
* @param request.ipMetadata.ipMetadataHash [Optional] The hash of the metadata for the IP.
* @param request.ipMetadata.nftMetadataURI [Optional] The URI of the metadata for the NFT.
* @param request.ipMetadata.nftMetadataHash [Optional] The hash of the metadata for the IP NFT.
* @param {Object} request.ipMetadata - [Optional] The desired metadata for the newly minted NFT and newly registered IP.
* @param request.ipMetadata.ipMetadataURI [Optional] The URI of the metadata for the IP.
* @param request.ipMetadata.ipMetadataHash [Optional] The hash of the metadata for the IP.
* @param request.ipMetadata.nftMetadataURI [Optional] The URI of the metadata for the NFT.
* @param request.ipMetadata.nftMetadataHash [Optional] The hash of the metadata for the IP NFT.
* @param request.txOptions [Optional] This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property.
* @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.
* @emits IPRegistered (ipId, chainId, tokenContract, tokenId, resolverAddr, metadataProviderAddress, metadata)
Expand Down Expand Up @@ -141,12 +146,12 @@ export class GroupClient {
signer: getAddress(this.groupingWorkflowsClient.address, "groupingWorkflowsClient"),
to: getAddress(this.groupingModuleClient.address, "groupingModuleClient"),
permission: AccessPermission.ALLOW,
func: "function addIp(address,address[])",
func: getFunctionSignature(groupingModuleAbi, "addIp"),
},
],
});

const object: GroupingWorkflowsMintAndRegisterIpAndAttachLicenseAndAddToGroupRequest = {
const object: GroupingWorkflowsMintAndRegisterIpAndAttachLicenseAndAddToGroup2Request = {
...request,
spgNftContract: getAddress(spgNftContract, "request.spgNftContract"),
recipient:
Expand All @@ -170,13 +175,15 @@ export class GroupClient {
if (request.txOptions?.encodedTxDataOnly) {
return {
encodedTxData:
this.groupingWorkflowsClient.mintAndRegisterIpAndAttachLicenseAndAddToGroupEncode(
this.groupingWorkflowsClient.mintAndRegisterIpAndAttachLicenseAndAddToGroup2Encode(
object,
),
};
} else {
const txHash =
await this.groupingWorkflowsClient.mintAndRegisterIpAndAttachLicenseAndAddToGroup(object);
await this.groupingWorkflowsClient.mintAndRegisterIpAndAttachLicenseAndAddToGroup2(
Copy link
Contributor

@DracoLi DracoLi Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was mintAndRegisterIpAndAttachLicenseAndAddToGroup2 created instead of mintAndRegisterIpAndAttachLicenseAndAddToGroup being updated? Do we still need the old function? I noticed a few functions are like this.

nvm I got it, looks like there are are multiple solidity functions with that name because the original one is deprecated. I guess no good ways around that until the deprecated ones are removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we are the same page.

object,
);
if (request.txOptions?.waitForTransaction) {
const receipt = await this.rpcClient.waitForTransactionReceipt({
...request.txOptions,
Expand All @@ -191,19 +198,20 @@ export class GroupClient {
handleError(error, "Failed to mint and register IP and attach license and add to group");
}
}
/** @deprecated This method is deprecated and will be removed in a future version */
/** Register an NFT as IP with metadata, attach license terms to the registered IP, and add it to a group IP.
* @param request - The request object containing necessary data to register ip and attach license and add to group.
* @param request.spgNftContract The address of the NFT collection.
* @param request.tokenId The ID of the NFT.
* @param request.groupId The ID of the group IP to add the newly registered IP.
* @param request.licenseTermsId The ID of the registered license terms that will be attached to the new IP.
* @param request.licenseTemplate [Optional] The address of the license template to be attached to the new group IP,default value is Programmable IP License.
* @param request.licenseTemplate [Optional] The address of the license template to be attached to the new group IP, default value is Programmable IP License.
* . @param request.deadline [Optional] The deadline for the signature in seconds, default is 1000s.
* @param request.ipMetadata - [Optional] The desired metadata for the newly minted NFT and newly registered IP.
* @param request.ipMetadata.ipMetadataURI [Optional] The URI of the metadata for the IP.
* @param request.ipMetadata.ipMetadataHash [Optional] The hash of the metadata for the IP.
* @param request.ipMetadata.nftMetadataURI [Optional] The URI of the metadata for the NFT.
* @param request.ipMetadata.nftMetadataHash [Optional] The hash of the metadata for the IP NFT.
* @param {Object} request.ipMetadata - [Optional] The desired metadata for the newly minted NFT and newly registered IP.
* @param request.ipMetadata.ipMetadataURI [Optional] The URI of the metadata for the IP.
* @param request.ipMetadata.ipMetadataHash [Optional] The hash of the metadata for the IP.
* @param request.ipMetadata.nftMetadataURI [Optional] The URI of the metadata for the NFT.
* @param request.ipMetadata.nftMetadataHash [Optional] The hash of the metadata for the IP NFT.
* @param request.txOptions [Optional] This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property.
* @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.
* @emits IPRegistered (ipId, chainId, tokenContract, tokenId, resolverAddr, metadataProviderAddress, metadata)
Expand All @@ -227,6 +235,7 @@ export class GroupClient {
const { result: state } = await ipAccount.state();
const blockTimestamp = (await this.rpcClient.getBlock()).timestamp;
const calculatedDeadline = getDeadline(blockTimestamp, request.deadline);

const { signature: sigAddToGroupSignature } = await getPermissionSignature({
ipId: getAddress(request.groupId, "request.groupId"),
deadline: calculatedDeadline,
Expand All @@ -236,10 +245,10 @@ export class GroupClient {
permissions: [
{
ipId: getAddress(request.groupId, "request.groupId"),
signer: getAddress(this.groupingWorkflowsClient.address, "groupingWorkflowsClient"),
to: getAddress(this.groupingModuleClient.address, "groupingModuleClient"),
signer: this.groupingWorkflowsClient.address,
to: this.groupingModuleClient.address,
permission: AccessPermission.ALLOW,
func: "function addIp(address,address[])",
func: getFunctionSignature(groupingModuleAbi, "addIp"),
},
],
});
Expand All @@ -253,21 +262,28 @@ export class GroupClient {
permissions: [
{
ipId: ipIdAddress,
signer: getAddress(this.groupingWorkflowsClient.address, "groupingWorkflowsClient"),
signer: this.groupingWorkflowsClient.address,
to: getAddress(this.coreMetadataModuleClient.address, "coreMetadataModuleAddress"),
permission: AccessPermission.ALLOW,
func: "function setAll(address,string,bytes32,bytes32)",
func: getFunctionSignature(coreMetadataModuleAbi, "setAll"),
},
{
ipId: ipIdAddress,
signer: getAddress(this.groupingWorkflowsClient.address, "groupingWorkflowsClient"),
signer: this.groupingWorkflowsClient.address,
to: getAddress(this.licensingModuleClient.address, "licensingModuleAddress"),
permission: AccessPermission.ALLOW,
func: "function attachLicenseTerms(address,address,uint256)",
func: getFunctionSignature(licensingModuleAbi, "attachLicenseTerms"),
},
{
ipId: ipIdAddress,
signer: this.groupingWorkflowsClient.address,
to: getAddress(this.licensingModuleClient.address, "licensingModuleAddress"),
permission: AccessPermission.ALLOW,
func: getFunctionSignature(licensingModuleAbi, "setLicensingConfig"),
},
],
});
const object: GroupingWorkflowsRegisterIpAndAttachLicenseAndAddToGroupRequest = {
const object: GroupingWorkflowsRegisterIpAndAttachLicenseAndAddToGroup2Request = {
nftContract: getAddress(request.nftContract, "request.nftContract"),
groupId: request.groupId,
licenseTemplate:
Expand All @@ -287,7 +303,7 @@ export class GroupClient {
deadline: calculatedDeadline,
signature: sigAddToGroupSignature,
},
sigMetadataAndAttach: {
sigMetadataAndAttachAndConfig: {
signer: getAddress(this.wallet.account!.address, "wallet.account.address"),
deadline: calculatedDeadline,
signature: sigMetadataAndAttachSignature,
Expand All @@ -296,10 +312,10 @@ export class GroupClient {
if (request.txOptions?.encodedTxDataOnly) {
return {
encodedTxData:
this.groupingWorkflowsClient.registerIpAndAttachLicenseAndAddToGroupEncode(object),
this.groupingWorkflowsClient.registerIpAndAttachLicenseAndAddToGroup2Encode(object),
};
}
const txHash = await this.groupingWorkflowsClient.registerIpAndAttachLicenseAndAddToGroup(
const txHash = await this.groupingWorkflowsClient.registerIpAndAttachLicenseAndAddToGroup2(
object,
);
if (request.txOptions?.waitForTransaction) {
Expand Down Expand Up @@ -356,12 +372,13 @@ export class GroupClient {
handleError(error, "Failed to register group and attach license");
}
}
/** @deprecated This method is deprecated and will be removed in a future version */
/** Register a group IP with a group reward pool, attach license terms to the group IP, and add individual IPs to the group IP.
* @param request - The request object containing necessary data to register group and attach license and add ips.
* @param request.pIds must have the same PIL terms as the group IP.
* @param request.ipIds The IP IDs of the IPs to be added to the group.
* @param request.groupPool The address specifying how royalty will be split amongst the pool of IPs in the group.
* @param request.licenseTermsId The ID of the registered license terms that will be attached to the new group IP.
* @param request.licenseTemplate [Optional] The address of the license template to be attached to the new group IP,default value is Programmable IP License.
* @param request.licenseTemplate [Optional] The address of the license template to be attached to the new group IP, default value is Programmable IP License.
* @param request.txOptions [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property.
* @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.
* @emits PGroupRegistered (groupId, groupPool);
Expand Down Expand Up @@ -396,7 +413,7 @@ export class GroupClient {
);
}
}
const object: GroupingWorkflowsRegisterGroupAndAttachLicenseAndAddIpsRequest = {
const object: GroupingWorkflowsRegisterGroupAndAttachLicenseAndAddIps2Request = {
groupPool: getAddress(request.groupPool, "request.groupPool"),
ipIds: request.ipIds,
licenseTemplate: request.licenseTemplate,
Expand All @@ -405,10 +422,10 @@ export class GroupClient {
if (request.txOptions?.encodedTxDataOnly) {
return {
encodedTxData:
this.groupingWorkflowsClient.registerGroupAndAttachLicenseAndAddIpsEncode(object),
this.groupingWorkflowsClient.registerGroupAndAttachLicenseAndAddIps2Encode(object),
};
}
const txHash = await this.groupingWorkflowsClient.registerGroupAndAttachLicenseAndAddIps(
const txHash = await this.groupingWorkflowsClient.registerGroupAndAttachLicenseAndAddIps2(
object,
);
if (request.txOptions?.waitForTransaction) {
Expand Down
Loading
Loading