Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit c40a72a

Browse files
committed
Implement eth.abc module with abstract base classes for public APIs
1 parent 814fb0e commit c40a72a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2742
-1842
lines changed

eth/_utils/datatypes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
from typing import Any, Dict, Tuple, Type, TypeVar, Iterator, List
1313

14+
from eth.abc import ConfigurableAPI
15+
1416

1517
def _is_local_prop(prop: str) -> bool:
1618
return len(prop.split('.')) == 1
@@ -64,7 +66,7 @@ def _get_top_level_keys(overrides: Dict[str, Any]) -> Iterator[str]:
6466
T = TypeVar('T')
6567

6668

67-
class Configurable(object):
69+
class Configurable(ConfigurableAPI):
6870
"""
6971
Base class for simple inline subclassing
7072
"""

eth/_utils/db.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,32 @@
1-
from typing import (
2-
TYPE_CHECKING,
3-
)
4-
51
from eth_typing import (
62
Hash32,
73
)
84

9-
from eth.rlp.headers import (
10-
BlockHeader,
5+
from eth.abc import (
6+
BlockHeaderAPI,
7+
ChainDatabaseAPI,
8+
StateAPI,
119
)
1210
from eth.typing import (
1311
AccountState,
1412
)
15-
from eth.vm.state import (
16-
BaseState,
17-
)
18-
19-
if TYPE_CHECKING:
20-
from eth.db.chain import BaseChainDB # noqa: F401
2113

2214

23-
def get_parent_header(block_header: BlockHeader, db: 'BaseChainDB') -> BlockHeader:
15+
def get_parent_header(block_header: BlockHeaderAPI, db: ChainDatabaseAPI) -> BlockHeaderAPI:
2416
"""
2517
Returns the header for the parent block.
2618
"""
2719
return db.get_block_header_by_hash(block_header.parent_hash)
2820

2921

30-
def get_block_header_by_hash(block_hash: Hash32, db: 'BaseChainDB') -> BlockHeader:
22+
def get_block_header_by_hash(block_hash: Hash32, db: ChainDatabaseAPI) -> BlockHeaderAPI:
3123
"""
3224
Returns the header for the parent block.
3325
"""
3426
return db.get_block_header_by_hash(block_hash)
3527

3628

37-
def apply_state_dict(state: BaseState, state_dict: AccountState) -> None:
29+
def apply_state_dict(state: StateAPI, state_dict: AccountState) -> None:
3830
for account, account_data in state_dict.items():
3931
state.set_balance(account, account_data["balance"])
4032
state.set_nonce(account, account_data["nonce"])

eth/_utils/spoof.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
DEFAULT_SPOOF_S,
1515
)
1616

17-
from eth.rlp.transactions import (
18-
BaseTransaction,
19-
BaseUnsignedTransaction,
17+
from eth.abc import (
18+
SignedTransactionAPI,
19+
UnsignedTransactionAPI,
2020
)
2121

2222
SPOOF_ATTRIBUTES_DEFAULTS = {
@@ -31,7 +31,7 @@
3131
class SpoofAttributes:
3232
def __init__(
3333
self,
34-
spoof_target: Union[BaseTransaction, BaseUnsignedTransaction],
34+
spoof_target: Union[SignedTransactionAPI, UnsignedTransactionAPI],
3535
**overrides: Any) -> None:
3636
self.spoof_target = spoof_target
3737
self.overrides = overrides

0 commit comments

Comments
 (0)