envio 3.13.0-rc.0 → 3.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/bin.mjs +10 -1
  2. package/index.d.ts +11 -0
  3. package/package.json +8 -20
  4. package/rescript.json +1 -4
  5. package/src/BatchProcessing.res +0 -2
  6. package/src/ChainState.res +39 -25
  7. package/src/ChainState.res.mjs +26 -23
  8. package/src/ChainState.resi +1 -2
  9. package/src/Config.res +69 -100
  10. package/src/Config.res.mjs +50 -63
  11. package/src/Core.res +46 -6
  12. package/src/Core.res.mjs +41 -4
  13. package/src/CrossChainState.res +13 -6
  14. package/src/CrossChainState.res.mjs +17 -4
  15. package/src/EventConfigBuilder.res +4 -10
  16. package/src/EventConfigBuilder.res.mjs +1 -3
  17. package/src/ExitOnCaughtUp.res +5 -1
  18. package/src/ExitOnCaughtUp.res.mjs +8 -3
  19. package/src/FinalizeBackfill.res +16 -10
  20. package/src/FinalizeBackfill.res.mjs +16 -5
  21. package/src/HandlerLoader.res +74 -32
  22. package/src/HandlerLoader.res.mjs +69 -23
  23. package/src/HandlerTypeCheck.mjs +14 -0
  24. package/src/HandlerTypeCheckWorker.mjs +68 -0
  25. package/src/Internal.res +1 -1
  26. package/src/Main.res +17 -12
  27. package/src/Main.res.mjs +9 -3
  28. package/src/NodeVersion.mjs +13 -0
  29. package/src/Persistence.res +79 -38
  30. package/src/Persistence.res.mjs +41 -10
  31. package/src/PgStorage.res +62 -34
  32. package/src/PgStorage.res.mjs +65 -31
  33. package/src/ResumePlan.res +172 -0
  34. package/src/ResumePlan.res.mjs +122 -0
  35. package/src/Supervisor.res +8 -8
  36. package/src/Supervisor.res.mjs +6 -1
  37. package/src/TestIndexer.res +19 -6
  38. package/src/TestIndexer.res.mjs +5 -4
  39. package/src/TsModuleHooks.mjs +121 -0
  40. package/src/Utils.res +0 -8
  41. package/src/Worker.res +8 -0
  42. package/src/Worker.res.mjs +11 -0
  43. package/src/bindings/NodeJs.res +8 -7
  44. package/src/bindings/NodeJs.res.mjs +0 -3
  45. package/src/bindings/Pino.res +2 -2
  46. package/src/db/InternalTable.res +52 -2
  47. package/src/db/InternalTable.res.mjs +32 -3
  48. package/src/sources/FuelHyperSync.res +2 -0
  49. package/src/sources/FuelHyperSync.res.mjs +1 -0
  50. package/src/sources/FuelHyperSync.resi +1 -0
  51. package/src/sources/FuelHyperSyncClient.res +25 -8
  52. package/src/sources/FuelHyperSyncClient.res.mjs +8 -2
  53. package/src/sources/FuelHyperSyncSource.res +24 -22
  54. package/src/sources/FuelHyperSyncSource.res.mjs +18 -13
  55. package/src/tui/InitApi.res +85 -0
  56. package/src/tui/{components/CustomHooks.res.mjs → InitApi.res.mjs} +11 -64
  57. package/src/tui/Tui.res +142 -249
  58. package/src/tui/Tui.res.mjs +123 -332
  59. package/src/Js.shim.ts +0 -11
  60. package/src/bindings/DateFns.res +0 -74
  61. package/src/bindings/DateFns.res.mjs +0 -22
  62. package/src/sources/FuelSDK.res +0 -38
  63. package/src/sources/FuelSDK.res.mjs +0 -27
  64. package/src/sources/vendored-fuel-abi-coder.js +0 -1792
  65. package/src/tui/bindings/Ink.res +0 -369
  66. package/src/tui/bindings/Ink.res.mjs +0 -66
  67. package/src/tui/bindings/Style.res +0 -123
  68. package/src/tui/bindings/Style.res.mjs +0 -2
  69. package/src/tui/components/BufferedProgressBar.res +0 -40
  70. package/src/tui/components/BufferedProgressBar.res.mjs +0 -57
  71. package/src/tui/components/CustomHooks.res +0 -122
  72. package/src/tui/components/Messages.res +0 -40
  73. package/src/tui/components/Messages.res.mjs +0 -71
  74. package/src/tui/components/SyncETA.res +0 -179
  75. package/src/tui/components/SyncETA.res.mjs +0 -249
  76. package/src/tui/components/TuiData.res +0 -98
  77. package/src/tui/components/TuiData.res.mjs +0 -73
