Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit b4b5a9d

Browse files
committed
Add selector txlog.views.flattedEvents
1 parent 6615720 commit b4b5a9d

File tree

1 file changed

+43
-0
lines changed
  • packages/debugger/lib/txlog/selectors

1 file changed

+43
-0
lines changed

packages/debugger/lib/txlog/selectors/index.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,49 @@ let txlog = createSelectorTree({
437437
}
438438
: node;
439439
return tie(log[""]); //"" is always the root node
440+
}),
441+
442+
/**
443+
* txlog.views.flattedEvents
444+
*/
445+
flattedEvents: createLeaf(["./transactionLog"], log => {
446+
const getFlattedEvents = (node, address, codeAddress, status) => {
447+
switch (node.type) {
448+
case "transaction":
449+
return node.actions.flatMap(subNode =>
450+
getFlattedEvents(subNode, node.origin, node.origin, status)
451+
);
452+
case "callexternal":
453+
const subNodeStatus = ["return", "selfdestruct"].includes(
454+
node.returnKind
455+
);
456+
return node.actions.flatMap(subNode =>
457+
getFlattedEvents(
458+
subNode,
459+
node.isDelegate ? address : node.address,
460+
node.address,
461+
status && subNodeStatus
462+
)
463+
);
464+
case "callinternal":
465+
return node.actions.flatMap(subNode =>
466+
getFlattedEvents(subNode, address, codeAddress, status)
467+
);
468+
case "event":
469+
return [
470+
{
471+
decoding: node.decoding,
472+
raw: node.raw,
473+
address,
474+
codeAddress,
475+
status
476+
}
477+
];
478+
default:
479+
return [];
480+
}
481+
};
482+
return getFlattedEvents(log, null, null, true);
440483
})
441484
}
442485
});

0 commit comments

Comments
 (0)