web3 7.12.1__py3-none-any.whl → 7.14.0__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.
Files changed (57) hide show
  1. ens/async_ens.py +9 -5
  2. ens/base_ens.py +1 -1
  3. ens/utils.py +2 -1
  4. web3/_utils/abi.py +5 -5
  5. web3/_utils/async_transactions.py +12 -9
  6. web3/_utils/batching.py +1 -1
  7. web3/_utils/caching/caching_utils.py +2 -2
  8. web3/_utils/contracts.py +5 -5
  9. web3/_utils/ens.py +1 -1
  10. web3/_utils/events.py +1 -1
  11. web3/_utils/module_testing/eth_module.py +133 -125
  12. web3/_utils/module_testing/go_ethereum_admin_module.py +7 -6
  13. web3/_utils/module_testing/go_ethereum_debug_module.py +5 -4
  14. web3/_utils/module_testing/go_ethereum_txpool_module.py +6 -3
  15. web3/_utils/module_testing/module_testing_utils.py +1 -1
  16. web3/_utils/module_testing/net_module.py +4 -3
  17. web3/_utils/module_testing/persistent_connection_provider.py +132 -20
  18. web3/_utils/module_testing/utils.py +7 -6
  19. web3/_utils/module_testing/web3_module.py +15 -11
  20. web3/_utils/normalizers.py +3 -3
  21. web3/_utils/transactions.py +2 -1
  22. web3/contract/async_contract.py +13 -13
  23. web3/contract/base_contract.py +11 -12
  24. web3/contract/utils.py +7 -7
  25. web3/eth/async_eth.py +3 -14
  26. web3/exceptions.py +8 -1
  27. web3/gas_strategies/time_based.py +1 -1
  28. web3/main.py +24 -11
  29. web3/manager.py +11 -13
  30. web3/middleware/__init__.py +1 -1
  31. web3/middleware/base.py +5 -5
  32. web3/middleware/buffered_gas_estimate.py +1 -1
  33. web3/middleware/filter.py +10 -9
  34. web3/middleware/formatting.py +11 -5
  35. web3/middleware/gas_price_strategy.py +1 -1
  36. web3/middleware/names.py +4 -4
  37. web3/middleware/signing.py +3 -3
  38. web3/middleware/stalecheck.py +2 -2
  39. web3/middleware/validation.py +2 -2
  40. web3/module.py +3 -3
  41. web3/providers/async_base.py +2 -2
  42. web3/providers/base.py +2 -2
  43. web3/providers/eth_tester/defaults.py +2 -2
  44. web3/providers/eth_tester/main.py +1 -1
  45. web3/providers/eth_tester/middleware.py +2 -2
  46. web3/providers/persistent/persistent.py +8 -7
  47. web3/providers/persistent/persistent_connection.py +1 -1
  48. web3/providers/persistent/subscription_manager.py +67 -14
  49. web3/providers/persistent/utils.py +1 -1
  50. web3/types.py +16 -3
  51. web3/utils/subscriptions.py +26 -4
  52. {web3-7.12.1.dist-info → web3-7.14.0.dist-info}/METADATA +1 -1
  53. {web3-7.12.1.dist-info → web3-7.14.0.dist-info}/RECORD +56 -57
  54. ens/specs/.DS_Store +0 -0
  55. {web3-7.12.1.dist-info → web3-7.14.0.dist-info}/WHEEL +0 -0
  56. {web3-7.12.1.dist-info → web3-7.14.0.dist-info}/licenses/LICENSE +0 -0
  57. {web3-7.12.1.dist-info → web3-7.14.0.dist-info}/top_level.txt +0 -0
ens/async_ens.py CHANGED
@@ -72,7 +72,9 @@ if TYPE_CHECKING:
72
72
  AsyncContract,
73
73
  AsyncContractFunction,
74
74
  )
75
- from web3.main import AsyncWeb3 # noqa: F401
75
+ from web3.main import ( # noqa: F401
76
+ AsyncWeb3,
77
+ )
76
78
  from web3.middleware.base import ( # noqa: F401
77
79
  Middleware,
78
80
  )
@@ -96,12 +98,12 @@ class AsyncENS(BaseENS):
96
98
  """
97
99
 
98
100
  # mypy types
99
- w3: "AsyncWeb3"
101
+ w3: "AsyncWeb3[Any]"
100
102
 
101
103
  def __init__(
102
104
  self,
103
- provider: "AsyncBaseProvider" = None,
104
- addr: ChecksumAddress = None,
105
+ provider: Optional["AsyncBaseProvider"] = None,
106
+ addr: Optional[ChecksumAddress] = None,
105
107
  middleware: Optional[Sequence[Tuple["Middleware", str]]] = None,
106
108
  ) -> None:
107
109
  """
@@ -123,7 +125,9 @@ class AsyncENS(BaseENS):
123
125
  )
124
126
 
125
127
  @classmethod
126
- def from_web3(cls, w3: "AsyncWeb3", addr: ChecksumAddress = None) -> "AsyncENS":
128
+ def from_web3(
129
+ cls, w3: "AsyncWeb3[Any]", addr: ChecksumAddress = None
130
+ ) -> "AsyncENS":
127
131
  """
128
132
  Generate an AsyncENS instance with web3
129
133
 
ens/base_ens.py CHANGED
@@ -38,7 +38,7 @@ if TYPE_CHECKING:
38
38
 
39
39
 
40
40
  class BaseENS:
41
- w3: Union["AsyncWeb3", "Web3"] = None
41
+ w3: Union["AsyncWeb3[Any]", "Web3"] = None
42
42
  ens: Union["Contract", "AsyncContract"] = None
43
43
  _resolver_contract: Union[Type["Contract"], Type["AsyncContract"]] = None
44
44
  _reverse_resolver_contract: Union[Type["Contract"], Type["AsyncContract"]] = None
ens/utils.py CHANGED
@@ -302,7 +302,7 @@ def is_valid_ens_name(ens_name: str) -> bool:
302
302
  def init_async_web3(
303
303
  provider: "AsyncBaseProvider" = None,
304
304
  middleware: Optional[Sequence[Tuple["Middleware", str]]] = (),
305
- ) -> "AsyncWeb3":
305
+ ) -> "AsyncWeb3[Any]":
306
306
  from web3 import (
307
307
  AsyncWeb3 as AsyncWeb3Main,
308
308
  )
@@ -327,6 +327,7 @@ def init_async_web3(
327
327
  )
328
328
  )
329
329
 
330
+ async_w3: "AsyncWeb3[Any]"
330
331
  if provider is default:
331
332
  async_w3 = AsyncWeb3Main(
332
333
  middleware=middleware, ens=None, modules={"eth": (AsyncEthMain)}
web3/_utils/abi.py CHANGED
@@ -852,7 +852,7 @@ def _named_subtree(
852
852
 
853
853
  def recursive_dict_to_namedtuple(data: Dict[str, Any]) -> Tuple[Any, ...]:
854
854
  def _dict_to_namedtuple(
855
- value: Union[Dict[str, Any], List[Any]]
855
+ value: Union[Dict[str, Any], List[Any]],
856
856
  ) -> Union[Tuple[Any, ...], List[Any]]:
857
857
  if not isinstance(value, dict):
858
858
  return value
@@ -864,7 +864,7 @@ def recursive_dict_to_namedtuple(data: Dict[str, Any]) -> Tuple[Any, ...]:
864
864
 
865
865
 
866
866
  def abi_decoded_namedtuple_factory(
867
- fields: Tuple[Any, ...]
867
+ fields: Tuple[Any, ...],
868
868
  ) -> Callable[..., Tuple[Any, ...]]:
869
869
  class ABIDecodedNamedTuple(namedtuple("ABIDecodedNamedTuple", fields, rename=True)): # type: ignore # noqa: E501
870
870
  def __new__(self, args: Any) -> "ABIDecodedNamedTuple":
@@ -877,9 +877,9 @@ def abi_decoded_namedtuple_factory(
877
877
 
878
878
 
879
879
  async def async_data_tree_map(
880
- async_w3: "AsyncWeb3",
880
+ async_w3: "AsyncWeb3[Any]",
881
881
  func: Callable[
882
- ["AsyncWeb3", TypeStr, Any], Coroutine[Any, Any, Tuple[TypeStr, Any]]
882
+ ["AsyncWeb3[Any]", TypeStr, Any], Coroutine[Any, Any, Tuple[TypeStr, Any]]
883
883
  ],
884
884
  data_tree: Any,
885
885
  ) -> "ABITypedData":
@@ -902,7 +902,7 @@ async def async_data_tree_map(
902
902
 
903
903
  @reject_recursive_repeats
904
904
  async def async_recursive_map(
905
- async_w3: "AsyncWeb3",
905
+ async_w3: "AsyncWeb3[Any]",
906
906
  func: Callable[[Any], Coroutine[Any, Any, TReturn]],
907
907
  data: Any,
908
908
  ) -> TReturn:
@@ -1,5 +1,6 @@
1
1
  from typing import (
2
2
  TYPE_CHECKING,
3
+ Any,
3
4
  Dict,
4
5
  Optional,
5
6
  Union,
@@ -46,13 +47,13 @@ if TYPE_CHECKING:
46
47
 
47
48
  # unused vars present in these funcs because they all need to have the same signature
48
49
  async def _estimate_gas(
49
- async_w3: "AsyncWeb3", tx: TxParams, _defaults: Dict[str, Union[bytes, int]]
50
+ async_w3: "AsyncWeb3[Any]", tx: TxParams, _defaults: Dict[str, Union[bytes, int]]
50
51
  ) -> int:
51
52
  return await async_w3.eth.estimate_gas(tx)
52
53
 
53
54
 
54
55
  async def _max_fee_per_gas(
55
- async_w3: "AsyncWeb3", tx: TxParams, defaults: Dict[str, Union[bytes, int]]
56
+ async_w3: "AsyncWeb3[Any]", tx: TxParams, defaults: Dict[str, Union[bytes, int]]
56
57
  ) -> Wei:
57
58
  block = await async_w3.eth.get_block("latest")
58
59
  max_priority_fee = tx.get(
@@ -62,13 +63,13 @@ async def _max_fee_per_gas(
62
63
 
63
64
 
64
65
  async def _max_priority_fee_gas(
65
- async_w3: "AsyncWeb3", _tx: TxParams, _defaults: Dict[str, Union[bytes, int]]
66
+ async_w3: "AsyncWeb3[Any]", _tx: TxParams, _defaults: Dict[str, Union[bytes, int]]
66
67
  ) -> Wei:
67
68
  return await async_w3.eth.max_priority_fee
68
69
 
69
70
 
70
71
  async def _chain_id(
71
- async_w3: "AsyncWeb3", _tx: TxParams, _defaults: Dict[str, Union[bytes, int]]
72
+ async_w3: "AsyncWeb3[Any]", _tx: TxParams, _defaults: Dict[str, Union[bytes, int]]
72
73
  ) -> int:
73
74
  return await async_w3.eth.chain_id
74
75
 
@@ -92,7 +93,7 @@ async def get_block_gas_limit(
92
93
 
93
94
 
94
95
  async def get_buffered_gas_estimate(
95
- async_w3: "AsyncWeb3", transaction: TxParams, gas_buffer: int = 100000
96
+ async_w3: "AsyncWeb3[Any]", transaction: TxParams, gas_buffer: int = 100000
96
97
  ) -> int:
97
98
  gas_estimate_transaction = cast(TxParams, dict(**transaction))
98
99
 
@@ -110,7 +111,9 @@ async def get_buffered_gas_estimate(
110
111
  return min(gas_limit, gas_estimate + gas_buffer)
111
112
 
112
113
 
113
- async def async_fill_nonce(async_w3: "AsyncWeb3", transaction: TxParams) -> TxParams:
114
+ async def async_fill_nonce(
115
+ async_w3: "AsyncWeb3[Any]", transaction: TxParams
116
+ ) -> TxParams:
114
117
  if "from" in transaction and "nonce" not in transaction:
115
118
  tx_count = await async_w3.eth.get_transaction_count(
116
119
  cast(ChecksumAddress, transaction["from"]),
@@ -121,7 +124,7 @@ async def async_fill_nonce(async_w3: "AsyncWeb3", transaction: TxParams) -> TxPa
121
124
 
122
125
 
123
126
  async def async_fill_transaction_defaults(
124
- async_w3: "AsyncWeb3", transaction: TxParams
127
+ async_w3: "AsyncWeb3[Any]", transaction: TxParams
125
128
  ) -> TxParams:
126
129
  """
127
130
  If async_w3 is None, fill as much as possible while offline
@@ -165,7 +168,7 @@ async def async_fill_transaction_defaults(
165
168
 
166
169
 
167
170
  async def async_get_required_transaction(
168
- async_w3: "AsyncWeb3", transaction_hash: _Hash32
171
+ async_w3: "AsyncWeb3[Any]", transaction_hash: _Hash32
169
172
  ) -> TxData:
170
173
  current_transaction = await async_w3.eth.get_transaction(transaction_hash)
171
174
  if not current_transaction:
@@ -176,7 +179,7 @@ async def async_get_required_transaction(
176
179
 
177
180
 
178
181
  async def async_replace_transaction(
179
- async_w3: "AsyncWeb3", current_transaction: TxData, new_transaction: TxParams
182
+ async_w3: "AsyncWeb3[Any]", current_transaction: TxData, new_transaction: TxParams
180
183
  ) -> HexBytes:
181
184
  new_transaction = prepare_replacement_transaction(
182
185
  async_w3, current_transaction, new_transaction
web3/_utils/batching.py CHANGED
@@ -71,7 +71,7 @@ RPC_METHODS_UNSUPPORTED_DURING_BATCH = {
71
71
 
72
72
 
73
73
  class RequestBatcher(Generic[TFunc]):
74
- def __init__(self, web3: Union["AsyncWeb3", "Web3"]) -> None:
74
+ def __init__(self, web3: Union["AsyncWeb3[Any]", "Web3"]) -> None:
75
75
  self.web3 = web3
76
76
  self._requests_info: List[BatchRequestInformation] = []
77
77
  self._async_requests_info: List[
@@ -238,7 +238,7 @@ def _should_cache_response(
238
238
 
239
239
 
240
240
  def handle_request_caching(
241
- func: Callable[[SYNC_PROVIDER_TYPE, RPCEndpoint, Any], "RPCResponse"]
241
+ func: Callable[[SYNC_PROVIDER_TYPE, RPCEndpoint, Any], "RPCResponse"],
242
242
  ) -> Callable[..., "RPCResponse"]:
243
243
  def wrapper(
244
244
  provider: SYNC_PROVIDER_TYPE, method: RPCEndpoint, params: Any
@@ -401,7 +401,7 @@ def async_handle_recv_caching(
401
401
  func: Callable[
402
402
  ["PersistentConnectionProvider", "RPCRequest"],
403
403
  Coroutine[Any, Any, "RPCResponse"],
404
- ]
404
+ ],
405
405
  ) -> Callable[..., Coroutine[Any, Any, "RPCResponse"]]:
406
406
  async def wrapper(
407
407
  provider: "PersistentConnectionProvider",
web3/_utils/contracts.py CHANGED
@@ -121,7 +121,7 @@ def find_matching_event_abi(
121
121
 
122
122
 
123
123
  def encode_abi(
124
- w3: Union["AsyncWeb3", "Web3"],
124
+ w3: Union["AsyncWeb3[Any]", "Web3"],
125
125
  abi: ABIElement,
126
126
  arguments: Sequence[Any],
127
127
  data: Optional[HexStr] = None,
@@ -168,7 +168,7 @@ def encode_abi(
168
168
 
169
169
  def prepare_transaction(
170
170
  address: ChecksumAddress,
171
- w3: Union["AsyncWeb3", "Web3"],
171
+ w3: Union["AsyncWeb3[Any]", "Web3"],
172
172
  abi_element_identifier: ABIElementIdentifier,
173
173
  contract_abi: Optional[ABI] = None,
174
174
  abi_callable: Optional[ABICallable] = None,
@@ -232,7 +232,7 @@ def prepare_transaction(
232
232
 
233
233
 
234
234
  def encode_transaction_data(
235
- w3: Union["AsyncWeb3", "Web3"],
235
+ w3: Union["AsyncWeb3[Any]", "Web3"],
236
236
  abi_element_identifier: ABIElementIdentifier,
237
237
  contract_abi: Optional[ABI] = None,
238
238
  abi_callable: Optional[ABICallable] = None,
@@ -363,7 +363,7 @@ def parse_block_identifier_int(w3: "Web3", block_identifier_int: int) -> BlockNu
363
363
 
364
364
 
365
365
  async def async_parse_block_identifier(
366
- async_w3: "AsyncWeb3", block_identifier: BlockIdentifier
366
+ async_w3: "AsyncWeb3[Any]", block_identifier: BlockIdentifier
367
367
  ) -> BlockIdentifier:
368
368
  if block_identifier is None:
369
369
  return async_w3.eth.default_block
@@ -381,7 +381,7 @@ async def async_parse_block_identifier(
381
381
 
382
382
 
383
383
  async def async_parse_block_identifier_int(
384
- async_w3: "AsyncWeb3", block_identifier_int: int
384
+ async_w3: "AsyncWeb3[Any]", block_identifier_int: int
385
385
  ) -> BlockNumber:
386
386
  if block_identifier_int >= 0:
387
387
  block_num = block_identifier_int
web3/_utils/ens.py CHANGED
@@ -75,7 +75,7 @@ class AsyncStaticENS:
75
75
 
76
76
  @contextmanager
77
77
  def ens_addresses(
78
- w3: Union["Web3", "AsyncWeb3"], name_addr_pairs: Dict[str, ChecksumAddress]
78
+ w3: Union["Web3", "AsyncWeb3[Any]"], name_addr_pairs: Dict[str, ChecksumAddress]
79
79
  ) -> Iterator[None]:
80
80
  original_ens = w3.ens
81
81
  if w3.provider.is_async:
web3/_utils/events.py CHANGED
@@ -453,7 +453,7 @@ class EventFilterBuilder(BaseEventFilterBuilder):
453
453
 
454
454
 
455
455
  class AsyncEventFilterBuilder(BaseEventFilterBuilder):
456
- async def deploy(self, async_w3: "AsyncWeb3") -> "AsyncLogFilter":
456
+ async def deploy(self, async_w3: "AsyncWeb3[Any]") -> "AsyncLogFilter":
457
457
  if not isinstance(async_w3, web3.AsyncWeb3):
458
458
  raise Web3ValueError(f"Invalid web3 argument: got: {async_w3!r}")
459
459