45
45
"arbi:" : (".arbiscan.io" , "arbiscan.io" ),
46
46
"testnet.arbi:" : ("-testnet.arbiscan.io" , "testnet.arbiscan.io" ),
47
47
"poly:" : (".polygonscan.com" , "polygonscan.com" ),
48
+ "mumbai:" : ("-testnet.polygonscan.com" , "testnet.polygonscan.com" ),
48
49
"avax:" : (".snowtrace.io" , "snowtrace.io" ),
49
50
"testnet.avax:" : ("-testnet.snowtrace.io" , "testnet.snowtrace.io" ),
50
51
"ftm:" : (".ftmscan.com" , "ftmscan.com" ),
@@ -215,6 +216,7 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
215
216
etherscan_api_key = kwargs .get ("etherscan_api_key" , None )
216
217
arbiscan_api_key = kwargs .get ("arbiscan_api_key" , None )
217
218
polygonscan_api_key = kwargs .get ("polygonscan_api_key" , None )
219
+ test_polygonscan_api_key = kwargs .get ("test_polygonscan_api_key" , None )
218
220
avax_api_key = kwargs .get ("avax_api_key" , None )
219
221
ftmscan_api_key = kwargs .get ("ftmscan_api_key" , None )
220
222
bscan_api_key = kwargs .get ("bscan_api_key" , None )
@@ -234,6 +236,9 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
234
236
if polygonscan_api_key and "polygonscan" in etherscan_url :
235
237
etherscan_url += f"&apikey={ polygonscan_api_key } "
236
238
etherscan_bytecode_url += f"&apikey={ polygonscan_api_key } "
239
+ if test_polygonscan_api_key and "polygonscan" in etherscan_url :
240
+ etherscan_url += f"&apikey={ test_polygonscan_api_key } "
241
+ etherscan_bytecode_url += f"&apikey={ test_polygonscan_api_key } "
237
242
if avax_api_key and "snowtrace" in etherscan_url :
238
243
etherscan_url += f"&apikey={ avax_api_key } "
239
244
etherscan_bytecode_url += f"&apikey={ avax_api_key } "
@@ -252,8 +257,16 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
252
257
contract_name : str = ""
253
258
254
259
if not only_bytecode :
255
- with urllib .request .urlopen (etherscan_url ) as response :
256
- html = response .read ()
260
+ if "polygon" in etherscan_url :
261
+ # build object with headers, then send request
262
+ new_etherscan_url = urllib .request .Request (
263
+ etherscan_url , headers = {"User-Agent" : "Mozilla/5.0" }
264
+ )
265
+ with urllib .request .urlopen (new_etherscan_url ) as response :
266
+ html = response .read ()
267
+ else :
268
+ with urllib .request .urlopen (etherscan_url ) as response :
269
+ html = response .read ()
257
270
258
271
info = json .loads (html )
259
272
0 commit comments