Skip to content

Commit

Permalink
eth_call uses Method
Browse files Browse the repository at this point in the history
  • Loading branch information
kclowes committed Sep 24, 2020
1 parent c0909fe commit a6f1351
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions web3/_utils/method_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ def apply_list_to_array_formatter(formatter: Any) -> Callable[..., Any]:
RPC.eth_blockNumber: to_integer_if_hex,
RPC.eth_chainId: to_integer_if_hex,
RPC.eth_coinbase: to_checksum_address,
RPC.eth_call: HexBytes,
RPC.eth_estimateGas: to_integer_if_hex,
RPC.eth_gasPrice: to_integer_if_hex,
RPC.eth_getBalance: to_integer_if_hex,
Expand Down
15 changes: 8 additions & 7 deletions web3/eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,20 +423,21 @@ def sign_munger(
mungers=[default_root_munger],
)

@apply_to_return_value(HexBytes)
def call(self, transaction: TxParams,
block_identifier: Optional[BlockIdentifier] = None) -> Sequence[Any]:
def call_munger(self, transaction: TxParams, block_identifier: Optional[BlockIdentifier] = None) -> Tuple[TxParams, BlockIdentifier]:
# TODO: move to middleware
if 'from' not in transaction and is_checksum_address(self.defaultAccount):
transaction = assoc(transaction, 'from', self.defaultAccount)

# TODO: move to middleware
if block_identifier is None:
block_identifier = self.defaultBlock
return self.web3.manager.request_blocking(
RPC.eth_call,
[transaction, block_identifier],
)

return (transaction, block_identifier)

call: Method[Callable[..., Union[bytes, bytearray]]] = Method(
RPC.eth_call,
mungers=[call_munger]
)

def estimateGas(self, transaction: TxParams,
block_identifier: Optional[BlockIdentifier] = None) -> Wei:
Expand Down

0 comments on commit a6f1351

Please sign in to comment.