-
-
Notifications
You must be signed in to change notification settings - Fork 114
/
Copy pathproxy.py
187 lines (173 loc) · 4.97 KB
/
proxy.py
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
from etherscan.enums.actions_enum import ActionsEnum as actions
from etherscan.enums.fields_enum import FieldsEnum as fields
from etherscan.enums.modules_enum import ModulesEnum as modules
from etherscan.enums.tags_enum import TagsEnum as tags
class Proxy:
@staticmethod
def get_proxy_block_number() -> str:
url = (
f"{fields.MODULE}"
f"{modules.PROXY}"
f"{fields.ACTION}"
f"{actions.ETH_BLOCK_NUMBER}"
)
return url
@staticmethod
def get_proxy_block_by_number(tag: str) -> str:
url = (
f"{fields.MODULE}"
f"{modules.PROXY}"
f"{fields.ACTION}"
f"{actions.ETH_GET_BLOCK_BY_NUMBER}"
f"{fields.TAG}"
f"{tag}"
f"{fields.BOOLEAN}"
f"true"
)
return url
@staticmethod
def get_proxy_uncle_by_block_number_and_index(tag: str, index: str) -> str:
url = (
f"{fields.MODULE}"
f"{modules.PROXY}"
f"{fields.ACTION}"
f"{actions.ETH_GET_UNCLE_BY_BLOCK_NUMBER_AND_INDEX}"
f"{fields.TAG}"
f"{tag}"
f"{fields.INDEX}"
f"{index}"
)
return url
@staticmethod
def get_proxy_block_transaction_count_by_number(tag: str) -> str:
url = (
f"{fields.MODULE}"
f"{modules.PROXY}"
f"{fields.ACTION}"
f"{actions.ETH_GET_BLOCK_TRANSACTION_COUNT_BY_NUMBER}"
f"{fields.TAG}"
f"{tag}"
)
return url
@staticmethod
def get_proxy_transaction_by_hash(txhash: str) -> str:
url = (
f"{fields.MODULE}"
f"{modules.PROXY}"
f"{fields.ACTION}"
f"{actions.ETH_GET_TRANSACTION_BY_HASH}"
f"{fields.TXHASH}"
f"{txhash}"
)
return url
@staticmethod
def get_proxy_transaction_by_block_number_and_index(tag: str, index: str) -> str:
url = (
f"{fields.MODULE}"
f"{modules.PROXY}"
f"{fields.ACTION}"
f"{actions.ETH_GET_TRANSACTION_BY_BLOCK_NUMBER_AND_INDEX}"
f"{fields.TAG}"
f"{tag}"
f"{fields.INDEX}"
f"{index}"
)
return url
@staticmethod
def get_proxy_transaction_count(address: str) -> str:
url = (
f"{fields.MODULE}"
f"{modules.PROXY}"
f"{fields.ACTION}"
f"{actions.ETH_GET_TRANSACTION_COUNT}"
f"{fields.ADDRESS}"
f"{address}"
f"{fields.TAG}"
f"{tags.LATEST}"
)
return url
@staticmethod
def get_proxy_transaction_receipt(txhash: str) -> str:
url = (
f"{fields.MODULE}"
f"{modules.PROXY}"
f"{fields.ACTION}"
f"{actions.ETH_GET_TRANSACTION_RECEIPT}"
f"{fields.TXHASH}"
f"{txhash}"
)
return url
@staticmethod
def get_proxy_call(to: str, data: str) -> str:
url = (
f"{fields.MODULE}"
f"{modules.PROXY}"
f"{fields.ACTION}"
f"{actions.ETH_CALL}"
f"{fields.TO}"
f"{to}"
f"{fields.DATA}"
f"{data}"
f"{fields.TAG}"
f"{tags.LATEST}"
)
return url
@staticmethod
def get_proxy_code_at(address: str) -> str:
url = (
f"{fields.MODULE}"
f"{modules.PROXY}"
f"{fields.ACTION}"
f"{actions.ETH_GET_CODE}"
f"{fields.ADDRESS}"
f"{address}"
f"{fields.TAG}"
f"{tags.LATEST}"
)
return url
@staticmethod
def get_proxy_storage_position_at(position: str, address: str) -> str:
url = (
f"{fields.MODULE}"
f"{modules.PROXY}"
f"{fields.ACTION}"
f"{actions.ETH_GET_STORAGE_AT}"
f"{fields.ADDRESS}"
f"{address}"
f"{fields.POSITION}"
f"{position}"
f"{fields.TAG}"
f"{tags.LATEST}"
)
return url
@staticmethod
def get_proxy_gas_price() -> str:
# NOTE: Results are in WEI
url = (
f"{fields.MODULE}"
f"{modules.PROXY}"
f"{fields.ACTION}"
f"{actions.ETH_GAS_PRICE}"
)
return url
@staticmethod
def get_proxy_est_gas(
to: str, data: str, value: str, gas_price: str, gas: str
) -> str:
url = (
f"{fields.MODULE}"
f"{modules.PROXY}"
f"{fields.ACTION}"
f"{actions.ETH_ESTIMATE_GAS}"
f"{fields.DATA}"
f"{data}"
f"{fields.TO}"
f"{to}"
f"{fields.VALUE}"
f"{value}"
f"{fields.GAS_PRICE}"
f"{gas_price}"
f"{fields.GAS}"
f"{gas}"
)
return url