diff --git a/slither/core/slither_core.py b/slither/core/slither_core.py index c42503ca9..a67c68bc6 100644 --- a/slither/core/slither_core.py +++ b/slither/core/slither_core.py @@ -7,7 +7,7 @@ import json import re import math from collections import defaultdict -from typing import Optional, Dict, List, Set, Union +from typing import Optional, Dict, List, Set, Union, Tuple from crytic_compile import CryticCompile @@ -57,7 +57,7 @@ class SlitherCore(Context): self._contract_name_collisions = defaultdict(list) self._contract_with_missing_inheritance = set() - self._storage_layouts = {} + self._storage_layouts: Dict[str, Dict[str, Tuple[int, int]]] = {} ################################################################################### ################################################################################### @@ -380,6 +380,6 @@ class SlitherCore(Context): else: offset += size - def storage_layout_of(self, contract, var): + def storage_layout_of(self, contract, var) -> Tuple[int, int]: return self._storage_layouts[contract.name][var.canonical_name] # endregion diff --git a/slither/core/solidity_types/array_type.py b/slither/core/solidity_types/array_type.py index aba611b8c..966d1b537 100644 --- a/slither/core/solidity_types/array_type.py +++ b/slither/core/solidity_types/array_type.py @@ -1,4 +1,4 @@ -from typing import Optional +from typing import Optional, Tuple from slither.core.expressions import Literal from slither.core.expressions.expression import Expression @@ -38,7 +38,7 @@ class ArrayType(Type): return self._length_value @property - def storage_size(self): + def storage_size(self) -> Tuple[int, bool]: if self._length_value: elem_size, _ = self._type.storage_size return elem_size * int(self._length_value.value), True diff --git a/slither/core/solidity_types/elementary_type.py b/slither/core/solidity_types/elementary_type.py index 16c25e2f0..6f1d7a8b5 100644 --- a/slither/core/solidity_types/elementary_type.py +++ b/slither/core/solidity_types/elementary_type.py @@ -1,5 +1,5 @@ import itertools -from typing import Optional +from typing import Optional, Tuple from slither.core.solidity_types.type import Type @@ -173,7 +173,7 @@ class ElementaryType(Type): return None @property - def storage_size(self): + def storage_size(self) -> Tuple[int, bool]: if self._type == 'string' or self._type == 'bytes': return 32, True diff --git a/slither/core/solidity_types/function_type.py b/slither/core/solidity_types/function_type.py index a666a3521..6a96bf368 100644 --- a/slither/core/solidity_types/function_type.py +++ b/slither/core/solidity_types/function_type.py @@ -1,4 +1,4 @@ -from typing import List +from typing import List, Tuple from slither.core.solidity_types.type import Type from slither.core.variables.function_type_variable import FunctionTypeVariable @@ -27,7 +27,7 @@ class FunctionType(Type): return [x.type for x in self.return_values] @property - def storage_size(self): + def storage_size(self) -> Tuple[int, bool]: return 24, False def __str__(self): diff --git a/slither/core/solidity_types/mapping_type.py b/slither/core/solidity_types/mapping_type.py index 815f2dd78..e2f8ebe30 100644 --- a/slither/core/solidity_types/mapping_type.py +++ b/slither/core/solidity_types/mapping_type.py @@ -1,3 +1,5 @@ +from typing import Tuple + from slither.core.solidity_types.type import Type @@ -18,7 +20,7 @@ class MappingType(Type): return self._to @property - def storage_size(self): + def storage_size(self) -> Tuple[int, bool]: return 32, True def __str__(self): diff --git a/slither/core/solidity_types/user_defined_type.py b/slither/core/solidity_types/user_defined_type.py index dc3c1dd8c..4aed394e8 100644 --- a/slither/core/solidity_types/user_defined_type.py +++ b/slither/core/solidity_types/user_defined_type.py @@ -1,4 +1,4 @@ -from typing import Union, TYPE_CHECKING +from typing import Union, TYPE_CHECKING, Tuple import math from slither.core.solidity_types.type import Type @@ -24,7 +24,7 @@ class UserDefinedType(Type): return self._type @property - def storage_size(self): + def storage_size(self) -> Tuple[int, bool]: from slither.core.declarations.structure import Structure from slither.core.declarations.enum import Enum from slither.core.declarations.contract import Contract