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

Feat publish source #914

Merged
merged 38 commits into from
Jan 8, 2021
Merged

Feat publish source #914

merged 38 commits into from
Jan 8, 2021

Conversation

matnad
Copy link
Collaborator

@matnad matnad commented Dec 28, 2020

What I did

Added a method to publish source to etherscan for solidity contracts.
DeployedContract.publish_source()

Related issue: #411

How I did it

Flatten source code into one file (thanks Ben for starting on this). Make sure to include all comments, proper licensing and exactly one pragma statement.
Will wait for contract to be recognized by etherscan after deploying, then submit request for verification and finally wait for the verification to be processed and report the result.

How to verify it

deployed = MyContract.deploy({'from': account}, publish_source=True)
and also
MyContract.get_verification_info()
image
-> https://ropsten.etherscan.io/address/0x6De9c6197bB8f61177C30946d90CAC2720272c5c#code

Tests are adapted for the changes to the solc versioning, but no new tests for this feature are written yet.

Checklist

  • I have confirmed that my PR passes all linting checks
  • I have included test cases
  • I have updated the documentation
  • I have added an entry to the changelog

@matnad
Copy link
Collaborator Author

matnad commented Dec 28, 2020

@Macarse @banteg feel free to test the branch and provide feedback!

Edit: Contracts need to be re-compiled to add additional information about the compiler version. Delete the build and/or deployment artifacts if you try it on existing contracts.

Copy link
Member

@iamdefinitelyahuman iamdefinitelyahuman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

brownie/network/contract.py Outdated Show resolved Hide resolved
brownie/network/contract.py Outdated Show resolved Hide resolved
brownie/network/contract.py Outdated Show resolved Hide resolved
@matnad
Copy link
Collaborator Author

matnad commented Dec 30, 2020

Update:

  • Applied requested changes
  • Handle pragma experimental ABIEncoderV2
  • Auto-fetch correct constructor arguments
  • Temporary fix for interfaces being saved into build/contracts/ (will discuss with @iamdefinitelyahuman for a better solution)

TODO:

  • Ensure correct order of files in the flattened file (base before derived is a hard requirement)
  • Isolate global structs and enums
  • Fix interface/contract issue
  • Callable while deploying via kwarg

Macarse
Macarse previously approved these changes Jan 5, 2021
@Macarse
Copy link
Contributor

Macarse commented Jan 5, 2021

@iamdefinitelyahuman I have tested the last version: 763a5c8
and I could verify a couple of contracts I couldn't verify in the past. I believe this is a good first version for contract verification 🚀

Great work @matnad h/t

- to prevent failing tests when compound changes their implementation
- also wrote a test for fetching proxy form etherscan, but it is too slow (commented out)
@matnad
Copy link
Collaborator Author

matnad commented Jan 6, 2021

This turned out to be a monster of a feature! A lot of edge cases have been handled and I currently can't find a repo that doesn't verify (including all brownie mixes). Happy to merge after a review.

For repos that don't work please open an issue and I will look at it.

Macarse
Macarse previously approved these changes Jan 6, 2021
brownie/network/contract.py Outdated Show resolved Hide resolved
docs/api-network.rst Show resolved Hide resolved
tests/project/compiler/test_solidity.py Outdated Show resolved Hide resolved
Copy link
Member

@iamdefinitelyahuman iamdefinitelyahuman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming along nicely..

docs/api-network.rst Show resolved Hide resolved
brownie/network/contract.py Outdated Show resolved Hide resolved
brownie/network/contract.py Outdated Show resolved Hide resolved
brownie/network/contract.py Outdated Show resolved Hide resolved
brownie/network/contract.py Outdated Show resolved Hide resolved
tests/project/compiler/test_solidity.py Outdated Show resolved Hide resolved
@matnad
Copy link
Collaborator Author

matnad commented Jan 8, 2021

Big update.

  • Complete refactor of get_verification_info() to use py-solc-ast. No more regex (except one that is safe). This is much cleaner now!
  • Moved the methods to ContractContainer and adjusted docs.
  • Added a simple test to check if verification info breaks.
  • Tested functionality with various repos (brownie mixes, private repos, testing repos).

Copy link
Member

@iamdefinitelyahuman iamdefinitelyahuman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing stuff.. this clearly has been a huge amount of work. The community loves you ❤️

brownie/network/contract.py Outdated Show resolved Hide resolved
- more efficient writing
- slight change to regex
@misterblonde
Copy link

I still have the issue, even when I'm using publish_source=True and your new get_verification_info() afterwards. I only have one solidity script with one compiler version, so that shouldn't be the issue. Has this been continued elsewhere/

@turkishfilms
Copy link

im getting a jsondecodererror when i use publish_source=True. I was able to manually verify(copy and paste) but wasnt able to automatically verify. only one .sol file

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

Successfully merging this pull request may close these issues.

5 participants