Skip to content

Commit

Permalink
fix: handle multipe events better in disp
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Jun 25, 2024
1 parent 8587c3d commit c1815f7
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions evm_trace/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,18 @@ def make_tree(
# Events have no children.
return

# Treat events as leaf calls.
for event in root.events:
yield cls(event, parent=displayable_root, is_last=True)

count = 1
for child_node in root.calls:
is_last = count == len(root.calls)
# Handle events, which won't have any sub-calls or anything.
total_events = len(root.events)
for index, event in enumerate(root.events, start=1):
is_last = index == total_events
yield cls(event, parent=displayable_root, is_last=is_last)

# Handle calls (and calls of calls).
total_calls = len(root.calls)
for index, child_node in enumerate(root.calls, start=1):
is_last = index == total_calls
# NOTE: `.make_tree()` will handle calls of calls (recursion).
yield from cls.make_tree(child_node, parent=displayable_root, is_last=is_last)
count += 1

def __str__(self) -> str:
"""
Expand Down

0 comments on commit c1815f7

Please sign in to comment.