envio 3.0.0-alpha.21 → 3.0.0-alpha.22
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.mjs +2 -48
- package/evm.schema.json +67 -0
- package/fuel.schema.json +67 -0
- package/index.d.ts +822 -38
- package/index.js +5 -3
- package/package.json +10 -8
- package/rescript.json +5 -9
- package/src/Address.res +4 -5
- package/src/Address.res.mjs +9 -12
- package/src/Api.res +15 -0
- package/src/Api.res.mjs +20 -0
- package/src/Batch.res +32 -34
- package/src/Batch.res.mjs +172 -187
- package/src/Bin.res +89 -0
- package/src/Bin.res.mjs +97 -0
- package/src/ChainFetcher.res +33 -57
- package/src/ChainFetcher.res.mjs +197 -227
- package/src/ChainManager.res +6 -14
- package/src/ChainManager.res.mjs +74 -85
- package/src/ChainMap.res +14 -16
- package/src/ChainMap.res.mjs +38 -38
- package/src/Config.res +193 -135
- package/src/Config.res.mjs +566 -592
- package/src/Core.res +182 -0
- package/src/Core.res.mjs +207 -0
- package/src/Ecosystem.res +25 -4
- package/src/Ecosystem.res.mjs +12 -13
- package/src/Env.res +20 -13
- package/src/Env.res.mjs +124 -113
- package/src/EnvSafe.res +269 -0
- package/src/EnvSafe.res.mjs +296 -0
- package/src/EnvSafe.resi +18 -0
- package/src/Envio.res +37 -26
- package/src/Envio.res.mjs +59 -60
- package/src/ErrorHandling.res +2 -2
- package/src/ErrorHandling.res.mjs +15 -15
- package/src/EventConfigBuilder.res +219 -81
- package/src/EventConfigBuilder.res.mjs +259 -202
- package/src/EventProcessing.res +27 -38
- package/src/EventProcessing.res.mjs +165 -183
- package/src/EventUtils.res +11 -11
- package/src/EventUtils.res.mjs +21 -22
- package/src/EvmTypes.res +0 -1
- package/src/EvmTypes.res.mjs +5 -5
- package/src/FetchState.res +360 -256
- package/src/FetchState.res.mjs +958 -914
- package/src/GlobalState.res +365 -351
- package/src/GlobalState.res.mjs +958 -992
- package/src/GlobalStateManager.res +1 -2
- package/src/GlobalStateManager.res.mjs +36 -44
- package/src/HandlerLoader.res +107 -23
- package/src/HandlerLoader.res.mjs +128 -38
- package/src/HandlerRegister.res +127 -103
- package/src/HandlerRegister.res.mjs +164 -164
- package/src/HandlerRegister.resi +12 -4
- package/src/Hasura.res +35 -22
- package/src/Hasura.res.mjs +158 -167
- package/src/InMemoryStore.res +20 -27
- package/src/InMemoryStore.res.mjs +64 -80
- package/src/InMemoryTable.res +34 -39
- package/src/InMemoryTable.res.mjs +165 -170
- package/src/Internal.res +52 -33
- package/src/Internal.res.mjs +84 -81
- package/src/LazyLoader.res.mjs +55 -61
- package/src/LoadLayer.res +77 -78
- package/src/LoadLayer.res.mjs +160 -189
- package/src/LoadManager.res +16 -21
- package/src/LoadManager.res.mjs +79 -84
- package/src/LogSelection.res +236 -68
- package/src/LogSelection.res.mjs +211 -141
- package/src/Logging.res +13 -9
- package/src/Logging.res.mjs +130 -143
- package/src/Main.res +428 -51
- package/src/Main.res.mjs +528 -271
- package/src/Persistence.res +77 -84
- package/src/Persistence.res.mjs +131 -132
- package/src/PgStorage.res +291 -167
- package/src/PgStorage.res.mjs +797 -817
- package/src/Prometheus.res +50 -58
- package/src/Prometheus.res.mjs +345 -373
- package/src/ReorgDetection.res +22 -24
- package/src/ReorgDetection.res.mjs +100 -106
- package/src/SafeCheckpointTracking.res +7 -7
- package/src/SafeCheckpointTracking.res.mjs +40 -43
- package/src/SimulateItems.res +41 -49
- package/src/SimulateItems.res.mjs +257 -272
- package/src/Sink.res +2 -2
- package/src/Sink.res.mjs +22 -26
- package/src/TableIndices.res +1 -2
- package/src/TableIndices.res.mjs +42 -48
- package/src/TestIndexer.res +196 -189
- package/src/TestIndexer.res.mjs +536 -536
- package/src/TestIndexerProxyStorage.res +15 -16
- package/src/TestIndexerProxyStorage.res.mjs +98 -122
- package/src/TestIndexerWorker.res +4 -0
- package/src/TestIndexerWorker.res.mjs +7 -0
- package/src/Throttler.res +3 -3
- package/src/Throttler.res.mjs +23 -24
- package/src/Time.res +1 -1
- package/src/Time.res.mjs +18 -21
- package/src/TopicFilter.res +3 -3
- package/src/TopicFilter.res.mjs +29 -30
- package/src/UserContext.res +93 -54
- package/src/UserContext.res.mjs +197 -182
- package/src/Utils.res +141 -86
- package/src/Utils.res.mjs +334 -295
- package/src/bindings/BigDecimal.res +0 -2
- package/src/bindings/BigDecimal.res.mjs +19 -23
- package/src/bindings/ClickHouse.res +28 -27
- package/src/bindings/ClickHouse.res.mjs +243 -240
- package/src/bindings/DateFns.res +11 -11
- package/src/bindings/DateFns.res.mjs +7 -7
- package/src/bindings/EventSource.res.mjs +2 -2
- package/src/bindings/Express.res +2 -5
- package/src/bindings/Hrtime.res +2 -2
- package/src/bindings/Hrtime.res.mjs +30 -32
- package/src/bindings/Lodash.res.mjs +1 -1
- package/src/bindings/NodeJs.res +14 -9
- package/src/bindings/NodeJs.res.mjs +20 -20
- package/src/bindings/Pino.res +8 -10
- package/src/bindings/Pino.res.mjs +40 -43
- package/src/bindings/Postgres.res +2 -5
- package/src/bindings/Postgres.res.mjs +9 -9
- package/src/bindings/PromClient.res +17 -2
- package/src/bindings/PromClient.res.mjs +30 -7
- package/src/bindings/SDSL.res.mjs +2 -2
- package/src/bindings/Viem.res +4 -4
- package/src/bindings/Viem.res.mjs +20 -22
- package/src/bindings/Vitest.res +1 -1
- package/src/bindings/Vitest.res.mjs +2 -2
- package/src/bindings/WebSocket.res +1 -1
- package/src/db/EntityHistory.res +9 -3
- package/src/db/EntityHistory.res.mjs +84 -59
- package/src/db/InternalTable.res +62 -60
- package/src/db/InternalTable.res.mjs +271 -203
- package/src/db/Schema.res +1 -2
- package/src/db/Schema.res.mjs +28 -32
- package/src/db/Table.res +28 -27
- package/src/db/Table.res.mjs +276 -292
- package/src/sources/EventRouter.res +21 -16
- package/src/sources/EventRouter.res.mjs +55 -57
- package/src/sources/Evm.res +17 -1
- package/src/sources/Evm.res.mjs +16 -8
- package/src/sources/EvmChain.res +15 -17
- package/src/sources/EvmChain.res.mjs +40 -42
- package/src/sources/Fuel.res +14 -1
- package/src/sources/Fuel.res.mjs +16 -8
- package/src/sources/FuelSDK.res +1 -1
- package/src/sources/FuelSDK.res.mjs +6 -8
- package/src/sources/HyperFuel.res +8 -10
- package/src/sources/HyperFuel.res.mjs +113 -123
- package/src/sources/HyperFuelClient.res.mjs +6 -7
- package/src/sources/HyperFuelSource.res +19 -20
- package/src/sources/HyperFuelSource.res.mjs +339 -356
- package/src/sources/HyperSync.res +11 -13
- package/src/sources/HyperSync.res.mjs +206 -220
- package/src/sources/HyperSyncClient.res +5 -7
- package/src/sources/HyperSyncClient.res.mjs +70 -75
- package/src/sources/HyperSyncHeightStream.res +8 -9
- package/src/sources/HyperSyncHeightStream.res.mjs +78 -86
- package/src/sources/HyperSyncJsonApi.res +18 -15
- package/src/sources/HyperSyncJsonApi.res.mjs +201 -231
- package/src/sources/HyperSyncSource.res +17 -21
- package/src/sources/HyperSyncSource.res.mjs +268 -290
- package/src/sources/Rpc.res +5 -5
- package/src/sources/Rpc.res.mjs +168 -192
- package/src/sources/RpcSource.res +166 -167
- package/src/sources/RpcSource.res.mjs +972 -1046
- package/src/sources/RpcWebSocketHeightStream.res +10 -11
- package/src/sources/RpcWebSocketHeightStream.res.mjs +131 -145
- package/src/sources/SimulateSource.res +1 -1
- package/src/sources/SimulateSource.res.mjs +35 -38
- package/src/sources/Source.res +1 -1
- package/src/sources/Source.res.mjs +3 -3
- package/src/sources/SourceManager.res +39 -20
- package/src/sources/SourceManager.res.mjs +340 -371
- package/src/sources/SourceManager.resi +2 -1
- package/src/sources/Svm.res +12 -5
- package/src/sources/Svm.res.mjs +44 -41
- package/src/tui/Tui.res +23 -12
- package/src/tui/Tui.res.mjs +292 -290
- package/src/tui/bindings/Ink.res +2 -4
- package/src/tui/bindings/Ink.res.mjs +35 -41
- package/src/tui/components/BufferedProgressBar.res +7 -7
- package/src/tui/components/BufferedProgressBar.res.mjs +46 -46
- package/src/tui/components/CustomHooks.res +1 -2
- package/src/tui/components/CustomHooks.res.mjs +102 -122
- package/src/tui/components/Messages.res +1 -2
- package/src/tui/components/Messages.res.mjs +38 -42
- package/src/tui/components/SyncETA.res +10 -11
- package/src/tui/components/SyncETA.res.mjs +178 -196
- package/src/tui/components/TuiData.res +1 -1
- package/src/tui/components/TuiData.res.mjs +7 -6
- package/src/vendored/Rest.res +52 -66
- package/src/vendored/Rest.res.mjs +324 -364
- package/svm.schema.json +67 -0
- package/src/Address.gen.ts +0 -8
- package/src/Config.gen.ts +0 -19
- package/src/Envio.gen.ts +0 -55
- package/src/EvmTypes.gen.ts +0 -6
- package/src/InMemoryStore.gen.ts +0 -6
- package/src/Internal.gen.ts +0 -64
- package/src/PgStorage.gen.ts +0 -10
- package/src/PgStorage.res.d.mts +0 -5
- package/src/Types.ts +0 -56
- package/src/bindings/BigDecimal.gen.ts +0 -14
- package/src/bindings/BigDecimal.res.d.mts +0 -5
- package/src/bindings/BigInt.gen.ts +0 -10
- package/src/bindings/BigInt.res +0 -70
- package/src/bindings/BigInt.res.d.mts +0 -5
- package/src/bindings/BigInt.res.mjs +0 -154
- package/src/bindings/Ethers.res.d.mts +0 -5
- package/src/bindings/Pino.gen.ts +0 -17
- package/src/bindings/Postgres.gen.ts +0 -8
- package/src/bindings/Postgres.res.d.mts +0 -5
- package/src/bindings/Promise.res +0 -67
- package/src/bindings/Promise.res.mjs +0 -26
- package/src/db/InternalTable.gen.ts +0 -36
- package/src/sources/HyperSyncClient.gen.ts +0 -19
|
@@ -22,8 +22,8 @@ let subscribeRequestJson =
|
|
|
22
22
|
"id": int,
|
|
23
23
|
"method": string,
|
|
24
24
|
"params": array<string>,
|
|
25
|
-
} =>
|
|
26
|
-
->
|
|
25
|
+
} => JSON.t)
|
|
26
|
+
->JSON.stringify
|
|
27
27
|
|
|
28
28
|
let wsMessageSchema = S.union([
|
|
29
29
|
S.object(s => {
|
|
@@ -57,12 +57,12 @@ let subscribe = (~wsUrl, ~chainId, ~onHeight: int => unit): (unit => unit) => {
|
|
|
57
57
|
let wsRef: ref<option<WebSocket.t>> = ref(None)
|
|
58
58
|
let isUnsubscribed = ref(false)
|
|
59
59
|
let errorCount = ref(0)
|
|
60
|
-
let staleTimeoutId: ref<option<
|
|
60
|
+
let staleTimeoutId: ref<option<timeoutId>> = ref(None)
|
|
61
61
|
|
|
62
62
|
let clearStaleTimeout = () => {
|
|
63
63
|
switch staleTimeoutId.contents {
|
|
64
64
|
| Some(id) =>
|
|
65
|
-
|
|
65
|
+
clearTimeout(id)
|
|
66
66
|
staleTimeoutId := None
|
|
67
67
|
| None => ()
|
|
68
68
|
}
|
|
@@ -70,7 +70,7 @@ let subscribe = (~wsUrl, ~chainId, ~onHeight: int => unit): (unit => unit) => {
|
|
|
70
70
|
|
|
71
71
|
let resetStaleTimeout = () => {
|
|
72
72
|
clearStaleTimeout()
|
|
73
|
-
staleTimeoutId := Some(
|
|
73
|
+
staleTimeoutId := Some(setTimeout(() => {
|
|
74
74
|
// Connection went stale - close to trigger reconnect
|
|
75
75
|
switch wsRef.contents {
|
|
76
76
|
| Some(ws) => ws->WebSocket.close
|
|
@@ -82,9 +82,8 @@ let subscribe = (~wsUrl, ~chainId, ~onHeight: int => unit): (unit => unit) => {
|
|
|
82
82
|
let rec scheduleReconnect = () => {
|
|
83
83
|
if !isUnsubscribed.contents && errorCount.contents < retryCount {
|
|
84
84
|
let duration =
|
|
85
|
-
baseDuration *
|
|
86
|
-
|
|
87
|
-
let _ = Js.Global.setTimeout(() => {
|
|
85
|
+
baseDuration * Math.pow(2.0, ~exp=errorCount.contents->Belt.Int.toFloat)->Belt.Float.toInt
|
|
86
|
+
let _ = setTimeout(() => {
|
|
88
87
|
if !isUnsubscribed.contents {
|
|
89
88
|
startConnection()
|
|
90
89
|
}
|
|
@@ -105,7 +104,7 @@ let subscribe = (~wsUrl, ~chainId, ~onHeight: int => unit): (unit => unit) => {
|
|
|
105
104
|
|
|
106
105
|
ws->WebSocket.onmessage(event => {
|
|
107
106
|
try {
|
|
108
|
-
switch event.data->
|
|
107
|
+
switch event.data->JSON.parseOrThrow->S.parseOrThrow(wsMessageSchema) {
|
|
109
108
|
| NewHead(blockNumber) =>
|
|
110
109
|
errorCount := 0
|
|
111
110
|
resetStaleTimeout()
|
|
@@ -132,7 +131,7 @@ let subscribe = (~wsUrl, ~chainId, ~onHeight: int => unit): (unit => unit) => {
|
|
|
132
131
|
"chainId": chainId,
|
|
133
132
|
"data": event.data,
|
|
134
133
|
})
|
|
135
|
-
|
|
|
134
|
+
| JsExn(_) as e =>
|
|
136
135
|
Logging.warn({
|
|
137
136
|
"msg": "WebSocket height stream failed to parse message",
|
|
138
137
|
"chainId": chainId,
|
|
@@ -146,7 +145,7 @@ let subscribe = (~wsUrl, ~chainId, ~onHeight: int => unit): (unit => unit) => {
|
|
|
146
145
|
"err": e->Utils.prettifyExn,
|
|
147
146
|
"data": event.data,
|
|
148
147
|
})
|
|
149
|
-
|
|
148
|
+
throw(e)
|
|
150
149
|
}
|
|
151
150
|
})
|
|
152
151
|
|
|
@@ -2,195 +2,181 @@
|
|
|
2
2
|
|
|
3
3
|
import * as Rpc from "./Rpc.res.mjs";
|
|
4
4
|
import * as Utils from "../Utils.res.mjs";
|
|
5
|
-
import * as Js_exn from "rescript/lib/es6/js_exn.js";
|
|
6
|
-
import * as Js_json from "rescript/lib/es6/js_json.js";
|
|
7
5
|
import * as Logging from "../Logging.res.mjs";
|
|
8
6
|
import * as Prometheus from "../Prometheus.res.mjs";
|
|
9
|
-
import * as
|
|
7
|
+
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
10
8
|
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
11
|
-
import * as
|
|
9
|
+
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
let subscribeRequestJson = JSON.stringify({
|
|
12
|
+
jsonrpc: "2.0",
|
|
13
|
+
id: 1,
|
|
14
|
+
method: "eth_subscribe",
|
|
15
|
+
params: ["newHeads"]
|
|
16
|
+
});
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}),
|
|
38
|
-
S$RescriptSchema.object(function (s) {
|
|
39
|
-
s.f("error", S$RescriptSchema.unknown);
|
|
40
|
-
return "ErrorResponse";
|
|
41
|
-
})
|
|
42
|
-
]);
|
|
18
|
+
let wsMessageSchema = S$RescriptSchema.union([
|
|
19
|
+
S$RescriptSchema.object(s => {
|
|
20
|
+
s.f("method", S$RescriptSchema.literal("eth_subscription"));
|
|
21
|
+
return {
|
|
22
|
+
TAG: "NewHead",
|
|
23
|
+
_0: s.f("params", S$RescriptSchema.object(s => s.f("result", S$RescriptSchema.object(s => s.f("number", Rpc.hexIntSchema)))))
|
|
24
|
+
};
|
|
25
|
+
}),
|
|
26
|
+
S$RescriptSchema.object(s => ({
|
|
27
|
+
TAG: "SubscriptionConfirmed",
|
|
28
|
+
_0: s.f("result", S$RescriptSchema.string)
|
|
29
|
+
})),
|
|
30
|
+
S$RescriptSchema.object(s => {
|
|
31
|
+
s.f("error", S$RescriptSchema.unknown);
|
|
32
|
+
return "ErrorResponse";
|
|
33
|
+
})
|
|
34
|
+
]);
|
|
43
35
|
|
|
44
36
|
function subscribe(wsUrl, chainId, onHeight) {
|
|
45
|
-
|
|
37
|
+
let wsRef = {
|
|
46
38
|
contents: undefined
|
|
47
39
|
};
|
|
48
|
-
|
|
40
|
+
let isUnsubscribed = {
|
|
49
41
|
contents: false
|
|
50
42
|
};
|
|
51
|
-
|
|
43
|
+
let errorCount = {
|
|
52
44
|
contents: 0
|
|
53
45
|
};
|
|
54
|
-
|
|
46
|
+
let staleTimeoutId = {
|
|
55
47
|
contents: undefined
|
|
56
48
|
};
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
let clearStaleTimeout = () => {
|
|
50
|
+
let id = staleTimeoutId.contents;
|
|
59
51
|
if (id !== undefined) {
|
|
60
|
-
clearTimeout(
|
|
52
|
+
clearTimeout(Primitive_option.valFromOption(id));
|
|
61
53
|
staleTimeoutId.contents = undefined;
|
|
62
|
-
return
|
|
54
|
+
return;
|
|
63
55
|
}
|
|
64
|
-
|
|
65
56
|
};
|
|
66
|
-
|
|
57
|
+
let resetStaleTimeout = () => {
|
|
67
58
|
clearStaleTimeout();
|
|
68
|
-
staleTimeoutId.contents =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}), 60000));
|
|
59
|
+
staleTimeoutId.contents = Primitive_option.some(setTimeout(() => {
|
|
60
|
+
let ws = wsRef.contents;
|
|
61
|
+
if (ws !== undefined) {
|
|
62
|
+
Primitive_option.valFromOption(ws).close();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}, 60000));
|
|
76
66
|
};
|
|
77
|
-
|
|
67
|
+
let scheduleReconnect = () => {
|
|
78
68
|
if (!(!isUnsubscribed.contents && errorCount.contents < 9)) {
|
|
79
|
-
return
|
|
69
|
+
return;
|
|
80
70
|
}
|
|
81
|
-
|
|
82
|
-
setTimeout((
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}), duration);
|
|
71
|
+
let duration = 125 * (Math.pow(2.0, errorCount.contents) | 0) | 0;
|
|
72
|
+
setTimeout(() => {
|
|
73
|
+
if (!isUnsubscribed.contents) {
|
|
74
|
+
return startConnection();
|
|
75
|
+
}
|
|
76
|
+
}, duration);
|
|
88
77
|
};
|
|
89
|
-
|
|
78
|
+
let startConnection = () => {
|
|
90
79
|
if (isUnsubscribed.contents || errorCount.contents >= 9) {
|
|
91
|
-
return
|
|
80
|
+
return;
|
|
92
81
|
}
|
|
93
|
-
|
|
94
|
-
wsRef.contents =
|
|
95
|
-
ws.onopen = (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
ws.onmessage =
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
var ws = wsRef.contents;
|
|
107
|
-
if (ws !== undefined) {
|
|
108
|
-
Caml_option.valFromOption(ws).close();
|
|
109
|
-
return ;
|
|
110
|
-
} else {
|
|
111
|
-
return ;
|
|
112
|
-
}
|
|
82
|
+
let ws = new WebSocket(wsUrl);
|
|
83
|
+
wsRef.contents = Primitive_option.some(ws);
|
|
84
|
+
ws.onopen = () => {
|
|
85
|
+
ws.send(subscribeRequestJson);
|
|
86
|
+
resetStaleTimeout();
|
|
87
|
+
};
|
|
88
|
+
ws.onmessage = event => {
|
|
89
|
+
try {
|
|
90
|
+
let blockNumber = S$RescriptSchema.parseOrThrow(JSON.parse(event.data), wsMessageSchema);
|
|
91
|
+
if (typeof blockNumber !== "object") {
|
|
92
|
+
if (errorCount.contents < 9) {
|
|
93
|
+
errorCount.contents = errorCount.contents + 1 | 0;
|
|
113
94
|
}
|
|
114
|
-
|
|
115
|
-
|
|
95
|
+
let ws = wsRef.contents;
|
|
96
|
+
if (ws !== undefined) {
|
|
97
|
+
Primitive_option.valFromOption(ws).close();
|
|
98
|
+
return;
|
|
99
|
+
} else {
|
|
100
|
+
return;
|
|
116
101
|
}
|
|
117
|
-
errorCount.contents = 0;
|
|
118
|
-
resetStaleTimeout();
|
|
119
|
-
Prometheus.SourceRequestCount.increment("WebSocket", chainId, "eth_subscribe");
|
|
120
|
-
return onHeight(blockNumber._0);
|
|
121
102
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (e.RE_EXN_ID === S$RescriptSchema.Raised) {
|
|
125
|
-
return Logging.warn({
|
|
126
|
-
msg: "WebSocket height stream received unrecognized message",
|
|
127
|
-
chainId: chainId,
|
|
128
|
-
data: $$event.data
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
if (e.RE_EXN_ID === Js_exn.$$Error) {
|
|
132
|
-
return Logging.warn({
|
|
133
|
-
msg: "WebSocket height stream failed to parse message",
|
|
134
|
-
chainId: chainId,
|
|
135
|
-
err: Utils.prettifyExn(e),
|
|
136
|
-
data: $$event.data
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
Logging.error({
|
|
140
|
-
msg: "Unexpected error in WebSocket height stream message handler",
|
|
141
|
-
chainId: chainId,
|
|
142
|
-
err: Utils.prettifyExn(e),
|
|
143
|
-
data: $$event.data
|
|
144
|
-
});
|
|
145
|
-
throw e;
|
|
103
|
+
if (blockNumber.TAG !== "NewHead") {
|
|
104
|
+
return resetStaleTimeout();
|
|
146
105
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (
|
|
154
|
-
return
|
|
106
|
+
errorCount.contents = 0;
|
|
107
|
+
resetStaleTimeout();
|
|
108
|
+
Prometheus.SourceRequestCount.increment("WebSocket", chainId, "eth_subscribe");
|
|
109
|
+
return onHeight(blockNumber._0);
|
|
110
|
+
} catch (raw_e) {
|
|
111
|
+
let e = Primitive_exceptions.internalToException(raw_e);
|
|
112
|
+
if (e.RE_EXN_ID === S$RescriptSchema.Raised) {
|
|
113
|
+
return Logging.warn({
|
|
114
|
+
msg: "WebSocket height stream received unrecognized message",
|
|
115
|
+
chainId: chainId,
|
|
116
|
+
data: event.data
|
|
117
|
+
});
|
|
155
118
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
119
|
+
if (e.RE_EXN_ID === "JsExn") {
|
|
120
|
+
return Logging.warn({
|
|
121
|
+
msg: "WebSocket height stream failed to parse message",
|
|
122
|
+
chainId: chainId,
|
|
123
|
+
err: Utils.prettifyExn(e),
|
|
124
|
+
data: event.data
|
|
125
|
+
});
|
|
160
126
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
127
|
+
Logging.error({
|
|
128
|
+
msg: "Unexpected error in WebSocket height stream message handler",
|
|
129
|
+
chainId: chainId,
|
|
130
|
+
err: Utils.prettifyExn(e),
|
|
131
|
+
data: event.data
|
|
132
|
+
});
|
|
133
|
+
throw e;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
ws.onerror = _error => {
|
|
137
|
+
if (errorCount.contents < 9) {
|
|
138
|
+
errorCount.contents = errorCount.contents + 1 | 0;
|
|
139
|
+
}
|
|
140
|
+
let ws = wsRef.contents;
|
|
141
|
+
if (ws === undefined) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
let ws$1 = Primitive_option.valFromOption(ws);
|
|
145
|
+
if (ws$1.readyState === 1) {
|
|
146
|
+
ws$1.close();
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
ws.onclose = () => {
|
|
151
|
+
wsRef.contents = undefined;
|
|
152
|
+
clearStaleTimeout();
|
|
153
|
+
scheduleReconnect();
|
|
154
|
+
};
|
|
168
155
|
};
|
|
169
156
|
startConnection();
|
|
170
|
-
return
|
|
157
|
+
return () => {
|
|
171
158
|
isUnsubscribed.contents = true;
|
|
172
159
|
clearStaleTimeout();
|
|
173
|
-
|
|
160
|
+
let ws = wsRef.contents;
|
|
174
161
|
if (ws !== undefined) {
|
|
175
|
-
|
|
176
|
-
return
|
|
162
|
+
Primitive_option.valFromOption(ws).close();
|
|
163
|
+
return;
|
|
177
164
|
}
|
|
178
|
-
|
|
179
165
|
};
|
|
180
166
|
}
|
|
181
167
|
|
|
182
|
-
|
|
168
|
+
let retryCount = 9;
|
|
183
169
|
|
|
184
|
-
|
|
170
|
+
let baseDuration = 125;
|
|
185
171
|
|
|
186
|
-
|
|
172
|
+
let staleTimeMillis = 60000;
|
|
187
173
|
|
|
188
174
|
export {
|
|
189
|
-
retryCount
|
|
190
|
-
baseDuration
|
|
191
|
-
staleTimeMillis
|
|
192
|
-
subscribeRequestJson
|
|
193
|
-
wsMessageSchema
|
|
194
|
-
subscribe
|
|
175
|
+
retryCount,
|
|
176
|
+
baseDuration,
|
|
177
|
+
staleTimeMillis,
|
|
178
|
+
subscribeRequestJson,
|
|
179
|
+
wsMessageSchema,
|
|
180
|
+
subscribe,
|
|
195
181
|
}
|
|
196
182
|
/* subscribeRequestJson Not a pure module */
|
|
@@ -21,7 +21,7 @@ let make = (~items: array<Internal.item>, ~endBlock: int, ~chain: ChainMap.Chain
|
|
|
21
21
|
~fromBlock as _,
|
|
22
22
|
~toBlock as _,
|
|
23
23
|
~addressesByContractName as _,
|
|
24
|
-
~
|
|
24
|
+
~indexingAddresses as _,
|
|
25
25
|
~knownHeight as _,
|
|
26
26
|
~partitionId as _,
|
|
27
27
|
~selection as _,
|
|
@@ -1,50 +1,47 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
+
import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.js";
|
|
3
4
|
|
|
4
5
|
function make(items, endBlock, chain) {
|
|
5
|
-
|
|
6
|
+
let delivered = {
|
|
6
7
|
contents: false
|
|
7
8
|
};
|
|
8
9
|
return {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
})
|
|
44
|
-
};
|
|
10
|
+
name: "SimulateSource",
|
|
11
|
+
sourceFor: "Sync",
|
|
12
|
+
chain: chain,
|
|
13
|
+
poweredByHyperSync: false,
|
|
14
|
+
pollingInterval: 0,
|
|
15
|
+
getBlockHashes: (param, param$1) => Promise.resolve({
|
|
16
|
+
TAG: "Ok",
|
|
17
|
+
_0: []
|
|
18
|
+
}),
|
|
19
|
+
getHeightOrThrow: () => Promise.resolve(Primitive_int.max(endBlock, 1)),
|
|
20
|
+
getItemsOrThrow: (param, param$1, param$2, param$3, param$4, param$5, param$6, param$7, param$8) => {
|
|
21
|
+
let result = delivered.contents ? [] : (delivered.contents = true, items);
|
|
22
|
+
let reportedHeight = Primitive_int.max(endBlock, 1);
|
|
23
|
+
return Promise.resolve({
|
|
24
|
+
knownHeight: reportedHeight,
|
|
25
|
+
reorgGuard: {
|
|
26
|
+
rangeLastBlock: {
|
|
27
|
+
blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
28
|
+
blockNumber: reportedHeight
|
|
29
|
+
},
|
|
30
|
+
prevRangeLastBlock: undefined
|
|
31
|
+
},
|
|
32
|
+
parsedQueueItems: result,
|
|
33
|
+
fromBlockQueried: 0,
|
|
34
|
+
latestFetchedBlockNumber: reportedHeight,
|
|
35
|
+
latestFetchedBlockTimestamp: 0,
|
|
36
|
+
stats: {
|
|
37
|
+
"total time elapsed (s)": 0
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
45
42
|
}
|
|
46
43
|
|
|
47
44
|
export {
|
|
48
|
-
make
|
|
45
|
+
make,
|
|
49
46
|
}
|
|
50
47
|
/* No side effect */
|
package/src/sources/Source.res
CHANGED
|
@@ -50,7 +50,7 @@ type t = {
|
|
|
50
50
|
~fromBlock: int,
|
|
51
51
|
~toBlock: option<int>,
|
|
52
52
|
~addressesByContractName: dict<array<Address.t>>,
|
|
53
|
-
~
|
|
53
|
+
~indexingAddresses: dict<FetchState.indexingAddress>,
|
|
54
54
|
~knownHeight: int,
|
|
55
55
|
~partitionId: string,
|
|
56
56
|
~selection: FetchState.selection,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as
|
|
3
|
+
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
let GetItemsError = /* @__PURE__ */Primitive_exceptions.create("Source.GetItemsError");
|
|
6
6
|
|
|
7
7
|
export {
|
|
8
|
-
GetItemsError
|
|
8
|
+
GetItemsError,
|
|
9
9
|
}
|
|
10
10
|
/* No side effect */
|