From 7a150106acea885d981201d081c856d681737c27 Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Mon, 9 Jan 2023 12:06:31 +0100 Subject: [PATCH 1/3] Improve support for new standard format --- crytic_compile/platform/standard.py | 2 +- scripts/ci_test_standard.sh | 6 +++--- tests/contract_with_toplevel.sol | 7 +++++++ tests/toplevel.sol | 3 +++ 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 tests/contract_with_toplevel.sol create mode 100644 tests/toplevel.sol diff --git a/crytic_compile/platform/standard.py b/crytic_compile/platform/standard.py index ed01936d..19669ff5 100644 --- a/crytic_compile/platform/standard.py +++ b/crytic_compile/platform/standard.py @@ -452,7 +452,7 @@ def _load_from_compile_current(crytic_compile: "CryticCompile", loaded_json: Dic filename = compilation_unit.filename_lookup(filename_str) source_unit = compilation_unit.create_source_unit(filename) - for contract_name, contract in source_unit_data["contracts"].items(): + for contract_name, contract in source_unit_data.get("contracts", {}).items(): compilation_unit.filename_to_contracts[filename].add(contract_name) source_unit = compilation_unit.create_source_unit(filename) diff --git a/scripts/ci_test_standard.sh b/scripts/ci_test_standard.sh index c983f2e7..7dd2703a 100755 --- a/scripts/ci_test_standard.sh +++ b/scripts/ci_test_standard.sh @@ -5,7 +5,7 @@ DIR=$(mktemp -d) cp tests/contract.sol "$DIR" cd "$DIR" || exit 255 -crytic-compile contract.sol --export-format archive +crytic-compile contract_with_toplevel.sol --export-format archive if [ $? -ne 0 ] then @@ -13,7 +13,7 @@ then exit 255 fi -crytic-compile crytic-export/contract.sol_export_archive.json +crytic-compile crytic-export/contract_with_toplevel.sol_export_archive.json if [ $? -ne 0 ] then @@ -22,7 +22,7 @@ then fi -crytic-compile contract.sol --export-zip test.zip +crytic-compile contract_with_toplevel.sol --export-zip test.zip if [ $? -ne 0 ] then diff --git a/tests/contract_with_toplevel.sol b/tests/contract_with_toplevel.sol new file mode 100644 index 00000000..0e1155d5 --- /dev/null +++ b/tests/contract_with_toplevel.sol @@ -0,0 +1,7 @@ +import "./toplevel.sol"; + +contract C{ + function f() external{ + + } +} diff --git a/tests/toplevel.sol b/tests/toplevel.sol new file mode 100644 index 00000000..2c82f464 --- /dev/null +++ b/tests/toplevel.sol @@ -0,0 +1,3 @@ +function g(){ + +} \ No newline at end of file From 6041a510bfc11ab327d34adcb5e6d7d33d0b25b0 Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Mon, 9 Jan 2023 14:20:37 +0100 Subject: [PATCH 2/3] Minor --- scripts/ci_test_standard.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/ci_test_standard.sh b/scripts/ci_test_standard.sh index 7dd2703a..40958efc 100755 --- a/scripts/ci_test_standard.sh +++ b/scripts/ci_test_standard.sh @@ -2,7 +2,8 @@ DIR=$(mktemp -d) -cp tests/contract.sol "$DIR" +cp tests/contract_with_toplevel.sol "$DIR" +cp tests/toplevel.sol "$DIR" cd "$DIR" || exit 255 crytic-compile contract_with_toplevel.sol --export-format archive From b94bdac2a7d20ca9f38b6bc1f415f32e30fc6b54 Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Mon, 9 Jan 2023 15:07:58 +0100 Subject: [PATCH 3/3] Minor --- scripts/ci_test_standard.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/ci_test_standard.sh b/scripts/ci_test_standard.sh index 40958efc..281087f4 100755 --- a/scripts/ci_test_standard.sh +++ b/scripts/ci_test_standard.sh @@ -6,6 +6,8 @@ cp tests/contract_with_toplevel.sol "$DIR" cp tests/toplevel.sol "$DIR" cd "$DIR" || exit 255 +solc-select use 0.8.0 --always-install + crytic-compile contract_with_toplevel.sol --export-format archive if [ $? -ne 0 ]