Skip to content

Commit 64ac6a4

Browse files
Bhargavasomucburgdorf
authored andcommitted
Enable complete type hinting for eth.estimators
1 parent 2678689 commit 64ac6a4

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

eth/estimators/gas.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
1+
from typing import (
2+
cast,
3+
Optional,
4+
)
5+
16
from cytoolz import (
27
curry,
38
)
49

10+
from eth.exceptions import (
11+
VMError,
12+
)
13+
14+
from eth.rlp.transactions import (
15+
BaseTransaction,
16+
)
517

618
from eth.utils.spoof import (
719
SpoofTransaction,
820
)
921

22+
from eth.vm.state import (
23+
BaseState,
24+
)
25+
1026

11-
def _get_computation_error(state, transaction):
27+
def _get_computation_error(state: BaseState, transaction: SpoofTransaction) -> Optional[VMError]:
1228

1329
snapshot = state.snapshot()
1430

1531
try:
16-
computation = state.execute_transaction(transaction)
32+
computation = state.execute_transaction(cast(BaseTransaction, transaction))
1733
if computation.is_error:
1834
return computation._error
1935
else:
@@ -24,7 +40,7 @@ def _get_computation_error(state, transaction):
2440

2541

2642
@curry
27-
def binary_gas_search(state, transaction, tolerance=1):
43+
def binary_gas_search(state: BaseState, transaction: BaseTransaction, tolerance: int=1) -> int:
2844
"""
2945
Run the transaction with various gas limits, progressively
3046
approaching the minimum needed to succeed without an OutOfGas exception.

0 commit comments

Comments
 (0)