envio 3.0.0-alpha.21 → 3.0.0-alpha.23
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/README.md +3 -3
- 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 +430 -51
- package/src/Main.res.mjs +530 -271
- package/src/Persistence.res +80 -84
- package/src/Persistence.res.mjs +131 -132
- package/src/PgStorage.res +294 -167
- package/src/PgStorage.res.mjs +799 -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 +16 -16
- package/src/TestIndexerProxyStorage.res.mjs +99 -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 +7 -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
|
@@ -1,75 +1,71 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
|
|
6
|
-
import * as Caml_option from "rescript/lib/es6/caml_option.js";
|
|
3
|
+
import * as Ink from "../bindings/Ink.res.mjs";
|
|
4
|
+
import * as Ink$1 from "ink";
|
|
7
5
|
import * as CustomHooks from "./CustomHooks.res.mjs";
|
|
8
6
|
import * as JsxRuntime from "react/jsx-runtime";
|
|
9
7
|
|
|
10
8
|
function Messages$Message(props) {
|
|
11
|
-
|
|
12
|
-
return JsxRuntime.jsx(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
let message = props.message;
|
|
10
|
+
return JsxRuntime.jsx(Ink$1.Text, {
|
|
11
|
+
children: message.content,
|
|
12
|
+
color: CustomHooks.InitApi.toTheme(message.color)
|
|
13
|
+
});
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
let Message = {
|
|
19
17
|
make: Messages$Message
|
|
20
18
|
};
|
|
21
19
|
|
|
22
20
|
function Messages$Notifications(props) {
|
|
23
21
|
return JsxRuntime.jsxs(JsxRuntime.Fragment, {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
children: [
|
|
23
|
+
JsxRuntime.jsx(Ink.Newline.make, {}),
|
|
24
|
+
JsxRuntime.jsx(Ink$1.Text, {
|
|
25
|
+
children: "Notifications:",
|
|
26
|
+
bold: true
|
|
27
|
+
}),
|
|
28
|
+
props.children
|
|
29
|
+
]
|
|
30
|
+
});
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
|
|
33
|
+
let Notifications = {
|
|
36
34
|
make: Messages$Notifications
|
|
37
35
|
};
|
|
38
36
|
|
|
39
37
|
function Messages(props) {
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
let messages = CustomHooks.useMessages(props.config);
|
|
39
|
+
let tmp;
|
|
42
40
|
if (typeof messages !== "object") {
|
|
43
41
|
tmp = null;
|
|
44
42
|
} else if (messages.TAG === "Data") {
|
|
45
|
-
|
|
43
|
+
let messages$1 = messages._0;
|
|
46
44
|
tmp = messages$1.length !== 0 ? JsxRuntime.jsx(Messages$Notifications, {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}))
|
|
52
|
-
}) : null;
|
|
45
|
+
children: messages$1.map((message, i) => JsxRuntime.jsx(Messages$Message, {
|
|
46
|
+
message: message
|
|
47
|
+
}, i.toString()))
|
|
48
|
+
}) : null;
|
|
53
49
|
} else {
|
|
54
50
|
tmp = JsxRuntime.jsx(Messages$Notifications, {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
children: JsxRuntime.jsx(Messages$Message, {
|
|
52
|
+
message: {
|
|
53
|
+
color: "danger",
|
|
54
|
+
content: "Failed to load messages from envio server"
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
});
|
|
62
58
|
}
|
|
63
59
|
return JsxRuntime.jsx(JsxRuntime.Fragment, {
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
children: tmp
|
|
61
|
+
});
|
|
66
62
|
}
|
|
67
63
|
|
|
68
|
-
|
|
64
|
+
let make = Messages;
|
|
69
65
|
|
|
70
66
|
export {
|
|
71
|
-
Message
|
|
72
|
-
Notifications
|
|
73
|
-
make
|
|
67
|
+
Message,
|
|
68
|
+
Notifications,
|
|
69
|
+
make,
|
|
74
70
|
}
|
|
75
71
|
/* Ink Not a pure module */
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
open Ink
|
|
2
|
-
open Belt
|
|
3
2
|
|
|
4
3
|
let isIndexerFullySynced = (chains: array<TuiData.chain>) => {
|
|
5
4
|
chains->Array.reduce(true, (accum, current) => {
|
|
@@ -25,12 +24,12 @@ let getTotalRemainingBlocks = (chains: array<TuiData.chain>) => {
|
|
|
25
24
|
})
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
let getLatestTimeCaughtUpToHead = (chains: array<TuiData.chain>, indexerStartTime:
|
|
27
|
+
let getLatestTimeCaughtUpToHead = (chains: array<TuiData.chain>, indexerStartTime: Date.t) => {
|
|
29
28
|
let latesttimestampCaughtUpToHeadOrEndblockFloat = chains->Array.reduce(0.0, (accum, current) => {
|
|
30
29
|
switch current.progress {
|
|
31
30
|
| Synced({timestampCaughtUpToHeadOrEndblock}) =>
|
|
32
|
-
timestampCaughtUpToHeadOrEndblock->
|
|
33
|
-
? timestampCaughtUpToHeadOrEndblock->
|
|
31
|
+
timestampCaughtUpToHeadOrEndblock->Date.getTime > accum
|
|
32
|
+
? timestampCaughtUpToHeadOrEndblock->Date.getTime
|
|
34
33
|
: accum
|
|
35
34
|
| Syncing(_)
|
|
36
35
|
| SearchingForEvents => accum
|
|
@@ -39,7 +38,7 @@ let getLatestTimeCaughtUpToHead = (chains: array<TuiData.chain>, indexerStartTim
|
|
|
39
38
|
|
|
40
39
|
DateFns.formatDistanceWithOptions(
|
|
41
40
|
indexerStartTime,
|
|
42
|
-
latesttimestampCaughtUpToHeadOrEndblockFloat->
|
|
41
|
+
latesttimestampCaughtUpToHeadOrEndblockFloat->Date.fromTime,
|
|
43
42
|
{includeSeconds: true},
|
|
44
43
|
)
|
|
45
44
|
}
|
|
@@ -81,14 +80,14 @@ let useEta = (~chains, ~indexerStartTime) => {
|
|
|
81
80
|
let (timeSinceStart, setTimeSinceStart) = React.useState(_ => 0.)
|
|
82
81
|
|
|
83
82
|
React.useEffect2(() => {
|
|
84
|
-
setTimeSinceStart(_ =>
|
|
83
|
+
setTimeSinceStart(_ => Date.now() -. indexerStartTime->Date.getTime)
|
|
85
84
|
setSecondsToSub(_ => 0.)
|
|
86
85
|
|
|
87
|
-
let intervalId =
|
|
86
|
+
let intervalId = setInterval(() => {
|
|
88
87
|
setSecondsToSub(prev => prev +. 1.)
|
|
89
88
|
}, 1000)
|
|
90
89
|
|
|
91
|
-
Some(() =>
|
|
90
|
+
Some(() => clearInterval(intervalId))
|
|
92
91
|
}, (chains, indexerStartTime))
|
|
93
92
|
|
|
94
93
|
//blocksProcessed/remainingBlocks = timeSoFar/eta
|
|
@@ -96,13 +95,13 @@ let useEta = (~chains, ~indexerStartTime) => {
|
|
|
96
95
|
|
|
97
96
|
let blocksProcessed = getTotalBlocksProcessed(chains)->Int.toFloat
|
|
98
97
|
if shouldDisplayEta && blocksProcessed > 0. {
|
|
99
|
-
let nowDate =
|
|
98
|
+
let nowDate = Date.now()
|
|
100
99
|
let remainingBlocks = getTotalRemainingBlocks(chains)->Int.toFloat
|
|
101
100
|
let etaFloat = timeSinceStart /. blocksProcessed *. remainingBlocks
|
|
102
101
|
let millisToSub = secondsToSub *. 1000.
|
|
103
102
|
let etaFloat = Pervasives.max(etaFloat -. millisToSub, 0.0) //template this
|
|
104
|
-
let eta = (etaFloat +. nowDate)->
|
|
105
|
-
let interval: DateFns.interval = {start: nowDate->
|
|
103
|
+
let eta = (etaFloat +. nowDate)->Date.fromTime
|
|
104
|
+
let interval: DateFns.interval = {start: nowDate->Date.fromTime, end: eta}
|
|
106
105
|
let duration = DateFns.intervalToDuration(interval)
|
|
107
106
|
let formattedDuration = DateFns.formatDuration(
|
|
108
107
|
duration,
|
|
@@ -1,263 +1,245 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as
|
|
4
|
-
import * as Caml from "rescript/lib/es6/caml.js";
|
|
3
|
+
import * as Ink from "ink";
|
|
5
4
|
import * as React from "react";
|
|
6
5
|
import * as DateFns from "date-fns";
|
|
7
|
-
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
|
|
8
6
|
import InkSpinner from "ink-spinner";
|
|
7
|
+
import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
|
|
8
|
+
import * as Primitive_float from "@rescript/runtime/lib/es6/Primitive_float.js";
|
|
9
9
|
import * as JsxRuntime from "react/jsx-runtime";
|
|
10
10
|
|
|
11
11
|
function isIndexerFullySynced(chains) {
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
return Stdlib_Array.reduce(chains, true, (accum, current) => {
|
|
13
|
+
let match = current.progress;
|
|
14
|
+
if (typeof match !== "object" || match.TAG === "Syncing") {
|
|
15
|
+
return false;
|
|
16
|
+
} else {
|
|
17
|
+
return accum;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
function getTotalRemainingBlocks(chains) {
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
return Stdlib_Array.reduce(chains, 0, (accum, param) => {
|
|
24
|
+
let progress = param.progress;
|
|
25
|
+
let endBlock = param.endBlock;
|
|
26
|
+
let finalBlock = endBlock !== undefined ? endBlock : param.knownHeight;
|
|
27
|
+
if (typeof progress !== "object") {
|
|
28
|
+
return (finalBlock - param.latestFetchedBlockNumber | 0) + accum | 0;
|
|
29
|
+
}
|
|
30
|
+
progress.TAG === "Syncing";
|
|
31
|
+
return (finalBlock - progress._0.latestProcessedBlock | 0) + accum | 0;
|
|
32
|
+
});
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
function getLatestTimeCaughtUpToHead(chains, indexerStartTime) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
36
|
+
let latesttimestampCaughtUpToHeadOrEndblockFloat = Stdlib_Array.reduce(chains, 0.0, (accum, current) => {
|
|
37
|
+
let match = current.progress;
|
|
38
|
+
if (typeof match !== "object") {
|
|
39
|
+
return accum;
|
|
40
|
+
}
|
|
41
|
+
if (match.TAG === "Syncing") {
|
|
42
|
+
return accum;
|
|
43
|
+
}
|
|
44
|
+
let timestampCaughtUpToHeadOrEndblock = match._0.timestampCaughtUpToHeadOrEndblock;
|
|
45
|
+
if (timestampCaughtUpToHeadOrEndblock.getTime() > accum) {
|
|
46
|
+
return timestampCaughtUpToHeadOrEndblock.getTime();
|
|
47
|
+
} else {
|
|
48
|
+
return accum;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
51
|
return DateFns.formatDistance(indexerStartTime, new Date(latesttimestampCaughtUpToHeadOrEndblockFloat), {
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
includeSeconds: true
|
|
53
|
+
});
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
function getTotalBlocksProcessed(chains) {
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
return Stdlib_Array.reduce(chains, 0, (accum, param) => {
|
|
58
|
+
let progress = param.progress;
|
|
59
|
+
if (typeof progress !== "object") {
|
|
60
|
+
return param.latestFetchedBlockNumber + accum | 0;
|
|
61
|
+
}
|
|
62
|
+
progress.TAG === "Syncing";
|
|
63
|
+
let match = progress._0;
|
|
64
|
+
return (match.latestProcessedBlock - match.firstEventBlockNumber | 0) + accum | 0;
|
|
65
|
+
});
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
function useShouldDisplayEta(chains) {
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
let match = React.useState(() => false);
|
|
70
|
+
let setShouldDisplayEta = match[1];
|
|
71
|
+
let shouldDisplayEta = match[0];
|
|
72
|
+
React.useEffect(() => {
|
|
73
|
+
if (!shouldDisplayEta) {
|
|
74
|
+
let allChainsStartedFetching = chains.every(chain => {
|
|
75
|
+
if (chain.knownHeight > 0) {
|
|
76
|
+
return chain.latestFetchedBlockNumber > 0;
|
|
77
|
+
} else {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
71
80
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (chain.knownHeight > 0) {
|
|
78
|
-
return chain.latestFetchedBlockNumber > 0;
|
|
79
|
-
} else {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
}));
|
|
83
|
-
if (allChainsStartedFetching) {
|
|
84
|
-
setShouldDisplayEta(function (param) {
|
|
85
|
-
return true;
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
}), [chains]);
|
|
81
|
+
if (allChainsStartedFetching) {
|
|
82
|
+
setShouldDisplayEta(param => true);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}, [chains]);
|
|
92
86
|
return shouldDisplayEta;
|
|
93
87
|
}
|
|
94
88
|
|
|
95
89
|
function useEta(chains, indexerStartTime) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
setSecondsToSub(function (prev) {
|
|
114
|
-
return prev + 1;
|
|
115
|
-
});
|
|
116
|
-
}), 1000);
|
|
117
|
-
return (function () {
|
|
118
|
-
clearInterval(intervalId);
|
|
119
|
-
});
|
|
120
|
-
}), [
|
|
121
|
-
chains,
|
|
122
|
-
indexerStartTime
|
|
123
|
-
]);
|
|
124
|
-
var blocksProcessed = getTotalBlocksProcessed(chains);
|
|
90
|
+
let shouldDisplayEta = useShouldDisplayEta(chains);
|
|
91
|
+
let match = React.useState(() => 0);
|
|
92
|
+
let setSecondsToSub = match[1];
|
|
93
|
+
let match$1 = React.useState(() => 0);
|
|
94
|
+
let setTimeSinceStart = match$1[1];
|
|
95
|
+
React.useEffect(() => {
|
|
96
|
+
setTimeSinceStart(param => Date.now() - indexerStartTime.getTime());
|
|
97
|
+
setSecondsToSub(param => 0);
|
|
98
|
+
let intervalId = setInterval(() => setSecondsToSub(prev => prev + 1), 1000);
|
|
99
|
+
return () => {
|
|
100
|
+
clearInterval(intervalId);
|
|
101
|
+
};
|
|
102
|
+
}, [
|
|
103
|
+
chains,
|
|
104
|
+
indexerStartTime
|
|
105
|
+
]);
|
|
106
|
+
let blocksProcessed = getTotalBlocksProcessed(chains);
|
|
125
107
|
if (!(shouldDisplayEta && blocksProcessed > 0)) {
|
|
126
|
-
return
|
|
108
|
+
return;
|
|
127
109
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
110
|
+
let nowDate = Date.now();
|
|
111
|
+
let remainingBlocks = getTotalRemainingBlocks(chains);
|
|
112
|
+
let etaFloat = match$1[0] / blocksProcessed * remainingBlocks;
|
|
113
|
+
let millisToSub = match[0] * 1000;
|
|
114
|
+
let etaFloat$1 = Primitive_float.max(etaFloat - millisToSub, 0.0);
|
|
115
|
+
let eta = new Date(etaFloat$1 + nowDate);
|
|
116
|
+
let interval_start = new Date(nowDate);
|
|
117
|
+
let interval = {
|
|
136
118
|
start: interval_start,
|
|
137
119
|
end: eta
|
|
138
120
|
};
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
121
|
+
let duration = DateFns.intervalToDuration(interval);
|
|
122
|
+
let formattedDuration = DateFns.formatDuration(duration, {
|
|
123
|
+
format: [
|
|
124
|
+
"hours",
|
|
125
|
+
"minutes",
|
|
126
|
+
"seconds"
|
|
127
|
+
]
|
|
128
|
+
});
|
|
129
|
+
let tmp = formattedDuration === "" ? "less than 1 second" : formattedDuration;
|
|
148
130
|
return tmp;
|
|
149
131
|
}
|
|
150
132
|
|
|
151
133
|
function SyncETA$Syncing(props) {
|
|
152
|
-
return JsxRuntime.jsxs(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
134
|
+
return JsxRuntime.jsxs(Ink.Text, {
|
|
135
|
+
children: [
|
|
136
|
+
JsxRuntime.jsx(Ink.Text, {
|
|
137
|
+
children: "Sync Time ETA: "
|
|
138
|
+
}),
|
|
139
|
+
JsxRuntime.jsx(Ink.Text, {
|
|
140
|
+
children: props.etaStr
|
|
141
|
+
}),
|
|
142
|
+
JsxRuntime.jsx(Ink.Text, {
|
|
143
|
+
children: " ("
|
|
144
|
+
}),
|
|
145
|
+
JsxRuntime.jsx(Ink.Text, {
|
|
146
|
+
children: JsxRuntime.jsx(InkSpinner, {}),
|
|
147
|
+
color: "#9860E5"
|
|
148
|
+
}),
|
|
149
|
+
JsxRuntime.jsx(Ink.Text, {
|
|
150
|
+
children: " in progress",
|
|
151
|
+
color: "#FFBB2F"
|
|
152
|
+
}),
|
|
153
|
+
JsxRuntime.jsx(Ink.Text, {
|
|
154
|
+
children: ")"
|
|
155
|
+
})
|
|
156
|
+
],
|
|
157
|
+
bold: true
|
|
158
|
+
});
|
|
177
159
|
}
|
|
178
160
|
|
|
179
|
-
|
|
161
|
+
let Syncing = {
|
|
180
162
|
make: SyncETA$Syncing
|
|
181
163
|
};
|
|
182
164
|
|
|
183
165
|
function SyncETA$Synced(props) {
|
|
184
|
-
return JsxRuntime.jsxs(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
166
|
+
return JsxRuntime.jsxs(Ink.Text, {
|
|
167
|
+
children: [
|
|
168
|
+
JsxRuntime.jsx(Ink.Text, {
|
|
169
|
+
children: "Time Synced: "
|
|
170
|
+
}),
|
|
171
|
+
JsxRuntime.jsx(Ink.Text, {
|
|
172
|
+
children: props.latestTimeCaughtUpToHeadStr
|
|
173
|
+
}),
|
|
174
|
+
JsxRuntime.jsx(Ink.Text, {
|
|
175
|
+
children: " ("
|
|
176
|
+
}),
|
|
177
|
+
JsxRuntime.jsx(Ink.Text, {
|
|
178
|
+
children: "synced",
|
|
179
|
+
color: "#3B8C3D"
|
|
180
|
+
}),
|
|
181
|
+
JsxRuntime.jsx(Ink.Text, {
|
|
182
|
+
children: ")"
|
|
183
|
+
})
|
|
184
|
+
],
|
|
185
|
+
bold: true
|
|
186
|
+
});
|
|
205
187
|
}
|
|
206
188
|
|
|
207
|
-
|
|
189
|
+
let Synced = {
|
|
208
190
|
make: SyncETA$Synced
|
|
209
191
|
};
|
|
210
192
|
|
|
211
193
|
function SyncETA$Calculating(props) {
|
|
212
|
-
return JsxRuntime.jsxs(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
194
|
+
return JsxRuntime.jsxs(Ink.Text, {
|
|
195
|
+
children: [
|
|
196
|
+
JsxRuntime.jsx(Ink.Text, {
|
|
197
|
+
children: JsxRuntime.jsx(InkSpinner, {}),
|
|
198
|
+
color: "#9860E5"
|
|
199
|
+
}),
|
|
200
|
+
JsxRuntime.jsx(Ink.Text, {
|
|
201
|
+
children: " Calculating ETA...",
|
|
202
|
+
bold: true
|
|
203
|
+
})
|
|
204
|
+
]
|
|
205
|
+
});
|
|
224
206
|
}
|
|
225
207
|
|
|
226
|
-
|
|
208
|
+
let Calculating = {
|
|
227
209
|
make: SyncETA$Calculating
|
|
228
210
|
};
|
|
229
211
|
|
|
230
212
|
function SyncETA(props) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
213
|
+
let indexerStartTime = props.indexerStartTime;
|
|
214
|
+
let chains = props.chains;
|
|
215
|
+
let optEta = useEta(chains, indexerStartTime);
|
|
234
216
|
if (!isIndexerFullySynced(chains)) {
|
|
235
217
|
if (optEta !== undefined) {
|
|
236
218
|
return JsxRuntime.jsx(SyncETA$Syncing, {
|
|
237
|
-
|
|
238
|
-
|
|
219
|
+
etaStr: optEta
|
|
220
|
+
});
|
|
239
221
|
} else {
|
|
240
222
|
return JsxRuntime.jsx(SyncETA$Calculating, {});
|
|
241
223
|
}
|
|
242
224
|
}
|
|
243
|
-
|
|
225
|
+
let latestTimeCaughtUpToHeadStr = getLatestTimeCaughtUpToHead(chains, indexerStartTime);
|
|
244
226
|
return JsxRuntime.jsx(SyncETA$Synced, {
|
|
245
|
-
|
|
246
|
-
|
|
227
|
+
latestTimeCaughtUpToHeadStr: latestTimeCaughtUpToHeadStr
|
|
228
|
+
});
|
|
247
229
|
}
|
|
248
230
|
|
|
249
|
-
|
|
231
|
+
let make = SyncETA;
|
|
250
232
|
|
|
251
233
|
export {
|
|
252
|
-
isIndexerFullySynced
|
|
253
|
-
getTotalRemainingBlocks
|
|
254
|
-
getLatestTimeCaughtUpToHead
|
|
255
|
-
getTotalBlocksProcessed
|
|
256
|
-
useShouldDisplayEta
|
|
257
|
-
useEta
|
|
258
|
-
Syncing
|
|
259
|
-
Synced
|
|
260
|
-
Calculating
|
|
261
|
-
make
|
|
234
|
+
isIndexerFullySynced,
|
|
235
|
+
getTotalRemainingBlocks,
|
|
236
|
+
getLatestTimeCaughtUpToHead,
|
|
237
|
+
getTotalBlocksProcessed,
|
|
238
|
+
useShouldDisplayEta,
|
|
239
|
+
useEta,
|
|
240
|
+
Syncing,
|
|
241
|
+
Synced,
|
|
242
|
+
Calculating,
|
|
243
|
+
make,
|
|
262
244
|
}
|
|
263
245
|
/* ink Not a pure module */
|
|
@@ -1,5 +1,6 @@
|
|
|
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 getNumberOfEventsProccessed(progress) {
|
|
5
6
|
if (typeof progress !== "object") {
|
|
@@ -10,8 +11,8 @@ function getNumberOfEventsProccessed(progress) {
|
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
function minOfOption(a, b) {
|
|
13
|
-
if (b !== undefined
|
|
14
|
-
return b;
|
|
14
|
+
if (b !== undefined) {
|
|
15
|
+
return Primitive_int.min(a, b);
|
|
15
16
|
} else {
|
|
16
17
|
return a;
|
|
17
18
|
}
|
|
@@ -26,9 +27,9 @@ function formatFloatLocaleString(n) {
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export {
|
|
29
|
-
getNumberOfEventsProccessed
|
|
30
|
-
minOfOption
|
|
31
|
-
formatLocaleString
|
|
32
|
-
formatFloatLocaleString
|
|
30
|
+
getNumberOfEventsProccessed,
|
|
31
|
+
minOfOption,
|
|
32
|
+
formatLocaleString,
|
|
33
|
+
formatFloatLocaleString,
|
|
33
34
|
}
|
|
34
35
|
/* No side effect */
|