Skip to content

Commit

Permalink
Add get_uncle_by_block, deprecate getUncleByBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
kclowes committed Jan 29, 2021
1 parent c7cfaaa commit 71bab38
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ API
- :meth:`web3.eth.get_transaction() <web3.eth.Eth.get_transaction>`
- :meth:`web3.eth.get_transaction_by_block() <web3.eth.Eth.get_transaction_by_block>`
- :meth:`web3.eth.getTransactionCount() <web3.eth.Eth.getTransactionCount>`
- :meth:`web3.eth.getUncleByBlock() <web3.eth.Eth.getUncleByBlock>`
- :meth:`web3.eth.get_uncle_by_block() <web3.eth.Eth.get_uncle_by_block>`
- :meth:`web3.eth.getUncleCount() <web3.eth.Eth.getUncleCount>`


Expand Down
10 changes: 7 additions & 3 deletions docs/web3.eth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,10 @@ The following methods are available on the ``web3.eth`` namespace.
.. py:method:: Eth.getUncle(block_identifier)
.. note:: Method to get an Uncle from its hash is not available through
RPC, a possible substitute is the method ``Eth.getUncleByBlock``
RPC, a possible substitute is the method ``Eth.get_uncle_by_block``


.. py:method:: Eth.getUncleByBlock(block_identifier, uncle_index)
.. py:method:: Eth.get_uncle_by_block(block_identifier, uncle_index)
* Delegates to ``eth_getUncleByBlockHashAndIndex`` or
``eth_getUncleByBlockNumberAndIndex`` RPC methods
Expand All @@ -469,7 +469,7 @@ The following methods are available on the ``web3.eth`` namespace.

.. code-block:: python
>>> web3.eth.getUncleByBlock(56160, 0)
>>> web3.eth.get_uncle_by_block(56160, 0)
AttributeDict({
'author': '0xbe4532e1b1db5c913cf553be76180c1777055403',
'difficulty': '0x17dd9ca0afe',
Expand Down Expand Up @@ -500,6 +500,10 @@ The following methods are available on the ``web3.eth`` namespace.
...
})
.. py:method:: Eth.getUncleByBlock(block_identifier, uncle_index)
.. warning:: Deprecated: This method is deprecated in favor of
:meth:`~web3.eth.Eth.get_uncle_by_block()`

.. py:method:: Eth.getUncleCount(block_identifier)
Expand Down
2 changes: 1 addition & 1 deletion web3/_utils/method_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def apply_list_to_array_formatter(formatter: Any) -> Callable[..., Any]:
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(integer_to_hex, 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_formatters_to_sequence([
Expand Down
3 changes: 2 additions & 1 deletion web3/eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def get_block_munger(
`eth_getUncleByBlockHashAndIndex`
`eth_getUncleByBlockNumberAndIndex`
"""
getUncleByBlock: Method[Callable[[BlockIdentifier, int], Uncle]] = Method(
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,
Expand Down Expand Up @@ -659,3 +659,4 @@ def setGasPriceStrategy(self, gas_price_strategy: GasPriceStrategy) -> None:
getTransactionByBlock = DeprecatedMethod(get_transaction_by_block,
'getTransactionByBlock',
'get_transaction_by_block')
getUncleByBlock = DeprecatedMethod(get_uncle_by_block, 'getUncleByBlock', 'get_uncle_by_block')

0 comments on commit 71bab38

Please sign in to comment.