Skip to content

Commit

Permalink
feat: add event utils to Contract
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler committed Oct 4, 2023
1 parent 84ebad5 commit 69f259f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion y/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import logging
import threading
from collections import defaultdict
from functools import partial
from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union

import a_sync
Expand Down Expand Up @@ -33,6 +32,7 @@
from y.time import check_node, check_node_async
from y.utils.cache import memory
from y.utils.dank_mids import dank_w3
from y.utils.events import Events

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -249,6 +249,9 @@ def __init__(
patch_contract(self, dank_w3) # Patch the Contract with coroutines for each method.
_squeeze(self) # Get rid of unnecessary memory-hog properties

for k, v in self.topics.items():
setattr(self.events, k, Events([self.address], [v], from_block=0))

self._ttl_cache_popper: Union[Literal["disabled"], int, asyncio.TimerHandle]
try:
self._ttl_cache_popper = "disabled" if cache_ttl is None else asyncio.get_running_loop().call_later(cache_ttl, self._ChecksumAddressSingletonMeta__instances.pop, self.address)
Expand Down

0 comments on commit 69f259f

Please sign in to comment.