@@ -1,328 +1,19 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
3
  import * as Env from "../Env.res.mjs";
4
- import * as Ink from "./bindings/Ink.res.mjs";
5
- import * as Ink$1 from "ink";
4
+ import * as Core from "../Core.res.mjs";
6
5
  import * as Envio from "../Envio.res.mjs";
7
- import * as React from "react";
8
- import * as SyncETA from "./components/SyncETA.res.mjs";
9
- import * as TuiData from "./components/TuiData.res.mjs";
10
- import * as Messages from "./components/Messages.res.mjs";
11
- import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
12
- import InkBigText from "ink-big-text";
13
- import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.js";
6
+ import * as Utils from "../Utils.res.mjs";
7
+ import * as ChainId from "../ChainId.res.mjs";
8
+ import * as InitApi from "./InitApi.res.mjs";
9
+ import * as Logging from "../Logging.res.mjs";
10
+ import * as Metrics from "../Metrics.res.mjs";
11
+ import * as Process from "process";
12
+ import * as Nodestream from "node:stream";
13
+ import * as Nodeconsole from "node:console";
14
14
  import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
15
- import * as Primitive_float from "@rescript/runtime/lib/es6/Primitive_float.js";
16
15
  import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
17
- import * as JsxRuntime from "react/jsx-runtime";
18
- import * as BufferedProgressBar from "./components/BufferedProgressBar.res.mjs";
19
-
20
- function Tui$ChainLine(props) {
21
- let blockUnit = props.blockUnit;
22
- let startBlock = props.startBlock;
23
- let toBlock = props.toBlock;
24
- let progressBlock = props.progressBlock;
25
- let chainsWidth = Primitive_int.min(props.stdoutColumns - 2 | 0, 60);
26
- let headerWidth = props.maxChainIdLength + 10 | 0;
27
- let progressBlockStr = TuiData.formatLocaleString(progressBlock);
28
- let toBlockStr = TuiData.formatLocaleString(toBlock);
29
- let eventsStr = TuiData.formatFloatLocaleString(props.eventsProcessed);
30
- let endLabel = ` (End ` + blockUnit + `)`;
31
- let blocksText = blockUnit + `s: ` + progressBlockStr + ` / ` + toBlockStr + (
32
- Stdlib_Option.isSome(props.endBlock) ? endLabel : ""
33
- ) + ` `;
34
- let eventsText = `Events: ` + eventsStr;
35
- let fitsSameLine = (blocksText.length + eventsText.length | 0) <= chainsWidth;
36
- return JsxRuntime.jsxs(Ink$1.Box, {
37
- children: [
38
- JsxRuntime.jsxs(Ink$1.Box, {
39
- children: [
40
- JsxRuntime.jsxs(Ink$1.Box, {
41
- children: [
42
- JsxRuntime.jsx(Ink$1.Text, {
43
- children: "Chain: "
44
- }),
45
- JsxRuntime.jsx(Ink$1.Text, {
46
- children: props.chainId,
47
- bold: true
48
- }),
49
- JsxRuntime.jsx(Ink$1.Text, {
50
- children: " "
51
- }),
52
- props.poweredByHyperSync ? JsxRuntime.jsx(Ink$1.Text, {
53
- children: "⚡",
54
- color: "#FFBB2F"
55
- }) : null
56
- ],
57
- width: headerWidth
58
- }),
59
- JsxRuntime.jsx(BufferedProgressBar.make, {
60
- loaded: progressBlock - startBlock | 0,
61
- buffered: props.bufferBlock - startBlock | 0,
62
- outOf: toBlock - startBlock | 0,
63
- barWidth: chainsWidth - headerWidth | 0,
64
- loadingColor: "#FFBB2F"
65
- })
66
- ],
67
- width: chainsWidth,
68
- flexDirection: "row"
69
- }),
70
- JsxRuntime.jsxs(Ink$1.Box, {
71
- children: [
72
- JsxRuntime.jsx(Ink$1.Text, {
73
- children: blocksText,
74
- color: "gray"
75
- }),
76
- fitsSameLine ? JsxRuntime.jsx(Ink$1.Text, {
77
- children: eventsText,
78
- color: "gray"
79
- }) : null
80
- ],
81
- flexDirection: "row"
82
- }),
83
- fitsSameLine ? null : JsxRuntime.jsx(Ink$1.Box, {
84
- children: JsxRuntime.jsx(Ink$1.Text, {
85
- children: eventsText.trim(),
86
- color: "gray"
87
- }),
88
- flexDirection: "row"
89
- }),
90
- JsxRuntime.jsx(Ink.Newline.make, {})
91
- ],
92
- flexDirection: "column"
93
- });
94
- }
95
-
96
- let ChainLine = {
97
- make: Tui$ChainLine
98
- };
99
-
100
- function computeEps(samples) {
101
- let len = samples.length;
102
- let match = samples[0];
103
- let match$1 = samples[len - 1 | 0];
104
- if (match !== undefined && match$1 !== undefined && match$1.time > match.time) {
105
- return (match$1.events - match.events) / ((match$1.time - match.time) / 1000);
106
- }
107
- }
108
-
109
- function use(totalEventsProcessed, tick) {
110
- let match = React.useState(() => []);
111
- let setSamples = match[1];
112
- React.useEffect(() => {
113
- let now = Date.now();
114
- let cutoff = now - 60000;
115
- setSamples(prev => {
116
- let kept = prev.filter(s => s.time >= cutoff);
117
- return kept.concat([{
118
- time: now,
119
- events: totalEventsProcessed
120
- }]);
121
- });
122
- }, [tick]);
123
- return computeEps(match[0]);
124
- }
125
-
126
- let EventsPerSecond = {
127
- windowMs: 60000,
128
- computeEps: computeEps,
129
- use: use
130
- };
131
-
132
- function Tui$TotalEventsProcessed(props) {
133
- let eventsPerSecond = props.eventsPerSecond;
134
- return JsxRuntime.jsxs(Ink$1.Text, {
135
- children: [
136
- JsxRuntime.jsx(Ink$1.Text, {
137
- children: "Total Events: ",
138
- bold: true
139
- }),
140
- JsxRuntime.jsx(Ink$1.Text, {
141
- children: TuiData.formatFloatLocaleString(props.totalEventsProcessed),
142
- color: "#FFBB2F"
143
- }),
144
- eventsPerSecond !== undefined ? JsxRuntime.jsx(Ink$1.Text, {
145
- children: ` (` + TuiData.formatFloatLocaleString(Math.round(eventsPerSecond)) + ` events/sec)`,
146
- color: "gray"
147
- }) : null
148
- ]
149
- });
150
- }
151
-
152
- let TotalEventsProcessed = {
153
- make: Tui$TotalEventsProcessed
154
- };
155
-
156
- function Tui$App(props) {
157
- let getMetrics = props.getMetrics;
158
- let config = props.config;
159
- let stdoutColumns = Ink.Hooks.useStdoutColumns();
160
- let match = React.useState(() => 0);
161
- let setTick = match[1];
162
- let metrics = getMetrics();
163
- React.useEffect(() => {
164
- let intervalId = setInterval(() => setTick(t => t + 1 | 0), 500);
165
- return () => {
166
- clearInterval(intervalId);
167
- };
168
- }, [getMetrics]);
169
- let match$1 = config.ecosystem.name;
170
- let blockUnit;
171
- switch (match$1) {
172
- case "evm" :
173
- case "fuel" :
174
- blockUnit = "Block";
175
- break;
176
- case "svm" :
177
- blockUnit = "Slot";
178
- break;
179
- }
180
- let chains = metrics.chains.map(m => TuiData.fromChainMetrics(m, blockUnit));
181
- let totalEventsProcessed = Stdlib_Array.reduce(chains, 0, (acc, chain) => acc + chain.eventsProcessed);
182
- let maxChainIdLength = Stdlib_Array.reduce(chains, 0, (acc, chain) => {
183
- let chainIdLength = chain.chainId.length;
184
- if (chainIdLength > acc) {
185
- return chainIdLength;
186
- } else {
187
- return acc;
188
- }
189
- });
190
- let eventsPerSecond = use(totalEventsProcessed, match[0]);
191
- let maxRateLimitTimeMs = Stdlib_Array.reduce(chains, 0, (acc, chain) => Primitive_float.max(acc, chain.rateLimitTimeMs));
192
- let maxResetInMs = Stdlib_Array.reduce(chains, 0.0, (acc, chain) => Primitive_float.max(acc, Stdlib_Option.getOr(chain.rateLimitResetInMs, 0.0)));
193
- let tmp;
194
- if (maxRateLimitTimeMs > 1000) {
195
- let rateLimitSecs = Math.round(maxRateLimitTimeMs / 1000);
196
- let activeSuffix;
197
- if (maxResetInMs > 0.0) {
198
- let resetSecs = Primitive_float.max(1.0, Math.ceil(maxResetInMs / 1000));
199
- activeSuffix = ` (⏳ ` + TuiData.formatFloatLocaleString(resetSecs) + `s until reset)`;
200
- } else {
201
- activeSuffix = "";
202
- }
203
- tmp = JsxRuntime.jsxs(Ink$1.Box, {
204
- children: [
205
- JsxRuntime.jsx(Ink.Newline.make, {}),
206
- JsxRuntime.jsx(Ink$1.Text, {
207
- children: `Backfill ` + TuiData.formatFloatLocaleString(rateLimitSecs) + `s slower due to your plan's rate limit` + activeSuffix,
208
- color: "#FF8269"
209
- }),
210
- JsxRuntime.jsxs(Ink$1.Text, {
211
- children: [
212
- JsxRuntime.jsx(Ink$1.Text, {
213
- children: "Upgrade at ",
214
- color: "#FF8269"
215
- }),
216
- JsxRuntime.jsx(Ink$1.Text, {
217
- children: "https://envio.dev/app/api-tokens",
218
- color: "#FF8269",
219
- underline: true
220
- }),
221
- JsxRuntime.jsx(Ink$1.Text, {
222
- children: " for higher rate limits.",
223
- color: "#FF8269"
224
- })
225
- ],
226
- color: "#FF8269"
227
- })
228
- ],
229
- flexDirection: "column"
230
- });
231
- } else {
232
- tmp = null;
233
- }
234
- let defaultPassword = "testing";
235
- let match$2 = config.storage.clickhouse;
236
- let match$3 = Env.ClickHouse.host();
237
- return JsxRuntime.jsxs(Ink$1.Box, {
238
- children: [
239
- JsxRuntime.jsx(InkBigText, {
240
- text: "envio",
241
- font: chains.length > 5 ? "tiny" : "block",
242
- colors: [
243
- "#FFBB2F",
244
- "#9860E5"
245
- ],
246
- space: false
247
- }),
248
- JsxRuntime.jsx(Ink.Newline.make, {}),
249
- chains.map((chainData, i) => JsxRuntime.jsx(Tui$ChainLine, {
250
- chainId: chainData.chainId,
251
- maxChainIdLength: maxChainIdLength,
252
- stdoutColumns: stdoutColumns,
253
- progressBlock: chainData.progressBlock,
254
- bufferBlock: chainData.bufferBlock,
255
- toBlock: chainData.toBlock,
256
- startBlock: chainData.startBlock,
257
- endBlock: chainData.endBlock,
258
- poweredByHyperSync: chainData.poweredByHyperSync,
259
- eventsProcessed: chainData.eventsProcessed,
260
- blockUnit: chainData.blockUnit
261
- }, i.toString())),
262
- JsxRuntime.jsx(Tui$TotalEventsProcessed, {
263
- totalEventsProcessed: totalEventsProcessed,
264
- eventsPerSecond: SyncETA.isIndexerFullySynced(chains) ? undefined : eventsPerSecond
265
- }),
266
- JsxRuntime.jsx(SyncETA.make, {
267
- chains: chains,
268
- indexerStartTime: metrics.startTime
269
- }),
270
- tmp,
271
- JsxRuntime.jsx(Ink.Newline.make, {}),
272
- JsxRuntime.jsxs(Ink$1.Box, {
273
- children: [
274
- JsxRuntime.jsx(Ink$1.Text, {
275
- children: "GraphQL: "
276
- }),
277
- JsxRuntime.jsx(Ink$1.Text, {
278
- children: Env.Hasura.url,
279
- color: "#6CBFEE",
280
- underline: true
281
- }),
282
- Env.Hasura.secret === defaultPassword ? JsxRuntime.jsx(Ink$1.Text, {
283
- children: ` (password: ` + defaultPassword + `)`,
284
- color: "gray"
285
- }) : null
286
- ],
287
- flexDirection: "row"
288
- }),
289
- config.isDev ? JsxRuntime.jsxs(Ink$1.Box, {
290
- children: [
291
- JsxRuntime.jsx(Ink$1.Text, {
292
- children: "Dev Console: "
293
- }),
294
- JsxRuntime.jsx(Ink$1.Text, {
295
- children: Env.envioAppUrl + `/console`,
296
- color: "#6CBFEE",
297
- underline: true
298
- })
299
- ],
300
- flexDirection: "row"
301
- }) : null,
302
- match$2 && match$3 !== undefined ? JsxRuntime.jsxs(Ink$1.Box, {
303
- children: [
304
- JsxRuntime.jsx(Ink$1.Text, {
305
- children: "ClickHouse: "
306
- }),
307
- JsxRuntime.jsx(Ink$1.Text, {
308
- children: match$3 + `/play`,
309
- color: "#6CBFEE",
310
- underline: true
311
- })
312
- ],
313
- flexDirection: "row"
314
- }) : null,
315
- JsxRuntime.jsx(Messages.make, {
316
- config: config
317
- })
318
- ],
319
- flexDirection: "column"
320
- });
321
- }
322
-
323
- let App = {
324
- make: Tui$App
325
- };
16
+ import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
326
17
 
