Skip to content

splitArgsAndOptions with single argument containing options #1252

@Skanislav

Description

@Skanislav

Describe the bug

export const splitArgsAndOptions = (args: ArgsOrCalldataWithOptions) => {
  const options = [
    'blockIdentifier',
    'parseRequest',
    'parseResponse',
    'formatResponse',
    'maxFee',
    'nonce',
    'signature',
    'addressSalt',
  ];
  const lastArg = args[args.length - 1];
  if (typeof lastArg === 'object' && options.some((x) => x in lastArg)) {
    return { args: args as ArgsOrCalldata, options: args.pop() as ContractOptions };
  }
  return { args: args as ArgsOrCalldata };
};

When it's called during buildCall, and the contract expects a single argument which is struct with a property that overlaps this list of hardcoded options. Resulting in this:

Error: Invalid number of arguments, expected 1 arguments, but got 0
    at _CallData.validate (index.ts:95:13)
    at default.ts:236:23
    at getCalldata (default.ts:115:10)
    at Contract.call (default.ts:234:22)
    at Contract.get_proposal_hash (default.ts:61:21)

To Reproduce

I exported ABIs using abi-wan-kanabi for this contracts and tried to call the get_proposal_hash. I spotted the error because the similar call worked for the function encode_proposal_data that accepts two arguments and works just fine.

Expected behavior

Desktop (please complete the following information):

  • Browser & version Chrome Version 124.0.6367.208
  • Node version v20.14.0
  • Starknet.js version 6.17.0
  • Network devnet

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions