cleanup and formatting

pull/2099/head
alpharush 1 year ago
parent 9fdc7dc228
commit 16140f29c8
  1. 45
      slither/core/declarations/solidity_variables.py
  2. 3
      slither/vyper_parsing/ast/types.py
  3. 6
      slither/vyper_parsing/declarations/struct.py
  4. 7
      slither/vyper_parsing/variables/event_variable.py
  5. 4
      slither/vyper_parsing/vyper_compilation_unit.py
  6. 3
      tests/unit/core/test_source_mapping.py

@ -40,7 +40,6 @@ SOLIDITY_VARIABLES_COMPOSED = {
"chain.id": "uint256",
"block.prevhash": "bytes32",
"self.balance": "uint256",
}
SOLIDITY_FUNCTIONS: Dict[str, List[str]] = {
@ -89,30 +88,30 @@ SOLIDITY_FUNCTIONS: Dict[str, List[str]] = {
"code(address)": ["bytes"],
"codehash(address)": ["bytes32"],
# Vyper
"create_from_blueprint()":[],
"empty()":[],
"convert()":[], # TODO make type conversion
"len()":["uint256"],
"method_id()":[],
"create_from_blueprint()": [],
"empty()": [],
"convert()": [], # TODO make type conversion
"len()": ["uint256"],
"method_id()": [],
"unsafe_sub()": [],
"unsafe_add()": [],
"unsafe_div()":[],
"unsafe_mul()":[],
"pow_mod256()":[],
"max_value()":[],
"min_value()":[],
"concat()":[],
"ecrecover()":[],
"isqrt()":[],
"range()":[],
"min()":[],
"max()":[],
"shift()":[],
"abs()":[],
"raw_call()":["bool", "bytes32"],
"_abi_encode()":[],
"slice()":[],
"uint2str()":["string"],
"unsafe_div()": [],
"unsafe_mul()": [],
"pow_mod256()": [],
"max_value()": [],
"min_value()": [],
"concat()": [],
"ecrecover()": [],
"isqrt()": [],
"range()": [],
"min()": [],
"max()": [],
"shift()": [],
"abs()": [],
"raw_call()": ["bool", "bytes32"],
"_abi_encode()": [],
"slice()": [],
"uint2str()": ["string"],
}

@ -85,9 +85,6 @@ class Index(ASTNode):
value: ASTNode
# TODO CONSTANT?
@dataclass
class Bytes(ASTNode):
value: bytes

@ -7,17 +7,15 @@ from slither.vyper_parsing.ast.types import StructDef, AnnAssign
class StructVyper:
def __init__( # pylint: disable=too-many-arguments
def __init__(
self,
st: Structure,
struct: StructDef,
) -> None:
print(struct)
self._structure = st
st.name = struct.name
# st.canonical_name = canonicalName
st.canonical_name = struct.name + self._structure.contract.name
self._elemsNotParsed: List[AnnAssign] = struct.body

@ -10,8 +10,11 @@ class EventVariableVyper:
print(variable_data)
self._variable = variable
self._variable.name = variable_data.target.id
if isinstance(variable_data.annotation, Call) and variable_data.annotation.func.id == "indexed":
self._variable.indexed = True
if (
isinstance(variable_data.annotation, Call)
and variable_data.annotation.func.id == "indexed"
):
self._variable.indexed = True
else:
self._variable.indexed = False
self._elem_to_parse = variable_data.annotation

@ -52,12 +52,12 @@ class VyperCompilationUnit:
if not self._parsed:
raise SlitherException("Parse the contract before running analyses")
for contract, contract_parser in self._underlying_contract_to_parser.items():
for contract_parser in self._underlying_contract_to_parser.values():
# State variables are analyzed for all contracts because interfaces may
# reference them, specifically, constants.
contract_parser.analyze_state_variables()
for contract, contract_parser in self._underlying_contract_to_parser.items():
for contract_parser in self._underlying_contract_to_parser.values():
contract_parser.analyze()
self._convert_to_slithir()

@ -114,6 +114,7 @@ def test_references_user_defined_types_when_casting(solc_binary_path):
lines = _sort_references_lines(a.references)
assert lines == [12, 18]
def test_references_self_identifier():
"""
Tests that shadowing state variables with local variables does not affect references.
@ -125,4 +126,4 @@ def test_references_self_identifier():
a = contracts[0].state_variables[0]
assert len(a.references) == 1
lines = _sort_references_lines(a.references)
assert lines == [4]
assert lines == [4]

Loading…
Cancel
Save