UNPKG

1.1 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.filterEvents = filterEvents;
7
8var _logging = require("./logging");
9
10// Copyright 2017-2022 @polkadot/api authors & contributors
11// SPDX-License-Identifier: Apache-2.0
12function filterEvents(txHash, _ref, allEvents, status) {
13 let {
14 block: {
15 extrinsics,
16 header
17 }
18 } = _ref;
19
20 // extrinsics to hashes
21 for (const [txIndex, x] of extrinsics.entries()) {
22 if (x.hash.eq(txHash)) {
23 return {
24 events: allEvents.filter(_ref2 => {
25 let {
26 phase
27 } = _ref2;
28 return phase.isApplyExtrinsic && phase.asApplyExtrinsic.eqn(txIndex);
29 }),
30 txIndex
31 };
32 }
33 } // if we do get the block after finalized, it _should_ be there
34 // only warn on filtering with isInBlock (finalization finalizes after)
35
36
37 if (status.isInBlock) {
38 const allHashes = extrinsics.map(x => x.hash.toHex());
39
40 _logging.l.warn(`block ${header.hash.toHex()}: Unable to find extrinsic ${txHash.toHex()} inside ${allHashes.join(', ')}`);
41 }
42
43 return {};
44}
\No newline at end of file