From 5f3a02eb024e42f7a23792b8b5f2b8caea277245 Mon Sep 17 00:00:00 2001 From: "Murray, Cory M (CGI Federal)" Date: Mon, 26 Sep 2022 10:06:38 -0500 Subject: [PATCH 1/8] add mumbai --- crytic_compile/platform/etherscan.py | 1 + 1 file changed, 1 insertion(+) diff --git a/crytic_compile/platform/etherscan.py b/crytic_compile/platform/etherscan.py index 6f6965ac..0de88f7e 100644 --- a/crytic_compile/platform/etherscan.py +++ b/crytic_compile/platform/etherscan.py @@ -45,6 +45,7 @@ "arbi:": (".arbiscan.io", "arbiscan.io"), "testnet.arbi:": ("-testnet.arbiscan.io", "testnet.arbiscan.io"), "poly:": (".polygonscan.com", "polygonscan.com"), + "mumbai:": (".mumbai.polygonscan.com", "mumbai.polygonscan.com"), "avax:": (".snowtrace.io", "snowtrace.io"), "testnet.avax:": ("-testnet.snowtrace.io", "testnet.snowtrace.io"), "ftm:": (".ftmscan.com", "ftmscan.com"), From 6303ee230b926b1e90e443357060b60e933072f7 Mon Sep 17 00:00:00 2001 From: "Murray, Cory M (CGI Federal)" Date: Mon, 26 Sep 2022 11:41:23 -0500 Subject: [PATCH 2/8] hacky nonsense --- crytic_compile/platform/etherscan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crytic_compile/platform/etherscan.py b/crytic_compile/platform/etherscan.py index 0de88f7e..20225994 100644 --- a/crytic_compile/platform/etherscan.py +++ b/crytic_compile/platform/etherscan.py @@ -45,7 +45,7 @@ "arbi:": (".arbiscan.io", "arbiscan.io"), "testnet.arbi:": ("-testnet.arbiscan.io", "testnet.arbiscan.io"), "poly:": (".polygonscan.com", "polygonscan.com"), - "mumbai:": (".mumbai.polygonscan.com", "mumbai.polygonscan.com"), + "mumbai:": ("-mumbai.polygonscan.com", "mumbai.polygonscan.com"), "avax:": (".snowtrace.io", "snowtrace.io"), "testnet.avax:": ("-testnet.snowtrace.io", "testnet.snowtrace.io"), "ftm:": (".ftmscan.com", "ftmscan.com"), From 2b7150b778aee69efaa9ce0e1bedc4e69f683cc3 Mon Sep 17 00:00:00 2001 From: "Murray, Cory M (CGI Federal)" Date: Mon, 26 Sep 2022 11:53:07 -0500 Subject: [PATCH 3/8] hacky nonsense --- crytic_compile/platform/etherscan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crytic_compile/platform/etherscan.py b/crytic_compile/platform/etherscan.py index 20225994..619c7190 100644 --- a/crytic_compile/platform/etherscan.py +++ b/crytic_compile/platform/etherscan.py @@ -45,7 +45,7 @@ "arbi:": (".arbiscan.io", "arbiscan.io"), "testnet.arbi:": ("-testnet.arbiscan.io", "testnet.arbiscan.io"), "poly:": (".polygonscan.com", "polygonscan.com"), - "mumbai:": ("-mumbai.polygonscan.com", "mumbai.polygonscan.com"), + "mumbai:": ("-testnet.polygonscan.com", "testnet.polygonscan.com"), "avax:": (".snowtrace.io", "snowtrace.io"), "testnet.avax:": ("-testnet.snowtrace.io", "testnet.snowtrace.io"), "ftm:": (".ftmscan.com", "ftmscan.com"), From 30a8200712c8af5423701e75500c38435fc2b9a7 Mon Sep 17 00:00:00 2001 From: "Murray, Cory M (CGI Federal)" Date: Mon, 26 Sep 2022 12:06:16 -0500 Subject: [PATCH 4/8] try again boi --- crytic_compile/cryticparser/cryticparser.py | 8 ++++++++ crytic_compile/platform/etherscan.py | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/crytic_compile/cryticparser/cryticparser.py b/crytic_compile/cryticparser/cryticparser.py index b6ef2144..b0126e20 100755 --- a/crytic_compile/cryticparser/cryticparser.py +++ b/crytic_compile/cryticparser/cryticparser.py @@ -328,6 +328,14 @@ def _init_etherscan(parser: ArgumentParser) -> None: default=DEFAULTS_FLAG_IN_CONFIG["etherscan_api_key"], ) + group_etherscan.add_argument( + "--test-polygonscan-apikey", + help="Etherscan API key.", + action="store", + dest="test_polygonscan_api_key", + default=DEFAULTS_FLAG_IN_CONFIG["etherscan_api_key"], + ) + group_etherscan.add_argument( "--avax-apikey", help="Etherscan API key.", diff --git a/crytic_compile/platform/etherscan.py b/crytic_compile/platform/etherscan.py index 619c7190..f5eb1f7e 100644 --- a/crytic_compile/platform/etherscan.py +++ b/crytic_compile/platform/etherscan.py @@ -216,6 +216,7 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: etherscan_api_key = kwargs.get("etherscan_api_key", None) arbiscan_api_key = kwargs.get("arbiscan_api_key", None) polygonscan_api_key = kwargs.get("polygonscan_api_key", None) + test_polygonscan_api_key = kwargs.get("test_polygonscan_api_key", None) avax_api_key = kwargs.get("avax_api_key", None) ftmscan_api_key = kwargs.get("ftmscan_api_key", None) bscan_api_key = kwargs.get("bscan_api_key", None) @@ -235,6 +236,9 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: if polygonscan_api_key and "polygonscan" in etherscan_url: etherscan_url += f"&apikey={polygonscan_api_key}" etherscan_bytecode_url += f"&apikey={polygonscan_api_key}" + if test_polygonscan_api_key and "polygonscan" in etherscan_url: + etherscan_url += f"&apikey={test_polygonscan_api_key}" + etherscan_bytecode_url += f"&apikey={test_polygonscan_api_key}" if avax_api_key and "snowtrace" in etherscan_url: etherscan_url += f"&apikey={avax_api_key}" etherscan_bytecode_url += f"&apikey={avax_api_key}" From 4b3fa5833a933b7d810a1e347f18634bfb91759c Mon Sep 17 00:00:00 2001 From: "Murray, Cory M (CGI Federal)" Date: Mon, 26 Sep 2022 13:40:57 -0500 Subject: [PATCH 5/8] hacky try number 3 --- crytic_compile/platform/etherscan.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crytic_compile/platform/etherscan.py b/crytic_compile/platform/etherscan.py index f5eb1f7e..5a7834ab 100644 --- a/crytic_compile/platform/etherscan.py +++ b/crytic_compile/platform/etherscan.py @@ -257,6 +257,8 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: contract_name: str = "" if not only_bytecode: + if "polygon" in etherscan_url: + etherscan_url = urllib.request.Request(etherscan_url,headers={"User-Agent": "Mozilla/5.0"}) with urllib.request.urlopen(etherscan_url) as response: html = response.read() From eb1d1257b99e0fa7e4f5a171f9af63e41c14b083 Mon Sep 17 00:00:00 2001 From: "Murray, Cory M (CGI Federal)" Date: Mon, 26 Sep 2022 13:44:03 -0500 Subject: [PATCH 6/8] hacky try number 4 --- crytic_compile/platform/etherscan.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crytic_compile/platform/etherscan.py b/crytic_compile/platform/etherscan.py index 5a7834ab..44c8c3aa 100644 --- a/crytic_compile/platform/etherscan.py +++ b/crytic_compile/platform/etherscan.py @@ -258,9 +258,13 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: if not only_bytecode: if "polygon" in etherscan_url: - etherscan_url = urllib.request.Request(etherscan_url,headers={"User-Agent": "Mozilla/5.0"}) - with urllib.request.urlopen(etherscan_url) as response: - html = response.read() + # build object with headers, then send request + new_etherscan_url = urllib.request.Request(etherscan_url,headers={"User-Agent": "Mozilla/5.0"}) + with urllib.request.urlopen(new_etherscan_url) as response: + html = response.read() + else: + with urllib.request.urlopen(etherscan_url) as response: + html = response.read() info = json.loads(html) From 126683440a1f7da543af2b471563d7066edad9b3 Mon Sep 17 00:00:00 2001 From: Josselin Feist Date: Tue, 4 Oct 2022 11:40:11 +0200 Subject: [PATCH 7/8] run black --- crytic_compile/platform/etherscan.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crytic_compile/platform/etherscan.py b/crytic_compile/platform/etherscan.py index 44c8c3aa..a83c97d8 100644 --- a/crytic_compile/platform/etherscan.py +++ b/crytic_compile/platform/etherscan.py @@ -259,7 +259,9 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: if not only_bytecode: if "polygon" in etherscan_url: # build object with headers, then send request - new_etherscan_url = urllib.request.Request(etherscan_url,headers={"User-Agent": "Mozilla/5.0"}) + new_etherscan_url = urllib.request.Request( + etherscan_url, headers={"User-Agent": "Mozilla/5.0"} + ) with urllib.request.urlopen(new_etherscan_url) as response: html = response.read() else: From e52139c660ed12f9c24af96632da8a933c2aab57 Mon Sep 17 00:00:00 2001 From: Josselin Feist Date: Tue, 4 Oct 2022 11:47:38 +0200 Subject: [PATCH 8/8] black --- crytic_compile/platform/foundry.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/crytic_compile/platform/foundry.py b/crytic_compile/platform/foundry.py index 177dab0e..92f6bf8e 100755 --- a/crytic_compile/platform/foundry.py +++ b/crytic_compile/platform/foundry.py @@ -140,12 +140,16 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: compilation_unit.bytecodes_runtime[contract_name] = target_loaded[ "deployedBytecode" ]["object"].replace("0x", "") - compilation_unit.srcmaps_init[contract_name] = target_loaded["bytecode"][ - "sourceMap" - ].split(";") if target_loaded["bytecode"].get("sourceMap") else [] - compilation_unit.srcmaps_runtime[contract_name] = target_loaded["deployedBytecode"][ - "sourceMap" - ].split(";") if target_loaded["deployedBytecode"].get("sourceMap") else [] + compilation_unit.srcmaps_init[contract_name] = ( + target_loaded["bytecode"]["sourceMap"].split(";") + if target_loaded["bytecode"].get("sourceMap") + else [] + ) + compilation_unit.srcmaps_runtime[contract_name] = ( + target_loaded["deployedBytecode"]["sourceMap"].split(";") + if target_loaded["deployedBytecode"].get("sourceMap") + else [] + ) version, optimized, runs = _get_config_info(self._target)