Skip to content
This repository was archived by the owner on May 24, 2022. It is now read-only.
This repository was archived by the owner on May 24, 2022. It is now read-only.

Overloaded functions are not all callable by name from the contract instance  #22

Open
@amaury1093

Description

@amaury1093

From parity-js/api#8

If I define a contract with an overloaded function, then try to call the function from the parity.js contract instance, I can only access one of the functions by name.

e.g.

contract C {
  function myFunc(address a) { return; }
  function myFunc(address a, uint b) { return; }
}
// after getting contract instances
theContract.instance.myFunc.call({}, ['0x0']); // errors due to missing property in array
theContract.instance.myFunc.call({}, ['0x0', 22]); // works fine

Workaround right now is to use the function signature bytes, (something like theContract.instance.be45fd62.call) which are different for each of the functions.

The code that causes this behaviour is here, where the value of the property corresponding to the function name is overwritten.

One possible fix would be to make contract.instance.myFunc dynamically determine which signature should be called based on the types of the arguments, and then call with the correct function signature based on that. The issue I see with this approach is that js is not typed the same way solidity is, so inferring the types may not be accurate.

Edit:

Seems like web3 handles it like this (setting key as func(argType1,argType2)), and this (choosing the function with the correct "shape" of parameters, if only one such function exists).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions