web3 7.0.0b4__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.
web3/_utils/rpc_abi.py CHANGED
@@ -123,18 +123,6 @@ class RPC:
123
123
  net_peerCount = RPCEndpoint("net_peerCount")
124
124
  net_version = RPCEndpoint("net_version")
125
125
 
126
- # personal
127
- personal_ecRecover = RPCEndpoint("personal_ecRecover")
128
- personal_importRawKey = RPCEndpoint("personal_importRawKey")
129
- personal_listAccounts = RPCEndpoint("personal_listAccounts")
130
- personal_listWallets = RPCEndpoint("personal_listWallets")
131
- personal_lockAccount = RPCEndpoint("personal_lockAccount")
132
- personal_newAccount = RPCEndpoint("personal_newAccount")
133
- personal_sendTransaction = RPCEndpoint("personal_sendTransaction")
134
- personal_sign = RPCEndpoint("personal_sign")
135
- personal_signTypedData = RPCEndpoint("personal_signTypedData")
136
- personal_unlockAccount = RPCEndpoint("personal_unlockAccount")
137
-
138
126
  # testing
139
127
  testing_timeTravel = RPCEndpoint("testing_timeTravel")
140
128
 
@@ -211,12 +199,6 @@ RPC_ABIS: Dict[str, Union[Sequence[Any], Dict[str, str]]] = {
211
199
  "eth_signTypedData": ["address", None],
212
200
  "eth_submitHashrate": ["uint", "bytes32"],
213
201
  "eth_submitWork": ["bytes8", "bytes32", "bytes32"],
214
- # personal
215
- "personal_sendTransaction": TRANSACTION_PARAMS_ABIS,
216
- "personal_lockAccount": ["address"],
217
- "personal_unlockAccount": ["address", None, None],
218
- "personal_sign": [None, "address", None],
219
- "personal_signTypedData": [None, "address", None],
220
202
  "trace_call": TRANSACTION_PARAMS_ABIS,
221
203
  "trace_filter": TRACE_FILTER_PARAM_ABIS,
222
204
  }
@@ -111,8 +111,8 @@ class AsyncContractEvent(BaseContractEvent):
111
111
  async def get_logs(
112
112
  self,
113
113
  argument_filters: Optional[Dict[str, Any]] = None,
114
- fromBlock: Optional[BlockIdentifier] = None,
115
- toBlock: Optional[BlockIdentifier] = None,
114
+ from_block: Optional[BlockIdentifier] = None,
115
+ to_block: Optional[BlockIdentifier] = None,
116
116
  block_hash: Optional[HexBytes] = None,
117
117
  ) -> Awaitable[Iterable[EventData]]:
118
118
  """
@@ -135,7 +135,7 @@ class AsyncContractEvent(BaseContractEvent):
135
135
  from = max(mycontract.web3.eth.block_number - 10, 1)
136
136
  to = mycontract.web3.eth.block_number
137
137
 
138
- events = mycontract.events.Transfer.getLogs(fromBlock=from, toBlock=to)
138
+ events = mycontract.events.Transfer.getLogs(from_block=from, to_block=to)
139
139
 
140
140
  for e in events:
141
141
  print(e["args"]["from"],
@@ -165,10 +165,10 @@ class AsyncContractEvent(BaseContractEvent):
165
165
 
166
166
  :param argument_filters: Filter by argument values. Indexed arguments are
167
167
  filtered by the node while non-indexed arguments are filtered by the library.
168
- :param fromBlock: block number or "latest", defaults to "latest"
169
- :param toBlock: block number or "latest". Defaults to "latest"
168
+ :param from_block: block number or "latest", defaults to "latest"
169
+ :param to_block: block number or "latest". Defaults to "latest"
170
170
  :param block_hash: block hash. Cannot be set at the
171
- same time as fromBlock or toBlock
171
+ same time as ``from_block`` or ``to_block``
172
172
  :yield: Tuple of :class:`AttributeDict` instances
173
173
  """
174
174
  event_abi = self._get_event_abi()
@@ -183,7 +183,7 @@ class AsyncContractEvent(BaseContractEvent):
183
183
  )
184
184
 
185
185
  _filter_params = self._get_event_filter_params(
186
- event_abi, argument_filters, fromBlock, toBlock, block_hash
186
+ event_abi, argument_filters, from_block, to_block, block_hash
187
187
  )
188
188
  # call JSON-RPC API
