Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mintAndRegisterIpAssetWithPilTerms crashes when encodedTxDataOnly is set due to ABI conflict #362

Open
alberto-crossmint opened this issue Dec 11, 2024 · 2 comments

Comments

@alberto-crossmint
Copy link

Describe the bug

mintAndRegisterIpAssetWithPilTerms crashes when we use it for calculating the calldata instead of for sending the transaction. Reason below 👇

To Reproduce

  1. Create wallet client
    const privateKey: Address = `(...)`;
    const account: Account = privateKeyToAccount(privateKey);

    const config: StoryConfig = {
        account: account,
        transport: http("https://rpc.odyssey.storyrpc.io/"),
        chainId: "odyssey",
    };
    const client = StoryClient.newClient(config);
  1. Define any license terms
  const licenseTerms = {
        transferable: true,
        royaltyPolicy: "0x28b4F70ffE5ba7A26aEF979226f77Eb57fb9Fdb6" as `0x${string}`,
        defaultMintingFee: BigInt(10),
        expiration: BigInt(0),
        commercialUse: true,
        commercialAttribution: true,
        commercializerChecker: zeroAddress,
        commercialRevShare: 0,
        commercialRevCeiling: BigInt(0),
        derivativesAllowed: true,
        derivativesAttribution: true,
        derivativesApproval: false,
        derivativesReciprocal: false,
        derivativeRevCeiling: BigInt(0),
        currency: "0xC0F6E387aC0B324Ec18EAcf22EE7271207dCE3d5" as `0x${string}`,
        uri: "",
        commercializerCheckerData: "0x" as `0x${string}`,
    };
  1. Invoke mintAndRegisterIpAssetWithPilTerms function with this license terms and encodedTxDataOnly to true. Example:
const obj = {
        spgNftContract: "0xa1c7FeC91A87AF09021360a5333CFFD64dBBE66A" as `0x${string}`,
        terms: [licenseTerms],
        ipMetadata: {
            ipMetadataURI: uploadedIpMetadata,
            ipMetadataHash: `0x${ipHash}` as `0x${string}`,
            nftMetadataURI: uploadedNftMetadata,
            nftMetadataHash: `0x${nftHash}` as `0x${string}`,
        },
        recipient: "0xAF3aC30f94dc04Be2915862BD014B789196B623e" as Address,
    };

const { encodedTxData } = await client.ipAsset.mintAndRegisterIpAssetWithPilTerms({
        ...obj,
        txOptions: { encodedTxDataOnly: true },
    });
  1. See the function fail. Reason is there are two mintAndRegisterIpAndAttachPILTerms functions defined on the licenseAttachmentWorkflowsAbi and viem doesn't know how to resolve the ambiguity between these two signatures with tuple and tuple[] terms arguments.

Expected behavior
This function to be usable

Screenshots
image

Environment (please complete the following information):

  • Node v20.12.2
  • Viem v2.17.5

Additional context
I may agree this is a bug in viem but this makes this function completely unusable. Is there a way that we can filter out the conflicting function signature from the abi in this mintAndRegisterIpAndAttachPilTerms2Encode function or maybe using this.rpcClient.simulateContract in the same way as we do in mintAndRegisterIpAndAttachPilTerms2?

@alberto-crossmint alberto-crossmint changed the title mintAndRegisterIpAssetWithPilTerms crashes when encodedTxDataOnly=true due to ABI conflict mintAndRegisterIpAssetWithPilTerms crashes when encodedTxDataOnly is set due to ABI conflict Dec 11, 2024
@bonnie57
Copy link
Collaborator

Hi @alberto-crossmint,

Thank you for identifying the issue. May I ask which version you're using? I tested it with @story-protocol/[email protected], and it worked well. I hope this helps resolve your question.

@alberto-crossmint
Copy link
Author

Thanks for taking a look @bonnie57 , confirming it's @story-protocol/[email protected]. Can you share the viem's version you're using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants