Skip to content

Commit

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

* chore: `black .`

* chore: bump deps

---------

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 134a06a commit 972c733
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
bobs_lazy_logging==0.0.4
checksum_dict>=1.4.2,<2
dank_mids>=4.20.108
dank_mids>=4.20.109
eth-brownie>=1.19.3,<1.21
eth_retry>=0.1.19,<0.2
evmspec>=0.1.0
ez-a-sync>=0.24.20
inflection>=0.1,<0.6
joblib>=1.0.1
Expand Down
6 changes: 3 additions & 3 deletions y/_db/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@


@final
class Log(evmspec.log.Log, frozen=True, kw_only=True, array_like=True):
class Log(evmspec.Log, frozen=True, kw_only=True, array_like=True):
"""
Extends :class:`~evmspec.log.Log` with additional configuration for immutability,
Extends :class:`evmspec.Log` with additional configuration for immutability,
keyword-only arguments, and array-like encoding behavior using :class:`msgspec.Struct`.
This class is designed to behave like a tuple specifically during `msgspec.json`
Expand All @@ -29,6 +29,6 @@ class Log(evmspec.log.Log, frozen=True, kw_only=True, array_like=True):
>>> print(log_tuple)
See Also:
- :class:`~evmspec.log.Log` for the base class implementation.
- :class:`evmspec.Log` for the base class implementation.
- :class:`msgspec.Struct` for details on the `array_like` feature.
"""
4 changes: 2 additions & 2 deletions y/_db/utils/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from async_lru import alru_cache
from brownie import chain
from brownie.network.event import _EventItem
from eth_typing import ChecksumAddress, HexStr
from eth_typing import HexStr
from evmspec.data import Address, HexBytes32, uint
from evmspec.log import Topic
from evmspec.structs.log import Topic
from hexbytes import HexBytes
from msgspec import json, ValidationError
from pony.orm import commit, db_session, select
Expand Down
4 changes: 2 additions & 2 deletions y/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import dank_mids.brownie_patch.call
import eth_event.main
import eth_utils
import evmspec.data
import evmspec.data._main
import multicall.call
import web3._utils as web3_utils
import web3.main as web3_main
Expand Down Expand Up @@ -245,7 +245,7 @@ def _monkey_patch_dependencies():
eth_utils.address.to_checksum_address = to_address

# this monkey patches evmspec's Address decode hook with our lru cache
evmspec.data.to_checksum_address = to_address
evmspec.data._main.to_checksum_address = to_address

# this monkey patches multicall.Call.target checksumming with our lru cache
multicall.call.to_checksum_address = to_address
Expand Down
4 changes: 3 additions & 1 deletion y/prices/lending/compound.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ async def get_underlying_price(
if isinstance(price, Exception):
# TODO debug why this occurs and refactor. only found on arbitrum cream
try:
price = await ENVS.CONTRACT_THREADS.run(oracle.getUnderlyingPrice, self.address, block_identifier=block)
price = await ENVS.CONTRACT_THREADS.run(
oracle.getUnderlyingPrice, self.address, block_identifier=block
)
except VirtualMachineError as e:
if str(e) in {
"revert: grace period not over",
Expand Down
4 changes: 2 additions & 2 deletions y/utils/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
EventDict,
)
from eth_typing import ChecksumAddress
from evmspec.log import Log
from evmspec import Log
from msgspec.structs import force_setattr
from toolz import groupby
from web3.middleware.filter import block_ranges
Expand Down Expand Up @@ -71,7 +71,7 @@ def decode_logs(logs: Union[Iterable[LogReceipt], Iterable[Log]]) -> EventDict:
Decode logs to events and enrich them with additional info.
Args:
logs: An iterable of :class:`~web3.types.LogReceipt` or :class:`~evmspec.log.Log` objects.
logs: An iterable of :class:`~web3.types.LogReceipt` or :class:`~evmspec.Log` objects.
Returns:
An :class:`~brownie.network.event.EventDict` containing decoded events.
Expand Down

0 comments on commit 972c733

Please sign in to comment.