titanoboa
titanoboa copied to clipboard
Adds a dictionary of event args/data to Event type for easier access to variables
Description
Updates Event type in boa/vyper/events.py
Allows access to event data with event variable names e.g. contract.get_logs()[0].args_map['my_event_variable']
- creates internal function
Event._get_ordered_args
from currentEvent.__repr__
code - refactors
Event.__repr__
to useEvent._get_ordered_args
- add
args_map
property to Event type - generates
args_map
dictionary fromEvent._get_ordered_args
- adds caching to
_get_ordered_args
andargs_map
TODO
[x] Convert event values to appropriate type. Currently all values are strings which makes comparing numbers cumbersome (always have to do event.args_map['my_int'] == str(my_int)
)
Testing
- Currently no testing for events. Would appreciate advice on how you guys want that setup.
- Have implemented in my own repo and my tests are passing successfully. Can clone and run
ape test --network=::foundry --cache-clear -m "event_emissions"
It’s missing a pre-commit run. Also some simple tests using a mock contract will help quite a bit! Something like what you have in your repo, but minimal.