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.
Files changed (82) hide show
  1. ens/_normalization.py +1 -3
  2. ens/async_ens.py +12 -9
  3. ens/contract_data.py +2 -2
  4. ens/ens.py +8 -5
  5. ens/exceptions.py +19 -27
  6. ens/specs/nf.json +1 -1
  7. ens/specs/normalization_spec.json +1 -1
  8. ens/utils.py +17 -10
  9. web3/__init__.py +2 -7
  10. web3/_utils/abi.py +30 -29
  11. web3/_utils/async_transactions.py +7 -4
  12. web3/_utils/blocks.py +6 -2
  13. web3/_utils/caching.py +7 -3
  14. web3/_utils/compat/__init__.py +0 -3
  15. web3/_utils/contract_sources/compile_contracts.py +1 -1
  16. web3/_utils/contracts.py +17 -17
  17. web3/_utils/datatypes.py +5 -1
  18. web3/_utils/decorators.py +6 -1
  19. web3/_utils/empty.py +1 -1
  20. web3/_utils/encoding.py +15 -10
  21. web3/_utils/error_formatters_utils.py +5 -3
  22. web3/_utils/events.py +38 -36
  23. web3/_utils/fee_utils.py +2 -4
  24. web3/_utils/filters.py +23 -18
  25. web3/_utils/formatters.py +2 -2
  26. web3/_utils/math.py +3 -2
  27. web3/_utils/method_formatters.py +24 -28
  28. web3/_utils/module.py +2 -1
  29. web3/_utils/module_testing/__init__.py +0 -3
  30. web3/_utils/module_testing/eth_module.py +494 -432
  31. web3/_utils/module_testing/module_testing_utils.py +1 -3
  32. web3/_utils/module_testing/utils.py +14 -7
  33. web3/_utils/normalizers.py +3 -3
  34. web3/_utils/request.py +4 -4
  35. web3/_utils/rpc_abi.py +5 -19
  36. web3/_utils/threads.py +8 -7
  37. web3/_utils/transactions.py +14 -12
  38. web3/_utils/type_conversion.py +5 -1
  39. web3/_utils/validation.py +12 -10
  40. web3/contract/async_contract.py +23 -18
  41. web3/contract/base_contract.py +69 -74
  42. web3/contract/contract.py +25 -19
  43. web3/contract/utils.py +11 -6
  44. web3/datastructures.py +22 -12
  45. web3/eth/async_eth.py +38 -32
  46. web3/eth/base_eth.py +7 -3
  47. web3/eth/eth.py +20 -15
  48. web3/exceptions.py +83 -78
  49. web3/gas_strategies/time_based.py +2 -4
  50. web3/geth.py +1 -191
  51. web3/main.py +6 -6
  52. web3/manager.py +128 -68
  53. web3/method.py +13 -5
  54. web3/middleware/base.py +4 -2
  55. web3/middleware/filter.py +45 -23
  56. web3/middleware/formatting.py +6 -3
  57. web3/middleware/names.py +4 -1
  58. web3/middleware/signing.py +8 -4
  59. web3/middleware/stalecheck.py +2 -1
  60. web3/providers/eth_tester/defaults.py +1 -49
  61. web3/providers/eth_tester/main.py +41 -15
  62. web3/providers/eth_tester/middleware.py +13 -9
  63. web3/providers/ipc.py +7 -3
  64. web3/providers/persistent/async_ipc.py +6 -7
  65. web3/providers/persistent/persistent.py +11 -1
  66. web3/providers/persistent/request_processor.py +7 -7
  67. web3/providers/persistent/websocket.py +3 -3
  68. web3/providers/rpc/async_rpc.py +24 -7
  69. web3/providers/rpc/rpc.py +30 -17
  70. web3/providers/rpc/utils.py +1 -10
  71. web3/testing.py +4 -4
  72. web3/tools/benchmark/main.py +13 -9
  73. web3/tools/benchmark/node.py +2 -8
  74. web3/tools/benchmark/utils.py +1 -1
  75. web3/tracing.py +9 -5
  76. web3/types.py +20 -23
  77. {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/METADATA +13 -28
  78. {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/RECORD +81 -82
  79. web3/_utils/module_testing/go_ethereum_personal_module.py +0 -300
  80. {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/LICENSE +0 -0
  81. {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/WHEEL +0 -0
  82. {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/top_level.txt +0 -0
@@ -92,7 +92,10 @@ from web3.exceptions import (
92
92
  NoABIEventsFound,
93
93
  NoABIFound,
94
94
  NoABIFunctionsFound,
95
+ Web3AttributeError,
96
+ Web3TypeError,
95
97
  Web3ValidationError,
98
+ Web3ValueError,
96
99
  )
97
100
  from web3.logs import (
98
101
  DISCARD,
@@ -125,7 +128,8 @@ if TYPE_CHECKING:
125
128
 
126
129
 
127
130
  class BaseContractEvent:
128
- """Base class for contract events
131
+ """
132
+ Base class for contract events
129
133
 
130
134
  An event accessed via the api `contract.events.myEvents(*args, **kwargs)`
131
135
  is a subclass of this class.
@@ -163,7 +167,7 @@ class BaseContractEvent:
163
167
  try:
164
168
  errors.name
165
169
  except AttributeError:
166
- raise AttributeError(
170
+ raise Web3AttributeError(
167
171
  f"Error flag must be one of: {EventLogErrorFlags.flag_options()}"
168
172
  )
169
173
 
@@ -185,7 +189,8 @@ class BaseContractEvent:
185
189
  f"The log with transaction hash: {log['transactionHash']!r} "
186
190
  f"and logIndex: {log['logIndex']} encountered the following "
187
191
  f"error during processing: {type(e).__name__}({e}). It has "
188
- "been discarded."
192
+ "been discarded.",
193
+ stacklevel=2,
189
194
  )
190
195
  continue
191
196
  yield rich_log
@@ -199,12 +204,12 @@ class BaseContractEvent:
199
204
  self,
200
205
  abi: ABIEvent,
201
206
  argument_filters: Optional[Dict[str, Any]] = None,
202
- fromBlock: Optional[BlockIdentifier] = None,
203
- toBlock: Optional[BlockIdentifier] = None,
204
- blockHash: Optional[HexBytes] = None,
207
+ from_block: Optional[BlockIdentifier] = None,
208
+ to_block: Optional[BlockIdentifier] = None,
209
+ block_hash: Optional[HexBytes] = None,
205
210
  ) -> FilterParams:
206
211
  if not self.address:
207
- raise TypeError(
212
+ raise Web3TypeError(
208
213
  "This method can be only called on "
209
214
  "an instated contract with an address"
210
215
  )
@@ -214,11 +219,12 @@ class BaseContractEvent:
214
219
 
215
220
  _filters = dict(**argument_filters)
216
221
 
217
- blkhash_set = blockHash is not None
218
- 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
219
224
  if blkhash_set and blknum_set:
220
225
  raise Web3ValidationError(
221
- "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`"
222
228
  )
223
229
 
224
230
  # Construct JSON-RPC raw filter presentation based on human readable
@@ -228,13 +234,13 @@ class BaseContractEvent:
228
234
  self.w3.codec,
229
235
  contract_address=self.address,
230
236
  argument_filters=_filters,
231
- fromBlock=fromBlock,
232
- toBlock=toBlock,
237
+ from_block=from_block,
238
+ to_block=to_block,
233
239
  address=self.address,
234
240
  )
235
241
 
236
- if blockHash is not None:
237
- event_filter_params["blockHash"] = blockHash
242
+ if block_hash is not None:
243
+ event_filter_params["blockHash"] = block_hash
238
244
 
239
245
  return event_filter_params
240
246
 
@@ -251,12 +257,12 @@ class BaseContractEvent:
251
257
  for filter_name, filter_value in _filters.items():
252
258
  _input = name_indexed_inputs[filter_name]
253
259
  if is_array_type(_input["type"]):
254
- raise TypeError(
260
+ raise Web3TypeError(
255
261
  "createFilter no longer supports array type filter arguments. "
256
262
  "see the build_filter method for filtering array type filters."
257
263
  )
258
264
  if is_list_like(filter_value) and is_dynamic_sized_type(_input["type"]):
259
- raise TypeError(
265
+ raise Web3TypeError(
260
266
  "createFilter no longer supports setting filter argument options "
261
267
  "for dynamic sized types. See the build_filter method for setting "
262
268
  "filters with the match_any method."
@@ -314,15 +320,15 @@ class BaseContractEvent:
314
320
  def _set_up_filter_builder(
315
321
  self,
316
322
  argument_filters: Optional[Dict[str, Any]] = None,
317
- fromBlock: Optional[BlockIdentifier] = None,
318
- toBlock: BlockIdentifier = "latest",
323
+ from_block: Optional[BlockIdentifier] = None,
324
+ to_block: BlockIdentifier = "latest",
319
325
  address: Optional[ChecksumAddress] = None,
320
326
  topics: Optional[Sequence[Any]] = None,
321
327
  filter_builder: Union[EventFilterBuilder, AsyncEventFilterBuilder] = None,
322
328
  ) -> None:
323
- if fromBlock is None:
324
- raise TypeError(
325
- "Missing mandatory keyword argument to create_filter: fromBlock"
329
+ if from_block is None:
330
+ raise Web3TypeError(
331
+ "Missing mandatory keyword argument to create_filter: `from_block`"
326
332
  )
327
333
 
328
334
  if argument_filters is None:
@@ -339,8 +345,8 @@ class BaseContractEvent:
339
345
  self.w3.codec,
340
346
  contract_address=self.address,
341
347
  argument_filters=_filters,
342
- fromBlock=fromBlock,
343
- toBlock=toBlock,
348
+ from_block=from_block,
349
+ to_block=to_block,
344
350
  address=address,
345
351
  topics=topics,
346
352
  )
@@ -348,8 +354,8 @@ class BaseContractEvent:
348
354
  filter_builder.address = cast(
349
355
  ChecksumAddress, event_filter_params.get("address")
350
356
  )
351
- filter_builder.fromBlock = event_filter_params.get("fromBlock")
352
- 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")
353
359
  match_any_vals = {
354
360
  arg: value
355
361
  for arg, value in _filters.items()
@@ -370,7 +376,8 @@ class BaseContractEvent:
370
376
 
371
377
 
372
378
  class BaseContractEvents:
373
- """Class containing contract event objects
379
+ """
380
+ Class containing contract event objects
374
381
 
375
382
  This is available via:
376
383
 
@@ -431,7 +438,8 @@ class BaseContractEvents:
431
438
  return getattr(self, event_name)
432
439
 
433
440
  def __iter__(self) -> Iterable[Type["BaseContractEvent"]]:
434
- """Iterate over supported
441
+ """
442
+ Iterate over supported
435
443
 
436
444
  :return: Iterable of :class:`ContractEvent`
437
445
  """
@@ -446,7 +454,8 @@ class BaseContractEvents:
446
454
 
447
455
 
448
456
  class BaseContractFunction:
449
- """Base class for contract functions
457
+ """
458
+ Base class for contract functions
450
459
 
451
460
  A function accessed via the api `contract.functions.myMethod(*args, **kwargs)`
452
461
  is a subclass of this class.
@@ -479,12 +488,9 @@ class BaseContractFunction:
479
488
  if self.function_identifier in [FallbackFn, ReceiveFn]:
480
489
  self.selector = encode_hex(b"")
481
490
  elif is_text(self.function_identifier):
482
- # https://github.com/python/mypy/issues/4976
483
- self.selector = encode_hex(
484
- function_abi_to_4byte_selector(self.abi) # type: ignore
485
- )
491
+ self.selector = encode_hex(function_abi_to_4byte_selector(self.abi))
486
492
  else:
487
- raise TypeError("Unsupported function identifier")
493
+ raise Web3TypeError("Unsupported function identifier")
488
494
 
489
495
  self.arguments = merge_args_and_kwargs(self.abi, self.args, self.kwargs)
490
496
 
@@ -495,26 +501,25 @@ class BaseContractFunction:
495
501
  call_transaction = cast(TxParams, dict(**transaction))
496
502
 
497
503
  if "data" in call_transaction:
498
- raise ValueError("Cannot set 'data' field in call transaction")
504
+ raise Web3ValueError("Cannot set 'data' field in call transaction")
499
505
 
500
506
  if self.address:
501
507
  call_transaction.setdefault("to", self.address)
502
508
  if self.w3.eth.default_account is not empty:
503
- # type ignored b/c check prevents an empty default_account
504
509
  call_transaction.setdefault(
505
510
  "from",
506
- self.w3.eth.default_account, # type: ignore
511
+ self.w3.eth.default_account,
507
512
  )
508
513
 
509
514
  if "to" not in call_transaction:
510
515
  if isinstance(self, type):
511
- raise ValueError(
516
+ raise Web3ValueError(
512
517
  "When using `Contract.[methodtype].[method].call()` from"
513
518
  " a contract factory you "
514
519
  "must provide a `to` address with the transaction"
515
520
  )
516
521
  else:
517
- raise ValueError(
522
+ raise Web3ValueError(
518
523
  "Please ensure that this contract instance has an address."
519
524
  )
520
525
 
@@ -527,24 +532,21 @@ class BaseContractFunction:
527
532
  transact_transaction = cast(TxParams, dict(**transaction))
528
533
 
529
534
  if "data" in transact_transaction:
530
- raise ValueError("Cannot set 'data' field in transact transaction")
535
+ raise Web3ValueError("Cannot set 'data' field in transact transaction")
531
536
 
532
537
  if self.address is not None:
533
538
  transact_transaction.setdefault("to", self.address)
534
539
  if self.w3.eth.default_account is not empty:
535
- # type ignored b/c check prevents an empty default_account
536
- transact_transaction.setdefault(
537
- "from", self.w3.eth.default_account # type: ignore
538
- )
540
+ transact_transaction.setdefault("from", self.w3.eth.default_account)
539
541
 
540
542
  if "to" not in transact_transaction:
541
543
  if isinstance(self, type):
542
- raise ValueError(
544
+ raise Web3ValueError(
543
545
  "When using `Contract.transact` from a contract factory you "
544
546
  "must provide a `to` address with the transaction"
545
547
  )
546
548
  else:
547
- raise ValueError(
549
+ raise Web3ValueError(
548
550
  "Please ensure that this contract instance has an address."
549
551
  )
550
552
  return transact_transaction
@@ -556,26 +558,23 @@ class BaseContractFunction:
556
558
  estimate_gas_transaction = cast(TxParams, dict(**transaction))
557
559
 
558
560
  if "data" in estimate_gas_transaction:
559
- raise ValueError("Cannot set 'data' field in estimate_gas transaction")
561
+ raise Web3ValueError("Cannot set 'data' field in estimate_gas transaction")
560
562
  if "to" in estimate_gas_transaction:
561
- raise ValueError("Cannot set to in estimate_gas transaction")
563
+ raise Web3ValueError("Cannot set to in estimate_gas transaction")
562
564
 
563
565
  if self.address:
564
566
  estimate_gas_transaction.setdefault("to", self.address)
565
567
  if self.w3.eth.default_account is not empty:
566
- # type ignored b/c check prevents an empty default_account
567
- estimate_gas_transaction.setdefault(
568
- "from", self.w3.eth.default_account # type: ignore
569
- )
568
+ estimate_gas_transaction.setdefault("from", self.w3.eth.default_account)
570
569
 
571
570
  if "to" not in estimate_gas_transaction:
572
571
  if isinstance(self, type):
573
- raise ValueError(
572
+ raise Web3ValueError(
574
573
  "When using `Contract.estimate_gas` from a contract factory "
575
574
  "you must provide a `to` address with the transaction"
576
575
  )
577
576
  else:
578
- raise ValueError(
577
+ raise Web3ValueError(
579
578
  "Please ensure that this contract instance has an address."
580
579
  )
581
580
  return estimate_gas_transaction
@@ -587,21 +586,23 @@ class BaseContractFunction:
587
586
  built_transaction = cast(TxParams, dict(**transaction))
588
587
 
589
588
  if "data" in built_transaction:
590
- raise ValueError("Cannot set 'data' field in build transaction")
589
+ raise Web3ValueError("Cannot set 'data' field in build transaction")
591
590
 
592
591
  if not self.address and "to" not in built_transaction:
593
- raise ValueError(
592
+ raise Web3ValueError(
594
593
  "When using `ContractFunction.build_transaction` from a contract "
595
594
  "factory you must provide a `to` address with the transaction"
596
595
  )
597
596
  if self.address and "to" in built_transaction:
598
- raise ValueError("Cannot set 'to' field in contract call build transaction")
597
+ raise Web3ValueError(
598
+ "Cannot set 'to' field in contract call build transaction"
599
+ )
599
600
 
600
601
  if self.address:
601
602
  built_transaction.setdefault("to", self.address)
602
603
 
603
604
  if "to" not in built_transaction:
604
- raise ValueError(
605
+ raise Web3ValueError(
605
606
  "Please ensure that this contract instance has an address."
606
607
  )
607
608
 
@@ -679,7 +680,8 @@ class BaseContractFunctions:
679
680
 
680
681
 
681
682
  class BaseContract:
682
- """Base class for Contract proxy classes.
683
+ """
684
+ Base class for Contract proxy classes.
683
685
 
684
686
  First you need to create your Contract classes using
685
687
  :meth:`web3.eth.Eth.contract` that takes compiled Solidity contract
@@ -760,7 +762,7 @@ class BaseContract:
760
762
  @combomethod
761
763
  def get_function_by_signature(self, signature: str) -> "BaseContractFunction":
762
764
  if " " in signature:
763
- raise ValueError(
765
+ raise Web3ValueError(
764
766
  "Function signature should not contain any spaces. "
765
767
  f"Found spaces in input: {signature}"
766
768
  )
@@ -792,9 +794,9 @@ class BaseContract:
792
794
  self, selector: Union[bytes, int, HexStr]
793
795
  ) -> "BaseContractFunction":
794
796
  def callable_check(fn_abi: ABIFunction) -> bool:
795
- # typed dict cannot be used w/ a normal Dict
796
- # https://github.com/python/mypy/issues/4976
797
- return encode_hex(function_abi_to_4byte_selector(fn_abi)) == to_4byte_hex(selector) # type: ignore # noqa: E501
797
+ return encode_hex(function_abi_to_4byte_selector(fn_abi)) == to_4byte_hex(
798
+ selector
799
+ )
798
800
 
799
801
  fns = self.find_functions_by_identifier(
800
802
  self.abi, self.w3, self.address, callable_check
@@ -805,8 +807,7 @@ class BaseContract:
805
807
  def decode_function_input(
806
808
  self, data: HexStr
807
809
  ) -> Tuple["BaseContractFunction", Dict[str, Any]]:
808
- # type ignored b/c expects data arg to be HexBytes
809
- data = HexBytes(data) # type: ignore
810
+ data = HexBytes(data)
810
811
  func = self.get_function_by_selector(data[:4])
811
812
  arguments = decode_transaction_data(
812
813
  func.abi, data, normalizers=BASE_RETURN_NORMALIZERS
@@ -893,7 +894,7 @@ class BaseContract:
893
894
  else:
894
895
  if args is not None or kwargs is not None:
895
896
  msg = "Constructor args were provided, but no constructor function was provided." # noqa: E501
896
- raise TypeError(msg)
897
+ raise Web3TypeError(msg)
897
898
 
898
899
  deploy_data = to_hex(cls.bytecode)
899
900
 
@@ -1088,10 +1089,7 @@ class BaseContractConstructor:
1088
1089
  )
1089
1090
 
1090
1091
  if self.w3.eth.default_account is not empty:
1091
- # type ignored b/c check prevents an empty default_account
1092
- estimate_gas_transaction.setdefault(
1093
- "from", self.w3.eth.default_account # type: ignore
1094
- )
1092
+ estimate_gas_transaction.setdefault("from", self.w3.eth.default_account)
1095
1093
 
1096
1094
  estimate_gas_transaction["data"] = self.data_in_transaction
1097
1095
 
@@ -1107,10 +1105,7 @@ class BaseContractConstructor:
1107
1105
  )
1108
1106
 
1109
1107
  if self.w3.eth.default_account is not empty:
1110
- # type ignored b/c check prevents an empty default_account
1111
- transact_transaction.setdefault(
1112
- "from", self.w3.eth.default_account # type: ignore
1113
- )
1108
+ transact_transaction.setdefault("from", self.w3.eth.default_account)
1114
1109
 
1115
1110
  transact_transaction["data"] = self.data_in_transaction
1116
1111
 
@@ -1128,7 +1123,7 @@ class BaseContractConstructor:
1128
1123
  ) -> None:
1129
1124
  keys_found = transaction.keys() & forbidden_keys
1130
1125
  if keys_found:
1131
- raise ValueError(
1126
+ raise Web3ValueError(
1132
1127
  f"Cannot set '{', '.join(keys_found)}' field(s) in transaction"
1133
1128
  )
1134
1129
 
web3/contract/contract.py CHANGED
@@ -81,7 +81,10 @@ from web3.exceptions import (
81
81
  ABIFunctionNotFound,
82
82
  NoABIFound,
83
83
  NoABIFunctionsFound,
84
+ Web3AttributeError,
85
+ Web3TypeError,
84
86
  Web3ValidationError,
87
+ Web3ValueError,
85
88
  )
86
89
  from web3.types import (
87
90
  ABI,
@@ -107,11 +110,12 @@ class ContractEvent(BaseContractEvent):
107
110
  def get_logs(
108
111
  self,
109
112
  argument_filters: Optional[Dict[str, Any]] = None,
110
- fromBlock: Optional[BlockIdentifier] = None,
111
- toBlock: Optional[BlockIdentifier] = None,
113
+ from_block: Optional[BlockIdentifier] = None,
114
+ to_block: Optional[BlockIdentifier] = None,
112
115
  block_hash: Optional[HexBytes] = None,
113
116
  ) -> Iterable[EventData]:
114
- """Get events for this contract instance using eth_getLogs API.
117
+ """
118
+ Get events for this contract instance using eth_getLogs API.
115
119
 
116
120
  This is a stateless method, as opposed to create_filter.
117
121
  It can be safely called against nodes which do not provide
@@ -127,10 +131,10 @@ class ContractEvent(BaseContractEvent):
127
131
 
128
132
  .. code-block:: python
129
133
 
130
- from = max(mycontract.web3.eth.block_number - 10, 1)
131
- 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
132
136
 
133
- events = mycontract.events.Transfer.get_logs(fromBlock=from, toBlock=to)
137
+ events = my_contract.events.Transfer.get_logs(from_block=from, to_block=to)
134
138
 
135
139
  for e in events:
136
140
  print(e["args"]["from"],
@@ -160,10 +164,10 @@ class ContractEvent(BaseContractEvent):
160
164
 
161
165
  :param argument_filters: Filter by argument values. Indexed arguments are
162
166
  filtered by the node while non-indexed arguments are filtered by the library.
163
- :param fromBlock: block number or "latest", defaults to "latest"
164
- :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"
165
169
  :param block_hash: block hash. block_hash cannot be set at the
166
- same time as fromBlock or toBlock
170
+ same time as ``from_block`` or ``to_block``
167
171
  :yield: Tuple of :class:`AttributeDict` instances
168
172
  """
169
173
  event_abi = self._get_event_abi()
@@ -178,7 +182,7 @@ class ContractEvent(BaseContractEvent):
178
182
  )
179
183
 
180
184
  _filter_params = self._get_event_filter_params(
181
- event_abi, argument_filters, fromBlock, toBlock, block_hash
185
+ event_abi, argument_filters, from_block, to_block, block_hash
182
186
  )
183
187
  # call JSON-RPC API
184
188
  logs = self.w3.eth.get_logs(_filter_params)
@@ -201,8 +205,8 @@ class ContractEvent(BaseContractEvent):
201
205
  self,
202
206
  *, # PEP 3102
203
207
  argument_filters: Optional[Dict[str, Any]] = None,
204
- fromBlock: Optional[BlockIdentifier] = None,
205
- toBlock: BlockIdentifier = "latest",
208
+ from_block: Optional[BlockIdentifier] = None,
209
+ to_block: BlockIdentifier = "latest",
206
210
  address: Optional[ChecksumAddress] = None,
207
211
  topics: Optional[Sequence[Any]] = None,
208
212
  ) -> LogFilter:
@@ -212,8 +216,8 @@ class ContractEvent(BaseContractEvent):
212
216
  filter_builder = EventFilterBuilder(self._get_event_abi(), self.w3.codec)
213
217
  self._set_up_filter_builder(
214
218
  argument_filters,
215
- fromBlock,
216
- toBlock,
219
+ from_block,
220
+ to_block,
217
221
  address,
218
222
  topics,
219
223
  filter_builder,
@@ -438,11 +442,13 @@ class Contract(BaseContract):
438
442
  events: ContractEvents = None
439
443
 
440
444
  def __init__(self, address: Optional[ChecksumAddress] = None) -> None:
441
- """Create a new smart contract proxy object.
442
- :param address: Contract address as 0x hex string"""
445
+ """
446
+ Create a new smart contract proxy object.
447
+ :param address: Contract address as 0x hex string
448
+ """
443
449
  _w3 = self.w3
444
450
  if _w3 is None:
445
- raise AttributeError(
451
+ raise Web3AttributeError(
446
452
  "The `Contract` class has not been initialized. Please use the "
447
453
  "`web3.contract` interface to create your contract class."
448
454
  )
@@ -451,7 +457,7 @@ class Contract(BaseContract):
451
457
  self.address = normalize_address(cast("ENS", _w3.ens), address)
452
458
 
453
459
  if not self.address:
454
- raise TypeError(
460
+ raise Web3TypeError(
455
461
  "The address argument is required to instantiate a contract."
456
462
  )
457
463
 
@@ -528,7 +534,7 @@ class Contract(BaseContract):
528
534
  :return: a contract constructor object
529
535
  """
530
536
  if cls.bytecode is None:
531
- raise ValueError(
537
+ raise Web3ValueError(
532
538
  "Cannot call constructor on a contract that does not have "
533
539
  "'bytecode' associated with it"
534
540
  )
web3/contract/utils.py CHANGED
@@ -43,6 +43,7 @@ from web3._utils.transactions import (
43
43
  )
44
44
  from web3.exceptions import (
45
45
  BadFunctionCallOutput,
46
+ Web3ValueError,
46
47
  )
47
48
  from web3.types import (
48
49
  ABI,
@@ -185,7 +186,8 @@ def estimate_gas_for_function(
185
186
  *args: Any,
186
187
  **kwargs: Any,
187
188
  ) -> int:
188
- """Estimates gas cost a function call would take.
189
+ """
190
+ Estimates gas cost a function call would take.
189
191
 
190
192
  Don't call this directly, instead use :meth:`Contract.estimate_gas`
191
193
  on your contract instance.
@@ -214,7 +216,8 @@ def build_transaction_for_function(
214
216
  *args: Any,
215
217
  **kwargs: Any,
216
218
  ) -> TxParams:
217
- """Builds a dictionary with the fields required to make the given transaction
219
+ """
220
+ Builds a dictionary with the fields required to make the given transaction
218
221
 
219
222
  Don't call this directly, instead use :meth:`Contract.build_transaction`
220
223
  on your contract instance.
@@ -261,11 +264,11 @@ def get_function_by_identifier(
261
264
  fns: Sequence[TContractFn], identifier: str
262
265
  ) -> TContractFn:
263
266
  if len(fns) > 1:
264
- raise ValueError(
267
+ raise Web3ValueError(
265
268
  f"Found multiple functions with matching {identifier}. " f"Found: {fns!r}"
266
269
  )
267
270
  elif len(fns) == 0:
268
- raise ValueError(f"Could not find any function with matching {identifier}")
271
+ raise Web3ValueError(f"Could not find any function with matching {identifier}")
269
272
  return fns[0]
270
273
 
271
274
 
@@ -394,7 +397,8 @@ async def async_estimate_gas_for_function(
394
397
  *args: Any,
395
398
  **kwargs: Any,
396
399
  ) -> int:
397
- """Estimates gas cost a function call would take.
400
+ """
401
+ Estimates gas cost a function call would take.
398
402
 
399
403
  Don't call this directly, instead use :meth:`Contract.estimate_gas`
400
404
  on your contract instance.
@@ -425,7 +429,8 @@ async def async_build_transaction_for_function(
425
429
  *args: Any,
426
430
  **kwargs: Any,
427
431
  ) -> TxParams:
428
- """Builds a dictionary with the fields required to make the given transaction
432
+ """
433
+ Builds a dictionary with the fields required to make the given transaction
429
434
 
430
435
  Don't call this directly, instead use :meth:`Contract.build_transaction`
431
436
  on your contract instance.