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 😃
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.
Hello @fvictorio !
Made a repo for reproducing error: Repository for reproducing error
Steps to reproduce:
yarn
to install required packagesyarn test ./test/test.js
contracts/TestContract.sol
// 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]);
// }
// }
yarn test ./test/test.js
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)
System information:
If you will need any additional information - please let me know!
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.