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 create Contract from etherscan contracts verified via JSON input #494

Closed
iamdefinitelyahuman opened this issue May 5, 2020 · 1 comment · Fixed by #637
Closed
Labels
bug Something isn't working Good First Issue Good issue for new contributors priority Should be included in next release

Comments

@iamdefinitelyahuman
Copy link
Member

What was wrong?

Contract.from_explorer fails when the source code is verified using the standard JSON input.

As an example: 0xaf1610D242c7CdD30c546844aF75c147C12e94F9

>>> Contract.from_explorer("0xaf1610D242c7CdD30c546844aF75c147C12e94F9") 
  File "<console>", line 1, in <module>
  File "eth_brownie-1.8.2-py3.8.egg/brownie/network/contract.py", line 440, in __init__
    contract = self.from_explorer(address, owner=owner, silent=True)
  File "eth_brownie-1.8.2-py3.8.egg/brownie/network/contract.py", line 651, in from_explorer
    build = compile_and_format(
  File "eth_brownie-1.8.2-py3.8.egg/brownie/project/compiler/__init__.py", line 132, in compile_and_format
    output_json = compile_from_input_json(input_json, silent, allow_paths)
  File "eth_brownie-1.8.2-py3.8.egg/brownie/project/compiler/__init__.py", line 247, in compile_from_input_json
    return solidity.compile_from_input_json(input_json, silent, allow_paths)
  File "eth_brownie-1.8.2-py3.8.egg/brownie/project/compiler/solidity.py", line 72, in compile_from_input_json
    raise CompilerError(e)
CompilerError: Compiler returned the following errors:

Pool-flattened.sol:1:1: ParserError: Expected pragma, import directive or contract/interface/library definition.
{{

How can it be fixed?

In Contract.from_explorer, check the format of SourceCode returned from Etherscan and handle accordingly.

@iamdefinitelyahuman iamdefinitelyahuman added bug Something isn't working Good First Issue Good issue for new contributors labels May 5, 2020
@iamdefinitelyahuman iamdefinitelyahuman mentioned this issue Jun 17, 2020
4 tasks
@iamdefinitelyahuman iamdefinitelyahuman added the priority Should be included in next release label Jun 17, 2020
@iamdefinitelyahuman
Copy link
Member Author

This issue is now causing the test suite to fail - it should be handled ASAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Good First Issue Good issue for new contributors priority Should be included in next release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant