Skip to content

Commit

Permalink
eth_estimateGas uses Method
Browse files Browse the repository at this point in the history
  • Loading branch information
kclowes committed Sep 24, 2020
1 parent a6f1351 commit 2b9e91c
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions web3/eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
HexStr,
)
from eth_utils import (
apply_to_return_value,
is_checksum_address,
is_string,
)
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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,
Expand Down

0 comments on commit 2b9e91c

Please sign in to comment.