189
189
  logs = await self.w3.eth.get_logs(_filter_params)
@@ -204,8 +204,8 @@ class AsyncContractEvent(BaseContractEvent):
204
204
  self,
205
205
  *, # PEP 3102
206
206
  argument_filters: Optional[Dict[str, Any]] = None,
207
- fromBlock: Optional[BlockIdentifier] = None,
208
- toBlock: BlockIdentifier = "latest",
207
+ from_block: Optional[BlockIdentifier] = None,
208
+ to_block: BlockIdentifier = "latest",
209
209
  address: Optional[ChecksumAddress] = None,
210
210
  topics: Optional[Sequence[Any]] = None,
211
211
  ) -> AsyncLogFilter:
@@ -215,8 +215,8 @@ class AsyncContractEvent(BaseContractEvent):
215
215
  filter_builder = AsyncEventFilterBuilder(self._get_event_abi(), self.w3.codec)
216
216
  self._set_up_filter_builder(
217
217
  argument_filters,
218
- fromBlock,
219
- toBlock,
218
+ from_block,
219
+ to_block,
220
220
  address,
221
221
  topics,
222
222
  filter_builder,
@@ -204,9 +204,9 @@ class BaseContractEvent:
204
204
  self,
205
205
  abi: ABIEvent,
206
206
  argument_filters: Optional[Dict[str, Any]] = None,
207
- fromBlock: Optional[BlockIdentifier] = None,
208
- toBlock: Optional[BlockIdentifier] = None,
209
- blockHash: Optional[HexBytes] = None,
207
+ from_block: Optional[BlockIdentifier] = None,
208
+ to_block: Optional[BlockIdentifier] = None,
209
+ block_hash: Optional[HexBytes] = None,
210
210
  ) -> FilterParams:
211
211
  if not self.address:
212
212
  raise Web3TypeError(
@@ -219,11 +219,12 @@ class BaseContractEvent:
219
219
 
220
220
  _filters = dict(**argument_filters)
221
221
 
222
- blkhash_set = blockHash is not None
223
- blknum_set = fromBlock is not None or toBlock is not None
222
+ blkhash_set = block_hash is not None
223
+ blknum_set = from_block is not None or to_block is not None
224
224
  if blkhash_set and blknum_set:
225
225
  raise Web3ValidationError(
226
- "blockHash cannot be set at the same time as fromBlock or toBlock"
226
+ "`block_hash` cannot be set at the same time as "
227
+ "`from_block` or `to_block`"
227
228
  )
228
229
 
229
230
  # Construct JSON-RPC raw filter presentation based on human readable
@@ -233,13 +234,13 @@ class BaseContractEvent:
233
234
  self.w3.codec,
234
235
  contract_address=self.address,
235
236
  argument_filters=_filters,
236
- fromBlock=fromBlock,
237
- toBlock=toBlock,
237
+ from_block=from_block,
238
+ to_block=to_block,
238
239
  address=self.address,
239
240
  )
240
241
 
241
- if blockHash is not None:
242
- event_filter_params["blockHash"] = blockHash
242
+ if block_hash is not None:
243
+ event_filter_params["blockHash"] = block_hash
243
244
 
244
245
  return event_filter_params
245
246
 
@@ -319,15 +320,15 @@ class BaseContractEvent:
319
320
  def _set_up_filter_builder(
320
321
  self,
321
322
  argument_filters: Optional[Dict[str, Any]] = None,
322
- fromBlock: Optional[BlockIdentifier] = None,
323
- toBlock: BlockIdentifier = "latest",
323
+ from_block: Optional[BlockIdentifier] = None,
324
+ to_block: BlockIdentifier = "latest",
324
325
  address: Optional[ChecksumAddress] = None,
325
326
  topics: Optional[Sequence[Any]] = None,
326
327
  filter_builder: Union[EventFilterBuilder, AsyncEventFilterBuilder] = None,
327
328
  ) -> None:
328
- if fromBlock is None:
329
+ if from_block is None:
329
330
  raise Web3TypeError(
330
- "Missing mandatory keyword argument to create_filter: fromBlock"
331
+ "Missing mandatory keyword argument to create_filter: `from_block`"
331
332
  )
332
333
 
333
334
  if argument_filters is None:
@@ -344,8 +345,8 @@ class BaseContractEvent:
344
345
  self.w3.codec,
345
346
  contract_address=self.address,
346
347
  argument_filters=_filters,
347
- fromBlock=fromBlock,
348
- toBlock=toBlock,
348
+ from_block=from_block,
349
+ to_block=to_block,
349
350
  address=address,
350
351
  topics=topics,
351
352
  )
@@ -353,8 +354,8 @@ class BaseContractEvent:
353
354
  filter_builder.address = cast(
354
355
  ChecksumAddress, event_filter_params.get("address")
355
356
  )
356
- filter_builder.fromBlock = event_filter_params.get("fromBlock")
357
- filter_builder.toBlock = event_filter_params.get("toBlock")
357
+ filter_builder.from_block = event_filter_params.get("fromBlock")
358
+ filter_builder.to_block = event_filter_params.get("toBlock")
358
359
  match_any_vals = {
359
360
  arg: value
360
361
  for arg, value in _filters.items()
web3/contract/contract.py CHANGED
@@ -110,8 +110,8 @@ class ContractEvent(BaseContractEvent):
110
110
  def get_logs(
111
111
  self,
112
112
  argument_filters: Optional[Dict[str, Any]] = None,
113
- fromBlock: Optional[BlockIdentifier] = None,
114
- toBlock: Optional[BlockIdentifier] = None,
113
+ from_block: Optional[BlockIdentifier] = None,
114
+ to_block: Optional[BlockIdentifier] = None,
115
115
  block_hash: Optional[HexBytes] = None,
116
116
  ) -> Iterable[EventData]:
117
117
  """
@@ -131,10 +131,10 @@ class ContractEvent(BaseContractEvent):
131
131
 
132
132
  .. code-block:: python
133
133
 
134
- from = max(mycontract.web3.eth.block_number - 10, 1)
135
- to = mycontract.web3.eth.block_number
134
+ from = max(my_contract.web3.eth.block_number - 10, 1)
135
+ to = my_contract.web3.eth.block_number
136
136
 
137
- events = mycontract.events.Transfer.get_logs(fromBlock=from, toBlock=to)
137
+ events = my_contract.events.Transfer.get_logs(from_block=from, to_block=to)
138
138
 
139
139
  for e in events:
140
140
  print(e["args"]["from"],
@@ -164,10 +164,10 @@ class ContractEvent(BaseContractEvent):
164
164
 
165
165
  :param argument_filters: Filter by argument values. Indexed arguments are
166
166
  filtered by the node while non-indexed arguments are filtered by the library.
167
- :param fromBlock: block number or "latest", defaults to "latest"
168
- :param toBlock: block number or "latest". Defaults to "latest"
167
+ :param from_block: block number or "latest", defaults to "latest"
168
+ :param to_block: block number or "latest". Defaults to "latest"
169
169
  :param block_hash: block hash. block_hash cannot be set at the
170
- same time as fromBlock or toBlock
170
+ same time as ``from_block`` or ``to_block``
171
171
  :yield: Tuple of :class:`AttributeDict` instances
172
172
  """
173
173
  event_abi = self._get_event_abi()
@@ -182,7 +182,7 @@ class ContractEvent(BaseContractEvent):
182
182
  )
183
183
 
184
184
  _filter_params = self._get_event_filter_params(
185
- event_abi, argument_filters, fromBlock, toBlock, block_hash
185
+ event_abi, argument_filters, from_block, to_block, block_hash
186
186
  )
187
187
  # call JSON-RPC API
188
188
  logs = self.w3.eth.get_logs(_filter_params)
@@ -205,8 +205,8 @@ class ContractEvent(BaseContractEvent):
205
205
  self,
206
206
  *, # PEP 3102
207
207
  argument_filters: Optional[Dict[str, Any]] = None,
208
- fromBlock: Optional[BlockIdentifier] = None,
209
- toBlock: BlockIdentifier = "latest",
208
+ from_block: Optional[BlockIdentifier] = None,
209
+ to_block: BlockIdentifier = "latest",
210
210
  address: Optional[ChecksumAddress] = None,
211
211
  topics: Optional[Sequence[Any]] = None,
212
212
  ) -> LogFilter:
@@ -216,8 +216,8 @@ class ContractEvent(BaseContractEvent):
216
216
  filter_builder = EventFilterBuilder(self._get_event_abi(), self.w3.codec)
