Skip to content

Commit ffc2251

Browse files
author
Feist Josselin
authored
Merge pull request #46 from crytic/dev-fix-zip-regression
Fix regression in standard export/import functionality
2 parents 758ce45 + 36aa29e commit ffc2251

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎crytic_compile/platform/standard.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def generate_standard_export(crytic_compile):
1717
contracts = dict()
1818
for contract_name in crytic_compile.contracts_names:
1919
filename = crytic_compile.filename_of_contract(contract_name)
20-
librairies = crytic_compile.libraries_names_and_patterns(contract_name)
20+
libraries = crytic_compile.libraries_names_and_patterns(contract_name)
2121
contracts[contract_name] = {
2222
"abi": crytic_compile.abi(contract_name),
2323
"bin": crytic_compile.bytecode_init(contract_name),
@@ -30,7 +30,7 @@ def generate_standard_export(crytic_compile):
3030
"short": filename.short,
3131
"relative": filename.relative,
3232
},
33-
"libraries": dict(librairies) if librairies else dict(),
33+
"libraries": dict(libraries) if libraries else dict(),
3434
"is_dependency": crytic_compile.is_dependency(filename.absolute),
3535
}
3636

@@ -43,6 +43,7 @@ def generate_standard_export(crytic_compile):
4343
"version": crytic_compile._compiler_version.version,
4444
"optimized": crytic_compile._compiler_version.optimized,
4545
},
46+
"package": crytic_compile._package,
4647
"working_dir": str(crytic_compile._working_dir),
4748
"type": int(crytic_compile._type),
4849
}
@@ -77,6 +78,7 @@ def compile(crytic_compile, target, **kwargs):
7778

7879

7980
def load_from_compile(crytic_compile, loaded_json):
81+
crytic_compile._package = loaded_json.get("package", None)
8082
crytic_compile._asts = loaded_json["asts"]
8183
crytic_compile._compiler_version = CompilerVersion(
8284
compiler=loaded_json["compiler"]["compiler"],

‎crytic_compile/utils/npm.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ def get_package_name(target):
88
:param target:
99
:return: str or None
1010
"""
11+
12+
# Verify the target path is a string (exported zip archives are lists)
13+
if not isinstance(target, str):
14+
return None
15+
16+
# Obtain the path the target string represents
1117
target = Path(target)
1218
if target.is_dir():
1319
package = Path(target, "package.json")

0 commit comments

Comments
 (0)