web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

Web3js doesn't call the right overloaded contract function.

Open nikoulai opened this issue 3 years ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

It is related to issue #5207

If we have a contract with overloaded functions, web3-eth-contract always fall into a specific one.

example:


    function addr(bytes32 node, uint coinType) public view returns(bytes memory) { }

    function addr(bytes32 node) public view returns (address payable) { }

If I try to call the second one

 await resolver.methods.addr('node').call();

I get this error:

Web3ValidatorError: Web3 validator found 1 error[s]:
    value at "/1" must pass "uint256" validation

Expected Behavior

we should be able to call the right function

Steps to Reproduce

Try to follow the example above for PublicResolver contract.

Web3.js Version

4.x-alpha

Environment

  • Operating System:
  • Browser:
  • Node.js Version:
  • NPM Version:

Anything Else?

Should we be able to call a function by

await resolver.methods['setAddr(bytes32,address)'](node, accounts[1]);

?? Because Typescript complains about the number of arguments ( it expects 0, but, validation fails normally if 0 passed)

nikoulai avatar Sep 14 '22 11:09 nikoulai