envio 2.32.3 → 3.0.0-alpha.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 (115) hide show
  1. package/bin.js +5 -3
  2. package/evm.schema.json +23 -6
  3. package/fuel.schema.json +17 -5
  4. package/index.d.ts +1 -27
  5. package/index.js +9 -6
  6. package/package.json +12 -7
  7. package/rescript.json +4 -3
  8. package/src/{Address.res.js → Address.res.mjs} +7 -6
  9. package/src/Batch.res +4 -4
  10. package/src/{Batch.res.js → Batch.res.mjs} +19 -18
  11. package/src/{ChainMap.res.js → ChainMap.res.mjs} +20 -19
  12. package/src/Change.res +9 -0
  13. package/src/Config.res +5 -5
  14. package/src/{Config.res.js → Config.res.mjs} +13 -10
  15. package/src/Envio.gen.ts +4 -17
  16. package/src/Envio.res +13 -38
  17. package/src/{Envio.res.js → Envio.res.mjs} +5 -16
  18. package/src/{ErrorHandling.res.js → ErrorHandling.res.mjs} +10 -9
  19. package/src/EventRegister.res +10 -11
  20. package/src/{EventRegister.res.js → EventRegister.res.mjs} +33 -26
  21. package/src/EventRegister.resi +2 -1
  22. package/src/{EventUtils.res.js → EventUtils.res.mjs} +10 -9
  23. package/src/{EvmTypes.res.js → EvmTypes.res.mjs} +5 -4
  24. package/src/{FetchState.res.js → FetchState.res.mjs} +44 -43
  25. package/src/{Hasura.res.js → Hasura.res.mjs} +25 -24
  26. package/src/InMemoryStore.res +7 -15
  27. package/src/{InMemoryStore.res.js → InMemoryStore.res.mjs} +21 -22
  28. package/src/InMemoryTable.res +50 -35
  29. package/src/{InMemoryTable.res.js → InMemoryTable.res.mjs} +73 -104
  30. package/src/Internal.gen.ts +1 -5
  31. package/src/Internal.res +29 -40
  32. package/src/Internal.res.mjs +58 -0
  33. package/src/{LazyLoader.res.js → LazyLoader.res.mjs} +14 -13
  34. package/src/{LoadManager.res.js → LoadManager.res.mjs} +11 -10
  35. package/src/{LogSelection.res.js → LogSelection.res.mjs} +14 -13
  36. package/src/{Logging.res.js → Logging.res.mjs} +37 -36
  37. package/src/Persistence.res +190 -38
  38. package/src/Persistence.res.mjs +213 -0
  39. package/src/PgStorage.res +700 -14
  40. package/src/{PgStorage.res.js → PgStorage.res.mjs} +478 -65
  41. package/src/Platform.res +140 -0
  42. package/src/Platform.res.mjs +170 -0
  43. package/src/Prometheus.res +41 -0
  44. package/src/{Prometheus.res.js → Prometheus.res.mjs} +106 -60
  45. package/src/{ReorgDetection.res.js → ReorgDetection.res.mjs} +12 -11
  46. package/src/SafeCheckpointTracking.res +5 -4
  47. package/src/{SafeCheckpointTracking.res.js → SafeCheckpointTracking.res.mjs} +6 -5
  48. package/src/Sink.res +47 -0
  49. package/src/Sink.res.mjs +37 -0
  50. package/src/{TableIndices.res.js → TableIndices.res.mjs} +8 -7
  51. package/src/{Throttler.res.js → Throttler.res.mjs} +7 -6
  52. package/src/{Time.res.js → Time.res.mjs} +8 -7
  53. package/src/{TopicFilter.res.js → TopicFilter.res.mjs} +18 -17
  54. package/src/Utils.res +42 -0
  55. package/src/{Utils.res.js → Utils.res.mjs} +71 -34
  56. package/src/bindings/BigDecimal.gen.ts +2 -2
  57. package/src/bindings/BigDecimal.res +5 -5
  58. package/src/bindings/BigDecimal.res.d.mts +5 -0
  59. package/src/bindings/{BigDecimal.res.js → BigDecimal.res.mjs} +10 -9
  60. package/src/bindings/BigInt.gen.ts +2 -2
  61. package/src/bindings/BigInt.res.d.mts +5 -0
  62. package/src/bindings/{BigInt.res.js → BigInt.res.mjs} +25 -24
  63. package/src/bindings/ClickHouse.res +387 -0
  64. package/src/bindings/ClickHouse.res.mjs +275 -0
  65. package/src/bindings/Ethers.gen.ts +2 -2
  66. package/src/bindings/Ethers.res.d.mts +5 -0
  67. package/src/bindings/{Ethers.res.js → Ethers.res.mjs} +18 -17
  68. package/src/bindings/Express.res.mjs +2 -0
  69. package/src/bindings/{Hrtime.res.js → Hrtime.res.mjs} +13 -12
  70. package/src/bindings/{Lodash.res.js → Lodash.res.mjs} +4 -3
  71. package/src/bindings/NodeJs.res +13 -1
  72. package/src/bindings/NodeJs.res.mjs +48 -0
  73. package/src/bindings/Pino.res +4 -4
  74. package/src/bindings/{Pino.res.js → Pino.res.mjs} +16 -15
  75. package/src/bindings/Postgres.res +17 -2
  76. package/src/bindings/{Postgres.res.js → Postgres.res.mjs} +4 -3
  77. package/src/bindings/{PromClient.res.js → PromClient.res.mjs} +6 -5
  78. package/src/bindings/{Promise.res.js → Promise.res.mjs} +6 -5
  79. package/src/bindings/{SDSL.res.js → SDSL.res.mjs} +3 -2
  80. package/src/bindings/{Viem.res.js → Viem.res.mjs} +9 -8
  81. package/src/bindings/vendored-lodash-fns.js +3 -35
  82. package/src/db/EntityHistory.res +33 -156
  83. package/src/db/EntityHistory.res.mjs +121 -0
  84. package/src/db/InternalTable.gen.ts +2 -2
  85. package/src/db/InternalTable.res +55 -56
  86. package/src/db/{InternalTable.res.js → InternalTable.res.mjs} +68 -71
  87. package/src/db/{Schema.res.js → Schema.res.mjs} +10 -9
  88. package/src/db/Table.res +86 -22
  89. package/src/db/{Table.res.js → Table.res.mjs} +108 -40
  90. package/src/sources/{EventRouter.res.js → EventRouter.res.mjs} +17 -16
  91. package/src/sources/{Fuel.res.js → Fuel.res.mjs} +6 -5
  92. package/src/sources/{HyperFuel.res.js → HyperFuel.res.mjs} +14 -13
  93. package/src/sources/{HyperFuelClient.res.js → HyperFuelClient.res.mjs} +7 -6
  94. package/src/sources/{HyperFuelSource.res.js → HyperFuelSource.res.mjs} +28 -27
  95. package/src/sources/{HyperSync.res.js → HyperSync.res.mjs} +21 -20
  96. package/src/sources/HyperSyncClient.gen.ts +1 -1
  97. package/src/sources/HyperSyncClient.res +78 -20
  98. package/src/sources/{HyperSyncClient.res.js → HyperSyncClient.res.mjs} +32 -15
  99. package/src/sources/{HyperSyncJsonApi.res.js → HyperSyncJsonApi.res.mjs} +10 -9
  100. package/src/sources/HyperSyncSource.res +77 -9
  101. package/src/sources/{HyperSyncSource.res.js → HyperSyncSource.res.mjs} +99 -38
  102. package/src/sources/{Rpc.res.js → Rpc.res.mjs} +16 -15
  103. package/src/sources/{RpcSource.res.js → RpcSource.res.mjs} +40 -39
  104. package/src/sources/Source.res +1 -1
  105. package/src/sources/{Source.res.js → Source.res.mjs} +4 -3
  106. package/src/sources/SourceManager.res +12 -1
  107. package/src/sources/{SourceManager.res.js → SourceManager.res.mjs} +32 -21
  108. package/src/sources/vendored-fuel-abi-coder.js +94 -149
  109. package/src/vendored/{Rest.res.js → Rest.res.mjs} +12 -11
  110. package/src/Internal.res.js +0 -62
  111. package/src/Persistence.res.js +0 -159
  112. package/src/bindings/NodeJs.res.js +0 -35
  113. package/src/db/EntityHistory.res.js +0 -195
  114. /package/src/{Indexer.res.js → Change.res.mjs} +0 -0
  115. /package/src/{bindings/Express.res.js → Indexer.res.mjs} +0 -0
package/bin.js CHANGED
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  //@ts-check
3
- "use strict";
4
3
 
5
- const { spawnSync } = require("child_process");
4
+ import { spawnSync } from "child_process";
5
+ import { createRequire } from "module";
6
+
7
+ const require = createRequire(import.meta.url);
6
8
 
7
9
  /**
8
10
  * Returns the executable path for envio located inside node_modules
@@ -15,7 +17,7 @@ const { spawnSync } = require("child_process");
15
17
  function getExePath() {
16
18
  const arch = process.arch;
17
19
  /**
18
- * @type string
20
+ * @type {string}
19
21
  */
20
22
  let os = process.platform;
21
23
  let extension = "";
package/evm.schema.json CHANGED
@@ -124,6 +124,13 @@
124
124
  "type": "null"
125
125
  }
126
126
  ]
127
+ },
128
+ "handlers": {
129
+ "description": "Optional relative path to handlers directory for auto-loading. Defaults to 'src/handlers' if not specified.",
130
+ "type": [
131
+ "string",
132
+ "null"
133
+ ]
127
134
  }
128
135
  },
129
136
  "additionalProperties": false,
@@ -153,8 +160,11 @@
153
160
  ]
154
161
  },
155
162
  "handler": {
156
- "description": "The relative path to a file where handlers are registered for the given contract",
157
- "type": "string"
163
+ "description": "Optional relative path to a file where handlers are registered for the given contract. If not provided, handlers can be auto-loaded from src directory.",
164
+ "type": [
165
+ "string",
166
+ "null"
167
+ ]
158
168
  },
