From 71dc0aabde2056f12818d524b57152e14c76f67a Mon Sep 17 00:00:00 2001 From: jbargu Date: Tue, 16 Feb 2021 17:23:50 +0100 Subject: [PATCH 1/6] Allow publishing source on BscScan --- brownie/network/contract.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/brownie/network/contract.py b/brownie/network/contract.py index 174f6b1e7..f9f10fa83 100644 --- a/brownie/network/contract.py +++ b/brownie/network/contract.py @@ -376,9 +376,9 @@ def publish_source(self, contract: Any, silent: bool = False) -> bool: url = CONFIG.active_network.get("explorer") if url is None: raise ValueError("Explorer API not set for this network") - if "etherscan" not in url: + if not any(allowed_explorer in url for allowed_explorer in ["etherscan", "bscscan"]): raise ValueError( - "Publishing source is only supported on etherscan, change the Explorer API" + "Publishing source is only supported on etherscan/bscscan, change the Explorer API" ) if os.getenv("ETHERSCAN_TOKEN"): From b2a7c42939fdc627331fefc51063614729fbe8ec Mon Sep 17 00:00:00 2001 From: jbargu Date: Wed, 17 Feb 2021 08:56:32 +0100 Subject: [PATCH 2/6] Generalize output messages --- brownie/network/contract.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/brownie/network/contract.py b/brownie/network/contract.py index f9f10fa83..debc42eae 100644 --- a/brownie/network/contract.py +++ b/brownie/network/contract.py @@ -373,12 +373,13 @@ def publish_source(self, contract: Any, silent: bool = False) -> bool: """Flatten contract and publish source on the selected explorer""" # Check required conditions for verifying + allowed_explorers = ["etherscan", "bscscan"] url = CONFIG.active_network.get("explorer") if url is None: raise ValueError("Explorer API not set for this network") - if not any(allowed_explorer in url for allowed_explorer in ["etherscan", "bscscan"]): + if not any(allowed_explorer in url for allowed_explorer in allowed_explorers): raise ValueError( - "Publishing source is only supported on etherscan/bscscan, change the Explorer API" + f"Publishing source is only supported on {allowed_explorers}, change the Explorer API" ) if os.getenv("ETHERSCAN_TOKEN"): @@ -453,7 +454,7 @@ def publish_source(self, contract: Any, silent: bool = False) -> bool: if i >= 10: raise ValueError(f"API request failed with: {data['result']}") elif i == 0 and not silent: - print("Waiting for etherscan to process contract...") + print(f"Waiting for {url} to process contract...") i += 1 time.sleep(10) From 6f955920c69f5aec307f74135e38d6c5f12bbeb9 Mon Sep 17 00:00:00 2001 From: jbargu Date: Wed, 17 Feb 2021 13:30:17 +0100 Subject: [PATCH 3/6] Fix line too long error --- brownie/network/contract.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/brownie/network/contract.py b/brownie/network/contract.py index debc42eae..629266b48 100644 --- a/brownie/network/contract.py +++ b/brownie/network/contract.py @@ -379,7 +379,8 @@ def publish_source(self, contract: Any, silent: bool = False) -> bool: raise ValueError("Explorer API not set for this network") if not any(allowed_explorer in url for allowed_explorer in allowed_explorers): raise ValueError( - f"Publishing source is only supported on {allowed_explorers}, change the Explorer API" + f"Publishing source is only supported on {allowed_explorers}," + "change the Explorer API" ) if os.getenv("ETHERSCAN_TOKEN"): From 9e2d0181bbf4d9d72daf8ec80844c1372fd7923c Mon Sep 17 00:00:00 2001 From: jbargu Date: Wed, 17 Feb 2021 13:30:41 +0100 Subject: [PATCH 4/6] Add changelog entry for BscScan --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 715147891..51390ead4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/eth-brownie/brownie) ### Fixed - Bump dependency version for [eth-event](https://github.com/iamdefinitelyahuman/eth-event) to [1.2.1](https://github.com/iamdefinitelyahuman/eth-event/releases/tag/v1.2.1) to mitigate the topic generation bug for events with dynamic/fixed size tuple array inputs ([#957](https://github.com/eth-brownie/brownie/pull/957)) +### Added +- Automatic source code verification on BscScan ## [1.13.1](https://github.com/eth-brownie/brownie/tree/v1.13.1) - 2021-01-31 ### Fixed From 4285465efcfe111d9e260ec0321a78390ea80eb8 Mon Sep 17 00:00:00 2001 From: jbargu Date: Wed, 17 Feb 2021 13:31:08 +0100 Subject: [PATCH 5/6] Add doc entry for "Verifying Deployments on BscScan" --- docs/deploy.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/deploy.rst b/docs/deploy.rst index 634402369..0ec19cb0b 100644 --- a/docs/deploy.rst +++ b/docs/deploy.rst @@ -89,7 +89,7 @@ The following actions WILL remove locally stored deployment data within your pro To restore a deleted :func:`ProjectContract ` instance, or generate one for a deployment that was handled outside of Brownie, use the :func:`ContractContainer.at ` method. -Verifying Deployments on Etherscan +Verifying Deployments on Etherscan/BscScan ========================================== Brownie features automatic source code verification for solidity contracts on all networks supported by etherscan. To verify a contract while deploying it, add the ``publish_source=True`` argument: @@ -119,4 +119,4 @@ If you need deployment artifacts on a development network, set :attr:`dev_deploy These temporary deployment artifacts and the corresponding entries in :ref:`the deployment map` will be removed whenever you (re-) load a project or connect, disconnect, revert or reset your local network. If you use a development network that is not started by brownie - for example an external instance of ganache - the deployment artifacts will not be deleted when disconnecting from that network. -However, the network will be reset and the deployment artifacts deleted when you connect to such a network with brownie. \ No newline at end of file +However, the network will be reset and the deployment artifacts deleted when you connect to such a network with brownie. From 930f2aa46fead495022fe010b7c4480ff8344aa0 Mon Sep 17 00:00:00 2001 From: Jure Grabnar Date: Fri, 26 Feb 2021 18:37:49 +0100 Subject: [PATCH 6/6] Update docs/deploy.rst Co-authored-by: Ben Hauser <35276322+iamdefinitelyahuman@users.noreply.github.com> --- docs/deploy.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/deploy.rst b/docs/deploy.rst index 0ec19cb0b..014032cc5 100644 --- a/docs/deploy.rst +++ b/docs/deploy.rst @@ -89,7 +89,7 @@ The following actions WILL remove locally stored deployment data within your pro To restore a deleted :func:`ProjectContract ` instance, or generate one for a deployment that was handled outside of Brownie, use the :func:`ContractContainer.at ` method. -Verifying Deployments on Etherscan/BscScan +Verifying Deployment Source Code ========================================== Brownie features automatic source code verification for solidity contracts on all networks supported by etherscan. To verify a contract while deploying it, add the ``publish_source=True`` argument: