titanoboa icon indicating copy to clipboard operation
titanoboa copied to clipboard

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

Open kibagateaux opened this issue 2 years ago • 1 comments

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 current Event.__repr__ code
  • refactors Event.__repr__ to use Event._get_ordered_args
  • add args_map property to Event type
  • generates args_map dictionary from Event._get_ordered_args
  • adds caching to _get_ordered_args and args_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"

kibagateaux avatar Jan 23 '23 19:01 kibagateaux

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.

bout3fiddy avatar Jan 25 '23 18:01 bout3fiddy