From cf365d9f88c16d4675dde886a517d81e53e67ffd Mon Sep 17 00:00:00 2001 From: Ayush Shukla Date: Sun, 4 Jul 2021 20:18:36 +0530 Subject: [PATCH 1/2] fix: correct polygon mainnet id --- brownie/data/network-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/brownie/data/network-config.yaml b/brownie/data/network-config.yaml index 468999529..10591abe8 100644 --- a/brownie/data/network-config.yaml +++ b/brownie/data/network-config.yaml @@ -64,9 +64,9 @@ live: explorer: https://api.ftmscan.com/api - name: Polygon networks: - - name: Mainnet + - name: Mainnet (Infura) chainid: 137 - id: polygon-main (Infura) + id: polygon-main host: https://polygon-mainnet.infura.io/v3/$WEB3_INFURA_PROJECT_ID explorer: https://api.polygonscan.com/api - name: Mumbai Testnet (Infura) From 296162268df51de4137aa8d8b7cfc1d451a7b44b Mon Sep 17 00:00:00 2001 From: Ayush Shukla Date: Sun, 4 Jul 2021 20:21:19 +0530 Subject: [PATCH 2/2] feat: add polygonscan block explorer --- CHANGELOG.md | 1 + brownie/network/contract.py | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9aa61f20..d353b130c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/eth-brownie/brownie) - Add polygon network integration ([#1119](https://github.com/eth-brownie/brownie/pull/1119)) - Fixed subcalls to empty accounts not appearing in the subcalls property of TransactionReceipts ([#1106](https://github.com/eth-brownie/brownie/pull/1106)) +- Add support for `POLYGONSCAN_TOKEN` env var ([#1135](https://github.com/eth-brownie/brownie/pull/1135)) ### Added - Added `LocalAccount.sign_message` method to sign `EIP712Message` objects ([#1097](https://github.com/eth-brownie/brownie/pull/1097)) diff --git a/brownie/network/contract.py b/brownie/network/contract.py index 81f5bba37..ba10ade4d 100644 --- a/brownie/network/contract.py +++ b/brownie/network/contract.py @@ -376,7 +376,11 @@ def publish_source(self, contract: Any, silent: bool = False) -> bool: """Flatten contract and publish source on the selected explorer""" # Check required conditions for verifying - explorer_tokens = {"etherscan": "ETHERSCAN_TOKEN", "bscscan": "BSCSCAN_TOKEN"} + explorer_tokens = { + "etherscan": "ETHERSCAN_TOKEN", + "bscscan": "BSCSCAN_TOKEN", + "polygonscan": "POLYGONSCAN_TOKEN", + } url = CONFIG.active_network.get("explorer") if url is None: raise ValueError("Explorer API not set for this network") @@ -1878,6 +1882,16 @@ def _fetch_from_explorer(address: str, action: str, silent: bool) -> Dict: "as the environment variable $BSCSCAN_TOKEN", BrownieEnvironmentWarning, ) + elif "polygonscan" in url: + if os.getenv("POLYGONSCAN_TOKEN"): + params["apiKey"] = os.getenv("POLYGONSCAN_TOKEN") + elif not silent: + warnings.warn( + "No PolygonScan API token set. You may experience issues with rate limiting. " + "Visit https://polygonscan.com/register to obtain a token, and then store it " + "as the environment variable $POLYGONSCAN_TOKEN", + BrownieEnvironmentWarning, + ) if not silent: print(