Add `Contract.fallback_function` and `.receive_function` properties

pull/1757/head
webthethird 2 years ago
parent a6f6fc0bfa
commit af6727c561
  1. 21
      slither/core/declarations/contract.py

@ -89,6 +89,9 @@ class Contract(SourceMapping): # pylint: disable=too-many-public-methods
self._signatures: Optional[List[str]] = None self._signatures: Optional[List[str]] = None
self._signatures_declared: Optional[List[str]] = None self._signatures_declared: Optional[List[str]] = None
self._fallback_function: Optional["FunctionContract"] = None
self._receive_function: Optional["FunctionContract"] = None
self._is_upgradeable: Optional[bool] = None self._is_upgradeable: Optional[bool] = None
self._is_upgradeable_proxy: Optional[bool] = None self._is_upgradeable_proxy: Optional[bool] = None
self._upgradeable_version: Optional[str] = None self._upgradeable_version: Optional[str] = None
@ -649,6 +652,24 @@ class Contract(SourceMapping): # pylint: disable=too-many-public-methods
""" """
return self.functions_declared + self.modifiers_declared # type: ignore return self.functions_declared + self.modifiers_declared # type: ignore
@property
def fallback_function(self) -> Optional["FunctionContract"]:
if self._fallback_function is None:
for f in self.functions:
if f.is_fallback:
self._fallback_function = f
break
return self._fallback_function
@property
def receive_function(self) -> Optional["FunctionContract"]:
if self._receive_function is None:
for f in self.functions:
if f.is_receive:
self._receive_function = f
break
return self._receive_function
def available_elements_from_inheritances( def available_elements_from_inheritances(
self, self,
elements: Dict[str, "Function"], elements: Dict[str, "Function"],

Loading…
Cancel
Save