159
169
  "events": {
160
170
  "description": "A list of events that should be indexed on this contract",
@@ -167,7 +177,6 @@
167
177
  "additionalProperties": false,
168
178
  "required": [
169
179
  "name",
170
- "handler",
171
180
  "events"
172
181
  ]
173
182
  },
@@ -257,7 +266,7 @@
257
266
  "accessList",
258
267
  "maxFeePerBlobGas",
259
268
  "blobVersionedHashes",
260
- "kind",
269
+ "type",
261
270
  "l1Fee",
262
271
  "l1GasPrice",
263
272
  "l1GasUsed",
@@ -567,6 +576,11 @@
567
576
  "description": "Use RPC as a backup for the main data-source. Currently, it acts as a fallback when real-time indexing stalls, with potential for more cases in the future.",
568
577
  "type": "string",
569
578
  "const": "fallback"
579
+ },
580
+ {
581
+ "description": "Use RPC for real-time indexing only. HyperSync will be used for historical sync, then automatically switch to this RPC once synced for lower latency.",
582
+ "type": "string",
583
+ "const": "live"
570
584
  }
571
585
  ]
572
586
  },
@@ -611,8 +625,11 @@
611
625
  ]
612
626
  },
613
627
  "handler": {
614
- "description": "The relative path to a file where handlers are registered for the given contract",
615
- "type": "string"
628
+ "description": "Optional relative path to a file where handlers are registered for the given contract. If not provided, handlers can be auto-loaded from src directory.",
629
+ "type": [
630
+ "string",
631
+ "null"
632
+ ]
616
633
  },
617
634
  "events": {
618
635
  "description": "A list of events that should be indexed on this contract",
package/fuel.schema.json CHANGED
@@ -63,6 +63,13 @@
63
63
  "boolean",
64
64
  "null"
65
65
  ]
66
+ },
67
+ "handlers": {
68
+ "description": "Optional relative path to handlers directory for auto-loading. Defaults to 'src/handlers' if not specified.",
69
+ "type": [
70
+ "string",
71
+ "null"
72
+ ]
66
73
  }
67
74
  },
68
75
  "additionalProperties": false,
@@ -90,8 +97,11 @@
90
97
  "type": "string"
91
98
  },
92
99
  "handler": {
93
- "description": "The relative path to a file where handlers are registered for the given contract",
94
- "type": "string"
100
+ "description": "Optional relative path to a file where handlers are registered for the given contract. If not provided, handlers can be auto-loaded from src directory.",
101
+ "type": [
102
+ "string",
103
+ "null"
104
+ ]
95
105
  },
96
106
  "events": {
97
107
  "description": "A list of events that should be indexed on this contract",
@@ -105,7 +115,6 @@
105
115
  "required": [
106
116
  "name",
107
117
  "abi_file_path",
108
- "handler",
109
118
  "events"
110
119
  ]
111
120
  },
@@ -238,8 +247,11 @@
238
247
  "type": "string"
239
248
  },
240
249
  "handler": {
241
- "description": "The relative path to a file where handlers are registered for the given contract",
242
- "type": "string"
250
+ "description": "Optional relative path to a file where handlers are registered for the given contract. If not provided, handlers can be auto-loaded from src directory.",
251
+ "type": [
252
+ "string",
253
+ "null"
254
+ ]
243
255
  },
244
256
  "events": {
245
257
  "description": "A list of events that should be indexed on this contract",
package/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export type {
7
7
  rateLimitDuration as RateLimitDuration,
8
8
  rateLimit as RateLimit,
9
9
  blockEvent as BlockEvent,
10
+ fuelBlockEvent as FuelBlockEvent,
10
11
  onBlockArgs as OnBlockArgs,
11
12
  onBlockOptions as OnBlockOptions,
12
13
  } from "./src/Envio.gen.ts";
@@ -100,33 +101,6 @@ export function createEffect<
100
101
  handler: (args: EffectArgs<I>) => Promise<R>
101
102
  ): Effect<I, O>;
102
103
 
103
- /**
104
- * @deprecated Use createEffect instead. The only difference is that rateLimit option becomes required. Set it to false to keep the same behaviour.
105
- */
106
- export function experimental_createEffect<
107
- IS,
108
- OS,
109
- I = UnknownToOutput<IS>,
110
- O = UnknownToOutput<OS>,
111
- // A hack to enforce that the inferred return type
112
- // matches the output schema type
113
- R extends O = O
114
- >(
115
- options: {
116
- /** The name of the effect. Used for logging and debugging. */
117
- readonly name: string;
118
- /** The input schema of the effect. */
119
- readonly input: IS;
120
- /** The output schema of the effect. */
121
- readonly output: OS;
122
- /** Rate limit for the effect. Set to false to disable or provide {calls: number, per: "second" | "minute"} to enable. */
123
- readonly rateLimit?: RateLimit;
124
- /** Whether the effect should be cached. */
125
- readonly cache?: boolean;
126
- },
127
- handler: (args: EffectArgs<I>) => Promise<R>
128
- ): Effect<I, O>;
129
-
130
104
  // Important! Should match the index.js file
