vyper icon indicating copy to clipboard operation
vyper copied to clipboard

bug: can't handle top-level "abi" key in .json interfaces

Open fubuloubu opened this issue 1 year ago • 9 comments

Version Information

  • vyper Version (output of vyper --version): 0.4.0
  • OS: linux
  • Python Version (output of python --version): 3.11.9

What's your issue about?

CompilerPanic:unhandled exception 'str' object has no attribute 'get'

  contract "contracts/StreamManager.vy:23", line 23:0 
       22
  ---> 23 from . import Validator
  --------^
       24

How can it be fixed?

fubuloubu avatar Sep 10 '24 01:09 fubuloubu

actually I think that Validator is a json file

fubuloubu avatar Sep 10 '24 01:09 fubuloubu

need a repro -- can you post the contents of Validator.json?

charles-cooper avatar Sep 10 '24 12:09 charles-cooper

https://github.com/ApeWorX/ApePay/blob/2b1326328c729b7a131b99321111f6d326754363/contracts/Validator.json

fubuloubu avatar Sep 10 '24 17:09 fubuloubu

compiling with -v shows the problem --

  File "/home/charles/vyper/vyper/semantics/types/module.py", line 212, in <listcomp>
    for item in [i for i in abi if i.get("type") == "function"]:
                                   ^^^^^
vyper.exceptions.CompilerPanic: unhandled exception 'str' object has no attribute 'get'

  contract "tmp/StreamManager.vy:1", line 1:0 
  ---> 1 from . import Validator
  -------^
       2

charles-cooper avatar Sep 10 '24 17:09 charles-cooper

compiling with -v shows the problem --

  File "/home/charles/vyper/vyper/semantics/types/module.py", line 212, in <listcomp>
    for item in [i for i in abi if i.get("type") == "function"]:
                                   ^^^^^
vyper.exceptions.CompilerPanic: unhandled exception 'str' object has no attribute 'get'

  contract "tmp/StreamManager.vy:1", line 1:0 
  ---> 1 from . import Validator
  -------^
       2

not sure I get it lol

fubuloubu avatar Sep 10 '24 17:09 fubuloubu

yea i mean it's not very well validated, but moving the contents of the "abi" key to top level (so the top level object is a list) fixes the compilation issue

charles-cooper avatar Sep 10 '24 17:09 charles-cooper

gotcha

to note for transparency though, this works in <0.4, so there is a bit of a regression not to support optional abi top-level key

fubuloubu avatar Sep 10 '24 17:09 fubuloubu

yea, not sure where this regression happened

charles-cooper avatar Sep 10 '24 17:09 charles-cooper

gotcha

to note for transparency though, this works in <0.4, so there is a bit of a regression not to support optional abi top-level key

seems like it's not a regression - https://github.com/vyperlang/vyper/pull/4279#issuecomment-2400633840

charles-cooper avatar Oct 10 '24 17:10 charles-cooper

fixed in https://github.com/vyperlang/vyper/pull/4279

charles-cooper avatar Jan 02 '25 18:01 charles-cooper