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

Cannot return ERC20 token address from contract #1376

Closed
Pet3ris opened this issue Apr 1, 2019 · 3 comments
Closed

Cannot return ERC20 token address from contract #1376

Pet3ris opened this issue Apr 1, 2019 · 3 comments
Labels
bug Bug that shouldn't change language semantics when fixed.

Comments

@Pet3ris
Copy link

Pet3ris commented Apr 1, 2019

Hi There,

I'm trying to compile the following contract running master:

Input contract

from vyper.interfaces import ERC20

token: ERC20

@public
@constant
def tokenAddress() -> address:
    return self.token

Output

vyper.exceptions.TypeMismatchException: line 8: Trying to return base type address(ERC20), output expecting address
    return self.token
-----------^

I can fix it temporarily by changing the address to an address(ERC20), this compiles to runtime bytecode, but doesn't compile when extracting the ABI:

Input contract 2 (-f abi)

from vyper.interfaces import ERC20

token: ERC20

@public
@constant
def tokenAddress() -> address(ERC20):
    return self.token

Output

vyper.exceptions.InvalidTypeException: line 7: Invalid base unit
def tokenAddress() -> address(ERC20):
------------------------------^
@jacqueswww
Copy link
Contributor

jacqueswww commented Apr 1, 2019

OK let me think of a few other uses cases, and I'll wrap those all in one PR (I think we are missing a few cases in the test suite).

@jacqueswww jacqueswww added the bug Bug that shouldn't change language semantics when fixed. label Apr 1, 2019
@Pet3ris
Copy link
Author

Pet3ris commented Apr 1, 2019

@jacqueswww - thanks a lot, may I selfishly suggest elements of the Uniswap contract for different ways of integrating ERC20 tokens as it has its own as well as external :).

@jacqueswww
Copy link
Contributor

Once I have assembled the PR, let's test it against uniswap before merging it ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug that shouldn't change language semantics when fixed.
Projects
None yet
Development

No branches or pull requests

2 participants