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

Adds a dictionary of event args/data to Event type for easier access to variables #60

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Changes from 7 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
48641f5
add key-value pair of event variable name to data emitted to all boa.…
kibagateaux Jan 23, 2023
9c1f958
move all Event type instantiation to decode_logs
kibagateaux Jan 23, 2023
ecbb5be
generate Event.args_map on request and cache instead of instaniating …
kibagateaux Jan 23, 2023
481b7f5
refactor for less code change
kibagateaux Jan 24, 2023
b25388e
use pre-commit hook
kibagateaux Jan 24, 2023
5ee6d62
fix formatting issues
kibagateaux Jan 24, 2023
ee50b01
return typed event data in args_map
kibagateaux Jan 25, 2023
7f6f671
update with pr comments and run pre-commit
kibagateaux Jan 30, 2023
813e0e6
add initial event tests
kibagateaux Feb 6, 2023
d36cbda
simplify tests
kibagateaux Feb 7, 2023
0c65895
remove chacing from event.ordered_args and update tests
kibagateaux Feb 7, 2023
0a35685
Merge branch 'master' of https://github.com/vyperlang/titanoboa
kibagateaux Jun 26, 2023
3385a34
improve state machine test
charles-cooper Jun 30, 2023
a9a710f
move some test directories around
charles-cooper Jun 30, 2023
3697e04
remove dead member variable
charles-cooper Jun 30, 2023
96cdb93
fix lint
charles-cooper Jun 30, 2023
43bfedc
add key-value pair of event variable name to data emitted to all boa.…
kibagateaux Jan 23, 2023
f4f0c90
move all Event type instantiation to decode_logs
kibagateaux Jan 23, 2023
2169b86
add initial event tests
kibagateaux Feb 6, 2023
4b960e7
simplify tests
kibagateaux Feb 7, 2023
dca7546
remove chacing from event.ordered_args and update tests
kibagateaux Feb 7, 2023
c027156
simplify and clean up event tests
kibagateaux Jul 4, 2023
5a3dc46
move event test out of strategies
kibagateaux Jul 4, 2023
1a2fc06
bump vyper version and update event tests for compatability
kibagateaux Jul 4, 2023
7dea3c3
update event tests to use actual contract event emissions
kibagateaux Jul 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions boa/vyper/event.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import functools
from dataclasses import dataclass
from typing import Any, List
from typing import Any, List, Dict, Tuple



@dataclass
Expand All @@ -11,6 +13,15 @@ class Event:
args: List[Any] # list of decoded args

def __repr__(self):
args = ", ".join(f"{k}={v}" for k, v in self._get_ordered_args())
return f"{self.event_type.name}({args})"

@functools.cached_property
def args_map(self) -> Dict[str, str | int]:
return dict(self._get_ordered_args())

@functools.cached_property
def _get_ordered_args(self) -> List[Tuple[str, str | int]]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is a cached property, I’d just call it something else other than a getter. ‘ordered_args’ is good enough.

t_i = 0
a_i = 0
b = []
Expand All @@ -25,10 +36,8 @@ def __repr__(self):
else:
b.append((k, self.args[a_i]))
a_i += 1

args = ", ".join(f"{k}={v}" for k, v in b)
return f"{self.event_type.name}({args})"


return b

class RawEvent:
event_data: Any