131
105
  export declare namespace S {
132
106
  export type Output<T> = Sury.Output<T>;
package/index.js CHANGED
@@ -2,18 +2,21 @@
2
2
  // Some parts like Sury reexport are impossible to implement
3
3
  // on the JS side, so we need to do it here
4
4
 
5
- const envioGen = require("./src/Envio.res.js");
6
- Object.assign(exports, envioGen);
5
+ import * as Sury from "rescript-schema";
6
+ import { schema as bigintSchema } from "./src/bindings/BigInt.res.mjs";
7
+ import { schema as bigDecimalSchema } from "./src/bindings/BigDecimal.res.mjs";
8
+
9
+ // Re-export everything from envioGen
10
+ export * from "./src/Envio.res.mjs";
7
11
 
8
- const Sury = require("rescript-schema");
9
12
  // Important! Should match the index.d.ts file
10
- exports.S = {
13
+ export const S = {
11
14
  string: Sury.string,
12
15
  jsonString: Sury.jsonString,
13
16
  boolean: Sury.boolean,
14
17
  int32: Sury.int32,
15
18
  number: Sury.number,
16
- bigint: require("./src/bindings/BigInt.res.js").schema,
19
+ bigint: bigintSchema,
17
20
  never: Sury.never,
18
21
  union: Sury.union,
19
22
  object: Sury.object,
@@ -31,7 +34,7 @@ exports.S = {
31
34
  merge: Sury.merge,
32
35
  optional: Sury.optional,
33
36
  nullable: Sury.nullable,
34
- bigDecimal: require("./src/bindings/BigDecimal.res.js").schema,
37
+ bigDecimal: bigDecimalSchema,
35
38
  // Nullish type will change in "sury@10"
36
39
  // nullish: Sury.nullish,
37
40
  assertOrThrow: Sury.assertOrThrow,
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "envio",
3
- "version": "v2.32.3",
3
+ "version": "v3.0.0-alpha.0",
4
+ "type": "module",
4
5
  "description": "A latency and sync speed optimized, developer friendly blockchain data indexer.",
5
6
  "bin": "./bin.js",
6
7
  "main": "./index.js",
@@ -24,17 +25,21 @@
24
25
  "url": "https://github.com/enviodev/hyperindex/issues"
25
26
  },
26
27
  "homepage": "https://envio.dev",
28
+ "engines": {
29
+ "node": ">=22.0.0"
30
+ },
27
31
  "optionalDependencies": {
28
- "envio-linux-x64": "v2.32.3",
29
- "envio-linux-arm64": "v2.32.3",
30
- "envio-darwin-x64": "v2.32.3",
31
- "envio-darwin-arm64": "v2.32.3"
32
+ "envio-linux-x64": "v3.0.0-alpha.0",
33
+ "envio-linux-arm64": "v3.0.0-alpha.0",
34
+ "envio-darwin-x64": "v3.0.0-alpha.0",
35
+ "envio-darwin-arm64": "v3.0.0-alpha.0"
32
36
  },
33
37
  "dependencies": {
34
- "@envio-dev/hypersync-client": "0.6.6",
38
+ "@clickhouse/client": "1.12.1",
39
+ "@envio-dev/hypersync-client": "0.7.0",
35
40
  "@envio-dev/hyperfuel-client": "1.2.2",
36
41
  "rescript": "11.1.3",
37
- "rescript-schema": "9.3.0",
42
+ "rescript-schema": "9.3.4",
38
43
  "viem": "2.21.0",
39
44
  "bignumber.js": "9.1.2",
40
45
  "pino": "8.16.1",
package/rescript.json CHANGED
@@ -7,16 +7,17 @@
7
7
  "subdirs": true
8
8
  }
9
9
  ],
10
- "suffix": ".res.js",
10
+ "suffix": ".res.mjs",
11
11
  "package-specs": {
12
- "module": "commonjs",
12
+ "module": "esmodule",
13
13
  "in-source": true
14
14
  },
15
15
  "gentypeconfig": {
16
16
  "shims": {
17
17
  "Js": "Js"
18
18
  },
19
- "generatedFileExtension": ".gen.ts"
19
+ "generatedFileExtension": ".gen.ts",
20
+ "moduleResolution": "node16"
20
21
  },
21
22
  "bs-dependencies": ["rescript-schema"],
22
23
  "bsc-flags": ["-open RescriptSchema"]
@@ -1,9 +1,8 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
- 'use strict';
3
2
 
4
- var Viem = require("viem");
5
- var Js_exn = require("rescript/lib/js/js_exn.js");
6
- var S$RescriptSchema = require("rescript-schema/src/S.res.js");
3
+ import * as Viem from "viem";
4
+ import * as Js_exn from "rescript/lib/es6/js_exn.js";
5
+ import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
7
6
 
8
7
  var schema = S$RescriptSchema.setName(S$RescriptSchema.string, "Address");
9
8
 
@@ -39,6 +38,8 @@ var Evm = {
39
38
  fromAddressOrThrow: fromAddressOrThrow
40
39
  };
41
40
 
42
- exports.schema = schema;
43
- exports.Evm = Evm;
41
+ export {
42
+ schema ,
43
+ Evm ,
44
+ }
44
45
  /* schema Not a pure module */
package/src/Batch.res CHANGED
@@ -24,7 +24,7 @@ type t = {
24
24
  items: array<Internal.item>,
25
25
  progressedChainsById: dict<chainAfterBatch>,
26
26
  // Unnest-like checkpoint fields:
27
- checkpointIds: array<int>,
27
+ checkpointIds: array<float>,
28
28
  checkpointChainIds: array<int>,
29
29
  checkpointBlockNumbers: array<int>,
30
30
  checkpointBlockHashes: array<Js.Null.t<string>>,
@@ -196,7 +196,7 @@ let addReorgCheckpoints = (
196
196
  for blockNumber in fromBlockExclusive + 1 to toBlockExclusive - 1 {
197
197
  switch reorgDetection->ReorgDetection.getHashByBlockNumber(~blockNumber) {
198
198
  | Js.Null.Value(hash) =>
199
- let checkpointId = prevCheckpointId.contents + 1
199
+ let checkpointId = prevCheckpointId.contents +. 1.
200
200
  prevCheckpointId := checkpointId
201
201
 
202
202
  mutCheckpointIds->Js.Array2.push(checkpointId)->ignore
@@ -277,7 +277,7 @@ let prepareOrderedBatch = (
277
277
  ~mutCheckpointEventsProcessed=checkpointEventsProcessed,
278
278
  )
279
279
 
280
- let checkpointId = prevCheckpointId.contents + 1
280
+ let checkpointId = prevCheckpointId.contents +. 1.
281
281
 
282
282
  items
283
283
  ->Js.Array2.push(item0)
@@ -421,7 +421,7 @@ let prepareUnorderedBatch = (
421
421
  ~mutCheckpointEventsProcessed=checkpointEventsProcessed,
422
422
  )
423
423
 
424
- let checkpointId = prevCheckpointId.contents + 1
424
+ let checkpointId = prevCheckpointId.contents +. 1.
425
425
 
426
426
  checkpointIds->Js.Array2.push(checkpointId)->ignore
427
427
  checkpointChainIds->Js.Array2.push(fetchState.chainId)->ignore
@@ -1,11 +1,10 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
- 'use strict';
3
2
 
4
- var Utils = require("./Utils.res.js");
5
- var ChainMap = require("./ChainMap.res.js");
6
- var Belt_Array = require("rescript/lib/js/belt_Array.js");
7
- var FetchState = require("./FetchState.res.js");
8
- var ReorgDetection = require("./ReorgDetection.res.js");
3
+ import * as Utils from "./Utils.res.mjs";
4
+ import * as ChainMap from "./ChainMap.res.mjs";
5
+ import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
6
+ import * as FetchState from "./FetchState.res.mjs";
7
+ import * as ReorgDetection from "./ReorgDetection.res.mjs";
9
8
 
10
9
  function getOrderedNextChain(fetchStates, batchSizePerChain) {
11
10
  var earliestChain;
@@ -375,16 +374,18 @@ function findLastEventItem(batch, chainId) {
375
374
  return result;
376
375
  }
377
376
 
378
- exports.getOrderedNextChain = getOrderedNextChain;
379
- exports.immutableEmptyBatchSizePerChain = immutableEmptyBatchSizePerChain;
380
- exports.hasOrderedReadyItem = hasOrderedReadyItem;
381
- exports.hasUnorderedReadyItem = hasUnorderedReadyItem;
382
- exports.hasMultichainReadyItem = hasMultichainReadyItem;
383
- exports.getProgressedChainsById = getProgressedChainsById;
384
- exports.addReorgCheckpoints = addReorgCheckpoints;
385
- exports.prepareOrderedBatch = prepareOrderedBatch;
386
- exports.prepareUnorderedBatch = prepareUnorderedBatch;
387
- exports.make = make;
388
- exports.findFirstEventBlockNumber = findFirstEventBlockNumber;
389
- exports.findLastEventItem = findLastEventItem;
377
+ export {
378
+ getOrderedNextChain ,
379
+ immutableEmptyBatchSizePerChain ,
380
+ hasOrderedReadyItem ,
381
+ hasUnorderedReadyItem ,
382
+ hasMultichainReadyItem ,
383
+ getProgressedChainsById ,
384
+ addReorgCheckpoints ,
385
+ prepareOrderedBatch ,
386
+ prepareUnorderedBatch ,
387
+ make ,
388
+ findFirstEventBlockNumber ,
389
+ findLastEventItem ,
390
+ }
390
391
  /* Utils Not a pure module */
@@ -1,12 +1,11 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
- 'use strict';
3
2
 
4
- var Caml = require("rescript/lib/js/caml.js");
5
- var Js_exn = require("rescript/lib/js/js_exn.js");
6
- var Belt_Id = require("rescript/lib/js/belt_Id.js");
7
- var Belt_Map = require("rescript/lib/js/belt_Map.js");
8
- var Belt_Option = require("rescript/lib/js/belt_Option.js");
9
- var Caml_option = require("rescript/lib/js/caml_option.js");
3
+ import * as Caml from "rescript/lib/es6/caml.js";
4
+ import * as Js_exn from "rescript/lib/es6/js_exn.js";
5
+ import * as Belt_Id from "rescript/lib/es6/belt_Id.js";
6
+ import * as Belt_Map from "rescript/lib/es6/belt_Map.js";
7
+ import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
8
+ import * as Caml_option from "rescript/lib/es6/caml_option.js";
10
9
 
11
10
  function toString(chainId) {
12
11
  return String(chainId);
@@ -62,16 +61,18 @@ function update(map, chain, updateFn) {
62
61
  }));
63
62
  }
64
63
 
65
- exports.Chain = Chain;
66
- exports.fromArrayUnsafe = fromArrayUnsafe;
67
- exports.get = get;
68
- exports.set = set;
69
- exports.values = values;
70
- exports.keys = keys;
71
- exports.entries = entries;
72
- exports.has = has;
73
- exports.map = map;
74
- exports.mapWithKey = mapWithKey;
75
- exports.size = size;
76
- exports.update = update;
64
+ export {
65
+ Chain ,
66
+ fromArrayUnsafe ,
67
+ get ,
68
+ set ,
69
+ values ,
70
+ keys ,
71
+ entries ,
72
+ has ,
73
+ map ,
74
+ mapWithKey ,
75
+ size ,
76
+ update ,
77
+ }
77
78
  /* ChainIdCmp Not a pure module */
package/src/Change.res ADDED
@@ -0,0 +1,9 @@
1
+ @tag("type")
2
+ type t<'entity> =
3
+ | @as("SET") Set({entityId: string, entity: 'entity, checkpointId: float})
4
+ | @as("DELETE") Delete({entityId: string, checkpointId: float})
5
+
6
+ @get
7
+ external getEntityId: t<'entity> => string = "entityId"
8
+ @get
9
+ external getCheckpointId: t<'entity> => float = "checkpointId"
package/src/Config.res CHANGED
@@ -1,7 +1,5 @@
1
1
  open Belt
2
2
 
3
- type ecosystem = | @as("evm") Evm | @as("fuel") Fuel
4
-
5
3
  type sourceSyncOptions = {
6
4
  initialBlockInterval?: int,
7
5
  backoffMultiplicative?: float,
@@ -47,7 +45,7 @@ type t = {
47
45
  multichain: multichain,
48
46
  chainMap: ChainMap.t<chain>,
49
47
  defaultChain: option<chain>,
50
- ecosystem: ecosystem,
48
+ platform: Platform.t,
51
49
  enableRawEvents: bool,
52
50
  preloadHandlers: bool,
53
51
  maxAddrInPartition: int,
@@ -62,7 +60,7 @@ let make = (
62
60
  ~chains: array<chain>=[],
63
61
  ~enableRawEvents=false,
64
62
  ~preloadHandlers=false,
65
- ~ecosystem=Evm,
63
+ ~ecosystem: Platform.name=Platform.Evm,
66
64
  ~batchSize=5000,
67
65
  ~lowercaseAddresses=false,
68
66
  ~multichain=Unordered,
@@ -92,6 +90,8 @@ let make = (
92
90
  })
93
91
  })
94
92
 
93
+ let platform = Platform.fromName(ecosystem)
94
+
95
95
  {
96
96
  shouldRollbackOnReorg,
97
97
  shouldSaveFullHistory,
@@ -99,7 +99,7 @@ let make = (
99
99
  chainMap,
100
100
  defaultChain: chains->Array.get(0),
101
101
  enableRawEvents,
102
- ecosystem,
102
+ platform,
103
103
  maxAddrInPartition,
104
104
  preloadHandlers,
105
105
  batchSize,
@@ -1,10 +1,10 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
- 'use strict';
3
2
 
4
- var Utils = require("./Utils.res.js");
5
- var Js_exn = require("rescript/lib/js/js_exn.js");
6
- var ChainMap = require("./ChainMap.res.js");
7
- var Belt_Array = require("rescript/lib/js/belt_Array.js");
3
+ import * as Utils from "./Utils.res.mjs";
4
+ import * as Js_exn from "rescript/lib/es6/js_exn.js";
5
+ import * as ChainMap from "./ChainMap.res.mjs";
6
+ import * as Platform from "./Platform.res.mjs";
7
+ import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
8
8
 
9
9
  function make(shouldRollbackOnReorgOpt, shouldSaveFullHistoryOpt, chainsOpt, enableRawEventsOpt, preloadHandlersOpt, ecosystemOpt, batchSizeOpt, lowercaseAddressesOpt, multichainOpt, shouldUseHypersyncClientDecoderOpt, maxAddrInPartitionOpt) {
10
10
  var shouldRollbackOnReorg = shouldRollbackOnReorgOpt !== undefined ? shouldRollbackOnReorgOpt : true;
@@ -34,13 +34,14 @@ function make(shouldRollbackOnReorgOpt, shouldSaveFullHistoryOpt, chainsOpt, ena
34
34
  addContractNameToContractNameMapping[addKey] = contract.name;
35
35
  }));
36
36
  }));
37
+ var platform = Platform.fromName(ecosystem);
37
38
  return {
38
39
  shouldRollbackOnReorg: shouldRollbackOnReorg,
39
40
  shouldSaveFullHistory: shouldSaveFullHistory,
40
41
  multichain: multichain,
41
42
  chainMap: chainMap,
42
43
  defaultChain: Belt_Array.get(chains, 0),
43
- ecosystem: ecosystem,
44
+ platform: platform,
44
45
  enableRawEvents: enableRawEvents,
45
46
  preloadHandlers: preloadHandlers,
46
47
  maxAddrInPartition: maxAddrInPartition,
@@ -77,8 +78,10 @@ function getChain(config, chainId) {
77
78
  }
78
79
  }
79
80
 
80
- exports.make = make;
81
- exports.shouldSaveHistory = shouldSaveHistory;
82
- exports.shouldPruneHistory = shouldPruneHistory;
83
- exports.getChain = getChain;
81
+ export {
82
+ make ,
83
+ shouldSaveHistory ,
84
+ shouldPruneHistory ,
85
+ getChain ,
86
+ }
84
87
  /* Utils Not a pure module */
package/src/Envio.gen.ts CHANGED
@@ -9,13 +9,13 @@ import type {Effect as $$effect} from './Types.ts';
9
9
 
10
10
  import type {Logger as $$logger} from './Types.ts';
11
11
 
12
- import type {S_t as RescriptSchema_S_t} from 'rescript-schema/RescriptSchema.gen';
12
+ import type {S_t as RescriptSchema_S_t} from 'rescript-schema/RescriptSchema.gen.js';
13
13
 
14
- import type {blockEvent as Internal_blockEvent} from './Internal.gen';
14
+ export type blockEvent = { readonly number: number };
15
15
 
16
- export type blockEvent = Internal_blockEvent;
16
+ export type fuelBlockEvent = { readonly height: number; readonly chainId: number };
17
17
 
18
- export type onBlockArgs<context> = { readonly block: blockEvent; readonly context: context };
18
+ export type onBlockArgs<block,context> = { readonly block: block; readonly context: context };
19
19
 
20
20
  export type onBlockOptions<chain> = {
21
21
  readonly name: string;
@@ -35,19 +35,6 @@ export type rateLimit =
35
35
  false
36
36
  | { readonly calls: number; readonly per: rateLimitDuration };
37
37
 
38
- export type experimental_effectOptions<input,output> = {
39
- /** The name of the effect. Used for logging and debugging. */
40
- readonly name: string;
41
- /** The input schema of the effect. */
42
- readonly input: RescriptSchema_S_t<input>;
43
- /** The output schema of the effect. */
44
- readonly output: RescriptSchema_S_t<output>;
45
- /** Rate limit for the effect. Set to false to disable or provide {calls: number, per: "second" | "minute"} to enable. */
46
- readonly rateLimit?: rateLimit;
47
- /** Whether the effect should be cached. */
48
- readonly cache?: boolean
49
- };
50
-
51
38
  export type effectOptions<input,output> = {
52
39
  /** The name of the effect. Used for logging and debugging. */
53
40
  readonly name: string;
package/src/Envio.res CHANGED
@@ -2,12 +2,22 @@
2
2
  // Should be an entry point after we get rid of the generated project.
3
3
  // Don't forget to keep index.d.ts in sync with this file.
4
4
 
5
+ // EVM block event with 'number' field for backward compatibility
5
6
  @genType
6
- type blockEvent = Internal.blockEvent
7
+ type blockEvent = {
8
+ number: int,
9
+ }
7
10
 
11
+ // Fuel block event with 'height' field
8
12
  @genType
9
- type onBlockArgs<'context> = {
10
- block: blockEvent,
13
+ type fuelBlockEvent = {
14
+ height: int,
15
+ chainId: int,
16
+ }
17
+
18
+ @genType
19
+ type onBlockArgs<'block, 'context> = {
20
+ block: 'block,
11
21
  context: 'context,
12
22
  }
13
23
 
@@ -42,19 +52,6 @@ and rateLimit =
42
52
  | @as(false) Disable
43
53
  | Enable({calls: int, per: rateLimitDuration})
44
54
  @genType
45
- and experimental_effectOptions<'input, 'output> = {
46
- /** The name of the effect. Used for logging and debugging. */
47
- name: string,
48
- /** The input schema of the effect. */
49
- input: S.t<'input>,
50
- /** The output schema of the effect. */
51
- output: S.t<'output>,
52
- /** Rate limit for the effect. Set to false to disable or provide {calls: number, per: "second" | "minute"} to enable. */
53
- rateLimit?: rateLimit,
54
- /** Whether the effect should be cached. */
55
- cache?: bool,
56
- }
57
- @genType
58
55
  and effectOptions<'input, 'output> = {
59
56
  /** The name of the effect. Used for logging and debugging. */
60
57
  name: string,
@@ -137,25 +134,3 @@ let createEffect = (
137
134
  },
138
135
  }->(Utils.magic: Internal.effect => effect<'input, 'output>)
139
136
  }
140
-
141
- @deprecated(
142
- "Use createEffect instead. The only difference is that rateLimit option becomes required. Set it to false to keep the same behaviour."
143
- )
144
- let experimental_createEffect = (
145
- options: experimental_effectOptions<'input, 'output>,
146
- handler: effectArgs<'input> => promise<'output>,
147
- ) => {
148
- createEffect(
149
- {
150
- name: options.name,
151
- input: options.input,
152
- output: options.output,
153
- rateLimit: switch options.rateLimit {
154
- | Some(rateLimit) => rateLimit
155
- | None => Disable
156
- },
157
- cache: ?options.cache,
158
- },
159
- handler,
160
- )
161
- }