Skip to content

Commit a5f05d5

Browse files
committed
Add get_uncle_by_block, deprecate getUncleByBlock
1 parent c7cfaaa commit a5f05d5

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

docs/overview.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ API
149149
- :meth:`web3.eth.get_transaction() <web3.eth.Eth.get_transaction>`
150150
- :meth:`web3.eth.get_transaction_by_block() <web3.eth.Eth.get_transaction_by_block>`
151151
- :meth:`web3.eth.getTransactionCount() <web3.eth.Eth.getTransactionCount>`
152-
- :meth:`web3.eth.getUncleByBlock() <web3.eth.Eth.getUncleByBlock>`
152+
- :meth:`web3.eth.get_uncle_by_block() <web3.eth.Eth.get_uncle_by_block>`
153153
- :meth:`web3.eth.getUncleCount() <web3.eth.Eth.getUncleCount>`
154154

155155

docs/web3.eth.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,10 @@ The following methods are available on the ``web3.eth`` namespace.
452452
.. py:method:: Eth.getUncle(block_identifier)
453453
454454
.. note:: Method to get an Uncle from its hash is not available through
455-
RPC, a possible substitute is the method ``Eth.getUncleByBlock``
455+
RPC, a possible substitute is the method ``Eth.get_uncle_by_block``
456456

457457

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

470470
.. code-block:: python
471471
472-
>>> web3.eth.getUncleByBlock(56160, 0)
472+
>>> web3.eth.get_uncle_by_block(56160, 0)
473473
AttributeDict({
474474
'author': '0xbe4532e1b1db5c913cf553be76180c1777055403',
475475
'difficulty': '0x17dd9ca0afe',
@@ -495,11 +495,15 @@ The following methods are available on the ``web3.eth`` namespace.
495495
})
496496
497497
# You can also refer to the block by hash:
498-
>>> web3.eth.getUncleByBlock('0x685b2226cbf6e1f890211010aa192bf16f0a0cba9534264a033b023d7367b845', 0)
498+
>>> web3.eth.get_uncle_by_block('0x685b2226cbf6e1f890211010aa192bf16f0a0cba9534264a033b023d7367b845', 0)
499499
AttributeDict({
500500
...
501501
})
502502
503+
.. py:method:: Eth.getUncleByBlock(block_identifier, uncle_index)
504+
505+
.. warning:: Deprecated: This method is deprecated in favor of
506+
:meth:`~web3.eth.Eth.get_uncle_by_block()`
503507

504508
.. py:method:: Eth.getUncleCount(block_identifier)
505509

newsfragments/1862.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add get_uncle_by_block, deprecate getUncleByBlock

web3/_utils/method_formatters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def apply_list_to_array_formatter(formatter: Any) -> Callable[..., Any]:
371371
apply_formatter_at_index(to_hex_if_integer, 0),
372372
apply_formatter_at_index(to_hex_if_integer, 1),
373373
),
374-
RPC.eth_getUncleByBlockHashAndIndex: apply_formatter_at_index(integer_to_hex, 1),
374+
RPC.eth_getUncleByBlockHashAndIndex: apply_formatter_at_index(to_hex_if_integer, 1),
375375
RPC.eth_newFilter: apply_formatter_at_index(filter_params_formatter, 0),
376376
RPC.eth_getLogs: apply_formatter_at_index(filter_params_formatter, 0),
377377
RPC.eth_call: apply_formatters_to_sequence([

web3/eth.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def get_block_munger(
382382
`eth_getUncleByBlockHashAndIndex`
383383
`eth_getUncleByBlockNumberAndIndex`
384384
"""
385-
getUncleByBlock: Method[Callable[[BlockIdentifier, int], Uncle]] = Method(
385+
get_uncle_by_block: Method[Callable[[BlockIdentifier, int], Uncle]] = Method(
386386
method_choice_depends_on_args=select_method_for_block_identifier(
387387
if_predefined=RPC.eth_getUncleByBlockNumberAndIndex,
388388
if_hash=RPC.eth_getUncleByBlockHashAndIndex,
@@ -659,3 +659,4 @@ def setGasPriceStrategy(self, gas_price_strategy: GasPriceStrategy) -> None:
659659
getTransactionByBlock = DeprecatedMethod(get_transaction_by_block,
660660
'getTransactionByBlock',
661661
'get_transaction_by_block')
662+
getUncleByBlock = DeprecatedMethod(get_uncle_by_block, 'getUncleByBlock', 'get_uncle_by_block')

0 commit comments

Comments
 (0)