@eclesia/indexer-engine 2.14.4 → 2.16.0

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.
Files changed (121) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +20 -15
  2. package/dist/_virtual/rolldown_runtime.mjs +10 -30
  3. package/dist/constants.cjs +31 -2
  4. package/dist/constants.cjs.map +1 -1
  5. package/dist/constants.d.cts +27 -3
  6. package/dist/constants.d.cts.map +1 -1
  7. package/dist/constants.d.mts +27 -3
  8. package/dist/constants.d.mts.map +1 -1
  9. package/dist/constants.mjs +27 -3
  10. package/dist/constants.mjs.map +1 -1
  11. package/dist/emitter/index.cjs +25 -7
  12. package/dist/emitter/index.cjs.map +1 -1
  13. package/dist/emitter/index.d.cts +8 -1
  14. package/dist/emitter/index.d.cts.map +1 -1
  15. package/dist/emitter/index.d.mts +8 -1
  16. package/dist/emitter/index.d.mts.map +1 -1
  17. package/dist/emitter/index.mjs +25 -7
  18. package/dist/emitter/index.mjs.map +1 -1
  19. package/dist/index.cjs +6 -0
  20. package/dist/index.d.cts +3 -3
  21. package/dist/index.d.mts +3 -3
  22. package/dist/index.mjs +3 -3
  23. package/dist/indexer/index.cjs +498 -225
  24. package/dist/indexer/index.cjs.map +1 -1
  25. package/dist/indexer/index.d.cts +111 -7
  26. package/dist/indexer/index.d.cts.map +1 -1
  27. package/dist/indexer/index.d.mts +111 -7
  28. package/dist/indexer/index.d.mts.map +1 -1
  29. package/dist/indexer/index.mjs +496 -224
  30. package/dist/indexer/index.mjs.map +1 -1
  31. package/dist/metrics/index.cjs +14 -0
  32. package/dist/metrics/index.cjs.map +1 -1
  33. package/dist/metrics/index.d.cts +7 -0
  34. package/dist/metrics/index.d.cts.map +1 -1
  35. package/dist/metrics/index.d.mts +7 -0
  36. package/dist/metrics/index.d.mts.map +1 -1
  37. package/dist/metrics/index.mjs +14 -0
  38. package/dist/metrics/index.mjs.map +1 -1
  39. package/dist/mocks/index.cjs +3 -1
  40. package/dist/mocks/index.cjs.map +1 -1
  41. package/dist/mocks/index.d.cts +2 -2
  42. package/dist/mocks/index.d.mts +2 -2
  43. package/dist/mocks/index.mjs +4 -2
  44. package/dist/mocks/index.mjs.map +1 -1
  45. package/dist/mocks/rpc-client.cjs +185 -20
  46. package/dist/mocks/rpc-client.cjs.map +1 -1
  47. package/dist/mocks/rpc-client.d.cts +26 -10
  48. package/dist/mocks/rpc-client.d.cts.map +1 -1
  49. package/dist/mocks/rpc-client.d.mts +26 -10
  50. package/dist/mocks/rpc-client.d.mts.map +1 -1
  51. package/dist/mocks/rpc-client.mjs +184 -22
  52. package/dist/mocks/rpc-client.mjs.map +1 -1
  53. package/dist/promise-queue/index.cjs +10 -4
  54. package/dist/promise-queue/index.cjs.map +1 -1
  55. package/dist/promise-queue/index.d.cts +1 -4
  56. package/dist/promise-queue/index.d.cts.map +1 -1
  57. package/dist/promise-queue/index.d.mts +1 -4
  58. package/dist/promise-queue/index.d.mts.map +1 -1
  59. package/dist/promise-queue/index.mjs +10 -4
  60. package/dist/promise-queue/index.mjs.map +1 -1
  61. package/dist/types/index.cjs.map +1 -1
  62. package/dist/types/index.d.cts +28 -5
  63. package/dist/types/index.d.cts.map +1 -1
  64. package/dist/types/index.d.mts +28 -5
  65. package/dist/types/index.d.mts.map +1 -1
  66. package/dist/types/index.mjs.map +1 -1
  67. package/dist/utils/index.cjs +6 -1
  68. package/dist/utils/index.cjs.map +1 -1
  69. package/dist/utils/index.d.cts +3 -2
  70. package/dist/utils/index.d.mts +3 -2
  71. package/dist/utils/index.mjs +7 -2
  72. package/dist/utils/index.mjs.map +1 -1
  73. package/dist/utils/text.cjs +31 -0
  74. package/dist/utils/text.cjs.map +1 -1
  75. package/dist/utils/text.d.cts +24 -1
  76. package/dist/utils/text.d.cts.map +1 -1
  77. package/dist/utils/text.d.mts +24 -1
  78. package/dist/utils/text.d.mts.map +1 -1
  79. package/dist/utils/text.mjs +30 -1
  80. package/dist/utils/text.mjs.map +1 -1
  81. package/dist/utils/timeout.cjs +32 -0
  82. package/dist/utils/timeout.cjs.map +1 -0
  83. package/dist/utils/timeout.d.cts +18 -0
  84. package/dist/utils/timeout.d.cts.map +1 -0
  85. package/dist/utils/timeout.d.mts +18 -0
  86. package/dist/utils/timeout.d.mts.map +1 -0
  87. package/dist/utils/timeout.mjs +30 -0
  88. package/dist/utils/timeout.mjs.map +1 -0
  89. package/package.json +35 -34
  90. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/ascii.cjs +0 -32
  91. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/ascii.cjs.map +0 -1
  92. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/ascii.mjs +0 -29
  93. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/ascii.mjs.map +0 -1
  94. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/base64.cjs +0 -67
  95. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/base64.cjs.map +0 -1
  96. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/base64.mjs +0 -64
  97. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/base64.mjs.map +0 -1
  98. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/bech32.cjs +0 -80
  99. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/bech32.cjs.map +0 -1
  100. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/bech32.mjs +0 -77
  101. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/bech32.mjs.map +0 -1
  102. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/hex.cjs +0 -33
  103. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/hex.cjs.map +0 -1
  104. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/hex.mjs +0 -30
  105. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/hex.mjs.map +0 -1
  106. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/index.cjs +0 -106
  107. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/index.cjs.map +0 -1
  108. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/index.mjs +0 -103
  109. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/index.mjs.map +0 -1
  110. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/rfc3339.cjs +0 -52
  111. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/rfc3339.cjs.map +0 -1
  112. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/rfc3339.mjs +0 -49
  113. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/rfc3339.mjs.map +0 -1
  114. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/utf8.cjs +0 -31
  115. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/utf8.cjs.map +0 -1
  116. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/utf8.mjs +0 -28
  117. package/dist/node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/utf8.mjs.map +0 -1
  118. package/dist/node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.cjs +0 -98
  119. package/dist/node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.cjs.map +0 -1
  120. package/dist/node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.mjs +0 -95
  121. package/dist/node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.mjs.map +0 -1
@@ -1,10 +1,33 @@
1
- import { __toESM } from "../_virtual/rolldown_runtime.mjs";
2
- import { require_build } from "../node_modules/.pnpm/@cosmjs_encoding@0.36.0/node_modules/@cosmjs/encoding/build/index.mjs";
1
+ import { createHash } from "node:crypto";
3
2
  import { fromRfc3339WithNanoseconds } from "@cosmjs/tendermint-rpc";
3
+ import { QueryDelegatorDelegationsResponse, QueryParamsResponse, QueryPoolResponse, QueryValidatorDelegationsResponse, QueryValidatorsRequest, QueryValidatorsResponse } from "cosmjs-types/cosmos/staking/v1beta1/query.js";
4
4
  import { Tx } from "cosmjs-types/cosmos/tx/v1beta1/tx.js";
5
+ import { fromBase64, fromHex, toBech32 } from "@cosmjs/encoding";
6
+ import { ModuleAccount } from "cosmjs-types/cosmos/auth/v1beta1/auth.js";
7
+ import { QueryModuleAccountsResponse } from "cosmjs-types/cosmos/auth/v1beta1/query.js";
8
+ import { QueryAllBalancesResponse } from "cosmjs-types/cosmos/bank/v1beta1/query.js";
9
+ import { Validator } from "cosmjs-types/cosmos/staking/v1beta1/staking.js";
5
10
 
6
11
  //#region src/mocks/rpc-client.ts
7
- var import_build = /* @__PURE__ */ __toESM(require_build(), 1);
12
+ /**
13
+ * Mock RPC client for benchmarking and testing
14
+ * Generates synthetic blockchain data without requiring an actual RPC node
15
+ */
16
+ /** Deterministic bech32 address from a small integer, for synthetic accounts and validators */
17
+ function syntheticAddress(prefix, seed) {
18
+ const bytes = new Uint8Array(20);
19
+ bytes[0] = seed & 255;
20
+ bytes[1] = seed >> 8 & 255;
21
+ bytes[19] = 1;
22
+ return toBech32(prefix, bytes);
23
+ }
24
+ /** Module accounts a chain always has, with deterministic addresses (computed on first use) */
25
+ function mockModuleAccounts() {
26
+ return {
27
+ fee_collector: syntheticAddress("cosmos", 1001),
28
+ distribution: syntheticAddress("cosmos", 1002)
29
+ };
30
+ }
8
31
  /**
9
32
  * Generates a synthetic transaction with realistic structure
10
33
  */
