Skip to content
Merged
Show file tree
Hide file tree
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
-Fixes a regression in crytic-compile where getting a package name wo…
…uld fail with a non-string target (standard exports, zip archives, etc).

-Adds package property to standard export/import.
  • Loading branch information
Xenomega committed Oct 30, 2019
commit 36aa29e6cae9ce818ffef27a915b25f5e997a9b9
6 changes: 4 additions & 2 deletions crytic_compile/platform/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def generate_standard_export(crytic_compile):
contracts = dict()
for contract_name in crytic_compile.contracts_names:
filename = crytic_compile.filename_of_contract(contract_name)
librairies = crytic_compile.libraries_names_and_patterns(contract_name)
libraries = crytic_compile.libraries_names_and_patterns(contract_name)
contracts[contract_name] = {
"abi": crytic_compile.abi(contract_name),
"bin": crytic_compile.bytecode_init(contract_name),
Expand All @@ -30,7 +30,7 @@ def generate_standard_export(crytic_compile):
"short": filename.short,
"relative": filename.relative,
},
"libraries": dict(librairies) if librairies else dict(),
"libraries": dict(libraries) if libraries else dict(),
"is_dependency": crytic_compile.is_dependency(filename.absolute),
}

Expand All @@ -43,6 +43,7 @@ def generate_standard_export(crytic_compile):
"version": crytic_compile._compiler_version.version,
"optimized": crytic_compile._compiler_version.optimized,
},
"package": crytic_compile._package,
"working_dir": str(crytic_compile._working_dir),
"type": int(crytic_compile._type),
}
Expand Down Expand Up @@ -77,6 +78,7 @@ def compile(crytic_compile, target, **kwargs):


def load_from_compile(crytic_compile, loaded_json):
crytic_compile._package = loaded_json.get("package", None)
crytic_compile._asts = loaded_json["asts"]
crytic_compile._compiler_version = CompilerVersion(
compiler=loaded_json["compiler"]["compiler"],
Expand Down
6 changes: 6 additions & 0 deletions crytic_compile/utils/npm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ def get_package_name(target):
:param target:
:return: str or None
"""

# Verify the target path is a string (exported zip archives are lists)
if not isinstance(target, str):
return None

# Obtain the path the target string represents
>
if target.is_dir():
package = Path(target, "package.json")
Expand Down