web3 7.0.0b3__py3-none-any.whl → 7.0.0b4__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 (79) 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 +12 -12
  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 +20 -18
  23. web3/_utils/fee_utils.py +2 -4
  24. web3/_utils/filters.py +17 -12
  25. web3/_utils/formatters.py +2 -2
  26. web3/_utils/math.py +3 -2
  27. web3/_utils/method_formatters.py +24 -5
  28. web3/_utils/module.py +2 -1
  29. web3/_utils/module_testing/eth_module.py +62 -69
  30. web3/_utils/module_testing/go_ethereum_personal_module.py +1 -1
  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 -1
  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 +12 -7
  41. web3/contract/base_contract.py +50 -56
  42. web3/contract/contract.py +12 -6
  43. web3/contract/utils.py +11 -6
  44. web3/datastructures.py +22 -12
  45. web3/eth/async_eth.py +33 -28
  46. web3/eth/base_eth.py +7 -3
  47. web3/eth/eth.py +18 -13
  48. web3/exceptions.py +30 -59
  49. web3/gas_strategies/time_based.py +2 -4
  50. web3/geth.py +1 -3
  51. web3/main.py +6 -2
  52. web3/manager.py +7 -5
  53. web3/method.py +13 -5
  54. web3/middleware/base.py +4 -2
  55. web3/middleware/filter.py +27 -17
  56. web3/middleware/formatting.py +6 -3
  57. web3/middleware/names.py +4 -1
  58. web3/middleware/signing.py +6 -2
  59. web3/middleware/stalecheck.py +2 -1
  60. web3/providers/eth_tester/defaults.py +1 -1
  61. web3/providers/eth_tester/main.py +5 -4
  62. web3/providers/eth_tester/middleware.py +10 -1
  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 +23 -6
  69. web3/providers/rpc/rpc.py +27 -16
  70. web3/testing.py +4 -4
  71. web3/tools/benchmark/main.py +13 -9
  72. web3/tools/benchmark/utils.py +1 -1
  73. web3/tracing.py +9 -5
  74. web3/types.py +19 -22
  75. {web3-7.0.0b3.dist-info → web3-7.0.0b4.dist-info}/METADATA +13 -28
  76. {web3-7.0.0b3.dist-info → web3-7.0.0b4.dist-info}/RECORD +79 -79
  77. {web3-7.0.0b3.dist-info → web3-7.0.0b4.dist-info}/LICENSE +0 -0
  78. {web3-7.0.0b3.dist-info → web3-7.0.0b4.dist-info}/WHEEL +0 -0
  79. {web3-7.0.0b3.dist-info → web3-7.0.0b4.dist-info}/top_level.txt +0 -0
