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
package/src/tui/bindings/Ink.res
CHANGED
|
@@ -117,8 +117,7 @@ module Spacer = {
|
|
|
117
117
|
|
|
118
118
|
For example, using <Spacer> in a <Box> with default flex direction (row) will position "Left" on the left side and will push "Right" to the right side.
|
|
119
119
|
*/
|
|
120
|
-
@module("ink")
|
|
121
|
-
@react.component
|
|
120
|
+
@module("ink") @react.component
|
|
122
121
|
external make: unit => React.element = "Spacer"
|
|
123
122
|
}
|
|
124
123
|
|
|
@@ -128,8 +127,7 @@ module Static = {
|
|
|
128
127
|
|
|
129
128
|
It's preferred to use <Static> for use cases like these, when you can't know or control the amount of items that need to be rendered.
|
|
130
129
|
*/
|
|
131
|
-
@module("ink")
|
|
132
|
-
@react.component
|
|
130
|
+
@module("ink") @react.component
|
|
133
131
|
external make: (
|
|
134
132
|
~children: ('a, int) => React.element,
|
|
135
133
|
~items: array<'a>,
|
|
@@ -1,72 +1,66 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as
|
|
3
|
+
import * as Ink from "ink";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import * as JsxRuntime from "react/jsx-runtime";
|
|
6
6
|
|
|
7
7
|
function render(options, element) {
|
|
8
|
-
return
|
|
8
|
+
return Ink.render(element, options);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
let Text = {};
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
let Box = {};
|
|
14
14
|
|
|
15
15
|
function Ink$Newline(props) {
|
|
16
|
-
return JsxRuntime.jsx(
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
return JsxRuntime.jsx(Ink.Text, {
|
|
17
|
+
children: " "
|
|
18
|
+
});
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
let Newline = {
|
|
22
22
|
make: Ink$Newline
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
let Spacer = {};
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
let Static = {};
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
let Transform = {};
|
|
30
30
|
|
|
31
31
|
function useStdoutColumns() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
stdout.on("resize", handler);
|
|
45
|
-
return (function () {
|
|
46
|
-
stdout.off("resize", handler);
|
|
47
|
-
});
|
|
48
|
-
}), [stdout]);
|
|
32
|
+
let match = Ink.useStdout();
|
|
33
|
+
let stdout = match.stdout;
|
|
34
|
+
let match$1 = React.useState(() => stdout.columns);
|
|
35
|
+
let setColumns = match$1[1];
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
let handler = () => setColumns(param => stdout.columns);
|
|
38
|
+
stdout.on("resize", handler);
|
|
39
|
+
return () => {
|
|
40
|
+
stdout.off("resize", handler);
|
|
41
|
+
};
|
|
42
|
+
}, [stdout]);
|
|
49
43
|
return match$1[0];
|
|
50
44
|
}
|
|
51
45
|
|
|
52
|
-
|
|
46
|
+
let Hooks = {
|
|
53
47
|
useStdoutColumns: useStdoutColumns
|
|
54
48
|
};
|
|
55
49
|
|
|
56
|
-
|
|
50
|
+
let BigText = {};
|
|
57
51
|
|
|
58
|
-
|
|
52
|
+
let Spinner = {};
|
|
59
53
|
|
|
60
54
|
export {
|
|
61
|
-
render
|
|
62
|
-
|
|
63
|
-
Box
|
|
64
|
-
Newline
|
|
65
|
-
Spacer
|
|
66
|
-
Static
|
|
67
|
-
Transform
|
|
68
|
-
Hooks
|
|
69
|
-
BigText
|
|
70
|
-
Spinner
|
|
55
|
+
render,
|
|
56
|
+
Text,
|
|
57
|
+
Box,
|
|
58
|
+
Newline,
|
|
59
|
+
Spacer,
|
|
60
|
+
Static,
|
|
61
|
+
Transform,
|
|
62
|
+
Hooks,
|
|
63
|
+
BigText,
|
|
64
|
+
Spinner,
|
|
71
65
|
}
|
|
72
66
|
/* ink Not a pure module */
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
open Ink
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
@react.component
|
|
4
4
|
let make = (~loaded, ~buffered=?, ~outOf, ~barWidth=36, ~loadingColor=Style.Secondary) => {
|
|
5
5
|
let maxCount = barWidth
|
|
6
6
|
|
|
7
7
|
let loadedFraction = loaded->Int.toFloat /. outOf->Int.toFloat
|
|
8
8
|
let loadedCount = Pervasives.min(
|
|
9
|
-
|
|
9
|
+
Math.floor(maxCount->Int.toFloat *. loadedFraction)->Belt.Float.toInt,
|
|
10
10
|
maxCount,
|
|
11
11
|
)
|
|
12
12
|
|
|
13
|
-
let bufferedCount = buffered->Option.
|
|
13
|
+
let bufferedCount = buffered->Option.mapOr(loadedCount, buffered => {
|
|
14
14
|
let bufferedFraction = buffered->Int.toFloat /. outOf->Int.toFloat
|
|
15
15
|
Pervasives.min(
|
|
16
|
-
|
|
16
|
+
Math.floor(maxCount->Int.toFloat *. bufferedFraction)->Belt.Float.toInt,
|
|
17
17
|
maxCount,
|
|
18
18
|
)
|
|
19
19
|
})
|
|
@@ -27,14 +27,14 @@ let make = (~loaded, ~buffered=?, ~outOf, ~barWidth=36, ~loadingColor=Style.Seco
|
|
|
27
27
|
|
|
28
28
|
<Box>
|
|
29
29
|
<Text backgroundColor={loadingColor} color={Gray}>
|
|
30
|
-
<Text> {" "->
|
|
30
|
+
<Text> {" "->String.repeat(loadedSpaces)->React.string} </Text>
|
|
31
31
|
<Text> {loadedPercentageStr->React.string} </Text>
|
|
32
32
|
</Text>
|
|
33
33
|
<Text backgroundColor={Gray}>
|
|
34
|
-
{" "->
|
|
34
|
+
{" "->String.repeat(bufferedCount - loadedCount)->React.string}
|
|
35
35
|
</Text>
|
|
36
36
|
<Text backgroundColor={White}>
|
|
37
|
-
{" "->
|
|
37
|
+
{" "->String.repeat(maxCount - bufferedCount)->React.string}
|
|
38
38
|
</Text>
|
|
39
39
|
</Box>
|
|
40
40
|
}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
3
|
+
import * as Ink from "ink";
|
|
4
|
+
import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.js";
|
|
5
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
6
6
|
import * as JsxRuntime from "react/jsx-runtime";
|
|
7
7
|
|
|
8
8
|
function BufferedProgressBar(props) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return JsxRuntime.jsxs(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
9
|
+
let __loadingColor = props.loadingColor;
|
|
10
|
+
let __barWidth = props.barWidth;
|
|
11
|
+
let outOf = props.outOf;
|
|
12
|
+
let barWidth = __barWidth !== undefined ? __barWidth : 36;
|
|
13
|
+
let loadingColor = __loadingColor !== undefined ? __loadingColor : "#FFBB2F";
|
|
14
|
+
let loadedFraction = props.loaded / outOf;
|
|
15
|
+
let loadedCount = Primitive_int.min(Math.floor(barWidth * loadedFraction) | 0, barWidth);
|
|
16
|
+
let bufferedCount = Stdlib_Option.mapOr(props.buffered, loadedCount, buffered => {
|
|
17
|
+
let bufferedFraction = buffered / outOf;
|
|
18
|
+
return Primitive_int.min(Math.floor(barWidth * bufferedFraction) | 0, barWidth);
|
|
19
|
+
});
|
|
20
|
+
let loadedFraction$1 = loadedFraction > 0.0 ? loadedFraction : 0.0;
|
|
21
|
+
let loadedPercentageStr = (loadedFraction$1 * 100 | 0).toString() + "% ";
|
|
22
|
+
let loadedPercentageStrCount = loadedPercentageStr.length;
|
|
23
|
+
let loadedSpaces = Primitive_int.max(loadedCount - loadedPercentageStrCount | 0, 0);
|
|
24
|
+
let loadedCount$1 = Primitive_int.max(loadedCount, loadedPercentageStrCount);
|
|
25
|
+
let bufferedCount$1 = Primitive_int.max(bufferedCount, loadedCount$1);
|
|
26
|
+
return JsxRuntime.jsxs(Ink.Box, {
|
|
27
|
+
children: [
|
|
28
|
+
JsxRuntime.jsxs(Ink.Text, {
|
|
29
|
+
children: [
|
|
30
|
+
JsxRuntime.jsx(Ink.Text, {
|
|
31
|
+
children: " ".repeat(loadedSpaces)
|
|
32
|
+
}),
|
|
33
|
+
JsxRuntime.jsx(Ink.Text, {
|
|
34
|
+
children: loadedPercentageStr
|
|
35
|
+
})
|
|
36
|
+
],
|
|
37
|
+
color: "gray",
|
|
38
|
+
backgroundColor: loadingColor
|
|
39
|
+
}),
|
|
40
|
+
JsxRuntime.jsx(Ink.Text, {
|
|
41
|
+
children: " ".repeat(bufferedCount$1 - loadedCount$1 | 0),
|
|
42
|
+
backgroundColor: "gray"
|
|
43
|
+
}),
|
|
44
|
+
JsxRuntime.jsx(Ink.Text, {
|
|
45
|
+
children: " ".repeat(barWidth - bufferedCount$1 | 0),
|
|
46
|
+
backgroundColor: "white"
|
|
47
|
+
})
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
let make = BufferedProgressBar;
|
|
53
53
|
|
|
54
54
|
export {
|
|
55
|
-
make
|
|
55
|
+
make,
|
|
56
56
|
}
|
|
57
57
|
/* ink Not a pure module */
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
open Belt
|
|
2
1
|
module InitApi = {
|
|
3
2
|
type ecosystem = | @as("evm") Evm | @as("fuel") Fuel | @as("svm") Svm
|
|
4
3
|
type body = {
|
|
@@ -35,7 +34,7 @@ module InitApi = {
|
|
|
35
34
|
| true => hyperSyncNetworks
|
|
36
35
|
| false => rpcNetworks
|
|
37
36
|
}
|
|
38
|
-
->
|
|
37
|
+
->Array.push(id)
|
|
39
38
|
->ignore
|
|
40
39
|
})
|
|
41
40
|
|
|
@@ -6,131 +6,117 @@ import * as Utils from "../../Utils.res.mjs";
|
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import * as Logging from "../../Logging.res.mjs";
|
|
8
8
|
import * as ChainMap from "../../ChainMap.res.mjs";
|
|
9
|
-
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
|
|
10
9
|
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
11
|
-
import * as
|
|
10
|
+
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
});
|
|
12
|
+
let bodySchema = S$RescriptSchema.object(s => ({
|
|
13
|
+
envioVersion: s.f("envioVersion", S$RescriptSchema.string),
|
|
14
|
+
envioApiToken: s.f("envioApiToken", S$RescriptSchema.option(S$RescriptSchema.string)),
|
|
15
|
+
ecosystem: s.f("ecosystem", S$RescriptSchema.$$enum([
|
|
16
|
+
"evm",
|
|
17
|
+
"fuel",
|
|
18
|
+
"svm"
|
|
19
|
+
])),
|
|
20
|
+
hyperSyncNetworks: s.f("hyperSyncNetworks", S$RescriptSchema.array(S$RescriptSchema.int)),
|
|
21
|
+
rpcNetworks: s.f("rpcNetworks", S$RescriptSchema.array(S$RescriptSchema.int))
|
|
22
|
+
}));
|
|
26
23
|
|
|
27
24
|
function makeBody(envioVersion, envioApiToken, config) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
usesHyperSync ? hyperSyncNetworks : rpcNetworks
|
|
52
|
-
).push(param.id);
|
|
53
|
-
}));
|
|
25
|
+
let hyperSyncNetworks = [];
|
|
26
|
+
let rpcNetworks = [];
|
|
27
|
+
ChainMap.values(config.chainMap).forEach(param => {
|
|
28
|
+
let sourceConfig = param.sourceConfig;
|
|
29
|
+
let usesHyperSync;
|
|
30
|
+
switch (sourceConfig.TAG) {
|
|
31
|
+
case "EvmSourceConfig" :
|
|
32
|
+
usesHyperSync = sourceConfig.hypersync !== undefined;
|
|
33
|
+
break;
|
|
34
|
+
case "FuelSourceConfig" :
|
|
35
|
+
usesHyperSync = true;
|
|
36
|
+
break;
|
|
37
|
+
case "SvmSourceConfig" :
|
|
38
|
+
usesHyperSync = false;
|
|
39
|
+
break;
|
|
40
|
+
case "CustomSources" :
|
|
41
|
+
usesHyperSync = sourceConfig._0.some(s => s.poweredByHyperSync);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
(
|
|
45
|
+
usesHyperSync ? hyperSyncNetworks : rpcNetworks
|
|
46
|
+
).push(param.id);
|
|
47
|
+
});
|
|
54
48
|
return {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
envioVersion: envioVersion,
|
|
50
|
+
envioApiToken: envioApiToken,
|
|
51
|
+
ecosystem: config.ecosystem.name,
|
|
52
|
+
hyperSyncNetworks: hyperSyncNetworks,
|
|
53
|
+
rpcNetworks: rpcNetworks
|
|
54
|
+
};
|
|
61
55
|
}
|
|
62
56
|
|
|
63
57
|
function toTheme(color) {
|
|
64
58
|
switch (color) {
|
|
65
59
|
case "primary" :
|
|
66
|
-
|
|
60
|
+
return "#9860E5";
|
|
67
61
|
case "secondary" :
|
|
68
|
-
|
|
62
|
+
return "#FFBB2F";
|
|
69
63
|
case "info" :
|
|
70
|
-
|
|
64
|
+
return "#6CBFEE";
|
|
71
65
|
case "danger" :
|
|
72
|
-
|
|
66
|
+
return "#FF8269";
|
|
73
67
|
case "success" :
|
|
74
|
-
|
|
68
|
+
return "#3B8C3D";
|
|
75
69
|
case "white" :
|
|
76
|
-
|
|
70
|
+
return "white";
|
|
77
71
|
case "gray" :
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
return "gray";
|
|
80
73
|
}
|
|
81
74
|
}
|
|
82
75
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
};
|
|
96
|
-
});
|
|
76
|
+
let messageSchema = S$RescriptSchema.object(s => ({
|
|
77
|
+
color: s.f("color", S$RescriptSchema.$$enum([
|
|
78
|
+
"primary",
|
|
79
|
+
"secondary",
|
|
80
|
+
"info",
|
|
81
|
+
"danger",
|
|
82
|
+
"success",
|
|
83
|
+
"white",
|
|
84
|
+
"gray"
|
|
85
|
+
])),
|
|
86
|
+
content: s.f("content", S$RescriptSchema.string)
|
|
87
|
+
}));
|
|
97
88
|
|
|
98
|
-
|
|
89
|
+
let client = Rest.client(Env.envioAppUrl + "/api", undefined);
|
|
99
90
|
|
|
100
91
|
function route() {
|
|
101
92
|
return {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
responses: [(function (s) {
|
|
108
|
-
return s.field("messages", S$RescriptSchema.array(messageSchema));
|
|
109
|
-
})]
|
|
110
|
-
};
|
|
93
|
+
method: "POST",
|
|
94
|
+
path: "/hyperindex/init",
|
|
95
|
+
input: s => s.body(bodySchema),
|
|
96
|
+
responses: [s => s.field("messages", S$RescriptSchema.array(messageSchema))]
|
|
97
|
+
};
|
|
111
98
|
}
|
|
112
99
|
|
|
113
100
|
async function getMessages(config) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
101
|
+
let envioVersion = Utils.EnvioPackage.value.version;
|
|
102
|
+
let body = makeBody(envioVersion, Env.envioApiToken, config);
|
|
103
|
+
let messages;
|
|
117
104
|
try {
|
|
118
|
-
messages = await Rest
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
|
|
105
|
+
messages = await Rest.fetch(route, body, client);
|
|
106
|
+
} catch (raw_exn) {
|
|
107
|
+
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
122
108
|
return {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
109
|
+
TAG: "Error",
|
|
110
|
+
_0: exn
|
|
111
|
+
};
|
|
126
112
|
}
|
|
127
113
|
return {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
114
|
+
TAG: "Ok",
|
|
115
|
+
_0: messages
|
|
116
|
+
};
|
|
131
117
|
}
|
|
132
118
|
|
|
133
|
-
|
|
119
|
+
let InitApi = {
|
|
134
120
|
bodySchema: bodySchema,
|
|
135
121
|
makeBody: makeBody,
|
|
136
122
|
toTheme: toTheme,
|
|
@@ -141,39 +127,33 @@ var InitApi = {
|
|
|
141
127
|
};
|
|
142
128
|
|
|
143
129
|
function useMessages(config) {
|
|
144
|
-
|
|
145
|
-
|
|
130
|
+
let match = React.useState(() => "Loading");
|
|
131
|
+
let setRequest = match[1];
|
|
132
|
+
React.useEffect(() => {
|
|
133
|
+
getMessages(config).then(res => {
|
|
134
|
+
if (res.TAG === "Ok") {
|
|
135
|
+
let data = res._0;
|
|
136
|
+
return setRequest(param => ({
|
|
137
|
+
TAG: "Data",
|
|
138
|
+
_0: data
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
let e = res._0;
|
|
142
|
+
Logging.error({
|
|
143
|
+
msg: "Failed to load messages from envio server",
|
|
144
|
+
err: Utils.prettifyExn(e)
|
|
146
145
|
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
return {
|
|
154
|
-
TAG: "Data",
|
|
155
|
-
_0: data
|
|
156
|
-
};
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
var e = res._0;
|
|
160
|
-
Logging.error({
|
|
161
|
-
msg: "Failed to load messages from envio server",
|
|
162
|
-
err: Utils.prettifyExn(e)
|
|
163
|
-
});
|
|
164
|
-
setRequest(function (param) {
|
|
165
|
-
return {
|
|
166
|
-
TAG: "Err",
|
|
167
|
-
_0: e
|
|
168
|
-
};
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
}), []);
|
|
146
|
+
setRequest(param => ({
|
|
147
|
+
TAG: "Err",
|
|
148
|
+
_0: e
|
|
149
|
+
}));
|
|
150
|
+
});
|
|
151
|
+
}, []);
|
|
172
152
|
return match[0];
|
|
173
153
|
}
|
|
174
154
|
|
|
175
155
|
export {
|
|
176
|
-
InitApi
|
|
177
|
-
useMessages
|
|
156
|
+
InitApi,
|
|
157
|
+
useMessages,
|
|
178
158
|
}
|
|
179
159
|
/* bodySchema Not a pure module */
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
open Belt
|
|
2
1
|
open Ink
|
|
3
2
|
module Message = {
|
|
4
3
|
@react.component
|
|
@@ -29,7 +28,7 @@ let make = (~config) => {
|
|
|
29
28
|
| Data(messages) =>
|
|
30
29
|
<Notifications>
|
|
31
30
|
{messages
|
|
32
|
-
->Array.mapWithIndex((
|
|
31
|
+
->Array.mapWithIndex((message, i) => {<Message key={i->Int.toString} message />})
|
|
33
32
|
->React.array}
|
|
34
33
|
</Notifications>
|
|
35
34
|
| Err(_) =>
|