envio 3.0.0-alpha.2 → 3.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +2 -2
  2. package/evm.schema.json +44 -34
  3. package/fuel.schema.json +32 -21
  4. package/index.d.ts +4 -1
  5. package/index.js +1 -0
  6. package/package.json +7 -6
  7. package/src/Batch.res.mjs +1 -1
  8. package/src/Benchmark.res +394 -0
  9. package/src/Benchmark.res.mjs +398 -0
  10. package/src/ChainFetcher.res +459 -0
  11. package/src/ChainFetcher.res.mjs +281 -0
  12. package/src/ChainManager.res +179 -0
  13. package/src/ChainManager.res.mjs +139 -0
  14. package/src/Config.res +15 -1
  15. package/src/Config.res.mjs +28 -5
  16. package/src/Ecosystem.res +9 -124
  17. package/src/Ecosystem.res.mjs +19 -160
  18. package/src/Env.res +0 -1
  19. package/src/Env.res.mjs +0 -3
  20. package/src/Envio.gen.ts +9 -1
  21. package/src/Envio.res +12 -9
  22. package/src/EventProcessing.res +476 -0
  23. package/src/EventProcessing.res.mjs +341 -0
  24. package/src/FetchState.res +54 -29
  25. package/src/FetchState.res.mjs +62 -35
  26. package/src/GlobalState.res +1169 -0
  27. package/src/GlobalState.res.mjs +1196 -0
  28. package/src/Internal.res +43 -1
  29. package/src/LoadLayer.res +444 -0
  30. package/src/LoadLayer.res.mjs +296 -0
  31. package/src/LoadLayer.resi +32 -0
  32. package/src/Prometheus.res +8 -8
  33. package/src/Prometheus.res.mjs +10 -10
  34. package/src/ReorgDetection.res +6 -10
  35. package/src/ReorgDetection.res.mjs +6 -6
  36. package/src/Types.ts +1 -1
  37. package/src/UserContext.res +356 -0
  38. package/src/UserContext.res.mjs +238 -0
  39. package/src/Utils.res +15 -0
  40. package/src/Utils.res.mjs +18 -0
  41. package/src/bindings/ClickHouse.res +31 -1
  42. package/src/bindings/ClickHouse.res.mjs +27 -1
  43. package/src/bindings/DateFns.res +71 -0
  44. package/src/bindings/DateFns.res.mjs +22 -0
  45. package/src/bindings/Ethers.res +27 -63
  46. package/src/bindings/Ethers.res.mjs +18 -65
  47. package/src/sources/Evm.res +87 -0
  48. package/src/sources/Evm.res.mjs +105 -0
  49. package/src/sources/EvmChain.res +95 -0
  50. package/src/sources/EvmChain.res.mjs +61 -0
  51. package/src/sources/Fuel.res +19 -34
  52. package/src/sources/Fuel.res.mjs +34 -16
  53. package/src/sources/FuelSDK.res +37 -0
  54. package/src/sources/FuelSDK.res.mjs +29 -0
  55. package/src/sources/HyperFuel.res +2 -2
  56. package/src/sources/HyperFuel.resi +1 -1
  57. package/src/sources/HyperFuelClient.res +2 -2
  58. package/src/sources/HyperFuelSource.res +8 -8
  59. package/src/sources/HyperFuelSource.res.mjs +5 -5
  60. package/src/sources/HyperSyncHeightStream.res +28 -110
  61. package/src/sources/HyperSyncHeightStream.res.mjs +30 -63
  62. package/src/sources/HyperSyncSource.res +16 -18
  63. package/src/sources/HyperSyncSource.res.mjs +25 -25
  64. package/src/sources/Rpc.res +43 -0
  65. package/src/sources/Rpc.res.mjs +31 -0
  66. package/src/sources/RpcSource.res +13 -8
  67. package/src/sources/RpcSource.res.mjs +12 -7
  68. package/src/sources/Source.res +3 -2
  69. package/src/sources/SourceManager.res +183 -108
  70. package/src/sources/SourceManager.res.mjs +162 -99
  71. package/src/sources/SourceManager.resi +4 -5
  72. package/src/sources/Svm.res +59 -0
  73. package/src/sources/Svm.res.mjs +79 -0
  74. package/src/bindings/Ethers.gen.ts +0 -14
