Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

platform: brownie: also parse interface JSON #359

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions crytic_compile/platform/brownie.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
Raises:
InvalidCompilation: If brownie failed to run
"""
build_directory = Path("build", "contracts")
contracts_directory = Path("build", "contracts")
interfaces_directory = Path("build", "interfaces")
brownie_ignore_compile = kwargs.get("brownie_ignore_compile", False) or kwargs.get(
"ignore_compile", False
)
Expand Down Expand Up @@ -75,10 +76,11 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
# pylint: disable=raise-missing-from
raise InvalidCompilation(error)

if not os.path.isdir(os.path.join(self._target, build_directory)):
if not os.path.isdir(os.path.join(self._target, contracts_directory)):
raise InvalidCompilation("`brownie compile` failed. Can you run it?")

filenames = list(Path(self._target, build_directory).rglob("*.json"))
filenames = list(Path(self._target, contracts_directory).rglob("*.json"))
filenames += list(Path(self._target, interfaces_directory).rglob("*.json"))

_iterate_over_files(crytic_compile, Path(self._target), filenames)

Expand Down Expand Up @@ -181,14 +183,16 @@ def _iterate_over_files(

source_unit.contracts_names.add(contract_name)
source_unit.abis[contract_name] = target_loaded["abi"]
source_unit.bytecodes_init[contract_name] = target_loaded["bytecode"].replace("0x", "")
source_unit.bytecodes_runtime[contract_name] = target_loaded[
"deployedBytecode"
].replace("0x", "")
source_unit.srcmaps_init[contract_name] = target_loaded["sourceMap"].split(";")
source_unit.srcmaps_runtime[contract_name] = target_loaded["deployedSourceMap"].split(
";"
source_unit.bytecodes_init[contract_name] = target_loaded.get("bytecode", "").replace(
"0x", ""
)
source_unit.bytecodes_runtime[contract_name] = target_loaded.get(
"deployedBytecode", ""
).replace("0x", "")
source_unit.srcmaps_init[contract_name] = target_loaded.get("sourceMap", "").split(";")
source_unit.srcmaps_runtime[contract_name] = target_loaded.get(
"deployedSourceMap", ""
).split(";")

userdoc = target_loaded.get("userdoc", {})
devdoc = target_loaded.get("devdoc", {})
Expand Down