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

Account.declareAndDeploy returns uninformative error on invalid constructor calldata #830

Open
FabijanC opened this issue Nov 13, 2023 · 2 comments
Assignees
Labels
Type: bug Something isn't working

Comments

@FabijanC
Copy link

FabijanC commented Nov 13, 2023

Describe the bug
I was experimenting with some contracts that require constructor arguments and some which don't. So I was trying to declare and deploy one which does, but forgot to provide them. I ended up getting this error:

TypeError: Cannot convert undefined to a BigInt
    at BigInt (<anonymous>)
    at toBigInt (/home/fabijanc/shardlabs/starknet-js-example/node_modules/starknet/src/utils/num.ts:15:10)
    at /home/fabijanc/shardlabs/starknet-js-example/node_modules/starknet/src/utils/transaction.ts:18:11
    at Array.forEach (<anonymous>)
    at transformCallsToMulticallArrays (/home/fabijanc/shardlabs/starknet-js-example/node_modules/starknet/src/utils/transaction.ts:15:9)
    at fromCallsToExecuteCalldata (/home/fabijanc/shardlabs/starknet-js-example/node_modules/starknet/src/utils/transaction.ts:38:35)
    at getExecuteCalldata (/home/fabijanc/shardlabs/starknet-js-example/node_modules/starknet/src/utils/transaction.ts:89:10)
    at Account.buildInvocation (/home/fabijanc/shardlabs/starknet-js-example/node_modules/starknet/src/account/default.ts:249:22)
    at Account.estimateInvokeFee (/home/fabijanc/shardlabs/starknet-js-example/node_modules/starknet/src/account/default.ts:124:35)

To Reproduce

After spawning starknet-devnet-rs with prefunded accounts, I tried running this script (omitted imports and constant definitions):

  const provider = new Provider({ rpc: { nodeUrl: "http://localhost:5050" } });
  const account = new Account(provider, accountAddress, accountPrivateKey);
  console.log(`Loaded account with address ${account.address}`);

  const compiledContract = await json.parse(
    fs.readFileSync(sierraPath).toString("ascii")
  );
  const compiledSierraCasm = await json.parse(
    fs.readFileSync(casmPath).toString("ascii")
  );

  console.log("Loaded artifacts");

  const declareDeployResponse = await account.declareAndDeploy(
    {
      contract: compiledContract,
      casm: compiledSierraCasm,
      // here one would specify the constructorCalldata - I forgot to
    },
    { maxFee: BigInt(1e18) }
  );

Expected behavior

  • A more informative error

Screenshots
N/A

Desktop (please complete the following information):

  • Node version: 16.14.0
  • Starknet.js version: 5.19.5
  • Network: starknet-devnet-rs
@FabijanC FabijanC added the Type: bug Something isn't working label Nov 13, 2023
@ainnee
Copy link

ainnee commented Nov 15, 2023

now everything is going good

@ivpavici ivpavici added the OnlyDust Open for OnlyDust contributors label Feb 2, 2024
@ivpavici ivpavici removed the OnlyDust Open for OnlyDust contributors label Feb 2, 2024
@ivpavici
Copy link
Collaborator

ivpavici commented Feb 2, 2024

@tabaktoni can we check if this is still relevant, used version was 5.19.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants