@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,4 +1,4 @@
1
- import { EcleciaIndexer } from "../indexer/index.cjs";
1
+ import { EclesiaIndexer } from "../indexer/index.cjs";
2
2
  import { CircularBuffer } from "../promise-queue/index.cjs";
3
3
  import { BlockResponse, BlockResultsResponse } from "@cosmjs/tendermint-rpc";
4
4
  import { BlockResultsResponse as BlockResultsResponse$1, Event } from "@cosmjs/tendermint-rpc/build/comet38/responses";
@@ -7,10 +7,10 @@ import { TxBody } from "cosmjs-types/cosmos/tx/v1beta1/tx";
7
7
 
8
8
  //#region src/types/index.d.ts
9
9
  declare namespace index_d_exports {
10
- export { BlockQueue, EcleciaIndexerConfig, EmitFunc, Events, FullBlockQueue, IndexingModule, LogEvent, MinimalBlockQueue, TxResult, UUIDEvent, WithHeightAndUUID };
10
+ export { BlockQueue, EcleciaIndexerConfig, EclesiaIndexerConfig, EmitFunc, Events, FullBlockQueue, IndexingModule, LogEvent, MinimalBlockQueue, TxResult, UUIDEvent, WithHeightAndUUID };
11
11
  }
12
12
  /** Configuration interface for the Eclesia indexer */
