From e5c56a50dec61e7d8df2e4b08f36cc9c2070c846 Mon Sep 17 00:00:00 2001 From: devtooligan Date: Fri, 7 Jul 2023 12:37:07 -0700 Subject: [PATCH] fix: external calls --- slither/utils/martin.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/slither/utils/martin.py b/slither/utils/martin.py index ded8c0efa3..d4d1a3fb32 100644 --- a/slither/utils/martin.py +++ b/slither/utils/martin.py @@ -108,6 +108,7 @@ def update_abstractness(self) -> float: def update_coupling(self) -> Dict: dependencies = {} for contract in self.contracts: + external_calls = [] for func in contract.functions: high_level_calls = [ ir @@ -116,7 +117,23 @@ def update_coupling(self) -> Dict: if isinstance(ir, HighLevelCall) ] # convert irs to string with target function and contract name - external_calls = [h.destination.type.type.name for h in high_level_calls] + # Get the target contract name for each high level call + new_external_calls = [] + for high_level_call in high_level_calls: + if isinstance(high_level_call.destination.type, Contract): + new_external_call = high_level_call.destination.type.name + elif isinstance(high_level_call.destination.type, str): + new_external_call = high_level_call.destination.type + else: + if not hasattr(high_level_call.destination.type, "type"): + continue + if isinstance(high_level_call.destination.type.type, Contract): + new_external_call = high_level_call.destination.type.type.name + if isinstance(high_level_call.destination.type.type, str): + new_external_call = high_level_call.destination.type.type + print(new_external_call) + new_external_calls.append(new_external_call) + external_calls.extend(new_external_calls) dependencies[contract.name] = set(external_calls) dependents = {} for contract, deps in dependencies.items():