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.
Files changed (219) hide show
  1. package/bin.mjs +2 -48
  2. package/evm.schema.json +67 -0
  3. package/fuel.schema.json +67 -0
  4. package/index.d.ts +822 -38
  5. package/index.js +5 -3
  6. package/package.json +10 -8
  7. package/rescript.json +5 -9
  8. package/src/Address.res +4 -5
  9. package/src/Address.res.mjs +9 -12
  10. package/src/Api.res +15 -0
  11. package/src/Api.res.mjs +20 -0
  12. package/src/Batch.res +32 -34
  13. package/src/Batch.res.mjs +172 -187
  14. package/src/Bin.res +89 -0
  15. package/src/Bin.res.mjs +97 -0
  16. package/src/ChainFetcher.res +33 -57
  17. package/src/ChainFetcher.res.mjs +197 -227
  18. package/src/ChainManager.res +6 -14
  19. package/src/ChainManager.res.mjs +74 -85
  20. package/src/ChainMap.res +14 -16
  21. package/src/ChainMap.res.mjs +38 -38
  22. package/src/Config.res +193 -135
  23. package/src/Config.res.mjs +566 -592
  24. package/src/Core.res +182 -0
  25. package/src/Core.res.mjs +207 -0
  26. package/src/Ecosystem.res +25 -4
  27. package/src/Ecosystem.res.mjs +12 -13
  28. package/src/Env.res +20 -13
  29. package/src/Env.res.mjs +124 -113
  30. package/src/EnvSafe.res +269 -0
  31. package/src/EnvSafe.res.mjs +296 -0
  32. package/src/EnvSafe.resi +18 -0
  33. package/src/Envio.res +37 -26
  34. package/src/Envio.res.mjs +59 -60
  35. package/src/ErrorHandling.res +2 -2
  36. package/src/ErrorHandling.res.mjs +15 -15
  37. package/src/EventConfigBuilder.res +219 -81
  38. package/src/EventConfigBuilder.res.mjs +259 -202
  39. package/src/EventProcessing.res +27 -38
  40. package/src/EventProcessing.res.mjs +165 -183
  41. package/src/EventUtils.res +11 -11
  42. package/src/EventUtils.res.mjs +21 -22
  43. package/src/EvmTypes.res +0 -1
  44. package/src/EvmTypes.res.mjs +5 -5
  45. package/src/FetchState.res +360 -256
  46. package/src/FetchState.res.mjs +958 -914
  47. package/src/GlobalState.res +365 -351
  48. package/src/GlobalState.res.mjs +958 -992
  49. package/src/GlobalStateManager.res +1 -2
  50. package/src/GlobalStateManager.res.mjs +36 -44
  51. package/src/HandlerLoader.res +107 -23
  52. package/src/HandlerLoader.res.mjs +128 -38
  53. package/src/HandlerRegister.res +127 -103
  54. package/src/HandlerRegister.res.mjs +164 -164
  55. package/src/HandlerRegister.resi +12 -4
  56. package/src/Hasura.res +35 -22
  57. package/src/Hasura.res.mjs +158 -167
  58. package/src/InMemoryStore.res +20 -27
  59. package/src/InMemoryStore.res.mjs +64 -80
  60. package/src/InMemoryTable.res +34 -39
  61. package/src/InMemoryTable.res.mjs +165 -170
  62. package/src/Internal.res +52 -33
  63. package/src/Internal.res.mjs +84 -81
  64. package/src/LazyLoader.res.mjs +55 -61
  65. package/src/LoadLayer.res +77 -78
  66. package/src/LoadLayer.res.mjs +160 -189
  67. package/src/LoadManager.res +16 -21
  68. package/src/LoadManager.res.mjs +79 -84
  69. package/src/LogSelection.res +236 -68
  70. package/src/LogSelection.res.mjs +211 -141
  71. package/src/Logging.res +13 -9
  72. package/src/Logging.res.mjs +130 -143
  73. package/src/Main.res +428 -51
  74. package/src/Main.res.mjs +528 -271
  75. package/src/Persistence.res +77 -84
  76. package/src/Persistence.res.mjs +131 -132
  77. package/src/PgStorage.res +291 -167
  78. package/src/PgStorage.res.mjs +797 -817
  79. package/src/Prometheus.res +50 -58
  80. package/src/Prometheus.res.mjs +345 -373
  81. package/src/ReorgDetection.res +22 -24
  82. package/src/ReorgDetection.res.mjs +100 -106
  83. package/src/SafeCheckpointTracking.res +7 -7
  84. package/src/SafeCheckpointTracking.res.mjs +40 -43
  85. package/src/SimulateItems.res +41 -49
  86. package/src/SimulateItems.res.mjs +257 -272
  87. package/src/Sink.res +2 -2
  88. package/src/Sink.res.mjs +22 -26
  89. package/src/TableIndices.res +1 -2
  90. package/src/TableIndices.res.mjs +42 -48
  91. package/src/TestIndexer.res +196 -189
  92. package/src/TestIndexer.res.mjs +536 -536
  93. package/src/TestIndexerProxyStorage.res +15 -16
  94. package/src/TestIndexerProxyStorage.res.mjs +98 -122
  95. package/src/TestIndexerWorker.res +4 -0
  96. package/src/TestIndexerWorker.res.mjs +7 -0
  97. package/src/Throttler.res +3 -3
  98. package/src/Throttler.res.mjs +23 -24
  99. package/src/Time.res +1 -1
  100. package/src/Time.res.mjs +18 -21
  101. package/src/TopicFilter.res +3 -3
  102. package/src/TopicFilter.res.mjs +29 -30
  103. package/src/UserContext.res +93 -54
  104. package/src/UserContext.res.mjs +197 -182
  105. package/src/Utils.res +141 -86
  106. package/src/Utils.res.mjs +334 -295
  107. package/src/bindings/BigDecimal.res +0 -2
  108. package/src/bindings/BigDecimal.res.mjs +19 -23
  109. package/src/bindings/ClickHouse.res +28 -27
  110. package/src/bindings/ClickHouse.res.mjs +243 -240
  111. package/src/bindings/DateFns.res +11 -11
  112. package/src/bindings/DateFns.res.mjs +7 -7
  113. package/src/bindings/EventSource.res.mjs +2 -2
  114. package/src/bindings/Express.res +2 -5
  115. package/src/bindings/Hrtime.res +2 -2
  116. package/src/bindings/Hrtime.res.mjs +30 -32
  117. package/src/bindings/Lodash.res.mjs +1 -1
  118. package/src/bindings/NodeJs.res +14 -9
  119. package/src/bindings/NodeJs.res.mjs +20 -20
  120. package/src/bindings/Pino.res +8 -10
  121. package/src/bindings/Pino.res.mjs +40 -43
  122. package/src/bindings/Postgres.res +2 -5
  123. package/src/bindings/Postgres.res.mjs +9 -9
  124. package/src/bindings/PromClient.res +17 -2
  125. package/src/bindings/PromClient.res.mjs +30 -7
  126. package/src/bindings/SDSL.res.mjs +2 -2
  127. package/src/bindings/Viem.res +4 -4
  128. package/src/bindings/Viem.res.mjs +20 -22
  129. package/src/bindings/Vitest.res +1 -1
  130. package/src/bindings/Vitest.res.mjs +2 -2
  131. package/src/bindings/WebSocket.res +1 -1
  132. package/src/db/EntityHistory.res +9 -3
  133. package/src/db/EntityHistory.res.mjs +84 -59
  134. package/src/db/InternalTable.res +62 -60
  135. package/src/db/InternalTable.res.mjs +271 -203
  136. package/src/db/Schema.res +1 -2
  137. package/src/db/Schema.res.mjs +28 -32
  138. package/src/db/Table.res +28 -27
  139. package/src/db/Table.res.mjs +276 -292
  140. package/src/sources/EventRouter.res +21 -16
  141. package/src/sources/EventRouter.res.mjs +55 -57
  142. package/src/sources/Evm.res +17 -1
  143. package/src/sources/Evm.res.mjs +16 -8
  144. package/src/sources/EvmChain.res +15 -17
  145. package/src/sources/EvmChain.res.mjs +40 -42
  146. package/src/sources/Fuel.res +14 -1
  147. package/src/sources/Fuel.res.mjs +16 -8
  148. package/src/sources/FuelSDK.res +1 -1
  149. package/src/sources/FuelSDK.res.mjs +6 -8
  150. package/src/sources/HyperFuel.res +8 -10
  151. package/src/sources/HyperFuel.res.mjs +113 -123
  152. package/src/sources/HyperFuelClient.res.mjs +6 -7
  153. package/src/sources/HyperFuelSource.res +19 -20
  154. package/src/sources/HyperFuelSource.res.mjs +339 -356
  155. package/src/sources/HyperSync.res +11 -13
  156. package/src/sources/HyperSync.res.mjs +206 -220
  157. package/src/sources/HyperSyncClient.res +5 -7
  158. package/src/sources/HyperSyncClient.res.mjs +70 -75
  159. package/src/sources/HyperSyncHeightStream.res +8 -9
  160. package/src/sources/HyperSyncHeightStream.res.mjs +78 -86
  161. package/src/sources/HyperSyncJsonApi.res +18 -15
  162. package/src/sources/HyperSyncJsonApi.res.mjs +201 -231
  163. package/src/sources/HyperSyncSource.res +17 -21
  164. package/src/sources/HyperSyncSource.res.mjs +268 -290
  165. package/src/sources/Rpc.res +5 -5
  166. package/src/sources/Rpc.res.mjs +168 -192
  167. package/src/sources/RpcSource.res +166 -167
  168. package/src/sources/RpcSource.res.mjs +972 -1046
  169. package/src/sources/RpcWebSocketHeightStream.res +10 -11
  170. package/src/sources/RpcWebSocketHeightStream.res.mjs +131 -145
  171. package/src/sources/SimulateSource.res +1 -1
  172. package/src/sources/SimulateSource.res.mjs +35 -38
  173. package/src/sources/Source.res +1 -1
  174. package/src/sources/Source.res.mjs +3 -3
  175. package/src/sources/SourceManager.res +39 -20
  176. package/src/sources/SourceManager.res.mjs +340 -371
  177. package/src/sources/SourceManager.resi +2 -1
  178. package/src/sources/Svm.res +12 -5
  179. package/src/sources/Svm.res.mjs +44 -41
  180. package/src/tui/Tui.res +23 -12
  181. package/src/tui/Tui.res.mjs +292 -290
  182. package/src/tui/bindings/Ink.res +2 -4
  183. package/src/tui/bindings/Ink.res.mjs +35 -41
  184. package/src/tui/components/BufferedProgressBar.res +7 -7
  185. package/src/tui/components/BufferedProgressBar.res.mjs +46 -46
  186. package/src/tui/components/CustomHooks.res +1 -2
  187. package/src/tui/components/CustomHooks.res.mjs +102 -122
  188. package/src/tui/components/Messages.res +1 -2
  189. package/src/tui/components/Messages.res.mjs +38 -42
  190. package/src/tui/components/SyncETA.res +10 -11
  191. package/src/tui/components/SyncETA.res.mjs +178 -196
  192. package/src/tui/components/TuiData.res +1 -1
  193. package/src/tui/components/TuiData.res.mjs +7 -6
  194. package/src/vendored/Rest.res +52 -66
  195. package/src/vendored/Rest.res.mjs +324 -364
  196. package/svm.schema.json +67 -0
  197. package/src/Address.gen.ts +0 -8
  198. package/src/Config.gen.ts +0 -19
  199. package/src/Envio.gen.ts +0 -55
  200. package/src/EvmTypes.gen.ts +0 -6
  201. package/src/InMemoryStore.gen.ts +0 -6
  202. package/src/Internal.gen.ts +0 -64
  203. package/src/PgStorage.gen.ts +0 -10
  204. package/src/PgStorage.res.d.mts +0 -5
  205. package/src/Types.ts +0 -56
  206. package/src/bindings/BigDecimal.gen.ts +0 -14
  207. package/src/bindings/BigDecimal.res.d.mts +0 -5
  208. package/src/bindings/BigInt.gen.ts +0 -10
  209. package/src/bindings/BigInt.res +0 -70
  210. package/src/bindings/BigInt.res.d.mts +0 -5
  211. package/src/bindings/BigInt.res.mjs +0 -154
  212. package/src/bindings/Ethers.res.d.mts +0 -5
  213. package/src/bindings/Pino.gen.ts +0 -17
  214. package/src/bindings/Postgres.gen.ts +0 -8
  215. package/src/bindings/Postgres.res.d.mts +0 -5
  216. package/src/bindings/Promise.res +0 -67
  217. package/src/bindings/Promise.res.mjs +0 -26
  218. package/src/db/InternalTable.gen.ts +0 -36
  219. package/src/sources/HyperSyncClient.gen.ts +0 -19