327
18
  function shouldUse(suppressedOpt, explicitTuiOpt) {
328
19
  let suppressed = suppressedOpt !== undefined ? suppressedOpt : false;
@@ -336,24 +27,124 @@ function shouldUse(suppressedOpt, explicitTuiOpt) {
336
27
  }
337
28
  }
338
29
 
30
+ function toChain(m) {
31
+ return {
32
+ chainId: ChainId.toString(m.chainId),
33
+ poweredByHyperSync: m.poweredByHyperSync,
34
+ startBlock: m.startBlock,
35
+ endBlock: m.endBlock,
36
+ firstEventBlockNumber: m.firstEventBlockNumber,
37
+ progressBlockNumber: m.progressBlockNumber,
38
+ latestFetchedBlockNumber: m.latestFetchedBlockNumber,
39
+ knownHeight: m.knownHeight,
40
+ sourceBlockNumber: m.sourceBlockNumber,
41
+ timestampCaughtUpToHeadOrEndblock: Stdlib_Option.map(m.timestampCaughtUpToHeadOrEndblock, prim => prim.getTime()),
42
+ numEventsProcessed: m.numEventsProcessed,
43
+ rateLimitTimeMs: m.rateLimitTimeMs,
44
+ rateLimitResetInMs: m.rateLimitResetInMs,
45
+ processedToEndblock: Metrics.hasProcessedToEndblock(m)
46
+ };
47
+ }
48
+
49
+ let redirectConsole = ((Console, Writable, print) => {
50
+ let original = [];
51
+ const restore = () => original.forEach(([name, method]) => { console[name] = method; });
52
+ const toDisplay = (stream) => new Writable({
53
+ write(chunk, _encoding, callback) {
54
+ // Each call ends its output with a newline, which printing a line adds.
55
+ if (!print(chunk.toString().replace(/\n$/, ""))) {
56
+ restore();
57
+ stream.write(chunk);
58
+ }
59
+ callback();
60
+ },
61
+ });
62
+ const redirected = new Console({
63
+ stdout: toDisplay(process.stdout),
64
+ stderr: process.stderr.isTTY ? toDisplay(process.stderr) : process.stderr,
65
+ colorMode: process.stdout.hasColors(),
66
+ });
67
+ const methods = Object.keys(console).filter((name) => typeof redirected[name] === "function");
68
+ original = methods.map((name) => [name, console[name]]);
69
+ methods.forEach((name) => { console[name] = redirected[name].bind(redirected); });
70
+ return restore;
71
+ });
72
+
339
73
  function start(config, getMetrics) {
340
- let match = Ink.render(undefined, JsxRuntime.jsx(Tui$App, {
341
- config: config,
342
- getMetrics: getMetrics
343
- }));
344
- let rerender = match.rerender;
345
- return () => rerender(JsxRuntime.jsx(Tui$App, {
346
- config: config,
347
- getMetrics: getMetrics
348
- }));
74
+ let metrics = getMetrics();
75
+ let match = config.storage.clickhouse;
76
+ let match$1 = Env.ClickHouse.host();
77
+ let info_ecosystem = config.ecosystem.name;
78
+ let info_version = Utils.EnvioPackage.value.version;
79
+ let info_projectDir = Process.cwd();
80
+ let info_startTime = metrics.startTime.getTime();
81
+ let info_graphqlUrl = Env.Hasura.url;
82
+ let info_graphqlPassword = Env.Hasura.secret === "testing" ? "testing" : undefined;
83
+ let info_devConsoleUrl = config.isDev ? Env.envioAppUrl + `/console` : undefined;
84
+ let info_clickhouseUrl = match && match$1 !== undefined ? match$1 + `/play` : undefined;
85
+ let info = {
86
+ ecosystem: info_ecosystem,
87
+ version: info_version,
88
+ projectDir: info_projectDir,
89
+ startTime: info_startTime,
90
+ graphqlUrl: info_graphqlUrl,
91
+ graphqlPassword: info_graphqlPassword,
92
+ devConsoleUrl: info_devConsoleUrl,
93
+ clickhouseUrl: info_clickhouseUrl
94
+ };
95
+ let tui;
96
+ try {
97
+ tui = Core.getAddon().Tui.start(info);
98
+ } catch (raw_exn) {
99
+ let exn = Primitive_exceptions.internalToException(raw_exn);
100
+ return Logging.warn({
101
+ msg: "Failed to start the TUI. Continuing without it.",
102
+ err: Utils.prettifyExn(exn)
103
+ });
104
+ }
105
+ let restoreConsole = redirectConsole(Nodeconsole.Console, Nodestream.Writable, text => tui.print(text));
106
+ let update = () => {
107
+ tui.update(getMetrics().chains.map(toChain));
108
+ };
109
+ update();
110
+ setInterval(update, 500);
111
+ let finish = () => {
112
+ tui.stop();
113
+ restoreConsole();
114
+ };
115
+ process.on("exit", finish);
116
+ [
117
+ "SIGINT",
118
+ "SIGTERM",
119
+ "SIGHUP"
120
+ ].forEach(signal => {
121
+ let onSignal = () => {
122
+ if (process.listenerCount(signal) === 1) {
123
+ finish();
124
+ process.removeListener(signal, onSignal);
125
+ process.kill(process.pid, signal);
126
+ return;
127
+ }
128
+ };
129
+ process.on(signal, onSignal);
130
+ });
131
+ InitApi.getMessages(config).then(result => {
132
+ if (result.TAG === "Ok") {
133
+ tui.setMessages(result._0);
134
+ return;
135
+ }
136
+ Logging.error({
137
+ msg: "Failed to load messages from envio server",
138
+ err: Utils.prettifyExn(result._0)
139
+ });
140
+ tui.setMessages(null);
141
+ });
349
142
  }
