Skip to content

Commit

Permalink
Change eth_call return type to reflect pythonic formatter conversion
Browse files Browse the repository at this point in the history
- Pythonic result formatters convert ``eth_call`` response to ``HexBytes``. Due to differences between the ``HexBytes.hex()`` method and the ``bytes.hex()`` method, the former more accurately represents the type that is returned.
  • Loading branch information
fselmo committed Feb 23, 2023
1 parent e13ba3e commit a983bb2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions newsfragments/2842.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
More accurately define the ``eth_call`` return type as ``HexBytes`` since the response is converted to ``HexBytes`` in the pythonic formatters and there are differences between ``HexBytes`` and ``bytes`` types.
6 changes: 3 additions & 3 deletions web3/eth/async_eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ async def fee_history(
Optional[BlockIdentifier],
Optional[CallOverride],
],
Awaitable[Union[bytes, bytearray]],
Awaitable[HexBytes],
]
] = Method(RPC.eth_call, mungers=[BaseEth.call_munger])

Expand All @@ -235,7 +235,7 @@ async def call(
block_identifier: Optional[BlockIdentifier] = None,
state_override: Optional[CallOverride] = None,
ccip_read_enabled: Optional[bool] = None,
) -> Union[bytes, bytearray]:
) -> HexBytes:
ccip_read_enabled_on_provider = self.w3.provider.global_ccip_read_enabled
if (
# default conditions:
Expand All @@ -255,7 +255,7 @@ async def _durin_call(
transaction: TxParams,
block_identifier: Optional[BlockIdentifier] = None,
state_override: Optional[CallOverride] = None,
) -> Union[bytes, bytearray]:
) -> HexBytes:
max_redirects = self.w3.provider.ccip_read_max_redirects

if not max_redirects or max_redirects < 4:
Expand Down
6 changes: 3 additions & 3 deletions web3/eth/eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def fee_history(
_call: Method[
Callable[
[TxParams, Optional[BlockIdentifier], Optional[CallOverride]],
Union[bytes, bytearray],
HexBytes,
]
] = Method(RPC.eth_call, mungers=[BaseEth.call_munger])

Expand All @@ -244,7 +244,7 @@ def call(
block_identifier: Optional[BlockIdentifier] = None,
state_override: Optional[CallOverride] = None,
ccip_read_enabled: Optional[bool] = None,
) -> Union[bytes, bytearray]:
) -> HexBytes:
ccip_read_enabled_on_provider = self.w3.provider.global_ccip_read_enabled
if (
# default conditions:
Expand All @@ -264,7 +264,7 @@ def _durin_call(
transaction: TxParams,
block_identifier: Optional[BlockIdentifier] = None,
state_override: Optional[CallOverride] = None,
) -> Union[bytes, bytearray]:
) -> HexBytes:
max_redirects = self.w3.provider.ccip_read_max_redirects

if not max_redirects or max_redirects < 4:
Expand Down

0 comments on commit a983bb2

Please sign in to comment.