diff --git a/docs/overview.rst b/docs/overview.rst index 5e9b288514..9150890796 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -166,8 +166,6 @@ API - :meth:`web3.eth.get_transaction() ` - :meth:`web3.eth.get_transaction_by_block() ` - :meth:`web3.eth.get_transaction_count() ` -- :meth:`web3.eth.get_uncle_by_block() ` -- :meth:`web3.eth.get_uncle_count() ` Sending Transactions diff --git a/docs/web3.eth.rst b/docs/web3.eth.rst index 9d391938b4..4bf4ffa79d 100644 --- a/docs/web3.eth.rst +++ b/docs/web3.eth.rst @@ -396,77 +396,6 @@ The following methods are available on the ``web3.eth`` namespace. 1 -.. py:method:: Eth.get_uncle_by_block(block_identifier, uncle_index) - - .. warning:: Deprecated. Will be removed in v8. - - * Delegates to ``eth_getUncleByBlockHashAndIndex`` or - ``eth_getUncleByBlockNumberAndIndex`` RPC methods - - Returns the uncle at the index specified by ``uncle_index`` - from the block specified by ``block_identifier``. Delegates to - ``eth_getUncleByBlockNumberAndIndex`` if ``block_identifier`` is an - integer or one of the predefined block parameters ``'latest', 'earliest', - 'pending'``, otherwise delegates to - ``eth_getUncleByBlockHashAndIndex``. Throws ``BlockNotFound`` if the block is not found. - - .. code-block:: python - - >>> web3.eth.get_uncle_by_block(56160, 0) - AttributeDict({ - 'author': '0xbe4532e1b1db5c913cf553be76180c1777055403', - 'difficulty': '0x17dd9ca0afe', - 'extraData': '0x476574682f686261722f76312e302e312f6c696e75782f676f312e342e32', - 'gasLimit': '0x2fefd8', - 'gasUsed': '0x0', - 'hash': '0xc78c35720d930f9ef34b4e6fb9d02ffec936f9b02a8f0fa858456e4afd4d5614', - 'logsBloom':'0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', - 'miner': '0xbe4532e1b1db5c913cf553be76180c1777055403', - 'mixHash': '0x041e14603f35a82f6023802fec96ef760433292434a39787514f140950597e5e', - 'nonce': '0x5d2b7e3f1af09995', - 'number': '0xdb5e', - 'parentHash': '0xcc30e8a9b15c548d5bf113c834143a8f0e1909fbfea96b2a208dc154293a78cf', - 'receiptsRoot': '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', - 'sealFields': ['0xa0041e14603f35a82f6023802fec96ef760433292434a39787514f140950597e5e', '0x885d2b7e3f1af09995'], - 'sha3Uncles': '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347', - 'size': None, 'stateRoot': '0x8ce2b1bf8e25a06a8ca34c647ff5fd0fa48ac725cc07f657ae1645ab8ef68c91', - 'timestamp': '0x55c6a972', - 'totalDifficulty': '0xce4c4f0a0b810b', - 'transactions': [], - 'transactionsRoot': '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', - 'uncles': [] - }) - - # You can also refer to the block by hash: - >>> web3.eth.get_uncle_by_block('0x685b2226cbf6e1f890211010aa192bf16f0a0cba9534264a033b023d7367b845', 0) - AttributeDict({ - ... - }) - - -.. py:method:: Eth.get_uncle_count(block_identifier) - - .. warning:: Deprecated. Will be removed in v8. - - * Delegates to ``eth_getUncleCountByBlockHash`` or - ``eth_getUncleCountByBlockNumber`` RPC methods - - Returns the (integer) number of uncles associated with the block specified by ``block_identifier``. - Delegates to ``eth_getUncleCountByBlockNumber`` if ``block_identifier`` is an - integer or one of the predefined block parameters ``'latest', 'earliest', - 'pending'``, otherwise delegates to ``eth_getUncleCountByBlockHash``. - Throws ``BlockNotFound`` if the block is not found. - - .. code-block:: python - - >>> web3.eth.get_uncle_count(56160) - 1 - - # You can also refer to the block by hash: - >>> web3.eth.get_uncle_count('0x685b2226cbf6e1f890211010aa192bf16f0a0cba9534264a033b023d7367b845') - 1 - - .. py:method:: Eth.get_transaction(transaction_hash) * Delegates to ``eth_getTransactionByHash`` RPC Method diff --git a/tests/core/manager/test_response_formatters.py b/tests/core/manager/test_response_formatters.py index 73bd1982d1..7b408141ee 100644 --- a/tests/core/manager/test_response_formatters.py +++ b/tests/core/manager/test_response_formatters.py @@ -8,7 +8,6 @@ from web3._utils.method_formatters import ( raise_block_not_found, - raise_block_not_found_for_uncle_at_index, raise_transaction_not_found, ) from web3.exceptions import ( @@ -36,7 +35,11 @@ ) -VALID_RESULT_OBJ_RESPONSE = {"jsonrpc": "2.0", "id": 1, "result": {"foo": "bar"}} +VALID_RESULT_OBJ_RESPONSE = { + "jsonrpc": "2.0", + "id": 1, + "result": {"foo": "bar"}, +} VALID_RESPONSE_EXTRA_FIELDS = merge(VALID_RESULT_OBJ_RESPONSE, {"unexpected": "field"}) VALID_RESPONSE_STRING_ID = merge(VALID_RESULT_OBJ_RESPONSE, {"id": "1"}) @@ -319,27 +322,6 @@ def test_formatted_response_error_responses_with_formatters_raise_expected_excep BlockNotFound, "Block with id: '0x03' not found.", ), - ( - (), - # test raise_block_not_found_for_uncle_at_index - raise_block_not_found_for_uncle_at_index, - BlockNotFound, - "Unknown block identifier or uncle index", - ), - ( - ("0x01",), # test handles missing param - # test raise_block_not_found_for_uncle_at_index - raise_block_not_found_for_uncle_at_index, - BlockNotFound, - "Unknown block identifier or uncle index", - ), - ( - ("0x01", "0x00"), # both params - # test raise_block_not_found_for_uncle_at_index - raise_block_not_found_for_uncle_at_index, - BlockNotFound, - "Uncle at index: 0 of block with id: '0x01' not found.", - ), ( (), # test raise_transaction_not_found @@ -362,7 +344,10 @@ def test_formatted_response_null_and_0x_results_with_formatters( with pytest.raises(error, match=re.escape(error_message)): # test null result response w3.manager.formatted_response( - VALID_RESPONSE_NULL_RESULT, params, identity, null_result_formatters + VALID_RESPONSE_NULL_RESULT, + params, + identity, + null_result_formatters, ) with pytest.raises(error, match=re.escape(error_message)): diff --git a/web3/_utils/caching/caching_utils.py b/web3/_utils/caching/caching_utils.py index 8692da3aee..b91725d8d1 100644 --- a/web3/_utils/caching/caching_utils.py +++ b/web3/_utils/caching/caching_utils.py @@ -155,8 +155,6 @@ def is_cacheable_request( RPC.eth_getBlockByNumber, RPC.eth_getRawTransactionByBlockNumberAndIndex, RPC.eth_getBlockTransactionCountByNumber, - RPC.eth_getUncleByBlockNumberAndIndex, - RPC.eth_getUncleCountByBlockNumber, } BLOCK_IN_RESULT = { RPC.eth_getBlockByHash, @@ -167,8 +165,6 @@ def is_cacheable_request( } BLOCKHASH_IN_PARAMS = { RPC.eth_getRawTransactionByBlockHashAndIndex, - RPC.eth_getUncleByBlockHashAndIndex, - RPC.eth_getUncleCountByBlockHash, } INTERNAL_VALIDATION_MAP: dict[ @@ -336,7 +332,8 @@ async def _async_should_cache_response( def async_handle_request_caching( func: Callable[ - [ASYNC_PROVIDER_TYPE, RPCEndpoint, Any], Coroutine[Any, Any, "RPCResponse"] + [ASYNC_PROVIDER_TYPE, RPCEndpoint, Any], + Coroutine[Any, Any, "RPCResponse"], ], ) -> Callable[..., Coroutine[Any, Any, "RPCResponse"]]: async def wrapper( diff --git a/web3/_utils/method_formatters.py b/web3/_utils/method_formatters.py index db475ac9e4..ea92613283 100644 --- a/web3/_utils/method_formatters.py +++ b/web3/_utils/method_formatters.py @@ -393,7 +393,10 @@ def storage_key_to_hexstr(value: bytes | int | str) -> HexStr: is_array_of_dicts, apply_list_to_array_formatter(transaction_result_formatter), ), - (is_array_of_strings, apply_list_to_array_formatter(to_hexbytes(32))), + ( + is_array_of_strings, + apply_list_to_array_formatter(to_hexbytes(32)), + ), ) ), "transactionsRoot": apply_formatter_if(is_not_null, to_hexbytes(32)), @@ -492,7 +495,10 @@ def storage_key_to_hexstr(value: bytes | int | str) -> HexStr: filter_result_formatter = apply_one_of_formatters( ( - (is_array_of_dicts, apply_list_to_array_formatter(log_entry_formatter)), + ( + is_array_of_dicts, + apply_list_to_array_formatter(log_entry_formatter), + ), (is_array_of_strings, apply_list_to_array_formatter(to_hexbytes(32))), ) ) @@ -716,12 +722,6 @@ def storage_key_to_hexstr(value: bytes | int | str) -> HexStr: RPC.eth_getRawTransactionByBlockHashAndIndex: apply_formatter_at_index( to_hex_if_integer, 1 ), - RPC.eth_getUncleCountByBlockNumber: apply_formatter_at_index(to_hex_if_integer, 0), - RPC.eth_getUncleByBlockNumberAndIndex: compose( - apply_formatter_at_index(to_hex_if_integer, 0), - apply_formatter_at_index(to_hex_if_integer, 1), - ), - RPC.eth_getUncleByBlockHashAndIndex: apply_formatter_at_index(to_hex_if_integer, 1), RPC.eth_newFilter: apply_formatter_at_index(filter_params_formatter, 0), RPC.eth_getLogs: apply_formatter_at_index(filter_params_formatter, 0), RPC.eth_call: apply_one_of_formatters( @@ -953,7 +953,9 @@ def subscription_formatter(value: Any) -> HexBytes | HexStr | dict[str, Any]: result_formatter = log_entry_formatter elif either_set_is_a_subset( - result_key_set, set(TRANSACTION_RESULT_FORMATTERS.keys()), percentage=75 + result_key_set, + set(TRANSACTION_RESULT_FORMATTERS.keys()), + percentage=75, ): # newPendingTransactions, full transactions result_formatter = transaction_result_formatter @@ -1021,8 +1023,6 @@ def subscription_formatter(value: Any) -> HexBytes | HexStr | dict[str, Any]: is_not_null, receipt_formatter, ), - RPC.eth_getUncleCountByBlockHash: to_integer_if_hex, - RPC.eth_getUncleCountByBlockNumber: to_integer_if_hex, RPC.eth_protocolVersion: compose( apply_formatter_if(is_0x_prefixed, to_integer_if_hex), apply_formatter_if(is_integer, str), @@ -1102,7 +1102,9 @@ def combine_formatters( yield formatter_map[method_name] -def get_request_formatters(method_name: RPCEndpoint) -> Callable[[RPCResponse], Any]: +def get_request_formatters( + method_name: RPCEndpoint, +) -> Callable[[RPCResponse], Any]: request_formatter_maps = ( ABI_REQUEST_FORMATTERS, # METHOD_NORMALIZERS needs to be after ABI_REQUEST_FORMATTERS @@ -1126,22 +1128,6 @@ def raise_block_not_found(params: tuple[BlockIdentifier, bool]) -> NoReturn: raise BlockNotFound(message) -def raise_block_not_found_for_uncle_at_index( - params: tuple[BlockIdentifier, HexStr | int], -) -> NoReturn: - try: - block_identifier = params[0] - uncle_index = to_integer_if_hex(params[1]) - message = ( - f"Uncle at index: {uncle_index} of block with id: " - f"{block_identifier!r} not found." - ) - except IndexError: - message = "Unknown block identifier or uncle index" - - raise BlockNotFound(message) - - def raise_transaction_not_found(params: tuple[_Hash32]) -> NoReturn: try: transaction_hash = params[0] @@ -1174,10 +1160,6 @@ def raise_transaction_not_found_with_index( RPC.eth_getBlockReceipts: raise_block_not_found, RPC.eth_getBlockTransactionCountByHash: raise_block_not_found, RPC.eth_getBlockTransactionCountByNumber: raise_block_not_found, - RPC.eth_getUncleCountByBlockHash: raise_block_not_found, - RPC.eth_getUncleCountByBlockNumber: raise_block_not_found, - RPC.eth_getUncleByBlockHashAndIndex: raise_block_not_found_for_uncle_at_index, - RPC.eth_getUncleByBlockNumberAndIndex: raise_block_not_found_for_uncle_at_index, RPC.eth_getTransactionByHash: raise_transaction_not_found, RPC.eth_getTransactionByBlockHashAndIndex: raise_transaction_not_found_with_index, RPC.eth_getTransactionByBlockNumberAndIndex: raise_transaction_not_found_with_index, @@ -1256,7 +1238,9 @@ def get_result_formatters( return compose(*partial_formatters, *formatters) -def get_error_formatters(method_name: RPCEndpoint) -> Callable[[RPCResponse], Any]: +def get_error_formatters( + method_name: RPCEndpoint, +) -> Callable[[RPCResponse], Any]: # Note error formatters work on the full response dict error_formatter_maps = (ERROR_FORMATTERS,) formatters = combine_formatters(error_formatter_maps, method_name) diff --git a/web3/_utils/module_testing/eth_module.py b/web3/_utils/module_testing/eth_module.py index c811e96a23..1c5924c435 100644 --- a/web3/_utils/module_testing/eth_module.py +++ b/web3/_utils/module_testing/eth_module.py @@ -195,7 +195,9 @@ async def test_eth_modify_transaction_legacy( txn_hash = await async_w3.eth.send_transaction(txn_params) modified_txn_hash = await async_w3.eth.modify_transaction( - txn_hash, gasPrice=(cast(Wei, txn_params["gasPrice"] * 2)), value=Wei(2) + txn_hash, + gasPrice=(cast(Wei, txn_params["gasPrice"] * 2)), + value=Wei(2), ) modified_txn = await async_w3.eth.get_transaction(modified_txn_hash) @@ -323,7 +325,8 @@ async def test_eth_sign_typed_data( async_skip_if_testrpc(async_w3) signature = HexBytes( await async_w3.eth.sign_typed_data( - async_keyfile_account_address_dual_type, json.loads(validJSONMessage) + async_keyfile_account_address_dual_type, + json.loads(validJSONMessage), ) ) assert len(signature) == 32 + 32 + 1 @@ -386,7 +389,9 @@ async def test_invalid_eth_sign_typed_data( @pytest.mark.asyncio async def test_async_eth_sign_transaction_legacy( - self, async_w3: "AsyncWeb3[Any]", async_keyfile_account_address: ChecksumAddress + self, + async_w3: "AsyncWeb3[Any]", + async_keyfile_account_address: ChecksumAddress, ) -> None: txn_params: TxParams = { "from": async_keyfile_account_address, @@ -407,7 +412,9 @@ async def test_async_eth_sign_transaction_legacy( @pytest.mark.asyncio async def test_async_eth_sign_transaction_hex_fees( - self, async_w3: "AsyncWeb3[Any]", async_keyfile_account_address: ChecksumAddress + self, + async_w3: "AsyncWeb3[Any]", + async_keyfile_account_address: ChecksumAddress, ) -> None: txn_params: TxParams = { "from": async_keyfile_account_address, @@ -432,7 +439,9 @@ async def test_async_eth_sign_transaction_hex_fees( @pytest.mark.asyncio async def test_async_eth_sign_transaction_ens_names( - self, async_w3: "AsyncWeb3[Any]", async_keyfile_account_address: ChecksumAddress + self, + async_w3: "AsyncWeb3[Any]", + async_keyfile_account_address: ChecksumAddress, ) -> None: with ens_addresses( async_w3, {"unlocked-account.eth": async_keyfile_account_address} @@ -627,7 +636,8 @@ async def test_eth_send_transaction_max_fee_less_than_tip( "maxPriorityFeePerGas": Wei(2 * 10**9), } with pytest.raises( - InvalidTransaction, match="maxFeePerGas must be >= maxPriorityFeePerGas" + InvalidTransaction, + match="maxFeePerGas must be >= maxPriorityFeePerGas", ): await async_w3.eth.send_transaction(txn_params) @@ -707,7 +717,9 @@ async def test_async_sign_and_send_raw_middleware( "gas": 21000, } async_w3.middleware_onion.inject( - SignAndSendRawMiddlewareBuilder.build(keyfile_account), "signing", layer=0 + SignAndSendRawMiddlewareBuilder.build(keyfile_account), + "signing", + layer=0, ) txn_hash = await async_w3.eth.send_transaction(txn) assert isinstance(txn_hash, HexBytes) @@ -1154,7 +1166,8 @@ async def test_eth_get_raw_transaction_raises_error( self, async_w3: "AsyncWeb3[Any]" ) -> None: with pytest.raises( - TransactionNotFound, match=f"Transaction with hash: '{UNKNOWN_HASH}'" + TransactionNotFound, + match=f"Transaction with hash: '{UNKNOWN_HASH}'", ): await async_w3.eth.get_raw_transaction(UNKNOWN_HASH) @@ -1250,7 +1263,9 @@ async def test_eth_get_balance(self, async_w3: "AsyncWeb3[Any]") -> None: @pytest.mark.asyncio async def test_eth_get_code( - self, async_w3: "AsyncWeb3[Any]", async_math_contract_address: ChecksumAddress + self, + async_w3: "AsyncWeb3[Any]", + async_math_contract_address: ChecksumAddress, ) -> None: code = await async_w3.eth.get_code(async_math_contract_address) assert isinstance(code, HexBytes) @@ -1269,7 +1284,9 @@ async def test_eth_get_code_invalid_address( @pytest.mark.asyncio async def test_eth_get_code_with_block_identifier( - self, async_w3: "AsyncWeb3[Any]", async_emitter_contract: "AsyncContract" + self, + async_w3: "AsyncWeb3[Any]", + async_emitter_contract: "AsyncContract", ) -> None: block_id = await async_w3.eth.block_number code = await async_w3.eth.get_code(async_emitter_contract.address, block_id) @@ -1415,7 +1432,10 @@ async def test_eth_call_with_0_result( txn_params = async_math_contract._prepare_transaction( abi_element_identifier="add", fn_args=(0, 0), - transaction={"from": accounts[0], "to": async_math_contract.address}, + transaction={ + "from": accounts[0], + "to": async_math_contract.address, + }, ) call_result = await async_w3.eth.call(txn_params) assert is_string(call_result) @@ -1437,7 +1457,8 @@ async def test_eth_call_revert_with_msg( }, ) with pytest.raises( - ContractLogicError, match="execution reverted: Function has been reverted" + ContractLogicError, + match="execution reverted: Function has been reverted", ): await async_w3.eth.call(txn_params) @@ -1729,7 +1750,8 @@ async def test_eth_call_offchain_lookup_raises_when_all_supplied_urls_fail( ) -> None: # GET and POST requests should fail since responses are not mocked with pytest.raises( - MultipleFailedRequests, match="Offchain lookup failed for supplied urls" + MultipleFailedRequests, + match="Offchain lookup failed for supplied urls", ): await async_offchain_lookup_contract.caller().testOffchainLookup( OFFCHAIN_LOOKUP_TEST_DATA @@ -1957,7 +1979,9 @@ async def test_async_eth_blob_base_fee(self, async_w3: "AsyncWeb3[Any]") -> None @pytest.mark.asyncio async def test_async_eth_get_logs_without_logs( - self, async_w3: "AsyncWeb3[Any]", async_block_with_txn_with_log: BlockData + self, + async_w3: "AsyncWeb3[Any]", + async_block_with_txn_with_log: BlockData, ) -> None: # Test with block range @@ -2124,7 +2148,9 @@ async def test_async_eth_syncing(self, async_w3: "AsyncWeb3[Any]") -> None: @pytest.mark.asyncio async def test_async_eth_get_storage_at( - self, async_w3: "AsyncWeb3[Any]", async_storage_contract: "AsyncContract" + self, + async_w3: "AsyncWeb3[Any]", + async_storage_contract: "AsyncContract", ) -> None: async_storage_contract_address = async_storage_contract.address @@ -2151,7 +2177,9 @@ async def test_async_eth_get_storage_at( @pytest.mark.asyncio async def test_async_eth_get_storage_at_ens_name( - self, async_w3: "AsyncWeb3[Any]", async_storage_contract: "AsyncContract" + self, + async_w3: "AsyncWeb3[Any]", + async_storage_contract: "AsyncContract", ) -> None: with ens_addresses(async_w3, {"storage.eth": async_storage_contract.address}): storage = await async_w3.eth.get_storage_at(ENS("storage.eth"), 1) @@ -2231,36 +2259,6 @@ async def test_eth_getBlockTransactionCountByHash_block_with_txn( assert is_integer(transaction_count) assert transaction_count >= 1 - @pytest.mark.asyncio - async def test_eth_getUncleCountByBlockHash( - self, async_w3: "AsyncWeb3[Any]", async_empty_block: BlockData - ) -> None: - with pytest.warns( - DeprecationWarning, - match=r"get_uncle_count is deprecated: all get_uncle\* " - r"methods will be removed in v8", - ): - uncle_count = await async_w3.eth.get_uncle_count(async_empty_block["hash"]) - - assert is_integer(uncle_count) - assert uncle_count == 0 - - @pytest.mark.asyncio - async def test_eth_getUncleCountByBlockNumber( - self, async_w3: "AsyncWeb3[Any]", async_empty_block: BlockData - ) -> None: - with pytest.warns( - DeprecationWarning, - match=r"get_uncle_count is deprecated: all get_uncle\* " - r"methods will be removed in v8", - ): - uncle_count = await async_w3.eth.get_uncle_count( - async_empty_block["number"] - ) - - assert is_integer(uncle_count) - assert uncle_count == 0 - @pytest.mark.asyncio async def test_eth_getBlockTransactionCountByNumber_block_with_txn( self, async_w3: "AsyncWeb3[Any]", async_block_with_txn: BlockData @@ -2319,10 +2317,12 @@ async def test_async_eth_sign_ens_names( async_keyfile_account_address_dual_type: ChecksumAddress, ) -> None: with ens_addresses( - async_w3, {"unlocked-acct.eth": async_keyfile_account_address_dual_type} + async_w3, + {"unlocked-acct.eth": async_keyfile_account_address_dual_type}, ): signature = await async_w3.eth.sign( - ENS("unlocked-acct.eth"), text="Message tö sign. Longer than hash!" + ENS("unlocked-acct.eth"), + text="Message tö sign. Longer than hash!", ) assert is_bytes(signature) assert len(signature) == 32 + 32 + 1 @@ -2464,7 +2464,9 @@ async def test_async_eth_replace_transaction_already_mined( @pytest.mark.asyncio async def test_async_eth_replace_transaction_incorrect_nonce( - self, async_w3: "AsyncWeb3[Any]", async_keyfile_account_address: ChecksumAddress + self, + async_w3: "AsyncWeb3[Any]", + async_keyfile_account_address: ChecksumAddress, ) -> None: txn_params: TxParams = { "from": async_keyfile_account_address, @@ -2504,7 +2506,9 @@ async def test_async_eth_replace_transaction_gas_price_too_low( @pytest.mark.asyncio async def test_async_eth_replace_transaction_gas_price_defaulting_minimum( - self, async_w3: "AsyncWeb3[Any]", async_keyfile_account_address: ChecksumAddress + self, + async_w3: "AsyncWeb3[Any]", + async_keyfile_account_address: ChecksumAddress, ) -> None: gas_price = async_w3.to_wei(1, "gwei") @@ -2870,28 +2874,6 @@ def test_eth_getBlockTransactionCountByNumber_block_with_txn( assert is_integer(transaction_count) assert transaction_count >= 1 - def test_eth_getUncleCountByBlockHash( - self, w3: "Web3", empty_block: BlockData - ) -> None: - with pytest.warns( - DeprecationWarning, match=r"All get_uncle\* methods have been deprecated" - ): - uncle_count = w3.eth.get_uncle_count(empty_block["hash"]) - - assert is_integer(uncle_count) - assert uncle_count == 0 - - def test_eth_getUncleCountByBlockNumber( - self, w3: "Web3", empty_block: BlockData - ) -> None: - with pytest.warns( - DeprecationWarning, match=r"All get_uncle\* methods have been deprecated" - ): - uncle_count = w3.eth.get_uncle_count(empty_block["number"]) - - assert is_integer(uncle_count) - assert uncle_count == 0 - def test_eth_get_code( self, w3: "Web3", math_contract_address: ChecksumAddress ) -> None: diff --git a/web3/_utils/rpc_abi.py b/web3/_utils/rpc_abi.py index bfbc0c90a3..caed07c371 100644 --- a/web3/_utils/rpc_abi.py +++ b/web3/_utils/rpc_abi.py @@ -87,10 +87,6 @@ class RPC: eth_getTransactionByHash = RPCEndpoint("eth_getTransactionByHash") eth_getTransactionCount = RPCEndpoint("eth_getTransactionCount") eth_getTransactionReceipt = RPCEndpoint("eth_getTransactionReceipt") - eth_getUncleByBlockHashAndIndex = RPCEndpoint("eth_getUncleByBlockHashAndIndex") - eth_getUncleByBlockNumberAndIndex = RPCEndpoint("eth_getUncleByBlockNumberAndIndex") - eth_getUncleCountByBlockHash = RPCEndpoint("eth_getUncleCountByBlockHash") - eth_getUncleCountByBlockNumber = RPCEndpoint("eth_getUncleCountByBlockNumber") eth_getWork = RPCEndpoint("eth_getWork") eth_newBlockFilter = RPCEndpoint("eth_newBlockFilter") eth_newFilter = RPCEndpoint("eth_newFilter") @@ -189,7 +185,6 @@ class RPC: "eth_getTransactionCount": ["address", None], "eth_getTransactionReceipt": ["bytes32"], "eth_getRawTransactionByBlockHashAndIndex": ["bytes32", "uint"], - "eth_getUncleCountByBlockHash": ["bytes32"], "eth_newFilter": FILTER_PARAMS_ABIS, "eth_sendRawTransaction": ["bytes"], "eth_sendTransaction": TRANSACTION_PARAMS_ABIS, diff --git a/web3/eth/async_eth.py b/web3/eth/async_eth.py index 178802e658..227ae7c5cd 100644 --- a/web3/eth/async_eth.py +++ b/web3/eth/async_eth.py @@ -33,9 +33,6 @@ from web3._utils.compat import ( Unpack, ) -from web3._utils.decorators import ( - deprecated_for, -) from web3._utils.fee_utils import ( async_fee_history_priority_fee, ) @@ -655,22 +652,6 @@ async def sign_typed_data( ) -> HexStr: return await self._sign_typed_data(account, data) - # eth_getUncleCountByBlockHash - # eth_getUncleCountByBlockNumber - - _get_uncle_count: Method[Callable[[BlockIdentifier], Awaitable[int]]] = Method( - method_choice_depends_on_args=select_method_for_block_identifier( - if_predefined=RPC.eth_getUncleCountByBlockNumber, - if_hash=RPC.eth_getUncleCountByBlockHash, - if_number=RPC.eth_getUncleCountByBlockNumber, - ), - mungers=[default_root_munger], - ) - - @deprecated_for("all get_uncle* methods will be removed in v8") - async def get_uncle_count(self, block_identifier: BlockIdentifier) -> int: - return await self._get_uncle_count(block_identifier) - # eth_newFilter, eth_newBlockFilter, eth_newPendingTransactionFilter filter: Method[ diff --git a/web3/eth/eth.py b/web3/eth/eth.py index 972314ee1c..c6c6ee0dcf 100644 --- a/web3/eth/eth.py +++ b/web3/eth/eth.py @@ -63,7 +63,6 @@ Web3ValueError, ) from web3.method import ( - DeprecatedMethod, Method, default_root_munger, ) @@ -87,7 +86,6 @@ TxData, TxParams, TxReceipt, - Uncle, Wei, _Hash32, ) @@ -401,7 +399,9 @@ def send_raw_transaction(self, transaction: HexStr | bytes) -> HexBytes: ) def get_block( - self, block_identifier: BlockIdentifier, full_transactions: bool = False + self, + block_identifier: BlockIdentifier, + full_transactions: bool = False, ) -> BlockData: return self._get_block(block_identifier, full_transactions) @@ -482,14 +482,20 @@ def get_transaction_receipt(self, transaction_hash: _Hash32) -> TxReceipt: return self._transaction_receipt(transaction_hash) def wait_for_transaction_receipt( - self, transaction_hash: _Hash32, timeout: float = 120, poll_latency: float = 0.1 + self, + transaction_hash: _Hash32, + timeout: float = 120, + poll_latency: float = 0.1, ) -> TxReceipt: try: with Timeout(timeout) as _timeout: while True: try: tx_receipt = self._transaction_receipt(transaction_hash) - except (TransactionNotFound, TransactionIndexingInProgress): + except ( + TransactionNotFound, + TransactionIndexingInProgress, + ): tx_receipt = None if tx_receipt is not None: break @@ -550,42 +556,6 @@ def get_proof_munger( mungers=[get_proof_munger], ) - # eth_getUncleCountByBlockHash - # eth_getUncleCountByBlockNumber - - _get_uncle_count: Method[Callable[[BlockIdentifier], int]] = Method( - method_choice_depends_on_args=select_method_for_block_identifier( - if_predefined=RPC.eth_getUncleCountByBlockNumber, - if_hash=RPC.eth_getUncleCountByBlockHash, - if_number=RPC.eth_getUncleCountByBlockNumber, - ), - mungers=[default_root_munger], - ) - get_uncle_count = DeprecatedMethod( - _get_uncle_count, - old_name="_get_uncle_count", - new_name="get_uncle_count", - msg="All get_uncle* methods have been deprecated", - ) - - # eth_getUncleByBlockHashAndIndex - # eth_getUncleByBlockNumberAndIndex - - _get_uncle_by_block: Method[Callable[[BlockIdentifier, int], Uncle]] = Method( - method_choice_depends_on_args=select_method_for_block_identifier( - if_predefined=RPC.eth_getUncleByBlockNumberAndIndex, - if_hash=RPC.eth_getUncleByBlockHashAndIndex, - if_number=RPC.eth_getUncleByBlockNumberAndIndex, - ), - mungers=[default_root_munger], - ) - get_uncle_by_block = DeprecatedMethod( - _get_uncle_by_block, - old_name="_get_uncle_by_block", - new_name="get_uncle_by_block", - msg="All get_uncle* methods have been deprecated", - ) - def replace_transaction( self, transaction_hash: _Hash32, new_transaction: TxParams ) -> HexBytes: diff --git a/web3/providers/eth_tester/defaults.py b/web3/providers/eth_tester/defaults.py index ccba1af8bb..31f0ac1d0a 100644 --- a/web3/providers/eth_tester/defaults.py +++ b/web3/providers/eth_tester/defaults.py @@ -97,7 +97,8 @@ def call_eth_tester( zip(OFFCHAIN_LOOKUP_FIELDS.keys(), abi_decoded_data) ) raise OffchainLookup( - offchain_lookup_payload, data=Web3.to_hex(parsed_data_as_bytes) + offchain_lookup_payload, + data=Web3.to_hex(parsed_data_as_bytes), ) elif possible_data[2:6] == "NH{q": # Solidity >= 0.8.0 Panic Error @@ -135,7 +136,9 @@ def inner(eth_tester: "EthereumTester", params: Any) -> TReturn: @curry def preprocess_params( - eth_tester: "EthereumTester", params: Any, preprocessor_fn: Callable[..., Any] + eth_tester: "EthereumTester", + params: Any, + preprocessor_fn: Callable[..., Any], ) -> tuple["EthereumTester", Callable[..., Any]]: return eth_tester, preprocessor_fn(params) @@ -269,20 +272,6 @@ def create_new_account(eth_tester: "EthereumTester") -> HexAddress: call_eth_tester("get_block_by_number"), ) ), - "getUncleCountByBlockHash": null_if_block_not_found( - compose( - len, - operator.itemgetter("uncles"), - call_eth_tester("get_block_by_hash"), - ) - ), - "getUncleCountByBlockNumber": null_if_block_not_found( - compose( - len, - operator.itemgetter("uncles"), - call_eth_tester("get_block_by_number"), - ) - ), "getCode": call_eth_tester("get_code"), "sign": not_implemented, "signTransaction": not_implemented, @@ -309,8 +298,6 @@ def create_new_account(eth_tester: "EthereumTester") -> HexAddress: call_eth_tester("get_transaction_receipt"), ) ), - "getUncleByBlockHashAndIndex": not_implemented, - "getUncleByBlockNumberAndIndex": not_implemented, "getCompilers": not_implemented, "compileLLL": not_implemented, "compileSolidity": not_implemented, diff --git a/web3/providers/eth_tester/middleware.py b/web3/providers/eth_tester/middleware.py index 974eeafce6..8bc7818b39 100644 --- a/web3/providers/eth_tester/middleware.py +++ b/web3/providers/eth_tester/middleware.py @@ -253,9 +253,6 @@ def is_hexstr(value: Any) -> bool: RPCEndpoint("eth_getBlockTransactionCountByNumber"): apply_formatters_to_args( apply_formatter_if(is_not_named_block, to_integer_if_hex), ), - RPCEndpoint("eth_getUncleCountByBlockNumber"): apply_formatters_to_args( - apply_formatter_if(is_not_named_block, to_integer_if_hex), - ), RPCEndpoint("eth_getTransactionByBlockHashAndIndex"): apply_formatters_to_args( identity, to_integer_if_hex, @@ -264,10 +261,6 @@ def is_hexstr(value: Any) -> bool: apply_formatter_if(is_not_named_block, to_integer_if_hex), to_integer_if_hex, ), - RPCEndpoint("eth_getUncleByBlockNumberAndIndex"): apply_formatters_to_args( - apply_formatter_if(is_not_named_block, to_integer_if_hex), - to_integer_if_hex, - ), RPCEndpoint("eth_newFilter"): apply_formatters_to_args( filter_request_transformer, ), @@ -360,7 +353,10 @@ def guess_from(w3: "Web3", _: TxParams) -> ChecksumAddress: @curry def fill_default( - field: str, guess_func: Callable[..., Any], w3: "Web3", transaction: TxParams + field: str, + guess_func: Callable[..., Any], + w3: "Web3", + transaction: TxParams, ) -> TxParams: # type ignored b/c TxParams keys must be string literal types if field in transaction and transaction[field] is not None: # type: ignore