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

cmd/abigen: Vyper issue #20418

Closed
lmittmann opened this issue Dec 2, 2019 · 5 comments
Closed

cmd/abigen: Vyper issue #20418

lmittmann opened this issue Dec 2, 2019 · 5 comments
Assignees

Comments

@lmittmann
Copy link
Contributor

lmittmann commented Dec 2, 2019

I tried to generate ABI bindings for a vyper contract using abigen an ran into an issue:

$ abigen -v
abigen version 1.9.8-stable
$ vyper --version
0.1.0b14+commit.49b201c
$ abigen --pkg main --type Uniswap --out uniswap.go --vy uniswap_exchange.vy
Fatal: Failed to generate ABI binding: 36:23: expected ';', found '.' (and 10 more errors)
[...forward to line 36...]
	// UniswapExchange.vyABI is the input ABI used to generate the binding from.
	const UniswapExchange.vyABI = "[{...

It seems like abigen is trying to use the full file name for variable and struct names, including the .vy suffix which of course is not allowed in Go. When renaming the file and striping the .vy suffix abigen works fine.

@gballet
Copy link
Member

gballet commented Dec 3, 2019

Would you mind sharing your version of abigen and vyper? Typing the commands you provided doesn't work:

Ξ ./abigen --pkg main --type Uniswap --out uniswap.go --vy uniswap_exchange.vy
Contract ABI (--abi), bytecode (--bin) and type (--type) flags are mutually exclusive with the Solidity (--sol) and Vyper (--vy) flags

and

Ξ ./abigen --pkg main --out uniswap.go --vy uniswap_exchange.vy        
Failed to build Vyper contract: vyper: exit status 1
/home/gballet/.local/lib/python3.6/site-packages/vyper/types/types.py:459: DeprecationWarning: Mapping definitions using subscript have deprecated (see VIP564). Use map(type1, type2) instead.
  DeprecationWarning
/usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import fnmatch, glob, traceback, errno, sys, atexit, locale, imp
vyper.exceptions.InvalidTypeException: line 24:10 Unknown list type.
     23 totalSupply: public(uint256)                      # total number of UNI in existence
---> 24 balances: uint256[address]                        # UNI balance of an address
------------------^
     25 allowances: (uint256[address])[address]           # UNI allowance of one address on another

@gballet
Copy link
Member

gballet commented Dec 3, 2019

I was able to confirm and reproduce the issue with 1.9.8-unstable and vyper 0.1.0b14+commit.49b201c. Working on a fix.

@lmittmann
Copy link
Contributor Author

for the sake of completeness: I used the uniswap_exchange.vy from the PR Uniswap/v1-contracts/pull/44.

@lmittmann
Copy link
Contributor Author

abigen also tries to include the files path in the variable and type names.

If you run

abigen --pkg main --type Uniswap --out uniswap.go --vy path/uniswap_exchange.vy

aibgen attempts to create variables like e.g., Path/UniswapExchange.vyABI.

@gballet
Copy link
Member

gballet commented Dec 16, 2019

Fixed in #20419

@gballet gballet closed this as completed Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants