Skip to content

Commit

Permalink
Extend and more properly define typing for BlockIdentifier
Browse files Browse the repository at this point in the history
- Borrowing from the typing used in web3.py, where it has worked quite well, ``BlockIdentifer`` needed some modernizing that would be nice to use across libraries. eth-tester could benefit once type hinting is introduced there.
  • Loading branch information
fselmo committed Jun 28, 2023
1 parent a1d8f6a commit bb75480
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion eth_typing/evm.py
Expand Up @@ -4,13 +4,18 @@
Union,
)

from typing_extensions import (
Literal,
)

from .encoding import (
HexStr,
)

Hash32 = NewType("Hash32", bytes)
BlockNumber = NewType("BlockNumber", int)
BlockIdentifier = Union[BlockNumber, Hash32]
BlockParams = Literal["latest", "earliest", "pending", "safe", "finalized"]
BlockIdentifier = Union[BlockParams, BlockNumber, Hash32, HexStr, int]

Address = NewType("Address", bytes)
HexAddress = NewType("HexAddress", HexStr)
Expand Down
1 change: 1 addition & 0 deletions newsfragments/47.feature.rst
@@ -0,0 +1 @@
Borrowing from the typing in web3.py, open up ``BlockIdentifier`` to include ``BlockParams`` (e.g. "latest", "finalized", etc..) as well as other valid values.

0 comments on commit bb75480

Please sign in to comment.