@eclesia/indexer-engine 2.7.3 → 2.7.4

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,13 +1,7 @@
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 {
1
+ import EventEmitter from "events";
2
+ export class EclesiaEmitter {
9
3
  constructor() {
10
- this.emitter = new events_1.default();
4
+ this.emitter = new EventEmitter();
11
5
  this.handled = new Map();
12
6
  this.handlerMap = new WeakMap();
13
7
  this.emitter.setMaxListeners(0);
@@ -71,4 +65,3 @@ class EclesiaEmitter {
71
65
  }
72
66
  }
73
67
  }
74
- exports.EclesiaEmitter = EclesiaEmitter;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
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";
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";
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,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC"}
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"}
package/dist/index.js CHANGED
@@ -1,44 +1,5 @@
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
+ 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,7 +1,7 @@
1
1
  import { CometClient } from "@cosmjs/tendermint-rpc";
2
2
  import winston from "winston";
3
- import { EclesiaEmitter } from "../emitter";
4
- import { EcleciaIndexerConfig, EmitFunc, WithHeightAndUUID } from "../types";
3
+ import { EclesiaEmitter } from "../emitter/index.js";
4
+ import { EcleciaIndexerConfig, EmitFunc, WithHeightAndUUID } from "../types/index.js";
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;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;IAsKX,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;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,30 +1,24 @@
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;
7
1
  /* eslint-disable max-lines */
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 = {
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 = {
28
22
  startHeight: 1,
29
23
  batchSize: 500,
30
24
  modules: [],
@@ -38,7 +32,7 @@ exports.defaultIndexerConfig = {
38
32
  beginTransaction: () => Promise.resolve(),
39
33
  endTransaction: (_status) => Promise.resolve(),
40
34
  };
41
- class EcleciaIndexer extends emitter_1.EclesiaEmitter {
35
+ export class EcleciaIndexer extends EclesiaEmitter {
42
36
  constructor(config) {
43
37
  super();
44
38
  this.initialized = false;
@@ -54,7 +48,7 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
54
48
  },
55
49
  };
56
50
  this.asyncEmit = async (type, event) => {
57
- event.uuid = (0, uuid_1.v4)();
51
+ event.uuid = uuidv4();
58
52
  /*
59
53
  * More than 1 listener can be registered for an event type
60
54
  * Fortunately these are all set up during module init() so we have a consistent count
@@ -90,40 +84,40 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
90
84
  return prom;
91
85
  };
92
86
  this.config = {
93
- ...exports.defaultIndexerConfig,
87
+ ...defaultIndexerConfig,
94
88
  ...config,
95
89
  };
96
90
  if (this.config.minimal) {
97
- this.blockQueue = new promise_queue_1.CircularBuffer(this.config.batchSize);
91
+ this.blockQueue = new CircularBuffer(this.config.batchSize);
98
92
  }
99
93
  else {
100
- this.blockQueue = new promise_queue_1.CircularBuffer(this.config.batchSize);
94
+ this.blockQueue = new CircularBuffer(this.config.batchSize);
101
95
  }
102
- const { printf, } = winston_1.default.format;
96
+ const { printf, } = winston.format;
103
97
  const eclesiaFormat = printf(({ level, message, timestamp, }) => {
104
98
  return `${timestamp} [${level.toUpperCase()}]:\t${message}`;
105
99
  });
106
- this.log = winston_1.default.createLogger({
100
+ this.log = winston.createLogger({
107
101
  level: this.config.logLevel,
108
102
  defaultMeta: {
109
103
  service: "Eclesia Indexer",
110
104
  },
111
105
  transports: [
112
- new winston_1.default.transports.File({
106
+ new winston.transports.File({
113
107
  filename: "error.log",
114
108
  level: "error",
115
109
  }),
116
- new winston_1.default.transports.File({
110
+ new winston.transports.File({
117
111
  filename: "combined.log",
118
112
  }),
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({
113
+ new winston.transports.Console({
114
+ format: winston.format.combine(winston.format.splat(), winston.format.timestamp(), eclesiaFormat, winston.format.colorize({
121
115
  all: true,
122
116
  })),
123
117
  }),
124
118
  ],
125
119
  });
126
- this.fastify = (0, fastify_1.default)({
120
+ this.fastify = Fastify({
127
121
  logger: false,
128
122
  });
129
123
  this.on("_unhandled", (msg) => {
@@ -170,9 +164,9 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
170
164
  this.blockClient.disconnect();
171
165
  this.log.verbose("Disconnected from RPC");
172
166
  }
173
- this.client = await (0, tendermint_rpc_2.connectComet)(this.config.rpcUrl);
167
+ this.client = await connectComet(this.config.rpcUrl);
174
168
  this.log.info("Connected to RPC for ad hoc queries");
175
- this.blockClient = await (0, tendermint_rpc_2.connectComet)(this.config.rpcUrl);
169
+ this.blockClient = await connectComet(this.config.rpcUrl);
176
170
  this.log.info("Connected to RPC for block & validator info");
177
171
  return true;
178
172
  }
@@ -267,7 +261,7 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
267
261
  throw new Error("Could not fetch block");
268
262
  }
269
263
  height = toProcess[0].block.header.height;
270
- timestamp = (0, tendermint_rpc_1.toRfc3339WithNanoseconds)(toProcess[0].block.header.time);
264
+ timestamp = toRfc3339WithNanoseconds(toProcess[0].block.header.time);
271
265
  await this.processBlock(toProcess[0], toProcess[1]);
272
266
  }
273
267
  else {
@@ -278,8 +272,8 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
278
272
  }
279
273
  this.log.silly("Decoded block");
280
274
  height = toProcess[0].block.header.height;
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);
275
+ timestamp = toRfc3339WithNanoseconds(toProcess[0].block.header.time);
276
+ await this.processBlock(toProcess[0], toProcess[1], QueryValidatorsResponse.decode(toProcess[2]).validators);
283
277
  }
284
278
  // Emit events to trigger periodic operations every 50, 100 and 1000 blocks
285
279
  if (height % 1000 == 0) {
@@ -316,7 +310,12 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
316
310
  catch (e) {
317
311
  this.log.error("" + e);
318
312
  this.setStatus("FAILED");
319
- await this.config.endTransaction(false);
313
+ try {
314
+ await this.config.endTransaction(false);
315
+ }
316
+ catch (dbe) {
317
+ this.log.error("Error ending transaction. Must be a DB error: " + dbe);
318
+ }
320
319
  this.tryToRecover = true;
321
320
  this.retryCount++;
322
321
  break;
@@ -343,7 +342,7 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
343
342
  this.log.debug("Processing block: %d", height);
344
343
  this.log.silly("Started db tx");
345
344
  // Initialize height & timestamp to be used for this block-processing run
346
- const timestamp = (0, tendermint_rpc_1.toRfc3339WithNanoseconds)(block.block.header.time);
345
+ const timestamp = toRfc3339WithNanoseconds(block.block.header.time);
347
346
  // Use & await asyncEmit to ensure db insertions in order
348
347
  /*
349
348
  * Emit block information to any interested modules.
@@ -377,7 +376,7 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
377
376
  this.log.silly("Modules handled tx events");
378
377
  // Emit details and result for each tx msg separately
379
378
  for (let t = 0; t < block.block.txs.length; t++) {
380
- const tx = tx_2.Tx.decode(block.block.txs[t]);
379
+ const tx = Tx.decode(block.block.txs[t]);
381
380
  const result = block_results.results[t].code;
382
381
  const txlog = block_results.results[t].log;
383
382
  if (result != 0) {
@@ -385,7 +384,7 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
385
384
  continue;
386
385
  }
387
386
  if (tx.body && tx.body.memo != "") {
388
- const txHash = (0, node_crypto_1.createHash)("sha256").update(block.block.txs[t])
387
+ const txHash = createHash("sha256").update(block.block.txs[t])
389
388
  .digest("hex");
390
389
  await this.asyncEmit("tx_memo", {
391
390
  value: {
@@ -416,12 +415,12 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
416
415
  timestamp,
417
416
  });
418
417
  if (msgs[i].typeUrl == "/cosmos.authz.v1beta1.MsgExec") {
419
- const authzMsgs = tx_1.MsgExec.decode(msgs[i].value).msgs;
418
+ const authzMsgs = MsgExec.decode(msgs[i].value).msgs;
420
419
  if (authzMsgs) {
421
420
  for (let r = 0; r < authzMsgs.length; r++) {
422
421
  this.log.silly("Indexer broadcasting msg for handling: " + authzMsgs[r].typeUrl);
423
422
  const authzMsgEvents = msgevents?.reduce((events, evt) => {
424
- if (evt.attributes.filter(x => (0, utils_1.decodeAttr)(x.key) == "authz_msg_index" && (0, utils_1.decodeAttr)(x.value) == "" + r).length > 0) {
423
+ if (evt.attributes.filter(x => decodeAttr(x.key) == "authz_msg_index" && decodeAttr(x.value) == "" + r).length > 0) {
425
424
  events.push(evt);
426
425
  }
427
426
  return events;
@@ -477,12 +476,12 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
477
476
  const timeoutPromise = new Promise((resolve, reject) => {
478
477
  setTimeout(reject, 20000, false);
479
478
  });
480
- const q = query_1.QueryValidatorsRequest.fromPartial({
479
+ const q = QueryValidatorsRequest.fromPartial({
481
480
  pagination: {
482
481
  limit: 1000n,
483
482
  },
484
483
  });
485
- const vals = query_1.QueryValidatorsRequest.encode(q).finish();
484
+ const vals = QueryValidatorsRequest.encode(q).finish();
486
485
  const toIndex = Promise.race([
487
486
  Promise.all([
488
487
  this.blockClient.block(i),
@@ -556,12 +555,12 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
556
555
  }));
557
556
  }
558
557
  else {
559
- const q = query_1.QueryValidatorsRequest.fromPartial({
558
+ const q = QueryValidatorsRequest.fromPartial({
560
559
  pagination: {
561
560
  limit: 1000n,
562
561
  },
563
562
  });
564
- const vals = query_1.QueryValidatorsRequest.encode(q).finish();
563
+ const vals = QueryValidatorsRequest.encode(q).finish();
565
564
  this.blockQueue.enqueue(Promise.all([
566
565
  this.client.block(height),
567
566
  this.client.blockResults(height),
@@ -593,7 +592,7 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
593
592
  }
594
593
  readGenesis() {
595
594
  if (this.config.genesisPath) {
596
- return node_fs_1.default.createReadStream(this.config.genesisPath).pipe((0, stream_json_1.parser)());
595
+ return fs.createReadStream(this.config.genesisPath).pipe(StreamJson.parser());
597
596
  }
598
597
  else {
599
598
  throw new Error("Genesis path not set");
@@ -603,15 +602,15 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
603
602
  const readPromise = new Promise((resolve, reject) => {
604
603
  try {
605
604
  const filters = path.split(".");
606
- const pickers = filters.map(filter => (0, Pick_1.pick)({
605
+ const pickers = filters.map(filter => Pick.pick({
607
606
  filter,
608
607
  }));
609
608
  let counter = 0;
610
- (0, stream_chain_1.chain)([
609
+ chain([
611
610
  this.readGenesis(),
612
611
  ...pickers,
613
- (0, StreamArray_1.streamArray)(),
614
- (0, Batch_1.batch)({
612
+ StreamArray.streamArray(),
613
+ Batch.batch({
615
614
  batchSize: 1000,
616
615
  }),
617
616
  processor,
@@ -637,11 +636,11 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
637
636
  const readPromise = new Promise((resolve, reject) => {
638
637
  try {
639
638
  const filters = path.split(".");
640
- const pickers = filters.map(filter => (0, Pick_1.pick)({
639
+ const pickers = filters.map(filter => Pick.pick({
641
640
  filter,
642
641
  }));
643
642
  let counter = 0;
644
- (0, stream_chain_1.chain)([this.readGenesis(), ...pickers, (0, StreamValues_1.streamValues)(), processor])
643
+ chain([this.readGenesis(), ...pickers, StreamValues.streamValues(), processor])
645
644
  .on("data", (_data) => {
646
645
  counter++;
647
646
  })
@@ -713,4 +712,3 @@ class EcleciaIndexer extends emitter_1.EclesiaEmitter {
713
712
  }
714
713
  }
715
714
  }
716
- exports.EcleciaIndexer = EcleciaIndexer;
@@ -1,13 +1,10 @@
1
- "use strict";
2
1
  /*
3
2
  *This implements an "infinite" FIFO queue of fixed size.
4
3
  *await `continue()` before enqueing items to ensure fixed size (as it only resolves when space available)
5
4
  *await `dequeue()` to pop an item as it will only resolve if the next item is available
6
5
  *size() is always at minimum 1 item which is the promise that will resolve to the next item whenever it is enqueued
7
6
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.CircularBuffer = exports.PromiseQueue = void 0;
10
- class PromiseQueue {
7
+ export class PromiseQueue {
11
8
  constructor(batchSize) {
12
9
  this.synced = false;
13
10
  const nextVal = new Promise((resolve, _reject) => {
@@ -72,8 +69,7 @@ class PromiseQueue {
72
69
  return this.items.length;
73
70
  }
74
71
  }
75
- exports.PromiseQueue = PromiseQueue;
76
- class CircularBuffer {
72
+ export class CircularBuffer {
77
73
  constructor(batchSize) {
78
74
  this.count = 0;
79
75
  this.next = 0;
@@ -169,4 +165,3 @@ class CircularBuffer {
169
165
  return this.count;
170
166
  }
171
167
  }
172
- exports.CircularBuffer = CircularBuffer;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,9 +1,4 @@
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");
1
+ import { bech32, } from "bech32";
7
2
  function toHexString(byteArray) {
8
3
  return Array.prototype.map
9
4
  .call(byteArray, (byte) => {
@@ -13,15 +8,16 @@ function toHexString(byteArray) {
13
8
  }
14
9
  function keyHashfromAddress(address) {
15
10
  try {
16
- return toHexString(bech32_1.bech32.fromWords(bech32_1.bech32.decode(address).words));
11
+ return toHexString(bech32.fromWords(bech32.decode(address).words));
17
12
  }
18
13
  catch (_e) {
19
14
  throw new Error("Could not decode address");
20
15
  }
21
16
  }
22
17
  function chainAddressfromKeyhash(prefix, keyhash) {
23
- const words = bech32_1.bech32.toWords(Buffer.from(keyhash, "hex"));
18
+ const words = bech32.toWords(Buffer.from(keyhash, "hex"));
24
19
  return keyhash !== ""
25
- ? bech32_1.bech32.encode(prefix, words)
20
+ ? bech32.encode(prefix, words)
26
21
  : "";
27
22
  }
23
+ export { chainAddressfromKeyhash, keyHashfromAddress, toHexString, };
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toPlainObject = void 0;
4
1
  const toPlainObject = (obj) => {
5
2
  return JSON.parse(JSON.stringify(obj, (key, value) => (typeof value === "bigint" ? value.toString() : value)));
6
3
  };
7
- exports.toPlainObject = toPlainObject;
4
+ export { toPlainObject, };
@@ -1,4 +1,4 @@
1
- export * from "./bech32";
2
- export * from "./bigint";
3
- export * from "./text";
1
+ export * from "./bech32.js";
2
+ export * from "./bigint.js";
3
+ export * from "./text.js";
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,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
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,19 +1,3 @@
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
+ export * from "./bech32.js";
2
+ export * from "./bigint.js";
3
+ export * from "./text.js";
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decodeAttr = void 0;
4
- const decodeAttr = (x) => {
1
+ export const decodeAttr = (x) => {
5
2
  if (typeof x === "string") {
6
3
  return x;
7
4
  }
@@ -12,4 +9,3 @@ const decodeAttr = (x) => {
12
9
  return "";
13
10
  }
14
11
  };
15
- exports.decodeAttr = decodeAttr;
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@eclesia/indexer-engine",
3
- "version": "2.7.3",
3
+ "version": "2.7.4",
4
4
  "description": "Core eclesia indexer engine",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
+ "type": "module",
7
8
  "scripts": {
8
9
  "build": "tsc",
9
10
  "lint": "eslint",
@@ -37,7 +38,7 @@
37
38
  "access": "public"
38
39
  },
39
40
  "dependencies": {
40
- "@cosmjs/tendermint-rpc": "^0.33.1",
41
+ "@cosmjs/tendermint-rpc": "^0.36.0",
41
42
  "bech32": "^2.0.0",
42
43
  "cosmjs-types": "^0.10.1",
43
44
  "dayjs": "^1.11.18",