@eclesia/indexer-engine 2.7.4 → 2.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,13 @@
1
- import EventEmitter from "events";
2
- export class EclesiaEmitter {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.EclesiaEmitter = void 0;
7
+ const events_1 = __importDefault(require("events"));
8
+ class EclesiaEmitter {
3
9
  constructor() {
4
- this.emitter = new EventEmitter();
10
+ this.emitter = new events_1.default();
5
11
  this.handled = new Map();
6
12
  this.handlerMap = new WeakMap();
7
13
  this.emitter.setMaxListeners(0);
@@ -65,3 +71,4 @@ export class EclesiaEmitter {
65
71
  }
66
72
  }
67
73
  }
74
+ exports.EclesiaEmitter = EclesiaEmitter;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from "./emitter/index.js";
2
- export * from "./indexer/index.js";
3
- export * from "./promise-queue/index.js";
4
- export * as Types from "./types/index.js";
5
- export * as Utils from "./utils/index.js";
1
+ export * from "./emitter";
2
+ export * from "./indexer";
3
+ export * from "./promise-queue";
4
+ export * as Types from "./types";
5
+ export * as Utils from "./utils";
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,44 @@
1
- export * from "./emitter/index.js";
2
- export * from "./indexer/index.js";
3
- export * from "./promise-queue/index.js";
4
- export * as Types from "./types/index.js";
5
- export * as Utils from "./utils/index.js";
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.Utils = exports.Types = void 0;
40
+ __exportStar(require("./emitter"), exports);
41
+ __exportStar(require("./indexer"), exports);
42
+ __exportStar(require("./promise-queue"), exports);
43
+ exports.Types = __importStar(require("./types"));
44
+ exports.Utils = __importStar(require("./utils"));
@@ -1,7 +1,7 @@
1
1
  import { CometClient } from "@cosmjs/tendermint-rpc";
2
2
  import winston from "winston";
3
- import { EclesiaEmitter } from "../emitter/index.js";
4
- import { EcleciaIndexerConfig, EmitFunc, WithHeightAndUUID } from "../types/index.js";
3
+ import { EclesiaEmitter } from "../emitter";
4
+ import { EcleciaIndexerConfig, EmitFunc, WithHeightAndUUID } from "../types";
5
5
  export declare const defaultIndexerConfig: {
6
6
  startHeight: number;
7
7
  batchSize: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/indexer/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACgC,WAAW,EACjD,MAAM,wBAAwB,CAAC;AAkChC,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EACL,cAAc,EACf,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EACO,oBAAoB,EAAE,QAAQ,EAAqB,iBAAiB,EACjF,MAAM,mBAAmB,CAAC;AAQ3B,eAAO,MAAM,oBAAoB;;;;;cAKX,oBAAoB,CAAC,UAAU,CAAC;;;;;;;8BAO1B,OAAO;CAClC,CAAC;AAEF,qBAAa,cAAe,SAAQ,cAAc;IAChD,OAAO,CAAC,MAAM,CAAuB;IAErC,OAAO,CAAC,OAAO,CAAkB;IAEjC,OAAO,CAAC,UAAU,CAAa;IAE/B,OAAO,CAAC,YAAY,CAAU;IAE9B,OAAO,CAAC,eAAe,CAAU;IAEjC,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,CAAC,UAAU,CAAK;IAEhB,MAAM,EAAG,WAAW,CAAC;IAErB,WAAW,EAAG,WAAW,CAAC;IAE1B,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC;IAE3B,OAAO,CAAC,YAAY,CAAkB;IAEtC,OAAO,CAAC,WAAW,CAEjB;IAEF,OAAO,CAAC,YAAY,CAA6D;gBAErE,MAAM,EAAE,oBAAoB;IA6ExC,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,aAAa,CAQnB;IAEF,OAAO,CAAC,SAAS;IASJ,OAAO;IAuBP,KAAK;IA2KX,SAAS,EAAE,QAAQ,CAAC,MAAM,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CA2C3D;YAEY,YAAY;YAmJZ,OAAO;IAmER,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,GAAE,OAAc,GAAG,OAAO,CAAC,UAAU,CAAC;IA2BlH,OAAO,CAAC,gBAAgB;YAiDV,YAAY;IAa1B,OAAO,CAAC,WAAW;YASL,cAAc;YAsCd,cAAc;YA4Bd,YAAY;CAkE3B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/indexer/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACgC,WAAW,EACjD,MAAM,wBAAwB,CAAC;AA4ChC,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EACL,cAAc,EACf,MAAM,YAAY,CAAC;AAIpB,OAAO,EACO,oBAAoB,EAAE,QAAQ,EAAqB,iBAAiB,EACjF,MAAM,UAAU,CAAC;AAQlB,eAAO,MAAM,oBAAoB;;;;;cAKX,oBAAoB,CAAC,UAAU,CAAC;;;;;;;8BAO1B,OAAO;CAClC,CAAC;AAEF,qBAAa,cAAe,SAAQ,cAAc;IAChD,OAAO,CAAC,MAAM,CAAuB;IAErC,OAAO,CAAC,OAAO,CAAkB;IAEjC,OAAO,CAAC,UAAU,CAAa;IAE/B,OAAO,CAAC,YAAY,CAAU;IAE9B,OAAO,CAAC,eAAe,CAAU;IAEjC,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,CAAC,UAAU,CAAK;IAEhB,MAAM,EAAG,WAAW,CAAC;IAErB,WAAW,EAAG,WAAW,CAAC;IAE1B,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC;IAE3B,OAAO,CAAC,YAAY,CAAkB;IAEtC,OAAO,CAAC,WAAW,CAEjB;IAEF,OAAO,CAAC,YAAY,CAA6D;gBAErE,MAAM,EAAE,oBAAoB;IA6ExC,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,aAAa,CAQnB;IAEF,OAAO,CAAC,SAAS;IASJ,OAAO;IAuBP,KAAK;IA2KX,SAAS,EAAE,QAAQ,CAAC,MAAM,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CA2C3D;YAEY,YAAY;YAmJZ,OAAO;IAmER,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,GAAE,OAAc,GAAG,OAAO,CAAC,UAAU,CAAC;IA2BlH,OAAO,CAAC,gBAAgB;YAiDV,YAAY;IAa1B,OAAO,CAAC,WAAW;YASL,cAAc;YAsCd,cAAc;YA4Bd,YAAY;CAuE3B"}
@@ -1,24 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.EcleciaIndexer = exports.defaultIndexerConfig = void 0;
1
7
  /* eslint-disable max-lines */
2
- import { createHash, } from "node:crypto";
3
- import fs from "node:fs";
4
- import { toRfc3339WithNanoseconds, } from "@cosmjs/tendermint-rpc";
5
- import { connectComet, } from "@cosmjs/tendermint-rpc";
6
- import { MsgExec, } from "cosmjs-types/cosmos/authz/v1beta1/tx.js";
7
- import { QueryValidatorsRequest, QueryValidatorsResponse, } from "cosmjs-types/cosmos/staking/v1beta1/query.js";
8
- import { Tx, } from "cosmjs-types/cosmos/tx/v1beta1/tx.js";
9
- import Fastify from "fastify";
10
- import { chain, } from "stream-chain";
11
- import StreamJson from "stream-json";
12
- import Pick from "stream-json/filters/Pick.js";
13
- import StreamArray from "stream-json/streamers/StreamArray.js";
14
- import StreamValues from "stream-json/streamers/StreamValues.js";
15
- import Batch from "stream-json/utils/Batch.js";
16
- import { v4 as uuidv4, } from "uuid";
17
- import winston from "winston";
18
- import { EclesiaEmitter, } from "../emitter/index.js";
19
- import { CircularBuffer, } from "../promise-queue/index.js";
20
- import { decodeAttr, } from "../utils/index.js";
21
- export const defaultIndexerConfig = {
8
+ const node_crypto_1 = require("node:crypto");
9
+ const node_fs_1 = __importDefault(require("node:fs"));
10
+ const tendermint_rpc_1 = require("@cosmjs/tendermint-rpc");
11
+ const tendermint_rpc_2 = require("@cosmjs/tendermint-rpc");
12
+ const tx_1 = require("cosmjs-types/cosmos/authz/v1beta1/tx");
13
+ const query_1 = require("cosmjs-types/cosmos/staking/v1beta1/query");
14
+ const tx_2 = require("cosmjs-types/cosmos/tx/v1beta1/tx");
15
+ const fastify_1 = __importDefault(require("fastify"));
16
+ const stream_chain_1 = require("stream-chain");
17
+ const stream_json_1 = require("stream-json");
18
+ const Pick_1 = require("stream-json/filters/Pick");
19
+ const StreamArray_1 = require("stream-json/streamers/StreamArray");
20
+ const StreamValues_1 = require("stream-json/streamers/StreamValues");
21
+ const Batch_1 = require("stream-json/utils/Batch");
22
+ const uuid_1 = require("uuid");
23
+ const winston_1 = __importDefault(require("winston"));
24
+ const emitter_1 = require("../emitter");
25
+ const promise_queue_1 = require("../promise-queue");
26
+ const utils_1 = require("../utils");
27
+ exports.defaultIndexerConfig = {
22
28
  startHeight: 1,
23
29
  batchSize: 500,
24
30
  modules: [],
@@ -32,7 +38,7 @@ export const defaultIndexerConfig = {
32
38
  beginTransaction: () => Promise.resolve(),
33
39
  endTransaction: (_status) => Promise.resolve(),
34
40
  };
35
- export class EcleciaIndexer extends EclesiaEmitter {
41
+ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
36
42
  constructor(config) {
37
43
  super();
38
44
  this.initialized = false;
@@ -48,7 +54,7 @@ export class EcleciaIndexer extends EclesiaEmitter {
48
54
  },
49
55
  };
50
56
  this.asyncEmit = async (type, event) => {
51
- event.uuid = uuidv4();
57
+ event.uuid = (0, uuid_1.v4)();
52
58
  /*
53
59
  * More than 1 listener can be registered for an event type
54
60
  * Fortunately these are all set up during module init() so we have a consistent count
@@ -84,40 +90,40 @@ export class EcleciaIndexer extends EclesiaEmitter {
84
90
  return prom;
85
91
  };
86
92
  this.config = {
87
- ...defaultIndexerConfig,
93
+ ...exports.defaultIndexerConfig,
88
94
  ...config,
89
95
  };
90
96
  if (this.config.minimal) {
91
- this.blockQueue = new CircularBuffer(this.config.batchSize);
97
+ this.blockQueue = new promise_queue_1.CircularBuffer(this.config.batchSize);
92
98
  }
93
99
  else {
94
- this.blockQueue = new CircularBuffer(this.config.batchSize);
100
+ this.blockQueue = new promise_queue_1.CircularBuffer(this.config.batchSize);
95
101
  }
96
- const { printf, } = winston.format;
102
+ const { printf, } = winston_1.default.format;
97
103
  const eclesiaFormat = printf(({ level, message, timestamp, }) => {
98
104
  return `${timestamp} [${level.toUpperCase()}]:\t${message}`;
99
105
  });
100
- this.log = winston.createLogger({
106
+ this.log = winston_1.default.createLogger({
101
107
  level: this.config.logLevel,
102
108
  defaultMeta: {
103
109
  service: "Eclesia Indexer",
104
110
  },
105
111
  transports: [
106
- new winston.transports.File({
112
+ new winston_1.default.transports.File({
107
113
  filename: "error.log",
108
114
  level: "error",
109
115
  }),
110
- new winston.transports.File({
116
+ new winston_1.default.transports.File({
111
117
  filename: "combined.log",
112
118
  }),
113
- new winston.transports.Console({
114
- format: winston.format.combine(winston.format.splat(), winston.format.timestamp(), eclesiaFormat, winston.format.colorize({
119
+ new winston_1.default.transports.Console({
120
+ format: winston_1.default.format.combine(winston_1.default.format.splat(), winston_1.default.format.timestamp(), eclesiaFormat, winston_1.default.format.colorize({
115
121
  all: true,
116
122
  })),
117
123
  }),
118
124
  ],
119
125
  });
120
- this.fastify = Fastify({
126
+ this.fastify = (0, fastify_1.default)({
121
127
  logger: false,
122
128
  });
123
129
  this.on("_unhandled", (msg) => {
@@ -164,9 +170,9 @@ export class EcleciaIndexer extends EclesiaEmitter {
164
170
  this.blockClient.disconnect();
165
171
  this.log.verbose("Disconnected from RPC");
166
172
  }
167
- this.client = await connectComet(this.config.rpcUrl);
173
+ this.client = await (0, tendermint_rpc_2.connectComet)(this.config.rpcUrl);
168
174
  this.log.info("Connected to RPC for ad hoc queries");
169
- this.blockClient = await connectComet(this.config.rpcUrl);
175
+ this.blockClient = await (0, tendermint_rpc_2.connectComet)(this.config.rpcUrl);
170
176
  this.log.info("Connected to RPC for block & validator info");
171
177
  return true;
172
178
  }
@@ -261,7 +267,7 @@ export class EcleciaIndexer extends EclesiaEmitter {
261
267
  throw new Error("Could not fetch block");
262
268
  }
263
269
  height = toProcess[0].block.header.height;
264
- timestamp = toRfc3339WithNanoseconds(toProcess[0].block.header.time);
270
+ timestamp = (0, tendermint_rpc_1.toRfc3339WithNanoseconds)(toProcess[0].block.header.time);
265
271
  await this.processBlock(toProcess[0], toProcess[1]);
266
272
  }
267
273
  else {
@@ -272,8 +278,8 @@ export class EcleciaIndexer extends EclesiaEmitter {
272
278
  }
273
279
  this.log.silly("Decoded block");
274
280
  height = toProcess[0].block.header.height;
275
- timestamp = toRfc3339WithNanoseconds(toProcess[0].block.header.time);
276
- await this.processBlock(toProcess[0], toProcess[1], QueryValidatorsResponse.decode(toProcess[2]).validators);
281
+ timestamp = (0, tendermint_rpc_1.toRfc3339WithNanoseconds)(toProcess[0].block.header.time);
282
+ await this.processBlock(toProcess[0], toProcess[1], query_1.QueryValidatorsResponse.decode(toProcess[2]).validators);
277
283
  }
278
284
  // Emit events to trigger periodic operations every 50, 100 and 1000 blocks
279
285
  if (height % 1000 == 0) {
@@ -342,7 +348,7 @@ export class EcleciaIndexer extends EclesiaEmitter {
342
348
  this.log.debug("Processing block: %d", height);
343
349
  this.log.silly("Started db tx");
344
350
  // Initialize height & timestamp to be used for this block-processing run
345
- const timestamp = toRfc3339WithNanoseconds(block.block.header.time);
351
+ const timestamp = (0, tendermint_rpc_1.toRfc3339WithNanoseconds)(block.block.header.time);
346
352
  // Use & await asyncEmit to ensure db insertions in order
347
353
  /*
348
354
  * Emit block information to any interested modules.
@@ -376,7 +382,7 @@ export class EcleciaIndexer extends EclesiaEmitter {
376
382
  this.log.silly("Modules handled tx events");
377
383
  // Emit details and result for each tx msg separately
378
384
  for (let t = 0; t < block.block.txs.length; t++) {
379
- const tx = Tx.decode(block.block.txs[t]);
385
+ const tx = tx_2.Tx.decode(block.block.txs[t]);
380
386
  const result = block_results.results[t].code;
381
387
  const txlog = block_results.results[t].log;
382
388
  if (result != 0) {
@@ -384,7 +390,7 @@ export class EcleciaIndexer extends EclesiaEmitter {
384
390
  continue;
385
391
  }
386
392
  if (tx.body && tx.body.memo != "") {
387
- const txHash = createHash("sha256").update(block.block.txs[t])
393
+ const txHash = (0, node_crypto_1.createHash)("sha256").update(block.block.txs[t])
388
394
  .digest("hex");
389
395
  await this.asyncEmit("tx_memo", {
390
396
  value: {
@@ -415,12 +421,12 @@ export class EcleciaIndexer extends EclesiaEmitter {
415
421
  timestamp,
416
422
  });
417
423
  if (msgs[i].typeUrl == "/cosmos.authz.v1beta1.MsgExec") {
418
- const authzMsgs = MsgExec.decode(msgs[i].value).msgs;
424
+ const authzMsgs = tx_1.MsgExec.decode(msgs[i].value).msgs;
419
425
  if (authzMsgs) {
420
426
  for (let r = 0; r < authzMsgs.length; r++) {
421
427
  this.log.silly("Indexer broadcasting msg for handling: " + authzMsgs[r].typeUrl);
422
428
  const authzMsgEvents = msgevents?.reduce((events, evt) => {
423
- if (evt.attributes.filter(x => decodeAttr(x.key) == "authz_msg_index" && decodeAttr(x.value) == "" + r).length > 0) {
429
+ if (evt.attributes.filter(x => (0, utils_1.decodeAttr)(x.key) == "authz_msg_index" && (0, utils_1.decodeAttr)(x.value) == "" + r).length > 0) {
424
430
  events.push(evt);
425
431
  }
426
432
  return events;
@@ -476,12 +482,12 @@ export class EcleciaIndexer extends EclesiaEmitter {
476
482
  const timeoutPromise = new Promise((resolve, reject) => {
477
483
  setTimeout(reject, 20000, false);
478
484
  });
479
- const q = QueryValidatorsRequest.fromPartial({
485
+ const q = query_1.QueryValidatorsRequest.fromPartial({
480
486
  pagination: {
481
487
  limit: 1000n,
482
488
  },
483
489
  });
484
- const vals = QueryValidatorsRequest.encode(q).finish();
490
+ const vals = query_1.QueryValidatorsRequest.encode(q).finish();
485
491
  const toIndex = Promise.race([
486
492
  Promise.all([
487
493
  this.blockClient.block(i),
@@ -555,12 +561,12 @@ export class EcleciaIndexer extends EclesiaEmitter {
555
561
  }));
556
562
  }
557
563
  else {
558
- const q = QueryValidatorsRequest.fromPartial({
564
+ const q = query_1.QueryValidatorsRequest.fromPartial({
559
565
  pagination: {
560
566
  limit: 1000n,
561
567
  },
562
568
  });
563
- const vals = QueryValidatorsRequest.encode(q).finish();
569
+ const vals = query_1.QueryValidatorsRequest.encode(q).finish();
564
570
  this.blockQueue.enqueue(Promise.all([
565
571
  this.client.block(height),
566
572
  this.client.blockResults(height),
@@ -592,7 +598,7 @@ export class EcleciaIndexer extends EclesiaEmitter {
592
598
  }
593
599
  readGenesis() {
594
600
  if (this.config.genesisPath) {
595
- return fs.createReadStream(this.config.genesisPath).pipe(StreamJson.parser());
601
+ return node_fs_1.default.createReadStream(this.config.genesisPath).pipe((0, stream_json_1.parser)());
596
602
  }
597
603
  else {
598
604
  throw new Error("Genesis path not set");
@@ -602,15 +608,15 @@ export class EcleciaIndexer extends EclesiaEmitter {
602
608
  const readPromise = new Promise((resolve, reject) => {
603
609
  try {
604
610
  const filters = path.split(".");
605
- const pickers = filters.map(filter => Pick.pick({
611
+ const pickers = filters.map(filter => (0, Pick_1.pick)({
606
612
  filter,
607
613
  }));
608
614
  let counter = 0;
609
- chain([
615
+ (0, stream_chain_1.chain)([
610
616
  this.readGenesis(),
611
617
  ...pickers,
612
- StreamArray.streamArray(),
613
- Batch.batch({
618
+ (0, StreamArray_1.streamArray)(),
619
+ (0, Batch_1.batch)({
614
620
  batchSize: 1000,
615
621
  }),
616
622
  processor,
@@ -636,11 +642,11 @@ export class EcleciaIndexer extends EclesiaEmitter {
636
642
  const readPromise = new Promise((resolve, reject) => {
637
643
  try {
638
644
  const filters = path.split(".");
639
- const pickers = filters.map(filter => Pick.pick({
645
+ const pickers = filters.map(filter => (0, Pick_1.pick)({
640
646
  filter,
641
647
  }));
642
648
  let counter = 0;
643
- chain([this.readGenesis(), ...pickers, StreamValues.streamValues(), processor])
649
+ (0, stream_chain_1.chain)([this.readGenesis(), ...pickers, (0, StreamValues_1.streamValues)(), processor])
644
650
  .on("data", (_data) => {
645
651
  counter++;
646
652
  })
@@ -706,9 +712,15 @@ export class EcleciaIndexer extends EclesiaEmitter {
706
712
  this.log.info("Finished importing");
707
713
  }
708
714
  catch (e) {
709
- await this.config.endTransaction(false);
715
+ try {
716
+ await this.config.endTransaction(false);
717
+ }
718
+ catch (dbe) {
719
+ this.log.error("Error ending transaction. Must be a DB error: " + dbe);
720
+ }
710
721
  this.log.error("Failed to import genesis");
711
722
  throw e;
712
723
  }
713
724
  }
714
725
  }
726
+ exports.EcleciaIndexer = EcleciaIndexer;
@@ -1,10 +1,13 @@
1
+ "use strict";
1
2
  /*
2
3
  *This implements an "infinite" FIFO queue of fixed size.
3
4
  *await `continue()` before enqueing items to ensure fixed size (as it only resolves when space available)
4
5
  *await `dequeue()` to pop an item as it will only resolve if the next item is available
5
6
  *size() is always at minimum 1 item which is the promise that will resolve to the next item whenever it is enqueued
6
7
  */
7
- export class PromiseQueue {
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.CircularBuffer = exports.PromiseQueue = void 0;
10
+ class PromiseQueue {
8
11
  constructor(batchSize) {
9
12
  this.synced = false;
10
13
  const nextVal = new Promise((resolve, _reject) => {
@@ -69,7 +72,8 @@ export class PromiseQueue {
69
72
  return this.items.length;
70
73
  }
71
74
  }
72
- export class CircularBuffer {
75
+ exports.PromiseQueue = PromiseQueue;
76
+ class CircularBuffer {
73
77
  constructor(batchSize) {
74
78
  this.count = 0;
75
79
  this.next = 0;
@@ -165,3 +169,4 @@ export class CircularBuffer {
165
169
  return this.count;
166
170
  }
167
171
  }
172
+ exports.CircularBuffer = CircularBuffer;
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,9 @@
1
- import { bech32, } from "bech32";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chainAddressfromKeyhash = chainAddressfromKeyhash;
4
+ exports.keyHashfromAddress = keyHashfromAddress;
5
+ exports.toHexString = toHexString;
6
+ const bech32_1 = require("bech32");
2
7
  function toHexString(byteArray) {
3
8
  return Array.prototype.map
4
9
  .call(byteArray, (byte) => {
@@ -8,16 +13,15 @@ function toHexString(byteArray) {
8
13
  }
9
14
  function keyHashfromAddress(address) {
10
15
  try {
11
- return toHexString(bech32.fromWords(bech32.decode(address).words));
16
+ return toHexString(bech32_1.bech32.fromWords(bech32_1.bech32.decode(address).words));
12
17
  }
13
18
  catch (_e) {
14
19
  throw new Error("Could not decode address");
15
20
  }
16
21
  }
17
22
  function chainAddressfromKeyhash(prefix, keyhash) {
18
- const words = bech32.toWords(Buffer.from(keyhash, "hex"));
23
+ const words = bech32_1.bech32.toWords(Buffer.from(keyhash, "hex"));
19
24
  return keyhash !== ""
20
- ? bech32.encode(prefix, words)
25
+ ? bech32_1.bech32.encode(prefix, words)
21
26
  : "";
22
27
  }
23
- export { chainAddressfromKeyhash, keyHashfromAddress, toHexString, };
@@ -1,4 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toPlainObject = void 0;
1
4
  const toPlainObject = (obj) => {
2
5
  return JSON.parse(JSON.stringify(obj, (key, value) => (typeof value === "bigint" ? value.toString() : value)));
3
6
  };
4
- export { toPlainObject, };
7
+ exports.toPlainObject = toPlainObject;
@@ -1,4 +1,4 @@
1
- export * from "./bech32.js";
2
- export * from "./bigint.js";
3
- export * from "./text.js";
1
+ export * from "./bech32";
2
+ export * from "./bigint";
3
+ export * from "./text";
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
@@ -1,3 +1,19 @@
1
- export * from "./bech32.js";
2
- export * from "./bigint.js";
3
- export * from "./text.js";
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./bech32"), exports);
18
+ __exportStar(require("./bigint"), exports);
19
+ __exportStar(require("./text"), exports);
@@ -1,4 +1,7 @@
1
- export const decodeAttr = (x) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decodeAttr = void 0;
4
+ const decodeAttr = (x) => {
2
5
  if (typeof x === "string") {
3
6
  return x;
4
7
  }
@@ -9,3 +12,4 @@ export const decodeAttr = (x) => {
9
12
  return "";
10
13
  }
11
14
  };
15
+ exports.decodeAttr = decodeAttr;
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "@eclesia/indexer-engine",
3
- "version": "2.7.4",
3
+ "version": "2.7.5",
4
4
  "description": "Core eclesia indexer engine",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
- "type": "module",
8
7
  "scripts": {
9
8
  "build": "tsc",
10
9
  "lint": "eslint",
@@ -38,7 +37,7 @@
38
37
  "access": "public"
39
38
  },
40
39
  "dependencies": {
41
- "@cosmjs/tendermint-rpc": "^0.36.0",
40
+ "@cosmjs/tendermint-rpc": "^0.33.1",
42
41
  "bech32": "^2.0.0",
43
42
  "cosmjs-types": "^0.10.1",
44
43
  "dayjs": "^1.11.18",