This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
Enhancement: Add flattedEvents
selector to debugger
#5385
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds to the debugger the seletor
txlog.views.flattedEvents
. This selector gives a flat list of all events emitted during the transaction so far; note that as atxlog
selector it's meant primarily to be used at the end of a transaction.The selector's return value is an array of all events emitted during the transaction so far, in order; note, however, that this includes events that may have reverted. However, each event includes a
status
field to distinguish, so if you want you can filter down to just the events that were successfully emitted (and then you can put indices on them if you really want :) ). (I thought about adding an additional selector that actually performed this filtering, but this seemed unnecessary so I skipped it.) Note that if you look at this selector before the transaction has completed, thenstatus: true
will merely indicate that the event hasn't reverted yet; it may still revert in the future.Each event contains the fields
decoding
,raw
(withtopics
anddata
),address
,codeAddress
, andstatus
. Thedecoding
is the same decoding from txlog;raw
is the same as well. Theaddress
field lists the address that officially emitted the event, whilecodeAddress
is the address of the actual code that emitted the event; these may differ in the event of a delegate call (as it's the storage address, not the code address, that officially emits the event). Note that if a constructor emits an event, the address being constructed is used for bothaddress
andcodeAddress
. Also note as usual that if a constructor reverts, we may not be able to determine the address, and it may show up as zero instead.I'll skip explaining how it works as it's just a straightforward recursive traversal of the txlog tree. Note that an event will be marked as
status: false
if either the call that made it reverts, or if any containing call reverts, because either way it was not successfully emitted!I also added a test.