envio 3.0.0-alpha.2 → 3.0.0-alpha.21
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 +164 -30
- package/bin.mjs +49 -0
- package/evm.schema.json +79 -169
- package/fuel.schema.json +50 -21
- package/index.d.ts +578 -1
- package/index.js +4 -0
- package/package.json +47 -31
- package/rescript.json +4 -1
- package/src/Batch.res +11 -8
- package/src/Batch.res.mjs +11 -9
- package/src/ChainFetcher.res +531 -0
- package/src/ChainFetcher.res.mjs +339 -0
- package/src/ChainManager.res +190 -0
- package/src/ChainManager.res.mjs +166 -0
- package/src/Change.res +3 -3
- package/src/Config.gen.ts +19 -0
- package/src/Config.res +725 -25
- package/src/Config.res.mjs +692 -26
- package/src/{Indexer.res → Ctx.res} +1 -1
- package/src/Ecosystem.res +9 -124
- package/src/Ecosystem.res.mjs +19 -160
- package/src/Env.res +33 -73
- package/src/Env.res.mjs +29 -85
- package/src/Envio.gen.ts +3 -1
- package/src/Envio.res +77 -9
- package/src/Envio.res.mjs +39 -1
- package/src/EventConfigBuilder.res +408 -0
- package/src/EventConfigBuilder.res.mjs +376 -0
- package/src/EventProcessing.res +469 -0
- package/src/EventProcessing.res.mjs +337 -0
- package/src/EvmTypes.gen.ts +6 -0
- package/src/EvmTypes.res +1 -0
- package/src/FetchState.res +1256 -639
- package/src/FetchState.res.mjs +1135 -612
- package/src/GlobalState.res +1224 -0
- package/src/GlobalState.res.mjs +1291 -0
- package/src/GlobalStateManager.res +68 -0
- package/src/GlobalStateManager.res.mjs +75 -0
- package/src/GlobalStateManager.resi +7 -0
- package/src/HandlerLoader.res +89 -0
- package/src/HandlerLoader.res.mjs +79 -0
- package/src/HandlerRegister.res +357 -0
- package/src/HandlerRegister.res.mjs +299 -0
- package/src/HandlerRegister.resi +30 -0
- package/src/Hasura.res +111 -175
- package/src/Hasura.res.mjs +88 -150
- package/src/InMemoryStore.res +1 -1
- package/src/InMemoryStore.res.mjs +3 -3
- package/src/InMemoryTable.res +1 -1
- package/src/InMemoryTable.res.mjs +1 -1
- package/src/Internal.gen.ts +6 -0
- package/src/Internal.res +265 -12
- package/src/Internal.res.mjs +115 -1
- package/src/LoadLayer.res +444 -0
- package/src/LoadLayer.res.mjs +296 -0
- package/src/LoadLayer.resi +32 -0
- package/src/LogSelection.res +33 -27
- package/src/LogSelection.res.mjs +6 -0
- package/src/Logging.res +21 -7
- package/src/Logging.res.mjs +16 -8
- package/src/Main.res +390 -0
- package/src/Main.res.mjs +341 -0
- package/src/Persistence.res +7 -21
- package/src/Persistence.res.mjs +3 -3
- package/src/PgStorage.gen.ts +10 -0
- package/src/PgStorage.res +116 -69
- package/src/PgStorage.res.d.mts +5 -0
- package/src/PgStorage.res.mjs +93 -50
- package/src/Prometheus.res +294 -224
- package/src/Prometheus.res.mjs +353 -340
- package/src/ReorgDetection.res +6 -10
- package/src/ReorgDetection.res.mjs +6 -6
- package/src/SafeCheckpointTracking.res +4 -4
- package/src/SafeCheckpointTracking.res.mjs +2 -2
- package/src/SimulateItems.res +353 -0
- package/src/SimulateItems.res.mjs +335 -0
- package/src/Sink.res +4 -2
- package/src/Sink.res.mjs +2 -1
- package/src/TableIndices.res +0 -1
- package/src/TestIndexer.res +913 -0
- package/src/TestIndexer.res.mjs +698 -0
- package/src/TestIndexerProxyStorage.res +205 -0
- package/src/TestIndexerProxyStorage.res.mjs +151 -0
- package/src/TopicFilter.res +1 -1
- package/src/Types.ts +1 -1
- package/src/UserContext.res +424 -0
- package/src/UserContext.res.mjs +279 -0
- package/src/Utils.res +97 -26
- package/src/Utils.res.mjs +91 -44
- package/src/bindings/BigInt.res +10 -0
- package/src/bindings/BigInt.res.mjs +15 -0
- package/src/bindings/ClickHouse.res +120 -23
- package/src/bindings/ClickHouse.res.mjs +118 -28
- package/src/bindings/DateFns.res +74 -0
- package/src/bindings/DateFns.res.mjs +22 -0
- package/src/bindings/EventSource.res +11 -2
- package/src/bindings/EventSource.res.mjs +8 -1
- package/src/bindings/Express.res +1 -0
- package/src/bindings/Hrtime.res +14 -1
- package/src/bindings/Hrtime.res.mjs +22 -2
- package/src/bindings/Hrtime.resi +4 -0
- package/src/bindings/Lodash.res +0 -1
- package/src/bindings/NodeJs.res +49 -3
- package/src/bindings/NodeJs.res.mjs +11 -3
- package/src/bindings/Pino.res +24 -10
- package/src/bindings/Pino.res.mjs +14 -8
- package/src/bindings/Postgres.gen.ts +8 -0
- package/src/bindings/Postgres.res +5 -1
- package/src/bindings/Postgres.res.d.mts +5 -0
- package/src/bindings/PromClient.res +0 -10
- package/src/bindings/PromClient.res.mjs +0 -3
- package/src/bindings/Vitest.res +144 -0
- package/src/bindings/Vitest.res.mjs +9 -0
- package/src/bindings/WebSocket.res +27 -0
- package/src/bindings/WebSocket.res.mjs +2 -0
- package/src/bindings/Yargs.res +8 -0
- package/src/bindings/Yargs.res.mjs +2 -0
- package/src/db/EntityHistory.res +7 -7
- package/src/db/EntityHistory.res.mjs +9 -9
- package/src/db/InternalTable.res +59 -111
- package/src/db/InternalTable.res.mjs +73 -104
- package/src/db/Table.res +27 -8
- package/src/db/Table.res.mjs +25 -14
- package/src/sources/Evm.res +84 -0
- package/src/sources/Evm.res.mjs +105 -0
- package/src/sources/EvmChain.res +94 -0
- package/src/sources/EvmChain.res.mjs +60 -0
- package/src/sources/Fuel.res +19 -34
- package/src/sources/Fuel.res.mjs +34 -16
- package/src/sources/FuelSDK.res +38 -0
- package/src/sources/FuelSDK.res.mjs +29 -0
- package/src/sources/HyperFuel.res +2 -2
- package/src/sources/HyperFuel.resi +1 -1
- package/src/sources/HyperFuelClient.res +2 -2
- package/src/sources/HyperFuelSource.res +35 -13
- package/src/sources/HyperFuelSource.res.mjs +26 -16
- package/src/sources/HyperSync.res +61 -60
- package/src/sources/HyperSync.res.mjs +53 -67
- package/src/sources/HyperSync.resi +6 -4
- package/src/sources/HyperSyncClient.res +29 -2
- package/src/sources/HyperSyncClient.res.mjs +9 -0
- package/src/sources/HyperSyncHeightStream.res +76 -118
- package/src/sources/HyperSyncHeightStream.res.mjs +68 -75
- package/src/sources/HyperSyncSource.res +122 -143
- package/src/sources/HyperSyncSource.res.mjs +106 -121
- package/src/sources/Rpc.res +86 -14
- package/src/sources/Rpc.res.mjs +101 -9
- package/src/sources/RpcSource.res +731 -364
- package/src/sources/RpcSource.res.mjs +845 -410
- package/src/sources/RpcWebSocketHeightStream.res +181 -0
- package/src/sources/RpcWebSocketHeightStream.res.mjs +196 -0
- package/src/sources/SimulateSource.res +59 -0
- package/src/sources/SimulateSource.res.mjs +50 -0
- package/src/sources/Source.res +7 -5
- package/src/sources/SourceManager.res +358 -221
- package/src/sources/SourceManager.res.mjs +346 -171
- package/src/sources/SourceManager.resi +17 -6
- package/src/sources/Svm.res +81 -0
- package/src/sources/Svm.res.mjs +90 -0
- package/src/tui/Tui.res +247 -0
- package/src/tui/Tui.res.mjs +337 -0
- package/src/tui/bindings/Ink.res +371 -0
- package/src/tui/bindings/Ink.res.mjs +72 -0
- package/src/tui/bindings/Style.res +123 -0
- package/src/tui/bindings/Style.res.mjs +2 -0
- package/src/tui/components/BufferedProgressBar.res +40 -0
- package/src/tui/components/BufferedProgressBar.res.mjs +57 -0
- package/src/tui/components/CustomHooks.res +122 -0
- package/src/tui/components/CustomHooks.res.mjs +179 -0
- package/src/tui/components/Messages.res +41 -0
- package/src/tui/components/Messages.res.mjs +75 -0
- package/src/tui/components/SyncETA.res +174 -0
- package/src/tui/components/SyncETA.res.mjs +263 -0
- package/src/tui/components/TuiData.res +47 -0
- package/src/tui/components/TuiData.res.mjs +34 -0
- package/svm.schema.json +112 -0
- package/bin.js +0 -48
- package/src/EventRegister.res +0 -241
- package/src/EventRegister.res.mjs +0 -240
- package/src/EventRegister.resi +0 -30
- package/src/bindings/Ethers.gen.ts +0 -14
- package/src/bindings/Ethers.res +0 -204
- package/src/bindings/Ethers.res.mjs +0 -130
- /package/src/{Indexer.res.mjs → Ctx.res.mjs} +0 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as $$Ink from "ink";
|
|
4
|
+
import * as Caml from "rescript/lib/es6/caml.js";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import * as DateFns from "date-fns";
|
|
7
|
+
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
|
|
8
|
+
import InkSpinner from "ink-spinner";
|
|
9
|
+
import * as JsxRuntime from "react/jsx-runtime";
|
|
10
|
+
|
|
11
|
+
function isIndexerFullySynced(chains) {
|
|
12
|
+
return Belt_Array.reduce(chains, true, (function (accum, current) {
|
|
13
|
+
var match = current.progress;
|
|
14
|
+
if (typeof match !== "object" || match.TAG === "Syncing") {
|
|
15
|
+
return false;
|
|
16
|
+
} else {
|
|
17
|
+
return accum;
|
|
18
|
+
}
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getTotalRemainingBlocks(chains) {
|
|
23
|
+
return Belt_Array.reduce(chains, 0, (function (accum, param) {
|
|
24
|
+
var progress = param.progress;
|
|
25
|
+
var endBlock = param.endBlock;
|
|
26
|
+
var 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
|
+
}
|
|
34
|
+
|
|
35
|
+
function getLatestTimeCaughtUpToHead(chains, indexerStartTime) {
|
|
36
|
+
var latesttimestampCaughtUpToHeadOrEndblockFloat = Belt_Array.reduce(chains, 0.0, (function (accum, current) {
|
|
37
|
+
var match = current.progress;
|
|
38
|
+
if (typeof match !== "object") {
|
|
39
|
+
return accum;
|
|
40
|
+
}
|
|
41
|
+
if (match.TAG === "Syncing") {
|
|
42
|
+
return accum;
|
|
43
|
+
}
|
|
44
|
+
var timestampCaughtUpToHeadOrEndblock = match._0.timestampCaughtUpToHeadOrEndblock;
|
|
45
|
+
if (timestampCaughtUpToHeadOrEndblock.valueOf() > accum) {
|
|
46
|
+
return timestampCaughtUpToHeadOrEndblock.valueOf();
|
|
47
|
+
} else {
|
|
48
|
+
return accum;
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
return DateFns.formatDistance(indexerStartTime, new Date(latesttimestampCaughtUpToHeadOrEndblockFloat), {
|
|
52
|
+
includeSeconds: true
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function getTotalBlocksProcessed(chains) {
|
|
57
|
+
return Belt_Array.reduce(chains, 0, (function (accum, param) {
|
|
58
|
+
var progress = param.progress;
|
|
59
|
+
if (typeof progress !== "object") {
|
|
60
|
+
return param.latestFetchedBlockNumber + accum | 0;
|
|
61
|
+
}
|
|
62
|
+
progress.TAG === "Syncing";
|
|
63
|
+
var match = progress._0;
|
|
64
|
+
return (match.latestProcessedBlock - match.firstEventBlockNumber | 0) + accum | 0;
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function useShouldDisplayEta(chains) {
|
|
69
|
+
var match = React.useState(function () {
|
|
70
|
+
return false;
|
|
71
|
+
});
|
|
72
|
+
var setShouldDisplayEta = match[1];
|
|
73
|
+
var shouldDisplayEta = match[0];
|
|
74
|
+
React.useEffect((function () {
|
|
75
|
+
if (!shouldDisplayEta) {
|
|
76
|
+
var allChainsStartedFetching = Belt_Array.every(chains, (function (chain) {
|
|
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]);
|
|
92
|
+
return shouldDisplayEta;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function useEta(chains, indexerStartTime) {
|
|
96
|
+
var shouldDisplayEta = useShouldDisplayEta(chains);
|
|
97
|
+
var match = React.useState(function () {
|
|
98
|
+
return 0;
|
|
99
|
+
});
|
|
100
|
+
var setSecondsToSub = match[1];
|
|
101
|
+
var match$1 = React.useState(function () {
|
|
102
|
+
return 0;
|
|
103
|
+
});
|
|
104
|
+
var setTimeSinceStart = match$1[1];
|
|
105
|
+
React.useEffect((function () {
|
|
106
|
+
setTimeSinceStart(function (param) {
|
|
107
|
+
return Date.now() - indexerStartTime.valueOf();
|
|
108
|
+
});
|
|
109
|
+
setSecondsToSub(function (param) {
|
|
110
|
+
return 0;
|
|
111
|
+
});
|
|
112
|
+
var intervalId = setInterval((function () {
|
|
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);
|
|
125
|
+
if (!(shouldDisplayEta && blocksProcessed > 0)) {
|
|
126
|
+
return ;
|
|
127
|
+
}
|
|
128
|
+
var nowDate = Date.now();
|
|
129
|
+
var remainingBlocks = getTotalRemainingBlocks(chains);
|
|
130
|
+
var etaFloat = match$1[0] / blocksProcessed * remainingBlocks;
|
|
131
|
+
var millisToSub = match[0] * 1000;
|
|
132
|
+
var etaFloat$1 = Caml.float_max(etaFloat - millisToSub, 0.0);
|
|
133
|
+
var eta = new Date(etaFloat$1 + nowDate);
|
|
134
|
+
var interval_start = new Date(nowDate);
|
|
135
|
+
var interval = {
|
|
136
|
+
start: interval_start,
|
|
137
|
+
end: eta
|
|
138
|
+
};
|
|
139
|
+
var duration = DateFns.intervalToDuration(interval);
|
|
140
|
+
var formattedDuration = DateFns.formatDuration(duration, {
|
|
141
|
+
format: [
|
|
142
|
+
"hours",
|
|
143
|
+
"minutes",
|
|
144
|
+
"seconds"
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
var tmp = formattedDuration === "" ? "less than 1 second" : formattedDuration;
|
|
148
|
+
return tmp;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function SyncETA$Syncing(props) {
|
|
152
|
+
return JsxRuntime.jsxs($$Ink.Text, {
|
|
153
|
+
children: [
|
|
154
|
+
JsxRuntime.jsx($$Ink.Text, {
|
|
155
|
+
children: "Sync Time ETA: "
|
|
156
|
+
}),
|
|
157
|
+
JsxRuntime.jsx($$Ink.Text, {
|
|
158
|
+
children: props.etaStr
|
|
159
|
+
}),
|
|
160
|
+
JsxRuntime.jsx($$Ink.Text, {
|
|
161
|
+
children: " ("
|
|
162
|
+
}),
|
|
163
|
+
JsxRuntime.jsx($$Ink.Text, {
|
|
164
|
+
children: JsxRuntime.jsx(InkSpinner, {}),
|
|
165
|
+
color: "#9860E5"
|
|
166
|
+
}),
|
|
167
|
+
JsxRuntime.jsx($$Ink.Text, {
|
|
168
|
+
children: " in progress",
|
|
169
|
+
color: "#FFBB2F"
|
|
170
|
+
}),
|
|
171
|
+
JsxRuntime.jsx($$Ink.Text, {
|
|
172
|
+
children: ")"
|
|
173
|
+
})
|
|
174
|
+
],
|
|
175
|
+
bold: true
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
var Syncing = {
|
|
180
|
+
make: SyncETA$Syncing
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
function SyncETA$Synced(props) {
|
|
184
|
+
return JsxRuntime.jsxs($$Ink.Text, {
|
|
185
|
+
children: [
|
|
186
|
+
JsxRuntime.jsx($$Ink.Text, {
|
|
187
|
+
children: "Time Synced: "
|
|
188
|
+
}),
|
|
189
|
+
JsxRuntime.jsx($$Ink.Text, {
|
|
190
|
+
children: props.latestTimeCaughtUpToHeadStr
|
|
191
|
+
}),
|
|
192
|
+
JsxRuntime.jsx($$Ink.Text, {
|
|
193
|
+
children: " ("
|
|
194
|
+
}),
|
|
195
|
+
JsxRuntime.jsx($$Ink.Text, {
|
|
196
|
+
children: "synced",
|
|
197
|
+
color: "#3B8C3D"
|
|
198
|
+
}),
|
|
199
|
+
JsxRuntime.jsx($$Ink.Text, {
|
|
200
|
+
children: ")"
|
|
201
|
+
})
|
|
202
|
+
],
|
|
203
|
+
bold: true
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
var Synced = {
|
|
208
|
+
make: SyncETA$Synced
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
function SyncETA$Calculating(props) {
|
|
212
|
+
return JsxRuntime.jsxs($$Ink.Text, {
|
|
213
|
+
children: [
|
|
214
|
+
JsxRuntime.jsx($$Ink.Text, {
|
|
215
|
+
children: JsxRuntime.jsx(InkSpinner, {}),
|
|
216
|
+
color: "#9860E5"
|
|
217
|
+
}),
|
|
218
|
+
JsxRuntime.jsx($$Ink.Text, {
|
|
219
|
+
children: " Calculating ETA...",
|
|
220
|
+
bold: true
|
|
221
|
+
})
|
|
222
|
+
]
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
var Calculating = {
|
|
227
|
+
make: SyncETA$Calculating
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
function SyncETA(props) {
|
|
231
|
+
var indexerStartTime = props.indexerStartTime;
|
|
232
|
+
var chains = props.chains;
|
|
233
|
+
var optEta = useEta(chains, indexerStartTime);
|
|
234
|
+
if (!isIndexerFullySynced(chains)) {
|
|
235
|
+
if (optEta !== undefined) {
|
|
236
|
+
return JsxRuntime.jsx(SyncETA$Syncing, {
|
|
237
|
+
etaStr: optEta
|
|
238
|
+
});
|
|
239
|
+
} else {
|
|
240
|
+
return JsxRuntime.jsx(SyncETA$Calculating, {});
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
var latestTimeCaughtUpToHeadStr = getLatestTimeCaughtUpToHead(chains, indexerStartTime);
|
|
244
|
+
return JsxRuntime.jsx(SyncETA$Synced, {
|
|
245
|
+
latestTimeCaughtUpToHeadStr: latestTimeCaughtUpToHeadStr
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
var make = SyncETA;
|
|
250
|
+
|
|
251
|
+
export {
|
|
252
|
+
isIndexerFullySynced ,
|
|
253
|
+
getTotalRemainingBlocks ,
|
|
254
|
+
getLatestTimeCaughtUpToHead ,
|
|
255
|
+
getTotalBlocksProcessed ,
|
|
256
|
+
useShouldDisplayEta ,
|
|
257
|
+
useEta ,
|
|
258
|
+
Syncing ,
|
|
259
|
+
Synced ,
|
|
260
|
+
Calculating ,
|
|
261
|
+
make ,
|
|
262
|
+
}
|
|
263
|
+
/* ink Not a pure module */
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
type syncing = {
|
|
2
|
+
firstEventBlockNumber: int,
|
|
3
|
+
latestProcessedBlock: int,
|
|
4
|
+
numEventsProcessed: float,
|
|
5
|
+
}
|
|
6
|
+
type synced = {
|
|
7
|
+
...syncing,
|
|
8
|
+
timestampCaughtUpToHeadOrEndblock: Js.Date.t,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type progress = SearchingForEvents | Syncing(syncing) | Synced(synced)
|
|
12
|
+
|
|
13
|
+
let getNumberOfEventsProccessed = (progress: progress) => {
|
|
14
|
+
switch progress {
|
|
15
|
+
| SearchingForEvents => 0.
|
|
16
|
+
| Syncing(syncing) => syncing.numEventsProcessed
|
|
17
|
+
| Synced(synced) => synced.numEventsProcessed
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
type chain = {
|
|
21
|
+
chainId: string,
|
|
22
|
+
eventsProcessed: float,
|
|
23
|
+
progressBlock: option<int>,
|
|
24
|
+
bufferBlock: option<int>,
|
|
25
|
+
sourceBlock: option<int>,
|
|
26
|
+
startBlock: int,
|
|
27
|
+
endBlock: option<int>,
|
|
28
|
+
firstEventBlockNumber: option<int>,
|
|
29
|
+
poweredByHyperSync: bool,
|
|
30
|
+
progress: progress,
|
|
31
|
+
latestFetchedBlockNumber: int,
|
|
32
|
+
knownHeight: int,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let minOfOption: (int, option<int>) => int = (a: int, b: option<int>) => {
|
|
36
|
+
switch (a, b) {
|
|
37
|
+
| (a, Some(b)) => min(a, b)
|
|
38
|
+
| (a, None) => a
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type number
|
|
43
|
+
@val external number: int => number = "Number"
|
|
44
|
+
@val external floatNumber: float => number = "Number"
|
|
45
|
+
@send external toLocaleString: number => string = "toLocaleString"
|
|
46
|
+
let formatLocaleString = n => n->number->toLocaleString
|
|
47
|
+
let formatFloatLocaleString = n => n->floatNumber->toLocaleString
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function getNumberOfEventsProccessed(progress) {
|
|
5
|
+
if (typeof progress !== "object") {
|
|
6
|
+
return 0;
|
|
7
|
+
} else {
|
|
8
|
+
return progress._0.numEventsProcessed;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function minOfOption(a, b) {
|
|
13
|
+
if (b !== undefined && a >= b) {
|
|
14
|
+
return b;
|
|
15
|
+
} else {
|
|
16
|
+
return a;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function formatLocaleString(n) {
|
|
21
|
+
return Number(n).toLocaleString();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function formatFloatLocaleString(n) {
|
|
25
|
+
return Number(n).toLocaleString();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
getNumberOfEventsProccessed ,
|
|
30
|
+
minOfOption ,
|
|
31
|
+
formatLocaleString ,
|
|
32
|
+
formatFloatLocaleString ,
|
|
33
|
+
}
|
|
34
|
+
/* No side effect */
|
package/svm.schema.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "Envio Svm Config Schema",
|
|
4
|
+
"description": "Schema for a YAML config for an envio Svm indexer",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"description": {
|
|
8
|
+
"description": "Description of the project",
|
|
9
|
+
"type": [
|
|
10
|
+
"string",
|
|
11
|
+
"null"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"name": {
|
|
15
|
+
"description": "Name of the project",
|
|
16
|
+
"type": "string"
|
|
17
|
+
},
|
|
18
|
+
"schema": {
|
|
19
|
+
"description": "Custom path to schema.graphql file",
|
|
20
|
+
"type": [
|
|
21
|
+
"string",
|
|
22
|
+
"null"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"output": {
|
|
26
|
+
"description": "Path where the generated directory will be placed. By default it's 'generated' relative to the current working directory. If set, it'll be a path relative to the config file location.",
|
|
27
|
+
"type": [
|
|
28
|
+
"string",
|
|
29
|
+
"null"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"handlers": {
|
|
33
|
+
"description": "Optional relative path to handlers directory for auto-loading. Defaults to 'src/handlers' if not specified.",
|
|
34
|
+
"type": [
|
|
35
|
+
"string",
|
|
36
|
+
"null"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"full_batch_size": {
|
|
40
|
+
"description": "Target number of events to be processed per batch. Set it to smaller number if you have many Effect API calls which are slow to resolve and can't be batched. (Default: 5000)",
|
|
41
|
+
"type": [
|
|
42
|
+
"integer",
|
|
43
|
+
"null"
|
|
44
|
+
],
|
|
45
|
+
"format": "uint64",
|
|
46
|
+
"minimum": 0
|
|
47
|
+
},
|
|
48
|
+
"ecosystem": {
|
|
49
|
+
"description": "Ecosystem of the project.",
|
|
50
|
+
"$ref": "#/$defs/EcosystemTag"
|
|
51
|
+
},
|
|
52
|
+
"chains": {
|
|
53
|
+
"description": "Configuration of the blockchain chains that the project is deployed on.",
|
|
54
|
+
"type": "array",
|
|
55
|
+
"items": {
|
|
56
|
+
"$ref": "#/$defs/Chain"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"additionalProperties": false,
|
|
61
|
+
"required": [
|
|
62
|
+
"name",
|
|
63
|
+
"ecosystem",
|
|
64
|
+
"chains"
|
|
65
|
+
],
|
|
66
|
+
"$defs": {
|
|
67
|
+
"EcosystemTag": {
|
|
68
|
+
"type": "string",
|
|
69
|
+
"enum": [
|
|
70
|
+
"svm"
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
"Chain": {
|
|
74
|
+
"type": "object",
|
|
75
|
+
"properties": {
|
|
76
|
+
"rpc": {
|
|
77
|
+
"description": "RPC endpoint URL for connecting to the Svm cluster to fetch blockchain data.",
|
|
78
|
+
"type": "string"
|
|
79
|
+
},
|
|
80
|
+
"start_block": {
|
|
81
|
+
"description": "The slot number at which the indexer should start ingesting data",
|
|
82
|
+
"type": "integer",
|
|
83
|
+
"format": "uint64",
|
|
84
|
+
"minimum": 0
|
|
85
|
+
},
|
|
86
|
+
"end_block": {
|
|
87
|
+
"description": "The slot number at which the indexer should terminate.",
|
|
88
|
+
"type": [
|
|
89
|
+
"integer",
|
|
90
|
+
"null"
|
|
91
|
+
],
|
|
92
|
+
"format": "uint64",
|
|
93
|
+
"minimum": 0
|
|
94
|
+
},
|
|
95
|
+
"block_lag": {
|
|
96
|
+
"description": "The number of blocks behind the chain head that the indexer should lag. Useful for avoiding reorg issues by indexing slightly behind the tip.",
|
|
97
|
+
"type": [
|
|
98
|
+
"integer",
|
|
99
|
+
"null"
|
|
100
|
+
],
|
|
101
|
+
"format": "uint32",
|
|
102
|
+
"minimum": 0
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"additionalProperties": false,
|
|
106
|
+
"required": [
|
|
107
|
+
"rpc",
|
|
108
|
+
"start_block"
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
package/bin.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
//@ts-check
|
|
3
|
-
|
|
4
|
-
import { spawnSync } from "child_process";
|
|
5
|
-
import { createRequire } from "module";
|
|
6
|
-
|
|
7
|
-
const require = createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Returns the executable path for envio located inside node_modules
|
|
11
|
-
* The naming convention is envio-${os}-${arch}
|
|
12
|
-
* If the platform is `win32` or `cygwin`, executable will include a `.exe` extension
|
|
13
|
-
* @see https://nodejs.org/api/os.html#osarch
|
|
14
|
-
* @see https://nodejs.org/api/os.html#osplatform
|
|
15
|
-
* @example "x/xx/node_modules/envio-darwin-arm64"
|
|
16
|
-
*/
|
|
17
|
-
function getExePath() {
|
|
18
|
-
const arch = process.arch;
|
|
19
|
-
/**
|
|
20
|
-
* @type {string}
|
|
21
|
-
*/
|
|
22
|
-
let os = process.platform;
|
|
23
|
-
let extension = "";
|
|
24
|
-
if (["win32", "cygwin"].includes(process.platform)) {
|
|
25
|
-
os = "windows";
|
|
26
|
-
extension = ".exe";
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
// Since the bin will be located inside `node_modules`, we can simply call require.resolve
|
|
31
|
-
return require.resolve(`envio-${os}-${arch}/bin/envio${extension}`);
|
|
32
|
-
} catch (e) {
|
|
33
|
-
throw new Error(
|
|
34
|
-
`Couldn't find envio binary inside node_modules for ${os}-${arch}`
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Runs `envio` with args using nodejs spawn
|
|
41
|
-
*/
|
|
42
|
-
function runEnvio() {
|
|
43
|
-
const args = process.argv.slice(2);
|
|
44
|
-
const processResult = spawnSync(getExePath(), args, { stdio: "inherit" });
|
|
45
|
-
process.exit(processResult.status ?? 0);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
runEnvio();
|