1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.filterEvents = void 0;
|
4 | const util_1 = require("@polkadot/util");
|
5 | const logging_js_1 = require("./logging.js");
|
6 | function filterEvents(txHash, { block: { extrinsics, header } }, allEvents, status) {
|
7 |
|
8 | for (const [txIndex, x] of extrinsics.entries()) {
|
9 | if (x.hash.eq(txHash)) {
|
10 | return {
|
11 | blockNumber: (0, util_1.isCompact)(header.number) ? header.number.unwrap() : header.number,
|
12 | events: allEvents.filter(({ phase }) => phase.isApplyExtrinsic &&
|
13 | phase.asApplyExtrinsic.eqn(txIndex)),
|
14 | txIndex
|
15 | };
|
16 | }
|
17 | }
|
18 |
|
19 |
|
20 | if (status.isInBlock) {
|
21 | const allHashes = extrinsics.map((x) => x.hash.toHex());
|
22 | logging_js_1.l.warn(`block ${header.hash.toHex()}: Unable to find extrinsic ${txHash.toHex()} inside ${allHashes.join(', ')}`);
|
23 | }
|
24 | return {};
|
25 | }
|
26 | exports.filterEvents = filterEvents;
|