Skip to content

Commit

Permalink
generate Event.args_map on request and cache instead of instaniating …
Browse files Browse the repository at this point in the history
…object
  • Loading branch information
kibagateaux committed Jan 23, 2023
1 parent 9c1f958 commit ecbb5be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 1 addition & 2 deletions boa/vyper/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,7 @@ def decode_log(self, e):
a_i += 1

event_name = ", ".join(f"{k}={v}" for k, v in decoded_values)
args_map = dict([(k,v) for k, v in decoded_values])
return Event(log_id, self.address, event_t, event_name, decoded_topics, args, args_map)
return Event(log_id, self.address, event_t, event_name, decoded_topics, args)

def marshal_to_python(self, computation, vyper_typ):
self._computation = computation # for further inspection
Expand Down
10 changes: 7 additions & 3 deletions boa/vyper/event.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import functools
from dataclasses import dataclass
from typing import Any, List, Dict

Expand All @@ -11,11 +12,14 @@ class Event:
event_name: str # human readable output
topics: List[Any] # list of decoded topics
args: List[Any] # list of decoded args
args_map: Dict[str, Any] # Mapping of decoded args

def __repr__(self):
return self.event_name


@functools.cached_property
def args_map(self):
event_values = self.event_name.split(', ')
return dict([(topic.split('=')) for topic in event_values])

class RawEvent:
event_data: Any
event_data: Any

0 comments on commit ecbb5be

Please sign in to comment.