350
143
 
351
144
  export {
352
- ChainLine,
353
- EventsPerSecond,
354
- TotalEventsProcessed,
355
- App,
356
145
  shouldUse,
146
+ toChain,
147
+ redirectConsole,
357
148
  start,
358
149
  }
359
150
  /* Env Not a pure module */
package/src/Js.shim.ts DELETED
@@ -1,11 +0,0 @@
1
- export type Json_t =
2
- | string
3
- | boolean
4
- | number
5
- | null
6
- | { [key: string]: Json_t }
7
- | Json_t[];
8
-
9
- export type t = unknown;
10
-
11
- export type Exn_t = Error;
@@ -1,74 +0,0 @@
1
- /**
2
- Formats:
3
- hh:mm:ss | 00:00:00
4
- do MMM ''yy | 1st Jan '21
5
- ha do MMM ''yy | 8PM 1st Jan '21
6
- ha | 8PM
7
- iii | Tues
8
- iii MMM | Tues Jan
9
- MMM | Jan
10
- `)
11
- */
12
- type dateFormats =
13
- | @as("HH:mm:ss") HoursMinSec
14
- | @as("ha") Hour
15
- | @as("do MMM ''yy") DayMonthYear
16
- | @as("ha do MMM ''yy") HourDayMonthYear
17
- | @as("h:mma do MMM ''yy") HourMinDayMonthYear
18
- | @as("iii") DayName
19
- | @as("iii MMM") DayNameMonth
20
- | @as("do MMM") DayMonth
21
- | @as("MMM") Month
22
- | @as("h:mma") HourMin
23
-
24
- @module("date-fns") external format: (Date.t, dateFormats) => string = "format"
25
-
26
- type formatDistanceToNowOptions = {includeSeconds: bool}
27
- @module("date-fns")
28
- external formatDistanceToNow: Date.t => string = "formatDistanceToNow"
29
-
30
- @module("date-fns")
31
- external formatDistance: (Date.t, Date.t) => string = "formatDistance"
32
-
33
- @module("date-fns")
34
- external formatDistanceWithOptions: (Date.t, Date.t, formatDistanceToNowOptions) => string =
35
- "formatDistance"
36
-
37
- @module("date-fns")
38
- external formatDistanceToNowWithOptions: (Date.t, formatDistanceToNowOptions) => string =
39
- "formatDistanceToNow"
40
-
41
- let formatDistanceToNowWithSeconds = (date: Date.t) =>
42
- date->formatDistanceToNowWithOptions({includeSeconds: true})
43
-
44
- type durationTimeFormat = {
45
- years: int,
46
- months: int,
47
- weeks: int,
48
- days: int,
49
- hours: int,
50
- minutes: int,
51
- seconds: int,
52
- }
53
-
54
- @module("date-fns")
55
- external formatRelative: (Date.t, Date.t) => string = "formatRelative"
56
-
57
- type durationFormatOutput = {format: array<string>}
58
-
59
- @module("date-fns")
60
- external formatDuration: (durationTimeFormat, durationFormatOutput) => string = "formatDuration"
61
-
62
- type interval = {start: Date.t, end: Date.t}
63
-
64
- @module("date-fns")
65
- external intervalToDuration: interval => durationTimeFormat = "intervalToDuration"
66
-
67
- //helper to convert millis elapsed to duration object
68
- let durationFromMillis = (millis: int) =>
69
- intervalToDuration({
70
- start: 0->(Utils.magic: int => Date.t),
71
- end: millis->(Utils.magic: int => Date.t),
72
- })
73
-
74
- @module("date-fns") external fromUnixTime: float => Date.t = "fromUnixTime"
@@ -1,22 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as DateFns from "date-fns";
4
-
5
- function formatDistanceToNowWithSeconds(date) {
6
- return DateFns.formatDistanceToNow(date, {
7
- includeSeconds: true
8
- });
9
- }
10
-
11
- function durationFromMillis(millis) {
12
- return DateFns.intervalToDuration({
13
- start: 0,
14
- end: millis
15
- });
16
- }
17
-
18
- export {
19
- formatDistanceToNowWithSeconds,
20
- durationFromMillis,
21
- }
22
- /* date-fns Not a pure module */
@@ -1,38 +0,0 @@
1
- type receiptType =
2
- | @as(0) Call
3
- | @as(1) Return
4
- | @as(2) ReturnData
5
- | @as(3) Panic
6
- | @as(4) Revert
7
- | @as(5) Log
8
- | @as(6) LogData
9
- // Transfer is to another contract, TransferOut is to wallet address
10
- | @as(7) Transfer
11
- | @as(8) TransferOut
12
- | @as(9) ScriptResult
13
- | @as(10) MessageOut
14
- | @as(11) Mint
15
- | @as(12) Burn
16
-
17
- @module("./vendored-fuel-abi-coder.js")
18
- external transpileAbi: JSON.t => EvmTypes.Abi.t = "transpileAbi"
19
-
20
- @module("./vendored-fuel-abi-coder.js") @scope("AbiCoder")
21
- external getLogDecoder: (~abi: EvmTypes.Abi.t, ~logId: string) => string => unknown =
22
- "getLogDecoder"
23
-
24
- module Receipt = {
25
- @tag("receiptType")
26
- type t =
27
- | @as(0) Call({assetId: string, amount: bigint, to: string})
28
- | @as(6) LogData({data: string, rb: bigint})
29
- | @as(7) Transfer({amount: bigint, assetId: string, to: string})
30
- | @as(8) TransferOut({amount: bigint, assetId: string, toAddress: string})
31
- | @as(11) Mint({val: bigint, subId: string})
32
- | @as(12) Burn({val: bigint, subId: string})
33
-
34
- let getLogDataDecoder = (~abi: EvmTypes.Abi.t, ~logId: string) => {
35
- let decode = getLogDecoder(~abi, ~logId)
36
- data => data->decode->(Utils.magic: 'a => Internal.eventParams)
37
- }
38
- }
@@ -1,27 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as VendoredFuelAbiCoderJs from "./vendored-fuel-abi-coder.js";
4
-
5
- function transpileAbi(prim) {
6
- return VendoredFuelAbiCoderJs.transpileAbi(prim);
7
- }
8
-
9
- function getLogDecoder(prim0, prim1) {
10
- return VendoredFuelAbiCoderJs.AbiCoder.getLogDecoder(prim0, prim1);
11
- }
12
-
13
- function getLogDataDecoder(abi, logId) {
14
- let decode = VendoredFuelAbiCoderJs.AbiCoder.getLogDecoder(abi, logId);
15
- return data => decode(data);
16
- }
17
-
18
- let Receipt = {
19
- getLogDataDecoder: getLogDataDecoder
20
- };
21
-
22
- export {
23
- transpileAbi,
24
- getLogDecoder,
25
- Receipt,
26
- }
27
- /* ./vendored-fuel-abi-coder.js Not a pure module */