@@ -68,15 +91,106 @@ var MockRpcClient = class {
68
91
  startHeight;
69
92
  endHeight;
70
93
  txPerBlock;
71
- constructor({ chainId, startHeight, endHeight, txPerBlock }) {
94
+ cometVersion;
95
+ validatorCount;
96
+ constructor({ chainId, startHeight, endHeight, txPerBlock, cometVersion, validatorCount }) {
72
97
  this.chainId = chainId;
73
98
  this.startHeight = startHeight;
74
99
  this.endHeight = endHeight;
75
100
  this.txPerBlock = txPerBlock;
101
+ this.cometVersion = cometVersion ?? "0.37";
102
+ this.validatorCount = validatorCount ?? 3;
103
+ }
104
+ /** The synthetic validator set, identical at every height */
105
+ validators() {
106
+ const set = [];
107
+ for (let i = 0; i < this.validatorCount; i++) set.push(Validator.fromPartial({
108
+ operatorAddress: syntheticAddress("cosmosvaloper", i + 1),
109
+ jailed: false,
110
+ status: 3,
111
+ tokens: String(1e6 * (i + 1)),
112
+ delegatorShares: String(1e6 * (i + 1)) + "000000000000000000",
113
+ description: { moniker: "mock-validator-" + (i + 1) },
114
+ commission: { commissionRates: {
115
+ rate: "100000000000000000",
116
+ maxRate: "200000000000000000",
117
+ maxChangeRate: "10000000000000000"
118
+ } },
119
+ minSelfDelegation: "1"
120
+ }));
121
+ return set;
122
+ }
123
+ /**
124
+ * Answers the ABCI queries the engine and the core modules issue. Unknown paths get a
125
+ * non-zero code, as a real node would answer for a query it does not serve.
126
+ */
127
+ async abciQuery(params) {
128
+ const reply = (value) => ({
129
+ key: new Uint8Array(),
130
+ value,
131
+ height: params.height,
132
+ index: 0,
133
+ code: 0,
134
+ codespace: "",
135
+ log: "",
136
+ info: ""
137
+ });
138
+ switch (params.path) {
139
+ case "/cosmos.staking.v1beta1.Query/Validators": {
140
+ const request = QueryValidatorsRequest.decode(params.data);
141
+ const all = this.validators();
142
+ const limit = Number(request.pagination?.limit ?? 100n) || 100;
143
+ const key = request.pagination?.key;
144
+ const offset = key && key.length > 0 ? key[0] : 0;
145
+ const page = all.slice(offset, offset + limit);
146
+ const next = offset + limit < all.length ? new Uint8Array([offset + limit]) : new Uint8Array();
147
+ return reply(QueryValidatorsResponse.encode(QueryValidatorsResponse.fromPartial({
148
+ validators: page,
149
+ pagination: {
150
+ nextKey: next,
151
+ total: BigInt(all.length)
152
+ }
153
+ })).finish());
154
+ }
155
+ case "/cosmos.auth.v1beta1.Query/ModuleAccounts": return reply(QueryModuleAccountsResponse.encode(QueryModuleAccountsResponse.fromPartial({ accounts: Object.entries(mockModuleAccounts()).map(([name, address]) => ({
156
+ typeUrl: "/cosmos.auth.v1beta1.ModuleAccount",
157
+ value: ModuleAccount.encode(ModuleAccount.fromPartial({
158
+ baseAccount: { address },
159
+ name
160
+ })).finish()
161
+ })) })).finish());
162
+ case "/cosmos.bank.v1beta1.Query/AllBalances": return reply(QueryAllBalancesResponse.encode(QueryAllBalancesResponse.fromPartial({ balances: [{
163
+ denom: "uatom",
164
+ amount: "1000000"
165
+ }] })).finish());
166
+ case "/cosmos.staking.v1beta1.Query/Pool": return reply(QueryPoolResponse.encode(QueryPoolResponse.fromPartial({ pool: {
167
+ bondedTokens: String(this.validators().reduce((sum, v) => sum + Number(v.tokens), 0)),
168
+ notBondedTokens: "0"
169
+ } })).finish());
170
+ case "/cosmos.staking.v1beta1.Query/Params": return reply(QueryParamsResponse.encode(QueryParamsResponse.fromPartial({ params: {
171
+ unbondingTime: {
172
+ seconds: 1814400n,
173
+ nanos: 0
174
+ },
175
+ maxValidators: 100,
176
+ maxEntries: 7,
177
+ historicalEntries: 1e4,
178
+ bondDenom: "uatom",
179
+ minCommissionRate: "0"
180
+ } })).finish());
181
+ case "/cosmos.staking.v1beta1.Query/DelegatorDelegations": return reply(QueryDelegatorDelegationsResponse.encode(QueryDelegatorDelegationsResponse.fromPartial({})).finish());
182
+ case "/cosmos.staking.v1beta1.Query/ValidatorDelegations": return reply(QueryValidatorDelegationsResponse.encode(QueryValidatorDelegationsResponse.fromPartial({})).finish());
183
+ default: return {
184
+ ...reply(new Uint8Array()),
185
+ code: 6,
186
+ log: "unknown request: " + params.path
187
+ };
188
+ }
76
189
  }
77
190
  async block(height) {
78
191
  const txs = [];
79
192
  for (let i = 0; i < this.txPerBlock; i++) txs.push(generateMockTx(height, i));
193
+ const hashOf = (h) => new Uint8Array(createHash("sha256").update(this.chainId + ":" + h).digest());
80
194
  return {
81
195
  block: {
82
196
  header: {
@@ -112,14 +226,14 @@ var MockRpcClient = class {
112
226
  },
113
227
  signatures: [{
114
228
  blockIdFlag: 2,
115
- validatorAddress: (0, import_build.fromHex)("D68EEC0D2E8248F1EC64CDB585EDB61ECA432BD8"),
229
+ validatorAddress: fromHex("D68EEC0D2E8248F1EC64CDB585EDB61ECA432BD8"),
116
230
  timestamp: fromRfc3339WithNanoseconds((/* @__PURE__ */ new Date()).toISOString()),
117
- signature: (0, import_build.fromBase64)("Z6d2P35dI6qBzfPdyIZvmZi7Imo2FmQ5kNSnpVb2UvCj0aSjRCtS59BauJFB6FDHPluOUYoz0rJ4jiOnNXh9AA==")
231
+ signature: fromBase64("Z6d2P35dI6qBzfPdyIZvmZi7Imo2FmQ5kNSnpVb2UvCj0aSjRCtS59BauJFB6FDHPluOUYoz0rJ4jiOnNXh9AA==")
118
232
  }]
119
233
  }
120
234
  },
121
235
  blockId: {
122
- hash: new Uint8Array(),
236
+ hash: hashOf(height),
123
237
  parts: {
124
238
  total: 0,
125
239
  hash: new Uint8Array()
@@ -135,30 +249,30 @@ var MockRpcClient = class {
135
249
  block: 11,
136
250
  app: 0
137
251
  },
138
- id: (0, import_build.fromHex)("d2982128df6a29e700980f325b0444e301c604d7"),
252
+ id: fromHex("d2982128df6a29e700980f325b0444e301c604d7"),
139
253
  listenAddr: "tcp://0.0.0.0:26656",
140
- network: "atomone-1",
141
- version: "0.37.15",
254
+ network: this.chainId,
255
+ version: this.cometVersion === "0.38" ? "0.38.17" : "0.37.15",
142
256
  channels: "40202122233038606100",
143
257
  moniker: "node",
144
258
  other: new Map([["txIndex", "on"], ["rpcAddress", "tcp://0.0.0.0:26657"]])
145
259
  },
146
260
  syncInfo: {
147
- latestBlockHash: (0, import_build.fromHex)("3F3F7A6F11FA91856BE440F8C78262307CAEAB122720D61CB14B118EF89892B5"),
148
- latestAppHash: (0, import_build.fromHex)("FF91D618633BDD5395763F34805E6DACF6BBFB642A2E787677BF28B39427F289"),
261
+ latestBlockHash: fromHex("3F3F7A6F11FA91856BE440F8C78262307CAEAB122720D61CB14B118EF89892B5"),
262
+ latestAppHash: fromHex("FF91D618633BDD5395763F34805E6DACF6BBFB642A2E787677BF28B39427F289"),
149
263
  latestBlockHeight: this.endHeight,
150
264
  latestBlockTime: fromRfc3339WithNanoseconds("2025-11-06T12:58:21.271608775Z"),
151
- earliestBlockHash: (0, import_build.fromHex)("54473B6F28CAA85F5664F7CA3F2EEE49CD9857BDE41E0BF604B1A1DE93CBFEFF"),
152
- earliestAppHash: (0, import_build.fromHex)("24DFB6C312A7FD4B753444F5CD5FAC4D239BAEC09B6A79BB3D04B21B0BC1FC53"),
265
+ earliestBlockHash: fromHex("54473B6F28CAA85F5664F7CA3F2EEE49CD9857BDE41E0BF604B1A1DE93CBFEFF"),
266
+ earliestAppHash: fromHex("24DFB6C312A7FD4B753444F5CD5FAC4D239BAEC09B6A79BB3D04B21B0BC1FC53"),
153
267
  earliestBlockHeight: 1,
154
268
  earliestBlockTime: fromRfc3339WithNanoseconds("2025-05-28T07:58:54.905470438Z"),
155
269
  catchingUp: false
156
270
  },
157
271
  validatorInfo: {
158
- address: (0, import_build.fromHex)("1C7CE0213D96CD5578249740DC31A9D8E4D7A226"),
272
+ address: fromHex("1C7CE0213D96CD5578249740DC31A9D8E4D7A226"),
159
273
  pubkey: {
160
274
  algorithm: "ed25519",
161
- data: (0, import_build.fromBase64)("+KoTmCU6lo7NCtsfPCYpdNf0fs3aScZ8CtdgHTR/oGs=")
275
+ data: fromBase64("+KoTmCU6lo7NCtsfPCYpdNf0fs3aScZ8CtdgHTR/oGs=")
162
276
  },
163
277
  votingPower: 0n
164
278
  }
@@ -172,24 +286,72 @@ var MockRpcClient = class {
172
286
  }
173
287
  async disconnect() {}
174
288
  async blockResults(height) {
289
+ const attribute = (key, value) => ({
290
+ key,
291
+ value
292
+ });
293
+ const feeCollector = mockModuleAccounts().fee_collector;
294
+ const transferEvents = (msgIndex) => [
295
+ {
296
+ type: "message",
297
+ attributes: [attribute("action", "/cosmos.bank.v1beta1.MsgSend"), attribute("msg_index", String(msgIndex))]
298
+ },
299
+ {
300
+ type: "coin_spent",
301
+ attributes: [
302
+ attribute("spender", syntheticAddress("cosmos", 1)),
303
+ attribute("amount", "10uatom"),
304
+ attribute("msg_index", String(msgIndex))
305
+ ]
306
+ },
307
+ {
308
+ type: "coin_received",
309
+ attributes: [
310
+ attribute("receiver", syntheticAddress("cosmos", 2)),
311
+ attribute("amount", "10uatom"),
312
+ attribute("msg_index", String(msgIndex))
313
+ ]
314
+ }
315
+ ];
175
316
  const results = [];
176
317
  for (let i = 0; i < this.txPerBlock; i++) results.push({
177
318
  code: 0,
178
319
  data: Buffer.from("success"),
179
- log: JSON.stringify([{
320
+ log: this.cometVersion === "0.38" ? "" : JSON.stringify([{
180
321
  msg_index: 0,
181
- events: []
322
+ events: transferEvents(0)
182
323
  }]),
183
324
  gasWanted: BigInt(2e5),
184
325
  gasUsed: BigInt(15e4),
185
- events: [],
326
+ events: transferEvents(0),
186
327
  codespace: ""
187
328
  });
329
+ const beginBlockEvents = [{
330
+ type: "coin_received",
331
+ attributes: [attribute("receiver", feeCollector), attribute("amount", "50uatom")]
332
+ }];
333
+ const endBlockEvents = [{
334
+ type: "coin_spent",
335
+ attributes: [attribute("spender", feeCollector), attribute("amount", "5uatom")]
336
+ }];
337
+ if (this.cometVersion === "0.38") {
338
+ const tagged = (events, mode) => events.map((event) => ({
339
+ type: event.type,
340
+ attributes: [...event.attributes, attribute("mode", mode)]
341
+ }));
342
+ return {
343
+ height,
344
+ results,
345
+ finalizeBlockEvents: [...tagged(beginBlockEvents, "BeginBlock"), ...tagged(endBlockEvents, "EndBlock")],
346
+ validatorUpdates: [],
347
+ consensusUpdates: void 0
348
+ };
349
+ }
188
350
  return {
189
351
  height,
190
352
  results,
191
- beginBlockEvents: [],
192
- endBlockEvents: [],
353
+ beginBlockEvents,
354
+ endBlockEvents,
193
355
  validatorUpdates: [],
194
356
  consensusUpdates: void 0
195
357
  };
@@ -204,5 +366,5 @@ function createMockRpcClient(config) {
204
366
  }
205
367
 
206
368
  //#endregion
207
- export { MockRpcClient, createMockRpcClient };
369
+ export { MockRpcClient, createMockRpcClient, mockModuleAccounts, syntheticAddress };
208
370
  //# sourceMappingURL=rpc-client.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-client.mjs","names":["tx: Tx","txs: Uint8Array[]","results: TxData[]"],"sources":["../../src/mocks/rpc-client.ts"],"sourcesContent":["/**\n * Mock RPC client for benchmarking and testing\n * Generates synthetic blockchain data without requiring an actual RPC node\n */\nimport {\n fromBase64, fromHex,\n} from \"@cosmjs/encoding\";\nimport {\n BlockResponse,\n BlockResultsResponse,\n CometClient,\n fromRfc3339WithNanoseconds,\n StatusResponse,\n TxData,\n} from \"@cosmjs/tendermint-rpc\";\nimport {\n Tx,\n} from \"cosmjs-types/cosmos/tx/v1beta1/tx.js\";\n\n/** Configuration for mock data generation */\nexport interface MockRpcConfig {\n /** Chain ID for generated blocks */\n chainId: string\n /** Number of transactions per block */\n txPerBlock: number\n /** Starting block height */\n startHeight: number\n /** Latest block height available */\n endHeight: number\n}\n/**\n * Generates a synthetic transaction with realistic structure\n */\nfunction generateMockTx(height: number, txIndex: number): Uint8Array {\n const tx: Tx = {\n body: {\n messages: [\n {\n typeUrl: \"/cosmos.bank.v1beta1.MsgSend\",\n value: new Uint8Array([10, 45, 99, 111, 115, 109, 111, 115, 49, 18, 45, 99, 111, 115, 109, 111, 115, 50]),\n },\n ],\n memo: `Mock tx ${height}-${txIndex}`,\n timeoutHeight: BigInt(height + 100),\n extensionOptions: [],\n nonCriticalExtensionOptions: [],\n },\n authInfo: {\n signerInfos: [\n {\n publicKey: {\n typeUrl: \"/cosmos.crypto.secp256k1.PubKey\",\n value: new Uint8Array(33),\n },\n modeInfo: {\n single: {\n mode: 1,\n },\n },\n sequence: BigInt(txIndex),\n },\n ],\n fee: {\n amount: [\n {\n denom: \"uatom\",\n amount: \"5000\",\n },\n ],\n gasLimit: BigInt(200000),\n payer: \"\",\n granter: \"\",\n },\n tip: undefined,\n },\n signatures: [new Uint8Array(64)],\n };\n\n return Tx.encode(tx).finish();\n}\n\nexport class MockRpcClient {\n private chainId: string;\n private startHeight: number;\n private endHeight: number;\n private txPerBlock: number;\n\n constructor({\n chainId,\n startHeight,\n endHeight,\n txPerBlock,\n }: {\n chainId: string\n startHeight: number\n endHeight: number\n txPerBlock: number\n }) {\n this.chainId = chainId;\n this.startHeight = startHeight;\n this.endHeight = endHeight;\n this.txPerBlock = txPerBlock;\n }\n\n async block(height: number): Promise<BlockResponse> {\n const txs: Uint8Array[] = [];\n for (let i = 0; i < this.txPerBlock; i++) {\n txs.push(generateMockTx(height, i));\n }\n return {\n block: {\n header: {\n height: height,\n version: {\n block: 11,\n app: 0,\n },\n time: fromRfc3339WithNanoseconds(new Date().toISOString()),\n chainId: this.chainId,\n lastBlockId: null,\n lastCommitHash: new Uint8Array(),\n dataHash: new Uint8Array(),\n validatorsHash: new Uint8Array(),\n nextValidatorsHash: new Uint8Array(),\n consensusHash: new Uint8Array(),\n appHash: new Uint8Array(),\n lastResultsHash: new Uint8Array(),\n evidenceHash: new Uint8Array(),\n proposerAddress: new Uint8Array(),\n },\n txs: txs,\n evidence: [],\n lastCommit: {\n height: height - 1,\n round: 0,\n blockId: {\n hash: new Uint8Array(),\n parts: {\n total: 0,\n hash: new Uint8Array(),\n },\n },\n signatures: [\n {\n blockIdFlag: 2,\n validatorAddress: fromHex(\"D68EEC0D2E8248F1EC64CDB585EDB61ECA432BD8\"),\n timestamp: fromRfc3339WithNanoseconds(new Date().toISOString()),\n signature: fromBase64(\"Z6d2P35dI6qBzfPdyIZvmZi7Imo2FmQ5kNSnpVb2UvCj0aSjRCtS59BauJFB6FDHPluOUYoz0rJ4jiOnNXh9AA==\"),\n },\n ],\n },\n },\n blockId: {\n hash: new Uint8Array(),\n parts: {\n total: 0,\n hash: new Uint8Array(),\n },\n },\n };\n }\n\n async status(): Promise<StatusResponse> {\n return {\n nodeInfo: {\n protocolVersion: {\n p2p: 8,\n block: 11,\n app: 0,\n },\n id: fromHex(\"d2982128df6a29e700980f325b0444e301c604d7\"),\n listenAddr: \"tcp://0.0.0.0:26656\",\n network: \"atomone-1\",\n version: \"0.37.15\",\n channels: \"40202122233038606100\",\n moniker: \"node\",\n other: new Map([[\"txIndex\", \"on\"], [\"rpcAddress\", \"tcp://0.0.0.0:26657\"]]),\n },\n syncInfo: {\n latestBlockHash: fromHex(\"3F3F7A6F11FA91856BE440F8C78262307CAEAB122720D61CB14B118EF89892B5\"),\n latestAppHash: fromHex(\"FF91D618633BDD5395763F34805E6DACF6BBFB642A2E787677BF28B39427F289\"),\n latestBlockHeight: this.endHeight,\n latestBlockTime: fromRfc3339WithNanoseconds(\"2025-11-06T12:58:21.271608775Z\"),\n earliestBlockHash: fromHex(\"54473B6F28CAA85F5664F7CA3F2EEE49CD9857BDE41E0BF604B1A1DE93CBFEFF\"),\n earliestAppHash: fromHex(\"24DFB6C312A7FD4B753444F5CD5FAC4D239BAEC09B6A79BB3D04B21B0BC1FC53\"),\n earliestBlockHeight: 1,\n earliestBlockTime: fromRfc3339WithNanoseconds(\"2025-05-28T07:58:54.905470438Z\"),\n catchingUp: false,\n },\n validatorInfo: {\n address: fromHex(\"1C7CE0213D96CD5578249740DC31A9D8E4D7A226\"),\n pubkey: {\n algorithm: \"ed25519\",\n data: fromBase64(\"+KoTmCU6lo7NCtsfPCYpdNf0fs3aScZ8CtdgHTR/oGs=\"),\n },\n votingPower: 0n,\n },\n };\n }\n\n subscribeNewBlock() {\n return {\n addListener: (..._args: unknown[]) => {},\n removeListener: (..._args: unknown[]) => {},\n } as ReturnType<CometClient[\"subscribeNewBlock\"]>;\n }\n\n async disconnect(): Promise<void> {\n // No-op for mock\n }\n\n async blockResults(height: number): Promise<BlockResultsResponse> {\n const results: TxData[] = [];\n for (let i = 0; i < this.txPerBlock; i++) {\n results.push({\n code: 0,\n data: Buffer.from(\"success\"),\n log: JSON.stringify([\n {\n msg_index: 0,\n events: [],\n },\n ]),\n gasWanted: BigInt(200000),\n gasUsed: BigInt(150000),\n events: [],\n codespace: \"\",\n });\n }\n return {\n height: height,\n results: results,\n beginBlockEvents: [],\n endBlockEvents: [],\n validatorUpdates: [],\n consensusUpdates: undefined,\n };\n }\n\n async connect(): Promise<void> {\n }\n}\n\n/**\n * Factory function to create a mock RPC client\n */\nexport function createMockRpcClient(config: MockRpcConfig): CometClient {\n return new MockRpcClient(config) as unknown as CometClient;\n}\n"],"mappings":";;;;;;;;;;AAiCA,SAAS,eAAe,QAAgB,SAA6B;CACnE,MAAMA,KAAS;EACb,MAAM;GACJ,UAAU,CACR;IACE,SAAS;IACT,OAAO,IAAI,WAAW;KAAC;KAAI;KAAI;KAAI;KAAK;KAAK;KAAK;KAAK;KAAK;KAAI;KAAI;KAAI;KAAI;KAAK;KAAK;KAAK;KAAK;KAAK;KAAG,CAAC;IAC1G,CACF;GACD,MAAM,WAAW,OAAO,GAAG;GAC3B,eAAe,OAAO,SAAS,IAAI;GACnC,kBAAkB,EAAE;GACpB,6BAA6B,EAAE;GAChC;EACD,UAAU;GACR,aAAa,CACX;IACE,WAAW;KACT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AW;GACZ,CAAC;AAEJ,SAAO;GACG;GACC;GACT,kBAAkB,EAAE;GACpB,gBAAgB,EAAE;GAClB,kBAAkB,EAAE;GACpB,kBAAkB;GACnB;;CAGH,MAAM,UAAyB;;;;;AAOjC,SAAgB,oBAAoB,QAAoC;AACtE,QAAO,IAAI,cAAc,OAAO"}
1
+ {"version":3,"file":"rpc-client.mjs","names":["tx: Tx","set: Validator[]","QueryStakingParamsResponse","txs: Uint8Array[]","results: TxData[]","beginBlockEvents: Event38[]","endBlockEvents: Event38[]"],"sources":["../../src/mocks/rpc-client.ts"],"sourcesContent":["/**\n * Mock RPC client for benchmarking and testing\n * Generates synthetic blockchain data without requiring an actual RPC node\n */\nimport {\n createHash,\n} from \"node:crypto\";\n\nimport {\n fromBase64, fromHex, toBech32,\n} from \"@cosmjs/encoding\";\nimport {\n AbciQueryParams,\n AbciQueryResponse,\n BlockResponse,\n BlockResultsResponse,\n CometClient,\n fromRfc3339WithNanoseconds,\n StatusResponse,\n TxData,\n} from \"@cosmjs/tendermint-rpc\";\nimport {\n BlockResultsResponse as BlockResultsResponse38, Event as Event38,\n} from \"@cosmjs/tendermint-rpc/build/comet38/responses.js\";\nimport {\n ModuleAccount,\n} from \"cosmjs-types/cosmos/auth/v1beta1/auth.js\";\nimport {\n QueryModuleAccountsResponse,\n} from \"cosmjs-types/cosmos/auth/v1beta1/query.js\";\nimport {\n QueryAllBalancesResponse,\n} from \"cosmjs-types/cosmos/bank/v1beta1/query.js\";\nimport {\n QueryDelegatorDelegationsResponse,\n QueryParamsResponse as QueryStakingParamsResponse,\n QueryPoolResponse,\n QueryValidatorDelegationsResponse,\n QueryValidatorsRequest,\n QueryValidatorsResponse,\n} from \"cosmjs-types/cosmos/staking/v1beta1/query.js\";\nimport {\n Validator,\n} from \"cosmjs-types/cosmos/staking/v1beta1/staking.js\";\nimport {\n Tx,\n} from \"cosmjs-types/cosmos/tx/v1beta1/tx.js\";\n\n/** Configuration for mock data generation */\nexport interface MockRpcConfig {\n /** Chain ID for generated blocks */\n chainId: string\n /** Number of transactions per block */\n txPerBlock: number\n /** Starting block height */\n startHeight: number\n /** Latest block height available */\n endHeight: number\n /** Which CometBFT response shape to produce (default: 0.37) */\n cometVersion?: \"0.37\" | \"0.38\"\n /** Size of the synthetic validator set answered by the Validators ABCI query (default: 3) */\n validatorCount?: number\n}\n\n/** Deterministic bech32 address from a small integer, for synthetic accounts and validators */\nexport function syntheticAddress(prefix: string, seed: number): string {\n const bytes = new Uint8Array(20);\n bytes[0] = seed & 0xff;\n bytes[1] = (seed >> 8) & 0xff;\n bytes[19] = 0x01;\n return toBech32(prefix, bytes);\n}\n\n/** Module accounts a chain always has, with deterministic addresses (computed on first use) */\nexport function mockModuleAccounts(): Record<string, string> {\n return {\n fee_collector: syntheticAddress(\"cosmos\", 1001),\n distribution: syntheticAddress(\"cosmos\", 1002),\n };\n}\n\n/**\n * Generates a synthetic transaction with realistic structure\n */\nfunction generateMockTx(height: number, txIndex: number): Uint8Array {\n const tx: Tx = {\n body: {\n messages: [\n {\n typeUrl: \"/cosmos.bank.v1beta1.MsgSend\",\n value: new Uint8Array([10, 45, 99, 111, 115, 109, 111, 115, 49, 18, 45, 99, 111, 115, 109, 111, 115, 50]),\n },\n ],\n memo: `Mock tx ${height}-${txIndex}`,\n timeoutHeight: BigInt(height + 100),\n extensionOptions: [],\n nonCriticalExtensionOptions: [],\n },\n authInfo: {\n signerInfos: [\n {\n publicKey: {\n typeUrl: \"/cosmos.crypto.secp256k1.PubKey\",\n value: new Uint8Array(33),\n },\n modeInfo: {\n single: {\n mode: 1,\n },\n },\n sequence: BigInt(txIndex),\n },\n ],\n fee: {\n amount: [\n {\n denom: \"uatom\",\n amount: \"5000\",\n },\n ],\n gasLimit: BigInt(200000),\n payer: \"\",\n granter: \"\",\n },\n tip: undefined,\n },\n signatures: [new Uint8Array(64)],\n };\n\n return Tx.encode(tx).finish();\n}\n\nexport class MockRpcClient {\n private chainId: string;\n private startHeight: number;\n private endHeight: number;\n private txPerBlock: number;\n private cometVersion: \"0.37\" | \"0.38\";\n private validatorCount: number;\n\n constructor({\n chainId,\n startHeight,\n endHeight,\n txPerBlock,\n cometVersion,\n validatorCount,\n }: MockRpcConfig) {\n this.chainId = chainId;\n this.startHeight = startHeight;\n this.endHeight = endHeight;\n this.txPerBlock = txPerBlock;\n this.cometVersion = cometVersion ?? \"0.37\";\n this.validatorCount = validatorCount ?? 3;\n }\n\n /** The synthetic validator set, identical at every height */\n validators(): Validator[] {\n const set: Validator[] = [];\n for (let i = 0; i < this.validatorCount; i++) {\n set.push(Validator.fromPartial({\n operatorAddress: syntheticAddress(\"cosmosvaloper\", i + 1),\n jailed: false,\n status: 3,\n tokens: String(1000000 * (i + 1)),\n delegatorShares: String(1000000 * (i + 1)) + \"000000000000000000\",\n description: {\n moniker: \"mock-validator-\" + (i + 1),\n },\n commission: {\n commissionRates: {\n rate: \"100000000000000000\",\n maxRate: \"200000000000000000\",\n maxChangeRate: \"10000000000000000\",\n },\n },\n minSelfDelegation: \"1\",\n }));\n }\n return set;\n }\n\n /**\n * Answers the ABCI queries the engine and the core modules issue. Unknown paths get a\n * non-zero code, as a real node would answer for a query it does not serve.\n */\n async abciQuery(params: AbciQueryParams): Promise<AbciQueryResponse> {\n const reply = (value: Uint8Array): AbciQueryResponse => ({\n key: new Uint8Array(),\n value,\n height: params.height,\n index: 0,\n code: 0,\n codespace: \"\",\n log: \"\",\n info: \"\",\n });\n switch (params.path) {\n case \"/cosmos.staking.v1beta1.Query/Validators\": {\n const request = QueryValidatorsRequest.decode(params.data);\n const all = this.validators();\n const limit = Number(request.pagination?.limit ?? 100n) || 100;\n const key = request.pagination?.key;\n const offset = key && key.length > 0 ? key[0] : 0;\n const page = all.slice(offset, offset + limit);\n const next = offset + limit < all.length ? new Uint8Array([offset + limit]) : new Uint8Array();\n return reply(QueryValidatorsResponse.encode(QueryValidatorsResponse.fromPartial({\n validators: page,\n pagination: {\n nextKey: next,\n total: BigInt(all.length),\n },\n })).finish());\n }\n case \"/cosmos.auth.v1beta1.Query/ModuleAccounts\":\n return reply(QueryModuleAccountsResponse.encode(QueryModuleAccountsResponse.fromPartial({\n accounts: Object.entries(mockModuleAccounts()).map(([name, address]) => ({\n typeUrl: \"/cosmos.auth.v1beta1.ModuleAccount\",\n value: ModuleAccount.encode(ModuleAccount.fromPartial({\n baseAccount: {\n address,\n },\n name,\n })).finish(),\n })),\n })).finish());\n case \"/cosmos.bank.v1beta1.Query/AllBalances\":\n return reply(QueryAllBalancesResponse.encode(QueryAllBalancesResponse.fromPartial({\n balances: [\n {\n denom: \"uatom\",\n amount: \"1000000\",\n },\n ],\n })).finish());\n case \"/cosmos.staking.v1beta1.Query/Pool\":\n return reply(QueryPoolResponse.encode(QueryPoolResponse.fromPartial({\n pool: {\n bondedTokens: String(this.validators().reduce((sum, v) => sum + Number(v.tokens), 0)),\n notBondedTokens: \"0\",\n },\n })).finish());\n case \"/cosmos.staking.v1beta1.Query/Params\":\n return reply(QueryStakingParamsResponse.encode(QueryStakingParamsResponse.fromPartial({\n params: {\n unbondingTime: {\n seconds: 1814400n,\n nanos: 0,\n },\n maxValidators: 100,\n maxEntries: 7,\n historicalEntries: 10000,\n bondDenom: \"uatom\",\n minCommissionRate: \"0\",\n },\n })).finish());\n case \"/cosmos.staking.v1beta1.Query/DelegatorDelegations\":\n return reply(QueryDelegatorDelegationsResponse.encode(QueryDelegatorDelegationsResponse.fromPartial({\n })).finish());\n case \"/cosmos.staking.v1beta1.Query/ValidatorDelegations\":\n return reply(QueryValidatorDelegationsResponse.encode(QueryValidatorDelegationsResponse.fromPartial({\n })).finish());\n default:\n return {\n ...reply(new Uint8Array()),\n code: 6,\n log: \"unknown request: \" + params.path,\n };\n }\n }\n\n async block(height: number): Promise<BlockResponse> {\n const txs: Uint8Array[] = [];\n for (let i = 0; i < this.txPerBlock; i++) {\n txs.push(generateMockTx(height, i));\n }\n // Deterministic, unique per height: the blocks table has a unique constraint on the hash\n const hashOf = (h: number) => new Uint8Array(createHash(\"sha256\").update(this.chainId + \":\" + h).digest());\n return {\n block: {\n header: {\n height: height,\n version: {\n block: 11,\n app: 0,\n },\n time: fromRfc3339WithNanoseconds(new Date().toISOString()),\n chainId: this.chainId,\n lastBlockId: null,\n lastCommitHash: new Uint8Array(),\n dataHash: new Uint8Array(),\n validatorsHash: new Uint8Array(),\n nextValidatorsHash: new Uint8Array(),\n consensusHash: new Uint8Array(),\n appHash: new Uint8Array(),\n lastResultsHash: new Uint8Array(),\n evidenceHash: new Uint8Array(),\n proposerAddress: new Uint8Array(),\n },\n txs: txs,\n evidence: [],\n lastCommit: {\n height: height - 1,\n round: 0,\n blockId: {\n hash: new Uint8Array(),\n parts: {\n total: 0,\n hash: new Uint8Array(),\n },\n },\n signatures: [\n {\n blockIdFlag: 2,\n validatorAddress: fromHex(\"D68EEC0D2E8248F1EC64CDB585EDB61ECA432BD8\"),\n timestamp: fromRfc3339WithNanoseconds(new Date().toISOString()),\n signature: fromBase64(\"Z6d2P35dI6qBzfPdyIZvmZi7Imo2FmQ5kNSnpVb2UvCj0aSjRCtS59BauJFB6FDHPluOUYoz0rJ4jiOnNXh9AA==\"),\n },\n ],\n },\n },\n blockId: {\n hash: hashOf(height),\n parts: {\n total: 0,\n hash: new Uint8Array(),\n },\n },\n };\n }\n\n async status(): Promise<StatusResponse> {\n return {\n nodeInfo: {\n protocolVersion: {\n p2p: 8,\n block: 11,\n app: 0,\n },\n id: fromHex(\"d2982128df6a29e700980f325b0444e301c604d7\"),\n listenAddr: \"tcp://0.0.0.0:26656\",\n network: this.chainId,\n version: this.cometVersion === \"0.38\" ? \"0.38.17\" : \"0.37.15\",\n channels: \"40202122233038606100\",\n moniker: \"node\",\n other: new Map([[\"txIndex\", \"on\"], [\"rpcAddress\", \"tcp://0.0.0.0:26657\"]]),\n },\n syncInfo: {\n latestBlockHash: fromHex(\"3F3F7A6F11FA91856BE440F8C78262307CAEAB122720D61CB14B118EF89892B5\"),\n latestAppHash: fromHex(\"FF91D618633BDD5395763F34805E6DACF6BBFB642A2E787677BF28B39427F289\"),\n latestBlockHeight: this.endHeight,\n latestBlockTime: fromRfc3339WithNanoseconds(\"2025-11-06T12:58:21.271608775Z\"),\n earliestBlockHash: fromHex(\"54473B6F28CAA85F5664F7CA3F2EEE49CD9857BDE41E0BF604B1A1DE93CBFEFF\"),\n earliestAppHash: fromHex(\"24DFB6C312A7FD4B753444F5CD5FAC4D239BAEC09B6A79BB3D04B21B0BC1FC53\"),\n earliestBlockHeight: 1,\n earliestBlockTime: fromRfc3339WithNanoseconds(\"2025-05-28T07:58:54.905470438Z\"),\n catchingUp: false,\n },\n validatorInfo: {\n address: fromHex(\"1C7CE0213D96CD5578249740DC31A9D8E4D7A226\"),\n pubkey: {\n algorithm: \"ed25519\",\n data: fromBase64(\"+KoTmCU6lo7NCtsfPCYpdNf0fs3aScZ8CtdgHTR/oGs=\"),\n },\n votingPower: 0n,\n },\n };\n }\n\n subscribeNewBlock() {\n return {\n addListener: (..._args: unknown[]) => {},\n removeListener: (..._args: unknown[]) => {},\n } as ReturnType<CometClient[\"subscribeNewBlock\"]>;\n }\n\n async disconnect(): Promise<void> {\n // No-op for mock\n }\n\n async blockResults(height: number): Promise<BlockResultsResponse | BlockResultsResponse38> {\n const attribute = (key: string, value: string) => ({\n key,\n value,\n });\n const feeCollector = mockModuleAccounts().fee_collector;\n // Events a real bank module emits for the transfer each mock tx performs\n const transferEvents = (msgIndex: number): Event38[] => [\n {\n type: \"message\",\n attributes: [attribute(\"action\", \"/cosmos.bank.v1beta1.MsgSend\"), attribute(\"msg_index\", String(msgIndex))],\n },\n {\n type: \"coin_spent\",\n attributes: [attribute(\"spender\", syntheticAddress(\"cosmos\", 1)), attribute(\"amount\", \"10uatom\"), attribute(\"msg_index\", String(msgIndex))],\n },\n {\n type: \"coin_received\",\n attributes: [attribute(\"receiver\", syntheticAddress(\"cosmos\", 2)), attribute(\"amount\", \"10uatom\"), attribute(\"msg_index\", String(msgIndex))],\n },\n ];\n const results: TxData[] = [];\n for (let i = 0; i < this.txPerBlock; i++) {\n results.push({\n code: 0,\n data: Buffer.from(\"success\"),\n // CometBFT 0.37 nodes return the structured log; 0.38 nodes return an empty log and\n // events tagged with msg_index instead\n log: this.cometVersion === \"0.38\"\n ? \"\"\n : JSON.stringify([\n {\n msg_index: 0,\n events: transferEvents(0),\n },\n ]),\n gasWanted: BigInt(200000),\n gasUsed: BigInt(150000),\n // The 0.37 and 0.38 event types are structurally identical\n events: transferEvents(0) as unknown as TxData[\"events\"],\n codespace: \"\",\n });\n }\n // Block-level flows: the fee collector receives the mint at the start of the block\n const beginBlockEvents: Event38[] = [\n {\n type: \"coin_received\",\n attributes: [attribute(\"receiver\", feeCollector), attribute(\"amount\", \"50uatom\")],\n },\n ];\n const endBlockEvents: Event38[] = [\n {\n type: \"coin_spent\",\n attributes: [attribute(\"spender\", feeCollector), attribute(\"amount\", \"5uatom\")],\n },\n ];\n if (this.cometVersion === \"0.38\") {\n // Cosmos SDK 0.50+ delivers both phases in one list, tagged with mode=BeginBlock / EndBlock\n const tagged = (events: Event38[], mode: string) => events.map(event => ({\n type: event.type,\n attributes: [...event.attributes, attribute(\"mode\", mode)],\n }));\n return {\n height,\n results,\n finalizeBlockEvents: [...tagged(beginBlockEvents, \"BeginBlock\"), ...tagged(endBlockEvents, \"EndBlock\")],\n validatorUpdates: [],\n consensusUpdates: undefined,\n } as unknown as BlockResultsResponse38;\n }\n return {\n height,\n results,\n beginBlockEvents,\n endBlockEvents,\n validatorUpdates: [],\n consensusUpdates: undefined,\n } as unknown as BlockResultsResponse;\n }\n\n async connect(): Promise<void> {\n }\n}\n\n/**\n * Factory function to create a mock RPC client\n */\nexport function createMockRpcClient(config: MockRpcConfig): CometClient {\n return new MockRpcClient(config) as unknown as CometClient;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiEA,SAAgB,iBAAiB,QAAgB,MAAsB;CACrE,MAAM,QAAQ,IAAI,WAAW,GAAG;AAChC,OAAM,KAAK,O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O;GAEvB,QAAQ,eAAe,EAAE;GACzB,WAAW;GACZ,CAAC;EAGJ,MAAMC,mBAA8B,CAClC;GACE,MAAM;GACN,YAAY,CAAC,UAAU,YAAY,aAAa,EAAE,UAAU,UAAU,UAAU,CAAC;GAClF,CACF;EACD,MAAMC,iBAA4B,CAChC;GACE,MAAM;GACN,YAAY,CAAC,UAAU,WAAW,aAAa,EAAE,UAAU,UAAU,SAAS,CAAC;GAChF,CACF;AACD,MAAI,KAAK,iBAAiB,QAAQ;GAEhC,MAAM,UAAU,QAAmB,SAAiB,OAAO,KAAI,WAAU;IACvE,MAAM,MAAM;IACZ,YAAY,CAAC,GAAG,MAAM,YAAY,UAAU,QAAQ,KAAK,CAAC;IAC3D,EAAE;AACH,UAAO;IACL;IACA;IACA,qBAAqB,CAAC,GAAG,OAAO,kBAAkB,aAAa,EAAE,GAAG,OAAO,gBAAgB,WAAW,CAAC;IACvG,kBAAkB,EAAE;IACpB,kBAAkB;IACnB;;AAEH,SAAO;GACL;GACA;GACA;GACA;GACA,kBAAkB,EAAE;GACpB,kBAAkB;GACnB;;CAGH,MAAM,UAAyB;;;;;AAOjC,SAAgB,oBAAoB,QAAoC;AACtE,QAAO,IAAI,cAAc,OAAO"}
@@ -1,10 +1,7 @@
1
1
 
2
2
  //#region src/promise-queue/index.ts
3
3
  /**
4
- * Implements an "infinite" FIFO queue of fixed size using promises
5
- * - await `continue()` before enqueing items to ensure fixed size (resolves when space available)
6
- * - await `dequeue()` to pop an item (resolves when next item is available)
7
- * - size() is always at minimum 1 item which is the promise for the next enqueued item
4
+ * @deprecated Not used by the engine; CircularBuffer is the block queue. Kept for compatibility, removed in 3.0.
8
5
  */
9
6
  var PromiseQueue = class {
10
7
  /** Optional error handler for enqueue failures */
@@ -120,6 +117,14 @@ var CircularBuffer = class {
120
117
  this.batcher(true);
121
118
  }
122
119
  enqueue(item) {
120
+ if (this.count >= this.batchSize) {
121
+ const error = /* @__PURE__ */ new Error("CircularBuffer is full (" + this.batchSize + " slots); await continue() before enqueueing");
122
+ if (this.errorHandler) {
123
+ this.errorHandler(error);
124
+ return;
125
+ }
126
+ throw error;
127
+ }
123
128
  try {
124
129
  this.enqueuer(item);
125
130
  const nextVal = new Promise((resolve, _reject) => {
@@ -137,6 +142,7 @@ var CircularBuffer = class {
137
142
  }
138
143
  }
139
144
  dequeue() {
145
+ if (this.count <= 0) throw new Error("CircularBuffer is empty; the previous dequeue() has not been fulfilled yet");
140
146
  const item = this.items[this.next];
141
147
  this.next++;
142
148
  this.count--;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/promise-queue/index.ts"],"sourcesContent":["/**\n * Implements an \"infinite\" FIFO queue of fixed size using promises\n * - await `continue()` before enqueing items to ensure fixed size (resolves when space available)\n * - await `dequeue()` to pop an item (resolves when next item is available)\n * - size() is always at minimum 1 item which is the promise for the next enqueued item\n */\nexport class PromiseQueue<T> {\n /** Optional error handler for enqueue failures */\n private errorHandler?: (error: unknown) => void;\n /** Array of promises representing queued items */\n private items: Array<Promise<T>>;\n\n /** Function to resolve the next enqueued promise */\n private enqueuer!: (val: T | PromiseLike<T>) => void;\n\n /** Function to resolve the continue promise when space is available */\n private batcher!: (val: boolean) => void;\n\n /** Flag indicating if the queue is synced with the data source */\n public synced = false;\n\n /** Maximum number of items to keep in the queue */\n private batchSize: number;\n\n /** Promise that resolves when it's safe to enqueue more items */\n private continuePromise: Promise<boolean>;\n\n constructor(batchSize: number, errorHandler?: (error: unknown) => void) {\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.batchSize = batchSize;\n this.errorHandler = errorHandler;\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n this.items = [nextVal];\n }\n\n enqueue(item: T | PromiseLike<T>) {\n try {\n this.enqueuer(item);\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items.push(nextVal);\n if (this.size() > this.batchSize) {\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n }\n }\n catch (e) {\n if (this.errorHandler) {\n this.errorHandler(e);\n }\n // If no error handler provided, silently ignore (existing behavior for backward compatibility)\n }\n }\n\n clear() {\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n this.items = [nextVal];\n }\n\n dequeue() {\n const item = this.items.shift();\n if (this.size() <= this.batchSize) {\n this.batcher(true);\n }\n\n return item as Promise<T>;\n }\n\n continue() {\n return this.continuePromise;\n }\n\n setSynced() {\n this.synced = true;\n }\n\n isEmpty() {\n if (this.items.length == 0) {\n return true;\n }\n else {\n return false;\n }\n }\n\n size() {\n return this.items.length;\n }\n}\n\n/**\n * Circular buffer implementation using promises for efficient memory usage\n * Reuses array slots in a circular fashion to maintain constant memory footprint\n * Used by the indexer for managing block processing queues\n */\nexport class CircularBuffer<T> {\n /** Optional error handler for enqueue failures */\n private errorHandler?: (error: unknown) => void;\n\n /** Fixed-size array of promises representing buffered items */\n private items: Array<Promise<T>>;\n\n /** Function to resolve the next enqueued promise */\n private enqueuer!: (val: T | PromiseLike<T>) => void;\n\n /** Current number of items in the buffer */\n private count: number = 0;\n\n /** Index of the next item to dequeue */\n private next: number = 0;\n\n /** Function to resolve the continue promise when space is available */\n private batcher!: (val: boolean) => void;\n\n /** Flag indicating if the buffer is synced with the data source */\n public synced = false;\n\n /** Maximum number of items the buffer can hold */\n private batchSize: number;\n\n /** Promise that resolves when it's safe to enqueue more items */\n private continuePromise: Promise<boolean>;\n\n /** Index of the next available slot for enqueueing */\n private nextAvail: number = 0;\n\n constructor(batchSize: number, errorHandler?: (error: unknown) => void) {\n if (batchSize <= 1) {\n throw new Error(\"Batch size must be greater than 1\");\n }\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items = new Array<Promise<T>>(batchSize);\n this.batchSize = batchSize;\n this.errorHandler = errorHandler;\n this.items[this.nextAvail] = nextVal;\n this.count = 1;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n }\n\n enqueue(item: T | PromiseLike<T>) {\n try {\n this.enqueuer(item);\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items[this.nextAvail] = nextVal;\n this.count++;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n if (this.nextAvail == this.next) {\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n }\n }\n catch (e) {\n if (this.errorHandler) {\n this.errorHandler(e);\n }\n // If no error handler provided, silently ignore (existing behavior for backward compatibility)\n }\n }\n\n dequeue() {\n const item = this.items[this.next];\n this.next++;\n this.count--;\n if (this.next >= this.batchSize) {\n this.next = 0;\n }\n if (this.count <= this.batchSize) {\n this.batcher(true);\n }\n return item;\n }\n\n clear() {\n this.next = 0;\n this.nextAvail = 0;\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items = new Array<Promise<T>>(this.batchSize);\n this.items[this.nextAvail] = nextVal;\n this.synced = false;\n this.count = 1;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n }\n\n continue() {\n return this.continuePromise;\n }\n\n setSynced() {\n this.synced = true;\n }\n\n isEmpty() {\n if (this.count == 0) {\n return true;\n }\n else {\n return false;\n }\n }\n\n size() {\n return this.count;\n }\n}\n"],"mappings":";;;;;;;;AAMA,IAAa,eAAb,MAA6B;;CAE3B,AAAQ;;CAER,AAAQ;;CAGR,AAAQ;;CAGR,AAAQ;;CAGR,A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,MAAM,KAAK,aAAa;AAC7B,OAAK,SAAS;AACd,OAAK,QAAQ;AACb,OAAK;AACL,MAAI,KAAK,aAAa,KAAK,UACzB,MAAK,YAAY;AAGnB,OAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY;AAChE,QAAK,UAAU;IACf;AACF,OAAK,QAAQ,KAAK;;CAGpB,WAAW;AACT,SAAO,KAAK;;CAGd,YAAY;AACV,OAAK,SAAS;;CAGhB,UAAU;AACR,MAAI,KAAK,SAAS,EAChB,QAAO;MAGP,QAAO;;CAIX,OAAO;AACL,SAAO,KAAK"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/promise-queue/index.ts"],"sourcesContent":["/**\n * @deprecated Not used by the engine; CircularBuffer is the block queue. Kept for compatibility, removed in 3.0.\n */\nexport class PromiseQueue<T> {\n /** Optional error handler for enqueue failures */\n private errorHandler?: (error: unknown) => void;\n /** Array of promises representing queued items */\n private items: Array<Promise<T>>;\n\n /** Function to resolve the next enqueued promise */\n private enqueuer!: (val: T | PromiseLike<T>) => void;\n\n /** Function to resolve the continue promise when space is available */\n private batcher!: (val: boolean) => void;\n\n /** Flag indicating if the queue is synced with the data source */\n public synced = false;\n\n /** Maximum number of items to keep in the queue */\n private batchSize: number;\n\n /** Promise that resolves when it's safe to enqueue more items */\n private continuePromise: Promise<boolean>;\n\n constructor(batchSize: number, errorHandler?: (error: unknown) => void) {\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.batchSize = batchSize;\n this.errorHandler = errorHandler;\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n this.items = [nextVal];\n }\n\n enqueue(item: T | PromiseLike<T>) {\n try {\n this.enqueuer(item);\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items.push(nextVal);\n if (this.size() > this.batchSize) {\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n }\n }\n catch (e) {\n if (this.errorHandler) {\n this.errorHandler(e);\n }\n // If no error handler provided, silently ignore (existing behavior for backward compatibility)\n }\n }\n\n clear() {\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n this.items = [nextVal];\n }\n\n dequeue() {\n const item = this.items.shift();\n if (this.size() <= this.batchSize) {\n this.batcher(true);\n }\n\n return item as Promise<T>;\n }\n\n continue() {\n return this.continuePromise;\n }\n\n setSynced() {\n this.synced = true;\n }\n\n isEmpty() {\n if (this.items.length == 0) {\n return true;\n }\n else {\n return false;\n }\n }\n\n size() {\n return this.items.length;\n }\n}\n\n/**\n * Circular buffer implementation using promises for efficient memory usage\n * Reuses array slots in a circular fashion to maintain constant memory footprint\n * Used by the indexer for managing block processing queues\n */\nexport class CircularBuffer<T> {\n /** Optional error handler for enqueue failures */\n private errorHandler?: (error: unknown) => void;\n\n /** Fixed-size array of promises representing buffered items */\n private items: Array<Promise<T>>;\n\n /** Function to resolve the next enqueued promise */\n private enqueuer!: (val: T | PromiseLike<T>) => void;\n\n /** Current number of items in the buffer */\n private count: number = 0;\n\n /** Index of the next item to dequeue */\n private next: number = 0;\n\n /** Function to resolve the continue promise when space is available */\n private batcher!: (val: boolean) => void;\n\n /** Flag indicating if the buffer is synced with the data source */\n public synced = false;\n\n /** Maximum number of items the buffer can hold */\n private batchSize: number;\n\n /** Promise that resolves when it's safe to enqueue more items */\n private continuePromise: Promise<boolean>;\n\n /** Index of the next available slot for enqueueing */\n private nextAvail: number = 0;\n\n constructor(batchSize: number, errorHandler?: (error: unknown) => void) {\n if (batchSize <= 1) {\n throw new Error(\"Batch size must be greater than 1\");\n }\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items = new Array<Promise<T>>(batchSize);\n this.batchSize = batchSize;\n this.errorHandler = errorHandler;\n this.items[this.nextAvail] = nextVal;\n this.count = 1;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n }\n\n enqueue(item: T | PromiseLike<T>) {\n if (this.count >= this.batchSize) {\n // Overwriting would silently drop the oldest unprocessed block; callers must await continue()\n const error = new Error(\"CircularBuffer is full (\" + this.batchSize + \" slots); await continue() before enqueueing\");\n if (this.errorHandler) {\n this.errorHandler(error);\n return;\n }\n throw error;\n }\n try {\n this.enqueuer(item);\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items[this.nextAvail] = nextVal;\n this.count++;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n if (this.nextAvail == this.next) {\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n }\n }\n catch (e) {\n if (this.errorHandler) {\n this.errorHandler(e);\n }\n // If no error handler provided, silently ignore (existing behavior for backward compatibility)\n }\n }\n\n dequeue() {\n if (this.count <= 0) {\n // The only pending slot (the sentinel) has already been handed out\n throw new Error(\"CircularBuffer is empty; the previous dequeue() has not been fulfilled yet\");\n }\n const item = this.items[this.next];\n this.next++;\n this.count--;\n if (this.next >= this.batchSize) {\n this.next = 0;\n }\n if (this.count <= this.batchSize) {\n this.batcher(true);\n }\n return item;\n }\n\n clear() {\n this.next = 0;\n this.nextAvail = 0;\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items = new Array<Promise<T>>(this.batchSize);\n this.items[this.nextAvail] = nextVal;\n this.synced = false;\n this.count = 1;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n }\n\n continue() {\n return this.continuePromise;\n }\n\n setSynced() {\n this.synced =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;CAM1B,UAAU;AACR,MAAI,KAAK,SAAS,EAEhB,OAAM,IAAI,MAAM,6EAA6E;EAE/F,MAAM,OAAO,KAAK,MAAM,KAAK;AAC7B,OAAK;AACL,OAAK;AACL,MAAI,KAAK,QAAQ,KAAK,UACpB,MAAK,OAAO;AAEd,MAAI,KAAK,SAAS,KAAK,UACrB,MAAK,QAAQ,KAAK;AAEpB,SAAO;;CAGT,QAAQ;AACN,OAAK,OAAO;AACZ,OAAK,YAAY;EACjB,MAAM,UAAU,IAAI,SAAY,SAAS,YAAY;AACnD,QAAK,WAAW;IAChB;AACF,OAAK,QAAQ,IAAI,MAAkB,KAAK,UAAU;AAClD,OAAK,MAAM,KAAK,aAAa;AAC7B,OAAK,SAAS;AACd,OAAK,QAAQ;AACb,OAAK;AACL,MAAI,KAAK,aAAa,KAAK,UACzB,MAAK,YAAY;AAGnB,OAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY;AAChE,QAAK,UAAU;IACf;AACF,OAAK,QAAQ,KAAK;;CAGpB,WAAW;AACT,SAAO,KAAK;;CAGd,YAAY;AACV,OAAK,SAAS;;CAGhB,UAAU;AACR,MAAI,KAAK,SAAS,EAChB,QAAO;MAGP,QAAO;;CAIX,OAAO;AACL,SAAO,KAAK"}
@@ -1,9 +1,6 @@
1
1
  //#region src/promise-queue/index.d.ts
2
2
  /**
3
- * Implements an "infinite" FIFO queue of fixed size using promises
4
- * - await `continue()` before enqueing items to ensure fixed size (resolves when space available)
5
- * - await `dequeue()` to pop an item (resolves when next item is available)
6
- * - size() is always at minimum 1 item which is the promise for the next enqueued item
3
+ * @deprecated Not used by the engine; CircularBuffer is the block queue. Kept for compatibility, removed in 3.0.
7
4
  */
8
5
  declare class PromiseQueue<T> {
9
6
  /** Optional error handler for enqueue failures */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/promise-queue/index.ts"],"sourcesContent":[],"mappings":";;AAMA;;;;;AAwEmB,cAxEN,YAwEM,CAAA,CAAA,CAAA,CAAA;EAGT;EAAA,QAAA,YAAA;EA2BG;EAsDG,QAAA,KAAA;EAAgB;EAAZ,QAAA,QAAA;EA2BX;EAAA,QAAA,OAAA;EAkCC;EAAA,MAAA,EAAA,OAAA;;;;;;gBAvLM,IAAI,YAAY;;aAsCb,QAAQ;cAGjB;;;;;;;;;;cA2BG;;;;;;;;;;;;;;;;;;;;;;gBAsDG,IAAI,YAAY;aA2BvB,QAAA;;cAkCC"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/promise-queue/index.ts"],"sourcesContent":[],"mappings":";;AAGA;;AAkCgC,cAlCnB,YAkCmB,CAAA,CAAA,CAAA,CAAA;EAAZ;EAsCO,QAAA,YAAA;EAAR;EAGT,QAAA,KAAA;EAAA;EA2BG,QAAA,QAAA;EAsDG;EAAgB,QAAA,OAAA;EAAZ;EAoCX,MAAA,EAAA,OAAA;EAAA;EAsCC,QAAA,SAAA;EAAA;;;gBApMM,IAAI,YAAY;;aAsCb,QAAQ;cAGjB;;;;;;;;;;cA2BG;;;;;;;;;;;;;;;;;;;;;;gBAsDG,IAAI,YAAY;aAoCvB,QAAA;;cAsCC"}
@@ -1,9 +1,6 @@
1
1
  //#region src/promise-queue/index.d.ts
2
2
  /**
3
- * Implements an "infinite" FIFO queue of fixed size using promises
4
- * - await `continue()` before enqueing items to ensure fixed size (resolves when space available)
5
- * - await `dequeue()` to pop an item (resolves when next item is available)
6
- * - size() is always at minimum 1 item which is the promise for the next enqueued item
3
+ * @deprecated Not used by the engine; CircularBuffer is the block queue. Kept for compatibility, removed in 3.0.
7
4
  */
8
5
  declare class PromiseQueue<T> {
9
6
  /** Optional error handler for enqueue failures */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/promise-queue/index.ts"],"sourcesContent":[],"mappings":";;AAMA;;;;;AAwEmB,cAxEN,YAwEM,CAAA,CAAA,CAAA,CAAA;EAGT;EAAA,QAAA,YAAA;EA2BG;EAsDG,QAAA,KAAA;EAAgB;EAAZ,QAAA,QAAA;EA2BX;EAAA,QAAA,OAAA;EAkCC;EAAA,MAAA,EAAA,OAAA;;;;;;gBAvLM,IAAI,YAAY;;aAsCb,QAAQ;cAGjB;;;;;;;;;;cA2BG;;;;;;;;;;;;;;;;;;;;;;gBAsDG,IAAI,YAAY;aA2BvB,QAAA;;cAkCC"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/promise-queue/index.ts"],"sourcesContent":[],"mappings":";;AAGA;;AAkCgC,cAlCnB,YAkCmB,CAAA,CAAA,CAAA,CAAA;EAAZ;EAsCO,QAAA,YAAA;EAAR;EAGT,QAAA,KAAA;EAAA;EA2BG,QAAA,QAAA;EAsDG;EAAgB,QAAA,OAAA;EAAZ;EAoCX,MAAA,EAAA,OAAA;EAAA;EAsCC,QAAA,SAAA;EAAA;;;gBApMM,IAAI,YAAY;;aAsCb,QAAQ;cAGjB;;;;;;;;;;cA2BG;;;;;;;;;;;;;;;;;;;;;;gBAsDG,IAAI,YAAY;aAoCvB,QAAA;;cAsCC"}
@@ -1,9 +1,6 @@
1
1
  //#region src/promise-queue/index.ts
2
2
  /**
3
- * Implements an "infinite" FIFO queue of fixed size using promises
4
- * - await `continue()` before enqueing items to ensure fixed size (resolves when space available)
5
- * - await `dequeue()` to pop an item (resolves when next item is available)
6
- * - size() is always at minimum 1 item which is the promise for the next enqueued item
3
+ * @deprecated Not used by the engine; CircularBuffer is the block queue. Kept for compatibility, removed in 3.0.
7
4
  */
8
5
  var PromiseQueue = class {
9
6
  /** Optional error handler for enqueue failures */
@@ -119,6 +116,14 @@ var CircularBuffer = class {
119
116
  this.batcher(true);
120
117
  }
121
118
  enqueue(item) {
119
+ if (this.count >= this.batchSize) {
120
+ const error = /* @__PURE__ */ new Error("CircularBuffer is full (" + this.batchSize + " slots); await continue() before enqueueing");
121
+ if (this.errorHandler) {
122
+ this.errorHandler(error);
123
+ return;
124
+ }
125
+ throw error;
126
+ }
122
127
  try {
123
128
  this.enqueuer(item);
124
129
  const nextVal = new Promise((resolve, _reject) => {
@@ -136,6 +141,7 @@ var CircularBuffer = class {
136
141
  }
137
142
  }
138
143
  dequeue() {
144
+ if (this.count <= 0) throw new Error("CircularBuffer is empty; the previous dequeue() has not been fulfilled yet");
139
145
  const item = this.items[this.next];
140
146
  this.next++;
141
147
  this.count--;
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/promise-queue/index.ts"],"sourcesContent":["/**\n * Implements an \"infinite\" FIFO queue of fixed size using promises\n * - await `continue()` before enqueing items to ensure fixed size (resolves when space available)\n * - await `dequeue()` to pop an item (resolves when next item is available)\n * - size() is always at minimum 1 item which is the promise for the next enqueued item\n */\nexport class PromiseQueue<T> {\n /** Optional error handler for enqueue failures */\n private errorHandler?: (error: unknown) => void;\n /** Array of promises representing queued items */\n private items: Array<Promise<T>>;\n\n /** Function to resolve the next enqueued promise */\n private enqueuer!: (val: T | PromiseLike<T>) => void;\n\n /** Function to resolve the continue promise when space is available */\n private batcher!: (val: boolean) => void;\n\n /** Flag indicating if the queue is synced with the data source */\n public synced = false;\n\n /** Maximum number of items to keep in the queue */\n private batchSize: number;\n\n /** Promise that resolves when it's safe to enqueue more items */\n private continuePromise: Promise<boolean>;\n\n constructor(batchSize: number, errorHandler?: (error: unknown) => void) {\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.batchSize = batchSize;\n this.errorHandler = errorHandler;\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n this.items = [nextVal];\n }\n\n enqueue(item: T | PromiseLike<T>) {\n try {\n this.enqueuer(item);\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items.push(nextVal);\n if (this.size() > this.batchSize) {\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n }\n }\n catch (e) {\n if (this.errorHandler) {\n this.errorHandler(e);\n }\n // If no error handler provided, silently ignore (existing behavior for backward compatibility)\n }\n }\n\n clear() {\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n this.items = [nextVal];\n }\n\n dequeue() {\n const item = this.items.shift();\n if (this.size() <= this.batchSize) {\n this.batcher(true);\n }\n\n return item as Promise<T>;\n }\n\n continue() {\n return this.continuePromise;\n }\n\n setSynced() {\n this.synced = true;\n }\n\n isEmpty() {\n if (this.items.length == 0) {\n return true;\n }\n else {\n return false;\n }\n }\n\n size() {\n return this.items.length;\n }\n}\n\n/**\n * Circular buffer implementation using promises for efficient memory usage\n * Reuses array slots in a circular fashion to maintain constant memory footprint\n * Used by the indexer for managing block processing queues\n */\nexport class CircularBuffer<T> {\n /** Optional error handler for enqueue failures */\n private errorHandler?: (error: unknown) => void;\n\n /** Fixed-size array of promises representing buffered items */\n private items: Array<Promise<T>>;\n\n /** Function to resolve the next enqueued promise */\n private enqueuer!: (val: T | PromiseLike<T>) => void;\n\n /** Current number of items in the buffer */\n private count: number = 0;\n\n /** Index of the next item to dequeue */\n private next: number = 0;\n\n /** Function to resolve the continue promise when space is available */\n private batcher!: (val: boolean) => void;\n\n /** Flag indicating if the buffer is synced with the data source */\n public synced = false;\n\n /** Maximum number of items the buffer can hold */\n private batchSize: number;\n\n /** Promise that resolves when it's safe to enqueue more items */\n private continuePromise: Promise<boolean>;\n\n /** Index of the next available slot for enqueueing */\n private nextAvail: number = 0;\n\n constructor(batchSize: number, errorHandler?: (error: unknown) => void) {\n if (batchSize <= 1) {\n throw new Error(\"Batch size must be greater than 1\");\n }\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items = new Array<Promise<T>>(batchSize);\n this.batchSize = batchSize;\n this.errorHandler = errorHandler;\n this.items[this.nextAvail] = nextVal;\n this.count = 1;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n }\n\n enqueue(item: T | PromiseLike<T>) {\n try {\n this.enqueuer(item);\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items[this.nextAvail] = nextVal;\n this.count++;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n if (this.nextAvail == this.next) {\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n }\n }\n catch (e) {\n if (this.errorHandler) {\n this.errorHandler(e);\n }\n // If no error handler provided, silently ignore (existing behavior for backward compatibility)\n }\n }\n\n dequeue() {\n const item = this.items[this.next];\n this.next++;\n this.count--;\n if (this.next >= this.batchSize) {\n this.next = 0;\n }\n if (this.count <= this.batchSize) {\n this.batcher(true);\n }\n return item;\n }\n\n clear() {\n this.next = 0;\n this.nextAvail = 0;\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items = new Array<Promise<T>>(this.batchSize);\n this.items[this.nextAvail] = nextVal;\n this.synced = false;\n this.count = 1;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n }\n\n continue() {\n return this.continuePromise;\n }\n\n setSynced() {\n this.synced = true;\n }\n\n isEmpty() {\n if (this.count == 0) {\n return true;\n }\n else {\n return false;\n }\n }\n\n size() {\n return this.count;\n }\n}\n"],"mappings":";;;;;;;AAMA,IAAa,eAAb,MAA6B;;CAE3B,AAAQ;;CAER,AAAQ;;CAGR,AAAQ;;CAGR,AAAQ;;CAGR,AAAO,SAAS;;CAGhB,AAAQ;;CAGR,AAAQ;CAER,YAAY,WAAmB,cAAyC;EACtE,MAAM,UAAU,IAAI,SAAY,SAAS,YAAY;AAC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AY;AAGnB,OAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY;AAChE,QAAK,UAAU;IACf;AACF,OAAK,QAAQ,KAAK;;CAGpB,WAAW;AACT,SAAO,KAAK;;CAGd,YAAY;AACV,OAAK,SAAS;;CAGhB,UAAU;AACR,MAAI,KAAK,SAAS,EAChB,QAAO;MAGP,QAAO;;CAIX,OAAO;AACL,SAAO,KAAK"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/promise-queue/index.ts"],"sourcesContent":["/**\n * @deprecated Not used by the engine; CircularBuffer is the block queue. Kept for compatibility, removed in 3.0.\n */\nexport class PromiseQueue<T> {\n /** Optional error handler for enqueue failures */\n private errorHandler?: (error: unknown) => void;\n /** Array of promises representing queued items */\n private items: Array<Promise<T>>;\n\n /** Function to resolve the next enqueued promise */\n private enqueuer!: (val: T | PromiseLike<T>) => void;\n\n /** Function to resolve the continue promise when space is available */\n private batcher!: (val: boolean) => void;\n\n /** Flag indicating if the queue is synced with the data source */\n public synced = false;\n\n /** Maximum number of items to keep in the queue */\n private batchSize: number;\n\n /** Promise that resolves when it's safe to enqueue more items */\n private continuePromise: Promise<boolean>;\n\n constructor(batchSize: number, errorHandler?: (error: unknown) => void) {\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.batchSize = batchSize;\n this.errorHandler = errorHandler;\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n this.items = [nextVal];\n }\n\n enqueue(item: T | PromiseLike<T>) {\n try {\n this.enqueuer(item);\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items.push(nextVal);\n if (this.size() > this.batchSize) {\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n }\n }\n catch (e) {\n if (this.errorHandler) {\n this.errorHandler(e);\n }\n // If no error handler provided, silently ignore (existing behavior for backward compatibility)\n }\n }\n\n clear() {\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n this.items = [nextVal];\n }\n\n dequeue() {\n const item = this.items.shift();\n if (this.size() <= this.batchSize) {\n this.batcher(true);\n }\n\n return item as Promise<T>;\n }\n\n continue() {\n return this.continuePromise;\n }\n\n setSynced() {\n this.synced = true;\n }\n\n isEmpty() {\n if (this.items.length == 0) {\n return true;\n }\n else {\n return false;\n }\n }\n\n size() {\n return this.items.length;\n }\n}\n\n/**\n * Circular buffer implementation using promises for efficient memory usage\n * Reuses array slots in a circular fashion to maintain constant memory footprint\n * Used by the indexer for managing block processing queues\n */\nexport class CircularBuffer<T> {\n /** Optional error handler for enqueue failures */\n private errorHandler?: (error: unknown) => void;\n\n /** Fixed-size array of promises representing buffered items */\n private items: Array<Promise<T>>;\n\n /** Function to resolve the next enqueued promise */\n private enqueuer!: (val: T | PromiseLike<T>) => void;\n\n /** Current number of items in the buffer */\n private count: number = 0;\n\n /** Index of the next item to dequeue */\n private next: number = 0;\n\n /** Function to resolve the continue promise when space is available */\n private batcher!: (val: boolean) => void;\n\n /** Flag indicating if the buffer is synced with the data source */\n public synced = false;\n\n /** Maximum number of items the buffer can hold */\n private batchSize: number;\n\n /** Promise that resolves when it's safe to enqueue more items */\n private continuePromise: Promise<boolean>;\n\n /** Index of the next available slot for enqueueing */\n private nextAvail: number = 0;\n\n constructor(batchSize: number, errorHandler?: (error: unknown) => void) {\n if (batchSize <= 1) {\n throw new Error(\"Batch size must be greater than 1\");\n }\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items = new Array<Promise<T>>(batchSize);\n this.batchSize = batchSize;\n this.errorHandler = errorHandler;\n this.items[this.nextAvail] = nextVal;\n this.count = 1;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n }\n\n enqueue(item: T | PromiseLike<T>) {\n if (this.count >= this.batchSize) {\n // Overwriting would silently drop the oldest unprocessed block; callers must await continue()\n const error = new Error(\"CircularBuffer is full (\" + this.batchSize + \" slots); await continue() before enqueueing\");\n if (this.errorHandler) {\n this.errorHandler(error);\n return;\n }\n throw error;\n }\n try {\n this.enqueuer(item);\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items[this.nextAvail] = nextVal;\n this.count++;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n if (this.nextAvail == this.next) {\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n }\n }\n catch (e) {\n if (this.errorHandler) {\n this.errorHandler(e);\n }\n // If no error handler provided, silently ignore (existing behavior for backward compatibility)\n }\n }\n\n dequeue() {\n if (this.count <= 0) {\n // The only pending slot (the sentinel) has already been handed out\n throw new Error(\"CircularBuffer is empty; the previous dequeue() has not been fulfilled yet\");\n }\n const item = this.items[this.next];\n this.next++;\n this.count--;\n if (this.next >= this.batchSize) {\n this.next = 0;\n }\n if (this.count <= this.batchSize) {\n this.batcher(true);\n }\n return item;\n }\n\n clear() {\n this.next = 0;\n this.nextAvail = 0;\n const nextVal = new Promise<T>((resolve, _reject) => {\n this.enqueuer = resolve;\n });\n this.items = new Array<Promise<T>>(this.batchSize);\n this.items[this.nextAvail] = nextVal;\n this.synced = false;\n this.count = 1;\n this.nextAvail++;\n if (this.nextAvail >= this.batchSize) {\n this.nextAvail = 0;\n }\n\n this.continuePromise = new Promise<boolean>((resolve, _reject) => {\n this.batcher = resolve;\n });\n this.batcher(true);\n }\n\n continue() {\n return this.continuePromise;\n }\n\n setSynced() {\n this.synced = true;\n }\n\n isEmpty() {\n if (this.count == 0) {\n return true;\n }\n else {\n return false;\n }\n }\n\n size() {\n return this.count;\n }\n}\n"],"mappings":";;;;AAGA,IAA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7B,OAAK;AACL,OAAK;AACL,MAAI,KAAK,QAAQ,KAAK,UACpB,MAAK,OAAO;AAEd,MAAI,KAAK,SAAS,KAAK,UACrB,MAAK,QAAQ,KAAK;AAEpB,SAAO;;CAGT,QAAQ;AACN,OAAK,OAAO;AACZ,OAAK,YAAY;EACjB,MAAM,UAAU,IAAI,SAAY,SAAS,YAAY;AACnD,QAAK,WAAW;IAChB;AACF,OAAK,QAAQ,IAAI,MAAkB,KAAK,UAAU;AAClD,OAAK,MAAM,KAAK,aAAa;AAC7B,OAAK,SAAS;AACd,OAAK,QAAQ;AACb,OAAK;AACL,MAAI,KAAK,aAAa,KAAK,UACzB,MAAK,YAAY;AAGnB,OAAK,kBAAkB,IAAI,SAAkB,SAAS,YAAY;AAChE,QAAK,UAAU;IACf;AACF,OAAK,QAAQ,KAAK;;CAGpB,WAAW;AACT,SAAO,KAAK;;CAGd,YAAY;AACV,OAAK,SAAS;;CAGhB,UAAU;AACR,MAAI,KAAK,SAAS,EAChB,QAAO;MAGP,QAAO;;CAIX,OAAO;AACL,SAAO,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["/* eslint-disable @stylistic/no-multi-spaces */\nimport {\n BlockResponse, BlockResultsResponse,\n} from \"@cosmjs/tendermint-rpc\";\nimport {\n BlockResultsResponse as BlockResultsResponse38, Event,\n} from \"@cosmjs/tendermint-rpc/build/comet38/responses\";\nimport {\n Validator,\n} from \"cosmjs-types/cosmos/staking/v1beta1/staking\";\nimport {\n TxBody,\n} from \"cosmjs-types/cosmos/tx/v1beta1/tx\";\n\nimport {\n EcleciaIndexer,\n} from \"../indexer\";\nimport {\n CircularBuffer,\n} from \"../promise-queue\";\n\n/** Configuration interface for the Eclesia indexer */\nexport type EcleciaIndexerConfig = {\n startHeight?: number // Block height to start indexing from\n endHeight?: number // Block height to stop indexing at (optional)\n batchSize: number // Number of blocks to process in parallel\n modules: string[] // List of module names to enable\n getNextHeight: () => number | PromiseLike<number> // Function to determine next block to process\n logLevel: \"error\" | \"warn\" | \"info\" | \"http\" | \"verbose\" | \"debug\" | \"silly\" // Logging verbosity level\n rpcUrl: string // Tendermint RPC endpoint URL\n shouldProcessGenesis: () => Promise<boolean> // Whether to process genesis state\n genesisPath?: string // Path to genesis file\n usePolling?: boolean // Use polling instead of WebSocket subscription\n pollingInterval?: number // Interval between polls in milliseconds\n minimal?: boolean // Use minimal indexing mode (blocks only)\n enableHealthcheck?: boolean // Enable health check HTTP server\n healthCheckPort?: number // Port for health check HTTP server (default: 8888)\n enablePrometheus?: boolean // Enable Prometheus metrics server\n prometheusPort?: number // Port for Prometheus metrics server (default: 9090)\n init?: () => Promise<void> // Custom initialization function\n beginTransaction: () => Promise<void> // Function to begin database transaction\n endTransaction: (status: boolean) => Promise<void> // Function to end database transaction\n};\n\n/** Queue for full indexing mode with validator data */\nexport type FullBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse, Uint8Array]>;\n\n/** Queue for minimal indexing mode without validator data */\nexport type MinimalBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse]>;\n\n/** Union type for block queues */\nexport type BlockQueue = FullBlockQueue | MinimalBlockQueue;\n\n/** Utility type to add height, timestamp, and UUID to event types */\nexport type WithHeightAndUUID<T> = {\n [K in keyof T]: T[K] & {\n uuid?: string // Unique identifier for event tracking\n height?: number // Block height when event occurred\n timestamp?: string // Block timestamp when event occurred\n };\n};\n\n/** Function signature for emitting events asynchronously */\nexport type EmitFunc<K extends keyof WithHeightAndUUID<EventMap>> = (\n t: K,\n e: WithHeightAndUUID<EventMap>[K],\n) => Promise<void | void[]>;\n\nexport type LogEvent = {\n type: \"log\" | \"info\" | \"warning\" | \"error\" | \"verbose\" | \"transient\"\n message: string\n};\nexport type UUIDEvent = {\n uuid: string\n error?: string\n status: boolean\n};\nexport type Events = {\n log: LogEvent\n uuid: UUIDEvent\n \"fatal-error\": {\n error: Error\n message: string\n retryCount?: number\n }\n begin_block: {\n value: {\n events: BlockResultsResponse[\"beginBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n validators: Validator[] | undefined\n }\n }\n\n block: {\n value: {\n block: BlockResponse\n block_results: BlockResultsResponse | BlockResultsResponse38\n }\n }\n end_block: {\n value: BlockResultsResponse[\"endBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n }\n tx_events: {\n value: BlockResultsResponse[\"results\"] | BlockResultsResponse38[\"results\"]\n }\n tx_memo: {\n value: {\n txHash: string\n txBody: TxBody\n }\n }\n _unhandled: {\n type: string\n event: unknown\n }\n \"periodic/small\": {\n value: null\n }\n \"periodic/medium\": {\n value: null\n }\n \"periodic/large\": {\n value: null\n }\n};\nexport type TxResult<T> = {\n tx: T\n events: Event[]\n};\n\n/** Interface that all indexing modules must implement */\nexport interface IndexingModule {\n indexer: EcleciaIndexer // Reference to the main indexer instance\n name: string // Unique module name\n depends: string[] // Array of module names this module depends on\n provides: string[] // Array of capabilities this module provides\n setup: () => Promise<void> // Async setup function for database schema initialization\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n init: (...args: any[]) => void // Initialization function called by the indexer\n}\n"],"mappings":""}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["/* eslint-disable @stylistic/no-multi-spaces */\nimport {\n BlockResponse, BlockResultsResponse,\n} from \"@cosmjs/tendermint-rpc\";\nimport {\n BlockResultsResponse as BlockResultsResponse38, Event,\n} from \"@cosmjs/tendermint-rpc/build/comet38/responses\";\nimport {\n Validator,\n} from \"cosmjs-types/cosmos/staking/v1beta1/staking\";\nimport {\n TxBody,\n} from \"cosmjs-types/cosmos/tx/v1beta1/tx\";\n\nimport {\n EclesiaIndexer,\n} from \"../indexer\";\nimport {\n CircularBuffer,\n} from \"../promise-queue\";\n\n/** Configuration interface for the Eclesia indexer */\nexport type EclesiaIndexerConfig = {\n startHeight?: number // Block height to start indexing from\n endHeight?: number // Block height to stop indexing at (optional)\n batchSize: number // Number of blocks to process in parallel\n modules: string[] // List of module names to enable\n getNextHeight: () => number | PromiseLike<number> // Function to determine next block to process\n logLevel: \"error\" | \"warn\" | \"info\" | \"http\" | \"verbose\" | \"debug\" | \"silly\" // Logging verbosity level\n rpcUrl: string // Tendermint RPC endpoint URL\n chainId?: string // Refuse to index if the RPC reports a different network\n shouldProcessGenesis: () => Promise<boolean> // Whether to process genesis state\n genesisPath?: string // Path to genesis file\n usePolling?: boolean // Use polling instead of WebSocket subscription\n pollingInterval?: number // Interval between polls in milliseconds\n minimal?: boolean // Use minimal indexing mode (blocks only)\n enableHealthcheck?: boolean // Enable health check HTTP server\n healthCheckPort?: number // Port for health check HTTP server (default: 8888)\n enablePrometheus?: boolean // Enable Prometheus metrics server\n prometheusPort?: number // Port for Prometheus metrics server (default: 9090)\n healthCheckHost?: string // Address the health check server binds to (default: 0.0.0.0)\n prometheusHost?: string // Address the metrics server binds to (default: 0.0.0.0)\n logFormat?: \"text\" | \"json\" // Console log format (default: text)\n maxRetries?: number // Emit fatal-error after this many consecutive failed restarts; unlimited when unset\n maxFailuresPerBlock?: number // Consecutive processing failures on one block before fatal-error (default: 5)\n onGenesisStart?: () => Promise<void> // Called before the genesis import begins, outside any transaction\n onGenesisComplete?: () => Promise<void> // Called inside the final genesis transaction, right before it commits\n init?: () => Promise<void> // Custom initialization function\n beginTransaction: () => Promise<void> // Function to begin database transaction\n endTransaction: (status: boolean) => Promise<void> // Function to end database transaction\n};\n\n/** @deprecated Misspelling kept for compatibility, use EclesiaIndexerConfig. Removed in 3.0. */\nexport type EcleciaIndexerConfig = EclesiaIndexerConfig;\n\n/** Queue for full indexing mode with validator data */\nexport type FullBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse, Uint8Array]>;\n\n/** Queue for minimal indexing mode without validator data */\nexport type MinimalBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse]>;\n\n/** Union type for block queues */\nexport type BlockQueue = FullBlockQueue | MinimalBlockQueue;\n\n/** Utility type to add height, timestamp, and UUID to event types */\nexport type WithHeightAndUUID<T> = {\n [K in keyof T]: T[K] & {\n uuid?: string // Unique identifier for event tracking\n height?: number // Block height when event occurred\n timestamp?: string // Block timestamp when event occurred\n };\n};\n\n/** Function signature for emitting events asynchronously */\nexport type EmitFunc<K extends keyof WithHeightAndUUID<EventMap>> = (\n t: K,\n e: WithHeightAndUUID<EventMap>[K],\n) => Promise<void | void[]>;\n\nexport type LogEvent = {\n type: \"log\" | \"info\" | \"warning\" | \"error\" | \"verbose\" | \"transient\"\n message: string\n};\nexport type UUIDEvent = {\n uuid: string\n error?: string\n status: boolean\n};\nexport type Events = {\n log: LogEvent\n uuid: UUIDEvent\n \"fatal-error\": {\n error: Error\n message: string\n retryCount?: number\n height?: number // Set when one block failed repeatedly\n }\n begin_block: {\n value: {\n events: BlockResultsResponse[\"beginBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n validators: Validator[] | undefined\n }\n }\n\n block: {\n value: {\n block: BlockResponse\n block_results: BlockResultsResponse | BlockResultsResponse38\n }\n }\n end_block: {\n value: BlockResultsResponse[\"endBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n }\n tx_events: {\n value: BlockResultsResponse[\"results\"] | BlockResultsResponse38[\"results\"]\n }\n tx_memo: {\n value: {\n txHash: string\n txBody: TxBody\n }\n }\n _unhandled: {\n type: string\n event: unknown\n }\n \"periodic/small\": {\n value: null\n }\n \"periodic/medium\": {\n value: null\n }\n \"periodic/large\": {\n value: null\n }\n};\nexport type TxResult<T> = {\n tx: T\n events: Event[]\n};\n\n/** Interface that all indexing modules must implement */\nexport interface IndexingModule {\n indexer: EclesiaIndexer // Reference to the main indexer instance\n name: string // Unique module name\n depends: string[] // Array of module names this module depends on\n provides: string[] // Array of capabilities this module provides\n setup: () => Promise<void> // Async setup function for database schema initialization\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n init: (...args: any[]) => void // Initialization function called by the indexer\n}\n\n/**\n * Global event map. Modules add their own events through declaration merging:\n *\n * declare global { interface EventMap extends MyModule.Events {} }\n *\n * Declared in a regular module (not an ambient .d.ts) so it is emitted into the\n * published declarations and consumers get typed events without extra setup.\n */\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n interface EventMap extends Events {\n }\n}\n"],"mappings":""}