217
217
  self._set_up_filter_builder(
218
218
  argument_filters,
219
- fromBlock,
220
- toBlock,
219
+ from_block,
220
+ to_block,
221
221
  address,
222
222
  topics,
223
223
  filter_builder,
web3/eth/async_eth.py CHANGED
@@ -57,12 +57,13 @@ from web3.eth.base_eth import (
57
57
  BaseEth,
58
58
  )
59
59
  from web3.exceptions import (
60
- MethodUnavailable,
60
+ MethodNotSupported,
61
61
  OffchainLookup,
62
62
  TimeExhausted,
63
63
  TooManyRequests,
64
64
  TransactionIndexingInProgress,
65
65
  TransactionNotFound,
66
+ Web3RPCError,
66
67
  Web3ValueError,
67
68
  )
68
69
  from web3.method import (
@@ -194,7 +195,7 @@ class AsyncEth(BaseEth):
194
195
  """
195
196
  try:
196
197
  return await self._max_priority_fee()
197
- except (ValueError, MethodUnavailable):
198
+ except Web3RPCError:
198
199
  warnings.warn(
199
200
  "There was an issue with the method eth_maxPriorityFeePerGas. "
200
201
  "Calculating using eth_feeHistory.",
@@ -736,7 +737,7 @@ class AsyncEth(BaseEth):
736
737
  ] = None,
737
738
  ) -> HexStr:
738
739
  if not isinstance(self.w3.provider, PersistentConnectionProvider):
739
- raise MethodUnavailable(
740
+ raise MethodNotSupported(
740
741
  "eth_subscribe is only supported with providers that support "
741
742
  "persistent connections."
742
743
  )
@@ -753,7 +754,7 @@ class AsyncEth(BaseEth):
753
754
 
754
755
  async def unsubscribe(self, subscription_id: HexStr) -> bool:
755
756
  if not isinstance(self.w3.provider, PersistentConnectionProvider):
756
- raise MethodUnavailable(
757
+ raise MethodNotSupported(
757
758
  "eth_unsubscribe is only supported with providers that support "
758
759
  "persistent connections."
759
760
  )
web3/eth/eth.py CHANGED
@@ -57,12 +57,12 @@ from web3.eth.base_eth import (
57
57
  BaseEth,
58
58
  )
59
59
  from web3.exceptions import (
60
- MethodUnavailable,
61
60
  OffchainLookup,
62
61
  TimeExhausted,
63
62
  TooManyRequests,
64
63
  TransactionIndexingInProgress,
65
64
  TransactionNotFound,
65
+ Web3RPCError,
66
66
  Web3ValueError,
67
67
  )
68
68
  from web3.method import (
@@ -187,7 +187,7 @@ class Eth(BaseEth):
187
187
  """
188
188
  try:
189
189
  return self._max_priority_fee()
190
- except (ValueError, MethodUnavailable):
190
+ except Web3RPCError:
191
191
  warnings.warn(
192
192
  "There was an issue with the method eth_maxPriorityFeePerGas. "
193
193
  "Calculating using eth_feeHistory.",
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,
@@ -69,6 +72,12 @@ class Web3TypeError(Web3Exception, TypeError):
69
72
  """
70
73
 
71
74
 
75
+ class MethodNotSupported(Web3Exception):
76
+ """
77
+ Raised when a method is not supported by the provider.
78
+ """
79
+
80
+
72
81
  class BadFunctionCallOutput(Web3Exception):
73
82
  """
74
83
  We failed to decode ABI output.
@@ -77,7 +86,7 @@ class BadFunctionCallOutput(Web3Exception):
77
86
  """
78
87
 
79
88
 
80
- class BlockNumberOutofRange(Web3Exception):
89
+ class BlockNumberOutOfRange(Web3Exception):
81
90
  """
82
91
  block_identifier passed does not match known block.
83
92
  """
@@ -216,25 +225,6 @@ class TimeExhausted(Web3Exception):
216
225
  """
217
226
 
218
227
 
219
- class TransactionNotFound(Web3Exception):
220
- """
221
- Raised when a tx hash used to lookup a tx in a jsonrpc call cannot be found.
222
- """
223
-
224
-
225
- class TransactionIndexingInProgress(Web3Exception):
226
- """
227
- Raised when a transaction receipt is not yet available due to transaction indexing
228
- still being in progress.
229
- """
230
-
231
-
232
- class BlockNotFound(Web3Exception):
233
- """
234
- Raised when the block id used to lookup a block in a jsonrpc call cannot be found.
235
- """
236
-
237
-
238
228
  class InfuraProjectIdNotFound(Web3Exception):
239
229
  """
240
230
  Raised when there is no Infura Project Id set.
@@ -317,7 +307,51 @@ class BadResponseFormat(Web3Exception):
317
307
  """
318
308
 
319
309
 
320
- class MethodUnavailable(Web3Exception):
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
333
+
334
+
335
+ class MethodUnavailable(Web3RPCError):
321
336
  """
322
337
  Raised when the method is not available on the node
323
338
  """
339
+
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
+ """
web3/geth.py CHANGED
@@ -1,23 +1,15 @@
1
1
  from typing import (
2
- Any,
3
2
  Awaitable,
4
3
  Callable,
5
- Dict,
6
4
  List,
7
5
  Optional,
8
6
  Protocol,
9
7
  Tuple,
10
8
  )
11
9
 
12
- from eth_typing.encoding import (
13
- HexStr,
14
- )
15
10
  from eth_typing.evm import (
16
11
  ChecksumAddress,
17
12
  )
18
- from hexbytes.main import (
19
- HexBytes,
20
- )
21
13
 
22
14
  from web3._utils.rpc_abi import (
23
15
  RPC,
@@ -31,10 +23,8 @@ from web3.module import (
31
23
  )
32
24
  from web3.types import (
33
25
  EnodeURI,
34
- GethWallet,
35
26
  NodeInfo,
36
27
  Peer,
37
- TxParams,
38
28
  TxPoolContent,
39
29
  TxPoolInspect,
40
30
  TxPoolStatus,
@@ -51,66 +41,6 @@ class UnlockAccountWrapper(Protocol):
51
41
  pass
52
42
 
53
43
 
54
- class GethPersonal(Module):
55
- """
56
- https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-personal
57
- """
58
-
59
- is_async = False
60
-
61
- ec_recover: Method[Callable[[str, HexStr], ChecksumAddress]] = Method(
62
- RPC.personal_ecRecover,
63
- mungers=[default_root_munger],
64
- )
65
-
66
- import_raw_key: Method[Callable[[str, str], ChecksumAddress]] = Method(
67
- RPC.personal_importRawKey,
68
- mungers=[default_root_munger],
69
- )
70
-
71
- list_accounts: Method[Callable[[], List[ChecksumAddress]]] = Method(
72
- RPC.personal_listAccounts,
73
- is_property=True,
74
- )
75
-
76
- list_wallets: Method[Callable[[], List[GethWallet]]] = Method(
77
- RPC.personal_listWallets,
78
- is_property=True,
79
- )
80
-
81
- send_transaction: Method[Callable[[TxParams, str], HexBytes]] = Method(
82
- RPC.personal_sendTransaction,
83
- mungers=[default_root_munger],
84
- )
85
-
86
- sign: Method[Callable[[str, ChecksumAddress, Optional[str]], HexStr]] = Method(
87
- RPC.personal_sign,
88
- mungers=[default_root_munger],
89
- )
90
-
91
- sign_typed_data: Method[
92
- Callable[[Dict[str, Any], ChecksumAddress, str], HexStr]
93
- ] = Method(
94
- RPC.personal_signTypedData,
95
- mungers=[default_root_munger],
96
- )
97
-
98
- new_account: Method[Callable[[str], ChecksumAddress]] = Method(
99
- RPC.personal_newAccount,
100
- mungers=[default_root_munger],
101
- )
102
-
103
- lock_account: Method[Callable[[ChecksumAddress], bool]] = Method(
104
- RPC.personal_lockAccount,
105
- mungers=[default_root_munger],
106
- )
107
-
108
- unlock_account: Method[UnlockAccountWrapper] = Method(
109
- RPC.personal_unlockAccount,
110
- mungers=[default_root_munger],
111
- )
112
-
113
-
114
44
  class GethTxPool(Module):
115
45
  """
116
46
  https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool
@@ -204,7 +134,6 @@ class GethAdmin(Module):
204
134
 
205
135
 
206
136
  class Geth(Module):
207
- personal: GethPersonal
208
137
  admin: GethAdmin
209
138
  txpool: GethTxPool
210
139
 
@@ -332,125 +261,8 @@ class AsyncGethAdmin(Module):
332
261
  return await self._stop_ws()
333
262
 
334
263
 
335
- class AsyncGethPersonal(Module):
336
- """
337
- https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-personal
338
- """
339
-
340
- is_async = True
341
-
342
- # ec_recover
343
-
344
- _ec_recover: Method[Callable[[str, HexStr], Awaitable[ChecksumAddress]]] = Method(
345
- RPC.personal_ecRecover,
346
- mungers=[default_root_munger],
347
- )
348
-
349
- async def ec_recover(self, message: str, signature: HexStr) -> ChecksumAddress:
350
- return await self._ec_recover(message, signature)
351
-
352
- # import_raw_key
353
-
354
- _import_raw_key: Method[Callable[[str, str], Awaitable[ChecksumAddress]]] = Method(
355
- RPC.personal_importRawKey,
356
- mungers=[default_root_munger],
357
- )
358
-
359
- async def import_raw_key(
360
- self, private_key: str, passphrase: str
361
- ) -> ChecksumAddress:
362
- return await self._import_raw_key(private_key, passphrase)
363
-
364
- # list_accounts and list_wallets
365
-
366
- _list_accounts: Method[Callable[[], Awaitable[List[ChecksumAddress]]]] = Method(
367
- RPC.personal_listAccounts,
368
- is_property=True,
369
- )
370
-
371
- _list_wallets: Method[Callable[[], Awaitable[List[GethWallet]]]] = Method(
372
- RPC.personal_listWallets,
373
- is_property=True,
374
- )
375
-
376
- async def list_accounts(self) -> List[ChecksumAddress]:
377
- return await self._list_accounts()
378
-
379
- async def list_wallets(self) -> List[GethWallet]:
380
- return await self._list_wallets()
381
-
382
- # send_transaction
383
-
384
- _send_transaction: Method[Callable[[TxParams, str], Awaitable[HexBytes]]] = Method(
385
- RPC.personal_sendTransaction,
386
- mungers=[default_root_munger],
387
- )
388
-
389
- async def send_transaction(
390
- self, transaction: TxParams, passphrase: str
391
- ) -> HexBytes:
392
- return await self._send_transaction(transaction, passphrase)
393
-
394
- # sign and sign_typed_data
395
-
396
- _sign: Method[
397
- Callable[[str, ChecksumAddress, Optional[str]], Awaitable[HexStr]]
398
- ] = Method(
399
- RPC.personal_sign,
400
- mungers=[default_root_munger],
401
- )
402
-
403
- _sign_typed_data: Method[
404
- Callable[[Dict[str, Any], ChecksumAddress, str], Awaitable[HexStr]]
405
- ] = Method(
406
- RPC.personal_signTypedData,
407
- mungers=[default_root_munger],
408
- )
409
-
410
- async def sign(
411
- self, message: str, account: ChecksumAddress, passphrase: str
412
- ) -> HexStr:
413
- return await self._sign(message, account, passphrase)
414
-
415
- async def sign_typed_data(
416
- self, message: Dict[str, Any], account: ChecksumAddress, passphrase: str
417
- ) -> HexStr:
418
- return await self._sign_typed_data(message, account, passphrase)
419
-
420
- # new_account, lock_account, and unlock_account
421
-
422
- _new_account: Method[Callable[[str], Awaitable[ChecksumAddress]]] = Method(
423
- RPC.personal_newAccount,
424
- mungers=[default_root_munger],
425
- )
426
-
427
- _lock_account: Method[Callable[[ChecksumAddress], Awaitable[bool]]] = Method(
428
- RPC.personal_lockAccount,
429
- mungers=[default_root_munger],
430
- )
431
-
432
- _unlock_account: Method[
433
- Callable[[ChecksumAddress, str, Optional[int]], Awaitable[bool]]
434
- ] = Method(
435
- RPC.personal_unlockAccount,
436
- mungers=[default_root_munger],
437
- )
438
-
439
- async def new_account(self, passphrase: str) -> ChecksumAddress:
440
- return await self._new_account(passphrase)
441
-
442
- async def lock_account(self, account: ChecksumAddress) -> bool:
443
- return await self._lock_account(account)
444
-
445
- async def unlock_account(
446
- self, account: ChecksumAddress, passphrase: str, duration: Optional[int] = None
447
- ) -> bool:
448
- return await self._unlock_account(account, passphrase, duration)
449
-
450
-
451
264
  class AsyncGeth(Module):
452
265
  is_async = True
453
266
 
454
- personal: AsyncGethPersonal
455
267
  admin: AsyncGethAdmin
456
268
  txpool: AsyncGethTxPool