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.
- package/bin.js +5 -3
- package/evm.schema.json +23 -6
- package/fuel.schema.json +17 -5
- package/index.d.ts +1 -27
- package/index.js +9 -6
- package/package.json +12 -7
- package/rescript.json +4 -3
- package/src/{Address.res.js → Address.res.mjs} +7 -6
- package/src/Batch.res +4 -4
- package/src/{Batch.res.js → Batch.res.mjs} +19 -18
- package/src/{ChainMap.res.js → ChainMap.res.mjs} +20 -19
- package/src/Change.res +9 -0
- package/src/Config.res +5 -5
- package/src/{Config.res.js → Config.res.mjs} +13 -10
- package/src/Envio.gen.ts +4 -17
- package/src/Envio.res +13 -38
- package/src/{Envio.res.js → Envio.res.mjs} +5 -16
- package/src/{ErrorHandling.res.js → ErrorHandling.res.mjs} +10 -9
- package/src/EventRegister.res +10 -11
- package/src/{EventRegister.res.js → EventRegister.res.mjs} +33 -26
- package/src/EventRegister.resi +2 -1
- package/src/{EventUtils.res.js → EventUtils.res.mjs} +10 -9
- package/src/{EvmTypes.res.js → EvmTypes.res.mjs} +5 -4
- package/src/{FetchState.res.js → FetchState.res.mjs} +44 -43
- package/src/{Hasura.res.js → Hasura.res.mjs} +25 -24
- package/src/InMemoryStore.res +7 -15
- package/src/{InMemoryStore.res.js → InMemoryStore.res.mjs} +21 -22
- package/src/InMemoryTable.res +50 -35
- package/src/{InMemoryTable.res.js → InMemoryTable.res.mjs} +73 -104
- package/src/Internal.gen.ts +1 -5
- package/src/Internal.res +29 -40
- package/src/Internal.res.mjs +58 -0
- package/src/{LazyLoader.res.js → LazyLoader.res.mjs} +14 -13
- package/src/{LoadManager.res.js → LoadManager.res.mjs} +11 -10
- package/src/{LogSelection.res.js → LogSelection.res.mjs} +14 -13
- package/src/{Logging.res.js → Logging.res.mjs} +37 -36
- package/src/Persistence.res +190 -38
- package/src/Persistence.res.mjs +213 -0
- package/src/PgStorage.res +700 -14
- package/src/{PgStorage.res.js → PgStorage.res.mjs} +478 -65
- package/src/Platform.res +140 -0
- package/src/Platform.res.mjs +170 -0
- package/src/Prometheus.res +41 -0
- package/src/{Prometheus.res.js → Prometheus.res.mjs} +106 -60
- package/src/{ReorgDetection.res.js → ReorgDetection.res.mjs} +12 -11
- package/src/SafeCheckpointTracking.res +5 -4
- package/src/{SafeCheckpointTracking.res.js → SafeCheckpointTracking.res.mjs} +6 -5
- package/src/Sink.res +47 -0
- package/src/Sink.res.mjs +37 -0
- package/src/{TableIndices.res.js → TableIndices.res.mjs} +8 -7
- package/src/{Throttler.res.js → Throttler.res.mjs} +7 -6
- package/src/{Time.res.js → Time.res.mjs} +8 -7
- package/src/{TopicFilter.res.js → TopicFilter.res.mjs} +18 -17
- package/src/Utils.res +42 -0
- package/src/{Utils.res.js → Utils.res.mjs} +71 -34
- package/src/bindings/BigDecimal.gen.ts +2 -2
- package/src/bindings/BigDecimal.res +5 -5
- package/src/bindings/BigDecimal.res.d.mts +5 -0
- package/src/bindings/{BigDecimal.res.js → BigDecimal.res.mjs} +10 -9
- package/src/bindings/BigInt.gen.ts +2 -2
- package/src/bindings/BigInt.res.d.mts +5 -0
- package/src/bindings/{BigInt.res.js → BigInt.res.mjs} +25 -24
- package/src/bindings/ClickHouse.res +387 -0
- package/src/bindings/ClickHouse.res.mjs +275 -0
- package/src/bindings/Ethers.gen.ts +2 -2
- package/src/bindings/Ethers.res.d.mts +5 -0
- package/src/bindings/{Ethers.res.js → Ethers.res.mjs} +18 -17
- package/src/bindings/Express.res.mjs +2 -0
- package/src/bindings/{Hrtime.res.js → Hrtime.res.mjs} +13 -12
- package/src/bindings/{Lodash.res.js → Lodash.res.mjs} +4 -3
- package/src/bindings/NodeJs.res +13 -1
- package/src/bindings/NodeJs.res.mjs +48 -0
- package/src/bindings/Pino.res +4 -4
- package/src/bindings/{Pino.res.js → Pino.res.mjs} +16 -15
- package/src/bindings/Postgres.res +17 -2
- package/src/bindings/{Postgres.res.js → Postgres.res.mjs} +4 -3
- package/src/bindings/{PromClient.res.js → PromClient.res.mjs} +6 -5
- package/src/bindings/{Promise.res.js → Promise.res.mjs} +6 -5
- package/src/bindings/{SDSL.res.js → SDSL.res.mjs} +3 -2
- package/src/bindings/{Viem.res.js → Viem.res.mjs} +9 -8
- package/src/bindings/vendored-lodash-fns.js +3 -35
- package/src/db/EntityHistory.res +33 -156
- package/src/db/EntityHistory.res.mjs +121 -0
- package/src/db/InternalTable.gen.ts +2 -2
- package/src/db/InternalTable.res +55 -56
- package/src/db/{InternalTable.res.js → InternalTable.res.mjs} +68 -71
- package/src/db/{Schema.res.js → Schema.res.mjs} +10 -9
- package/src/db/Table.res +86 -22
- package/src/db/{Table.res.js → Table.res.mjs} +108 -40
- package/src/sources/{EventRouter.res.js → EventRouter.res.mjs} +17 -16
- package/src/sources/{Fuel.res.js → Fuel.res.mjs} +6 -5
- package/src/sources/{HyperFuel.res.js → HyperFuel.res.mjs} +14 -13
- package/src/sources/{HyperFuelClient.res.js → HyperFuelClient.res.mjs} +7 -6
- package/src/sources/{HyperFuelSource.res.js → HyperFuelSource.res.mjs} +28 -27
- package/src/sources/{HyperSync.res.js → HyperSync.res.mjs} +21 -20
- package/src/sources/HyperSyncClient.gen.ts +1 -1
- package/src/sources/HyperSyncClient.res +78 -20
- package/src/sources/{HyperSyncClient.res.js → HyperSyncClient.res.mjs} +32 -15
- package/src/sources/{HyperSyncJsonApi.res.js → HyperSyncJsonApi.res.mjs} +10 -9
- package/src/sources/HyperSyncSource.res +77 -9
- package/src/sources/{HyperSyncSource.res.js → HyperSyncSource.res.mjs} +99 -38
- package/src/sources/{Rpc.res.js → Rpc.res.mjs} +16 -15
- package/src/sources/{RpcSource.res.js → RpcSource.res.mjs} +40 -39
- package/src/sources/Source.res +1 -1
- package/src/sources/{Source.res.js → Source.res.mjs} +4 -3
- package/src/sources/SourceManager.res +12 -1
- package/src/sources/{SourceManager.res.js → SourceManager.res.mjs} +32 -21
- package/src/sources/vendored-fuel-abi-coder.js +94 -149
- package/src/vendored/{Rest.res.js → Rest.res.mjs} +12 -11
- package/src/Internal.res.js +0 -62
- package/src/Persistence.res.js +0 -159
- package/src/bindings/NodeJs.res.js +0 -35
- package/src/db/EntityHistory.res.js +0 -195
- /package/src/{Indexer.res.js → Change.res.mjs} +0 -0
- /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
|
-
|
|
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": "
|
|
157
|
-
"type":
|
|
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
|
-
"
|
|
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": "
|
|
615
|
-
"type":
|
|
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": "
|
|
94
|
-
"type":
|
|
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": "
|
|
242
|
-
"type":
|
|
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
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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": "
|
|
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": "
|
|
29
|
-
"envio-linux-arm64": "
|
|
30
|
-
"envio-darwin-x64": "
|
|
31
|
-
"envio-darwin-arm64": "
|
|
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
|
-
"@
|
|
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.
|
|
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.
|
|
10
|
+
"suffix": ".res.mjs",
|
|
11
11
|
"package-specs": {
|
|
12
|
-
"module": "
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
43
|
-
|
|
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<
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
14
|
+
export type blockEvent = { readonly number: number };
|
|
15
15
|
|
|
16
|
-
export type
|
|
16
|
+
export type fuelBlockEvent = { readonly height: number; readonly chainId: number };
|
|
17
17
|
|
|
18
|
-
export type onBlockArgs<context> = { readonly block:
|
|
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 =
|
|
7
|
+
type blockEvent = {
|
|
8
|
+
number: int,
|
|
9
|
+
}
|
|
7
10
|
|
|
11
|
+
// Fuel block event with 'height' field
|
|
8
12
|
@genType
|
|
9
|
-
type
|
|
10
|
-
|
|
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
|
-
}
|