Skip to content

Commit

Permalink
chore: refactor (#24)
Browse files Browse the repository at this point in the history
* chore: refactor

* chore: `black .`

* fix(test): install pytest in gh workflow

* chore: update lockfile

* fix(test): dont use pytest asyncio plugin

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
BobTheBuidler and github-actions[bot] authored Dec 4, 2024
1 parent c63e5ef commit dfcbf1a
Show file tree
Hide file tree
Showing 19 changed files with 174 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ jobs:
PYTEST_NETWORK: mainnet
ETHERSCAN_TOKEN: ${{ secrets.ETHERSCAN_TOKEN }}
run: |
poetry run pytest --asyncio-task-timeout=3600
poetry run pytest
14 changes: 9 additions & 5 deletions evmspec/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from evmspec import block, header, log, trace, transaction
from evmspec.header import ErigonBlockHeader
from evmspec.receipt import FullTransactionReceipt, TransactionReceipt
from evmspec.trace import FilterTrace
from evmspec import block, structs, trace, transaction
from evmspec.structs import (
ErigonBlockHeader,
FilterTrace,
FullTransactionReceipt,
TransactionReceipt,
header,
)
from evmspec.transaction import (
TransactionRLP,
TransactionLegacy,
Expand All @@ -15,11 +19,11 @@
# modules
"block",
"header",
"log",
"receipt",
"trace",
"transaction",
# structs
"structs",
# - header
"ErigonBlockHeader",
# - receipt
Expand Down
12 changes: 1 addition & 11 deletions evmspec/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,7 @@
from msgspec import UNSET, Raw, ValidationError, field, json

from evmspec._ids import IntId
from evmspec.data import (
Address,
BlockHash,
BlockNumber,
Nonce,
TransactionHash,
UnixTimestamp,
Wei,
uint,
_decode_hook,
)
from evmspec.data import *
from evmspec.transaction import Transaction, TransactionRLP


Expand Down
26 changes: 26 additions & 0 deletions evmspec/data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from evmspec.data import uints
from evmspec.data.main import (
Address,
BlockHash,
BlockNumber,
HexBytes32,
Nonce,
TransactionHash,
UnixTimestamp,
Wei,
uint,
_decode_hook,
)

__all__ = [
"Address",
"uint",
"Wei",
"HexBytes32",
"TransactionHash",
"BlockNumber",
"BlockHash",
"uints",
"UnixTimestamp",
"Nonce",
]
4 changes: 2 additions & 2 deletions evmspec/data.py → evmspec/data/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from typing_extensions import Self

if TYPE_CHECKING:
from evmspec.log import Log
from evmspec.receipt import TransactionReceipt
from evmspec.structs.log import Log
from evmspec.structs.receipt import TransactionReceipt

_T = TypeVar("_T")
"""A generic type variable."""
Expand Down
17 changes: 11 additions & 6 deletions evmspec/uints.py → evmspec/data/uints.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
"""
This module provides classes to decode and represent unsigned integer
types of any byte size, ensuring values adhere to defined minimum and maximum constraints.
Note:
While only a few specific classes like :class:`uint8`, :class:`uint64`,
:class:`uint128`, and :class:`uint256` are explicitly defined,
other classes are dynamically generated for byte sizes from 2 to 31, excluding those already defined.
"""

import sys

from hexbytes import HexBytes

from evmspec.data import uint
from evmspec.data.main import uint


class _UintData(uint):
Expand All @@ -12,11 +22,6 @@ class _UintData(uint):
This class provides a framework to define unsigned integer types of any byte size,
ensuring values adhere to defined minimum and maximum constraints.
Note:
While only a few specific classes like :class:`uint8`, :class:`uint64`,
:class:`uint128`, and :class:`uint256` are explicitly defined,
other classes are dynamically generated for byte sizes from 2 to 31, excluding those already defined.
See Also:
:class:`uint8`, :class:`uint64`, :class:`uint128`, :class:`uint256`
"""
Expand Down
20 changes: 20 additions & 0 deletions evmspec/structs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from evmspec.structs.header import ErigonBlockHeader
from evmspec.structs.receipt import FullTransactionReceipt, TransactionReceipt
from evmspec.structs.trace import FilterTrace

__all__ = [
# - header
"ErigonBlockHeader",
# - receipt
"FullTransactionReceipt",
"TransactionReceipt",
# - trace
"FilterTrace",
# - transaction
"Transaction",
"AnyTransaction",
"TransactionRLP",
"TransactionLegacy",
"Transaction2930",
"Transaction1559",
]
1 change: 1 addition & 0 deletions evmspec/header.py → evmspec/structs/header.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from hexbytes import HexBytes

from dictstruct import LazyDictStruct

from evmspec.data import Address, UnixTimestamp, uint


Expand Down
2 changes: 1 addition & 1 deletion evmspec/log.py → evmspec/structs/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from dictstruct import LazyDictStruct
from hexbytes import HexBytes

from evmspec import uints
from evmspec._ids import LogIndex, TransactionIndex
from evmspec.data import (
Address,
Expand All @@ -12,6 +11,7 @@
HexBytes32,
TransactionHash,
uint,
uints,
)

_ADDRESS_TOPIC_PREFIX = HexBytes("0") * 12
Expand Down
2 changes: 1 addition & 1 deletion evmspec/receipt.py → evmspec/structs/receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from evmspec._ids import TransactionIndex
from evmspec.data import Address, BlockNumber, TransactionHash, Wei, uint, _decode_hook
from evmspec.log import Log
from evmspec.structs.log import Log


class FeeStats(DictStruct, frozen=True, forbid_unknown_fields=True): # type: ignore [call-arg]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 1 addition & 10 deletions evmspec/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,7 @@
from msgspec import UNSET, Raw, field, json

from evmspec._ids import ChainId, TransactionIndex
from evmspec.data import (
Address,
BlockHash,
BlockNumber,
HexBytes32,
Nonce,
TransactionHash,
Wei,
uint,
)
from evmspec.data import *


class AccessListEntry(LazyDictStruct, frozen=True, forbid_unknown_fields=True): # type: ignore [call-arg]
Expand Down
106 changes: 99 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ sphinx = "*"
sphinx-rtd-theme = "*"
mypy = "*"
types-cachetools = "*"
pytest = "*"

[tool.mypy]
ignore_missing_imports = true

0 comments on commit dfcbf1a

Please sign in to comment.