web3 7.0.0b3__py3-none-any.whl → 7.0.0b5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ens/_normalization.py +1 -3
- ens/async_ens.py +12 -9
- ens/contract_data.py +2 -2
- ens/ens.py +8 -5
- ens/exceptions.py +19 -27
- ens/specs/nf.json +1 -1
- ens/specs/normalization_spec.json +1 -1
- ens/utils.py +17 -10
- web3/__init__.py +2 -7
- web3/_utils/abi.py +30 -29
- web3/_utils/async_transactions.py +7 -4
- web3/_utils/blocks.py +6 -2
- web3/_utils/caching.py +7 -3
- web3/_utils/compat/__init__.py +0 -3
- web3/_utils/contract_sources/compile_contracts.py +1 -1
- web3/_utils/contracts.py +17 -17
- web3/_utils/datatypes.py +5 -1
- web3/_utils/decorators.py +6 -1
- web3/_utils/empty.py +1 -1
- web3/_utils/encoding.py +15 -10
- web3/_utils/error_formatters_utils.py +5 -3
- web3/_utils/events.py +38 -36
- web3/_utils/fee_utils.py +2 -4
- web3/_utils/filters.py +23 -18
- web3/_utils/formatters.py +2 -2
- web3/_utils/math.py +3 -2
- web3/_utils/method_formatters.py +24 -28
- web3/_utils/module.py +2 -1
- web3/_utils/module_testing/__init__.py +0 -3
- web3/_utils/module_testing/eth_module.py +494 -432
- web3/_utils/module_testing/module_testing_utils.py +1 -3
- web3/_utils/module_testing/utils.py +14 -7
- web3/_utils/normalizers.py +3 -3
- web3/_utils/request.py +4 -4
- web3/_utils/rpc_abi.py +5 -19
- web3/_utils/threads.py +8 -7
- web3/_utils/transactions.py +14 -12
- web3/_utils/type_conversion.py +5 -1
- web3/_utils/validation.py +12 -10
- web3/contract/async_contract.py +23 -18
- web3/contract/base_contract.py +69 -74
- web3/contract/contract.py +25 -19
- web3/contract/utils.py +11 -6
- web3/datastructures.py +22 -12
- web3/eth/async_eth.py +38 -32
- web3/eth/base_eth.py +7 -3
- web3/eth/eth.py +20 -15
- web3/exceptions.py +83 -78
- web3/gas_strategies/time_based.py +2 -4
- web3/geth.py +1 -191
- web3/main.py +6 -6
- web3/manager.py +128 -68
- web3/method.py +13 -5
- web3/middleware/base.py +4 -2
- web3/middleware/filter.py +45 -23
- web3/middleware/formatting.py +6 -3
- web3/middleware/names.py +4 -1
- web3/middleware/signing.py +8 -4
- web3/middleware/stalecheck.py +2 -1
- web3/providers/eth_tester/defaults.py +1 -49
- web3/providers/eth_tester/main.py +41 -15
- web3/providers/eth_tester/middleware.py +13 -9
- web3/providers/ipc.py +7 -3
- web3/providers/persistent/async_ipc.py +6 -7
- web3/providers/persistent/persistent.py +11 -1
- web3/providers/persistent/request_processor.py +7 -7
- web3/providers/persistent/websocket.py +3 -3
- web3/providers/rpc/async_rpc.py +24 -7
- web3/providers/rpc/rpc.py +30 -17
- web3/providers/rpc/utils.py +1 -10
- web3/testing.py +4 -4
- web3/tools/benchmark/main.py +13 -9
- web3/tools/benchmark/node.py +2 -8
- web3/tools/benchmark/utils.py +1 -1
- web3/tracing.py +9 -5
- web3/types.py +20 -23
- {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/METADATA +13 -28
- {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/RECORD +81 -82
- web3/_utils/module_testing/go_ethereum_personal_module.py +0 -300
- {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/LICENSE +0 -0
- {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/WHEEL +0 -0
- {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/top_level.txt +0 -0
web3/exceptions.py
CHANGED
|
@@ -13,6 +13,7 @@ from eth_utils import (
|
|
|
13
13
|
|
|
14
14
|
from web3.types import (
|
|
15
15
|
BlockData,
|
|
16
|
+
RPCResponse,
|
|
16
17
|
)
|
|
17
18
|
|
|
18
19
|
|
|
@@ -30,6 +31,8 @@ class Web3Exception(Exception):
|
|
|
30
31
|
# deal with other exceptions
|
|
31
32
|
"""
|
|
32
33
|
|
|
34
|
+
user_message: Optional[str] = None
|
|
35
|
+
|
|
33
36
|
def __init__(
|
|
34
37
|
self,
|
|
35
38
|
*args: Any,
|
|
@@ -41,6 +44,40 @@ class Web3Exception(Exception):
|
|
|
41
44
|
self.user_message = user_message
|
|
42
45
|
|
|
43
46
|
|
|
47
|
+
class Web3AssertionError(Web3Exception, AssertionError):
|
|
48
|
+
"""
|
|
49
|
+
A web3.py exception wrapper for `AssertionError`, for better control over
|
|
50
|
+
exception handling.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class Web3ValueError(Web3Exception, ValueError):
|
|
55
|
+
"""
|
|
56
|
+
A web3.py exception wrapper for `ValueError`, for better control over
|
|
57
|
+
exception handling.
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class Web3AttributeError(Web3Exception, AttributeError):
|
|
62
|
+
"""
|
|
63
|
+
A web3.py exception wrapper for `AttributeError`, for better control over
|
|
64
|
+
exception handling.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class Web3TypeError(Web3Exception, TypeError):
|
|
69
|
+
"""
|
|
70
|
+
A web3.py exception wrapper for `TypeError`, for better control over
|
|
71
|
+
exception handling.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class MethodNotSupported(Web3Exception):
|
|
76
|
+
"""
|
|
77
|
+
Raised when a method is not supported by the provider.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
|
|
44
81
|
class BadFunctionCallOutput(Web3Exception):
|
|
45
82
|
"""
|
|
46
83
|
We failed to decode ABI output.
|
|
@@ -48,24 +85,18 @@ class BadFunctionCallOutput(Web3Exception):
|
|
|
48
85
|
Most likely ABI mismatch.
|
|
49
86
|
"""
|
|
50
87
|
|
|
51
|
-
pass
|
|
52
88
|
|
|
53
|
-
|
|
54
|
-
class BlockNumberOutofRange(Web3Exception):
|
|
89
|
+
class BlockNumberOutOfRange(Web3Exception):
|
|
55
90
|
"""
|
|
56
91
|
block_identifier passed does not match known block.
|
|
57
92
|
"""
|
|
58
93
|
|
|
59
|
-
pass
|
|
60
|
-
|
|
61
94
|
|
|
62
95
|
class ProviderConnectionError(Web3Exception):
|
|
63
96
|
"""
|
|
64
97
|
Raised when unable to connect to a provider
|
|
65
98
|
"""
|
|
66
99
|
|
|
67
|
-
pass
|
|
68
|
-
|
|
69
100
|
|
|
70
101
|
class CannotHandleRequest(Web3Exception):
|
|
71
102
|
"""
|
|
@@ -73,16 +104,12 @@ class CannotHandleRequest(Web3Exception):
|
|
|
73
104
|
that the manager should proceed to the next provider.
|
|
74
105
|
"""
|
|
75
106
|
|
|
76
|
-
pass
|
|
77
|
-
|
|
78
107
|
|
|
79
108
|
class TooManyRequests(Web3Exception):
|
|
80
109
|
"""
|
|
81
110
|
Raised by a provider to signal that too many requests have been made consecutively.
|
|
82
111
|
"""
|
|
83
112
|
|
|
84
|
-
pass
|
|
85
|
-
|
|
86
113
|
|
|
87
114
|
class MultipleFailedRequests(Web3Exception):
|
|
88
115
|
"""
|
|
@@ -90,16 +117,12 @@ class MultipleFailedRequests(Web3Exception):
|
|
|
90
117
|
(or similar) data have failed.
|
|
91
118
|
"""
|
|
92
119
|
|
|
93
|
-
pass
|
|
94
|
-
|
|
95
120
|
|
|
96
121
|
class InvalidAddress(Web3Exception):
|
|
97
122
|
"""
|
|
98
123
|
The supplied address does not have a valid checksum, as defined in EIP-55
|
|
99
124
|
"""
|
|
100
125
|
|
|
101
|
-
pass
|
|
102
|
-
|
|
103
126
|
|
|
104
127
|
class NameNotFound(Web3Exception):
|
|
105
128
|
"""
|
|
@@ -107,8 +130,6 @@ class NameNotFound(Web3Exception):
|
|
|
107
130
|
does not resolve to an address.
|
|
108
131
|
"""
|
|
109
132
|
|
|
110
|
-
pass
|
|
111
|
-
|
|
112
133
|
|
|
113
134
|
class StaleBlockchain(Web3Exception):
|
|
114
135
|
"""
|
|
@@ -138,8 +159,6 @@ class MismatchedABI(Web3Exception):
|
|
|
138
159
|
attempt is made to access a function/event that does not exist in the ABI.
|
|
139
160
|
"""
|
|
140
161
|
|
|
141
|
-
pass
|
|
142
|
-
|
|
143
162
|
|
|
144
163
|
class ABIEventFunctionNotFound(AttributeError, MismatchedABI):
|
|
145
164
|
"""
|
|
@@ -147,8 +166,6 @@ class ABIEventFunctionNotFound(AttributeError, MismatchedABI):
|
|
|
147
166
|
that does not exist in the ABI.
|
|
148
167
|
"""
|
|
149
168
|
|
|
150
|
-
pass
|
|
151
|
-
|
|
152
169
|
|
|
153
170
|
class ABIFunctionNotFound(AttributeError, MismatchedABI):
|
|
154
171
|
"""
|
|
@@ -156,56 +173,43 @@ class ABIFunctionNotFound(AttributeError, MismatchedABI):
|
|
|
156
173
|
that does not exist in the ABI.
|
|
157
174
|
"""
|
|
158
175
|
|
|
159
|
-
pass
|
|
160
|
-
|
|
161
176
|
|
|
162
177
|
class FallbackNotFound(Web3Exception):
|
|
163
178
|
"""
|
|
164
179
|
Raised when fallback function doesn't exist in contract.
|
|
165
180
|
"""
|
|
166
181
|
|
|
167
|
-
pass
|
|
168
182
|
|
|
169
|
-
|
|
170
|
-
class Web3ValidationError(Web3Exception, ValidationError):
|
|
183
|
+
# type ignored because subclassing ValidationError which has type Any
|
|
184
|
+
class Web3ValidationError(Web3Exception, ValidationError): # type: ignore[misc]
|
|
171
185
|
"""
|
|
172
186
|
Raised when a supplied value is invalid.
|
|
173
187
|
"""
|
|
174
188
|
|
|
175
|
-
pass
|
|
176
|
-
|
|
177
189
|
|
|
178
190
|
class ExtraDataLengthError(Web3ValidationError):
|
|
179
191
|
"""
|
|
180
192
|
Raised when an RPC call returns >32 bytes of extraData.
|
|
181
193
|
"""
|
|
182
194
|
|
|
183
|
-
pass
|
|
184
|
-
|
|
185
195
|
|
|
186
196
|
class NoABIFunctionsFound(Web3Exception):
|
|
187
197
|
"""
|
|
188
198
|
Raised when an ABI is present, but doesn't contain any functions.
|
|
189
199
|
"""
|
|
190
200
|
|
|
191
|
-
pass
|
|
192
|
-
|
|
193
201
|
|
|
194
202
|
class NoABIFound(Web3Exception):
|
|
195
203
|
"""
|
|
196
204
|
Raised when no ABI is present.
|
|
197
205
|
"""
|
|
198
206
|
|
|
199
|
-
pass
|
|
200
|
-
|
|
201
207
|
|
|
202
208
|
class NoABIEventsFound(Web3Exception):
|
|
203
209
|
"""
|
|
204
210
|
Raised when an ABI doesn't contain any events.
|
|
205
211
|
"""
|
|
206
212
|
|
|
207
|
-
pass
|
|
208
|
-
|
|
209
213
|
|
|
210
214
|
class InsufficientData(Web3Exception):
|
|
211
215
|
"""
|
|
@@ -213,8 +217,6 @@ class InsufficientData(Web3Exception):
|
|
|
213
217
|
complete a calculation
|
|
214
218
|
"""
|
|
215
219
|
|
|
216
|
-
pass
|
|
217
|
-
|
|
218
220
|
|
|
219
221
|
class TimeExhausted(Web3Exception):
|
|
220
222
|
"""
|
|
@@ -222,57 +224,24 @@ class TimeExhausted(Web3Exception):
|
|
|
222
224
|
result within a specified timeout.
|
|
223
225
|
"""
|
|
224
226
|
|
|
225
|
-
pass
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
class TransactionNotFound(Web3Exception):
|
|
229
|
-
"""
|
|
230
|
-
Raised when a tx hash used to lookup a tx in a jsonrpc call cannot be found.
|
|
231
|
-
"""
|
|
232
|
-
|
|
233
|
-
pass
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
class TransactionIndexingInProgress(Web3Exception):
|
|
237
|
-
"""
|
|
238
|
-
Raised when a transaction receipt is not yet available due to transaction indexing
|
|
239
|
-
still being in progress.
|
|
240
|
-
"""
|
|
241
|
-
|
|
242
|
-
pass
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
class BlockNotFound(Web3Exception):
|
|
246
|
-
"""
|
|
247
|
-
Raised when the block id used to lookup a block in a jsonrpc call cannot be found.
|
|
248
|
-
"""
|
|
249
|
-
|
|
250
|
-
pass
|
|
251
|
-
|
|
252
227
|
|
|
253
228
|
class InfuraProjectIdNotFound(Web3Exception):
|
|
254
229
|
"""
|
|
255
230
|
Raised when there is no Infura Project Id set.
|
|
256
231
|
"""
|
|
257
232
|
|
|
258
|
-
pass
|
|
259
|
-
|
|
260
233
|
|
|
261
234
|
class LogTopicError(Web3Exception):
|
|
262
235
|
"""
|
|
263
236
|
Raised when the number of log topics is mismatched.
|
|
264
237
|
"""
|
|
265
238
|
|
|
266
|
-
pass
|
|
267
|
-
|
|
268
239
|
|
|
269
240
|
class InvalidEventABI(Web3Exception):
|
|
270
241
|
"""
|
|
271
242
|
Raised when the event ABI is invalid.
|
|
272
243
|
"""
|
|
273
244
|
|
|
274
|
-
pass
|
|
275
|
-
|
|
276
245
|
|
|
277
246
|
class ContractLogicError(Web3Exception):
|
|
278
247
|
"""
|
|
@@ -294,16 +263,12 @@ class ContractCustomError(ContractLogicError):
|
|
|
294
263
|
Raised on a contract revert custom error
|
|
295
264
|
"""
|
|
296
265
|
|
|
297
|
-
pass
|
|
298
|
-
|
|
299
266
|
|
|
300
267
|
class ContractPanicError(ContractLogicError):
|
|
301
268
|
"""
|
|
302
269
|
Raised when a contract reverts with Panic, as of Solidity 0.8.0
|
|
303
270
|
"""
|
|
304
271
|
|
|
305
|
-
pass
|
|
306
|
-
|
|
307
272
|
|
|
308
273
|
class OffchainLookup(ContractLogicError):
|
|
309
274
|
"""
|
|
@@ -341,12 +306,52 @@ class BadResponseFormat(Web3Exception):
|
|
|
341
306
|
Raised when a JSON-RPC response comes back in an unexpected format
|
|
342
307
|
"""
|
|
343
308
|
|
|
344
|
-
|
|
309
|
+
|
|
310
|
+
class Web3RPCError(Web3Exception):
|
|
311
|
+
"""
|
|
312
|
+
Raised when a JSON-RPC response contains an error field.
|
|
313
|
+
"""
|
|
314
|
+
|
|
315
|
+
def __init__(
|
|
316
|
+
self,
|
|
317
|
+
message: str,
|
|
318
|
+
rpc_response: Optional[RPCResponse] = None,
|
|
319
|
+
user_message: Optional[str] = None,
|
|
320
|
+
) -> None:
|
|
321
|
+
if user_message is None:
|
|
322
|
+
user_message = (
|
|
323
|
+
"An RPC error was returned by the node. Check the message provided in "
|
|
324
|
+
"the error and any available logs for more information."
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
super().__init__(
|
|
328
|
+
message,
|
|
329
|
+
user_message=user_message,
|
|
330
|
+
)
|
|
331
|
+
self.message = message
|
|
332
|
+
self.rpc_response = rpc_response
|
|
345
333
|
|
|
346
334
|
|
|
347
|
-
class MethodUnavailable(
|
|
335
|
+
class MethodUnavailable(Web3RPCError):
|
|
348
336
|
"""
|
|
349
337
|
Raised when the method is not available on the node
|
|
350
338
|
"""
|
|
351
339
|
|
|
352
|
-
|
|
340
|
+
|
|
341
|
+
class TransactionNotFound(Web3RPCError):
|
|
342
|
+
"""
|
|
343
|
+
Raised when a tx hash used to look up a tx in a jsonrpc call cannot be found.
|
|
344
|
+
"""
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
class TransactionIndexingInProgress(Web3RPCError):
|
|
348
|
+
"""
|
|
349
|
+
Raised when a transaction receipt is not yet available due to transaction indexing
|
|
350
|
+
still being in progress.
|
|
351
|
+
"""
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
class BlockNotFound(Web3RPCError):
|
|
355
|
+
"""
|
|
356
|
+
Raised when the block id used to look up a block in a jsonrpc call cannot be found.
|
|
357
|
+
"""
|
|
@@ -84,8 +84,7 @@ def _get_raw_miner_data(
|
|
|
84
84
|
latest = w3.eth.get_block("latest", full_transactions=True)
|
|
85
85
|
|
|
86
86
|
for transaction in latest["transactions"]:
|
|
87
|
-
|
|
88
|
-
yield (latest["miner"], latest["hash"], transaction["gasPrice"]) # type: ignore
|
|
87
|
+
yield (latest["miner"], latest["hash"], transaction["gasPrice"])
|
|
89
88
|
|
|
90
89
|
block = latest
|
|
91
90
|
|
|
@@ -97,8 +96,7 @@ def _get_raw_miner_data(
|
|
|
97
96
|
# block numbers to make caching the data easier to implement.
|
|
98
97
|
block = w3.eth.get_block(block["parentHash"], full_transactions=True)
|
|
99
98
|
for transaction in block["transactions"]:
|
|
100
|
-
|
|
101
|
-
yield (block["miner"], block["hash"], transaction["gasPrice"]) # type: ignore # noqa: E501
|
|
99
|
+
yield (block["miner"], block["hash"], transaction["gasPrice"])
|
|
102
100
|
|
|
103
101
|
|
|
104
102
|
def _aggregate_miner_data(
|
web3/geth.py
CHANGED
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
from typing import (
|
|
2
|
-
Any,
|
|
3
2
|
Awaitable,
|
|
4
3
|
Callable,
|
|
5
|
-
Dict,
|
|
6
4
|
List,
|
|
7
5
|
Optional,
|
|
6
|
+
Protocol,
|
|
8
7
|
Tuple,
|
|
9
8
|
)
|
|
10
9
|
|
|
11
|
-
from eth_typing.encoding import (
|
|
12
|
-
HexStr,
|
|
13
|
-
)
|
|
14
10
|
from eth_typing.evm import (
|
|
15
11
|
ChecksumAddress,
|
|
16
12
|
)
|
|
17
|
-
from hexbytes.main import (
|
|
18
|
-
HexBytes,
|
|
19
|
-
)
|
|
20
13
|
|
|
21
|
-
from web3._utils.compat import (
|
|
22
|
-
Protocol,
|
|
23
|
-
)
|
|
24
14
|
from web3._utils.rpc_abi import (
|
|
25
15
|
RPC,
|
|
26
16
|
)
|
|
@@ -33,10 +23,8 @@ from web3.module import (
|
|
|
33
23
|
)
|
|
34
24
|
from web3.types import (
|
|
35
25
|
EnodeURI,
|
|
36
|
-
GethWallet,
|
|
37
26
|
NodeInfo,
|
|
38
27
|
Peer,
|
|
39
|
-
TxParams,
|
|
40
28
|
TxPoolContent,
|
|
41
29
|
TxPoolInspect,
|
|
42
30
|
TxPoolStatus,
|
|
@@ -53,66 +41,6 @@ class UnlockAccountWrapper(Protocol):
|
|
|
53
41
|
pass
|
|
54
42
|
|
|
55
43
|
|
|
56
|
-
class GethPersonal(Module):
|
|
57
|
-
"""
|
|
58
|
-
https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-personal
|
|
59
|
-
"""
|
|
60
|
-
|
|
61
|
-
is_async = False
|
|
62
|
-
|
|
63
|
-
ec_recover: Method[Callable[[str, HexStr], ChecksumAddress]] = Method(
|
|
64
|
-
RPC.personal_ecRecover,
|
|
65
|
-
mungers=[default_root_munger],
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
import_raw_key: Method[Callable[[str, str], ChecksumAddress]] = Method(
|
|
69
|
-
RPC.personal_importRawKey,
|
|
70
|
-
mungers=[default_root_munger],
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
list_accounts: Method[Callable[[], List[ChecksumAddress]]] = Method(
|
|
74
|
-
RPC.personal_listAccounts,
|
|
75
|
-
is_property=True,
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
list_wallets: Method[Callable[[], List[GethWallet]]] = Method(
|
|
79
|
-
RPC.personal_listWallets,
|
|
80
|
-
is_property=True,
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
send_transaction: Method[Callable[[TxParams, str], HexBytes]] = Method(
|
|
84
|
-
RPC.personal_sendTransaction,
|
|
85
|
-
mungers=[default_root_munger],
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
sign: Method[Callable[[str, ChecksumAddress, Optional[str]], HexStr]] = Method(
|
|
89
|
-
RPC.personal_sign,
|
|
90
|
-
mungers=[default_root_munger],
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
sign_typed_data: Method[
|
|
94
|
-
Callable[[Dict[str, Any], ChecksumAddress, str], HexStr]
|
|
95
|
-
] = Method(
|
|
96
|
-
RPC.personal_signTypedData,
|
|
97
|
-
mungers=[default_root_munger],
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
new_account: Method[Callable[[str], ChecksumAddress]] = Method(
|
|
101
|
-
RPC.personal_newAccount,
|
|
102
|
-
mungers=[default_root_munger],
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
lock_account: Method[Callable[[ChecksumAddress], bool]] = Method(
|
|
106
|
-
RPC.personal_lockAccount,
|
|
107
|
-
mungers=[default_root_munger],
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
unlock_account: Method[UnlockAccountWrapper] = Method(
|
|
111
|
-
RPC.personal_unlockAccount,
|
|
112
|
-
mungers=[default_root_munger],
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
|
|
116
44
|
class GethTxPool(Module):
|
|
117
45
|
"""
|
|
118
46
|
https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool
|
|
@@ -206,7 +134,6 @@ class GethAdmin(Module):
|
|
|
206
134
|
|
|
207
135
|
|
|
208
136
|
class Geth(Module):
|
|
209
|
-
personal: GethPersonal
|
|
210
137
|
admin: GethAdmin
|
|
211
138
|
txpool: GethTxPool
|
|
212
139
|
|
|
@@ -334,125 +261,8 @@ class AsyncGethAdmin(Module):
|
|
|
334
261
|
return await self._stop_ws()
|
|
335
262
|
|
|
336
263
|
|
|
337
|
-
class AsyncGethPersonal(Module):
|
|
338
|
-
"""
|
|
339
|
-
https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-personal
|
|
340
|
-
"""
|
|
341
|
-
|
|
342
|
-
is_async = True
|
|
343
|
-
|
|
344
|
-
# ec_recover
|
|
345
|
-
|
|
346
|
-
_ec_recover: Method[Callable[[str, HexStr], Awaitable[ChecksumAddress]]] = Method(
|
|
347
|
-
RPC.personal_ecRecover,
|
|
348
|
-
mungers=[default_root_munger],
|
|
349
|
-
)
|
|
350
|
-
|
|
351
|
-
async def ec_recover(self, message: str, signature: HexStr) -> ChecksumAddress:
|
|
352
|
-
return await self._ec_recover(message, signature)
|
|
353
|
-
|
|
354
|
-
# import_raw_key
|
|
355
|
-
|
|
356
|
-
_import_raw_key: Method[Callable[[str, str], Awaitable[ChecksumAddress]]] = Method(
|
|
357
|
-
RPC.personal_importRawKey,
|
|
358
|
-
mungers=[default_root_munger],
|
|
359
|
-
)
|
|
360
|
-
|
|
361
|
-
async def import_raw_key(
|
|
362
|
-
self, private_key: str, passphrase: str
|
|
363
|
-
) -> ChecksumAddress:
|
|
364
|
-
return await self._import_raw_key(private_key, passphrase)
|
|
365
|
-
|
|
366
|
-
# list_accounts and list_wallets
|
|
367
|
-
|
|
368
|
-
_list_accounts: Method[Callable[[], Awaitable[List[ChecksumAddress]]]] = Method(
|
|
369
|
-
RPC.personal_listAccounts,
|
|
370
|
-
is_property=True,
|
|
371
|
-
)
|
|
372
|
-
|
|
373
|
-
_list_wallets: Method[Callable[[], Awaitable[List[GethWallet]]]] = Method(
|
|
374
|
-
RPC.personal_listWallets,
|
|
375
|
-
is_property=True,
|
|
376
|
-
)
|
|
377
|
-
|
|
378
|
-
async def list_accounts(self) -> List[ChecksumAddress]:
|
|
379
|
-
return await self._list_accounts()
|
|
380
|
-
|
|
381
|
-
async def list_wallets(self) -> List[GethWallet]:
|
|
382
|
-
return await self._list_wallets()
|
|
383
|
-
|
|
384
|
-
# send_transaction
|
|
385
|
-
|
|
386
|
-
_send_transaction: Method[Callable[[TxParams, str], Awaitable[HexBytes]]] = Method(
|
|
387
|
-
RPC.personal_sendTransaction,
|
|
388
|
-
mungers=[default_root_munger],
|
|
389
|
-
)
|
|
390
|
-
|
|
391
|
-
async def send_transaction(
|
|
392
|
-
self, transaction: TxParams, passphrase: str
|
|
393
|
-
) -> HexBytes:
|
|
394
|
-
return await self._send_transaction(transaction, passphrase)
|
|
395
|
-
|
|
396
|
-
# sign and sign_typed_data
|
|
397
|
-
|
|
398
|
-
_sign: Method[
|
|
399
|
-
Callable[[str, ChecksumAddress, Optional[str]], Awaitable[HexStr]]
|
|
400
|
-
] = Method(
|
|
401
|
-
RPC.personal_sign,
|
|
402
|
-
mungers=[default_root_munger],
|
|
403
|
-
)
|
|
404
|
-
|
|
405
|
-
_sign_typed_data: Method[
|
|
406
|
-
Callable[[Dict[str, Any], ChecksumAddress, str], Awaitable[HexStr]]
|
|
407
|
-
] = Method(
|
|
408
|
-
RPC.personal_signTypedData,
|
|
409
|
-
mungers=[default_root_munger],
|
|
410
|
-
)
|
|
411
|
-
|
|
412
|
-
async def sign(
|
|
413
|
-
self, message: str, account: ChecksumAddress, passphrase: str
|
|
414
|
-
) -> HexStr:
|
|
415
|
-
return await self._sign(message, account, passphrase)
|
|
416
|
-
|
|
417
|
-
async def sign_typed_data(
|
|
418
|
-
self, message: Dict[str, Any], account: ChecksumAddress, passphrase: str
|
|
419
|
-
) -> HexStr:
|
|
420
|
-
return await self._sign_typed_data(message, account, passphrase)
|
|
421
|
-
|
|
422
|
-
# new_account, lock_account, and unlock_account
|
|
423
|
-
|
|
424
|
-
_new_account: Method[Callable[[str], Awaitable[ChecksumAddress]]] = Method(
|
|
425
|
-
RPC.personal_newAccount,
|
|
426
|
-
mungers=[default_root_munger],
|
|
427
|
-
)
|
|
428
|
-
|
|
429
|
-
_lock_account: Method[Callable[[ChecksumAddress], Awaitable[bool]]] = Method(
|
|
430
|
-
RPC.personal_lockAccount,
|
|
431
|
-
mungers=[default_root_munger],
|
|
432
|
-
)
|
|
433
|
-
|
|
434
|
-
_unlock_account: Method[
|
|
435
|
-
Callable[[ChecksumAddress, str, Optional[int]], Awaitable[bool]]
|
|
436
|
-
] = Method(
|
|
437
|
-
RPC.personal_unlockAccount,
|
|
438
|
-
mungers=[default_root_munger],
|
|
439
|
-
)
|
|
440
|
-
|
|
441
|
-
async def new_account(self, passphrase: str) -> ChecksumAddress:
|
|
442
|
-
return await self._new_account(passphrase)
|
|
443
|
-
|
|
444
|
-
async def lock_account(self, account: ChecksumAddress) -> bool:
|
|
445
|
-
return await self._lock_account(account)
|
|
446
|
-
|
|
447
|
-
async def unlock_account(
|
|
448
|
-
self, account: ChecksumAddress, passphrase: str, duration: Optional[int] = None
|
|
449
|
-
) -> bool:
|
|
450
|
-
return await self._unlock_account(account, passphrase, duration)
|
|
451
|
-
|
|
452
|
-
|
|
453
264
|
class AsyncGeth(Module):
|
|
454
265
|
is_async = True
|
|
455
266
|
|
|
456
|
-
personal: AsyncGethPersonal
|
|
457
267
|
admin: AsyncGethAdmin
|
|
458
268
|
txpool: AsyncGethTxPool
|
web3/main.py
CHANGED
|
@@ -84,14 +84,16 @@ from web3.eth import (
|
|
|
84
84
|
AsyncEth,
|
|
85
85
|
Eth,
|
|
86
86
|
)
|
|
87
|
+
from web3.exceptions import (
|
|
88
|
+
Web3TypeError,
|
|
89
|
+
Web3ValueError,
|
|
90
|
+
)
|
|
87
91
|
from web3.geth import (
|
|
88
92
|
AsyncGeth,
|
|
89
93
|
AsyncGethAdmin,
|
|
90
|
-
AsyncGethPersonal,
|
|
91
94
|
AsyncGethTxPool,
|
|
92
95
|
Geth,
|
|
93
96
|
GethAdmin,
|
|
94
|
-
GethPersonal,
|
|
95
97
|
GethTxPool,
|
|
96
98
|
)
|
|
97
99
|
from web3.manager import (
|
|
@@ -152,7 +154,6 @@ def get_async_default_modules() -> Dict[str, Union[Type[Module], Sequence[Any]]]
|
|
|
152
154
|
AsyncGeth,
|
|
153
155
|
{
|
|
154
156
|
"admin": AsyncGethAdmin,
|
|
155
|
-
"personal": AsyncGethPersonal,
|
|
156
157
|
"txpool": AsyncGethTxPool,
|
|
157
158
|
},
|
|
158
159
|
),
|
|
@@ -167,7 +168,6 @@ def get_default_modules() -> Dict[str, Union[Type[Module], Sequence[Any]]]:
|
|
|
167
168
|
Geth,
|
|
168
169
|
{
|
|
169
170
|
"admin": GethAdmin,
|
|
170
|
-
"personal": GethPersonal,
|
|
171
171
|
"txpool": GethTxPool,
|
|
172
172
|
},
|
|
173
173
|
),
|
|
@@ -283,7 +283,7 @@ class BaseWeb3:
|
|
|
283
283
|
input_bytes = to_bytes(primitive, hexstr=hexstr, text=text)
|
|
284
284
|
return eth_utils_keccak(input_bytes)
|
|
285
285
|
|
|
286
|
-
raise
|
|
286
|
+
raise Web3TypeError(
|
|
287
287
|
f"You called keccak with first arg {primitive!r} and keywords "
|
|
288
288
|
f"{{'text': {text!r}, 'hexstr': {hexstr!r}}}. You must call it with "
|
|
289
289
|
"one of these approaches: keccak(text='txt'), keccak(hexstr='0x747874'), "
|
|
@@ -304,7 +304,7 @@ class BaseWeb3:
|
|
|
304
304
|
and list of corresponding values -- `[20, [-1, 5, 0], True]`
|
|
305
305
|
"""
|
|
306
306
|
if len(abi_types) != len(values):
|
|
307
|
-
raise
|
|
307
|
+
raise Web3ValueError(
|
|
308
308
|
"Length mismatch between provided abi types and values. Got "
|
|
309
309
|
f"{len(abi_types)} types and {len(values)} values."
|
|
310
310
|
)
|