Skip to content

Commit 4d35e4b

Browse files
authored
Improve standard legacy support (#229)
* Improve standard legacy support * Run black
1 parent fa3fbbf commit 4d35e4b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

crytic_compile/platform/standard.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,18 @@ def _load_from_compile_legacy2(crytic_compile: "CryticCompile", loaded_json: Dic
351351
crytic_compile.dependencies.add(filename.short)
352352
crytic_compile.dependencies.add(filename.used)
353353
compilation_unit.asts = compilation_unit_json["asts"]
354-
compilation_unit.filenames = {
355-
_convert_dict_to_filename(filename) for filename in compilation_unit_json["filenames"]
356-
}
354+
355+
if "filenames" in compilation_unit_json:
356+
compilation_unit.filenames = {
357+
_convert_dict_to_filename(filename)
358+
for filename in compilation_unit_json["filenames"]
359+
}
360+
else:
361+
# For legay code, we recover the filenames from the contracts list
362+
# This is not perfect, as a filename might not be associated to any contract
363+
for contract_name, contract in compilation_unit_json["contracts"].items():
364+
filename = _convert_dict_to_filename(contract["filenames"])
365+
compilation_unit.filenames.add(filename)
357366

358367

359368
def _load_from_compile_current(crytic_compile: "CryticCompile", loaded_json: Dict) -> None:

0 commit comments

Comments
 (0)