diff --git a/packages/core-sdk/package.json b/packages/core-sdk/package.json index 5301d49f..e6f5b1cc 100644 --- a/packages/core-sdk/package.json +++ b/packages/core-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@story-protocol/core-sdk", - "version": "1.0.0-rc.23", + "version": "1.1.0-stable", "description": "Story Protocol Core SDK", "main": "dist/story-protocol-core-sdk.cjs.js", "module": "dist/story-protocol-core-sdk.esm.js", @@ -17,7 +17,7 @@ ], "scripts": { "build": "pnpm run fix && preconstruct build", - "test": "pnpm run test:unit && pnpm run test:integration", + "test": "pnpm run test:unit", "test:unit": "TS_NODE_PROJECT='./tsconfig.test.json' c8 --all --src ./src mocha -r ts-node/register './test/unit/**/*.test.ts'", "test:integration": "TS_NODE_PROJECT='./tsconfig.test.json' mocha -r ts-node/register './test/integration/**/*.test.ts' --timeout 240000", "fix": "pnpm run format:fix && pnpm run lint:fix", diff --git a/packages/core-sdk/src/client.ts b/packages/core-sdk/src/client.ts index 6cd6daad..168f7457 100644 --- a/packages/core-sdk/src/client.ts +++ b/packages/core-sdk/src/client.ts @@ -26,7 +26,7 @@ if (typeof process !== "undefined") { export class StoryClient { private readonly config: StoryConfig & { chainId: SupportedChainIds }; private readonly rpcClient: PublicClient; - private readonly wallet: SimpleWalletClient; + public readonly wallet: SimpleWalletClient; private _ipAsset: IPAssetClient | null = null; private _permission: PermissionClient | null = null; private _license: LicenseClient | null = null; diff --git a/packages/core-sdk/src/index.ts b/packages/core-sdk/src/index.ts index 0a0bd365..3a9a800e 100644 --- a/packages/core-sdk/src/index.ts +++ b/packages/core-sdk/src/index.ts @@ -48,6 +48,7 @@ export type { MintLicenseTokensResponse, LicenseTermsId, LicenseTerms, + RegisterPILTermsRequest, } from "./types/resources/license"; export { PIL_TYPE } from "./types/resources/license"; diff --git a/packages/react-sdk/generator/index.js b/packages/react-sdk/generator/index.js index bbe7bf64..530e5675 100644 --- a/packages/react-sdk/generator/index.js +++ b/packages/react-sdk/generator/index.js @@ -43,7 +43,7 @@ const visit = (file) => { if ( ts.isMethodDeclaration(member) && (member.modifiers?.some( - (m) => m.kind === ts.SyntaxKind.PublicKeyword + (m) => m.kind === ts.SyntaxKind.PublicKeyword, ) ?? true) && member.name && @@ -51,7 +51,7 @@ const visit = (file) => { ) { const requests = []; const isAsync = member.modifiers?.some( - (modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword + (modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword, ); program.getTypeChecker().getSignatureFromDeclaration(member); member.parameters.forEach((parameter) => { @@ -72,7 +72,7 @@ const visit = (file) => { ts .getLeadingCommentRanges(sourceFile.text, member.pos) ?.map((range) => - sourceFile.text.substring(range.pos, range.end).trim() + sourceFile.text.substring(range.pos, range.end).trim(), ) || [], defaultValues: undefined, // Get default value, }; @@ -104,16 +104,16 @@ files.forEach((file, index) => { (acc, curr) => acc.concat( curr.requests.map((item) => item.type), - curr.responseType + curr.responseType, ), - [] + [], ); const filteredTypes = [ ...new Set( types .filter((type) => !isPrimitiveType(type)) .filter((type) => !isViemType(type)) - .filter((type) => !isEnclosedInCurlyBraces(type)) + .filter((type) => !isEnclosedInCurlyBraces(type)), ), ]; exportTypes.push(...filteredTypes); @@ -123,8 +123,29 @@ files.forEach((file, index) => { name: fileName, methodNames: asyncMethods, viemTypes: [...new Set(types.filter((type) => isViemType(type)))], - }) + }), ); + + const returnObjectWithUndefined = asyncMethods.reduce((acc, method) => { + acc[method] = undefined; + return acc; + }, {}); + + sources.push( + ejs.render( + ` + if (!client) { + return { + loadings, + errors, + <%= Object.entries(returnObjectWithUndefined).map(([key, value]) => \`\${key}: \${value}\`).join(',\\n ') %> + }; + } + `, + { returnObjectWithUndefined }, + ), + ); + const methodTemplates = methods.map((method) => { return ejs.render(resourceTemplate.methodTemplate, { method: method, @@ -138,7 +159,7 @@ files.forEach((file, index) => { ejs.render(resourceTemplate.endTemplate, { methodNames, name: fileName, - }) + }), ); fs.writeFileSync(`src/resources/use${fileName}.ts`, sources.join("\n")); }); @@ -151,7 +172,7 @@ exec("npm run fix", (error) => { if (error) { console.log( "\x1b[31m%s\x1b[0m", - "\nError occurred while running npm run fix command. Please run `npm run fix` manually." + "\nError occurred while running npm run fix command. Please run `npm run fix` manually.", ); bar.stop(); return; @@ -160,6 +181,6 @@ exec("npm run fix", (error) => { bar.stop(); console.log( "\x1b[32m%s\x1b[0m", - "React SDK templates generated successfully!" + "React SDK templates generated successfully!", ); }); diff --git a/packages/react-sdk/package.json b/packages/react-sdk/package.json index c7caa12b..31a93930 100644 --- a/packages/react-sdk/package.json +++ b/packages/react-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@story-protocol/react-sdk", - "version": "0.0.2", + "version": "1.1.0-stable", "description": "The Story Protocol React SDK", "main": "dist/story-protocol-react-sdk.cjs.js", "module": "dist/story-protocol-react-sdk.esm.js", @@ -14,6 +14,7 @@ "scripts": { "generate": "node ./generator/index.js", "build": "pnpm run fix && preconstruct build", + "test:integration": "jest -i", "fix": "pnpm run format:fix && pnpm run lint:fix", "format": "prettier --check .", "format:fix": "prettier --write .", @@ -62,7 +63,7 @@ }, "license": "MIT", "dependencies": { - "@story-protocol/core-sdk": "1.0.0-rc.22", + "@story-protocol/core-sdk": "1.1.0-stable", "react": "^18.3.1", "viem": "^2.8.12" }, diff --git a/packages/react-sdk/src/StoryProtocolContext.tsx b/packages/react-sdk/src/StoryProtocolContext.tsx index efb74c25..57e4b4bf 100644 --- a/packages/react-sdk/src/StoryProtocolContext.tsx +++ b/packages/react-sdk/src/StoryProtocolContext.tsx @@ -11,13 +11,21 @@ const StoryContext = createContext({} as StoryClient); const StoryProvider = ({ config, children }: Props) => { const [client, setClient] = useState(); - if (!client) { + if (!config.wallet) { + setClient( + StoryClient.newClient({ + transport: config.transport, + }), + ); + } else if (!client) { setClient(StoryClient.newClient(config)); } + return ( {children} ); }; + const useStoryContext = (): StoryClient => { return useContext(StoryContext); }; diff --git a/packages/react-sdk/src/index.ts b/packages/react-sdk/src/index.ts index ecdb3cbc..44f5d909 100644 --- a/packages/react-sdk/src/index.ts +++ b/packages/react-sdk/src/index.ts @@ -24,6 +24,7 @@ export type { IPAccountExecuteWithSigRequest, IPAccountExecuteWithSigResponse, IpAccountStateResponse, + TokenResponse, GenerateCreatorMetadataParam, IpCreator, GenerateIpMetadataParam, @@ -41,8 +42,9 @@ export type { RegisterIpAndMakeDerivativeRequest, RegisterIpAndMakeDerivativeResponse, MintAndRegisterIpAndMakeDerivativeRequest, - RegisterNonComSocialRemixingPILRequest, + RegisterPILTermsRequest, RegisterPILResponse, + RegisterNonComSocialRemixingPILRequest, RegisterCommercialUsePILRequest, RegisterCommercialRemixPILRequest, AttachLicenseTermsRequest, diff --git a/packages/react-sdk/src/resources/useDispute.ts b/packages/react-sdk/src/resources/useDispute.ts index 9ec2a159..cdd2b41a 100644 --- a/packages/react-sdk/src/resources/useDispute.ts +++ b/packages/react-sdk/src/resources/useDispute.ts @@ -24,6 +24,16 @@ const useDispute = () => { resolveDispute: null, }); + if (!client) { + return { + loadings, + errors, + raiseDispute: undefined, + cancelDispute: undefined, + resolveDispute: undefined, + }; + } + /** * Raises a dispute on a given ipId * @param request - The request object containing necessary data to raise a dispute. @@ -47,7 +57,7 @@ const useDispute = () => { "raiseDispute", client.dispute.raiseDispute.bind(client.dispute), setLoadings, - setErrors + setErrors, ); /** @@ -70,7 +80,7 @@ const useDispute = () => { "cancelDispute", client.dispute.cancelDispute.bind(client.dispute), setLoadings, - setErrors + setErrors, ); /** @@ -91,7 +101,7 @@ const useDispute = () => { "resolveDispute", client.dispute.resolveDispute.bind(client.dispute), setLoadings, - setErrors + setErrors, ); return { diff --git a/packages/react-sdk/src/resources/useIpAccount.ts b/packages/react-sdk/src/resources/useIpAccount.ts index 9c9a1d66..b372285e 100644 --- a/packages/react-sdk/src/resources/useIpAccount.ts +++ b/packages/react-sdk/src/resources/useIpAccount.ts @@ -4,7 +4,9 @@ import { IPAccountExecuteWithSigRequest, IPAccountExecuteWithSigResponse, IpAccountStateResponse, + TokenResponse, } from "@story-protocol/core-sdk"; +import { Address } from "viem"; import { useState } from "react"; import { useStoryContext } from "../StoryProtocolContext"; @@ -16,13 +18,26 @@ const useIpAccount = () => { execute: false, executeWithSig: false, getIpAccountNonce: false, + getToken: false, }); const [errors, setErrors] = useState>({ execute: null, executeWithSig: null, getIpAccountNonce: null, + getToken: null, }); + if (!client) { + return { + loadings, + errors, + execute: undefined, + executeWithSig: undefined, + getIpAccountNonce: undefined, + getToken: undefined, + }; + } + /** Executes a transaction from the IP Account. * @param request - The request object containing necessary data to execute IP Account a transaction. * @param request.ipId The Ip Id to get ip account. @@ -40,7 +55,7 @@ const useIpAccount = () => { "execute", client.ipAccount.execute.bind(client.ipAccount), setLoadings, - setErrors + setErrors, ); /** Executes a transaction from the IP Account. @@ -62,21 +77,32 @@ const useIpAccount = () => { "executeWithSig", client.ipAccount.executeWithSig.bind(client.ipAccount), setLoadings, - setErrors + setErrors, ); /** Returns the IPAccount's internal nonce for transaction ordering. * @param ipId The IP ID - * @returns The nonce for transaction ordering. + * @returns A Promise that resolves to the IP Account's nonce. */ const getIpAccountNonce = withLoadingErrorHandling< - string, + Address, IpAccountStateResponse >( "getIpAccountNonce", client.ipAccount.getIpAccountNonce.bind(client.ipAccount), setLoadings, - setErrors + setErrors, + ); + + /** + * Returns the identifier of the non-fungible token which owns the account + * @returns A Promise that resolves to an object containing the chain ID, token contract address, and token ID. + */ + const getToken = withLoadingErrorHandling( + "getToken", + client.ipAccount.getToken.bind(client.ipAccount), + setLoadings, + setErrors, ); return { @@ -85,6 +111,7 @@ const useIpAccount = () => { execute, executeWithSig, getIpAccountNonce, + getToken, }; }; export default useIpAccount; diff --git a/packages/react-sdk/src/resources/useIpAsset.ts b/packages/react-sdk/src/resources/useIpAsset.ts index 6e215f5d..dfd33ce5 100644 --- a/packages/react-sdk/src/resources/useIpAsset.ts +++ b/packages/react-sdk/src/resources/useIpAsset.ts @@ -43,6 +43,20 @@ const useIpAsset = () => { mintAndRegisterIpAndMakeDerivative: null, }); + if (!client) { + return { + loadings, + errors, + register: undefined, + registerDerivative: undefined, + registerDerivativeWithLicenseTokens: undefined, + mintAndRegisterIpAssetWithPilTerms: undefined, + registerIpAndAttachPilTerms: undefined, + registerDerivativeIp: undefined, + mintAndRegisterIpAndMakeDerivative: undefined, + }; + } + /** * Create a new `IpCreator` object with the specified details. * @param params - The parameters required to create the `IpCreator` object. @@ -58,7 +72,7 @@ const useIpAsset = () => { * @returns An `IpCreator` object containing the provided details. */ const generateCreatorMetadata = ( - param: GenerateCreatorMetadataParam + param: GenerateCreatorMetadataParam, ): IpCreator => { return client.ipAsset.generateCreatorMetadata(param); }; @@ -128,7 +142,7 @@ const useIpAsset = () => { "register", client.ipAsset.register.bind(client.ipAsset), setLoadings, - setErrors + setErrors, ); /** @@ -151,7 +165,7 @@ const useIpAsset = () => { "registerDerivative", client.ipAsset.registerDerivative.bind(client.ipAsset), setLoadings, - setErrors + setErrors, ); /** @@ -172,7 +186,7 @@ const useIpAsset = () => { "registerDerivativeWithLicenseTokens", client.ipAsset.registerDerivativeWithLicenseTokens.bind(client.ipAsset), setLoadings, - setErrors + setErrors, ); /** @@ -201,7 +215,7 @@ const useIpAsset = () => { "mintAndRegisterIpAssetWithPilTerms", client.ipAsset.mintAndRegisterIpAssetWithPilTerms.bind(client.ipAsset), setLoadings, - setErrors + setErrors, ); /** @@ -230,7 +244,7 @@ const useIpAsset = () => { "registerIpAndAttachPilTerms", client.ipAsset.registerIpAndAttachPilTerms.bind(client.ipAsset), setLoadings, - setErrors + setErrors, ); /** @@ -259,7 +273,7 @@ const useIpAsset = () => { "registerDerivativeIp", client.ipAsset.registerDerivativeIp.bind(client.ipAsset), setLoadings, - setErrors + setErrors, ); /** @@ -287,7 +301,7 @@ const useIpAsset = () => { "mintAndRegisterIpAndMakeDerivative", client.ipAsset.mintAndRegisterIpAndMakeDerivative.bind(client.ipAsset), setLoadings, - setErrors + setErrors, ); return { diff --git a/packages/react-sdk/src/resources/useLicense.ts b/packages/react-sdk/src/resources/useLicense.ts index 8fa06201..6586bcd0 100644 --- a/packages/react-sdk/src/resources/useLicense.ts +++ b/packages/react-sdk/src/resources/useLicense.ts @@ -1,6 +1,7 @@ import { - RegisterNonComSocialRemixingPILRequest, + RegisterPILTermsRequest, RegisterPILResponse, + RegisterNonComSocialRemixingPILRequest, RegisterCommercialUsePILRequest, RegisterCommercialRemixPILRequest, AttachLicenseTermsRequest, @@ -18,6 +19,7 @@ import { withLoadingErrorHandling } from "../withLoadingErrorHandling"; const useLicense = () => { const client = useStoryContext(); const [loadings, setLoadings] = useState>({ + registerPILTerms: false, registerNonComSocialRemixingPIL: false, registerCommercialUsePIL: false, registerCommercialRemixPIL: false, @@ -26,6 +28,7 @@ const useLicense = () => { getLicenseTerms: false, }); const [errors, setErrors] = useState>({ + registerPILTerms: null, registerNonComSocialRemixingPIL: null, registerCommercialUsePIL: null, registerCommercialRemixPIL: null, @@ -34,6 +37,54 @@ const useLicense = () => { getLicenseTerms: null, }); + if (!client) { + return { + loadings, + errors, + registerPILTerms: undefined, + registerNonComSocialRemixingPIL: undefined, + registerCommercialUsePIL: undefined, + registerCommercialRemixPIL: undefined, + attachLicenseTerms: undefined, + mintLicenseTokens: undefined, + getLicenseTerms: undefined, + }; + } + + /** + * Registers new license terms and return the ID of the newly registered license terms. + * @param request - The request object that contains all data needed to register a license term. + * @param request.transferable Indicates whether the license is transferable or not. + * @param request.royaltyPolicy The address of the royalty policy contract which required to StoryProtocol in advance. + * @param request.mintingFee The fee to be paid when minting a license. + * @param request.expiration The expiration period of the license. + * @param request.commercialUse Indicates whether the work can be used commercially or not. + * @param request.commercialAttribution Whether attribution is required when reproducing the work commercially or not. + * @param request.commercializerChecker Commercializers that are allowed to commercially exploit the work. If zero address, then no restrictions is enforced. + * @param request.commercializerCheckerData The data to be passed to the commercializer checker contract. + * @param request.commercialRevShare Percentage of revenue that must be shared with the licensor. + * @param request.commercialRevCeiling The maximum revenue that can be generated from the commercial use of the work. + * @param request.derivativesAllowed Indicates whether the licensee can create derivatives of his work or not. + * @param request.derivativesAttribution Indicates whether attribution is required for derivatives of the work or not. + * @param request.derivativesApproval Indicates whether the licensor must approve derivatives of the work before they can be linked to the licensor IP ID or not. + * @param request.derivativesReciprocal Indicates whether the licensee must license derivatives of the work under the same terms or not. + * @param request.derivativeRevCeiling The maximum revenue that can be generated from the derivative use of the work. + * @param request.currency The ERC20 token to be used to pay the minting fee. the token must be registered in story protocol. + * @param request.uri The URI of the license terms, which can be used to fetch the offchain license terms. + * @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property. + * @returns A Promise that resolves to an object containing the optional transaction hash, optional transaction encodedTxData and optional license terms Id. + * @emits LicenseTermsRegistered (licenseTermsId, licenseTemplate, licenseTerms); + */ + const registerPILTerms = withLoadingErrorHandling< + RegisterPILTermsRequest, + RegisterPILResponse + >( + "registerPILTerms", + client.license.registerPILTerms.bind(client.license), + setLoadings, + setErrors, + ); + /** * Convenient function to register a PIL non commercial social remix license to the registry * @param request - [Optional] The request object that contains all data needed to register a PIL non commercial social remix license. @@ -48,13 +99,13 @@ const useLicense = () => { "registerNonComSocialRemixingPIL", client.license.registerNonComSocialRemixingPIL.bind(client.license), setLoadings, - setErrors + setErrors, ); /** * Convenient function to register a PIL commercial use license to the registry. * @param request - The request object that contains all data needed to register a PIL commercial use license. - * @param request.mintingFee The fee to be paid when minting a license. + * @param request.defaultMintingFee The fee to be paid when minting a license. * @param request.currency The ERC20 token to be used to pay the minting fee and the token must be registered in story protocol. * @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property. * @returns A Promise that resolves to an object containing the optional transaction hash and optional license terms Id. @@ -67,13 +118,13 @@ const useLicense = () => { "registerCommercialUsePIL", client.license.registerCommercialUsePIL.bind(client.license), setLoadings, - setErrors + setErrors, ); /** * Convenient function to register a PIL commercial Remix license to the registry. * @param request - The request object that contains all data needed to register license. - * @param request.mintingFee The fee to be paid when minting a license. + * @param request.defaultMintingFee The fee to be paid when minting a license. * @param request.commercialRevShare Percentage of revenue that must be shared with the licensor. * @param request.currency The ERC20 token to be used to pay the minting fee. the token must be registered in story protocol. * @param request.txOptions - [Optional] transaction. This extends `WaitForTransactionReceiptParameters` from the Viem library, excluding the `hash` property. @@ -87,7 +138,7 @@ const useLicense = () => { "registerCommercialRemixPIL", client.license.registerCommercialRemixPIL.bind(client.license), setLoadings, - setErrors + setErrors, ); /** @@ -106,7 +157,7 @@ const useLicense = () => { "attachLicenseTerms", client.license.attachLicenseTerms.bind(client.license), setLoadings, - setErrors + setErrors, ); /** @@ -138,7 +189,7 @@ const useLicense = () => { "mintLicenseTokens", client.license.mintLicenseTokens.bind(client.license), setLoadings, - setErrors + setErrors, ); /** @@ -153,12 +204,13 @@ const useLicense = () => { "getLicenseTerms", client.license.getLicenseTerms.bind(client.license), setLoadings, - setErrors + setErrors, ); return { loadings, errors, + registerPILTerms, registerNonComSocialRemixingPIL, registerCommercialUsePIL, registerCommercialRemixPIL, diff --git a/packages/react-sdk/src/resources/useNftClient.ts b/packages/react-sdk/src/resources/useNftClient.ts index 67cd4d85..bbe2113d 100644 --- a/packages/react-sdk/src/resources/useNftClient.ts +++ b/packages/react-sdk/src/resources/useNftClient.ts @@ -16,6 +16,14 @@ const useNftClient = () => { createNFTCollection: null, }); + if (!client) { + return { + loadings, + errors, + createNFTCollection: undefined, + }; + } + /** * Creates a new SPG NFT Collection. * @param request - The request object containing necessary data to create a SPG NFT Collection. @@ -36,7 +44,7 @@ const useNftClient = () => { "createNFTCollection", client.nftClient.createNFTCollection.bind(client.nftClient), setLoadings, - setErrors + setErrors, ); return { diff --git a/packages/react-sdk/src/resources/usePermission.ts b/packages/react-sdk/src/resources/usePermission.ts index 051e196f..0d2178e5 100644 --- a/packages/react-sdk/src/resources/usePermission.ts +++ b/packages/react-sdk/src/resources/usePermission.ts @@ -28,6 +28,18 @@ const usePermission = () => { createBatchPermissionSignature: null, }); + if (!client) { + return { + loadings, + errors, + setPermission: undefined, + createSetPermissionSignature: undefined, + setAllPermissions: undefined, + setBatchPermissions: undefined, + createBatchPermissionSignature: undefined, + }; + } + /** * Sets the permission for a specific function call * Each policy is represented as a mapping from an IP account address to a signer address to a recipient @@ -55,7 +67,7 @@ const usePermission = () => { "setPermission", client.permission.setPermission.bind(client.permission), setLoadings, - setErrors + setErrors, ); /** @@ -78,7 +90,7 @@ const usePermission = () => { "createSetPermissionSignature", client.permission.createSetPermissionSignature.bind(client.permission), setLoadings, - setErrors + setErrors, ); /** @@ -98,7 +110,7 @@ const usePermission = () => { "setAllPermissions", client.permission.setAllPermissions.bind(client.permission), setLoadings, - setErrors + setErrors, ); /** @@ -122,7 +134,7 @@ const usePermission = () => { "setBatchPermissions", client.permission.setBatchPermissions.bind(client.permission), setLoadings, - setErrors + setErrors, ); /** @@ -146,7 +158,7 @@ const usePermission = () => { "createBatchPermissionSignature", client.permission.createBatchPermissionSignature.bind(client.permission), setLoadings, - setErrors + setErrors, ); return { diff --git a/packages/react-sdk/src/resources/useRoyalty.ts b/packages/react-sdk/src/resources/useRoyalty.ts index 5f2807d2..b60e28e9 100644 --- a/packages/react-sdk/src/resources/useRoyalty.ts +++ b/packages/react-sdk/src/resources/useRoyalty.ts @@ -35,6 +35,19 @@ const useRoyalty = () => { getRoyaltyVaultAddress: null, }); + if (!client) { + return { + loadings, + errors, + collectRoyaltyTokens: undefined, + payRoyaltyOnBehalf: undefined, + claimableRevenue: undefined, + claimRevenue: undefined, + snapshot: undefined, + getRoyaltyVaultAddress: undefined, + }; + } + /** * Allows ancestors to claim the royalty tokens and any accrued revenue tokens * @param request - The request object that contains all data needed to collect royalty tokens. @@ -51,7 +64,7 @@ const useRoyalty = () => { "collectRoyaltyTokens", client.royalty.collectRoyaltyTokens.bind(client.royalty), setLoadings, - setErrors + setErrors, ); /** @@ -71,7 +84,7 @@ const useRoyalty = () => { "payRoyaltyOnBehalf", client.royalty.payRoyaltyOnBehalf.bind(client.royalty), setLoadings, - setErrors + setErrors, ); /** @@ -90,7 +103,7 @@ const useRoyalty = () => { "claimableRevenue", client.royalty.claimableRevenue.bind(client.royalty), setLoadings, - setErrors + setErrors, ); /** @@ -111,7 +124,7 @@ const useRoyalty = () => { "claimRevenue", client.royalty.claimRevenue.bind(client.royalty), setLoadings, - setErrors + setErrors, ); /** @@ -126,7 +139,7 @@ const useRoyalty = () => { "snapshot", client.royalty.snapshot.bind(client.royalty), setLoadings, - setErrors + setErrors, ); /** @@ -138,7 +151,7 @@ const useRoyalty = () => { "getRoyaltyVaultAddress", client.royalty.getRoyaltyVaultAddress.bind(client.royalty), setLoadings, - setErrors + setErrors, ); return { diff --git a/packages/react-sdk/src/withLoadingErrorHandling.ts b/packages/react-sdk/src/withLoadingErrorHandling.ts index 7c52d39a..36aeea2a 100644 --- a/packages/react-sdk/src/withLoadingErrorHandling.ts +++ b/packages/react-sdk/src/withLoadingErrorHandling.ts @@ -12,7 +12,7 @@ export const withLoadingErrorHandling = actionName: string, method: AsyncFunction, setLoadings: SetLoadings, - setErrors: SetErrors + setErrors: SetErrors, ) => async (request: T): Promise => { try { diff --git a/packages/react-sdk/test/integration/useDispute.test.ts b/packages/react-sdk/test/integration/useDispute.test.ts index 69e18746..8a58655b 100644 --- a/packages/react-sdk/test/integration/useDispute.test.ts +++ b/packages/react-sdk/test/integration/useDispute.test.ts @@ -51,7 +51,7 @@ describe("useDispute Functions", () => { expect.objectContaining({ txHash: expect.any(String), disputeId: expect.any(BigInt), - }) + }), ); }); }); @@ -59,11 +59,11 @@ describe("useDispute Functions", () => { it("should success when cancel dispute", async () => { await act(async () => { await expect( - disputeHook.cancelDispute({ disputeId: disputedId }) + disputeHook.cancelDispute({ disputeId: disputedId }), ).resolves.toEqual( expect.objectContaining({ txHash: expect.any(String), - }) + }), ); }); }); diff --git a/packages/react-sdk/test/integration/useIpAccount.test.ts b/packages/react-sdk/test/integration/useIpAccount.test.ts index 09d001a3..7774c50c 100644 --- a/packages/react-sdk/test/integration/useIpAccount.test.ts +++ b/packages/react-sdk/test/integration/useIpAccount.test.ts @@ -92,11 +92,11 @@ describe("useIpAccount Functions", () => { value: 0, data, ipId: ipId, - }) + }), ).resolves.toEqual( expect.objectContaining({ txHash: expect.any(String), - }) + }), ); }); }); diff --git a/packages/react-sdk/test/integration/useIpAsset.test.ts b/packages/react-sdk/test/integration/useIpAsset.test.ts index 0e26d1cd..13b27284 100644 --- a/packages/react-sdk/test/integration/useIpAsset.test.ts +++ b/packages/react-sdk/test/integration/useIpAsset.test.ts @@ -52,7 +52,7 @@ describe("useIpAsset Functions", () => { expect.objectContaining({ ipId: expect.any(String), txHash: expect.any(String), - }) + }), ); }); }); @@ -72,12 +72,12 @@ describe("useIpAsset Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ ipId: expect.any(String), txHash: expect.any(String), - }) + }), ); }); }); @@ -122,11 +122,11 @@ describe("useIpAsset Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ txHash: expect.any(String), - }) + }), ); }); }); @@ -165,11 +165,11 @@ describe("useIpAsset Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ txHash: expect.any(String), - }) + }), ); }); }); @@ -205,12 +205,12 @@ describe("useIpAsset Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ ipId: expect.any(String), txHash: expect.any(String), - }) + }), ); }); }); @@ -232,12 +232,12 @@ describe("useIpAsset Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ ipId: expect.any(String), txHash: expect.any(String), - }) + }), ); }); }); @@ -259,12 +259,12 @@ describe("useIpAsset Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ ipId: expect.any(String), txHash: expect.any(String), - }) + }), ); }); }); @@ -298,12 +298,12 @@ describe("useIpAsset Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ txHash: expect.any(String), ipId: expect.any(String), - }) + }), ); }); }); @@ -323,12 +323,12 @@ describe("useIpAsset Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ ipId: expect.any(String), txHash: expect.any(String), - }) + }), ); }); }); diff --git a/packages/react-sdk/test/integration/useLicense.test.ts b/packages/react-sdk/test/integration/useLicense.test.ts index 4e165561..f0a614ea 100644 --- a/packages/react-sdk/test/integration/useLicense.test.ts +++ b/packages/react-sdk/test/integration/useLicense.test.ts @@ -21,11 +21,11 @@ describe("useLicense Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ licenseTermsId: expect.any(BigInt), - }) + }), ); }); }); @@ -34,16 +34,16 @@ describe("useLicense Functions", () => { await act(async () => { await expect( licenseHook.registerCommercialUsePIL({ - mintingFee: "1", + defaultMintingFee: "1", currency: mockERC20Address, txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ licenseTermsId: expect.any(BigInt), - }) + }), ); }); }); @@ -52,17 +52,17 @@ describe("useLicense Functions", () => { await act(async () => { await expect( licenseHook.registerCommercialRemixPIL({ - mintingFee: "1", + defaultMintingFee: "1", commercialRevShare: 100, currency: mockERC20Address, txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ licenseTermsId: expect.any(BigInt), - }) + }), ); }); }); @@ -105,12 +105,12 @@ describe("useLicense Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ txHash: expect.any(String), success: expect.any(Boolean), - }) + }), ); }); }); @@ -124,12 +124,12 @@ describe("useLicense Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ txHash: expect.any(String), licenseTokenIds: expect.any(Array), - }) + }), ); }); }); @@ -137,7 +137,7 @@ describe("useLicense Functions", () => { it("should success when get license terms", async () => { await act(async () => { await expect(licenseHook.getLicenseTerms(licenseId)).resolves.toEqual( - expect.any(Object) + expect.any(Object), ); }); }); diff --git a/packages/react-sdk/test/integration/useNftClient.test.ts b/packages/react-sdk/test/integration/useNftClient.test.ts index c681adcb..e86adc0a 100644 --- a/packages/react-sdk/test/integration/useNftClient.test.ts +++ b/packages/react-sdk/test/integration/useNftClient.test.ts @@ -19,11 +19,11 @@ describe("useNftClient Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ nftContract: expect.any(String), - }) + }), ); }); }); diff --git a/packages/react-sdk/test/integration/usePermission.test.ts b/packages/react-sdk/test/integration/usePermission.test.ts index 30706632..4a79e6c5 100644 --- a/packages/react-sdk/test/integration/usePermission.test.ts +++ b/packages/react-sdk/test/integration/usePermission.test.ts @@ -39,12 +39,12 @@ describe("usePermission Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ txHash: expect.any(String), success: true, - }) + }), ); }); }); @@ -59,12 +59,12 @@ describe("usePermission Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ txHash: expect.any(String), success: true, - }) + }), ); }); }); @@ -81,12 +81,12 @@ describe("usePermission Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ txHash: expect.any(String), success: true, - }) + }), ); }); }); @@ -114,12 +114,12 @@ describe("usePermission Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ txHash: expect.any(String), success: true, - }) + }), ); }); }); @@ -149,12 +149,12 @@ describe("usePermission Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ txHash: expect.any(String), success: true, - }) + }), ); }); }); diff --git a/packages/react-sdk/test/integration/useRoyalty.test.ts b/packages/react-sdk/test/integration/useRoyalty.test.ts index f7831f58..37a85758 100644 --- a/packages/react-sdk/test/integration/useRoyalty.test.ts +++ b/packages/react-sdk/test/integration/useRoyalty.test.ts @@ -39,7 +39,7 @@ describe("useRoyalty Functions", () => { return await act(async () => { return ( await licenseHook.registerCommercialUsePIL({ - mintingFee: "1", + defaultMintingFee: "1", currency: mockERC20Address, txOptions: { waitForTransaction: true, @@ -86,12 +86,12 @@ describe("useRoyalty Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ txHash: expect.any(String), royaltyTokensCollected: expect.any(BigInt), - }) + }), ); }); }); @@ -107,11 +107,11 @@ describe("useRoyalty Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ txHash: expect.any(String), - }) + }), ); }); }); @@ -124,12 +124,12 @@ describe("useRoyalty Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ txHash: expect.any(String), snapshotId: expect.any(BigInt), - }) + }), ); }); }); @@ -141,7 +141,7 @@ describe("useRoyalty Functions", () => { account: ipId1, snapshotId: "1", token: mockERC20Address, - }) + }), ).resolves.toEqual(expect.any(BigInt)); }); }); @@ -157,12 +157,12 @@ describe("useRoyalty Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ txHash: expect.any(String), claimableToken: expect.any(BigInt), - }) + }), ); }); }); @@ -247,12 +247,12 @@ describe("useRoyalty Functions", () => { txOptions: { waitForTransaction: true, }, - }) + }), ).resolves.toEqual( expect.objectContaining({ txHash: expect.any(String), claimableToken: expect.any(BigInt), - }) + }), ); }); }); diff --git a/packages/react-sdk/test/integration/utils/util.ts b/packages/react-sdk/test/integration/utils/util.ts index eeb80166..51c72975 100644 --- a/packages/react-sdk/test/integration/utils/util.ts +++ b/packages/react-sdk/test/integration/utils/util.ts @@ -47,7 +47,7 @@ export const walletClient = createWalletClient({ }); export const getTokenId = async ( - nftContract?: Address + nftContract?: Address, ): Promise => { const { request } = await publicClient.simulateContract({ abi: [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c7d8e8c8..2b5ab821 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -140,8 +140,8 @@ importers: packages/react-sdk: dependencies: '@story-protocol/core-sdk': - specifier: 1.0.0-rc.22 - version: 1.0.0-rc.22(typescript@5.4.5) + specifier: 1.1.0-stable + version: 1.1.0-stable(typescript@5.4.5) react: specifier: ^18.3.1 version: 18.3.1 @@ -3942,8 +3942,8 @@ packages: '@stablelib/wipe': 1.0.1 dev: true - /@story-protocol/core-sdk@1.0.0-rc.22(typescript@5.4.5): - resolution: {integrity: sha512-l+i7lzUGTdpBNfoMeFSRztFPuP9uTzAEA9PZ0wDviWg5pA22D+QmnbkF1HrBd5Mctxtv5tivdFSLARizBEjWEA==} + /@story-protocol/core-sdk@1.1.0-stable(typescript@5.4.5): + resolution: {integrity: sha512-gS7nk7UsRcOazd9rKUyKANF97GowGCt4OauEDPtb/az1szjsavfEbC8+wR7D+bO7lde9e1/yoIeWcoN0Fj4vQw==} dependencies: abitype: 0.10.3(typescript@5.4.5) axios: 1.6.8