diff --git a/package.json b/package.json index f27634e6..803256c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typescript-sdk", - "version": "0.0.3", + "version": "0.0.4", "private": true, "repository": "https://github.com/storyprotocol/typescript-sdk", "author": "storyprotocol engineering ", diff --git a/packages/core-sdk/src/abi/generated.ts b/packages/core-sdk/src/abi/generated.ts index 502cfbc4..bfce62a0 100644 --- a/packages/core-sdk/src/abi/generated.ts +++ b/packages/core-sdk/src/abi/generated.ts @@ -1,5 +1,6 @@ import { Address, + Hex, Abi, Account, Chain, @@ -8,10 +9,10 @@ import { WriteContractParameters, WriteContractReturnType, PublicClient, - Hex, decodeEventLog, WatchContractEventReturnType, TransactionReceipt, + encodeFunctionData, } from "viem"; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -7409,6 +7410,8 @@ function getAddress(address: Record, chainId?: number): Address return address[chainId || 0] || "0x"; } +export type EncodedTxData = { to: Address; data: Hex }; + export type SimpleWalletClient< TChain extends Chain | undefined = Chain | undefined, TAccount extends Account | undefined = Account | undefined, @@ -7574,6 +7577,23 @@ export class AccessControllerClient extends AccessControllerEventClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method setAllPermissions for contract AccessController with only encode + * + * @param request AccessControllerSetAllPermissionsRequest + * @return EncodedTxData + */ + public setAllPermissionsEncode(request: AccessControllerSetAllPermissionsRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: accessControllerAbi, + functionName: "setAllPermissions", + args: [request.ipAccount, request.signer, request.permission], + }), + }; + } + /** * method setBatchPermissions for contract AccessController * @@ -7593,6 +7613,25 @@ export class AccessControllerClient extends AccessControllerEventClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method setBatchPermissions for contract AccessController with only encode + * + * @param request AccessControllerSetBatchPermissionsRequest + * @return EncodedTxData + */ + public setBatchPermissionsEncode( + request: AccessControllerSetBatchPermissionsRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: accessControllerAbi, + functionName: "setBatchPermissions", + args: [request.permissions], + }), + }; + } + /** * method setPermission for contract AccessController * @@ -7611,6 +7650,23 @@ export class AccessControllerClient extends AccessControllerEventClient { }); return await this.wallet.writeContract(call as WriteContractParameters); } + + /** + * method setPermission for contract AccessController with only encode + * + * @param request AccessControllerSetPermissionRequest + * @return EncodedTxData + */ + public setPermissionEncode(request: AccessControllerSetPermissionRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: accessControllerAbi, + functionName: "setPermission", + args: [request.ipAccount, request.signer, request.to, request.func, request.permission], + }), + }; + } } // Contract CoreMetadataModule ============================================================= @@ -7977,6 +8033,23 @@ export class CoreMetadataModuleClient extends CoreMetadataModuleReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method freezeMetadata for contract CoreMetadataModule with only encode + * + * @param request CoreMetadataModuleFreezeMetadataRequest + * @return EncodedTxData + */ + public freezeMetadataEncode(request: CoreMetadataModuleFreezeMetadataRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: coreMetadataModuleAbi, + functionName: "freezeMetadata", + args: [request.ipId], + }), + }; + } + /** * method setAll for contract CoreMetadataModule * @@ -7994,6 +8067,23 @@ export class CoreMetadataModuleClient extends CoreMetadataModuleReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method setAll for contract CoreMetadataModule with only encode + * + * @param request CoreMetadataModuleSetAllRequest + * @return EncodedTxData + */ + public setAllEncode(request: CoreMetadataModuleSetAllRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: coreMetadataModuleAbi, + functionName: "setAll", + args: [request.ipId, request.metadataURI, request.metadataHash, request.nftMetadataHash], + }), + }; + } + /** * method setMetadataURI for contract CoreMetadataModule * @@ -8013,6 +8103,23 @@ export class CoreMetadataModuleClient extends CoreMetadataModuleReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method setMetadataURI for contract CoreMetadataModule with only encode + * + * @param request CoreMetadataModuleSetMetadataUriRequest + * @return EncodedTxData + */ + public setMetadataUriEncode(request: CoreMetadataModuleSetMetadataUriRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: coreMetadataModuleAbi, + functionName: "setMetadataURI", + args: [request.ipId, request.metadataURI, request.metadataHash], + }), + }; + } + /** * method updateNftTokenURI for contract CoreMetadataModule * @@ -8031,6 +8138,25 @@ export class CoreMetadataModuleClient extends CoreMetadataModuleReadOnlyClient { }); return await this.wallet.writeContract(call as WriteContractParameters); } + + /** + * method updateNftTokenURI for contract CoreMetadataModule with only encode + * + * @param request CoreMetadataModuleUpdateNftTokenUriRequest + * @return EncodedTxData + */ + public updateNftTokenUriEncode( + request: CoreMetadataModuleUpdateNftTokenUriRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: coreMetadataModuleAbi, + functionName: "updateNftTokenURI", + args: [request.ipId, request.nftMetadataHash], + }), + }; + } } // Contract DisputeModule ============================================================= @@ -8279,6 +8405,23 @@ export class DisputeModuleClient extends DisputeModuleEventClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method cancelDispute for contract DisputeModule with only encode + * + * @param request DisputeModuleCancelDisputeRequest + * @return EncodedTxData + */ + public cancelDisputeEncode(request: DisputeModuleCancelDisputeRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: disputeModuleAbi, + functionName: "cancelDispute", + args: [request.disputeId, request.data], + }), + }; + } + /** * method raiseDispute for contract DisputeModule * @@ -8298,6 +8441,23 @@ export class DisputeModuleClient extends DisputeModuleEventClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method raiseDispute for contract DisputeModule with only encode + * + * @param request DisputeModuleRaiseDisputeRequest + * @return EncodedTxData + */ + public raiseDisputeEncode(request: DisputeModuleRaiseDisputeRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: disputeModuleAbi, + functionName: "raiseDispute", + args: [request.targetIpId, request.linkToDisputeEvidence, request.targetTag, request.data], + }), + }; + } + /** * method resolveDispute for contract DisputeModule * @@ -8316,6 +8476,23 @@ export class DisputeModuleClient extends DisputeModuleEventClient { }); return await this.wallet.writeContract(call as WriteContractParameters); } + + /** + * method resolveDispute for contract DisputeModule with only encode + * + * @param request DisputeModuleResolveDisputeRequest + * @return EncodedTxData + */ + public resolveDisputeEncode(request: DisputeModuleResolveDisputeRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: disputeModuleAbi, + functionName: "resolveDispute", + args: [request.disputeId, request.data], + }), + }; + } } // Contract IPAccountImpl ============================================================= @@ -8409,6 +8586,23 @@ export class IpAccountImplClient extends IpAccountImplReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method execute for contract IPAccountImpl with only encode + * + * @param request IpAccountImplExecuteRequest + * @return EncodedTxData + */ + public executeEncode(request: IpAccountImplExecuteRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: ipAccountImplAbi, + functionName: "execute", + args: [request.to, request.value, request.data], + }), + }; + } + /** * method executeWithSig for contract IPAccountImpl * @@ -8434,6 +8628,30 @@ export class IpAccountImplClient extends IpAccountImplReadOnlyClient { }); return await this.wallet.writeContract(call as WriteContractParameters); } + + /** + * method executeWithSig for contract IPAccountImpl with only encode + * + * @param request IpAccountImplExecuteWithSigRequest + * @return EncodedTxData + */ + public executeWithSigEncode(request: IpAccountImplExecuteWithSigRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: ipAccountImplAbi, + functionName: "executeWithSig", + args: [ + request.to, + request.value, + request.data, + request.signer, + request.deadline, + request.signature, + ], + }), + }; + } } // Contract IPAssetRegistry ============================================================= @@ -8678,6 +8896,23 @@ export class IpAssetRegistryClient extends IpAssetRegistryReadOnlyClient { }); return await this.wallet.writeContract(call as WriteContractParameters); } + + /** + * method register for contract IPAssetRegistry with only encode + * + * @param request IpAssetRegistryRegisterRequest + * @return EncodedTxData + */ + public registerEncode(request: IpAssetRegistryRegisterRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: ipAssetRegistryAbi, + functionName: "register", + args: [request.chainid, request.tokenContract, request.tokenId], + }), + }; + } } // Contract IpRoyaltyVaultImpl ============================================================= @@ -8973,6 +9208,25 @@ export class IpRoyaltyVaultImplClient extends IpRoyaltyVaultImplReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method claimRevenueBySnapshotBatch for contract IpRoyaltyVaultImpl with only encode + * + * @param request IpRoyaltyVaultImplClaimRevenueBySnapshotBatchRequest + * @return EncodedTxData + */ + public claimRevenueBySnapshotBatchEncode( + request: IpRoyaltyVaultImplClaimRevenueBySnapshotBatchRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: ipRoyaltyVaultImplAbi, + functionName: "claimRevenueBySnapshotBatch", + args: [request.snapshotIds, request.token], + }), + }; + } + /** * method claimRevenueByTokenBatch for contract IpRoyaltyVaultImpl * @@ -8992,6 +9246,25 @@ export class IpRoyaltyVaultImplClient extends IpRoyaltyVaultImplReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method claimRevenueByTokenBatch for contract IpRoyaltyVaultImpl with only encode + * + * @param request IpRoyaltyVaultImplClaimRevenueByTokenBatchRequest + * @return EncodedTxData + */ + public claimRevenueByTokenBatchEncode( + request: IpRoyaltyVaultImplClaimRevenueByTokenBatchRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: ipRoyaltyVaultImplAbi, + functionName: "claimRevenueByTokenBatch", + args: [request.snapshotId, request.tokenList], + }), + }; + } + /** * method collectRoyaltyTokens for contract IpRoyaltyVaultImpl * @@ -9011,6 +9284,25 @@ export class IpRoyaltyVaultImplClient extends IpRoyaltyVaultImplReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method collectRoyaltyTokens for contract IpRoyaltyVaultImpl with only encode + * + * @param request IpRoyaltyVaultImplCollectRoyaltyTokensRequest + * @return EncodedTxData + */ + public collectRoyaltyTokensEncode( + request: IpRoyaltyVaultImplCollectRoyaltyTokensRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: ipRoyaltyVaultImplAbi, + functionName: "collectRoyaltyTokens", + args: [request.ancestorIpId], + }), + }; + } + /** * method snapshot for contract IpRoyaltyVaultImpl * @@ -9026,6 +9318,22 @@ export class IpRoyaltyVaultImplClient extends IpRoyaltyVaultImplReadOnlyClient { }); return await this.wallet.writeContract(call as WriteContractParameters); } + + /** + * method snapshot for contract IpRoyaltyVaultImpl with only encode + * + * @param request IpRoyaltyVaultImplSnapshotRequest + * @return EncodedTxData + */ + public snapshotEncode(): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: ipRoyaltyVaultImplAbi, + functionName: "snapshot", + }), + }; + } } // Contract LicenseRegistry ============================================================= @@ -10228,6 +10536,25 @@ export class LicenseRegistryClient extends LicenseRegistryReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method attachLicenseTermsToIp for contract LicenseRegistry with only encode + * + * @param request LicenseRegistryAttachLicenseTermsToIpRequest + * @return EncodedTxData + */ + public attachLicenseTermsToIpEncode( + request: LicenseRegistryAttachLicenseTermsToIpRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licenseRegistryAbi, + functionName: "attachLicenseTermsToIp", + args: [request.ipId, request.licenseTemplate, request.licenseTermsId], + }), + }; + } + /** * method initialize for contract LicenseRegistry * @@ -10247,6 +10574,23 @@ export class LicenseRegistryClient extends LicenseRegistryReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method initialize for contract LicenseRegistry with only encode + * + * @param request LicenseRegistryInitializeRequest + * @return EncodedTxData + */ + public initializeEncode(request: LicenseRegistryInitializeRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licenseRegistryAbi, + functionName: "initialize", + args: [request.accessManager], + }), + }; + } + /** * method registerDerivativeIp for contract LicenseRegistry * @@ -10271,6 +10615,30 @@ export class LicenseRegistryClient extends LicenseRegistryReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method registerDerivativeIp for contract LicenseRegistry with only encode + * + * @param request LicenseRegistryRegisterDerivativeIpRequest + * @return EncodedTxData + */ + public registerDerivativeIpEncode( + request: LicenseRegistryRegisterDerivativeIpRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licenseRegistryAbi, + functionName: "registerDerivativeIp", + args: [ + request.childIpId, + request.parentIpIds, + request.licenseTemplate, + request.licenseTermsIds, + ], + }), + }; + } + /** * method registerLicenseTemplate for contract LicenseRegistry * @@ -10290,6 +10658,25 @@ export class LicenseRegistryClient extends LicenseRegistryReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method registerLicenseTemplate for contract LicenseRegistry with only encode + * + * @param request LicenseRegistryRegisterLicenseTemplateRequest + * @return EncodedTxData + */ + public registerLicenseTemplateEncode( + request: LicenseRegistryRegisterLicenseTemplateRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licenseRegistryAbi, + functionName: "registerLicenseTemplate", + args: [request.licenseTemplate], + }), + }; + } + /** * method setAuthority for contract LicenseRegistry * @@ -10309,6 +10696,23 @@ export class LicenseRegistryClient extends LicenseRegistryReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method setAuthority for contract LicenseRegistry with only encode + * + * @param request LicenseRegistrySetAuthorityRequest + * @return EncodedTxData + */ + public setAuthorityEncode(request: LicenseRegistrySetAuthorityRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licenseRegistryAbi, + functionName: "setAuthority", + args: [request.newAuthority], + }), + }; + } + /** * method setDefaultLicenseTerms for contract LicenseRegistry * @@ -10328,6 +10732,25 @@ export class LicenseRegistryClient extends LicenseRegistryReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method setDefaultLicenseTerms for contract LicenseRegistry with only encode + * + * @param request LicenseRegistrySetDefaultLicenseTermsRequest + * @return EncodedTxData + */ + public setDefaultLicenseTermsEncode( + request: LicenseRegistrySetDefaultLicenseTermsRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licenseRegistryAbi, + functionName: "setDefaultLicenseTerms", + args: [request.newLicenseTemplate, request.newLicenseTermsId], + }), + }; + } + /** * method setExpireTime for contract LicenseRegistry * @@ -10347,6 +10770,23 @@ export class LicenseRegistryClient extends LicenseRegistryReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method setExpireTime for contract LicenseRegistry with only encode + * + * @param request LicenseRegistrySetExpireTimeRequest + * @return EncodedTxData + */ + public setExpireTimeEncode(request: LicenseRegistrySetExpireTimeRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licenseRegistryAbi, + functionName: "setExpireTime", + args: [request.ipId, request.expireTime], + }), + }; + } + /** * method setLicensingConfigForIp for contract LicenseRegistry * @@ -10366,6 +10806,25 @@ export class LicenseRegistryClient extends LicenseRegistryReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method setLicensingConfigForIp for contract LicenseRegistry with only encode + * + * @param request LicenseRegistrySetLicensingConfigForIpRequest + * @return EncodedTxData + */ + public setLicensingConfigForIpEncode( + request: LicenseRegistrySetLicensingConfigForIpRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licenseRegistryAbi, + functionName: "setLicensingConfigForIp", + args: [request.ipId, request.licensingConfig], + }), + }; + } + /** * method setLicensingConfigForLicense for contract LicenseRegistry * @@ -10390,6 +10849,30 @@ export class LicenseRegistryClient extends LicenseRegistryReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method setLicensingConfigForLicense for contract LicenseRegistry with only encode + * + * @param request LicenseRegistrySetLicensingConfigForLicenseRequest + * @return EncodedTxData + */ + public setLicensingConfigForLicenseEncode( + request: LicenseRegistrySetLicensingConfigForLicenseRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licenseRegistryAbi, + functionName: "setLicensingConfigForLicense", + args: [ + request.ipId, + request.licenseTemplate, + request.licenseTermsId, + request.licensingConfig, + ], + }), + }; + } + /** * method upgradeToAndCall for contract LicenseRegistry * @@ -10408,6 +10891,23 @@ export class LicenseRegistryClient extends LicenseRegistryReadOnlyClient { }); return await this.wallet.writeContract(call as WriteContractParameters); } + + /** + * method upgradeToAndCall for contract LicenseRegistry with only encode + * + * @param request LicenseRegistryUpgradeToAndCallRequest + * @return EncodedTxData + */ + public upgradeToAndCallEncode(request: LicenseRegistryUpgradeToAndCallRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licenseRegistryAbi, + functionName: "upgradeToAndCall", + args: [request.newImplementation, request.data], + }), + }; + } } // Contract LicenseToken ============================================================= @@ -10676,6 +11176,25 @@ export class LicensingModuleClient extends LicensingModuleEventClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method attachLicenseTerms for contract LicensingModule with only encode + * + * @param request LicensingModuleAttachLicenseTermsRequest + * @return EncodedTxData + */ + public attachLicenseTermsEncode( + request: LicensingModuleAttachLicenseTermsRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licensingModuleAbi, + functionName: "attachLicenseTerms", + args: [request.ipId, request.licenseTemplate, request.licenseTermsId], + }), + }; + } + /** * method mintLicenseTokens for contract LicensingModule * @@ -10702,6 +11221,30 @@ export class LicensingModuleClient extends LicensingModuleEventClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method mintLicenseTokens for contract LicensingModule with only encode + * + * @param request LicensingModuleMintLicenseTokensRequest + * @return EncodedTxData + */ + public mintLicenseTokensEncode(request: LicensingModuleMintLicenseTokensRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licensingModuleAbi, + functionName: "mintLicenseTokens", + args: [ + request.licensorIpId, + request.licenseTemplate, + request.licenseTermsId, + request.amount, + request.receiver, + request.royaltyContext, + ], + }), + }; + } + /** * method registerDerivative for contract LicensingModule * @@ -10728,12 +11271,37 @@ export class LicensingModuleClient extends LicensingModuleEventClient { } /** - * method registerDerivativeWithLicenseTokens for contract LicensingModule + * method registerDerivative for contract LicensingModule with only encode * - * @param request LicensingModuleRegisterDerivativeWithLicenseTokensRequest - * @return Promise + * @param request LicensingModuleRegisterDerivativeRequest + * @return EncodedTxData */ - public async registerDerivativeWithLicenseTokens( + public registerDerivativeEncode( + request: LicensingModuleRegisterDerivativeRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licensingModuleAbi, + functionName: "registerDerivative", + args: [ + request.childIpId, + request.parentIpIds, + request.licenseTermsIds, + request.licenseTemplate, + request.royaltyContext, + ], + }), + }; + } + + /** + * method registerDerivativeWithLicenseTokens for contract LicensingModule + * + * @param request LicensingModuleRegisterDerivativeWithLicenseTokensRequest + * @return Promise + */ + public async registerDerivativeWithLicenseTokens( request: LicensingModuleRegisterDerivativeWithLicenseTokensRequest, ): Promise { const { request: call } = await this.rpcClient.simulateContract({ @@ -10745,6 +11313,25 @@ export class LicensingModuleClient extends LicensingModuleEventClient { }); return await this.wallet.writeContract(call as WriteContractParameters); } + + /** + * method registerDerivativeWithLicenseTokens for contract LicensingModule with only encode + * + * @param request LicensingModuleRegisterDerivativeWithLicenseTokensRequest + * @return EncodedTxData + */ + public registerDerivativeWithLicenseTokensEncode( + request: LicensingModuleRegisterDerivativeWithLicenseTokensRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: licensingModuleAbi, + functionName: "registerDerivativeWithLicenseTokens", + args: [request.childIpId, request.licenseTokenIds, request.royaltyContext], + }), + }; + } } // Contract ModuleRegistry ============================================================= @@ -11819,6 +12406,23 @@ export class PiLicenseTemplateClient extends PiLicenseTemplateReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method initialize for contract PILicenseTemplate with only encode + * + * @param request PiLicenseTemplateInitializeRequest + * @return EncodedTxData + */ + public initializeEncode(request: PiLicenseTemplateInitializeRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: piLicenseTemplateAbi, + functionName: "initialize", + args: [request.accessManager, request.name, request.metadataURI], + }), + }; + } + /** * method registerLicenseTerms for contract PILicenseTemplate * @@ -11838,6 +12442,25 @@ export class PiLicenseTemplateClient extends PiLicenseTemplateReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method registerLicenseTerms for contract PILicenseTemplate with only encode + * + * @param request PiLicenseTemplateRegisterLicenseTermsRequest + * @return EncodedTxData + */ + public registerLicenseTermsEncode( + request: PiLicenseTemplateRegisterLicenseTermsRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: piLicenseTemplateAbi, + functionName: "registerLicenseTerms", + args: [request.terms], + }), + }; + } + /** * method setApproval for contract PILicenseTemplate * @@ -11857,6 +12480,23 @@ export class PiLicenseTemplateClient extends PiLicenseTemplateReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method setApproval for contract PILicenseTemplate with only encode + * + * @param request PiLicenseTemplateSetApprovalRequest + * @return EncodedTxData + */ + public setApprovalEncode(request: PiLicenseTemplateSetApprovalRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: piLicenseTemplateAbi, + functionName: "setApproval", + args: [request.parentIpId, request.licenseTermsId, request.childIpId, request.approved], + }), + }; + } + /** * method setAuthority for contract PILicenseTemplate * @@ -11876,6 +12516,23 @@ export class PiLicenseTemplateClient extends PiLicenseTemplateReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method setAuthority for contract PILicenseTemplate with only encode + * + * @param request PiLicenseTemplateSetAuthorityRequest + * @return EncodedTxData + */ + public setAuthorityEncode(request: PiLicenseTemplateSetAuthorityRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: piLicenseTemplateAbi, + functionName: "setAuthority", + args: [request.newAuthority], + }), + }; + } + /** * method upgradeToAndCall for contract PILicenseTemplate * @@ -11895,6 +12552,23 @@ export class PiLicenseTemplateClient extends PiLicenseTemplateReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method upgradeToAndCall for contract PILicenseTemplate with only encode + * + * @param request PiLicenseTemplateUpgradeToAndCallRequest + * @return EncodedTxData + */ + public upgradeToAndCallEncode(request: PiLicenseTemplateUpgradeToAndCallRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: piLicenseTemplateAbi, + functionName: "upgradeToAndCall", + args: [request.newImplementation, request.data], + }), + }; + } + /** * method verifyMintLicenseToken for contract PILicenseTemplate * @@ -11914,6 +12588,25 @@ export class PiLicenseTemplateClient extends PiLicenseTemplateReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method verifyMintLicenseToken for contract PILicenseTemplate with only encode + * + * @param request PiLicenseTemplateVerifyMintLicenseTokenRequest + * @return EncodedTxData + */ + public verifyMintLicenseTokenEncode( + request: PiLicenseTemplateVerifyMintLicenseTokenRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: piLicenseTemplateAbi, + functionName: "verifyMintLicenseToken", + args: [request[0], request[1], request[2], request[3]], + }), + }; + } + /** * method verifyRegisterDerivative for contract PILicenseTemplate * @@ -11933,6 +12626,25 @@ export class PiLicenseTemplateClient extends PiLicenseTemplateReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method verifyRegisterDerivative for contract PILicenseTemplate with only encode + * + * @param request PiLicenseTemplateVerifyRegisterDerivativeRequest + * @return EncodedTxData + */ + public verifyRegisterDerivativeEncode( + request: PiLicenseTemplateVerifyRegisterDerivativeRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: piLicenseTemplateAbi, + functionName: "verifyRegisterDerivative", + args: [request.childIpId, request.parentIpId, request.licenseTermsId, request.licensee], + }), + }; + } + /** * method verifyRegisterDerivativeForAllParents for contract PILicenseTemplate * @@ -11951,6 +12663,30 @@ export class PiLicenseTemplateClient extends PiLicenseTemplateReadOnlyClient { }); return await this.wallet.writeContract(call as WriteContractParameters); } + + /** + * method verifyRegisterDerivativeForAllParents for contract PILicenseTemplate with only encode + * + * @param request PiLicenseTemplateVerifyRegisterDerivativeForAllParentsRequest + * @return EncodedTxData + */ + public verifyRegisterDerivativeForAllParentsEncode( + request: PiLicenseTemplateVerifyRegisterDerivativeForAllParentsRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: piLicenseTemplateAbi, + functionName: "verifyRegisterDerivativeForAllParents", + args: [ + request.childIpId, + request.parentIpIds, + request.licenseTermsIds, + request.childIpOwner, + ], + }), + }; + } } // Contract RoyaltyModule ============================================================= @@ -12002,6 +12738,23 @@ export class RoyaltyModuleClient { }); return await this.wallet.writeContract(call as WriteContractParameters); } + + /** + * method payRoyaltyOnBehalf for contract RoyaltyModule with only encode + * + * @param request RoyaltyModulePayRoyaltyOnBehalfRequest + * @return EncodedTxData + */ + public payRoyaltyOnBehalfEncode(request: RoyaltyModulePayRoyaltyOnBehalfRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: royaltyModuleAbi, + functionName: "payRoyaltyOnBehalf", + args: [request.receiverIpId, request.payerIpId, request.token, request.amount], + }), + }; + } } // Contract RoyaltyPolicyLAP ============================================================= @@ -12106,6 +12859,23 @@ export class RoyaltyPolicyLapClient extends RoyaltyPolicyLapReadOnlyClient { }); return await this.wallet.writeContract(call as WriteContractParameters); } + + /** + * method onRoyaltyPayment for contract RoyaltyPolicyLAP with only encode + * + * @param request RoyaltyPolicyLapOnRoyaltyPaymentRequest + * @return EncodedTxData + */ + public onRoyaltyPaymentEncode(request: RoyaltyPolicyLapOnRoyaltyPaymentRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: royaltyPolicyLapAbi, + functionName: "onRoyaltyPayment", + args: [request.caller, request.ipId, request.token, request.amount], + }), + }; + } } // Contract SPG ============================================================= @@ -12498,6 +13268,30 @@ export class SpgClient extends SpgEventClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method createCollection for contract SPG with only encode + * + * @param request SpgCreateCollectionRequest + * @return EncodedTxData + */ + public createCollectionEncode(request: SpgCreateCollectionRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgAbi, + functionName: "createCollection", + args: [ + request.name, + request.symbol, + request.maxSupply, + request.mintFee, + request.mintFeeToken, + request.owner, + ], + }), + }; + } + /** * method mintAndRegisterIp for contract SPG * @@ -12517,6 +13311,23 @@ export class SpgClient extends SpgEventClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method mintAndRegisterIp for contract SPG with only encode + * + * @param request SpgMintAndRegisterIpRequest + * @return EncodedTxData + */ + public mintAndRegisterIpEncode(request: SpgMintAndRegisterIpRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgAbi, + functionName: "mintAndRegisterIp", + args: [request.nftContract, request.recipient, request.metadata], + }), + }; + } + /** * method mintAndRegisterIpAndAttachPILTerms for contract SPG * @@ -12536,6 +13347,25 @@ export class SpgClient extends SpgEventClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method mintAndRegisterIpAndAttachPILTerms for contract SPG with only encode + * + * @param request SpgMintAndRegisterIpAndAttachPilTermsRequest + * @return EncodedTxData + */ + public mintAndRegisterIpAndAttachPilTermsEncode( + request: SpgMintAndRegisterIpAndAttachPilTermsRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgAbi, + functionName: "mintAndRegisterIpAndAttachPILTerms", + args: [request.nftContract, request.recipient, request.metadata, request.terms], + }), + }; + } + /** * method mintAndRegisterIpAndMakeDerivative for contract SPG * @@ -12555,6 +13385,25 @@ export class SpgClient extends SpgEventClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method mintAndRegisterIpAndMakeDerivative for contract SPG with only encode + * + * @param request SpgMintAndRegisterIpAndMakeDerivativeRequest + * @return EncodedTxData + */ + public mintAndRegisterIpAndMakeDerivativeEncode( + request: SpgMintAndRegisterIpAndMakeDerivativeRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgAbi, + functionName: "mintAndRegisterIpAndMakeDerivative", + args: [request.nftContract, request.derivData, request.metadata, request.recipient], + }), + }; + } + /** * method mintAndRegisterIpAndMakeDerivativeWithLicenseTokens for contract SPG * @@ -12580,6 +13429,31 @@ export class SpgClient extends SpgEventClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method mintAndRegisterIpAndMakeDerivativeWithLicenseTokens for contract SPG with only encode + * + * @param request SpgMintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest + * @return EncodedTxData + */ + public mintAndRegisterIpAndMakeDerivativeWithLicenseTokensEncode( + request: SpgMintAndRegisterIpAndMakeDerivativeWithLicenseTokensRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgAbi, + functionName: "mintAndRegisterIpAndMakeDerivativeWithLicenseTokens", + args: [ + request.nftContract, + request.licenseTokenIds, + request.royaltyContext, + request.metadata, + request.recipient, + ], + }), + }; + } + /** * method registerIp for contract SPG * @@ -12597,6 +13471,23 @@ export class SpgClient extends SpgEventClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method registerIp for contract SPG with only encode + * + * @param request SpgRegisterIpRequest + * @return EncodedTxData + */ + public registerIpEncode(request: SpgRegisterIpRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgAbi, + functionName: "registerIp", + args: [request.nftContract, request.tokenId, request.metadata, request.sigMetadata], + }), + }; + } + /** * method registerIpAndAttachPILTerms for contract SPG * @@ -12623,6 +13514,32 @@ export class SpgClient extends SpgEventClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method registerIpAndAttachPILTerms for contract SPG with only encode + * + * @param request SpgRegisterIpAndAttachPilTermsRequest + * @return EncodedTxData + */ + public registerIpAndAttachPilTermsEncode( + request: SpgRegisterIpAndAttachPilTermsRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgAbi, + functionName: "registerIpAndAttachPILTerms", + args: [ + request.nftContract, + request.tokenId, + request.metadata, + request.terms, + request.sigMetadata, + request.sigAttach, + ], + }), + }; + } + /** * method registerIpAndMakeDerivative for contract SPG * @@ -12649,6 +13566,32 @@ export class SpgClient extends SpgEventClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method registerIpAndMakeDerivative for contract SPG with only encode + * + * @param request SpgRegisterIpAndMakeDerivativeRequest + * @return EncodedTxData + */ + public registerIpAndMakeDerivativeEncode( + request: SpgRegisterIpAndMakeDerivativeRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgAbi, + functionName: "registerIpAndMakeDerivative", + args: [ + request.nftContract, + request.tokenId, + request.derivData, + request.metadata, + request.sigMetadata, + request.sigRegister, + ], + }), + }; + } + /** * method registerIpAndMakeDerivativeWithLicenseTokens for contract SPG * @@ -12676,6 +13619,33 @@ export class SpgClient extends SpgEventClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method registerIpAndMakeDerivativeWithLicenseTokens for contract SPG with only encode + * + * @param request SpgRegisterIpAndMakeDerivativeWithLicenseTokensRequest + * @return EncodedTxData + */ + public registerIpAndMakeDerivativeWithLicenseTokensEncode( + request: SpgRegisterIpAndMakeDerivativeWithLicenseTokensRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgAbi, + functionName: "registerIpAndMakeDerivativeWithLicenseTokens", + args: [ + request.nftContract, + request.tokenId, + request.licenseTokenIds, + request.royaltyContext, + request.metadata, + request.sigMetadata, + request.sigRegister, + ], + }), + }; + } + /** * method registerPILTermsAndAttach for contract SPG * @@ -12694,6 +13664,25 @@ export class SpgClient extends SpgEventClient { }); return await this.wallet.writeContract(call as WriteContractParameters); } + + /** + * method registerPILTermsAndAttach for contract SPG with only encode + * + * @param request SpgRegisterPilTermsAndAttachRequest + * @return EncodedTxData + */ + public registerPilTermsAndAttachEncode( + request: SpgRegisterPilTermsAndAttachRequest, + ): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgAbi, + functionName: "registerPILTermsAndAttach", + args: [request.ipId, request.terms], + }), + }; + } } // Contract SPGNFTBeacon ============================================================= @@ -12897,6 +13886,22 @@ export class SpgnftBeaconClient extends SpgnftBeaconReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method renounceOwnership for contract SPGNFTBeacon with only encode + * + * @param request SpgnftBeaconRenounceOwnershipRequest + * @return EncodedTxData + */ + public renounceOwnershipEncode(): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftBeaconAbi, + functionName: "renounceOwnership", + }), + }; + } + /** * method transferOwnership for contract SPGNFTBeacon * @@ -12916,6 +13921,23 @@ export class SpgnftBeaconClient extends SpgnftBeaconReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method transferOwnership for contract SPGNFTBeacon with only encode + * + * @param request SpgnftBeaconTransferOwnershipRequest + * @return EncodedTxData + */ + public transferOwnershipEncode(request: SpgnftBeaconTransferOwnershipRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftBeaconAbi, + functionName: "transferOwnership", + args: [request.newOwner], + }), + }; + } + /** * method upgradeTo for contract SPGNFTBeacon * @@ -12932,6 +13954,23 @@ export class SpgnftBeaconClient extends SpgnftBeaconReadOnlyClient { }); return await this.wallet.writeContract(call as WriteContractParameters); } + + /** + * method upgradeTo for contract SPGNFTBeacon with only encode + * + * @param request SpgnftBeaconUpgradeToRequest + * @return EncodedTxData + */ + public upgradeToEncode(request: SpgnftBeaconUpgradeToRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftBeaconAbi, + functionName: "upgradeTo", + args: [request.newImplementation], + }), + }; + } } // Contract SPGNFTImpl ============================================================= @@ -13848,6 +14887,23 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method approve for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplApproveRequest + * @return EncodedTxData + */ + public approveEncode(request: SpgnftImplApproveRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "approve", + args: [request.to, request.tokenId], + }), + }; + } + /** * method grantRole for contract SPGNFTImpl * @@ -13865,6 +14921,23 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method grantRole for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplGrantRoleRequest + * @return EncodedTxData + */ + public grantRoleEncode(request: SpgnftImplGrantRoleRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "grantRole", + args: [request.role, request.account], + }), + }; + } + /** * method initialize for contract SPGNFTImpl * @@ -13889,6 +14962,30 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method initialize for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplInitializeRequest + * @return EncodedTxData + */ + public initializeEncode(request: SpgnftImplInitializeRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "initialize", + args: [ + request.name, + request.symbol, + request.maxSupply, + request.mintCost, + request.mintToken, + request.owner, + ], + }), + }; + } + /** * method mint for contract SPGNFTImpl * @@ -13906,6 +15003,23 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method mint for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplMintRequest + * @return EncodedTxData + */ + public mintEncode(request: SpgnftImplMintRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "mint", + args: [request.to], + }), + }; + } + /** * method mintBySPG for contract SPGNFTImpl * @@ -13923,6 +15037,23 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method mintBySPG for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplMintBySpgRequest + * @return EncodedTxData + */ + public mintBySpgEncode(request: SpgnftImplMintBySpgRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "mintBySPG", + args: [request.to, request.payer], + }), + }; + } + /** * method renounceRole for contract SPGNFTImpl * @@ -13942,6 +15073,23 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method renounceRole for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplRenounceRoleRequest + * @return EncodedTxData + */ + public renounceRoleEncode(request: SpgnftImplRenounceRoleRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "renounceRole", + args: [request.role, request.callerConfirmation], + }), + }; + } + /** * method revokeRole for contract SPGNFTImpl * @@ -13959,6 +15107,23 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method revokeRole for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplRevokeRoleRequest + * @return EncodedTxData + */ + public revokeRoleEncode(request: SpgnftImplRevokeRoleRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "revokeRole", + args: [request.role, request.account], + }), + }; + } + /** * method safeTransferFrom for contract SPGNFTImpl * @@ -13978,6 +15143,23 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method safeTransferFrom for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplSafeTransferFromRequest + * @return EncodedTxData + */ + public safeTransferFromEncode(request: SpgnftImplSafeTransferFromRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "safeTransferFrom", + args: [request.from, request.to, request.tokenId], + }), + }; + } + /** * method safeTransferFrom for contract SPGNFTImpl * @@ -13997,6 +15179,23 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method safeTransferFrom for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplSafeTransferFrom2Request + * @return EncodedTxData + */ + public safeTransferFrom2Encode(request: SpgnftImplSafeTransferFrom2Request): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "safeTransferFrom", + args: [request.from, request.to, request.tokenId, request.data], + }), + }; + } + /** * method setApprovalForAll for contract SPGNFTImpl * @@ -14016,6 +15215,23 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method setApprovalForAll for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplSetApprovalForAllRequest + * @return EncodedTxData + */ + public setApprovalForAllEncode(request: SpgnftImplSetApprovalForAllRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "setApprovalForAll", + args: [request.operator, request.approved], + }), + }; + } + /** * method setMintCost for contract SPGNFTImpl * @@ -14035,6 +15251,23 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method setMintCost for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplSetMintCostRequest + * @return EncodedTxData + */ + public setMintCostEncode(request: SpgnftImplSetMintCostRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "setMintCost", + args: [request.cost], + }), + }; + } + /** * method setMintToken for contract SPGNFTImpl * @@ -14054,6 +15287,23 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method setMintToken for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplSetMintTokenRequest + * @return EncodedTxData + */ + public setMintTokenEncode(request: SpgnftImplSetMintTokenRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "setMintToken", + args: [request.token], + }), + }; + } + /** * method transferFrom for contract SPGNFTImpl * @@ -14073,6 +15323,23 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { return await this.wallet.writeContract(call as WriteContractParameters); } + /** + * method transferFrom for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplTransferFromRequest + * @return EncodedTxData + */ + public transferFromEncode(request: SpgnftImplTransferFromRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "transferFrom", + args: [request.from, request.to, request.tokenId], + }), + }; + } + /** * method withdrawToken for contract SPGNFTImpl * @@ -14091,4 +15358,21 @@ export class SpgnftImplClient extends SpgnftImplReadOnlyClient { }); return await this.wallet.writeContract(call as WriteContractParameters); } + + /** + * method withdrawToken for contract SPGNFTImpl with only encode + * + * @param request SpgnftImplWithdrawTokenRequest + * @return EncodedTxData + */ + public withdrawTokenEncode(request: SpgnftImplWithdrawTokenRequest): EncodedTxData { + return { + to: this.address, + data: encodeFunctionData({ + abi: spgnftImplAbi, + functionName: "withdrawToken", + args: [request.token, request.recipient], + }), + }; + } } diff --git a/packages/core-sdk/src/index.ts b/packages/core-sdk/src/index.ts index e32f9257..c6c8e845 100644 --- a/packages/core-sdk/src/index.ts +++ b/packages/core-sdk/src/index.ts @@ -85,6 +85,7 @@ export type { export type { PiLicenseTemplateGetLicenseTermsResponse, IpAccountImplStateResponse, + EncodedTxData, } from "./abi/generated"; export { getPermissionSignature } from "./utils/sign"; diff --git a/packages/core-sdk/src/resources/dispute.ts b/packages/core-sdk/src/resources/dispute.ts index 4ff41e9d..8eddf5d2 100644 --- a/packages/core-sdk/src/resources/dispute.ts +++ b/packages/core-sdk/src/resources/dispute.ts @@ -39,22 +39,28 @@ export class DisputeClient { */ public async raiseDispute(request: RaiseDisputeRequest): Promise { try { - const txHash = await this.disputeModuleClient.raiseDispute({ + const req = { targetIpId: getAddress(request.targetIpId, "request.targetIpId"), linkToDisputeEvidence: request.linkToDisputeEvidence, targetTag: stringToHex(request.targetTag, { size: 32 }), data: request.calldata || "0x", - }); + }; - if (request.txOptions?.waitForTransaction) { - const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - const targetLogs = this.disputeModuleClient.parseTxDisputeRaisedEvent(txReceipt); - return { - txHash: txHash, - disputeId: targetLogs[0].disputeId, - }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: this.disputeModuleClient.raiseDisputeEncode(req) }; + } else { + const txHash = await this.disputeModuleClient.raiseDispute(req); + + if (request.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + const targetLogs = this.disputeModuleClient.parseTxDisputeRaisedEvent(txReceipt); + return { + txHash: txHash, + disputeId: targetLogs[0].disputeId, + }; + } + return { txHash: txHash }; } - return { txHash: txHash }; } catch (error) { handleError(error, "Failed to raise dispute"); } @@ -74,16 +80,21 @@ export class DisputeClient { */ public async cancelDispute(request: CancelDisputeRequest): Promise { try { - const txHash = await this.disputeModuleClient.cancelDispute({ + const req = { disputeId: BigInt(request.disputeId), data: request.calldata ? request.calldata : "0x", - }); + }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: this.disputeModuleClient.cancelDisputeEncode(req) }; + } else { + const txHash = await this.disputeModuleClient.cancelDispute(req); - if (request.txOptions?.waitForTransaction) { - await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - } + if (request.txOptions?.waitForTransaction) { + await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + } - return { txHash: txHash }; + return { txHash: txHash }; + } } catch (error) { handleError(error, "Failed to cancel dispute"); } @@ -101,15 +112,21 @@ export class DisputeClient { */ public async resolveDispute(request: ResolveDisputeRequest): Promise { try { - const txHash = await this.disputeModuleClient.resolveDispute({ + const req = { disputeId: BigInt(request.disputeId), data: request.data, - }); - if (request.txOptions?.waitForTransaction) { - await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - } + }; + + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: this.disputeModuleClient.resolveDisputeEncode(req) }; + } else { + const txHash = await this.disputeModuleClient.resolveDispute(req); + if (request.txOptions?.waitForTransaction) { + await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + } - return { txHash: txHash }; + return { txHash: txHash }; + } } catch (error) { handleError(error, "Failed to resolve dispute"); } diff --git a/packages/core-sdk/src/resources/ipAccount.ts b/packages/core-sdk/src/resources/ipAccount.ts index 5822e775..ff82d115 100644 --- a/packages/core-sdk/src/resources/ipAccount.ts +++ b/packages/core-sdk/src/resources/ipAccount.ts @@ -40,16 +40,22 @@ export class IPAccountClient { getAddress(request.ipId, "request.ipId"), ); - const txHash = await ipAccountClient.execute({ + const req = { to: request.to, value: BigInt(0), data: request.data, - }); + }; - if (request.txOptions?.waitForTransaction) { - await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: ipAccountClient.executeEncode(req) }; + } else { + const txHash = await ipAccountClient.execute(req); + + if (request.txOptions?.waitForTransaction) { + await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + } + return { txHash: txHash }; } - return { txHash: txHash }; } catch (error) { handleError(error, "Failed to execute the IP Account transaction"); } @@ -76,19 +82,25 @@ export class IPAccountClient { getAddress(request.ipId, "request.ipId"), ); - const txHash = await ipAccountClient.executeWithSig({ + const req = { to: getAddress(request.to, "request.to"), value: BigInt(0), data: request.data, signer: getAddress(request.signer, "request.signer"), deadline: BigInt(request.deadline), signature: request.signature, - }); + }; + + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: ipAccountClient.executeWithSigEncode(req) }; + } else { + const txHash = await ipAccountClient.executeWithSig(req); - if (request.txOptions?.waitForTransaction) { - await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + if (request.txOptions?.waitForTransaction) { + await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + } + return { txHash: txHash }; } - return { txHash: txHash }; } catch (error) { handleError(error, "Failed to execute with signature for the IP Account transaction"); } diff --git a/packages/core-sdk/src/resources/ipAsset.ts b/packages/core-sdk/src/resources/ipAsset.ts index 12eff524..e353e646 100644 --- a/packages/core-sdk/src/resources/ipAsset.ts +++ b/packages/core-sdk/src/resources/ipAsset.ts @@ -136,22 +136,36 @@ export class IPAssetClient { deadline: calculatedDeadline, signature, }; - let txHash: Hex; - if (request.metadata) { - txHash = await this.spgClient.registerIp(object); - } else { - txHash = await this.ipAssetRegistryClient.register({ - tokenContract: object.nftContract, - tokenId: object.tokenId, - chainid: chain[this.chainId], - }); - } - if (request.txOptions?.waitForTransaction) { - const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - const targetLogs = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(txReceipt); - return { txHash: txHash, ipId: targetLogs[0].ipId }; + if (request.txOptions?.encodedTxDataOnly) { + if (request.metadata) { + return { encodedTxData: this.spgClient.registerIpEncode(object) }; + } else { + return { + encodedTxData: this.ipAssetRegistryClient.registerEncode({ + tokenContract: object.nftContract, + tokenId: object.tokenId, + chainid: chain[this.chainId], + }), + }; + } } else { - return { txHash: txHash }; + let txHash: Hex; + if (request.metadata) { + txHash = await this.spgClient.registerIp(object); + } else { + txHash = await this.ipAssetRegistryClient.register({ + tokenContract: object.nftContract, + tokenId: object.tokenId, + chainid: chain[this.chainId], + }); + } + if (request.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + const targetLogs = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(txReceipt); + return { txHash: txHash, ipId: targetLogs[0].ipId }; + } else { + return { txHash: txHash }; + } } } catch (error) { handleError(error, "Failed to register IP"); @@ -207,18 +221,23 @@ export class IPAssetClient { } } - const txHash = await this.licensingModuleClient.registerDerivative({ + const req = { childIpId: request.childIpId, parentIpIds: request.parentIpIds, licenseTermsIds: request.licenseTermsIds.map((id) => BigInt(id)), licenseTemplate: request.licenseTemplate || this.licenseTemplateClient.address, royaltyContext: zeroAddress, - }); - if (request.txOptions?.waitForTransaction) { - await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - return { txHash }; + }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: this.licensingModuleClient.registerDerivativeEncode(req) }; } else { - return { txHash }; + const txHash = await this.licensingModuleClient.registerDerivative(req); + if (request.txOptions?.waitForTransaction) { + await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + return { txHash }; + } else { + return { txHash }; + } } } catch (error) { handleError(error, "Failed to register derivative"); @@ -253,16 +272,23 @@ export class IPAssetClient { throw new Error(`License token id ${licenseTokenId} must be owned by the caller.`); } } - const txHash = await this.licensingModuleClient.registerDerivativeWithLicenseTokens({ + const req = { childIpId: getAddress(request.childIpId, "request.childIpId"), licenseTokenIds: request.licenseTokenIds, royaltyContext: zeroAddress, - }); - if (request.txOptions?.waitForTransaction) { - await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - return { txHash: txHash }; + }; + if (request.txOptions?.encodedTxDataOnly) { + return { + encodedTxData: this.licensingModuleClient.registerDerivativeWithLicenseTokensEncode(req), + }; } else { - return { txHash: txHash }; + const txHash = await this.licensingModuleClient.registerDerivativeWithLicenseTokens(req); + if (request.txOptions?.waitForTransaction) { + await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + return { txHash: txHash }; + } else { + return { txHash: txHash }; + } } } catch (error) { handleError(error, "Failed to register derivative with license tokens"); @@ -325,20 +351,25 @@ export class IPAssetClient { nftMetadataHash: request.metadata.nftMetadataHash || object.metadata.nftMetadataHash, }; } - const txHash = await this.spgClient.mintAndRegisterIpAndAttachPilTerms(object); - if (request.txOptions?.waitForTransaction) { - const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - const iPRegisteredLog = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(txReceipt)[0]; - const licenseTermsId = - this.licensingModuleClient.parseTxLicenseTermsAttachedEvent(txReceipt)[0].licenseTermsId; - return { - txHash: txHash, - ipId: iPRegisteredLog.ipId, - licenseTermsId, - tokenId: iPRegisteredLog.tokenId, - }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: this.spgClient.mintAndRegisterIpAndAttachPilTermsEncode(object) }; + } else { + const txHash = await this.spgClient.mintAndRegisterIpAndAttachPilTerms(object); + if (request.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + const iPRegisteredLog = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(txReceipt)[0]; + const licenseTermsId = + this.licensingModuleClient.parseTxLicenseTermsAttachedEvent(txReceipt)[0] + .licenseTermsId; + return { + txHash: txHash, + ipId: iPRegisteredLog.ipId, + licenseTermsId, + tokenId: iPRegisteredLog.tokenId, + }; + } + return { txHash }; } - return { txHash }; } catch (error) { handleError(error, "Failed to mint and register IP and attach PIL terms"); } @@ -451,13 +482,17 @@ export class IPAssetClient { deadline: calculatedDeadline, signature, }; - const txHash = await this.spgClient.registerIpAndAttachPilTerms(object); - if (request.txOptions?.waitForTransaction) { - const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - const log = this.licensingModuleClient.parseTxLicenseTermsAttachedEvent(txReceipt)[0]; - return { txHash, licenseTermsId: log.licenseTermsId, ipId: log.ipId }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: this.spgClient.registerIpAndAttachPilTermsEncode(object) }; + } else { + const txHash = await this.spgClient.registerIpAndAttachPilTerms(object); + if (request.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + const log = this.licensingModuleClient.parseTxLicenseTermsAttachedEvent(txReceipt)[0]; + return { txHash, licenseTermsId: log.licenseTermsId, ipId: log.ipId }; + } + return { txHash }; } - return { txHash }; } catch (error) { handleError(error, "Failed to register IP and attach PIL terms"); } @@ -593,13 +628,17 @@ export class IPAssetClient { deadline: calculatedDeadline, signature, }; - const txHash = await this.spgClient.registerIpAndMakeDerivative(object); - if (request.txOptions?.waitForTransaction) { - const receipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - const log = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(receipt)[0]; - return { txHash, ipId: log.ipId }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: this.spgClient.registerIpAndMakeDerivativeEncode(object) }; + } else { + const txHash = await this.spgClient.registerIpAndMakeDerivative(object); + if (request.txOptions?.waitForTransaction) { + const receipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + const log = this.ipAssetRegistryClient.parseTxIpRegisteredEvent(receipt)[0]; + return { txHash, ipId: log.ipId }; + } + return { txHash }; } - return { txHash }; } catch (error) { handleError(error, "Failed to register derivative IP"); } diff --git a/packages/core-sdk/src/resources/license.ts b/packages/core-sdk/src/resources/license.ts index ae88194b..45b70cea 100644 --- a/packages/core-sdk/src/resources/license.ts +++ b/packages/core-sdk/src/resources/license.ts @@ -67,13 +67,24 @@ export class LicenseClient { if (licenseTermsId !== 0n) { return { licenseTermsId: licenseTermsId }; } - const txHash = await this.licenseTemplateClient.registerLicenseTerms({ terms: licenseTerms }); - if (request?.txOptions?.waitForTransaction) { - const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - const targetLogs = this.licenseTemplateClient.parseTxLicenseTermsRegisteredEvent(txReceipt); - return { txHash: txHash, licenseTermsId: targetLogs[0].licenseTermsId }; + if (request?.txOptions?.encodedTxDataOnly) { + return { + encodedTxData: this.licenseTemplateClient.registerLicenseTermsEncode({ + terms: licenseTerms, + }), + }; } else { - return { txHash: txHash }; + const txHash = await this.licenseTemplateClient.registerLicenseTerms({ + terms: licenseTerms, + }); + if (request?.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + const targetLogs = + this.licenseTemplateClient.parseTxLicenseTermsRegisteredEvent(txReceipt); + return { txHash: txHash, licenseTermsId: targetLogs[0].licenseTermsId }; + } else { + return { txHash: txHash }; + } } } catch (error) { handleError(error, "Failed to register non commercial social remixing PIL"); @@ -101,13 +112,24 @@ export class LicenseClient { if (licenseTermsId !== 0n) { return { licenseTermsId: licenseTermsId }; } - const txHash = await this.licenseTemplateClient.registerLicenseTerms({ terms: licenseTerms }); - if (request.txOptions?.waitForTransaction) { - const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - const targetLogs = this.licenseTemplateClient.parseTxLicenseTermsRegisteredEvent(txReceipt); - return { txHash: txHash, licenseTermsId: targetLogs[0].licenseTermsId }; + if (request.txOptions?.encodedTxDataOnly) { + return { + encodedTxData: this.licenseTemplateClient.registerLicenseTermsEncode({ + terms: licenseTerms, + }), + }; } else { - return { txHash: txHash }; + const txHash = await this.licenseTemplateClient.registerLicenseTerms({ + terms: licenseTerms, + }); + if (request.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + const targetLogs = + this.licenseTemplateClient.parseTxLicenseTermsRegisteredEvent(txReceipt); + return { txHash: txHash, licenseTermsId: targetLogs[0].licenseTermsId }; + } else { + return { txHash: txHash }; + } } } catch (error) { handleError(error, "Failed to register commercial use PIL"); @@ -137,13 +159,24 @@ export class LicenseClient { if (licenseTermsId !== 0n) { return { licenseTermsId: licenseTermsId }; } - const txHash = await this.licenseTemplateClient.registerLicenseTerms({ terms: licenseTerms }); - if (request.txOptions?.waitForTransaction) { - const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - const targetLogs = this.licenseTemplateClient.parseTxLicenseTermsRegisteredEvent(txReceipt); - return { txHash: txHash, licenseTermsId: targetLogs[0].licenseTermsId }; + if (request.txOptions?.encodedTxDataOnly) { + return { + encodedTxData: this.licenseTemplateClient.registerLicenseTermsEncode({ + terms: licenseTerms, + }), + }; } else { - return { txHash: txHash }; + const txHash = await this.licenseTemplateClient.registerLicenseTerms({ + terms: licenseTerms, + }); + if (request.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + const targetLogs = + this.licenseTemplateClient.parseTxLicenseTermsRegisteredEvent(txReceipt); + return { txHash: txHash, licenseTermsId: targetLogs[0].licenseTermsId }; + } else { + return { txHash: txHash }; + } } } catch (error) { handleError(error, "Failed to register commercial remix PIL"); @@ -188,16 +221,21 @@ export class LicenseClient { if (isAttachedLicenseTerms) { return { txHash: "", success: false }; } - const txHash = await this.licensingModuleClient.attachLicenseTerms({ + const req = { ipId: request.ipId, licenseTemplate: request.licenseTemplate || this.licenseTemplateClient.address, licenseTermsId: request.licenseTermsId, - }); - if (request.txOptions?.waitForTransaction) { - await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - return { txHash: txHash, success: true }; + }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: this.licensingModuleClient.attachLicenseTermsEncode(req) }; } else { - return { txHash: txHash }; + const txHash = await this.licensingModuleClient.attachLicenseTerms(req); + if (request.txOptions?.waitForTransaction) { + await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + return { txHash: txHash, success: true }; + } else { + return { txHash: txHash }; + } } } catch (error) { handleError(error, "Failed to attach license terms"); @@ -258,7 +296,7 @@ export class LicenseClient { ); } const amount = BigInt(request.amount || 1); - const txHash = await this.licensingModuleClient.mintLicenseTokens({ + const req = { licensorIpId: request.licensorIpId, licenseTemplate: request.licenseTemplate || this.licenseTemplateClient.address, licenseTermsId: request.licenseTermsId, @@ -267,18 +305,23 @@ export class LicenseClient { (request.receiver && getAddress(request.receiver, "request.receiver")) || this.wallet.account!.address, royaltyContext: zeroAddress, - }); - if (request.txOptions?.waitForTransaction) { - const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - const targetLogs = this.licensingModuleClient.parseTxLicenseTokensMintedEvent(txReceipt); - const startLicenseTokenId = targetLogs[0].startLicenseTokenId; - const licenseTokenIds = []; - for (let i = 0; i < amount; i++) { - licenseTokenIds.push(startLicenseTokenId + BigInt(i)); - } - return { txHash: txHash, licenseTokenIds: licenseTokenIds }; + }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: this.licensingModuleClient.mintLicenseTokensEncode(req) }; } else { - return { txHash: txHash }; + const txHash = await this.licensingModuleClient.mintLicenseTokens(req); + if (request.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + const targetLogs = this.licensingModuleClient.parseTxLicenseTokensMintedEvent(txReceipt); + const startLicenseTokenId = targetLogs[0].startLicenseTokenId; + const licenseTokenIds = []; + for (let i = 0; i < amount; i++) { + licenseTokenIds.push(startLicenseTokenId + BigInt(i)); + } + return { txHash: txHash, licenseTokenIds: licenseTokenIds }; + } else { + return { txHash: txHash }; + } } } catch (error) { handleError(error, "Failed to mint license tokens"); diff --git a/packages/core-sdk/src/resources/nftClient.ts b/packages/core-sdk/src/resources/nftClient.ts index 8e39e083..df006885 100644 --- a/packages/core-sdk/src/resources/nftClient.ts +++ b/packages/core-sdk/src/resources/nftClient.ts @@ -43,7 +43,7 @@ export class NftClient { throw new Error("Invalid mint fee token address, mint fee is greater than 0."); } - const txHash = await this.spgClient.createCollection({ + const req = { name: request.name, symbol: request.symbol, maxSupply: request.maxSupply ?? Number(maxUint32), @@ -52,17 +52,23 @@ export class NftClient { owner: (request.owner && getAddress(request.owner, "request.owner")) || this.wallet.account!.address, - }); + }; - if (request.txOptions?.waitForTransaction) { - const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - const targetLogs = this.spgClient.parseTxCollectionCreatedEvent(txReceipt); - return { - txHash: txHash, - nftContract: targetLogs[0].nftContract, - }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: this.spgClient.createCollectionEncode(req) }; + } else { + const txHash = await this.spgClient.createCollection(req); + + if (request.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + const targetLogs = this.spgClient.parseTxCollectionCreatedEvent(txReceipt); + return { + txHash: txHash, + nftContract: targetLogs[0].nftContract, + }; + } + return { txHash: txHash }; } - return { txHash: txHash }; } catch (error) { handleError(error, "Failed to create a SPG NFT collection"); } diff --git a/packages/core-sdk/src/resources/permission.ts b/packages/core-sdk/src/resources/permission.ts index 011e2c62..4fe60d1c 100644 --- a/packages/core-sdk/src/resources/permission.ts +++ b/packages/core-sdk/src/resources/permission.ts @@ -65,18 +65,25 @@ export class PermissionClient { public async setPermission(request: SetPermissionsRequest): Promise { try { await this.checkIsRegistered(request.ipId); - const txHash = await this.accessControllerClient.setPermission({ + + const req = { ipAccount: request.ipId, signer: request.signer, to: request.to, func: request.func ? toFunctionSelector(request.func) : defaultFunctionSelector, permission: request.permission, - }); - if (request.txOptions?.waitForTransaction) { - await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - return { txHash: txHash, success: true }; + }; + + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: this.accessControllerClient.setPermissionEncode(req) }; } else { - return { txHash: txHash }; + const txHash = await this.accessControllerClient.setPermission(req); + if (request.txOptions?.waitForTransaction) { + await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + return { txHash: txHash, success: true }; + } else { + return { txHash: txHash }; + } } } catch (error) { handleError(error, "Failed to set permissions"); @@ -131,20 +138,25 @@ export class PermissionClient { chainId: chain[this.chainId], wallet: this.wallet as WalletClient, }); - const txHash = await ipAccountClient.executeWithSig({ + const req = { to: getAddress(this.accessControllerClient.address, "accessControllerClientAddress"), value: BigInt(0), data, signer: signer, deadline: calculatedDeadline, signature, - }); - - if (txOptions?.waitForTransaction) { - await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - return { txHash: txHash, success: true }; + }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: ipAccountClient.executeWithSigEncode(req) }; } else { - return { txHash: txHash }; + const txHash = await ipAccountClient.executeWithSig(req); + + if (txOptions?.waitForTransaction) { + await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + return { txHash: txHash, success: true }; + } else { + return { txHash: txHash }; + } } } catch (error) { handleError(error, "Failed to create set permission signature"); @@ -165,16 +177,21 @@ export class PermissionClient { ): Promise { try { await this.checkIsRegistered(request.ipId); - const txHash = await this.accessControllerClient.setAllPermissions({ + const req = { ipAccount: request.ipId, signer: request.signer, permission: request.permission, - }); - if (request.txOptions?.waitForTransaction) { - await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - return { txHash: txHash, success: true }; + }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: this.accessControllerClient.setAllPermissionsEncode(req) }; } else { - return { txHash: txHash }; + const txHash = await this.accessControllerClient.setAllPermissions(req); + if (request.txOptions?.waitForTransaction) { + await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + return { txHash: txHash, success: true }; + } else { + return { txHash: txHash }; + } } } catch (error) { handleError(error, "Failed to set all permissions"); @@ -202,7 +219,7 @@ export class PermissionClient { for (const permission of permissions) { await this.checkIsRegistered(permission.ipId); } - const txHash = await this.accessControllerClient.setBatchPermissions({ + const req = { permissions: permissions.map((permission) => ({ ipAccount: permission.ipId, signer: permission.signer, @@ -210,12 +227,17 @@ export class PermissionClient { func: permission.func ? toFunctionSelector(permission.func) : defaultFunctionSelector, permission: permission.permission, })), - }); - if (txOptions?.waitForTransaction) { - await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - return { txHash: txHash, success: true }; + }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: this.accessControllerClient.setBatchPermissionsEncode(req) }; } else { - return { txHash: txHash }; + const txHash = await this.accessControllerClient.setBatchPermissions(req); + if (txOptions?.waitForTransaction) { + await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + return { txHash: txHash, success: true }; + } else { + return { txHash: txHash }; + } } } catch (error) { handleError(error, "Failed to set batch permissions"); @@ -268,24 +290,30 @@ export class PermissionClient { wallet: this.wallet as WalletClient, permissionFunc: "setBatchPermissions", }); - const txHash = await ipAccountClient.executeWithSig({ + const req = { to: getAddress(this.accessControllerClient.address, "accessControllerAddress"), value: BigInt(0), data, signer: getAddress(this.wallet.account!.address, "walletAccountAddress"), deadline: calculatedDeadline, signature, - }); - if (txOptions?.waitForTransaction) { - await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - return { txHash: txHash, success: true }; + }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: ipAccountClient.executeWithSigEncode(req) }; } else { - return { txHash: txHash }; + const txHash = await ipAccountClient.executeWithSig(req); + if (txOptions?.waitForTransaction) { + await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + return { txHash: txHash, success: true }; + } else { + return { txHash: txHash }; + } } } catch (error) { handleError(error, "Failed to create batch permission signature"); } } + private async checkIsRegistered(ipId: Address): Promise { const isRegistered = await this.ipAssetRegistryClient.isRegistered({ id: getAddress(ipId, "ipId"), diff --git a/packages/core-sdk/src/resources/royalty.ts b/packages/core-sdk/src/resources/royalty.ts index 52cbb66c..475a85f4 100644 --- a/packages/core-sdk/src/resources/royalty.ts +++ b/packages/core-sdk/src/resources/royalty.ts @@ -68,18 +68,23 @@ export class RoyaltyClient { this.wallet, proxyAddress, ); - const txHash = await ipRoyaltyVault.collectRoyaltyTokens({ + const req = { ancestorIpId: request.parentIpId, - }); - if (request.txOptions?.waitForTransaction) { - const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - const targetLogs = ipRoyaltyVault.parseTxRoyaltyTokensCollectedEvent(txReceipt); - return { - txHash: txHash, - royaltyTokensCollected: targetLogs[0].royaltyTokensCollected, - }; + }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: ipRoyaltyVault.collectRoyaltyTokensEncode(req) }; } else { - return { txHash: txHash }; + const txHash = await ipRoyaltyVault.collectRoyaltyTokens(req); + if (request.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + const targetLogs = ipRoyaltyVault.parseTxRoyaltyTokensCollectedEvent(txReceipt); + return { + txHash: txHash, + royaltyTokensCollected: targetLogs[0].royaltyTokensCollected, + }; + } else { + return { txHash: txHash }; + } } } catch (error) { handleError(error, "Failed to collect royalty tokens"); @@ -112,17 +117,22 @@ export class RoyaltyClient { if (!isPayerRegistered) { throw new Error(`The payer IP with id ${request.payerIpId} is not registered.`); } - const txHash = await this.royaltyModuleClient.payRoyaltyOnBehalf({ + const req = { receiverIpId: request.receiverIpId, payerIpId: request.payerIpId, token: getAddress(request.token, "request.token"), amount: BigInt(request.amount), - }); - if (request.txOptions?.waitForTransaction) { - await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - return { txHash }; + }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: this.royaltyModuleClient.payRoyaltyOnBehalfEncode(req) }; } else { - return { txHash }; + const txHash = await this.royaltyModuleClient.payRoyaltyOnBehalf(req); + if (request.txOptions?.waitForTransaction) { + await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + return { txHash }; + } else { + return { txHash }; + } } } catch (error) { handleError(error, "Failed to pay royalty on behalf"); @@ -189,21 +199,27 @@ export class RoyaltyClient { to: proxyAddress, value: 0, ipId: getAddress(request.account, "request.account"), - txOptions: { - waitForTransaction: true, - }, + txOptions: request.txOptions, data: encodeFunctionData({ abi: ipRoyaltyVaultImplAbi, functionName: "claimRevenueBySnapshotBatch", args: [request.snapshotIds, request.token], }), }); + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: iPAccountExecuteResponse.encodedTxData }; + } txHash = iPAccountExecuteResponse.txHash as Hex; } else { - txHash = await ipRoyaltyVault.claimRevenueBySnapshotBatch({ + const req = { snapshotIds: request.snapshotIds, token: getAddress(request.token, "request.token"), - }); + }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: ipRoyaltyVault.claimRevenueBySnapshotBatchEncode(req) }; + } else { + txHash = await ipRoyaltyVault.claimRevenueBySnapshotBatch(req); + } } if (request.txOptions?.waitForTransaction) { const txReceipt = await this.rpcClient.waitForTransactionReceipt({ @@ -236,13 +252,17 @@ export class RoyaltyClient { this.wallet, proxyAddress, ); - const txHash = await ipRoyaltyVault.snapshot(); - if (request.txOptions?.waitForTransaction) { - const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); - const targetLogs = ipRoyaltyVault.parseTxSnapshotCompletedEvent(txReceipt); - return { txHash, snapshotId: targetLogs[0].snapshotId }; + if (request.txOptions?.encodedTxDataOnly) { + return { encodedTxData: ipRoyaltyVault.snapshotEncode() }; } else { - return { txHash }; + const txHash = await ipRoyaltyVault.snapshot(); + if (request.txOptions?.waitForTransaction) { + const txReceipt = await this.rpcClient.waitForTransactionReceipt({ hash: txHash }); + const targetLogs = ipRoyaltyVault.parseTxSnapshotCompletedEvent(txReceipt); + return { txHash, snapshotId: targetLogs[0].snapshotId }; + } else { + return { txHash }; + } } } catch (error) { handleError(error, "Failed to snapshot"); diff --git a/packages/core-sdk/src/types/options.ts b/packages/core-sdk/src/types/options.ts index 6a373cc1..0ad22103 100644 --- a/packages/core-sdk/src/types/options.ts +++ b/packages/core-sdk/src/types/options.ts @@ -3,6 +3,10 @@ export type TxOptions = { // can receive a transaction receipt in return (which // contains data about the transaction and return values). waitForTransaction?: boolean; + // When the time of setting this option, the transaction will + // not submit and execute, it will only encode the abi and + // function data and return. + encodedTxDataOnly?: boolean; // The price (in wei) to pay per gas. gasPrice?: bigint; // Total fee per gas (in wei). diff --git a/packages/core-sdk/src/types/resources/dispute.ts b/packages/core-sdk/src/types/resources/dispute.ts index c2000bc3..f779d5fc 100644 --- a/packages/core-sdk/src/types/resources/dispute.ts +++ b/packages/core-sdk/src/types/resources/dispute.ts @@ -1,6 +1,7 @@ import { Address } from "viem"; import { TxOptions } from "../options"; +import { EncodedTxData } from "../../abi/generated"; export type RaiseDisputeRequest = { targetIpId: Address; @@ -12,7 +13,8 @@ export type RaiseDisputeRequest = { }; export type RaiseDisputeResponse = { - txHash: string; + txHash?: string; + encodedTxData?: EncodedTxData; disputeId?: bigint; }; @@ -23,7 +25,8 @@ export type CancelDisputeRequest = { }; export type CancelDisputeResponse = { - txHash: string; + txHash?: string; + encodedTxData?: EncodedTxData; }; export type ResolveDisputeRequest = { @@ -33,5 +36,6 @@ export type ResolveDisputeRequest = { }; export type ResolveDisputeResponse = { - txHash: string; + txHash?: string; + encodedTxData?: EncodedTxData; }; diff --git a/packages/core-sdk/src/types/resources/ipAccount.ts b/packages/core-sdk/src/types/resources/ipAccount.ts index d4ac3809..f91f9367 100644 --- a/packages/core-sdk/src/types/resources/ipAccount.ts +++ b/packages/core-sdk/src/types/resources/ipAccount.ts @@ -1,6 +1,7 @@ import { Address } from "viem"; import { TxOptions } from "../options"; +import { EncodedTxData } from "../../abi/generated"; export type IPAccountExecuteRequest = { ipId: Address; @@ -11,7 +12,8 @@ export type IPAccountExecuteRequest = { }; export type IPAccountExecuteResponse = { - txHash: string; + txHash?: string; + encodedTxData?: EncodedTxData; }; export type IPAccountExecuteWithSigRequest = { @@ -26,5 +28,6 @@ export type IPAccountExecuteWithSigRequest = { }; export type IPAccountExecuteWithSigResponse = { - txHash: string; + txHash?: string; + encodedTxData?: EncodedTxData; }; diff --git a/packages/core-sdk/src/types/resources/ipAsset.ts b/packages/core-sdk/src/types/resources/ipAsset.ts index 4e1a04c6..8ebdb40d 100644 --- a/packages/core-sdk/src/types/resources/ipAsset.ts +++ b/packages/core-sdk/src/types/resources/ipAsset.ts @@ -2,6 +2,7 @@ import { Address, Hex } from "viem"; import { TxOptions } from "../options"; import { PIL_TYPE } from "./license"; +import { EncodedTxData } from "../../abi/generated"; type Metadata = { metadata?: { @@ -13,6 +14,7 @@ type Metadata = { export type RegisterIpResponse = { txHash?: string; + encodedTxData?: EncodedTxData; ipId?: Address; }; @@ -30,7 +32,8 @@ export type RegisterDerivativeWithLicenseTokensRequest = { }; export type RegisterDerivativeWithLicenseTokensResponse = { - txHash: string; + txHash?: string; + encodedTxData?: EncodedTxData; }; export type RegisterDerivativeRequest = { @@ -43,6 +46,7 @@ export type RegisterDerivativeRequest = { export type RegisterDerivativeResponse = { txHash?: string; + encodedTxData?: EncodedTxData; childIpId?: Address; }; @@ -57,7 +61,8 @@ export type CreateIpAssetWithPilTermsRequest = { } & Metadata; export type CreateIpAssetWithPilTermsResponse = { - txHash: string; + txHash?: string; + encodedTxData?: EncodedTxData; ipId?: Address; tokenId?: bigint; licenseTermsId?: bigint; @@ -76,7 +81,8 @@ export type RegisterIpAndMakeDerivativeRequest = { } & Metadata; export type RegisterIpAndMakeDerivativeResponse = { - txHash: string; + txHash?: string; + encodedTxData?: EncodedTxData; ipId?: Address; }; @@ -92,7 +98,8 @@ export type RegisterIpAndAttachPilTermsRequest = { } & Metadata; export type RegisterIpAndAttachPilTermsResponse = { - txHash: string; + txHash?: string; + encodedTxData?: EncodedTxData; ipId?: Address; licenseTermsId?: bigint; }; diff --git a/packages/core-sdk/src/types/resources/license.ts b/packages/core-sdk/src/types/resources/license.ts index 9d8a2f0c..abeafd32 100644 --- a/packages/core-sdk/src/types/resources/license.ts +++ b/packages/core-sdk/src/types/resources/license.ts @@ -1,6 +1,7 @@ import { Address } from "viem"; import { TxOptions } from "../options"; +import { EncodedTxData } from "../../abi/generated"; export type LicenseApiResponse = { data: License; @@ -40,6 +41,7 @@ export type LicenseTermsIdResponse = bigint; export type RegisterPILResponse = { licenseTermsId?: bigint; txHash?: string; + encodedTxData?: EncodedTxData; }; export type RegisterCommercialUsePILRequest = { @@ -63,7 +65,8 @@ export type AttachLicenseTermsRequest = { }; export type AttachLicenseTermsResponse = { - txHash: string; + txHash?: string; + encodedTxData?: EncodedTxData; success?: boolean; }; @@ -79,6 +82,7 @@ export type MintLicenseTokensRequest = { export type MintLicenseTokensResponse = { licenseTokenIds?: bigint[]; txHash?: string; + encodedTxData?: EncodedTxData; }; export enum PIL_TYPE { diff --git a/packages/core-sdk/src/types/resources/nftClient.ts b/packages/core-sdk/src/types/resources/nftClient.ts index 3d536498..880295d0 100644 --- a/packages/core-sdk/src/types/resources/nftClient.ts +++ b/packages/core-sdk/src/types/resources/nftClient.ts @@ -1,6 +1,7 @@ import { Hex } from "viem"; import { TxOptions } from "../options"; +import { EncodedTxData } from "../../abi/generated"; export type CreateNFTCollectionRequest = { name: string; @@ -12,4 +13,8 @@ export type CreateNFTCollectionRequest = { txOptions?: TxOptions; }; -export type CreateNFTCollectionResponse = { txHash: string; nftContract?: Hex }; +export type CreateNFTCollectionResponse = { + txHash?: string; + encodedTxData?: EncodedTxData; + nftContract?: Hex; +}; diff --git a/packages/core-sdk/src/types/resources/permission.ts b/packages/core-sdk/src/types/resources/permission.ts index 6db05caf..2767c6f6 100644 --- a/packages/core-sdk/src/types/resources/permission.ts +++ b/packages/core-sdk/src/types/resources/permission.ts @@ -1,6 +1,7 @@ import { Address } from "viem"; import { TxOptions } from "../options"; +import { EncodedTxData } from "../../abi/generated"; export type SetPermissionsRequest = { ipId: Address; @@ -12,7 +13,8 @@ export type SetPermissionsRequest = { }; export type SetPermissionsResponse = { - txHash: string; + txHash?: string; + encodedTxData?: EncodedTxData; success?: boolean; }; diff --git a/packages/core-sdk/src/types/resources/royalty.ts b/packages/core-sdk/src/types/resources/royalty.ts index fa7ce7f6..ae03166b 100644 --- a/packages/core-sdk/src/types/resources/royalty.ts +++ b/packages/core-sdk/src/types/resources/royalty.ts @@ -1,6 +1,7 @@ import { Address } from "viem"; import { TxOptions } from "../options"; +import { EncodedTxData } from "../../abi/generated"; export type RoyaltyPolicyApiResponse = { data: RoyaltyPolicy; @@ -28,7 +29,8 @@ export type CollectRoyaltyTokensRequest = { }; export type CollectRoyaltyTokensResponse = { - txHash: string; + txHash?: string; + encodedTxData?: EncodedTxData; royaltyTokensCollected?: bigint; }; @@ -58,7 +60,8 @@ export type PayRoyaltyOnBehalfRequest = { }; export type PayRoyaltyOnBehalfResponse = { - txHash: string; + txHash?: string; + encodedTxData?: EncodedTxData; }; export type SnapshotRequest = { @@ -75,11 +78,13 @@ export type ClaimRevenueRequest = { }; export type ClaimRevenueResponse = { - txHash: string; + txHash?: string; + encodedTxData?: EncodedTxData; claimableToken?: bigint; }; export type SnapshotResponse = { - txHash: string; + txHash?: string; + encodedTxData?: EncodedTxData; snapshotId?: bigint; }; diff --git a/packages/core-sdk/test/unit/resources/ipAsset.test.ts b/packages/core-sdk/test/unit/resources/ipAsset.test.ts index 50985403..abd16e0f 100644 --- a/packages/core-sdk/test/unit/resources/ipAsset.test.ts +++ b/packages/core-sdk/test/unit/resources/ipAsset.test.ts @@ -191,6 +191,41 @@ describe("Test IpAssetClient", () => { expect(response.ipId).equals("0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"); }); + it("should return encoded tx data when register a IP given correct args, encodedTxDataOnly is true and metadata", async () => { + sinon + .stub(ipAssetClient.ipAssetRegistryClient, "ipId") + .resolves("0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"); + sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(false); + sinon + .stub(ipAssetClient.spgClient, "registerIp") + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + sinon.stub(ipAssetClient.ipAssetRegistryClient, "parseTxIpRegisteredEvent").returns([ + { + ipId: "0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4", + chainId: 0n, + tokenContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + tokenId: 0n, + name: "", + uri: "", + registrationDate: 0n, + }, + ]); + const response = await ipAssetClient.register({ + nftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + tokenId: "3", + metadata: { + metadataURI: "", + metadataHash: zeroHash, + nftMetadataHash: zeroHash, + }, + txOptions: { + encodedTxDataOnly: true, + }, + }); + + expect(response.encodedTxData!.data).to.be.a("string").and.not.empty; + }); + it("should throw error when request fails", async () => { sinon .stub(ipAssetClient.ipAssetRegistryClient, "ipId") @@ -347,6 +382,34 @@ describe("Test IpAssetClient", () => { "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997", ); }); + + it("should return encoded tx data when registerDerivative given correct childIpId, parentIpId, licenseTermsIds and encodedTxDataOnly of true ", async () => { + sinon + .stub(ipAssetClient.ipAssetRegistryClient, "isRegistered") + .onCall(0) + .resolves(true) + .onCall(1) + .resolves(true); + sinon + .stub(ipAssetClient.licenseRegistryReadOnlyClient, "hasIpAttachedLicenseTerms") + .resolves(true); + sinon + .stub(ipAssetClient.licensingModuleClient, "registerDerivative") + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + + const res = await ipAssetClient.registerDerivative({ + childIpId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + parentIpIds: ["0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"], + licenseTermsIds: ["1"], + licenseTemplate: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + txOptions: { + encodedTxDataOnly: true, + }, + }); + + expect(res.encodedTxData!.data).to.be.a("string").and.not.empty; + }); + }); describe("Test ipAssetClient.registerDerivativeWithLicenseTokens", async () => { @@ -436,6 +499,32 @@ describe("Test IpAssetClient", () => { "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997", ); }); + + it("should return encoded tx data when registerDerivativeWithLicenseTokens given correct args and encodedTxDataOnly of true", async () => { + sinon + .stub(ipAssetClient.ipAssetRegistryClient, "isRegistered") + .onCall(0) + .resolves(true) + .onCall(1) + .resolves(true); + sinon + .stub(ipAssetClient.licenseTokenReadOnlyClient, "ownerOf") + .resolves("0x73fcb515cee99e4991465ef586cfe2b072ebb512"); + sinon + .stub(ipAssetClient.licensingModuleClient, "registerDerivativeWithLicenseTokens") + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + + const res = await ipAssetClient.registerDerivativeWithLicenseTokens({ + childIpId: "0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4", + licenseTokenIds: ["1"], + txOptions: { + encodedTxDataOnly: true, + }, + }); + + expect(res.encodedTxData!.data).to.be.a("string").and.not.empty; + }); + }); describe("Test ipAssetClient.createIpAssetWithPilTerms", async () => { @@ -481,6 +570,7 @@ describe("Test IpAssetClient", () => { expect(result.txHash).to.equal(hash); }); + it("should return ipId, tokenId, licenseTermsId,txHash when createIpAssetWithPilTerms given correct args and waitForTransaction of true", async () => { const hash = "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"; sinon.stub(ipAssetClient.spgClient, "mintAndRegisterIpAndAttachPilTerms").resolves(hash); @@ -519,6 +609,26 @@ describe("Test IpAssetClient", () => { expect(result.licenseTermsId).to.equal(0n); expect(result.tokenId).to.equal(1n); }); + + it("should return encoded tx data when createIpAssetWithPilTerms given correct args and encodedTxDataOnly is true", async () => { + const hash = "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"; + sinon.stub(ipAssetClient.spgClient, "mintAndRegisterIpAndAttachPilTerms").resolves(hash); + const result = await ipAssetClient.mintAndRegisterIpAssetWithPilTerms({ + nftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + pilType: 0, + recipient: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + metadata: { + metadataURI: "", + metadataHash: toHex(0, { size: 32 }), + }, + txOptions: { + encodedTxDataOnly: true + } + }); + + expect(result.encodedTxData!.data).to.be.a("string").and.not.empty; + }); + }); describe("Test ipAssetClient.registerDerivativeIp", async () => { @@ -695,6 +805,49 @@ describe("Test IpAssetClient", () => { ); expect(res.ipId).equal("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); }); + + it("should return encoded tx data when registerDerivativeIp given correct args and encodedTxDataOnly of true", async () => { + sinon + .stub(ipAssetClient.ipAssetRegistryClient, "ipId") + .resolves("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); + sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(false); + sinon + .stub(ipAssetClient.licenseRegistryReadOnlyClient, "hasIpAttachedLicenseTerms") + .resolves(true); + sinon + .stub(ipAssetClient.spgClient, "registerIpAndMakeDerivative") + .resolves("0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"); + sinon.stub(ipAssetClient.ipAssetRegistryClient, "parseTxIpRegisteredEvent").returns([ + { + ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + chainId: 0n, + tokenContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + tokenId: 1n, + name: "", + uri: "", + registrationDate: 0n, + }, + ]); + + const res = await ipAssetClient.registerDerivativeIp({ + nftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + tokenId: "3", + derivData: { + parentIpIds: ["0xd142822Dc1674154EaF4DDF38bbF7EF8f0D8ECe4"], + licenseTermsIds: ["1"], + licenseTemplate: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + }, + metadata: { + metadataURI: "https://", + nftMetadataHash: toHex("nftMetadata", { size: 32 }), + }, + txOptions: { + encodedTxDataOnly: true, + }, + }); + + expect(res.encodedTxData!.data).to.be.a("string").and.not.empty; + }); }); describe("Test ipAssetClient.registerIpAndAttachPilTerms", async () => { @@ -807,5 +960,36 @@ describe("Test IpAssetClient", () => { expect(result.txHash).to.equal(hash); expect(result.ipId).to.equal("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); }); + + it("should return encoded tx data when registerIpAndAttachPilTerms given correct args and encodedTxDataOnly of true", async () => { + const hash = "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997"; + sinon + .stub(ipAssetClient.ipAssetRegistryClient, "ipId") + .resolves("0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c"); + sinon.stub(ipAssetClient.ipAssetRegistryClient, "isRegistered").resolves(false); + + sinon.stub(ipAssetClient.spgClient, "registerIpAndAttachPilTerms").resolves(hash); + sinon.stub(ipAssetClient.licensingModuleClient, "parseTxLicenseTermsAttachedEvent").returns([ + { + ipId: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + caller: "0x73fcb515cee99e4991465ef586cfe2b072ebb512", + licenseTemplate: "0x1daAE3197Bc469Cb97B917aa460a12dD95c6627c", + licenseTermsId: 0n, + }, + ]); + const result = await ipAssetClient.registerIpAndAttachPilTerms({ + nftContract: "0x1daAE3197Bc469Cb97B917aa460a12dD95c662ac", + tokenId: "3", + metadata: { + metadataURI: "https://", + }, + pilType: 0, + txOptions: { + encodedTxDataOnly: true, + }, + }); + + expect(result.encodedTxData!.data).to.be.a("string").and.not.empty; + }); }); }); diff --git a/packages/wagmi-generator/sdk.ts b/packages/wagmi-generator/sdk.ts index 2a85da7a..cd260d92 100644 --- a/packages/wagmi-generator/sdk.ts +++ b/packages/wagmi-generator/sdk.ts @@ -239,6 +239,46 @@ function generateContractFunction(contractName: string, func: AbiFunction) { return {func: funcLine.join("\n"), types: types.join("\n")} } +function generateContractDataFunction(contractName: string, func: AbiFunction) { + const abiName = `${camelCase(contractName)}Abi` + const indexFuncName = ('index' in func) ? `${func.name}${func.index}` : func.name + const inName = `${pascalCase(contractName)}${pascalCase(indexFuncName)}Request` + const inType = generateContractTypes(inName, func.inputs) + const inParams = inType.valid ? `request: ${inName}` : `` + let method = 'readContract' + + let funcLine: Array = []; + let types: Array = []; + + if (inType.valid) types.push(`${inType.comment}\n${inType.type}`) + + addImport('viem', 'encodeFunctionData') + + funcLine.push(``) + funcLine.push(`/**`) + funcLine.push(` * method ${func.name} for contract ${contractName} with only encode`) + funcLine.push(` *`) + funcLine.push(` * @param request ${inName}`) + funcLine.push(` * @return EncodedTxData`) + funcLine.push(`*/`) + funcLine.push(` public ${camelCase(indexFuncName)}Encode(${inParams}): EncodedTxData {`) + funcLine.push(` return {`) + funcLine.push(` to: this.address,`) + funcLine.push(` data:encodeFunctionData({`) + funcLine.push(` abi: ${abiName},`) + funcLine.push(` functionName: "${func.name}",`) + if (inType.valid) { + funcLine.push(` args: [`) + funcLine.push(inType.args) + funcLine.push(` ],`) + } + funcLine.push(` }),`) + funcLine.push(` };`) + funcLine.push(` }`) + + return {func: funcLine.join("\n"), types: ""} +} + function generateEventFunction(contractName: any, event: AbiEvent) { const abiName = `${camelCase(contractName)}Abi` const typeName = `${pascalCase(contractName)}${pascalCase(event.name)}Event` @@ -414,6 +454,10 @@ function generateContract(config: SDKConfig, contract: Contract): string { const data = generateContractFunction(contract.name, it) file.push(data.func) types.push(data.types) + + const dataFunc = generateContractDataFunction(contract.name, it) + file.push(dataFunc.func) + types.push(dataFunc.types) }) file.push(`}`) } @@ -432,7 +476,9 @@ function generateCommon(config: SDKConfig) { file.push(` return address[chainId || 0] || '0x'`) file.push(`}`) file.push(``) - addImport('viem', 'Address') + file.push(`export type EncodedTxData = {to: Address, data: Hex}`) + file.push(``) + addImport('viem', 'Address', 'Hex') if (config.permissionLessSDK) { file.push(``)