@@ -139,7 +139,10 @@ RPC_ACCESS_LIST = [
139
139
  if TYPE_CHECKING:
140
140
  from _pytest.monkeypatch import MonkeyPatch # noqa: F401
141
141
 
142
- from web3.contract import Contract # noqa: F401
142
+ from web3.contract import ( # noqa: F401
143
+ AsyncContract,
144
+ Contract,
145
+ )
143
146
  from web3.main import ( # noqa: F401
144
147
  AsyncWeb3,
145
148
  Web3,
@@ -147,7 +150,8 @@ if TYPE_CHECKING:
147
150
 
148
151
 
149
152
  def abi_encoded_offchain_lookup_contract_address(
150
- w3: Union["Web3", "AsyncWeb3"], offchain_lookup_contract: "Contract"
153
+ w3: Union["Web3", "AsyncWeb3"],
154
+ offchain_lookup_contract: Union["Contract", "AsyncContract"],
151
155
  ) -> HexAddress:
152
156
  return HexAddress(
153
157
  remove_0x_prefix(
@@ -834,7 +838,7 @@ class AsyncEthModuleTest:
834
838
  async def test_eth_estimate_gas_with_override_param_type_check(
835
839
  self,
836
840
  async_w3: "AsyncWeb3",
837
- async_math_contract: "Contract",
841
+ async_math_contract: "AsyncContract",
838
842
  params: StateOverrideParams,
839
843
  ) -> None:
840
844
  txn_params: TxParams = {"from": await async_w3.eth.coinbase}
@@ -1100,9 +1104,7 @@ class AsyncEthModuleTest:
1100
1104
  f"{unknown_identifier}"
1101
1105
  ),
1102
1106
  ):
1103
- await async_w3.eth.get_raw_transaction_by_block(
1104
- unknown_identifier, 0 # type: ignore
1105
- )
1107
+ await async_w3.eth.get_raw_transaction_by_block(unknown_identifier, 0)
1106
1108
 
1107
1109
  @pytest.mark.asyncio
1108
1110
  async def test_eth_get_balance(self, async_w3: "AsyncWeb3") -> None:
@@ -1130,7 +1132,7 @@ class AsyncEthModuleTest:
1130
1132
  async def test_eth_get_code_invalid_address(
1131
1133
  self,
1132
1134
  async_w3: "AsyncWeb3",
1133
- async_math_contract: "Contract",
1135
+ async_math_contract: "AsyncContract",
1134
1136
  ) -> None:
1135
1137
  with pytest.raises(InvalidAddress):
1136
1138
  await async_w3.eth.get_code(
@@ -1139,7 +1141,7 @@ class AsyncEthModuleTest:
1139
1141
 
1140
1142
  @pytest.mark.asyncio
1141
1143
  async def test_eth_get_code_with_block_identifier(
1142
- self, async_w3: "AsyncWeb3", async_emitter_contract: "Contract"
1144
+ self, async_w3: "AsyncWeb3", async_emitter_contract: "AsyncContract"
1143
1145
  ) -> None:
1144
1146
  block_id = await async_w3.eth.block_number
1145
1147
  code = await async_w3.eth.get_code(async_emitter_contract.address, block_id)
@@ -1151,28 +1153,15 @@ class AsyncEthModuleTest:
1151
1153
  self,
1152
1154
  async_w3: "AsyncWeb3",
1153
1155
  async_unlocked_account_dual_type: ChecksumAddress,
1154
- async_math_contract: "Contract",
1156
+ async_math_contract: "AsyncContract",
1155
1157
  ) -> None:
1156
- # Initialize transaction for gas estimation
1157
- txn_params: TxParams = {
1158
- "from": async_unlocked_account_dual_type,
1159
- "value": Wei(1),
1160
- "gas": 21000,
1161
- }
1162
- txn = async_math_contract._prepare_transaction(
1163
- fn_name="incrementCounter",
1164
- fn_args=[1],
1165
- transaction=txn_params,
1158
+ # build txn
1159
+ txn = await async_math_contract.functions.incrementCounter(1).build_transaction(
1160
+ {"from": async_unlocked_account_dual_type}
1166
1161
  )
1167
1162
 
1168
- # create access list using data from transaction
1169
- response = await async_w3.eth.create_access_list(
1170
- {
1171
- "from": async_unlocked_account_dual_type,
1172
- "to": async_math_contract.address,
1173
- "data": txn["data"],
1174
- }
1175
- )
1163
+ # create access list
1164
+ response = await async_w3.eth.create_access_list(txn)
1176
1165
 
1177
1166
  assert is_dict(response)
1178
1167
  access_list = response["accessList"]
@@ -1182,6 +1171,13 @@ class AsyncEthModuleTest:
1182
1171
  assert len(access_list[0]["storageKeys"][0]) == 32
1183
1172
  assert int(response["gasUsed"]) >= 0
1184
1173
 
1174
+ # assert the result can be used directly in a transaction dict
1175
+ txn["accessList"] = response["accessList"]
1176
+ txn["gas"] = response["gasUsed"]
1177
+
1178
+ # send txn with access list
1179
+ await async_w3.eth.send_transaction(txn)
1180
+
1185
1181
  @pytest.mark.asyncio
1186
1182
  async def test_eth_get_transaction_count(
1187
1183
  self, async_w3: "AsyncWeb3", async_unlocked_account_dual_type: ChecksumAddress
@@ -1194,7 +1190,7 @@ class AsyncEthModuleTest:
1194
1190
 
1195
1191
  @pytest.mark.asyncio
1196
1192
  async def test_eth_call(
1197
- self, async_w3: "AsyncWeb3", async_math_contract: "Contract"
1193
+ self, async_w3: "AsyncWeb3", async_math_contract: "AsyncContract"
1198
1194
  ) -> None:
1199
1195
  coinbase = await async_w3.eth.coinbase
1200
1196
  txn_params = async_math_contract._prepare_transaction(
@@ -1211,7 +1207,7 @@ class AsyncEthModuleTest:
1211
1207
  async def test_eth_call_with_override_code(
1212
1208
  self,
1213
1209
  async_w3: "AsyncWeb3",
1214
- async_revert_contract: "Contract",
1210
+ async_revert_contract: "AsyncContract",
1215
1211
  ) -> None:
1216
1212
  coinbase = await async_w3.eth.coinbase
1217
1213
  txn_params = async_revert_contract._prepare_transaction(
@@ -1267,7 +1263,7 @@ class AsyncEthModuleTest:
1267
1263
  async def test_eth_call_with_override_param_type_check(
1268
1264
  self,
1269
1265
  async_w3: "AsyncWeb3",
1270
- async_math_contract: "Contract",
1266
+ async_math_contract: "AsyncContract",
1271
1267
  params: StateOverrideParams,
1272
1268
  ) -> None:
1273
1269
  coinbase = await async_w3.eth.coinbase
@@ -1280,7 +1276,7 @@ class AsyncEthModuleTest:
1280
1276
 
1281
1277
  @pytest.mark.asyncio
1282
1278
  async def test_eth_call_with_0_result(
1283
- self, async_w3: "AsyncWeb3", async_math_contract: "Contract"
1279
+ self, async_w3: "AsyncWeb3", async_math_contract: "AsyncContract"
1284
1280
  ) -> None:
1285
1281
  coinbase = await async_w3.eth.coinbase
1286
1282
  txn_params = async_math_contract._prepare_transaction(
@@ -1297,7 +1293,7 @@ class AsyncEthModuleTest:
1297
1293
  async def test_eth_call_revert_with_msg(
1298
1294
  self,
1299
1295
  async_w3: "AsyncWeb3",
1300
- async_revert_contract: "Contract",
1296
+ async_revert_contract: "AsyncContract",
1301
1297
  async_unlocked_account: ChecksumAddress,
1302
1298
  ) -> None:
1303
1299
  txn_params = async_revert_contract._prepare_transaction(
@@ -1316,7 +1312,7 @@ class AsyncEthModuleTest:
1316
1312
  async def test_eth_call_revert_without_msg(
1317
1313
  self,
1318
1314
  async_w3: "AsyncWeb3",
1319
- async_revert_contract: "Contract",
1315
+ async_revert_contract: "AsyncContract",
1320
1316
  async_unlocked_account: ChecksumAddress,
1321
1317
  ) -> None:
1322
1318
  with pytest.raises(ContractLogicError, match="execution reverted"):
@@ -1333,7 +1329,7 @@ class AsyncEthModuleTest:
1333
1329
  async def test_eth_call_revert_custom_error_with_msg(
1334
1330
  self,
1335
1331
  async_w3: "AsyncWeb3",
1336
- async_revert_contract: "Contract",
1332
+ async_revert_contract: "AsyncContract",
1337
1333
  async_unlocked_account: ChecksumAddress,
1338
1334
  ) -> None:
1339
1335
  data = async_revert_contract.encode_abi(
@@ -1353,7 +1349,7 @@ class AsyncEthModuleTest:
1353
1349
  async def test_eth_call_revert_custom_error_without_msg(
1354
1350
  self,
1355
1351
  async_w3: "AsyncWeb3",
1356
- async_revert_contract: "Contract",
1352
+ async_revert_contract: "AsyncContract",
1357
1353
  async_unlocked_account: ChecksumAddress,
1358
1354
  ) -> None:
1359
1355
  data = async_revert_contract.encode_abi(fn_name="Unauthorized")
@@ -1385,7 +1381,7 @@ class AsyncEthModuleTest:
1385
1381
  async def test_contract_panic_errors(
1386
1382
  self,
1387
1383
  async_w3: "AsyncWeb3",
1388
- async_panic_errors_contract: "Contract",
1384
+ async_panic_errors_contract: "AsyncContract",
1389
1385
  panic_error: str,
1390
1386
  params: List[Any],
1391
1387
  ) -> None:
@@ -1402,7 +1398,7 @@ class AsyncEthModuleTest:
1402
1398
  async def test_eth_call_offchain_lookup(
1403
1399
  self,
1404
1400
  async_w3: "AsyncWeb3",
1405
- async_offchain_lookup_contract: "Contract",
1401
+ async_offchain_lookup_contract: "AsyncContract",
1406
1402
  async_unlocked_account: ChecksumAddress,
1407
1403
  monkeypatch: "MonkeyPatch",
1408
1404
  ) -> None:
@@ -1428,7 +1424,7 @@ class AsyncEthModuleTest:
1428
1424
  async def test_eth_call_offchain_lookup_raises_when_ccip_read_is_disabled(
1429
1425
  self,
1430
1426
  async_w3: "AsyncWeb3",
1431
- async_offchain_lookup_contract: "Contract",
1427
+ async_offchain_lookup_contract: "AsyncContract",
1432
1428
  ) -> None:
1433
1429
  return_data = (
1434
1430
  OFFCHAIN_LOOKUP_4BYTE_DATA
@@ -1466,7 +1462,7 @@ class AsyncEthModuleTest:
1466
1462
  async def test_eth_call_offchain_lookup_call_flag_overrides_provider_flag(
1467
1463
  self,
1468
1464
  async_w3: "AsyncWeb3",
1469
- async_offchain_lookup_contract: "Contract",
1465
+ async_offchain_lookup_contract: "AsyncContract",
1470
1466
  async_unlocked_account: ChecksumAddress,
1471
1467
  monkeypatch: "MonkeyPatch",
1472
1468
  ) -> None:
@@ -1494,7 +1490,7 @@ class AsyncEthModuleTest:
1494
1490
  async def test_eth_call_offchain_lookup_raises_if_max_redirects_is_less_than_4(
1495
1491
  self,
1496
1492
  async_w3: "AsyncWeb3",
1497
- async_offchain_lookup_contract: "Contract",
1493
+ async_offchain_lookup_contract: "AsyncContract",
1498
1494
  max_redirects: int,
1499
1495
  ) -> None:
1500
1496
  default_max_redirects = async_w3.provider.ccip_read_max_redirects
@@ -1511,7 +1507,7 @@ class AsyncEthModuleTest:
1511
1507
  async def test_eth_call_offchain_lookup_raises_for_improperly_formatted_rest_request_response( # noqa: E501
1512
1508
  self,
1513
1509
  async_w3: "AsyncWeb3",
1514
- async_offchain_lookup_contract: "Contract",
1510
+ async_offchain_lookup_contract: "AsyncContract",
1515
1511
  async_unlocked_account: ChecksumAddress,
1516
1512
  monkeypatch: "MonkeyPatch",
1517
1513
  ) -> None:
@@ -1535,7 +1531,7 @@ class AsyncEthModuleTest:
1535
1531
  async def test_eth_call_offchain_lookup_tries_next_url_for_non_4xx_error_status_and_tests_POST( # noqa: E501
1536
1532
  self,
1537
1533
  async_w3: "AsyncWeb3",
1538
- async_offchain_lookup_contract: "Contract",
1534
+ async_offchain_lookup_contract: "AsyncContract",
1539
1535
  async_unlocked_account: ChecksumAddress,
1540
1536
  monkeypatch: "MonkeyPatch",
1541
1537
  status_code_non_4xx_error: int,
@@ -1573,7 +1569,7 @@ class AsyncEthModuleTest:
1573
1569
  async def test_eth_call_offchain_lookup_calls_raise_for_status_for_4xx_status_code(
1574
1570
  self,
1575
1571
  async_w3: "AsyncWeb3",
1576
- async_offchain_lookup_contract: "Contract",
1572
+ async_offchain_lookup_contract: "AsyncContract",
1577
1573
  async_unlocked_account: ChecksumAddress,
1578
1574
  monkeypatch: "MonkeyPatch",
1579
1575
  ) -> None:
@@ -1596,7 +1592,7 @@ class AsyncEthModuleTest:
1596
1592
  async def test_eth_call_offchain_lookup_raises_when_all_supplied_urls_fail(
1597
1593
  self,
1598
1594
  async_w3: "AsyncWeb3",
1599
- async_offchain_lookup_contract: "Contract",
1595
+ async_offchain_lookup_contract: "AsyncContract",
1600
1596
  ) -> None:
1601
1597
  # GET and POST requests should fail since responses are not mocked
1602
1598
  with pytest.raises(
@@ -1610,7 +1606,7 @@ class AsyncEthModuleTest:
1610
1606
  async def test_eth_call_continuous_offchain_lookup_raises_with_too_many_requests(
1611
1607
  self,
1612
1608
  async_w3: "AsyncWeb3",
1613
- async_offchain_lookup_contract: "Contract",
1609
+ async_offchain_lookup_contract: "AsyncContract",
1614
1610
  async_unlocked_account: ChecksumAddress,
1615
1611
  monkeypatch: "MonkeyPatch",
1616
1612
  ) -> None:
@@ -1685,7 +1681,7 @@ class AsyncEthModuleTest:
1685
1681
  self,
1686
1682
  async_w3: "AsyncWeb3",
1687
1683
  async_block_with_txn_with_log: BlockData,
1688
- async_emitter_contract: "Contract",
1684
+ async_emitter_contract: "AsyncContract",
1689
1685
  txn_hash_with_log: HexStr,
1690
1686
  ) -> None:
1691
1687
  receipt = await async_w3.eth.wait_for_transaction_receipt(txn_hash_with_log)
@@ -1752,7 +1748,7 @@ class AsyncEthModuleTest:
1752
1748
  self,
1753
1749
  async_w3: "AsyncWeb3",
1754
1750
  async_block_with_txn_with_log: BlockData,
1755
- async_emitter_contract: "Contract",
1751
+ async_emitter_contract: "AsyncContract",
1756
1752
  txn_hash_with_log: HexStr,
1757
1753
  ) -> None:
1758
1754
  receipt = await async_w3.eth.wait_for_transaction_receipt(txn_hash_with_log)
@@ -1777,7 +1773,7 @@ class AsyncEthModuleTest:
1777
1773
  accounts = await async_w3.eth.accounts
1778
1774
  assert is_list_like(accounts)
1779
1775
  assert len(accounts) != 0
1780
- assert all((is_checksum_address(account) for account in accounts))
1776
+ assert all(is_checksum_address(account) for account in accounts)
1781
1777
  assert await async_w3.eth.coinbase in accounts
1782
1778
 
1783
1779
  @pytest.mark.asyncio
@@ -1950,7 +1946,7 @@ class AsyncEthModuleTest:
1950
1946
 
1951
1947
  @pytest.mark.asyncio
1952
1948
  async def test_async_eth_get_storage_at(
1953
- self, async_w3: "AsyncWeb3", async_storage_contract: "Contract"
1949
+ self, async_w3: "AsyncWeb3", async_storage_contract: "AsyncContract"
1954
1950
  ) -> None:
1955
1951
  async_storage_contract_address = async_storage_contract.address
1956
1952
 
@@ -1978,7 +1974,7 @@ class AsyncEthModuleTest:
1978
1974
  @pytest.mark.asyncio
1979
1975
  @pytest.mark.xfail
1980
1976
  async def test_async_eth_get_storage_at_ens_name(
1981
- self, async_w3: "AsyncWeb3", async_storage_contract: "Contract"
1977
+ self, async_w3: "AsyncWeb3", async_storage_contract: "AsyncContract"
1982
1978
  ) -> None:
1983
1979
  with ens_addresses(async_w3, {"storage.eth": async_storage_contract.address}):
1984
1980
  storage = await async_w3.eth.get_storage_at(ENS("storage.eth"), 1)
@@ -2536,7 +2532,7 @@ class EthModuleTest:
2536
2532
  accounts = w3.eth.accounts
2537
2533
  assert is_list_like(accounts)
2538
2534
  assert len(accounts) != 0
2539
- assert all((is_checksum_address(account) for account in accounts))
2535
+ assert all(is_checksum_address(account) for account in accounts)
2540
2536
  assert w3.eth.coinbase in accounts
2541
2537
 
2542
2538
  def test_eth_block_number(self, w3: "Web3") -> None:
@@ -2735,24 +2731,14 @@ class EthModuleTest:
2735
2731
  unlocked_account_dual_type: ChecksumAddress,
2736
2732
  math_contract: "Contract",
2737
2733
  ) -> None:
2738
- # Initialize transaction for gas estimation
2739
- txn_params: TxParams = {
2740
- "from": unlocked_account_dual_type,
2741
- "value": Wei(1),
2742
- "gas": 21000,
2743
- }
2744
-
2745
- txn = math_contract.functions.incrementCounter(1).build_transaction(txn_params)
2746
-
2747
- # create access list using data from transaction
2748
- response = w3.eth.create_access_list(
2749
- {
2750
- "from": unlocked_account_dual_type,
2751
- "to": math_contract.address,
2752
- "data": txn["data"],
2753
- }
2734
+ # build txn
2735
+ txn = math_contract.functions.incrementCounter(1).build_transaction(
2736
+ {"from": unlocked_account_dual_type}
2754
2737
  )
2755
2738
 
2739
+ # create access list
2740
+ response = w3.eth.create_access_list(txn)
2741
+
2756
2742
  assert is_dict(response)
2757
2743
  access_list = response["accessList"]
2758
2744
  assert len(access_list) > 0
@@ -2761,6 +2747,13 @@ class EthModuleTest:
2761
2747
  assert len(access_list[0]["storageKeys"][0]) == 32
2762
2748
  assert int(response["gasUsed"]) >= 0
2763
2749
 
2750
+ # assert the result can be used directly in a transaction dict
2751
+ txn["accessList"] = response["accessList"]
2752
+ txn["gas"] = response["gasUsed"]
2753
+
2754
+ # send txn with access list
2755
+ w3.eth.send_transaction(txn)
2756
+
2764
2757
  def test_eth_sign(
2765
2758
  self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress
2766
2759
  ) -> None:
@@ -4255,7 +4248,7 @@ class EthModuleTest:
4255
4248
  ) -> None:
4256
4249
  block = w3.eth.get_block(block_with_txn["number"], True)
4257
4250
  transaction = block["transactions"][0]
4258
- assert transaction["hash"] == block_with_txn["transactions"][0] # type: ignore
4251
+ assert transaction["hash"] == block_with_txn["transactions"][0]
4259
4252
 
4260
4253
  def test_eth_getBlockReceipts_hash(
4261
4254
  self, w3: "Web3", empty_block: BlockData
@@ -4714,7 +4707,7 @@ class EthModuleTest:
4714
4707
  f"{unknown_identifier}"
4715
4708
  ),
4716
4709
  ):
4717
- w3.eth.get_raw_transaction_by_block(unknown_identifier, 0) # type: ignore
4710
+ w3.eth.get_raw_transaction_by_block(unknown_identifier, 0)
4718
4711
 
4719
4712
  def test_default_account(
4720
4713
  self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress
@@ -62,7 +62,7 @@ class GoEthereumPersonalModuleTest:
62
62
  accounts = w3.geth.personal.list_accounts()
63
63
  assert is_list_like(accounts)
64
64
  assert len(accounts) > 0
65
- assert all((is_checksum_address(item) for item in accounts))
65
+ assert all(is_checksum_address(item) for item in accounts)
66
66
 
67
67
  def test_personal_list_wallets(self, w3: "Web3") -> None:
68
68
  wallets = w3.geth.personal.list_wallets()
@@ -7,6 +7,7 @@ from typing import (
7
7
  Collection,
8
8
  Dict,
9
9
  Generator,
10
+ Literal,
10
11
  Sequence,
11
12
  Union,
12
13
  )
@@ -28,9 +29,6 @@ from hexbytes import (
28
29
  HexBytes,
29
30
  )
30
31
 
31
- from web3._utils.compat import (
32
- Literal,
33
- )
34
32
  from web3._utils.request import (
35
33
  async_cache_and_return_session,
36
34
  cache_and_return_session,
@@ -36,6 +36,7 @@ class RequestMocker:
36
36
  via a ``request_mocker`` fixture defined within the appropriate context.
37
37
 
38
38
  Example:
39
+ -------
39
40
 
40
41
  def test_my_w3(w3, request_mocker):
41
42
  assert w3.eth.block_number == 0
@@ -46,6 +47,7 @@ class RequestMocker:
46
47
  assert w3.eth.block_number == 0
47
48
 
48
49
  Example with async and a mocked response object:
50
+ -----------------------------------------------
49
51
 
50
52
  async def test_my_w3(async_w3, request_mocker):
51
53
  def _iter_responses():
@@ -77,6 +79,7 @@ class RequestMocker:
77
79
 
78
80
  If a method name is not present in any of the dicts above, the request is made as
79
81
  usual.
82
+
80
83
  """
81
84
 
82
85
  def __init__(
@@ -90,12 +93,13 @@ class RequestMocker:
90
93
  self.mock_results = mock_results or {}
91
94
  self.mock_errors = mock_errors or {}
92
95
  self.mock_responses = mock_responses or {}
93
- self._make_request: Union["AsyncMakeRequestFn", "MakeRequestFn"] = (
94
- w3.provider.make_request
95
- )
96
+ self._make_request: Union[
97
+ "AsyncMakeRequestFn", "MakeRequestFn"
98
+ ] = w3.provider.make_request
96
99
 
97
100
  def __enter__(self) -> "Self":
98
- setattr(self.w3.provider, "make_request", self._mock_request_handler)
101
+ # mypy error: Cannot assign to a method
102
+ self.w3.provider.make_request = self._mock_request_handler # type: ignore[method-assign] # noqa: E501
99
103
  # reset request func cache to re-build request_func with mocked make_request
100
104
  self.w3.provider._request_func_cache = (None, None)
101
105
 
@@ -103,7 +107,8 @@ class RequestMocker:
103
107
 
104
108
  # define __exit__ with typing information
105
109
  def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:
106
- setattr(self.w3.provider, "make_request", self._make_request)
110
+ # mypy error: Cannot assign to a method
111
+ self.w3.provider.make_request = self._make_request # type: ignore[method-assign] # noqa: E501
107
112
  # reset request func cache to re-build request_func with original make_request
108
113
  self.w3.provider._request_func_cache = (None, None)
109
114
 
@@ -163,13 +168,15 @@ class RequestMocker:
163
168
 
164
169
  # -- async -- #
165
170
  async def __aenter__(self) -> "Self":
166
- setattr(self.w3.provider, "make_request", self._async_mock_request_handler)
171
+ # mypy error: Cannot assign to a method
172
+ self.w3.provider.make_request = self._async_mock_request_handler # type: ignore[method-assign] # noqa: E501
167
173
  # reset request func cache to re-build request_func with mocked make_request
168
174
  self.w3.provider._request_func_cache = (None, None)
169
175
  return self
170
176
 
171
177
  async def __aexit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:
172
- setattr(self.w3.provider, "make_request", self._make_request)
178
+ # mypy error: Cannot assign to a method
179
+ self.w3.provider.make_request = self._make_request # type: ignore[method-assign] # noqa: E501
173
180
  # reset request func cache to re-build request_func with original make_request
174
181
  self.w3.provider._request_func_cache = (None, None)
175
182
 
@@ -60,6 +60,7 @@ from web3._utils.validation import (
60
60
  from web3.exceptions import (
61
61
  InvalidAddress,
62
62
  NameNotFound,
63
+ Web3ValueError,
63
64
  )
64
65
  from web3.types import (
65
66
  ABI,
@@ -151,7 +152,7 @@ def abi_bytes_to_hex(
151
152
 
152
153
  num_bytes = abi_type.sub
153
154
  if len(bytes_data) > num_bytes:
154
- raise ValueError(
155
+ raise Web3ValueError(
155
156
  f"This value was expected to be at most {num_bytes} bytes, "
156
157
  f"but instead was {len(bytes_data)}: {data!r}"
157
158
  )
@@ -273,8 +274,7 @@ def normalize_address_no_ens(address: ChecksumAddress) -> ChecksumAddress:
273
274
  def normalize_bytecode(bytecode: bytes) -> HexBytes:
274
275
  if bytecode:
275
276
  bytecode = HexBytes(bytecode)
276
- # type ignored b/c bytecode is converted to HexBytes above
277
- return bytecode # type: ignore
277
+ return bytecode
278
278
 
279
279
 
280
280
  # --- async -- #
web3/_utils/request.py CHANGED
@@ -109,9 +109,9 @@ def get_response_from_post_request(
109
109
 
110
110
 
111
111
  def make_post_request(
112
- endpoint_uri: URI, data: Union[bytes, Dict[str, Any]], *args: Any, **kwargs: Any
112
+ endpoint_uri: URI, data: Union[bytes, Dict[str, Any]], **kwargs: Any
113
113
  ) -> bytes:
114
- response = get_response_from_post_request(endpoint_uri, data=data, *args, **kwargs)
114
+ response = get_response_from_post_request(endpoint_uri, data=data, **kwargs)
115
115
  response.raise_for_status()
116
116
  return response.content
117
117
 
@@ -236,10 +236,10 @@ async def async_get_response_from_post_request(
236
236
 
237
237
 
238
238
  async def async_make_post_request(
239
- endpoint_uri: URI, data: Union[bytes, Dict[str, Any]], *args: Any, **kwargs: Any
239
+ endpoint_uri: URI, data: Union[bytes, Dict[str, Any]], **kwargs: Any
240
240
  ) -> bytes:
241
241
  response = await async_get_response_from_post_request(
242
- endpoint_uri, data=data, *args, **kwargs
242
+ endpoint_uri, data=data, **kwargs
243
243
  )
244
244
  response.raise_for_status()
245
245
  return await response.read()
web3/_utils/rpc_abi.py CHANGED
@@ -24,6 +24,9 @@ from eth_utils.toolz import (
24
24
  from web3._utils.abi import (
25
25
  map_abi_data,
26
26
  )
27
+ from web3.exceptions import (
28
+ Web3TypeError,
29
+ )
27
30
  from web3.types import (
28
31
  RPCEndpoint,
29
32
  )
@@ -158,6 +161,7 @@ TRANSACTION_PARAMS_ABIS = {
158
161
  "from": "address",
159
162
  "gas": "uint",
160
163
  "gasPrice": "uint",
164
+ "maxFeePerBlobGas": "uint",
161
165
  "maxFeePerGas": "uint",
162
166
  "maxPriorityFeePerGas": "uint",
163
167
  "nonce": "uint",
@@ -246,6 +250,6 @@ def abi_request_formatters(
246
250
  single_dict_formatter = apply_abi_formatters_to_dict(normalizers, abi_types)
247
251
  yield method, apply_formatter_at_index(single_dict_formatter, 0)
248
252
  else:
249
- raise TypeError(
253
+ raise Web3TypeError(
250
254
  f"ABI definitions must be a list or dictionary, got {abi_types!r}"
251
255
  )
web3/_utils/threads.py CHANGED
@@ -12,11 +12,12 @@ from typing import (
12
12
  Any,
13
13
  Callable,
14
14
  Generic,
15
+ Literal,
15
16
  Type,
16
17
  )
17
18
 
18
- from web3._utils.compat import (
19
- Literal,
19
+ from web3.exceptions import (
20
+ Web3ValueError,
20
21
  )
21
22
  from web3.types import (
22
23
  TReturn,
@@ -63,24 +64,24 @@ class Timeout(Exception):
63
64
  @property
64
65
  def expire_at(self) -> int:
65
66
  if self.seconds is None:
66
- raise ValueError(
67
+ raise Web3ValueError(
67
68
  "Timeouts with `seconds == None` do not have an expiration time"
68
69
  )
69
70
  elif self.begun_at is None:
70
- raise ValueError("Timeout has not been started")
71
+ raise Web3ValueError("Timeout has not been started")
71
72
  return self.begun_at + self.seconds
72
73
 
73
74
  def start(self) -> None:
74
75
  if self.is_running is not None:
75
- raise ValueError("Timeout has already been started")
76
+ raise Web3ValueError("Timeout has already been started")
76
77
  self.begun_at = time.time()
77
78
  self.is_running = True
78
79
 
79
80
  def check(self) -> None:
80
81
  if self.is_running is None:
81
- raise ValueError("Timeout has not been started")
82
+ raise Web3ValueError("Timeout has not been started")
82
83
  elif self.is_running is False:
83
- raise ValueError("Timeout has already been cancelled")
84
+ raise Web3ValueError("Timeout has already been cancelled")
84
85
  elif self.seconds is None:
85
86
  return
86
87
  elif time.time() > self.expire_at: