From 2b9e91cb875a57f7d1917835db01eddb0c34a294 Mon Sep 17 00:00:00 2001 From: Keri Date: Mon, 21 Sep 2020 14:53:54 -0600 Subject: [PATCH] eth_estimateGas uses Method --- web3/eth.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/web3/eth.py b/web3/eth.py index 91ceedd679..9bf7b95fad 100644 --- a/web3/eth.py +++ b/web3/eth.py @@ -22,7 +22,6 @@ HexStr, ) from eth_utils import ( - apply_to_return_value, is_checksum_address, is_string, ) @@ -423,7 +422,11 @@ def sign_munger( mungers=[default_root_munger], ) - def call_munger(self, transaction: TxParams, block_identifier: Optional[BlockIdentifier] = None) -> Tuple[TxParams, BlockIdentifier]: + 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) @@ -439,9 +442,11 @@ def call_munger(self, transaction: TxParams, block_identifier: Optional[BlockIde mungers=[call_munger] ) - def estimateGas(self, transaction: TxParams, - block_identifier: Optional[BlockIdentifier] = None) -> Wei: - # TODO: move to middleware + def estimate_gas_munger( + self, + transaction: TxParams, + block_identifier: Optional[BlockIdentifier] = None + ) -> Sequence[Union[TxParams, BlockIdentifier]]: if 'from' not in transaction and is_checksum_address(self.defaultAccount): transaction = assoc(transaction, 'from', self.defaultAccount) @@ -450,10 +455,12 @@ def estimateGas(self, transaction: TxParams, else: params = [transaction, block_identifier] - return self.web3.manager.request_blocking( - RPC.eth_estimateGas, - params, - ) + return params + + estimateGas: Method[Callable[..., Wei]] = Method( + RPC.eth_estimateGas, + mungers=[estimate_gas_munger] + ) def filter( self, filter_params: Optional[Union[str, FilterParams]] = None,