diff --git a/setup.py b/setup.py index 01d28b812..a2ab2b2e8 100644 --- a/setup.py +++ b/setup.py @@ -11,10 +11,12 @@ setup( install_requires=[ "prettytable>=0.7.2", "pysha3>=1.0.2", - #"crytic-compile>=0.1.13", + # "crytic-compile>=0.1.13", "crytic-compile", ], - dependency_links=["git+https://github.com/crytic/crytic-compile.git@dev-compilation-units#egg=crytic-compile"], + dependency_links=[ + "git+https://github.com/crytic/crytic-compile.git@dev-compilation-units#egg=crytic-compile" + ], license="AGPL-3.0", long_description=open("README.md").read(), entry_points={ diff --git a/slither/tools/flattening/flattening.py b/slither/tools/flattening/flattening.py index 13132938a..e900e4581 100644 --- a/slither/tools/flattening/flattening.py +++ b/slither/tools/flattening/flattening.py @@ -71,10 +71,11 @@ class Flattening: Set _use_abi_encorder_v2 :return: """ - for p in self._slither.pragma_directives: - if "ABIEncoderV2" in str(p.directive): - self._use_abi_encoder_v2 = True - return + for compilation_unit in self._slither.compilation_units: + for p in compilation_unit.pragma_directives: + if "ABIEncoderV2" in str(p.directive): + self._use_abi_encoder_v2 = True + return def _get_source_code( self, contract: Contract diff --git a/slither/tools/kspec_coverage/kspec_coverage.py b/slither/tools/kspec_coverage/kspec_coverage.py index 86b59be53..569a35cf1 100755 --- a/slither/tools/kspec_coverage/kspec_coverage.py +++ b/slither/tools/kspec_coverage/kspec_coverage.py @@ -9,5 +9,9 @@ def kspec_coverage(args): slither = Slither(contract, **vars(args)) + compilation_units = slither.compilation_units + if len(compilation_units) != 1: + print("Only single compilation unit supported") + return # Run the analysis on the Klab specs - run_analysis(args, slither, kspec) + run_analysis(args, compilation_units[0], kspec) diff --git a/tests/test_function.py b/tests/test_function.py index 273a9eab0..2a943e0ae 100644 --- a/tests/test_function.py +++ b/tests/test_function.py @@ -13,7 +13,8 @@ from slither.core.solidity_types.elementary_type import ElementaryType def test_functions(): # pylint: disable=too-many-statements slither = Slither("tests/test_function.sol") - functions = slither.contracts_as_dict["TestFunction"].available_functions_as_dict() + compilation_unit = slither.compilation_units[0] + functions = compilation_unit.contracts_as_dict["TestFunction"].available_functions_as_dict() f = functions["external_payable(uint256)"] assert f.name == "external_payable" @@ -243,7 +244,8 @@ def test_functions(): def test_function_can_send_eth(): slither = Slither("tests/test_function.sol") - functions = slither.contracts_as_dict["TestFunctionCanSendEth"].available_functions_as_dict() + compilation_unit = slither.compilation_units[0] + functions = compilation_unit.contracts_as_dict["TestFunctionCanSendEth"].available_functions_as_dict() assert functions["send_direct()"].can_send_eth() is True assert functions["transfer_direct()"].can_send_eth() is True