13
- type EcleciaIndexerConfig = {
13
+ type EclesiaIndexerConfig = {
14
14
  startHeight?: number;
15
15
  endHeight?: number;
16
16
  batchSize: number;
@@ -18,6 +18,7 @@ type EcleciaIndexerConfig = {
18
18
  getNextHeight: () => number | PromiseLike<number>;
19
19
  logLevel: "error" | "warn" | "info" | "http" | "verbose" | "debug" | "silly";
20
20
  rpcUrl: string;
21
+ chainId?: string;
21
22
  shouldProcessGenesis: () => Promise<boolean>;
22
23
  genesisPath?: string;
23
24
  usePolling?: boolean;
@@ -27,10 +28,19 @@ type EcleciaIndexerConfig = {
27
28
  healthCheckPort?: number;
28
29
  enablePrometheus?: boolean;
29
30
  prometheusPort?: number;
31
+ healthCheckHost?: string;
32
+ prometheusHost?: string;
33
+ logFormat?: "text" | "json";
34
+ maxRetries?: number;
35
+ maxFailuresPerBlock?: number;
36
+ onGenesisStart?: () => Promise<void>;
37
+ onGenesisComplete?: () => Promise<void>;
30
38
  init?: () => Promise<void>;
31
39
  beginTransaction: () => Promise<void>;
32
40
  endTransaction: (status: boolean) => Promise<void>;
33
41
  };
42
+ /** @deprecated Misspelling kept for compatibility, use EclesiaIndexerConfig. Removed in 3.0. */
43
+ type EcleciaIndexerConfig = EclesiaIndexerConfig;
34
44
  /** Queue for full indexing mode with validator data */
35
45
  type FullBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse, Uint8Array]>;
36
46
  /** Queue for minimal indexing mode without validator data */
@@ -61,6 +71,7 @@ type Events = {
61
71
  error: Error;
62
72
  message: string;
63
73
  retryCount?: number;
74
+ height?: number;
64
75
  };
65
76
  begin_block: {
66
77
  value: {
@@ -106,13 +117,25 @@ type TxResult<T> = {
106
117
  };
107
118
  /** Interface that all indexing modules must implement */
108
119
  interface IndexingModule {
109
- indexer: EcleciaIndexer;
120
+ indexer: EclesiaIndexer;
110
121
  name: string;
111
122
  depends: string[];
112
123
  provides: string[];
113
124
  setup: () => Promise<void>;
114
125
  init: (...args: any[]) => void;
115
126
  }
127
+ /**
128
+ * Global event map. Modules add their own events through declaration merging:
129
+ *
130
+ * declare global { interface EventMap extends MyModule.Events {} }
131
+ *
132
+ * Declared in a regular module (not an ambient .d.ts) so it is emitted into the
133
+ * published declarations and consumers get typed events without extra setup.
134
+ */
135
+ declare global {
136
+ interface EventMap extends Events {}
137
+ }
138
+ //# sourceMappingURL=index.d.ts.map
116
139
  //#endregion
117
- export { EcleciaIndexerConfig, EmitFunc, WithHeightAndUUID, index_d_exports };
140
+ export { EclesiaIndexerConfig, EmitFunc, WithHeightAndUUID, index_d_exports };
118
141
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;KAsBY,oBAAA;;;;;gCAKoB;;;8BAGF;;;;;;;EARlB,gBAAA,CAAA,EAAA,OAAoB;EAKA,cAAA,CAAA,EAAA,MAAA;EAGF,IAAA,CAAA,EAAA,GAAA,GASf,OATe,CAAA,IAAA,CAAA;EASf,gBAAA,EAAA,GAAA,GACW,OADX,CAAA,IAAA,CAAA;EACW,cAAA,EAAA,CAAA,MAAA,EAAA,OAAA,EAAA,GACa,OADb,CAAA,IAAA,CAAA;CACa;;AAI3B,KAAA,cAAA,GAAiB,cAAH,CAAA,CAAmB,aAAnB,EAAkC,oBAAlC,EAAwD,UAAxD,CAAA,CAAA;;AAAkC,KAGhD,iBAAA,GAAoB,cAH4B,CAAA,CAGZ,aAHY,EAGG,oBAHH,CAAA,CAAA;;AAA/B,KAMjB,UAAA,GAAa,cANI,GAMa,iBANb;;AAGjB,KAMA,iBANiB,CAAA,CAAA,CAAA,GAAA,QAAmB,MAOlC,CAPkC,GAO9B,CAP8B,CAO5B,CAP4B,CAAA,GAAA;EAAe,IAAA,CAAA,EAAA,MAAA;EAA/B,MAAA,CAAA,EAAA,MAAA;EAAc,SAAA,CAAA,EAAA,MAAA;AAGlC,CAAA,EAGZ;;AACkB,KAQN,QARM,CAAA,YAAA,MAQmB,iBARnB,CAQqC,QARrC,CAAA,CAAA,GAAA,CAAA,CAAA,EASb,GATa,EAAA,CAAA,EAUb,iBAVa,CAUK,QAVL,CAAA,CAUe,GAVf,CAAA,EAAA,GAWb,OAXa,CAAA,IAAA,GAAA,IAAA,EAAA,CAAA;AAAE,KAaR,QAAA,GAbQ;EAAC,IAAA,EAAA,KAAA,GAAA,MAAA,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;EAKT,MAAA,EAAA,OAAM;CACX;AACC,KAFI,MAAA,GAEJ;EAEG,GAAA,EAHJ,QAGI;EAOG,IAAA,EATN,SASM;EAA2C,aAAA,EAAA;IACvC,KAAA,EARP,KAQO;IAML,OAAA,EAAA,MAAA;IACQ,UAAA,CAAA,EAAA,MAAA;IAAuB,MAAA,CAAA,EAAA,MAAA;EAIjC,CAAA;EAAyC,WAAA,EAAA;IAGzC,KAAA,EAAA;MAAkC,MAAA,EAf/B,oBAe+B,CAAA,kBAAA,CAAA,GAfY,sBAeZ,CAAA,qBAAA,CAAA;MAK/B,UAAA,EAnBI,SAmBJ,EAAA,GAAA,SAAA;IAAM,CAAA;EAiBR,CAAA;EAMK,KAAA,EAAA;IAQhB,KAAA,EAAA;MAAA,KAAA,EA5CY,aA4CZ;MAY4B,aAAM,EAvDd,oBAuDc,GAvDS,sBAuDT;IAAA,CAAA;EAAA,CAAA;;WAnDxB,yCAAyC;;;WAGzC,kCAAkC;;;;;cAK/B;;;;;;;;;;;;;;;;;KAiBF;MACN;UACI;;;UAIO,cAAA;WACN;;;;eAII;;;;;;;;;;;;6BAec"}
@@ -1,4 +1,4 @@
1
- import { EcleciaIndexer } from "../indexer/index.mjs";
1
+ import { EclesiaIndexer } from "../indexer/index.mjs";
2
2
  import { CircularBuffer } from "../promise-queue/index.mjs";
3
3
  import { BlockResponse, BlockResultsResponse } from "@cosmjs/tendermint-rpc";
4
4
  import { BlockResultsResponse as BlockResultsResponse$1, Event } from "@cosmjs/tendermint-rpc/build/comet38/responses";
@@ -7,10 +7,10 @@ import { TxBody } from "cosmjs-types/cosmos/tx/v1beta1/tx";
7
7
 
8
8
  //#region src/types/index.d.ts
9
9
  declare namespace index_d_exports {
10
- export { BlockQueue, EcleciaIndexerConfig, EmitFunc, Events, FullBlockQueue, IndexingModule, LogEvent, MinimalBlockQueue, TxResult, UUIDEvent, WithHeightAndUUID };
10
+ export { BlockQueue, EcleciaIndexerConfig, EclesiaIndexerConfig, EmitFunc, Events, FullBlockQueue, IndexingModule, LogEvent, MinimalBlockQueue, TxResult, UUIDEvent, WithHeightAndUUID };
11
11
  }
12
12
  /** Configuration interface for the Eclesia indexer */
13
- type EcleciaIndexerConfig = {
13
+ type EclesiaIndexerConfig = {
14
14
  startHeight?: number;
15
15
  endHeight?: number;
16
16
  batchSize: number;
@@ -18,6 +18,7 @@ type EcleciaIndexerConfig = {
18
18
  getNextHeight: () => number | PromiseLike<number>;
19
19
  logLevel: "error" | "warn" | "info" | "http" | "verbose" | "debug" | "silly";
20
20
  rpcUrl: string;
21
+ chainId?: string;
21
22
  shouldProcessGenesis: () => Promise<boolean>;
22
23
  genesisPath?: string;
23
24
  usePolling?: boolean;
@@ -27,10 +28,19 @@ type EcleciaIndexerConfig = {
27
28
  healthCheckPort?: number;
28
29
  enablePrometheus?: boolean;
29
30
  prometheusPort?: number;
31
+ healthCheckHost?: string;
32
+ prometheusHost?: string;
33
+ logFormat?: "text" | "json";
34
+ maxRetries?: number;
35
+ maxFailuresPerBlock?: number;
36
+ onGenesisStart?: () => Promise<void>;
37
+ onGenesisComplete?: () => Promise<void>;
30
38
  init?: () => Promise<void>;
31
39
  beginTransaction: () => Promise<void>;
32
40
  endTransaction: (status: boolean) => Promise<void>;
33
41
  };
42
+ /** @deprecated Misspelling kept for compatibility, use EclesiaIndexerConfig. Removed in 3.0. */
43
+ type EcleciaIndexerConfig = EclesiaIndexerConfig;
34
44
  /** Queue for full indexing mode with validator data */
35
45
  type FullBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse, Uint8Array]>;
36
46
  /** Queue for minimal indexing mode without validator data */
@@ -61,6 +71,7 @@ type Events = {
61
71
  error: Error;
62
72
  message: string;
63
73
  retryCount?: number;
74
+ height?: number;
64
75
  };
65
76
  begin_block: {
66
77
  value: {
@@ -106,13 +117,25 @@ type TxResult<T> = {
106
117
  };
107
118
  /** Interface that all indexing modules must implement */
108
119
  interface IndexingModule {
109
- indexer: EcleciaIndexer;
120
+ indexer: EclesiaIndexer;
110
121
  name: string;
111
122
  depends: string[];
112
123
  provides: string[];
113
124
  setup: () => Promise<void>;
114
125
  init: (...args: any[]) => void;
115
126
  }
127
+ /**
128
+ * Global event map. Modules add their own events through declaration merging:
129
+ *
130
+ * declare global { interface EventMap extends MyModule.Events {} }
131
+ *
132
+ * Declared in a regular module (not an ambient .d.ts) so it is emitted into the
133
+ * published declarations and consumers get typed events without extra setup.
134
+ */
135
+ declare global {
136
+ interface EventMap extends Events {}
137
+ }
138
+ //# sourceMappingURL=index.d.ts.map
116
139
  //#endregion
117
- export { EcleciaIndexerConfig, EmitFunc, WithHeightAndUUID, index_d_exports };
140
+ export { EclesiaIndexerConfig, EmitFunc, WithHeightAndUUID, index_d_exports };
118
141
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;KAsBY,oBAAA;;;;;gCAKoB;;;8BAGF;;;;;;;EARlB,gBAAA,CAAA,EAAA,OAAoB;EAKA,cAAA,CAAA,EAAA,MAAA;EAGF,IAAA,CAAA,EAAA,GAAA,GASf,OATe,CAAA,IAAA,CAAA;EASf,gBAAA,EAAA,GAAA,GACW,OADX,CAAA,IAAA,CAAA;EACW,cAAA,EAAA,CAAA,MAAA,EAAA,OAAA,EAAA,GACa,OADb,CAAA,IAAA,CAAA;CACa;;AAI3B,KAAA,cAAA,GAAiB,cAAH,CAAA,CAAmB,aAAnB,EAAkC,oBAAlC,EAAwD,UAAxD,CAAA,CAAA;;AAAkC,KAGhD,iBAAA,GAAoB,cAH4B,CAAA,CAGZ,aAHY,EAGG,oBAHH,CAAA,CAAA;;AAA/B,KAMjB,UAAA,GAAa,cANI,GAMa,iBANb;;AAGjB,KAMA,iBANiB,CAAA,CAAA,CAAA,GAAA,QAAmB,MAOlC,CAPkC,GAO9B,CAP8B,CAO5B,CAP4B,CAAA,GAAA;EAAe,IAAA,CAAA,EAAA,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AA,CAAA,CAAA,EAAA,GAAA,EAAA,CAAA,EACA,iBADA,CACkB,QADlB,CAAA,CAC4B,GAD5B,CAAA,EAAA,GAEA,OAFA,CAAA,IAAA,GAAA,IAAA,EAAA,CAAA;AACkB,KAGX,QAAA,GAHW;EAAlB,IAAA,EAAA,KAAA,GAAA,MAAA,GAAA,SAAA,GAAA,OAAA,GAAA,SAAA,GAAA,WAAA;EAA4B,OAAA,EAAA,MAAA;CAC5B;AAAO,KAMA,SAAA,GANA;EAEA,IAAA,EAAA,MAAQ;EAIR,KAAA,CAAA,EAAA,MAAS;EAKT,MAAA,EAAA,OAAM;CACX;AACC,KAFI,MAAA,GAEJ;EAEG,GAAA,EAHJ,QAGI;EAOG,IAAA,EATN,SASM;EAA2C,aAAA,EAAA;IACvC,KAAA,EARP,KAQO;IAML,OAAA,EAAA,MAAA;IACQ,UAAA,CAAA,EAAA,MAAA;IAAuB,MAAA,CAAA,EAAA,MAAA;EAIjC,CAAA;EAAyC,WAAA,EAAA;IAGzC,KAAA,EAAA;MAAkC,MAAA,EAf/B,oBAe+B,CAAA,kBAAA,CAAA,GAfY,sBAeZ,CAAA,qBAAA,CAAA;MAK/B,UAAA,EAnBI,SAmBJ,EAAA,GAAA,SAAA;IAAM,CAAA;EAiBR,CAAA;EAMK,KAAA,EAAA;IAQhB,KAAA,EAAA;MAAA,KAAA,EA5CY,aA4CZ;MAY4B,aAAM,EAvDd,oBAuDc,GAvDS,sBAuDT;IAAA,CAAA;EAAA,CAAA;;WAnDxB,yCAAyC;;;WAGzC,kCAAkC;;;;;cAK/B;;;;;;;;;;;;;;;;;KAiBF;MACN;UACI;;;UAIO,cAAA;WACN;;;;eAII;;;;;;;;;;;;6BAec"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","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.mjs","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":""}
@@ -2,14 +2,19 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_bech32 = require('./bech32.cjs');
3
3
  const require_bigint = require('./bigint.cjs');
4
4
  const require_text = require('./text.cjs');
5
+ const require_timeout = require('./timeout.cjs');
5
6
 
6
7
  //#region src/utils/index.ts
7
8
  var utils_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
8
9
  chainAddressfromKeyhash: () => require_bech32.chainAddressfromKeyhash,
9
10
  decodeAttr: () => require_text.decodeAttr,
11
+ hasBlockEventMode: () => require_text.hasBlockEventMode,
10
12
  keyHashfromAddress: () => require_bech32.keyHashfromAddress,
13
+ redactUrl: () => require_text.redactUrl,
14
+ retryDelay: () => require_timeout.retryDelay,
11
15
  toHexString: () => require_bech32.toHexString,
12
- toPlainObject: () => require_bigint.toPlainObject
16
+ toPlainObject: () => require_bigint.toPlainObject,
17
+ withTimeout: () => require_timeout.withTimeout
13
18
  });
14
19
 
15
20
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["/* eslint-disable @stylistic/no-multi-spaces */\n// Utility function exports\nexport * from \"./bech32\"; // Bech32 address encoding/decoding utilities\nexport * from \"./bigint\"; // BigInt handling utilities\nexport * from \"./text\"; // Text processing and encoding utilities\n"],"mappings":""}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["/* eslint-disable @stylistic/no-multi-spaces */\n// Utility function exports\nexport * from \"./bech32\"; // Bech32 address encoding/decoding utilities\nexport * from \"./bigint\"; // BigInt handling utilities\nexport * from \"./text\"; // Text processing and encoding utilities\nexport * from \"./timeout\"; // Promise timeout helper\n"],"mappings":""}
@@ -1,10 +1,11 @@
1
1
  import { chainAddressfromKeyhash, keyHashfromAddress, toHexString } from "./bech32.cjs";
2
2
  import { toPlainObject } from "./bigint.cjs";
3
- import { decodeAttr } from "./text.cjs";
3
+ import { BlockEventMode, ModeTaggedEvent, decodeAttr, hasBlockEventMode, redactUrl } from "./text.cjs";
4
+ import { retryDelay, withTimeout } from "./timeout.cjs";
4
5
 
5
6
  //#region src/utils/index.d.ts
6
7
  declare namespace index_d_exports {
7
- export { chainAddressfromKeyhash, decodeAttr, keyHashfromAddress, toHexString, toPlainObject };
8
+ export { BlockEventMode, ModeTaggedEvent, chainAddressfromKeyhash, decodeAttr, hasBlockEventMode, keyHashfromAddress, redactUrl, retryDelay, toHexString, toPlainObject, withTimeout };
8
9
  }
9
10
  //#endregion
10
11
  export { index_d_exports };
@@ -1,10 +1,11 @@
1
1
  import { chainAddressfromKeyhash, keyHashfromAddress, toHexString } from "./bech32.mjs";
2
2
  import { toPlainObject } from "./bigint.mjs";
3
- import { decodeAttr } from "./text.mjs";
3
+ import { BlockEventMode, ModeTaggedEvent, decodeAttr, hasBlockEventMode, redactUrl } from "./text.mjs";
4
+ import { retryDelay, withTimeout } from "./timeout.mjs";
4
5
 
5
6
  //#region src/utils/index.d.ts
6
7
  declare namespace index_d_exports {
7
- export { chainAddressfromKeyhash, decodeAttr, keyHashfromAddress, toHexString, toPlainObject };
8
+ export { BlockEventMode, ModeTaggedEvent, chainAddressfromKeyhash, decodeAttr, hasBlockEventMode, keyHashfromAddress, redactUrl, retryDelay, toHexString, toPlainObject, withTimeout };
8
9
  }
9
10
  //#endregion
10
11
  export { index_d_exports };
@@ -1,15 +1,20 @@
1
1
  import { __export } from "../_virtual/rolldown_runtime.mjs";
2
2
  import { chainAddressfromKeyhash, keyHashfromAddress, toHexString } from "./bech32.mjs";
3
3
  import { toPlainObject } from "./bigint.mjs";
4
- import { decodeAttr } from "./text.mjs";
4
+ import { decodeAttr, hasBlockEventMode, redactUrl } from "./text.mjs";
5
+ import { retryDelay, withTimeout } from "./timeout.mjs";
5
6
 
6
7
  //#region src/utils/index.ts
7
8
  var utils_exports = /* @__PURE__ */ __export({
8
9
  chainAddressfromKeyhash: () => chainAddressfromKeyhash,
9
10
  decodeAttr: () => decodeAttr,
11
+ hasBlockEventMode: () => hasBlockEventMode,
10
12
  keyHashfromAddress: () => keyHashfromAddress,
13
+ redactUrl: () => redactUrl,
14
+ retryDelay: () => retryDelay,
11
15
  toHexString: () => toHexString,
12
- toPlainObject: () => toPlainObject
16
+ toPlainObject: () => toPlainObject,
17
+ withTimeout: () => withTimeout
13
18
  });
14
19
 
15
20
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["/* eslint-disable @stylistic/no-multi-spaces */\n// Utility function exports\nexport * from \"./bech32\"; // Bech32 address encoding/decoding utilities\nexport * from \"./bigint\"; // BigInt handling utilities\nexport * from \"./text\"; // Text processing and encoding utilities\n"],"mappings":""}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["/* eslint-disable @stylistic/no-multi-spaces */\n// Utility function exports\nexport * from \"./bech32\"; // Bech32 address encoding/decoding utilities\nexport * from \"./bigint\"; // BigInt handling utilities\nexport * from \"./text\"; // Text processing and encoding utilities\nexport * from \"./timeout\"; // Promise timeout helper\n"],"mappings":""}
@@ -11,7 +11,38 @@ const decodeAttr = (x) => {
11
11
  else if (x instanceof Uint8Array) return Buffer.from(x).toString();
12
12
  else return "";
13
13
  };
14
+ const MODE_SPELLINGS = {
15
+ BeginBlock: ["BeginBlock", "begin_block"],
16
+ EndBlock: ["EndBlock", "end_block"]
17
+ };
18
+ /**
19
+ * Checks whether a finalize_block event carries the given `mode` attribute.
20
+ * The SDK emits `mode=BeginBlock` / `mode=EndBlock`; the snake_case spellings
21
+ * are accepted as well so forks that lowercase the value keep working.
22
+ * @param event - Event with an attributes array
23
+ * @param mode - Which phase of the block the event must belong to
24
+ * @returns true when the event has a matching `mode` attribute
25
+ */
26
+ const hasBlockEventMode = (event, mode) => {
27
+ const accepted = MODE_SPELLINGS[mode];
28
+ return event.attributes.some((a) => decodeAttr(a.key) === "mode" && accepted.includes(decodeAttr(a.value)));
29
+ };
30
+ /**
31
+ * Returns a URL that is safe to log: the password part of any credentials is masked.
32
+ * Strings that do not parse as a URL are returned unchanged.
33
+ */
34
+ const redactUrl = (url) => {
35
+ try {
36
+ const parsed = new URL(url);
37
+ if (parsed.password) parsed.password = "***";
38
+ return parsed.toString();
39
+ } catch (_e) {
40
+ return url;
41
+ }
42
+ };
14
43
 
15
44
  //#endregion
16
45
  exports.decodeAttr = decodeAttr;
46
+ exports.hasBlockEventMode = hasBlockEventMode;
47
+ exports.redactUrl = redactUrl;
17
48
  //# sourceMappingURL=text.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"text.cjs","names":[],"sources":["../../src/utils/text.ts"],"sourcesContent":["/**\n * Decodes blockchain event attributes from various formats to strings\n * Handles both string and Uint8Array inputs from Tendermint events\n * @param x - The attribute value to decode (string or Uint8Array)\n * @returns Decoded string value\n */\nexport const decodeAttr = (x: Uint8Array | string) => {\n if (typeof x === \"string\") {\n return x;\n }\n else if (x instanceof Uint8Array) {\n return Buffer.from(x).toString();\n }\n else {\n return \"\";\n }\n};\n"],"mappings":";;;;;;;;AAMA,MAAa,cAAc,MAA2B;AACpD,KAAI,OAAO,MAAM,SACf,QAAO;UAEA,aAAa,WACpB,QAAO,OAAO,KAAK,EAAE,CAAC,UAAU;KAGhC,QAAO"}
1
+ {"version":3,"file":"text.cjs","names":["MODE_SPELLINGS: Record<BlockEventMode, readonly string[]>"],"sources":["../../src/utils/text.ts"],"sourcesContent":["/**\n * Decodes blockchain event attributes from various formats to strings\n * Handles both string and Uint8Array inputs from Tendermint events\n * @param x - The attribute value to decode (string or Uint8Array)\n * @returns Decoded string value\n */\nexport const decodeAttr = (x: Uint8Array | string) => {\n if (typeof x === \"string\") {\n return x;\n }\n else if (x instanceof Uint8Array) {\n return Buffer.from(x).toString();\n }\n else {\n return \"\";\n }\n};\n\n/** Minimal shape of an ABCI event, compatible with both CometBFT 0.37 and 0.38 response types */\nexport type ModeTaggedEvent = {\n attributes: readonly {\n key: Uint8Array | string\n value: Uint8Array | string\n }[]\n};\n\n/** Values Cosmos SDK 0.50+ stamps on `finalize_block_events` to mark their origin (baseapp.go) */\nexport type BlockEventMode = \"BeginBlock\" | \"EndBlock\";\n\nconst MODE_SPELLINGS: Record<BlockEventMode, readonly string[]> = {\n BeginBlock: [\"BeginBlock\", \"begin_block\"],\n EndBlock: [\"EndBlock\", \"end_block\"],\n};\n\n/**\n * Checks whether a finalize_block event carries the given `mode` attribute.\n * The SDK emits `mode=BeginBlock` / `mode=EndBlock`; the snake_case spellings\n * are accepted as well so forks that lowercase the value keep working.\n * @param event - Event with an attributes array\n * @param mode - Which phase of the block the event must belong to\n * @returns true when the event has a matching `mode` attribute\n */\nexport const hasBlockEventMode = (event: ModeTaggedEvent, mode: BlockEventMode): boolean => {\n const accepted = MODE_SPELLINGS[mode];\n return event.attributes.some(a => decodeAttr(a.key) === \"mode\" && accepted.includes(decodeAttr(a.value)));\n};\n\n/**\n * Returns a URL that is safe to log: the password part of any credentials is masked.\n * Strings that do not parse as a URL are returned unchanged.\n */\nexport const redactUrl = (url: string): string => {\n try {\n const parsed = new URL(url);\n if (parsed.password) {\n parsed.password = \"***\";\n }\n return parsed.toString();\n }\n catch (_e) {\n return url;\n }\n};\n"],"mappings":";;;;;;;;AAMA,MAAa,cAAc,MAA2B;AACpD,KAAI,OAAO,MAAM,SACf,QAAO;UAEA,aAAa,WACpB,QAAO,OAAO,KAAK,EAAE,CAAC,UAAU;KAGhC,QAAO;;AAeX,MAAMA,iBAA4D;CAChE,YAAY,CAAC,cAAc,cAAc;CACzC,UAAU,CAAC,YAAY,YAAY;CACpC;;;;;;;;;AAUD,MAAa,qBAAqB,OAAwB,SAAkC;CAC1F,MAAM,WAAW,eAAe;AAChC,QAAO,MAAM,WAAW,MAAK,MAAK,WAAW,EAAE,IAAI,KAAK,UAAU,SAAS,SAAS,WAAW,EAAE,MAAM,CAAC,CAAC;;;;;;AAO3G,MAAa,aAAa,QAAwB;AAChD,KAAI;EACF,MAAM,SAAS,IAAI,IAAI,IAAI;AAC3B,MAAI,OAAO,SACT,QAAO,WAAW;AAEpB,SAAO,OAAO,UAAU;UAEnB,IAAI;AACT,SAAO"}
@@ -6,6 +6,29 @@
6
6
  * @returns Decoded string value
7
7
  */
8
8
  declare const decodeAttr: (x: Uint8Array | string) => string;
9
+ /** Minimal shape of an ABCI event, compatible with both CometBFT 0.37 and 0.38 response types */
10
+ type ModeTaggedEvent = {
11
+ attributes: readonly {
12
+ key: Uint8Array | string;
13
+ value: Uint8Array | string;
14
+ }[];
15
+ };
16
+ /** Values Cosmos SDK 0.50+ stamps on `finalize_block_events` to mark their origin (baseapp.go) */
17
+ type BlockEventMode = "BeginBlock" | "EndBlock";
18
+ /**
19
+ * Checks whether a finalize_block event carries the given `mode` attribute.
20
+ * The SDK emits `mode=BeginBlock` / `mode=EndBlock`; the snake_case spellings
21
+ * are accepted as well so forks that lowercase the value keep working.
22
+ * @param event - Event with an attributes array
23
+ * @param mode - Which phase of the block the event must belong to
24
+ * @returns true when the event has a matching `mode` attribute
25
+ */
26
+ declare const hasBlockEventMode: (event: ModeTaggedEvent, mode: BlockEventMode) => boolean;
27
+ /**
28
+ * Returns a URL that is safe to log: the password part of any credentials is masked.
29
+ * Strings that do not parse as a URL are returned unchanged.
30
+ */
31
+ declare const redactUrl: (url: string) => string;
9
32
  //#endregion
10
- export { decodeAttr };
33
+ export { BlockEventMode, ModeTaggedEvent, decodeAttr, hasBlockEventMode, redactUrl };
11
34
  //# sourceMappingURL=text.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"text.d.cts","names":[],"sources":["../../src/utils/text.ts"],"sourcesContent":[],"mappings":";;AAMA;;;;;cAAa,gBAAiB"}
1
+ {"version":3,"file":"text.d.cts","names":[],"sources":["../../src/utils/text.ts"],"sourcesContent":[],"mappings":";;AAMA;AAaA;AAQA;AAeA;AASA;cA7Ca,gBAAiB;;KAalB,eAAA;;SAEH;WACE;;;;KAKC,cAAA;;;;;;;;;cAeC,2BAA4B,uBAAuB;;;;;cASnD"}
@@ -6,6 +6,29 @@
6
6
  * @returns Decoded string value
7
7
  */
8
8
  declare const decodeAttr: (x: Uint8Array | string) => string;
9
+ /** Minimal shape of an ABCI event, compatible with both CometBFT 0.37 and 0.38 response types */
10
+ type ModeTaggedEvent = {
11
+ attributes: readonly {
12
+ key: Uint8Array | string;
13
+ value: Uint8Array | string;
14
+ }[];
15
+ };
16
+ /** Values Cosmos SDK 0.50+ stamps on `finalize_block_events` to mark their origin (baseapp.go) */
17
+ type BlockEventMode = "BeginBlock" | "EndBlock";
18
+ /**
19
+ * Checks whether a finalize_block event carries the given `mode` attribute.
20
+ * The SDK emits `mode=BeginBlock` / `mode=EndBlock`; the snake_case spellings
21
+ * are accepted as well so forks that lowercase the value keep working.
22
+ * @param event - Event with an attributes array
23
+ * @param mode - Which phase of the block the event must belong to
24
+ * @returns true when the event has a matching `mode` attribute
25
+ */
26
+ declare const hasBlockEventMode: (event: ModeTaggedEvent, mode: BlockEventMode) => boolean;
27
+ /**
28
+ * Returns a URL that is safe to log: the password part of any credentials is masked.
29
+ * Strings that do not parse as a URL are returned unchanged.
30
+ */
31
+ declare const redactUrl: (url: string) => string;
9
32
  //#endregion
10
- export { decodeAttr };
33
+ export { BlockEventMode, ModeTaggedEvent, decodeAttr, hasBlockEventMode, redactUrl };
11
34
  //# sourceMappingURL=text.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"text.d.mts","names":[],"sources":["../../src/utils/text.ts"],"sourcesContent":[],"mappings":";;AAMA;;;;;cAAa,gBAAiB"}
1
+ {"version":3,"file":"text.d.mts","names":[],"sources":["../../src/utils/text.ts"],"sourcesContent":[],"mappings":";;AAMA;AAaA;AAQA;AAeA;AASA;cA7Ca,gBAAiB;;KAalB,eAAA;;SAEH;WACE;;;;KAKC,cAAA;;;;;;;;;cAeC,2BAA4B,uBAAuB;;;;;cASnD"}
@@ -10,7 +10,36 @@ const decodeAttr = (x) => {
10
10
  else if (x instanceof Uint8Array) return Buffer.from(x).toString();
11
11
  else return "";
12
12
  };
13
+ const MODE_SPELLINGS = {
14
+ BeginBlock: ["BeginBlock", "begin_block"],
15
+ EndBlock: ["EndBlock", "end_block"]
16
+ };
17
+ /**
18
+ * Checks whether a finalize_block event carries the given `mode` attribute.
19
+ * The SDK emits `mode=BeginBlock` / `mode=EndBlock`; the snake_case spellings
20
+ * are accepted as well so forks that lowercase the value keep working.
21
+ * @param event - Event with an attributes array
22
+ * @param mode - Which phase of the block the event must belong to
23
+ * @returns true when the event has a matching `mode` attribute
24
+ */
25
+ const hasBlockEventMode = (event, mode) => {
26
+ const accepted = MODE_SPELLINGS[mode];
27
+ return event.attributes.some((a) => decodeAttr(a.key) === "mode" && accepted.includes(decodeAttr(a.value)));
28
+ };
29
+ /**
30
+ * Returns a URL that is safe to log: the password part of any credentials is masked.
31
+ * Strings that do not parse as a URL are returned unchanged.
32
+ */
33
+ const redactUrl = (url) => {
34
+ try {
35
+ const parsed = new URL(url);
36
+ if (parsed.password) parsed.password = "***";
37
+ return parsed.toString();
38
+ } catch (_e) {
39
+ return url;
40
+ }
41
+ };
13
42
 
14
43
  //#endregion
15
- export { decodeAttr };
44
+ export { decodeAttr, hasBlockEventMode, redactUrl };
16
45
  //# sourceMappingURL=text.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"text.mjs","names":[],"sources":["../../src/utils/text.ts"],"sourcesContent":["/**\n * Decodes blockchain event attributes from various formats to strings\n * Handles both string and Uint8Array inputs from Tendermint events\n * @param x - The attribute value to decode (string or Uint8Array)\n * @returns Decoded string value\n */\nexport const decodeAttr = (x: Uint8Array | string) => {\n if (typeof x === \"string\") {\n return x;\n }\n else if (x instanceof Uint8Array) {\n return Buffer.from(x).toString();\n }\n else {\n return \"\";\n }\n};\n"],"mappings":";;;;;;;AAMA,MAAa,cAAc,MAA2B;AACpD,KAAI,OAAO,MAAM,SACf,QAAO;UAEA,aAAa,WACpB,QAAO,OAAO,KAAK,EAAE,CAAC,UAAU;KAGhC,QAAO"}
1
+ {"version":3,"file":"text.mjs","names":["MODE_SPELLINGS: Record<BlockEventMode, readonly string[]>"],"sources":["../../src/utils/text.ts"],"sourcesContent":["/**\n * Decodes blockchain event attributes from various formats to strings\n * Handles both string and Uint8Array inputs from Tendermint events\n * @param x - The attribute value to decode (string or Uint8Array)\n * @returns Decoded string value\n */\nexport const decodeAttr = (x: Uint8Array | string) => {\n if (typeof x === \"string\") {\n return x;\n }\n else if (x instanceof Uint8Array) {\n return Buffer.from(x).toString();\n }\n else {\n return \"\";\n }\n};\n\n/** Minimal shape of an ABCI event, compatible with both CometBFT 0.37 and 0.38 response types */\nexport type ModeTaggedEvent = {\n attributes: readonly {\n key: Uint8Array | string\n value: Uint8Array | string\n }[]\n};\n\n/** Values Cosmos SDK 0.50+ stamps on `finalize_block_events` to mark their origin (baseapp.go) */\nexport type BlockEventMode = \"BeginBlock\" | \"EndBlock\";\n\nconst MODE_SPELLINGS: Record<BlockEventMode, readonly string[]> = {\n BeginBlock: [\"BeginBlock\", \"begin_block\"],\n EndBlock: [\"EndBlock\", \"end_block\"],\n};\n\n/**\n * Checks whether a finalize_block event carries the given `mode` attribute.\n * The SDK emits `mode=BeginBlock` / `mode=EndBlock`; the snake_case spellings\n * are accepted as well so forks that lowercase the value keep working.\n * @param event - Event with an attributes array\n * @param mode - Which phase of the block the event must belong to\n * @returns true when the event has a matching `mode` attribute\n */\nexport const hasBlockEventMode = (event: ModeTaggedEvent, mode: BlockEventMode): boolean => {\n const accepted = MODE_SPELLINGS[mode];\n return event.attributes.some(a => decodeAttr(a.key) === \"mode\" && accepted.includes(decodeAttr(a.value)));\n};\n\n/**\n * Returns a URL that is safe to log: the password part of any credentials is masked.\n * Strings that do not parse as a URL are returned unchanged.\n */\nexport const redactUrl = (url: string): string => {\n try {\n const parsed = new URL(url);\n if (parsed.password) {\n parsed.password = \"***\";\n }\n return parsed.toString();\n }\n catch (_e) {\n return url;\n }\n};\n"],"mappings":";;;;;;;AAMA,MAAa,cAAc,MAA2B;AACpD,KAAI,OAAO,MAAM,SACf,QAAO;UAEA,aAAa,WACpB,QAAO,OAAO,KAAK,EAAE,CAAC,UAAU;KAGhC,QAAO;;AAeX,MAAMA,iBAA4D;CAChE,YAAY,CAAC,cAAc,cAAc;CACzC,UAAU,CAAC,YAAY,YAAY;CACpC;;;;;;;;;AAUD,MAAa,qBAAqB,OAAwB,SAAkC;CAC1F,MAAM,WAAW,eAAe;AAChC,QAAO,MAAM,WAAW,MAAK,MAAK,WAAW,EAAE,IAAI,KAAK,UAAU,SAAS,SAAS,WAAW,EAAE,MAAM,CAAC,CAAC;;;;;;AAO3G,MAAa,aAAa,QAAwB;AAChD,KAAI;EACF,MAAM,SAAS,IAAI,IAAI,IAAI;AAC3B,MAAI,OAAO,SACT,QAAO,WAAW;AAEpB,SAAO,OAAO,UAAU;UAEnB,IAAI;AACT,SAAO"}
@@ -0,0 +1,32 @@
1
+
2
+ //#region src/utils/timeout.ts
3
+ /**
4
+ * Races a promise against a timer and clears the timer however the race settles,
5
+ * so a finished operation never leaves a pending timeout keeping the event loop alive.
6
+ * @param promise - The operation to bound
7
+ * @param ms - Milliseconds to wait before rejecting
8
+ * @param error - Error to reject with when the timer wins
9
+ * @returns The promise's value, or a rejection with `error` on timeout
10
+ */
11
+ const withTimeout = (promise, ms, error) => {
12
+ let handle;
13
+ const timeout = new Promise((_resolve, reject) => {
14
+ handle = setTimeout(() => reject(error), ms);
15
+ });
16
+ return Promise.race([promise, timeout]).finally(() => {
17
+ if (handle) clearTimeout(handle);
18
+ });
19
+ };
20
+ /**
21
+ * Restart delay for the n-th consecutive failure: exponential from `baseMs`, capped at `maxMs`.
22
+ * @param attempt - 1 for the first restart, 2 for the second, and so on
23
+ */
24
+ const retryDelay = (attempt, baseMs, maxMs) => {
25
+ const exponent = Math.max(0, attempt - 1);
26
+ return Math.min(baseMs * Math.pow(2, exponent), maxMs);
27
+ };
28
+
29
+ //#endregion
30
+ exports.retryDelay = retryDelay;
31
+ exports.withTimeout = withTimeout;
32
+ //# sourceMappingURL=timeout.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeout.cjs","names":["handle: NodeJS.Timeout | undefined"],"sources":["../../src/utils/timeout.ts"],"sourcesContent":["/**\n * Races a promise against a timer and clears the timer however the race settles,\n * so a finished operation never leaves a pending timeout keeping the event loop alive.\n * @param promise - The operation to bound\n * @param ms - Milliseconds to wait before rejecting\n * @param error - Error to reject with when the timer wins\n * @returns The promise's value, or a rejection with `error` on timeout\n */\nexport const withTimeout = <T>(promise: Promise<T>, ms: number, error: Error): Promise<T> => {\n let handle: NodeJS.Timeout | undefined;\n const timeout = new Promise<never>((_resolve, reject) => {\n handle = setTimeout(() => reject(error), ms);\n });\n return Promise.race([promise, timeout]).finally(() => {\n if (handle) {\n clearTimeout(handle);\n }\n });\n};\n\n/**\n * Restart delay for the n-th consecutive failure: exponential from `baseMs`, capped at `maxMs`.\n * @param attempt - 1 for the first restart, 2 for the second, and so on\n */\nexport const retryDelay = (attempt: number, baseMs: number, maxMs: number): number => {\n const exponent = Math.max(0, attempt - 1);\n return Math.min(baseMs * Math.pow(2, exponent), maxMs);\n};\n"],"mappings":";;;;;;;;;;AAQA,MAAa,eAAkB,SAAqB,IAAY,UAA6B;CAC3F,IAAIA;CACJ,MAAM,UAAU,IAAI,SAAgB,UAAU,WAAW;AACvD,WAAS,iBAAiB,OAAO,MAAM,EAAE,GAAG;GAC5C;AACF,QAAO,QAAQ,KAAK,CAAC,SAAS,QAAQ,CAAC,CAAC,cAAc;AACpD,MAAI,OACF,cAAa,OAAO;GAEtB;;;;;;AAOJ,MAAa,cAAc,SAAiB,QAAgB,UAA0B;CACpF,MAAM,WAAW,KAAK,IAAI,GAAG,UAAU,EAAE;AACzC,QAAO,KAAK,IAAI,SAAS,KAAK,IAAI,GAAG,SAAS,EAAE,MAAM"}
@@ -0,0 +1,18 @@
1
+ //#region src/utils/timeout.d.ts
2
+ /**
3
+ * Races a promise against a timer and clears the timer however the race settles,
4
+ * so a finished operation never leaves a pending timeout keeping the event loop alive.
5
+ * @param promise - The operation to bound
6
+ * @param ms - Milliseconds to wait before rejecting
7
+ * @param error - Error to reject with when the timer wins
8
+ * @returns The promise's value, or a rejection with `error` on timeout
9
+ */
10
+ declare const withTimeout: <T>(promise: Promise<T>, ms: number, error: Error) => Promise<T>;
11
+ /**
12
+ * Restart delay for the n-th consecutive failure: exponential from `baseMs`, capped at `maxMs`.
13
+ * @param attempt - 1 for the first restart, 2 for the second, and so on
14
+ */
15
+ declare const retryDelay: (attempt: number, baseMs: number, maxMs: number) => number;
16
+ //#endregion
17
+ export { retryDelay, withTimeout };
18
+ //# sourceMappingURL=timeout.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeout.d.cts","names":[],"sources":["../../src/utils/timeout.ts"],"sourcesContent":[],"mappings":";;AAQA;;;;;;;AAgBa,cAhBA,WAmBZ,EAAA,CAAA,CAAA,CAAA,CAAA,OAAA,EAnBuC,OAmBvC,CAnB+C,CAmB/C,CAAA,EAAA,EAAA,EAAA,MAAA,EAAA,KAAA,EAnBsE,KAmBtE,EAAA,GAnB8E,OAmB9E,CAnBsF,CAmBtF,CAAA;;;;;cAHY"}
@@ -0,0 +1,18 @@
1
+ //#region src/utils/timeout.d.ts
2
+ /**
3
+ * Races a promise against a timer and clears the timer however the race settles,
4
+ * so a finished operation never leaves a pending timeout keeping the event loop alive.
5
+ * @param promise - The operation to bound
6
+ * @param ms - Milliseconds to wait before rejecting
7
+ * @param error - Error to reject with when the timer wins
8
+ * @returns The promise's value, or a rejection with `error` on timeout
9
+ */
10
+ declare const withTimeout: <T>(promise: Promise<T>, ms: number, error: Error) => Promise<T>;
11
+ /**
12
+ * Restart delay for the n-th consecutive failure: exponential from `baseMs`, capped at `maxMs`.
13
+ * @param attempt - 1 for the first restart, 2 for the second, and so on
14
+ */
15
+ declare const retryDelay: (attempt: number, baseMs: number, maxMs: number) => number;
16
+ //#endregion
17
+ export { retryDelay, withTimeout };
18
+ //# sourceMappingURL=timeout.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeout.d.mts","names":[],"sources":["../../src/utils/timeout.ts"],"sourcesContent":[],"mappings":";;AAQA;;;;;;;AAgBa,cAhBA,WAmBZ,EAAA,CAAA,CAAA,CAAA,CAAA,OAAA,EAnBuC,OAmBvC,CAnB+C,CAmB/C,CAAA,EAAA,EAAA,EAAA,MAAA,EAAA,KAAA,EAnBsE,KAmBtE,EAAA,GAnB8E,OAmB9E,CAnBsF,CAmBtF,CAAA;;;;;cAHY"}
@@ -0,0 +1,30 @@
1
+ //#region src/utils/timeout.ts
2
+ /**
3
+ * Races a promise against a timer and clears the timer however the race settles,
4
+ * so a finished operation never leaves a pending timeout keeping the event loop alive.
5
+ * @param promise - The operation to bound
6
+ * @param ms - Milliseconds to wait before rejecting
7
+ * @param error - Error to reject with when the timer wins
8
+ * @returns The promise's value, or a rejection with `error` on timeout
9
+ */
10
+ const withTimeout = (promise, ms, error) => {
11
+ let handle;
12
+ const timeout = new Promise((_resolve, reject) => {
13
+ handle = setTimeout(() => reject(error), ms);
14
+ });
15
+ return Promise.race([promise, timeout]).finally(() => {
16
+ if (handle) clearTimeout(handle);
17
+ });
18
+ };
19
+ /**
20
+ * Restart delay for the n-th consecutive failure: exponential from `baseMs`, capped at `maxMs`.
21
+ * @param attempt - 1 for the first restart, 2 for the second, and so on
22
+ */
23
+ const retryDelay = (attempt, baseMs, maxMs) => {
24
+ const exponent = Math.max(0, attempt - 1);
25
+ return Math.min(baseMs * Math.pow(2, exponent), maxMs);
26
+ };
27
+
28
+ //#endregion
29
+ export { retryDelay, withTimeout };
30
+ //# sourceMappingURL=timeout.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeout.mjs","names":["handle: NodeJS.Timeout | undefined"],"sources":["../../src/utils/timeout.ts"],"sourcesContent":["/**\n * Races a promise against a timer and clears the timer however the race settles,\n * so a finished operation never leaves a pending timeout keeping the event loop alive.\n * @param promise - The operation to bound\n * @param ms - Milliseconds to wait before rejecting\n * @param error - Error to reject with when the timer wins\n * @returns The promise's value, or a rejection with `error` on timeout\n */\nexport const withTimeout = <T>(promise: Promise<T>, ms: number, error: Error): Promise<T> => {\n let handle: NodeJS.Timeout | undefined;\n const timeout = new Promise<never>((_resolve, reject) => {\n handle = setTimeout(() => reject(error), ms);\n });\n return Promise.race([promise, timeout]).finally(() => {\n if (handle) {\n clearTimeout(handle);\n }\n });\n};\n\n/**\n * Restart delay for the n-th consecutive failure: exponential from `baseMs`, capped at `maxMs`.\n * @param attempt - 1 for the first restart, 2 for the second, and so on\n */\nexport const retryDelay = (attempt: number, baseMs: number, maxMs: number): number => {\n const exponent = Math.max(0, attempt - 1);\n return Math.min(baseMs * Math.pow(2, exponent), maxMs);\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,eAAkB,SAAqB,IAAY,UAA6B;CAC3F,IAAIA;CACJ,MAAM,UAAU,IAAI,SAAgB,UAAU,WAAW;AACvD,WAAS,iBAAiB,OAAO,MAAM,EAAE,GAAG;GAC5C;AACF,QAAO,QAAQ,KAAK,CAAC,SAAS,QAAQ,CAAC,CAAC,cAAc;AACpD,MAAI,OACF,cAAa,OAAO;GAEtB;;;;;;AAOJ,MAAa,cAAc,SAAiB,QAAgB,UAA0B;CACpF,MAAM,WAAW,KAAK,IAAI,GAAG,UAAU,EAAE;AACzC,QAAO,KAAK,IAAI,SAAS,KAAK,IAAI,GAAG,SAAS,EAAE,MAAM"}