Skip to content

Improve error messages on mismatched argument types #964

Closed
@carver

Description

What was wrong?

When sending an argument with the wrong type to a contract function, people find it difficult to debug and end up frustrated, like in #625

How can it be fixed?

We largely solve for the general case: that multiple functions can exist with the same name. Obviously we have to support that, but it's incredibly common to have names that are unique even without the argument types. In these cases, we can give clearer error messages about exactly which types are expected for which arguments.

For example, we could raise the function:

ValidationError: a function with name testFunction is defined by the contract, but some argument types don't match:

  • address _location ✔️
  • uint256 _reading ✔️
  • uint256 _minParameter ✔️
  • uint256 _maxParameter ✔️
  • bytes32 _codeHash ⚠️ This argument was supplied as a string that was too long. If you want to supply a hex string, this function only accepts values that are exactly 64 characters (plus 2 for 0x). Alternatively, supply this argument as python native bytes, with a length of 32 bytes. Actually supplied argument: "0xFFFFF..." (length: 67)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions