Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend and more properly define typing for BlockIdentifier #47

Merged
merged 2 commits into from Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.
4 changes: 4 additions & 0 deletions setup.py
Expand Up @@ -57,6 +57,10 @@
author_email="snakecharmers@ethereum.org",
url="https://github.com/ethereum/eth-typing",
include_package_data=True,
install_requires=[
# remove typing_extensions after python_requires>=3.8
"typing-extensions>=4.0.1",
],
python_requires=">=3.7.2, <4",
extras_require=extras_require,
py_modules=["eth_typing"],
Expand Down