package/README.md CHANGED
@@ -14,11 +14,11 @@ HyperIndex is a fast, developer-friendly multichain indexer, optimized for both
14
14
  - **[Indexer auto-generation](https://docs.envio.dev/docs/HyperIndex/contract-import)** – Generate Indexers directly from smart contract addresses
15
15
  - **High performance** – Historical backfills at over 10,000+ events per second ([fastest in market](https://docs.envio.dev/blog/indexer-benchmarking-results))
16
16
  - **Local development** – Full-featured local environment with Docker
17
- - **[Multichain indexing](https://docs.envio.dev/docs/HyperIndex/multichain-indexing)** – Index any EVM-compatible blockchain and Fuel (simultaneously)
17
+ - **[Multichain indexing](https://docs.envio.dev/docs/HyperIndex/multichain-indexing)** – Index any EVM-, SVM-, or Fuel-compatible blockchain
18
18
  - **Real-time indexing** – Instantly track blockchain events
19
19
  - **[Reorg support](https://docs.envio.dev/docs/HyperIndex/reorgs-support)** – Graceful handling of blockchain reorganizations
20
20
  - **GraphQL API** – Easy-to-query indexed data
21
- - **Flexible language support** – JavaScript, TypeScript, and ReScript
21
+ - **Flexible language support** – TypeScript, JavaScript, and ReScript
22
22
  - **Factory contract support** – Index data from 1M+ dynamically registered contracts seamlessly
23
23
  - **On-chain & off-chain data integration** – Easily combine multiple data sources
24
24
  - **[Self-hosted & managed options](https://docs.envio.dev/docs/HyperIndex/hosted-service)** – Run your own setup or use HyperIndex hosted services
package/evm.schema.json CHANGED
@@ -15,17 +15,6 @@
15
15
  "description": "Name of the project",
16
16
  "type": "string"
17
17
  },
18
- "ecosystem": {
19
- "description": "Ecosystem of the project.",
20
- "anyOf": [
21
- {
22
- "$ref": "#/$defs/EcosystemTag"
23
- },
24
- {
25
- "type": "null"
26
- }
27
- ]
28
- },
29
18
  "schema": {
30
19
  "description": "Custom path to schema.graphql file",
31
20
  "type": [
@@ -40,6 +29,33 @@
40
29
  "null"
41
30
  ]
42
31
  },
32
+ "handlers": {
33
+ "description": "Optional relative path to handlers directory for auto-loading. Defaults to 'src/handlers' if not specified.",
34
+ "type": [
35
+ "string",
36
+ "null"
37
+ ]
38
+ },
39
+ "full_batch_size": {
40
+ "description": "Target number of events to be processed per batch. Set it to smaller number if you have many Effect API calls which are slow to resolve and can't be batched. (Default: 5000)",
41
+ "type": [
42
+ "integer",
43
+ "null"
44
+ ],
45
+ "format": "uint64",
46
+ "minimum": 0
47
+ },
48
+ "ecosystem": {
49
+ "description": "Ecosystem of the project.",
50
+ "anyOf": [
51
+ {
52
+ "$ref": "#/$defs/EcosystemTag"
53
+ },
54
+ {
55
+ "type": "null"
56
+ }
57
+ ]
58
+ },
43
59
  "contracts": {
44
60
  "description": "Global contract definitions that must contain all definitions except addresses. You can share a single handler/abi/event definitions for contracts across multiple chains.",
45
61
  "type": [
@@ -54,7 +70,7 @@
54
70
  "description": "Configuration of the blockchain chains that the project is deployed on.",
55
71
  "type": "array",
56
72
  "items": {
57
- "$ref": "#/$defs/Network"
73
+ "$ref": "#/$defs/Chain"
58
74
  }
59
75
  },
60
76
  "multichain": {
@@ -121,13 +137,6 @@
121
137
  "type": "null"
122
138
  }
123
139
  ]
124
- },
125
- "handlers": {
126
- "description": "Optional relative path to handlers directory for auto-loading. Defaults to 'src/handlers' if not specified.",
127
- "type": [
128
- "string",
129
- "null"
130
- ]
131
140
  }
132
141
  },
133
142
  "additionalProperties": false,
@@ -259,7 +268,6 @@
259
268
  "root",
260
269
  "status",
261
270
  "yParity",
262
- "chainId",
263
271
  "accessList",
264
272
  "maxFeePerBlobGas",
265
273
  "blobVersionedHashes",
@@ -301,17 +309,17 @@
301
309
  "mixHash"
302
310
  ]
303
311
  },
304
- "Network": {
312
+ "Chain": {
305
313
  "type": "object",
306
314
  "properties": {
307
315
  "id": {
308
- "description": "The public blockchain network ID.",
316
+ "description": "The public blockchain chain ID.",
309
317
  "type": "integer",
310
318
  "format": "uint64",
311
319
  "minimum": 0
312
320
  },
313
321
  "rpc_config": {
314
- "description": "RPC configuration for utilizing as the network's data-source. Typically optional for chains with HyperSync support, which is highly recommended. HyperSync dramatically enhances performance, providing up to a 1000x speed boost over traditional RPC.",
322
+ "description": "RPC configuration for utilizing as the chain's data-source. Typically optional for chains with HyperSync support, which is highly recommended. HyperSync dramatically enhances performance, providing up to a 1000x speed boost over traditional RPC.",
315
323
  "anyOf": [
316
324
  {
317
325
  "$ref": "#/$defs/RpcConfig"
@@ -322,10 +330,10 @@
322
330
  ]
323
331
  },
324
332
  "rpc": {
325
- "description": "RPC configuration for your indexer. If not specified otherwise, for networks supported by HyperSync, RPC serves as a fallback for added reliability. For others, it acts as the primary data-source. HyperSync offers significant performance improvements, up to a 1000x faster than traditional RPC.",
333
+ "description": "RPC configuration for your indexer. If not specified otherwise, for chains supported by HyperSync, RPC serves as a fallback for added reliability. For others, it acts as the primary data-source. HyperSync offers significant performance improvements, up to a 1000x faster than traditional RPC.",
326
334
  "anyOf": [
327
335
  {
328
- "$ref": "#/$defs/NetworkRpc"
336
+ "$ref": "#/$defs/RpcSelection"
329
337
  },
330
338
  {
331
339
  "type": "null"
@@ -343,7 +351,7 @@
343
351
  }
344
352
  ]
345
353
  },
346
- "confirmed_block_threshold": {
354
+ "max_reorg_depth": {
347
355
  "description": "The number of blocks from the head that the indexer should account for in case of reorgs.",
348
356
  "type": [
349
357
  "integer",
@@ -367,18 +375,20 @@
367
375
  "minimum": 0
368
376
  },
369
377
  "contracts": {
370
- "description": "All the contracts that should be indexed on the given network",
371
- "type": "array",
378
+ "description": "All the contracts that should be indexed on the given chain",
379
+ "type": [
380
+ "array",
381
+ "null"
382
+ ],
372
383
  "items": {
373
- "$ref": "#/$defs/NetworkContract_for_ContractConfig"
384
+ "$ref": "#/$defs/ChainContract_for_ContractConfig"
374
385
  }
375
386
  }
376
387
  },
377
388
  "additionalProperties": false,
378
389
  "required": [
379
390
  "id",
380
- "start_block",
381
- "contracts"
391
+ "start_block"
382
392
  ]
383
393
  },
384
394
  "RpcConfig": {
@@ -466,7 +476,7 @@
466
476
  "url"
467
477
  ]
468
478
  },
469
- "NetworkRpc": {
479
+ "RpcSelection": {
470
480
  "anyOf": [
471
481
  {
472
482
  "type": "string"
@@ -594,7 +604,7 @@
594
604
  "url"
595
605
  ]
596
606
  },
597
- "NetworkContract_for_ContractConfig": {
607
+ "ChainContract_for_ContractConfig": {
598
608
  "type": "object",
599
609
  "properties": {
600
610
  "name": {
@@ -606,7 +616,7 @@
606
616
  "$ref": "#/$defs/Addresses"
607
617
  },
608
618
  "start_block": {
609
- "description": "The block at which the indexer should start ingesting data for this specific contract. If not specified, uses the network start_block. Can be greater than the network start_block for more specific indexing.",
619
+ "description": "The block at which the indexer should start ingesting data for this specific contract. If not specified, uses the chain start_block. Can be greater than the chain start_block for more specific indexing.",
610
620
  "type": [
611
621
  "integer",
612
622
  "null"
package/fuel.schema.json CHANGED
@@ -15,10 +15,6 @@
15
15
  "description": "Name of the project",
16
16
  "type": "string"
17
17
  },
18
- "ecosystem": {
19
- "description": "Ecosystem of the project.",
20
- "$ref": "#/$defs/EcosystemTag"
21
- },
22
18
  "schema": {
23
19
  "description": "Custom path to schema.graphql file",
24
20
  "type": [
@@ -33,6 +29,26 @@
33
29
  "null"
34
30
  ]
35
31
  },
32
+ "handlers": {
33
+ "description": "Optional relative path to handlers directory for auto-loading. Defaults to 'src/handlers' if not specified.",
34
+ "type": [
35
+ "string",
36
+ "null"
37
+ ]
38
+ },
39
+ "full_batch_size": {
40
+ "description": "Target number of events to be processed per batch. Set it to smaller number if you have many Effect API calls which are slow to resolve and can't be batched. (Default: 5000)",
41
+ "type": [
42
+ "integer",
43
+ "null"
44
+ ],
45
+ "format": "uint64",
46
+ "minimum": 0
47
+ },
48
+ "ecosystem": {
49
+ "description": "Ecosystem of the project.",
50
+ "$ref": "#/$defs/EcosystemTag"
51
+ },
36
52
  "contracts": {
37
53
  "description": "Global contract definitions that must contain all definitions except addresses. You can share a single handler/abi/event definitions for contracts across multiple chains.",
38
54
  "type": [
@@ -47,7 +63,7 @@
47
63
  "description": "Configuration of the blockchain chains that the project is deployed on.",
48
64
  "type": "array",
49
65
  "items": {
50
- "$ref": "#/$defs/Network"
66
+ "$ref": "#/$defs/Chain"
51
67
  }
52
68
  },
53
69
  "raw_events": {
@@ -56,13 +72,6 @@
56
72
  "boolean",
57
73
  "null"
58
74
  ]
59
- },
60
- "handlers": {
61
- "description": "Optional relative path to handlers directory for auto-loading. Defaults to 'src/handlers' if not specified.",
62
- "type": [
63
- "string",
64
- "null"
65
- ]
66
75
  }
67
76
  },
68
77
  "additionalProperties": false,
@@ -152,11 +161,11 @@
152
161
  "call"
153
162
  ]
154
163
  },
155
- "Network": {
164
+ "Chain": {
156
165
  "type": "object",
157
166
  "properties": {
158
167
  "id": {
159
- "description": "Public chain/network id",
168
+ "description": "Public chain id",
160
169
  "type": "integer",
161
170
  "format": "uint64",
162
171
  "minimum": 0
@@ -188,18 +197,20 @@
188
197
  ]
189
198
  },
190
199
  "contracts": {
191
- "description": "All the contracts that should be indexed on the given network",
192
- "type": "array",
200
+ "description": "All the contracts that should be indexed on the given chain",
201
+ "type": [
202
+ "array",
203
+ "null"
204
+ ],
193
205
  "items": {
194
- "$ref": "#/$defs/NetworkContract_for_ContractConfig"
206
+ "$ref": "#/$defs/ChainContract_for_ContractConfig"
195
207
  }
196
208
  }
197
209
  },
198
210
  "additionalProperties": false,
199
211
  "required": [
200
212
  "id",
201
- "start_block",
202
- "contracts"
213
+ "start_block"
203
214
  ]
204
215
  },
205
216
  "HyperfuelConfig": {
@@ -215,7 +226,7 @@
215
226
  "url"
216
227
  ]
217
228
  },
218
- "NetworkContract_for_ContractConfig": {
229
+ "ChainContract_for_ContractConfig": {
219
230
  "type": "object",
220
231
  "properties": {
221
232
  "name": {
@@ -227,7 +238,7 @@
227
238
  "$ref": "#/$defs/Addresses"
228
239
  },
229
240
  "start_block": {
230
- "description": "The block at which the indexer should start ingesting data for this specific contract. If not specified, uses the network start_block. Can be greater than the network start_block for more specific indexing.",
241
+ "description": "The block at which the indexer should start ingesting data for this specific contract. If not specified, uses the chain start_block. Can be greater than the chain start_block for more specific indexing.",
231
242
  "type": [
232
243
  "integer",
233
244
  "null"
package/index.d.ts CHANGED
@@ -8,10 +8,12 @@ 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";
15
17
 
16
18
  import type {
17
19
  effect as Effect,
@@ -108,6 +110,7 @@ export declare namespace S {
108
110
  export type Input<T> = Sury.Input<T>;
109
111
  export type Schema<Output, Input = unknown> = Sury.Schema<Output, Input>;
110
112
  export const string: typeof Sury.string;
113
+ export const address: Sury.Schema<Address, Address>;
111
114
  export const jsonString: typeof Sury.jsonString;
112
115
  export const boolean: typeof Sury.boolean;
113
116
  export const int32: typeof Sury.int32;
package/index.js CHANGED
@@ -12,6 +12,7 @@ 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,
15
16
  jsonString: Sury.jsonString,
16
17
  boolean: Sury.boolean,
17
18
  int32: Sury.int32,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "envio",
3
- "version": "v3.0.0-alpha.2",
3
+ "version": "v3.0.0-alpha.4",
4
4
  "type": "module",
5
5
  "description": "A latency and sync speed optimized, developer friendly blockchain data indexer.",
6
6
  "bin": "./bin.js",
@@ -29,10 +29,10 @@
29
29
  "node": ">=22.0.0"
30
30
  },
31
31
  "optionalDependencies": {
32
- "envio-linux-x64": "v3.0.0-alpha.2",
33
- "envio-linux-arm64": "v3.0.0-alpha.2",
34
- "envio-darwin-x64": "v3.0.0-alpha.2",
35
- "envio-darwin-arm64": "v3.0.0-alpha.2"
32
+ "envio-linux-x64": "v3.0.0-alpha.4",
33
+ "envio-linux-arm64": "v3.0.0-alpha.4",
34
+ "envio-darwin-x64": "v3.0.0-alpha.4",
35
+ "envio-darwin-arm64": "v3.0.0-alpha.4"
36
36
  },
37
37
  "dependencies": {
38
38
  "@clickhouse/client": "1.12.1",
@@ -48,7 +48,8 @@
48
48
  "rescript-schema": "9.3.4",
49
49
  "viem": "2.21.0",
50
50
  "rescript-envsafe": "5.0.0",
51
- "dotenv": "16.4.5"
51
+ "dotenv": "16.4.5",
52
+ "date-fns": "3.3.1"
52
53
  },
53
54
  "files": [
54
55
  "bin.js",
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
  }