-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathevmole.pyi
78 lines (66 loc) · 2.83 KB
/
evmole.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from typing import List, Optional, Union
class Function:
"""
Represents a public smart contract function.
Attributes:
selector (str): Function selector as a 4-byte hex string without '0x' prefix (e.g., 'aabbccdd').
bytecode_offset (int): Starting byte offset within the EVM bytecode for the function body.
arguments (Optional[str]): Function argument types in canonical format (e.g., 'uint256,address[]').
None if arguments were not extracted
state_mutability (Optional[str]): Function's state mutability ('pure', 'view', 'payable', or 'nonpayable').
None if state mutability was not extracted
"""
selector: str
bytecode_offset: int
arguments: Optional[str]
state_mutability: Optional[str]
class StorageRecord:
"""
Represents a storage variable record in a smart contract's storage layout.
Attributes:
slot (str): Storage slot number as a hex string (e.g., '0', '1b').
offset (int): Byte offset within the storage slot (0-31).
type (str): Variable type (e.g., 'uint256', 'mapping(address => uint256)', 'bytes32').
reads (List[str]): List of function selectors that read from this storage location.
writes (List[str]): List of function selectors that write to this storage location.
"""
slot: str
offset: int
type: str
reads: List[str]
writes: List[str]
class Contract:
"""
Contains analyzed information about a smart contract.
Attributes:
functions (Optional[List[Function]]): List of detected contract functions.
None if no functions were extracted
storage (Optional[List[StorageRecord]]): List of contract storage records.
None if storage layout was not extracted
"""
functions: Optional[List[Function]]
storage: Optional[List[StorageRecord]]
def contract_info(
code: Union[bytes, str],
*,
selectors: bool = False,
arguments: bool = False,
state_mutability: bool = False,
storage: bool = False,
) -> Contract:
"""
Extracts information about a smart contract from its EVM bytecode.
Args:
code (Union[bytes, str]): Runtime bytecode as a hex string (with or without '0x' prefix)
or raw bytes.
selectors (bool, optional): When True, extracts function selectors. Defaults to False.
arguments (bool, optional): When True, extracts function arguments. Defaults to False.
state_mutability (bool, optional): When True, extracts function state mutability.
Defaults to False.
storage (bool, optional): When True, extracts the contract's storage layout.
Defaults to False.
Returns:
Contract: Object containing the requested smart contract information. Fields that
weren't requested to be extracted will be None.
"""
...