Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to OverloadedMethod #348

Closed
iamdefinitelyahuman opened this issue Feb 1, 2020 · 0 comments · Fixed by #507
Closed

Improvements to OverloadedMethod #348

iamdefinitelyahuman opened this issue Feb 1, 2020 · 0 comments · Fixed by #507
Labels
enhancement New feature or request

Comments

@iamdefinitelyahuman
Copy link
Member

Overview

  1. OverloadedMethod should infer which method is being called, based on the given inputs.
  2. It should be possible to iterate over the functions within OverloadedMethod.

Related: https://ethereum.stackexchange.com/questions/79505/what-is-a-good-alternative-to-contracttranslator-encode-abi

Specification

As an example, consider the ERC223 transfer function, which is possible as (address,uint256) and (address,uint256,bytes).

>>> erc223.transfer
<OverloadedMethod object 'ERC223Token.transfer'>

The following examples should all work:

>>> erc223.transfer(accounts[0], 1000)
>>> erc223.transfer(accounts[0], 1000, "0x1234")
>>> erc223.transfer.encode_abi(accounts[0], 1000, "0x1234")

An important consideration is that Brownie is fairly loose with types. There could be situations where it is not possible to determine the correct function from the given inputs. It could be possible to use stricter type checks, but if that's inconsistent with how everything else works - maybe better to just raise and demand explicitness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant