Skip to content

Commit 821d6fe

Browse files
authored
Merge pull request #487 from vikramarun/master
Adding EVM chain support
2 parents 75383f8 + 6103fea commit 821d6fe

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

crytic_compile/cryticparser/cryticparser.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,30 @@ def _init_etherscan(parser: ArgumentParser) -> None:
385385
default=DEFAULTS_FLAG_IN_CONFIG["etherscan_api_key"],
386386
)
387387

388+
group_etherscan.add_argument(
389+
"--base-apikey",
390+
help="Basescan API key.",
391+
action="store",
392+
dest="base_api_key",
393+
default=DEFAULTS_FLAG_IN_CONFIG["etherscan_api_key"],
394+
)
395+
396+
group_etherscan.add_argument(
397+
"--gno-apikey",
398+
help="Gnosisscan API key.",
399+
action="store",
400+
dest="gno_api_key",
401+
default=DEFAULTS_FLAG_IN_CONFIG["etherscan_api_key"],
402+
)
403+
404+
group_etherscan.add_argument(
405+
"--polyzk-apikey",
406+
help="zkEVM Polygonscan API key.",
407+
action="store",
408+
dest="polyzk_api_key",
409+
default=DEFAULTS_FLAG_IN_CONFIG["etherscan_api_key"],
410+
)
411+
388412
group_etherscan.add_argument(
389413
"--etherscan-export-directory",
390414
help="Directory in which to save the analyzed contracts.",

crytic_compile/platform/etherscan.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
"testnet.avax:": ("-testnet.snowtrace.io", "testnet.snowtrace.io"),
5151
"ftm:": (".ftmscan.com", "ftmscan.com"),
5252
"goerli.base:": ("-goerli.basescan.org", "goerli.basescan.org"),
53+
"base:": (".basescan.org", "basescan.org"),
54+
"gno:": (".gnosisscan.io", "gnosisscan.io"),
55+
"polyzk:": ("-zkevm.polygonscan.com", "zkevm.polygonscan.com"),
5356
}
5457

5558

@@ -237,6 +240,9 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
237240
ftmscan_api_key = kwargs.get("ftmscan_api_key", None)
238241
bscan_api_key = kwargs.get("bscan_api_key", None)
239242
optim_api_key = kwargs.get("optim_api_key", None)
243+
base_api_key = kwargs.get("base_api_key", None)
244+
gno_api_key = kwargs.get("gno_api_key", None)
245+
polyzk_api_key = kwargs.get("polyzk_api_key", None)
240246

241247
export_dir = kwargs.get("export_dir", "crytic-export")
242248
export_dir = os.path.join(
@@ -267,6 +273,15 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
267273
if optim_api_key and "optim" in etherscan_url:
268274
etherscan_url += f"&apikey={optim_api_key}"
269275
etherscan_bytecode_url += f"&apikey={optim_api_key}"
276+
if base_api_key and "base" in etherscan_url:
277+
etherscan_url += f"&apikey={base_api_key}"
278+
etherscan_bytecode_url += f"&apikey={base_api_key}"
279+
if gno_api_key and "gno" in etherscan_url:
280+
etherscan_url += f"&apikey={gno_api_key}"
281+
etherscan_bytecode_url += f"&apikey={gno_api_key}"
282+
if polyzk_api_key and "zkevm" in etherscan_url:
283+
etherscan_url += f"&apikey={polyzk_api_key}"
284+
etherscan_bytecode_url += f"&apikey={polyzk_api_key}"
270285

271286
source_code: str = ""
272287
result: Dict[str, Union[bool, str, int]] = {}
@@ -299,6 +314,10 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
299314
LOGGER.error("Incorrect etherscan request")
300315
raise InvalidCompilation("Incorrect etherscan request " + etherscan_url)
301316

317+
if not info["message"].startswith("OK") and "Invalid API Key" in info["result"]:
318+
LOGGER.error("Invalid etherscan API Key")
319+
raise InvalidCompilation("Invalid etherscan API Key: " + etherscan_url)
320+
302321
if not info["message"].startswith("OK"):
303322
LOGGER.error("Contract has no public source code")
304323
raise InvalidCompilation("Contract has no public source code: " + etherscan_url)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
description="Util to facilitate smart contracts compilation.",
1212
url="https://github.com/crytic/crytic-compile",
1313
author="Trail of Bits",
14-
version="0.3.2",
14+
version="0.3.4",
1515
packages=find_packages(),
1616
python_requires=">=3.8",
17-
install_requires=["pycryptodome>=3.4.6", "cbor2", "solc-select>=v1.0.2"],
17+
install_requires=["pycryptodome>=3.4.6", "cbor2", "solc-select>=v1.0.4"],
1818
extras_require={
1919
"test": [
2020
"pytest",

0 commit comments

Comments
 (0)