From e726dd0f61811f34ed55f18de0b2f9c97e5d77c3 Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Mon, 2 Jan 2023 14:08:41 -0600 Subject: [PATCH 1/8] support multiple compilation units for foundry --- crytic_compile/platform/foundry.py | 226 ++++++++++++----------------- 1 file changed, 95 insertions(+), 131 deletions(-) diff --git a/crytic_compile/platform/foundry.py b/crytic_compile/platform/foundry.py index 38f588d6..9825cb17 100755 --- a/crytic_compile/platform/foundry.py +++ b/crytic_compile/platform/foundry.py @@ -14,9 +14,11 @@ from crytic_compile.platform.abstract_platform import AbstractPlatform from crytic_compile.platform.exceptions import InvalidCompilation from crytic_compile.platform.types import Type -from crytic_compile.utils.naming import convert_filename +from crytic_compile.utils.naming import convert_filename, extract_name from crytic_compile.utils.natspec import Natspec +from .solc import relative_to_short + # Handle cycle if TYPE_CHECKING: from crytic_compile import CryticCompile @@ -60,14 +62,7 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: cmd = [ "forge", "build", - "--extra-output", - "abi", - "--extra-output", - "userdoc", - "--extra-output", - "devdoc", - "--extra-output", - "evm.methodIdentifiers", + "--build-info", "--force", ] @@ -94,68 +89,99 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: if stderr: LOGGER.error(stderr) - filenames = Path(self._target, out_directory).rglob("*.json") - - # foundry only support solc for now - compiler = "solc" - compilation_unit = CompilationUnit(crytic_compile, str(self._target)) - - for filename_txt in filenames: - with open(filename_txt, encoding="utf8") as file_desc: - target_loaded = json.load(file_desc) - - userdoc = target_loaded.get("userdoc", {}) - devdoc = target_loaded.get("devdoc", {}) - natspec = Natspec(userdoc, devdoc) - - if not "ast" in target_loaded: - continue - - filename_str = target_loaded["ast"]["absolutePath"] - - try: - filename = convert_filename( - filename_str, lambda x: x, crytic_compile, working_dir=self._target - ) - except InvalidCompilation as i: - txt = str(i) - txt += "\nSomething went wrong, please open an issue in https://github.com/crytic/crytic-compile" - # pylint: disable=raise-missing-from - raise InvalidCompilation(txt) - - source_unit = compilation_unit.create_source_unit(filename) - - source_unit.ast = target_loaded["ast"] - - contract_name = filename_txt.parts[-1] - contract_name = contract_name[: -len(".json")] - - source_unit.natspec[contract_name] = natspec - compilation_unit.filename_to_contracts[filename].add(contract_name) - source_unit.contracts_names.add(contract_name) - source_unit.abis[contract_name] = target_loaded["abi"] - source_unit.bytecodes_init[contract_name] = target_loaded["bytecode"][ - "object" - ].replace("0x", "") - source_unit.bytecodes_runtime[contract_name] = target_loaded["deployedBytecode"][ - "object" - ].replace("0x", "") - source_unit.srcmaps_init[contract_name] = ( - target_loaded["bytecode"]["sourceMap"].split(";") - if target_loaded["bytecode"].get("sourceMap") - else [] - ) - source_unit.srcmaps_runtime[contract_name] = ( - target_loaded["deployedBytecode"]["sourceMap"].split(";") - if target_loaded["deployedBytecode"].get("sourceMap") - else [] - ) + build_directory = Path( + self._target, + out_directory, + "build-info", + ) + files = sorted( + os.listdir(build_directory), key=lambda x: os.path.getmtime(Path(build_directory, x)) + ) + files = [f for f in files if f.endswith(".json")] + if not files: + txt = f"`forge build` failed. Can you run it?\n{build_directory} is empty" + raise InvalidCompilation(txt) - version, optimized, runs = _get_config_info(self._target) + for file in files: + build_info = Path(build_directory, file) - compilation_unit.compiler_version = CompilerVersion( - compiler=compiler, version=version, optimized=optimized, optimize_runs=runs - ) + # The file here should always ends .json, but just in case use ife + uniq_id = file if ".json" not in file else file[0:-5] + compilation_unit = CompilationUnit(crytic_compile, uniq_id) + + with open(build_info, encoding="utf8") as file_desc: + loaded_json = json.load(file_desc) + + targets_json = loaded_json["output"] + + version_from_config = loaded_json["solcVersion"] # TODO supper vyper + input_json = loaded_json["input"] + compiler = "solc" if input_json["language"] == "Solidity" else "vyper" + optimized = input_json["settings"]["optimizer"]["enabled"] + + compilation_unit.compiler_version = CompilerVersion( + compiler=compiler, version=version_from_config, optimized=optimized + ) + + skip_filename = compilation_unit.compiler_version.version in [ + f"0.4.{x}" for x in range(0, 10) + ] + + if "contracts" in targets_json: + for original_filename, contracts_info in targets_json["contracts"].items(): + + filename = convert_filename( + original_filename, + relative_to_short, + crytic_compile, + working_dir=self._target, + ) + + source_unit = compilation_unit.create_source_unit(filename) + + for original_contract_name, info in contracts_info.items(): + contract_name = extract_name(original_contract_name) + + source_unit.contracts_names.add(contract_name) + compilation_unit.filename_to_contracts[filename].add(contract_name) + + source_unit.abis[contract_name] = info["abi"] + source_unit.bytecodes_init[contract_name] = info["evm"]["bytecode"][ + "object" + ] + source_unit.bytecodes_runtime[contract_name] = info["evm"][ + "deployedBytecode" + ]["object"] + source_unit.srcmaps_init[contract_name] = info["evm"]["bytecode"][ + "sourceMap" + ].split(";") + source_unit.srcmaps_runtime[contract_name] = info["evm"][ + "deployedBytecode" + ]["sourceMap"].split(";") + userdoc = info.get("userdoc", {}) + devdoc = info.get("devdoc", {}) + natspec = Natspec(userdoc, devdoc) + source_unit.natspec[contract_name] = natspec + + if "sources" in targets_json: + for path, info in targets_json["sources"].items(): + if skip_filename: + path = convert_filename( + self._target, + relative_to_short, + crytic_compile, + working_dir=self._target, + ) + else: + path = convert_filename( + path, + relative_to_short, + crytic_compile, + working_dir=self._target, + ) + + source_unit = compilation_unit.create_source_unit(path) + source_unit.ast = info["ast"] @staticmethod def is_supported(target: str, **kwargs: str) -> bool: @@ -197,65 +223,3 @@ def _guessed_tests(self) -> List[str]: List[str]: The guessed unit tests commands """ return ["forge test"] - - -def _get_config_info(target: str) -> Tuple[str, Optional[bool], Optional[int]]: - """get the compiler version from solidity-files-cache.json - - Args: - target (str): path to the project directory - - Returns: - (str, str, str): compiler version, optimized, runs - - Raises: - InvalidCompilation: If cache/solidity-files-cache.json cannot be parsed - """ - config = Path(target, "cache", "solidity-files-cache.json") - if not config.exists(): - raise InvalidCompilation( - "Could not find the cache/solidity-files-cache.json file." - + "If you are using 'cache = true' in foundry's config file, please remove it." - + " Otherwise please open an issue in https://github.com/crytic/crytic-compile" - ) - with open(config, "r", encoding="utf8") as config_f: - config_dict = json.load(config_f) - - version: Optional[str] = None - optimizer: Optional[bool] = None - runs: Optional[int] = None - - if "files" in config_dict: - items = list(config_dict["files"].values()) - # On the form - # { .. - # "artifacts": { - # "CONTRACT_NAME": { - # "0.8.X+commit...": "filename"} - # - if len(items) >= 1: - item = items[0] - if "artifacts" in item: - items_artifact = list(item["artifacts"].values()) - if len(items_artifact) >= 1: - item_version = items_artifact[0] - version = list(item_version.keys())[0] - assert version - plus_position = version.find("+") - if plus_position > 0: - version = version[:plus_position] - if ( - "solcConfig" in item - and "settings" in item["solcConfig"] - and "optimizer" in item["solcConfig"]["settings"] - ): - optimizer = item["solcConfig"]["settings"]["optimizer"]["enabled"] - runs = item["solcConfig"]["settings"]["optimizer"].get("runs", None) - - if version is None: - raise InvalidCompilation( - "Something went wrong with cache/solidity-files-cache.json parsing" - + ". Please open an issue in https://github.com/crytic/crytic-compile" - ) - - return version, optimizer, runs From 6708c58fae55c0f925d12aa02961c034e0e1fe39 Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Mon, 2 Jan 2023 14:21:07 -0600 Subject: [PATCH 2/8] pylint --- crytic_compile/platform/foundry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crytic_compile/platform/foundry.py b/crytic_compile/platform/foundry.py index 9825cb17..ef2d1392 100755 --- a/crytic_compile/platform/foundry.py +++ b/crytic_compile/platform/foundry.py @@ -7,7 +7,7 @@ import shutil import subprocess from pathlib import Path -from typing import TYPE_CHECKING, List, Tuple, Optional +from typing import TYPE_CHECKING, List from crytic_compile.compilation_unit import CompilationUnit from crytic_compile.compiler.compiler import CompilerVersion From 4ee6d3b1c275ec604485be8f01255e330eba2ff3 Mon Sep 17 00:00:00 2001 From: Josselin Feist Date: Wed, 4 Jan 2023 18:41:11 +0100 Subject: [PATCH 3/8] Refactor copy/paste logic --- crytic_compile/platform/foundry.py | 91 +-------------- crytic_compile/platform/hardhat.py | 182 +++++++++++++++-------------- 2 files changed, 97 insertions(+), 176 deletions(-) diff --git a/crytic_compile/platform/foundry.py b/crytic_compile/platform/foundry.py index ef2d1392..3e1f77b9 100755 --- a/crytic_compile/platform/foundry.py +++ b/crytic_compile/platform/foundry.py @@ -16,6 +16,7 @@ from crytic_compile.platform.types import Type from crytic_compile.utils.naming import convert_filename, extract_name from crytic_compile.utils.natspec import Natspec +from .hardhat import hardhat_like_parsing from .solc import relative_to_short @@ -94,94 +95,8 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: out_directory, "build-info", ) - files = sorted( - os.listdir(build_directory), key=lambda x: os.path.getmtime(Path(build_directory, x)) - ) - files = [f for f in files if f.endswith(".json")] - if not files: - txt = f"`forge build` failed. Can you run it?\n{build_directory} is empty" - raise InvalidCompilation(txt) - - for file in files: - build_info = Path(build_directory, file) - - # The file here should always ends .json, but just in case use ife - uniq_id = file if ".json" not in file else file[0:-5] - compilation_unit = CompilationUnit(crytic_compile, uniq_id) - - with open(build_info, encoding="utf8") as file_desc: - loaded_json = json.load(file_desc) - - targets_json = loaded_json["output"] - - version_from_config = loaded_json["solcVersion"] # TODO supper vyper - input_json = loaded_json["input"] - compiler = "solc" if input_json["language"] == "Solidity" else "vyper" - optimized = input_json["settings"]["optimizer"]["enabled"] - - compilation_unit.compiler_version = CompilerVersion( - compiler=compiler, version=version_from_config, optimized=optimized - ) - - skip_filename = compilation_unit.compiler_version.version in [ - f"0.4.{x}" for x in range(0, 10) - ] - - if "contracts" in targets_json: - for original_filename, contracts_info in targets_json["contracts"].items(): - - filename = convert_filename( - original_filename, - relative_to_short, - crytic_compile, - working_dir=self._target, - ) - - source_unit = compilation_unit.create_source_unit(filename) - - for original_contract_name, info in contracts_info.items(): - contract_name = extract_name(original_contract_name) - - source_unit.contracts_names.add(contract_name) - compilation_unit.filename_to_contracts[filename].add(contract_name) - - source_unit.abis[contract_name] = info["abi"] - source_unit.bytecodes_init[contract_name] = info["evm"]["bytecode"][ - "object" - ] - source_unit.bytecodes_runtime[contract_name] = info["evm"][ - "deployedBytecode" - ]["object"] - source_unit.srcmaps_init[contract_name] = info["evm"]["bytecode"][ - "sourceMap" - ].split(";") - source_unit.srcmaps_runtime[contract_name] = info["evm"][ - "deployedBytecode" - ]["sourceMap"].split(";") - userdoc = info.get("userdoc", {}) - devdoc = info.get("devdoc", {}) - natspec = Natspec(userdoc, devdoc) - source_unit.natspec[contract_name] = natspec - - if "sources" in targets_json: - for path, info in targets_json["sources"].items(): - if skip_filename: - path = convert_filename( - self._target, - relative_to_short, - crytic_compile, - working_dir=self._target, - ) - else: - path = convert_filename( - path, - relative_to_short, - crytic_compile, - working_dir=self._target, - ) - - source_unit = compilation_unit.create_source_unit(path) - source_unit.ast = info["ast"] + + hardhat_like_parsing(crytic_compile, self._target, build_directory, self._target) @staticmethod def is_supported(target: str, **kwargs: str) -> bool: diff --git a/crytic_compile/platform/hardhat.py b/crytic_compile/platform/hardhat.py index aba547dd..998deed0 100755 --- a/crytic_compile/platform/hardhat.py +++ b/crytic_compile/platform/hardhat.py @@ -26,6 +26,99 @@ LOGGER = logging.getLogger("CryticCompile") +def hardhat_like_parsing( + crytic_compile: "CryticCompile", target: str, build_directory: Path, working_dir: str +) -> None: + files = sorted( + os.listdir(build_directory), key=lambda x: os.path.getmtime(Path(build_directory, x)) + ) + files = [str(f) for f in files if str(f).endswith(".json")] + if not files: + txt = f"`hardhat compile` failed. Can you run it?\n{build_directory} is empty" + raise InvalidCompilation(txt) + + for file in files: + build_info = Path(build_directory, file) + + # The file here should always ends .json, but just in case use ife + uniq_id = file if ".json" not in file else file[0:-5] + compilation_unit = CompilationUnit(crytic_compile, uniq_id) + + with open(build_info, encoding="utf8") as file_desc: + loaded_json = json.load(file_desc) + + targets_json = loaded_json["output"] + + version_from_config = loaded_json["solcVersion"] # TODO supper vyper + input_json = loaded_json["input"] + compiler = "solc" if input_json["language"] == "Solidity" else "vyper" + optimized = input_json["settings"]["optimizer"]["enabled"] + + compilation_unit.compiler_version = CompilerVersion( + compiler=compiler, version=version_from_config, optimized=optimized + ) + + skip_filename = compilation_unit.compiler_version.version in [ + f"0.4.{x}" for x in range(0, 10) + ] + + if "contracts" in targets_json: + for original_filename, contracts_info in targets_json["contracts"].items(): + + filename = convert_filename( + original_filename, + relative_to_short, + crytic_compile, + working_dir=working_dir, + ) + + source_unit = compilation_unit.create_source_unit(filename) + + for original_contract_name, info in contracts_info.items(): + contract_name = extract_name(original_contract_name) + + source_unit.contracts_names.add(contract_name) + compilation_unit.filename_to_contracts[filename].add(contract_name) + + source_unit.abis[contract_name] = info["abi"] + source_unit.bytecodes_init[contract_name] = info["evm"]["bytecode"][ + "object" + ] + source_unit.bytecodes_runtime[contract_name] = info["evm"][ + "deployedBytecode" + ]["object"] + source_unit.srcmaps_init[contract_name] = info["evm"]["bytecode"][ + "sourceMap" + ].split(";") + source_unit.srcmaps_runtime[contract_name] = info["evm"][ + "deployedBytecode" + ]["sourceMap"].split(";") + userdoc = info.get("userdoc", {}) + devdoc = info.get("devdoc", {}) + natspec = Natspec(userdoc, devdoc) + source_unit.natspec[contract_name] = natspec + + if "sources" in targets_json: + for path, info in targets_json["sources"].items(): + if skip_filename: + path = convert_filename( + target, + relative_to_short, + crytic_compile, + working_dir=working_dir, + ) + else: + path = convert_filename( + path, + relative_to_short, + crytic_compile, + working_dir=working_dir, + ) + + source_unit = compilation_unit.create_source_unit(path) + source_unit.ast = info["ast"] + + class Hardhat(AbstractPlatform): """ Hardhat platform @@ -88,94 +181,7 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: if stderr: LOGGER.error(stderr) - files = sorted( - os.listdir(build_directory), key=lambda x: os.path.getmtime(Path(build_directory, x)) - ) - files = [f for f in files if f.endswith(".json")] - if not files: - txt = f"`hardhat compile` failed. Can you run it?\n{build_directory} is empty" - raise InvalidCompilation(txt) - - for file in files: - build_info = Path(build_directory, file) - - # The file here should always ends .json, but just in case use ife - uniq_id = file if ".json" not in file else file[0:-5] - compilation_unit = CompilationUnit(crytic_compile, uniq_id) - - with open(build_info, encoding="utf8") as file_desc: - loaded_json = json.load(file_desc) - - targets_json = loaded_json["output"] - - version_from_config = loaded_json["solcVersion"] # TODO supper vyper - input_json = loaded_json["input"] - compiler = "solc" if input_json["language"] == "Solidity" else "vyper" - optimized = input_json["settings"]["optimizer"]["enabled"] - - compilation_unit.compiler_version = CompilerVersion( - compiler=compiler, version=version_from_config, optimized=optimized - ) - - skip_filename = compilation_unit.compiler_version.version in [ - f"0.4.{x}" for x in range(0, 10) - ] - - if "contracts" in targets_json: - for original_filename, contracts_info in targets_json["contracts"].items(): - - filename = convert_filename( - original_filename, - relative_to_short, - crytic_compile, - working_dir=hardhat_working_dir, - ) - - source_unit = compilation_unit.create_source_unit(filename) - - for original_contract_name, info in contracts_info.items(): - contract_name = extract_name(original_contract_name) - - source_unit.contracts_names.add(contract_name) - compilation_unit.filename_to_contracts[filename].add(contract_name) - - source_unit.abis[contract_name] = info["abi"] - source_unit.bytecodes_init[contract_name] = info["evm"]["bytecode"][ - "object" - ] - source_unit.bytecodes_runtime[contract_name] = info["evm"][ - "deployedBytecode" - ]["object"] - source_unit.srcmaps_init[contract_name] = info["evm"]["bytecode"][ - "sourceMap" - ].split(";") - source_unit.srcmaps_runtime[contract_name] = info["evm"][ - "deployedBytecode" - ]["sourceMap"].split(";") - userdoc = info.get("userdoc", {}) - devdoc = info.get("devdoc", {}) - natspec = Natspec(userdoc, devdoc) - source_unit.natspec[contract_name] = natspec - - if "sources" in targets_json: - for path, info in targets_json["sources"].items(): - if skip_filename: - path = convert_filename( - self._target, - relative_to_short, - crytic_compile, - working_dir=hardhat_working_dir, - ) - else: - path = convert_filename( - path, - relative_to_short, - crytic_compile, - working_dir=hardhat_working_dir, - ) - - source_unit = compilation_unit.create_source_unit(path) - source_unit.ast = info["ast"] + hardhat_like_parsing(crytic_compile, self._target, build_directory, hardhat_working_dir) @staticmethod def is_supported(target: str, **kwargs: str) -> bool: From d890670707e0e8a92f7ec6a85a65722d2098b1bd Mon Sep 17 00:00:00 2001 From: Josselin Feist Date: Wed, 4 Jan 2023 18:43:44 +0100 Subject: [PATCH 4/8] pylint --- crytic_compile/platform/foundry.py | 8 -------- crytic_compile/platform/hardhat.py | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/crytic_compile/platform/foundry.py b/crytic_compile/platform/foundry.py index 3e1f77b9..57bc4c94 100755 --- a/crytic_compile/platform/foundry.py +++ b/crytic_compile/platform/foundry.py @@ -1,7 +1,6 @@ """ Truffle platform """ -import json import logging import os import shutil @@ -9,17 +8,10 @@ from pathlib import Path from typing import TYPE_CHECKING, List -from crytic_compile.compilation_unit import CompilationUnit -from crytic_compile.compiler.compiler import CompilerVersion from crytic_compile.platform.abstract_platform import AbstractPlatform -from crytic_compile.platform.exceptions import InvalidCompilation from crytic_compile.platform.types import Type -from crytic_compile.utils.naming import convert_filename, extract_name -from crytic_compile.utils.natspec import Natspec from .hardhat import hardhat_like_parsing -from .solc import relative_to_short - # Handle cycle if TYPE_CHECKING: from crytic_compile import CryticCompile diff --git a/crytic_compile/platform/hardhat.py b/crytic_compile/platform/hardhat.py index 998deed0..0b652d55 100755 --- a/crytic_compile/platform/hardhat.py +++ b/crytic_compile/platform/hardhat.py @@ -25,10 +25,24 @@ LOGGER = logging.getLogger("CryticCompile") - +# pylint: disable=too-many-locals def hardhat_like_parsing( crytic_compile: "CryticCompile", target: str, build_directory: Path, working_dir: str ) -> None: + """ + This function parse the output generated by hardhat. + It can be re-used by any platform that follows the same schema (ex:foudnry) + + + Args: + crytic_compile: CryticCompile object + target: target + build_directory: build directory + working_dir: working directory + + Returns: + + """ files = sorted( os.listdir(build_directory), key=lambda x: os.path.getmtime(Path(build_directory, x)) ) @@ -128,7 +142,6 @@ class Hardhat(AbstractPlatform): PROJECT_URL = "https://github.com/nomiclabs/hardhat" TYPE = Type.HARDHAT - # pylint: disable=too-many-locals,too-many-statements def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: """Run the compilation From 2cd29fcec564a20d7ef3a0bdc68fb6761cb993cf Mon Sep 17 00:00:00 2001 From: Josselin Feist Date: Thu, 5 Jan 2023 11:27:29 +0100 Subject: [PATCH 5/8] Fix darglint --- crytic_compile/platform/foundry.py | 2 -- crytic_compile/platform/hardhat.py | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crytic_compile/platform/foundry.py b/crytic_compile/platform/foundry.py index 57bc4c94..d163344f 100755 --- a/crytic_compile/platform/foundry.py +++ b/crytic_compile/platform/foundry.py @@ -36,8 +36,6 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: crytic_compile (CryticCompile): CryticCompile object to populate **kwargs: optional arguments. Used: "foundry_ignore_compile", "foundry_out_directory" - Raises: - InvalidCompilation: If foundry failed to run """ ignore_compile = kwargs.get("foundry_ignore_compile", False) or kwargs.get( diff --git a/crytic_compile/platform/hardhat.py b/crytic_compile/platform/hardhat.py index 0b652d55..4241c2cf 100755 --- a/crytic_compile/platform/hardhat.py +++ b/crytic_compile/platform/hardhat.py @@ -42,6 +42,10 @@ def hardhat_like_parsing( Returns: + + Raises: + InvalidCompilation: If hardhat failed to run + """ files = sorted( os.listdir(build_directory), key=lambda x: os.path.getmtime(Path(build_directory, x)) @@ -150,8 +154,6 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: **kwargs: optional arguments. Used: "hardhat_ignore", "hardhat_ignore_compile", "ignore_compile", "hardhat_artifacts_directory","hardhat_working_dir","npx_disable" - Raises: - InvalidCompilation: If hardhat failed to run """ hardhat_ignore_compile = kwargs.get("hardhat_ignore_compile", False) or kwargs.get( From 8b12dce4272855c6fccf754ecf61f9e1512ee63a Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Mon, 9 Jan 2023 11:16:13 +0100 Subject: [PATCH 6/8] Update doc --- crytic_compile/platform/hardhat.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/crytic_compile/platform/hardhat.py b/crytic_compile/platform/hardhat.py index 4241c2cf..c36f0f0e 100755 --- a/crytic_compile/platform/hardhat.py +++ b/crytic_compile/platform/hardhat.py @@ -40,9 +40,6 @@ def hardhat_like_parsing( build_directory: build directory working_dir: working directory - Returns: - - Raises: InvalidCompilation: If hardhat failed to run From 25c12457cca4eb05bd7b49896ac3557ddaf5a419 Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Mon, 9 Jan 2023 11:28:31 +0100 Subject: [PATCH 7/8] Try to help mypy --- crytic_compile/platform/hardhat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crytic_compile/platform/hardhat.py b/crytic_compile/platform/hardhat.py index c36f0f0e..6c81cd56 100755 --- a/crytic_compile/platform/hardhat.py +++ b/crytic_compile/platform/hardhat.py @@ -161,7 +161,7 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: self._target, kwargs.get("hardhat_artifacts_directory", "artifacts"), "build-info" ) - hardhat_working_dir = kwargs.get("hardhat_working_dir", self._target) + hardhat_working_dir: str = kwargs.get("hardhat_working_dir", self._target) base_cmd = ["hardhat"] if not kwargs.get("npx_disable", False): From f4640909c2df1b44ee4c11e1387ba2042d73d1a6 Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Mon, 9 Jan 2023 12:08:20 +0100 Subject: [PATCH 8/8] Fix pylint --- crytic_compile/platform/foundry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crytic_compile/platform/foundry.py b/crytic_compile/platform/foundry.py index 4017ec41..4021d5e7 100755 --- a/crytic_compile/platform/foundry.py +++ b/crytic_compile/platform/foundry.py @@ -10,7 +10,7 @@ from crytic_compile.platform.abstract_platform import AbstractPlatform from crytic_compile.platform.types import Type -from .hardhat import hardhat_like_parsing +from crytic_compile.platform.hardhat import hardhat_like_parsing from crytic_compile.utils.subprocess import run # Handle cycle