From 8c34abe1c32f8b8b03dc5f2e86c192367245c17e Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 15 Oct 2018 13:05:24 +0100 Subject: [PATCH] Add constructors to contract.all_functions_called --- slither/core/declarations/contract.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/slither/core/declarations/contract.py b/slither/core/declarations/contract.py index e7b80817c..59bef5a93 100644 --- a/slither/core/declarations/contract.py +++ b/slither/core/declarations/contract.py @@ -95,6 +95,10 @@ class Contract(ChildSlither, SourceMapping): def modifiers_as_dict(self): return self._modifiers + @property + def constructor(self): + return next((func for func in self.functions if func.is_constructor), None) + @property def functions(self): ''' @@ -116,7 +120,13 @@ class Contract(ChildSlither, SourceMapping): ''' all_calls = (f.all_internal_calls() for f in self.functions) all_calls = [item for sublist in all_calls for item in sublist] + self.functions - all_calls = set(all_calls) + all_calls = list(set(all_calls)) + + all_constructors = [c.constructor for c in self.inheritance] + all_constructors = list(set([c for c in all_constructors if c])) + + all_calls = set(all_calls+all_constructors) + return [c for c in all_calls if isinstance(c, Function)] def functions_as_dict(self):