@@ -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 $$Ink from "ink";
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 $$Ink.render(element, options);
8
+ return Ink.render(element, options);
9
9
  }
10
10
 
11
- var $$Text = {};
11
+ let Text = {};
12
12
 
13
- var Box = {};
13
+ let Box = {};
14
14
 
15
15
  function Ink$Newline(props) {
16
- return JsxRuntime.jsx($$Ink.Text, {
17
- children: " "
18
- });
16
+ return JsxRuntime.jsx(Ink.Text, {
17
+ children: " "
18
+ });
19
19
  }
20
20
 
21
- var Newline = {
21
+ let Newline = {
22
22
  make: Ink$Newline
23
23
  };
24
24
 
25
- var Spacer = {};
25
+ let Spacer = {};
26
26
 
27
- var Static = {};
27
+ let Static = {};
28
28
 
29
- var Transform = {};
29
+ let Transform = {};
30
30
 
31
31
  function useStdoutColumns() {
32
- var match = $$Ink.useStdout();
33
- var stdout = match.stdout;
34
- var match$1 = React.useState(function () {
35
- return stdout.columns;
36
- });
37
- var setColumns = match$1[1];
38
- React.useEffect((function () {
39
- var handler = function () {
40
- setColumns(function (param) {
41
- return stdout.columns;
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
- var Hooks = {
46
+ let Hooks = {
53
47
  useStdoutColumns: useStdoutColumns
54
48
  };
55
49
 
56
- var BigText = {};
50
+ let BigText = {};
57
51
 
58
- var Spinner = {};
52
+ let Spinner = {};
59
53
 
60
54
  export {
61
- render ,
62
- $$Text ,
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
- open Belt
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
- Js.Math.floor_float(maxCount->Js.Int.toFloat *. loadedFraction)->Belt.Float.toInt,
9
+ Math.floor(maxCount->Int.toFloat *. loadedFraction)->Belt.Float.toInt,
10
10
  maxCount,
11
11
  )
12
12
 
13
- let bufferedCount = buffered->Option.mapWithDefault(loadedCount, buffered => {
13
+ let bufferedCount = buffered->Option.mapOr(loadedCount, buffered => {
14
14
  let bufferedFraction = buffered->Int.toFloat /. outOf->Int.toFloat
15
15
  Pervasives.min(
16
- Js.Math.floor_float(maxCount->Js.Int.toFloat *. bufferedFraction)->Belt.Float.toInt,
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> {" "->Js.String2.repeat(loadedSpaces)->React.string} </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
- {" "->Js.String2.repeat(bufferedCount - loadedCount)->React.string}
34
+ {" "->String.repeat(bufferedCount - loadedCount)->React.string}
35
35
  </Text>
36
36
  <Text backgroundColor={White}>
37
- {" "->Js.String2.repeat(maxCount - bufferedCount)->React.string}
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 $$Ink from "ink";
4
- import * as Caml from "rescript/lib/es6/caml.js";
5
- import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
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
- var __loadingColor = props.loadingColor;
10
- var __barWidth = props.barWidth;
11
- var outOf = props.outOf;
12
- var barWidth = __barWidth !== undefined ? __barWidth : 36;
13
- var loadingColor = __loadingColor !== undefined ? __loadingColor : "#FFBB2F";
14
- var loadedFraction = props.loaded / outOf;
15
- var loadedCount = Caml.int_min(Math.floor(barWidth * loadedFraction) | 0, barWidth);
16
- var bufferedCount = Belt_Option.mapWithDefault(props.buffered, loadedCount, (function (buffered) {
17
- var bufferedFraction = buffered / outOf;
18
- return Caml.int_min(Math.floor(barWidth * bufferedFraction) | 0, barWidth);
19
- }));
20
- var loadedFraction$1 = loadedFraction > 0.0 ? loadedFraction : 0.0;
21
- var loadedPercentageStr = String(loadedFraction$1 * 100 | 0) + "% ";
22
- var loadedPercentageStrCount = loadedPercentageStr.length;
23
- var loadedSpaces = Caml.int_max(loadedCount - loadedPercentageStrCount | 0, 0);
24
- var loadedCount$1 = loadedCount > loadedPercentageStrCount ? loadedCount : loadedPercentageStrCount;
25
- var bufferedCount$1 = bufferedCount > loadedCount$1 ? 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
- });
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
- var make = BufferedProgressBar;
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
- ->Js.Array2.push(id)
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 Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
10
+ import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
12
11
 
13
- var bodySchema = S$RescriptSchema.object(function (s) {
14
- return {
15
- envioVersion: s.f("envioVersion", S$RescriptSchema.string),
16
- envioApiToken: s.f("envioApiToken", S$RescriptSchema.option(S$RescriptSchema.string)),
17
- ecosystem: s.f("ecosystem", S$RescriptSchema.$$enum([
18
- "evm",
19
- "fuel",
20
- "svm"
21
- ])),
22
- hyperSyncNetworks: s.f("hyperSyncNetworks", S$RescriptSchema.array(S$RescriptSchema.$$int)),
23
- rpcNetworks: s.f("rpcNetworks", S$RescriptSchema.array(S$RescriptSchema.$$int))
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
- var hyperSyncNetworks = [];
29
- var rpcNetworks = [];
30
- Belt_Array.forEach(ChainMap.values(config.chainMap), (function (param) {
31
- var sourceConfig = param.sourceConfig;
32
- var usesHyperSync;
33
- switch (sourceConfig.TAG) {
34
- case "EvmSourceConfig" :
35
- usesHyperSync = sourceConfig.hypersync !== undefined;
36
- break;
37
- case "FuelSourceConfig" :
38
- usesHyperSync = true;
39
- break;
40
- case "SvmSourceConfig" :
41
- usesHyperSync = false;
42
- break;
43
- case "CustomSources" :
44
- usesHyperSync = Belt_Array.some(sourceConfig._0, (function (s) {
45
- return s.poweredByHyperSync;
46
- }));
47
- break;
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
- envioVersion: envioVersion,
56
- envioApiToken: envioApiToken,
57
- ecosystem: config.ecosystem.name,
58
- hyperSyncNetworks: hyperSyncNetworks,
59
- rpcNetworks: rpcNetworks
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
- return "#9860E5";
60
+ return "#9860E5";
67
61
  case "secondary" :
68
- return "#FFBB2F";
62
+ return "#FFBB2F";
69
63
  case "info" :
70
- return "#6CBFEE";
64
+ return "#6CBFEE";
71
65
  case "danger" :
72
- return "#FF8269";
66
+ return "#FF8269";
73
67
  case "success" :
74
- return "#3B8C3D";
68
+ return "#3B8C3D";
75
69
  case "white" :
76
- return "white";
70
+ return "white";
77
71
  case "gray" :
78
- return "gray";
79
-
72
+ return "gray";
80
73
  }
81
74
  }
82
75
 
83
- var messageSchema = S$RescriptSchema.object(function (s) {
84
- return {
85
- color: s.f("color", S$RescriptSchema.$$enum([
86
- "primary",
87
- "secondary",
88
- "info",
89
- "danger",
90
- "success",
91
- "white",
92
- "gray"
93
- ])),
94
- content: s.f("content", S$RescriptSchema.string)
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
- var client = Rest.client(Env.envioAppUrl + "/api", undefined);
89
+ let client = Rest.client(Env.envioAppUrl + "/api", undefined);
99
90
 
100
91
  function route() {
101
92
  return {
102
- method: "POST",
103
- path: "/hyperindex/init",
104
- input: (function (s) {
105
- return s.body(bodySchema);
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
- var envioVersion = Utils.EnvioPackage.value.version;
115
- var body = makeBody(envioVersion, Env.envioApiToken, config);
116
- var messages;
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.$$fetch(route, body, client);
119
- }
120
- catch (raw_exn){
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
- TAG: "Error",
124
- _0: exn
125
- };
109
+ TAG: "Error",
110
+ _0: exn
111
+ };
126
112
  }
127
113
  return {
128
- TAG: "Ok",
129
- _0: messages
130
- };
114
+ TAG: "Ok",
115
+ _0: messages
116
+ };
131
117
  }
132
118
 
133
- var InitApi = {
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
- var match = React.useState(function () {
145
- return "Loading";
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
- var setRequest = match[1];
148
- React.useEffect((function () {
149
- getMessages(config).then(function (res) {
150
- if (res.TAG === "Ok") {
151
- var data = res._0;
152
- return setRequest(function (param) {
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((i, message) => {<Message key={i->Int.toString} message />})
31
+ ->Array.mapWithIndex((message, i) => {<Message key={i->Int.toString} message />})
33
32
  ->React.array}
34
33
  </Notifications>
35
34
  | Err(_) =>