Currently if invalid amount of parameters is passed to the contract function (more than required) we get following error output:

  1) Some tests 
       Should not allow the owner to withdraw token with address of testContract.token():
     Error: cannot override "0" (operation="overrides", overrides=["0"], code=UNSUPPORTED_OPERATION, version=contracts/5.7.0)
      at Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:269:28)
      at Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:281:20)
      at **/node_modules/@ethersproject/contracts/src.ts/index.ts:304:16
      at step (node_modules/@ethersproject/contracts/lib/index.js:48:23)
      at Object.next (node_modules/@ethersproject/contracts/lib/index.js:29:53)
      at fulfilled (node_modules/@ethersproject/contracts/lib/index.js:20:58)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at runNextTicks (node:internal/process/task_queues:64:3)
      at listOnTimeout (node:internal/timers:533:9)
      at processTimers (node:internal/timers:507:7)

  2) Some tests
       Should allow the owner to withdraw tokens:
     Error: cannot override "0","1" (operation="overrides", overrides=["0","1"], code=UNSUPPORTED_OPERATION, version=contracts/5.7.0)
      at Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:269:28)
      at Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:281:20)
      at **/node_modules/@ethersproject/contracts/src.ts/index.ts:304:16
      at step (node_modules/@ethersproject/contracts/lib/index.js:48:23)
      at Object.next (node_modules/@ethersproject/contracts/lib/index.js:29:53)
      at fulfilled (node_modules/@ethersproject/contracts/lib/index.js:20:58)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at runNextTicks (node:internal/process/task_queues:64:3)
      at listOnTimeout (node:internal/timers:533:9)
      at processTimers (node:internal/timers:507:7)

Which is not informative on what the user did wrong. Will it be possible to improve the output with something like:

HH-XXXX: Invalid parameters passed to the function

or

HH-XXXX: overloaded function is not found

Thanks in advance 😃

0

Hey @Pafaul, thanks for opening this. That error comes from ethers, but tbh it's the first time I see that error message. Can you tell me how to reproduce it? I think the error messages for invalid arguments are a bit better than that.

0

Hello @fvictorio !

Made a repo for reproducing error: Repository for reproducing error

Steps to reproduce:

  1. Clone the repo
  2. Run yarn to install required packages
  3. Run yarn test ./test/test.js
  4. First test run must not fail
  5. Go to the contracts/TestContract.sol
  6. Comment the uncommented contract and uncomment the commented one so it looks like this:
// SPDX-License-Identifier: MIT

pragma solidity 0.8.17;

contract HumanReadableErrors {
    uint256 public id_;
    function testMe(uint256[] memory id) external {
        id_ = id[0];
    }
}

// contract HumanReadableErrors {
//     uint256 public id_;
//     function testMe(uint256[] memory id, address[] memory users) external {
//         id_ = id[0] + uint160(users[0]);
//     }
// }
  1. Run the test again using command: yarn test ./test/test.js
  2. Receive the error:
  1) Try to reproduce error
       Error:
     Error: cannot override "0" (operation="overrides", overrides=["0"], code=UNSUPPORTED_OPERATION, version=contracts/5.7.0)
      at Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:269:28)
      at Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:281:20)
      at **/error-report/node_modules/@ethersproject/contracts/src.ts/index.ts:304:16
      at step (node_modules/@ethersproject/contracts/lib/index.js:48:23)
      at Object.next (node_modules/@ethersproject/contracts/lib/index.js:29:53)
      at fulfilled (node_modules/@ethersproject/contracts/lib/index.js:20:58)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at runNextTicks (node:internal/process/task_queues:64:3)
      at listOnTimeout (node:internal/timers:533:9)
      at processTimers (node:internal/timers:507:7)
  1. After it you can re-launch tests without changing the smart-contract and receive the error repeatedly

System information:

  • WSL2 + Ubuntu 20.04
  • HH: 6.1.2
  • Uses TS config, but files are in JS
  • other config files can be found in the repo

If you will need any additional information - please let me know!

0

Hey @Pafaul, sorry for not responding before.

I understand now. If a function expects one argument (say, one number) and you pass two arguments:

await contract.f(1, 2)

then you get a proper error saying "too many arguments".

But if the extra argument is an array (like in your case):

await contract.f(1, [2])

then ethers think you are passing an overrides object and shows that confusing error.

Sadly there isn't much we can do on our side. You can open an issue in the ethers repo if you have the time.

0
© 2022 pullanswer.com - All rights reserved.