envio 3.0.0-alpha.1 → 3.0.0-alpha.11

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 (139) hide show
  1. package/README.md +2 -2
  2. package/evm.schema.json +53 -57
  3. package/fuel.schema.json +35 -31
  4. package/index.d.ts +459 -1
  5. package/index.js +4 -0
  6. package/package.json +23 -11
  7. package/rescript.json +4 -1
  8. package/src/Batch.res.mjs +1 -1
  9. package/src/Benchmark.res +394 -0
  10. package/src/Benchmark.res.mjs +398 -0
  11. package/src/ChainFetcher.res +526 -0
  12. package/src/ChainFetcher.res.mjs +343 -0
  13. package/src/ChainManager.res +184 -0
  14. package/src/ChainManager.res.mjs +150 -0
  15. package/src/Config.res +367 -27
  16. package/src/Config.res.mjs +338 -28
  17. package/src/{Indexer.res → Ctx.res} +1 -1
  18. package/src/Ecosystem.res +25 -0
  19. package/src/Ecosystem.res.mjs +29 -0
  20. package/src/Env.res +253 -0
  21. package/src/Env.res.mjs +274 -0
  22. package/src/Envio.gen.ts +9 -1
  23. package/src/Envio.res +12 -9
  24. package/src/EventProcessing.res +476 -0
  25. package/src/EventProcessing.res.mjs +341 -0
  26. package/src/EventRegister.res +4 -15
  27. package/src/EventRegister.res.mjs +3 -9
  28. package/src/EventRegister.resi +2 -8
  29. package/src/FetchState.res +54 -29
  30. package/src/FetchState.res.mjs +62 -35
  31. package/src/GlobalState.res +1163 -0
  32. package/src/GlobalState.res.mjs +1196 -0
  33. package/src/GlobalStateManager.res +68 -0
  34. package/src/GlobalStateManager.res.mjs +75 -0
  35. package/src/GlobalStateManager.resi +7 -0
  36. package/src/HandlerLoader.res +89 -0
  37. package/src/HandlerLoader.res.mjs +79 -0
  38. package/src/Internal.gen.ts +3 -14
  39. package/src/Internal.res +45 -13
  40. package/src/LoadLayer.res +444 -0
  41. package/src/LoadLayer.res.mjs +296 -0
  42. package/src/LoadLayer.resi +32 -0
  43. package/src/LogSelection.res +33 -27
  44. package/src/LogSelection.res.mjs +6 -0
  45. package/src/Logging.res +11 -4
  46. package/src/Logging.res.mjs +14 -6
  47. package/src/Main.res +351 -0
  48. package/src/Main.res.mjs +312 -0
  49. package/src/Persistence.res +1 -2
  50. package/src/PgStorage.gen.ts +10 -0
  51. package/src/PgStorage.res +28 -34
  52. package/src/PgStorage.res.d.mts +5 -0
  53. package/src/PgStorage.res.mjs +27 -27
  54. package/src/Prometheus.res +20 -8
  55. package/src/Prometheus.res.mjs +55 -40
  56. package/src/ReorgDetection.res +6 -10
  57. package/src/ReorgDetection.res.mjs +6 -6
  58. package/src/TestIndexer.res +608 -0
  59. package/src/TestIndexer.res.mjs +456 -0
  60. package/src/TestIndexerProxyStorage.res +210 -0
  61. package/src/TestIndexerProxyStorage.res.mjs +157 -0
  62. package/src/Types.ts +1 -1
  63. package/src/UserContext.res +355 -0
  64. package/src/UserContext.res.mjs +236 -0
  65. package/src/Utils.res +50 -0
  66. package/src/Utils.res.mjs +36 -0
  67. package/src/bindings/ClickHouse.res +31 -1
  68. package/src/bindings/ClickHouse.res.mjs +27 -1
  69. package/src/bindings/DateFns.res +71 -0
  70. package/src/bindings/DateFns.res.mjs +22 -0
  71. package/src/bindings/Ethers.res +27 -67
  72. package/src/bindings/Ethers.res.mjs +18 -70
  73. package/src/bindings/EventSource.res +13 -0
  74. package/src/bindings/EventSource.res.mjs +2 -0
  75. package/src/bindings/NodeJs.res +44 -3
  76. package/src/bindings/NodeJs.res.mjs +11 -3
  77. package/src/bindings/Pino.res +19 -5
  78. package/src/bindings/Pino.res.mjs +10 -4
  79. package/src/bindings/Postgres.gen.ts +8 -0
  80. package/src/bindings/Postgres.res +3 -0
  81. package/src/bindings/Postgres.res.d.mts +5 -0
  82. package/src/bindings/RescriptMocha.res +123 -0
  83. package/src/bindings/RescriptMocha.res.mjs +18 -0
  84. package/src/bindings/Vitest.res +134 -0
  85. package/src/bindings/Vitest.res.mjs +9 -0
  86. package/src/bindings/Yargs.res +8 -0
  87. package/src/bindings/Yargs.res.mjs +2 -0
  88. package/src/db/InternalTable.res +2 -0
  89. package/src/db/InternalTable.res.mjs +1 -1
  90. package/src/sources/Evm.res +87 -0
  91. package/src/sources/Evm.res.mjs +105 -0
  92. package/src/sources/EvmChain.res +90 -0
  93. package/src/sources/EvmChain.res.mjs +57 -0
  94. package/src/sources/Fuel.res +19 -34
  95. package/src/sources/Fuel.res.mjs +34 -16
  96. package/src/sources/FuelSDK.res +38 -0
  97. package/src/sources/FuelSDK.res.mjs +29 -0
  98. package/src/sources/HyperFuel.res +2 -2
  99. package/src/sources/HyperFuel.resi +1 -1
  100. package/src/sources/HyperFuelClient.res +2 -2
  101. package/src/sources/HyperFuelSource.res +13 -9
  102. package/src/sources/HyperFuelSource.res.mjs +10 -6
  103. package/src/sources/HyperSync.res +12 -3
  104. package/src/sources/HyperSync.res.mjs +9 -7
  105. package/src/sources/HyperSync.resi +4 -0
  106. package/src/sources/HyperSyncHeightStream.res +99 -0
  107. package/src/sources/HyperSyncHeightStream.res.mjs +96 -0
  108. package/src/sources/HyperSyncSource.res +68 -169
  109. package/src/sources/HyperSyncSource.res.mjs +78 -156
  110. package/src/sources/Rpc.res +43 -0
  111. package/src/sources/Rpc.res.mjs +31 -0
  112. package/src/sources/RpcSource.res +51 -153
  113. package/src/sources/RpcSource.res.mjs +56 -139
  114. package/src/sources/Source.res +3 -2
  115. package/src/sources/SourceManager.res +183 -108
  116. package/src/sources/SourceManager.res.mjs +162 -99
  117. package/src/sources/SourceManager.resi +4 -5
  118. package/src/sources/Svm.res +72 -0
  119. package/src/sources/Svm.res.mjs +85 -0
  120. package/src/tui/Tui.res +266 -0
  121. package/src/tui/Tui.res.mjs +342 -0
  122. package/src/tui/bindings/Ink.res +376 -0
  123. package/src/tui/bindings/Ink.res.mjs +75 -0
  124. package/src/tui/bindings/Style.res +123 -0
  125. package/src/tui/bindings/Style.res.mjs +2 -0
  126. package/src/tui/components/BufferedProgressBar.res +40 -0
  127. package/src/tui/components/BufferedProgressBar.res.mjs +57 -0
  128. package/src/tui/components/CustomHooks.res +122 -0
  129. package/src/tui/components/CustomHooks.res.mjs +179 -0
  130. package/src/tui/components/Messages.res +41 -0
  131. package/src/tui/components/Messages.res.mjs +75 -0
  132. package/src/tui/components/SyncETA.res +193 -0
  133. package/src/tui/components/SyncETA.res.mjs +269 -0
  134. package/src/tui/components/TuiData.res +46 -0
  135. package/src/tui/components/TuiData.res.mjs +29 -0
  136. package/src/Platform.res +0 -140
  137. package/src/Platform.res.mjs +0 -170
  138. package/src/bindings/Ethers.gen.ts +0 -14
  139. /package/src/{Indexer.res.mjs → Ctx.res.mjs} +0 -0
package/index.d.ts CHANGED
@@ -8,10 +8,15 @@ export type {
8
8
  rateLimit as RateLimit,
9
9
  blockEvent as BlockEvent,
10
10
  fuelBlockEvent as FuelBlockEvent,
11
+ svmOnBlockArgs as SvmOnBlockArgs,
11
12
  onBlockArgs as OnBlockArgs,
12
13
  onBlockOptions as OnBlockOptions,
13
14
  } from "./src/Envio.gen.ts";
14
- export type { EffectCaller } from "./src/Types.ts";
15
+ import type { Address } from "./src/Types.ts";
16
+ export type { EffectCaller, Address } from "./src/Types.ts";
17
+
18
+ /** Utility type to expand/flatten complex types for better IDE display. */
19
+ export type Prettify<T> = { [K in keyof T]: T[K] } & {};
15
20
 
16
21
  import type {
17
22
  effect as Effect,
@@ -108,6 +113,10 @@ export declare namespace S {
108
113
  export type Input<T> = Sury.Input<T>;
109
114
  export type Schema<Output, Input = unknown> = Sury.Schema<Output, Input>;
110
115
  export const string: typeof Sury.string;
116
+ export const address: Sury.Schema<Address, Address>;
117
+ // export const evmChainId: Sury.Schema<EvmChainId, EvmChainId>;
118
+ // export const fuelChainId: Sury.Schema<FuelChainId, FuelChainId>;
119
+ // export const svmChainId: Sury.Schema<SvmChainId, SvmChainId>;
111
120
  export const jsonString: typeof Sury.jsonString;
112
121
  export const boolean: typeof Sury.boolean;
113
122
  export const int32: typeof Sury.int32;
@@ -137,3 +146,452 @@ export declare namespace S {
137
146
  export const assertOrThrow: typeof Sury.assertOrThrow;
138
147
  export const parseOrThrow: typeof Sury.parseOrThrow;
139
148
  }
149
+
150
+ // ============== Indexer Config (Module Augmentation) ==============
151
+
152
+ /**
153
+ * Configuration interface for the indexer.
154
+ * This interface is augmented by generated/envio.d.ts with project-specific config using typeof config.
155
+ *
156
+ * @example
157
+ * // In generated/envio.d.ts:
158
+ * declare module "envio" {
159
+ * interface Global {
160
+ * config: typeof config;
161
+ * }
162
+ * }
163
+ */
164
+ export interface Global {}
165
+
166
+ /**
167
+ * Shape of the indexer configuration.
168
+ * Will be used internally for defineConfig.
169
+ * Currently should match the internal.config.json structure.
170
+ */
171
+ type IndexerConfig = {
172
+ /** The indexer name. */
173
+ name: string;
174
+ /** The indexer description. */
175
+ description?: string;
176
+ /** Path to handlers directory for auto-loading (default: "src/handlers"). */
177
+ handlers?: string;
178
+ /** Multichain mode: ordered or unordered (default: "unordered"). */
179
+ multichain?: "ordered" | "unordered";
180
+ /** Target batch size for event processing (default: 5000). */
181
+ fullBatchSize?: number;
182
+ /** Whether to rollback on chain reorg (default: true). */
183
+ rollbackOnReorg?: boolean;
184
+ /** Whether to save full entity history (default: false). */
185
+ saveFullHistory?: boolean;
186
+ /** Whether raw events are enabled (default: false). */
187
+ rawEvents?: boolean;
188
+ /** EVM ecosystem configuration. */
189
+ evm?: {
190
+ /** Chain configurations keyed by chain name. */
191
+ chains: Record<string, EvmChainConfig>;
192
+ /** Contract configurations keyed by contract name. */
193
+ contracts?: Record<string, EvmContractConfig>;
194
+ /** Address format (default: "checksum"). */
195
+ addressFormat?: "lowercase" | "checksum";
196
+ };
197
+ /** Fuel ecosystem configuration. */
198
+ fuel?: {
199
+ /** Chain configurations keyed by chain name. */
200
+ chains: Record<string, FuelChainConfig>;
201
+ /** Contract configurations keyed by contract name. */
202
+ contracts?: Record<string, FuelContractConfig>;
203
+ };
204
+ /** SVM ecosystem configuration. */
205
+ svm?: {
206
+ /** Chain configurations keyed by chain name. */
207
+ chains: Record<string, SvmChainConfig>;
208
+ };
209
+ };
210
+
211
+ // ============== Contract Types ==============
212
+
213
+ /** EVM contract configuration. */
214
+ type EvmContractConfig = {
215
+ /** The contract ABI. */
216
+ readonly abi: unknown;
217
+ };
218
+
219
+ /** Fuel contract configuration. */
220
+ type FuelContractConfig = {
221
+ /** The contract ABI. */
222
+ readonly abi: unknown;
223
+ };
224
+
225
+ // ============== EVM Types ==============
226
+
227
+ /** EVM chain configuration (for IndexerConfig). */
228
+ type EvmChainConfig<Id extends number = number> = {
229
+ /** The chain ID. */
230
+ readonly id: Id;
231
+ /** The block number indexing starts from. */
232
+ readonly startBlock: number;
233
+ /** The block number indexing stops at (if configured). */
234
+ readonly endBlock?: number;
235
+ /** Number of blocks to keep for reorg handling (default: 200). */
236
+ readonly maxReorgDepth?: number;
237
+ };
238
+
239
+ /** EVM chain value (for runtime Indexer). */
240
+ type EvmChain<
241
+ Id extends number = number,
242
+ ContractName extends string = never
243
+ > = {
244
+ /** The chain ID. */
245
+ readonly id: Id;
246
+ /** The chain name. */
247
+ readonly name: string;
248
+ /** The block number indexing starts from. */
249
+ readonly startBlock: number;
250
+ /** The block number indexing stops at (if configured). */
251
+ readonly endBlock: number | undefined;
252
+ /** Whether the chain has completed initial sync and is processing live events. */
253
+ readonly isLive: boolean;
254
+ } & {
255
+ readonly [K in ContractName]: EvmContract<K>;
256
+ };
257
+
258
+ /** EVM contract (for runtime Indexer). */
259
+ type EvmContract<Name extends string = string> = {
260
+ /** The contract name. */
261
+ readonly name: Name;
262
+ /** The contract ABI. */
263
+ readonly abi: readonly unknown[];
264
+ /** The contract addresses. */
265
+ readonly addresses: readonly Address[];
266
+ };
267
+
268
+ /** Fuel contract (for runtime Indexer). */
269
+ type FuelContract<Name extends string = string> = {
270
+ /** The contract name. */
271
+ readonly name: Name;
272
+ /** The contract ABI. */
273
+ readonly abi: unknown;
274
+ /** The contract addresses. */
275
+ readonly addresses: readonly Address[];
276
+ };
277
+
278
+ // ============== Fuel Types ==============
279
+
280
+ /** Fuel chain configuration (for IndexerConfig). */
281
+ type FuelChainConfig<Id extends number = number> = {
282
+ /** The chain ID. */
283
+ readonly id: Id;
284
+ /** The block number indexing starts from. */
285
+ readonly startBlock: number;
286
+ /** The block number indexing stops at (if configured). */
287
+ readonly endBlock?: number;
288
+ /** Number of blocks to keep for reorg handling (default: 200). */
289
+ readonly maxReorgDepth?: number;
290
+ };
291
+
292
+ /** Fuel chain value (for runtime Indexer). */
293
+ type FuelChain<
294
+ Id extends number = number,
295
+ ContractName extends string = never
296
+ > = {
297
+ /** The chain ID. */
298
+ readonly id: Id;
299
+ /** The chain name. */
300
+ readonly name: string;
301
+ /** The block number indexing starts from. */
302
+ readonly startBlock: number;
303
+ /** The block number indexing stops at (if configured). */
304
+ readonly endBlock: number | undefined;
305
+ /** Whether the chain has completed initial sync and is processing live events. */
306
+ readonly isLive: boolean;
307
+ } & {
308
+ readonly [K in ContractName]: FuelContract<K>;
309
+ };
310
+
311
+ // ============== SVM (Solana) Types ==============
312
+
313
+ /** SVM chain configuration (for IndexerConfig). */
314
+ type SvmChainConfig<Id extends number = number> = {
315
+ /** The chain ID. */
316
+ readonly id: Id;
317
+ /** The block number indexing starts from. */
318
+ readonly startBlock: number;
319
+ /** The block number indexing stops at (if configured). */
320
+ readonly endBlock?: number;
321
+ /** Number of blocks to keep for reorg handling (default: 200). */
322
+ readonly maxReorgDepth?: number;
323
+ };
324
+
325
+ /** SVM chain value (for runtime Indexer). */
326
+ type SvmChain<Id extends number = number> = {
327
+ /** The chain ID. */
328
+ readonly id: Id;
329
+ /** The chain name. */
330
+ readonly name: string;
331
+ /** The block number indexing starts from. */
332
+ readonly startBlock: number;
333
+ /** The block number indexing stops at (if configured). */
334
+ readonly endBlock: number | undefined;
335
+ /** Whether the chain has completed initial sync and is processing live events. */
336
+ readonly isLive: boolean;
337
+ };
338
+
339
+ // ============== Indexer Type ==============
340
+
341
+ /** Minimal type constraint for IndexerFromConfig to allow usage without full IndexerConfig. */
342
+ type IndexerConfigTypes = {
343
+ evm?: {
344
+ chains: Record<string, { id: number }>;
345
+ contracts?: Record<string, {}>;
346
+ };
347
+ fuel?: {
348
+ chains: Record<string, { id: number }>;
349
+ contracts?: Record<string, {}>;
350
+ };
351
+ svm?: { chains: Record<string, { id: number }> };
352
+ entities?: Record<string, object>;
353
+ };
354
+
355
+ // Helper: Check if ecosystem is configured in a given config
356
+ type HasEvm<Config> = "evm" extends keyof Config ? true : false;
357
+ type HasFuel<Config> = "fuel" extends keyof Config ? true : false;
358
+ type HasSvm<Config> = "svm" extends keyof Config ? true : false;
359
+
360
+ // Count ecosystems using tuple length
361
+ type BoolToNum<B extends boolean> = B extends true ? 1 : 0;
362
+ type EcosystemTuple<Config> = [
363
+ ...([BoolToNum<HasEvm<Config>>] extends [1] ? [1] : []),
364
+ ...([BoolToNum<HasFuel<Config>>] extends [1] ? [1] : []),
365
+ ...([BoolToNum<HasSvm<Config>>] extends [1] ? [1] : [])
366
+ ];
367
+ type EcosystemCount<Config> = EcosystemTuple<Config>["length"];
368
+
369
+ // EVM ecosystem type
370
+ type EvmEcosystem<Config extends IndexerConfigTypes> =
371
+ "evm" extends keyof Config
372
+ ? Config["evm"] extends {
373
+ chains: infer Chains;
374
+ contracts?: Record<infer ContractName, any>;
375
+ }
376
+ ? Chains extends Record<string, { id: number }>
377
+ ? {
378
+ /** Array of all EVM chain IDs. */
379
+ readonly chainIds: readonly Chains[keyof Chains]["id"][];
380
+ /** Per-chain configuration keyed by chain name or ID. */
381
+ readonly chains: {
382
+ readonly [K in Chains[keyof Chains]["id"]]: EvmChain<
383
+ K,
384
+ ContractName extends string ? ContractName : never
385
+ >;
386
+ } & {
387
+ readonly [K in keyof Chains]: EvmChain<
388
+ Chains[K]["id"],
389
+ ContractName extends string ? ContractName : never
390
+ >;
391
+ };
392
+ }
393
+ : never
394
+ : never
395
+ : never;
396
+
397
+ // Fuel ecosystem type
398
+ type FuelEcosystem<Config extends IndexerConfigTypes> =
399
+ "fuel" extends keyof Config
400
+ ? Config["fuel"] extends {
401
+ chains: infer Chains;
402
+ contracts?: Record<infer ContractName, any>;
403
+ }
404
+ ? Chains extends Record<string, { id: number }>
405
+ ? {
406
+ /** Array of all Fuel chain IDs. */
407
+ readonly chainIds: readonly Chains[keyof Chains]["id"][];
408
+ /** Per-chain configuration keyed by chain name or ID. */
409
+ readonly chains: {
410
+ readonly [K in Chains[keyof Chains]["id"]]: FuelChain<
411
+ K,
412
+ ContractName extends string ? ContractName : never
413
+ >;
414
+ } & {
415
+ readonly [K in keyof Chains]: FuelChain<
416
+ Chains[K]["id"],
417
+ ContractName extends string ? ContractName : never
418
+ >;
419
+ };
420
+ }
421
+ : never
422
+ : never
423
+ : never;
424
+
425
+ // SVM ecosystem type
426
+ type SvmEcosystem<Config extends IndexerConfigTypes> =
427
+ "svm" extends keyof Config
428
+ ? Config["svm"] extends { chains: infer Chains }
429
+ ? Chains extends Record<string, { id: number }>
430
+ ? {
431
+ /** Array of all SVM chain IDs. */
432
+ readonly chainIds: readonly Chains[keyof Chains]["id"][];
433
+ /** Per-chain configuration keyed by chain name or ID. */
434
+ readonly chains: {
435
+ readonly [K in Chains[keyof Chains]["id"]]: SvmChain<K>;
436
+ } & {
437
+ readonly [K in keyof Chains]: SvmChain<Chains[K]["id"]>;
438
+ };
439
+ }
440
+ : never
441
+ : never
442
+ : never;
443
+
444
+ // Single ecosystem chains (flattened at root level)
445
+ type SingleEcosystemChains<Config extends IndexerConfigTypes> =
446
+ HasEvm<Config> extends true
447
+ ? EvmEcosystem<Config>
448
+ : HasFuel<Config> extends true
449
+ ? FuelEcosystem<Config>
450
+ : HasSvm<Config> extends true
451
+ ? SvmEcosystem<Config>
452
+ : {};
453
+
454
+ // Multi-ecosystem chains (namespaced by ecosystem)
455
+ type MultiEcosystemChains<Config extends IndexerConfigTypes> =
456
+ (HasEvm<Config> extends true
457
+ ? {
458
+ /** EVM ecosystem configuration. */
459
+ readonly evm: EvmEcosystem<Config>;
460
+ }
461
+ : {}) &
462
+ (HasFuel<Config> extends true
463
+ ? {
464
+ /** Fuel ecosystem configuration. */
465
+ readonly fuel: FuelEcosystem<Config>;
466
+ }
467
+ : {}) &
468
+ (HasSvm<Config> extends true
469
+ ? {
470
+ /** SVM ecosystem configuration. */
471
+ readonly svm: SvmEcosystem<Config>;
472
+ }
473
+ : {});
474
+
475
+ /**
476
+ * Indexer type resolved from config, adapting chain properties based on configured ecosystems.
477
+ * - Single ecosystem: chains are at the root level.
478
+ * - Multiple ecosystems: chains are namespaced by ecosystem (evm, fuel, svm).
479
+ */
480
+ export type IndexerFromConfig<Config extends IndexerConfigTypes> = Prettify<
481
+ {
482
+ /** The indexer name from config.yaml. */
483
+ readonly name: string;
484
+ /** The indexer description from config.yaml. */
485
+ readonly description: string | undefined;
486
+ } & (EcosystemCount<Config> extends 1
487
+ ? SingleEcosystemChains<Config>
488
+ : MultiEcosystemChains<Config>)
489
+ >;
490
+
491
+ // ============== Test Indexer Types ==============
492
+
493
+ /** Configuration for a single chain in the test indexer. */
494
+ export type TestIndexerChainConfig = {
495
+ /** The block number to start processing from. */
496
+ startBlock: number;
497
+ /** The block number to stop processing at. */
498
+ endBlock: number;
499
+ };
500
+
501
+ /** Entity change value containing sets and/or deleted IDs. */
502
+ type EntityChangeValue<Entity> = {
503
+ /** Entities that were created or updated. */
504
+ readonly sets?: readonly Entity[];
505
+ /** IDs of entities that were deleted. */
506
+ readonly deleted?: readonly string[];
507
+ };
508
+
509
+ /** A dynamic contract address registration. */
510
+ type AddressRegistration = {
511
+ /** The contract address. */
512
+ readonly address: Address;
513
+ /** The contract name. */
514
+ readonly contract: string;
515
+ };
516
+
517
+ /** Extract entities from config. */
518
+ type ConfigEntities<Config extends IndexerConfigTypes> =
519
+ Config["entities"] extends Record<string, object> ? Config["entities"] : {};
520
+
521
+ /** Entity operations available on test indexer for direct entity manipulation. */
522
+ type EntityOps<Entity> = {
523
+ /** Get an entity by ID. Returns undefined if not found. */
524
+ readonly get: (id: string) => Promise<Entity | undefined>;
525
+ /** Set (create or update) an entity. */
526
+ readonly set: (entity: Entity) => void;
527
+ };
528
+
529
+ /** A single change representing entity modifications at a specific block. */
530
+ type EntityChange<Config extends IndexerConfigTypes> = {
531
+ /** The block where the changes occurred. */
532
+ readonly block: number;
533
+ /** The block hash (if available). */
534
+ readonly blockHash?: string;
535
+ /** The chain ID. */
536
+ readonly chainId: number;
537
+ /** Number of events processed in this block. */
538
+ readonly eventsProcessed: number;
539
+ /** Dynamic contract address registrations for this block. */
540
+ readonly addresses?: {
541
+ readonly sets?: readonly AddressRegistration[];
542
+ };
543
+ } & {
544
+ readonly [K in keyof ConfigEntities<Config>]?: EntityChangeValue<
545
+ ConfigEntities<Config>[K]
546
+ >;
547
+ };
548
+
549
+
550
+ // Helper to extract chain IDs from config for test indexer
551
+ type TestIndexerChainIds<Config extends IndexerConfigTypes> =
552
+ HasEvm<Config> extends true
553
+ ? Config["evm"] extends { chains: infer Chains }
554
+ ? Chains extends Record<string, { id: number }>
555
+ ? Chains[keyof Chains]["id"]
556
+ : never
557
+ : never
558
+ : HasFuel<Config> extends true
559
+ ? Config["fuel"] extends { chains: infer Chains }
560
+ ? Chains extends Record<string, { id: number }>
561
+ ? Chains[keyof Chains]["id"]
562
+ : never
563
+ : never
564
+ : HasSvm<Config> extends true
565
+ ? Config["svm"] extends { chains: infer Chains }
566
+ ? Chains extends Record<string, { id: number }>
567
+ ? Chains[keyof Chains]["id"]
568
+ : never
569
+ : never
570
+ : never;
571
+
572
+ /** Process configuration for the test indexer, with chains keyed by chain ID. */
573
+ export type TestIndexerProcessConfig<Config extends IndexerConfigTypes> = {
574
+ /** Chain configurations keyed by chain ID. Each chain specifies start and end blocks. */
575
+ chains: {
576
+ [K in TestIndexerChainIds<Config>]?: TestIndexerChainConfig;
577
+ };
578
+ };
579
+
580
+ /**
581
+ * Test indexer type resolved from config.
582
+ * Allows running the indexer for specific block ranges and inspecting results.
583
+ */
584
+ export type TestIndexerFromConfig<Config extends IndexerConfigTypes> = {
585
+ /** Process blocks for the specified chains and return progress with checkpoints and changes. */
586
+ process: (
587
+ config: Prettify<TestIndexerProcessConfig<Config>>
588
+ ) => Promise<{
589
+ /** Changes happened during the processing. */
590
+ readonly changes: readonly EntityChange<Config>[];
591
+ }>;
592
+ } & {
593
+ /** Entity operations for direct manipulation outside of handlers. */
594
+ readonly [K in keyof ConfigEntities<Config>]: EntityOps<
595
+ ConfigEntities<Config>[K]
596
+ >;
597
+ };
package/index.js CHANGED
@@ -12,6 +12,10 @@ export * from "./src/Envio.res.mjs";
12
12
  // Important! Should match the index.d.ts file
13
13
  export const S = {
14
14
  string: Sury.string,
15
+ address: Sury.string,
16
+ evmChainId: Sury.number,
17
+ fuelChainId: Sury.number,
18
+ svmChainId: Sury.number,
15
19
  jsonString: Sury.jsonString,
16
20
  boolean: Sury.boolean,
17
21
  int32: Sury.int32,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "envio",
3
- "version": "v3.0.0-alpha.1",
3
+ "version": "v3.0.0-alpha.11",
4
4
  "type": "module",
5
5
  "description": "A latency and sync speed optimized, developer friendly blockchain data indexer.",
6
6
  "bin": "./bin.js",
@@ -29,23 +29,35 @@
29
29
  "node": ">=22.0.0"
30
30
  },
31
31
  "optionalDependencies": {
32
- "envio-linux-x64": "v3.0.0-alpha.1",
33
- "envio-linux-arm64": "v3.0.0-alpha.1",
34
- "envio-darwin-x64": "v3.0.0-alpha.1",
35
- "envio-darwin-arm64": "v3.0.0-alpha.1"
32
+ "envio-linux-x64": "v3.0.0-alpha.11",
33
+ "envio-linux-arm64": "v3.0.0-alpha.11",
34
+ "envio-darwin-x64": "v3.0.0-alpha.11",
35
+ "envio-darwin-arm64": "v3.0.0-alpha.11"
36
36
  },
37
37
  "dependencies": {
38
38
  "@clickhouse/client": "1.12.1",
39
- "@envio-dev/hypersync-client": "0.7.0",
39
+ "@elastic/ecs-pino-format": "1.4.0",
40
40
  "@envio-dev/hyperfuel-client": "1.2.2",
41
+ "@envio-dev/hypersync-client": "0.7.0",
42
+ "bignumber.js": "9.1.2",
43
+ "eventsource": "4.1.0",
44
+ "express": "4.19.2",
45
+ "pino": "10.1.0",
46
+ "pino-pretty": "13.1.3",
47
+ "prom-client": "15.0.0",
48
+ "yargs": "17.7.2",
41
49
  "rescript": "11.1.3",
42
50
  "rescript-schema": "9.3.4",
43
51
  "viem": "2.21.0",
44
- "bignumber.js": "9.1.2",
45
- "pino": "8.16.1",
46
- "pino-pretty": "10.2.3",
47
- "@elastic/ecs-pino-format": "1.4.0",
48
- "prom-client": "15.0.0"
52
+ "rescript-envsafe": "5.0.0",
53
+ "dotenv": "16.4.5",
54
+ "date-fns": "3.3.1",
55
+ "@rescript/react": "0.14.0",
56
+ "ink": "6.5.1",
57
+ "ink-big-text": "2.0.0",
58
+ "ink-spinner": "5.0.0",
59
+ "postgres": "3.4.8",
60
+ "tsx": "4.21.0"
49
61
  },
50
62
  "files": [
51
63
  "bin.js",
package/rescript.json CHANGED
@@ -19,6 +19,9 @@
19
19
  "generatedFileExtension": ".gen.ts",
20
20
  "moduleResolution": "node16"
21
21
  },
22
- "bs-dependencies": ["rescript-schema"],
22
+ "jsx": {
23
+ "version": 4
24
+ },
25
+ "bs-dependencies": ["rescript-schema", "@rescript/react", "rescript-envsafe"],
23
26
  "bsc-flags": ["-open RescriptSchema"]
24
27
  }
package/src/Batch.res.mjs CHANGED
@@ -80,7 +80,7 @@ function getProgressedChainsById(chainsBeforeBatch, batchSizePerChain, progressB
80
80
  var progressedChain;
81
81
  if (batchSize !== undefined) {
82
82
  var leftItems = fetchState.buffer.slice(batchSize);
83
- progressedChain = getChainAfterBatchIfProgressed(chainBeforeBatch, progressBlockNumberAfterBatch, FetchState.updateInternal(fetchState, undefined, undefined, undefined, leftItems, undefined), batchSize);
83
+ progressedChain = getChainAfterBatchIfProgressed(chainBeforeBatch, progressBlockNumberAfterBatch, FetchState.updateInternal(fetchState, undefined, undefined, undefined, leftItems, undefined, undefined), batchSize);
84
84
  } else {
85
85
  progressedChain = getChainAfterBatchIfProgressed(chainBeforeBatch, progressBlockNumberAfterBatch, chainBeforeBatch.fetchState, 0);
86
86
  }