envio 3.0.0-alpha.21 → 3.0.0-alpha.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/README.md +3 -3
  2. package/bin.mjs +2 -48
  3. package/evm.schema.json +67 -0
  4. package/fuel.schema.json +67 -0
  5. package/index.d.ts +822 -38
  6. package/index.js +5 -3
  7. package/package.json +10 -8
  8. package/rescript.json +5 -9
  9. package/src/Address.res +4 -5
  10. package/src/Address.res.mjs +9 -12
  11. package/src/Api.res +15 -0
  12. package/src/Api.res.mjs +20 -0
  13. package/src/Batch.res +32 -34
  14. package/src/Batch.res.mjs +172 -187
  15. package/src/Bin.res +89 -0
  16. package/src/Bin.res.mjs +97 -0
  17. package/src/ChainFetcher.res +33 -57
  18. package/src/ChainFetcher.res.mjs +197 -227
  19. package/src/ChainManager.res +6 -14
  20. package/src/ChainManager.res.mjs +74 -85
  21. package/src/ChainMap.res +14 -16
  22. package/src/ChainMap.res.mjs +38 -38
  23. package/src/Config.res +193 -135
  24. package/src/Config.res.mjs +566 -592
  25. package/src/Core.res +182 -0
  26. package/src/Core.res.mjs +207 -0
  27. package/src/Ecosystem.res +25 -4
  28. package/src/Ecosystem.res.mjs +12 -13
  29. package/src/Env.res +20 -13
  30. package/src/Env.res.mjs +124 -113
  31. package/src/EnvSafe.res +269 -0
  32. package/src/EnvSafe.res.mjs +296 -0
  33. package/src/EnvSafe.resi +18 -0
  34. package/src/Envio.res +37 -26
  35. package/src/Envio.res.mjs +59 -60
  36. package/src/ErrorHandling.res +2 -2
  37. package/src/ErrorHandling.res.mjs +15 -15
  38. package/src/EventConfigBuilder.res +219 -81
  39. package/src/EventConfigBuilder.res.mjs +259 -202
  40. package/src/EventProcessing.res +27 -38
  41. package/src/EventProcessing.res.mjs +165 -183
  42. package/src/EventUtils.res +11 -11
  43. package/src/EventUtils.res.mjs +21 -22
  44. package/src/EvmTypes.res +0 -1
  45. package/src/EvmTypes.res.mjs +5 -5
  46. package/src/FetchState.res +360 -256
  47. package/src/FetchState.res.mjs +958 -914
  48. package/src/GlobalState.res +365 -351
  49. package/src/GlobalState.res.mjs +958 -992
  50. package/src/GlobalStateManager.res +1 -2
  51. package/src/GlobalStateManager.res.mjs +36 -44
  52. package/src/HandlerLoader.res +107 -23
  53. package/src/HandlerLoader.res.mjs +128 -38
  54. package/src/HandlerRegister.res +127 -103
  55. package/src/HandlerRegister.res.mjs +164 -164
  56. package/src/HandlerRegister.resi +12 -4
  57. package/src/Hasura.res +35 -22
  58. package/src/Hasura.res.mjs +158 -167
  59. package/src/InMemoryStore.res +20 -27
  60. package/src/InMemoryStore.res.mjs +64 -80
  61. package/src/InMemoryTable.res +34 -39
  62. package/src/InMemoryTable.res.mjs +165 -170
  63. package/src/Internal.res +52 -33
  64. package/src/Internal.res.mjs +84 -81
  65. package/src/LazyLoader.res.mjs +55 -61
  66. package/src/LoadLayer.res +77 -78
  67. package/src/LoadLayer.res.mjs +160 -189
  68. package/src/LoadManager.res +16 -21
  69. package/src/LoadManager.res.mjs +79 -84
  70. package/src/LogSelection.res +236 -68
  71. package/src/LogSelection.res.mjs +211 -141
  72. package/src/Logging.res +13 -9
  73. package/src/Logging.res.mjs +130 -143
  74. package/src/Main.res +430 -51
  75. package/src/Main.res.mjs +530 -271
  76. package/src/Persistence.res +80 -84
  77. package/src/Persistence.res.mjs +131 -132
  78. package/src/PgStorage.res +294 -167
  79. package/src/PgStorage.res.mjs +799 -817
  80. package/src/Prometheus.res +50 -58
  81. package/src/Prometheus.res.mjs +345 -373
  82. package/src/ReorgDetection.res +22 -24
  83. package/src/ReorgDetection.res.mjs +100 -106
  84. package/src/SafeCheckpointTracking.res +7 -7
  85. package/src/SafeCheckpointTracking.res.mjs +40 -43
  86. package/src/SimulateItems.res +41 -49
  87. package/src/SimulateItems.res.mjs +257 -272
  88. package/src/Sink.res +2 -2
  89. package/src/Sink.res.mjs +22 -26
  90. package/src/TableIndices.res +1 -2
  91. package/src/TableIndices.res.mjs +42 -48
  92. package/src/TestIndexer.res +196 -189
  93. package/src/TestIndexer.res.mjs +536 -536
  94. package/src/TestIndexerProxyStorage.res +16 -16
  95. package/src/TestIndexerProxyStorage.res.mjs +99 -122
  96. package/src/TestIndexerWorker.res +4 -0
  97. package/src/TestIndexerWorker.res.mjs +7 -0
  98. package/src/Throttler.res +3 -3
  99. package/src/Throttler.res.mjs +23 -24
  100. package/src/Time.res +1 -1
  101. package/src/Time.res.mjs +18 -21
  102. package/src/TopicFilter.res +3 -3
  103. package/src/TopicFilter.res.mjs +29 -30
  104. package/src/UserContext.res +93 -54
  105. package/src/UserContext.res.mjs +197 -182
  106. package/src/Utils.res +141 -86
  107. package/src/Utils.res.mjs +334 -295
  108. package/src/bindings/BigDecimal.res +0 -2
  109. package/src/bindings/BigDecimal.res.mjs +19 -23
  110. package/src/bindings/ClickHouse.res +28 -27
  111. package/src/bindings/ClickHouse.res.mjs +243 -240
  112. package/src/bindings/DateFns.res +11 -11
  113. package/src/bindings/DateFns.res.mjs +7 -7
  114. package/src/bindings/EventSource.res.mjs +2 -2
  115. package/src/bindings/Express.res +2 -5
  116. package/src/bindings/Hrtime.res +2 -2
  117. package/src/bindings/Hrtime.res.mjs +30 -32
  118. package/src/bindings/Lodash.res.mjs +1 -1
  119. package/src/bindings/NodeJs.res +14 -9
  120. package/src/bindings/NodeJs.res.mjs +20 -20
  121. package/src/bindings/Pino.res +8 -10
  122. package/src/bindings/Pino.res.mjs +40 -43
  123. package/src/bindings/Postgres.res +7 -5
  124. package/src/bindings/Postgres.res.mjs +9 -9
  125. package/src/bindings/PromClient.res +17 -2
  126. package/src/bindings/PromClient.res.mjs +30 -7
  127. package/src/bindings/SDSL.res.mjs +2 -2
  128. package/src/bindings/Viem.res +4 -4
  129. package/src/bindings/Viem.res.mjs +20 -22
  130. package/src/bindings/Vitest.res +1 -1
  131. package/src/bindings/Vitest.res.mjs +2 -2
  132. package/src/bindings/WebSocket.res +1 -1
  133. package/src/db/EntityHistory.res +9 -3
  134. package/src/db/EntityHistory.res.mjs +84 -59
  135. package/src/db/InternalTable.res +62 -60
  136. package/src/db/InternalTable.res.mjs +271 -203
  137. package/src/db/Schema.res +1 -2
  138. package/src/db/Schema.res.mjs +28 -32
  139. package/src/db/Table.res +28 -27
  140. package/src/db/Table.res.mjs +276 -292
  141. package/src/sources/EventRouter.res +21 -16
  142. package/src/sources/EventRouter.res.mjs +55 -57
  143. package/src/sources/Evm.res +17 -1
  144. package/src/sources/Evm.res.mjs +16 -8
  145. package/src/sources/EvmChain.res +15 -17
  146. package/src/sources/EvmChain.res.mjs +40 -42
  147. package/src/sources/Fuel.res +14 -1
  148. package/src/sources/Fuel.res.mjs +16 -8
  149. package/src/sources/FuelSDK.res +1 -1
  150. package/src/sources/FuelSDK.res.mjs +6 -8
  151. package/src/sources/HyperFuel.res +8 -10
  152. package/src/sources/HyperFuel.res.mjs +113 -123
  153. package/src/sources/HyperFuelClient.res.mjs +6 -7
  154. package/src/sources/HyperFuelSource.res +19 -20
  155. package/src/sources/HyperFuelSource.res.mjs +339 -356
  156. package/src/sources/HyperSync.res +11 -13
  157. package/src/sources/HyperSync.res.mjs +206 -220
  158. package/src/sources/HyperSyncClient.res +5 -7
  159. package/src/sources/HyperSyncClient.res.mjs +70 -75
  160. package/src/sources/HyperSyncHeightStream.res +8 -9
  161. package/src/sources/HyperSyncHeightStream.res.mjs +78 -86
  162. package/src/sources/HyperSyncJsonApi.res +18 -15
  163. package/src/sources/HyperSyncJsonApi.res.mjs +201 -231
  164. package/src/sources/HyperSyncSource.res +17 -21
  165. package/src/sources/HyperSyncSource.res.mjs +268 -290
  166. package/src/sources/Rpc.res +5 -5
  167. package/src/sources/Rpc.res.mjs +168 -192
  168. package/src/sources/RpcSource.res +166 -167
  169. package/src/sources/RpcSource.res.mjs +972 -1046
  170. package/src/sources/RpcWebSocketHeightStream.res +10 -11
  171. package/src/sources/RpcWebSocketHeightStream.res.mjs +131 -145
  172. package/src/sources/SimulateSource.res +1 -1
  173. package/src/sources/SimulateSource.res.mjs +35 -38
  174. package/src/sources/Source.res +1 -1
  175. package/src/sources/Source.res.mjs +3 -3
  176. package/src/sources/SourceManager.res +39 -20
  177. package/src/sources/SourceManager.res.mjs +340 -371
  178. package/src/sources/SourceManager.resi +2 -1
  179. package/src/sources/Svm.res +12 -5
  180. package/src/sources/Svm.res.mjs +44 -41
  181. package/src/tui/Tui.res +23 -12
  182. package/src/tui/Tui.res.mjs +292 -290
  183. package/src/tui/bindings/Ink.res +2 -4
  184. package/src/tui/bindings/Ink.res.mjs +35 -41
  185. package/src/tui/components/BufferedProgressBar.res +7 -7
  186. package/src/tui/components/BufferedProgressBar.res.mjs +46 -46
  187. package/src/tui/components/CustomHooks.res +1 -2
  188. package/src/tui/components/CustomHooks.res.mjs +102 -122
  189. package/src/tui/components/Messages.res +1 -2
  190. package/src/tui/components/Messages.res.mjs +38 -42
  191. package/src/tui/components/SyncETA.res +10 -11
  192. package/src/tui/components/SyncETA.res.mjs +178 -196
  193. package/src/tui/components/TuiData.res +1 -1
  194. package/src/tui/components/TuiData.res.mjs +7 -6
  195. package/src/vendored/Rest.res +52 -66
  196. package/src/vendored/Rest.res.mjs +324 -364
  197. package/svm.schema.json +67 -0
  198. package/src/Address.gen.ts +0 -8
  199. package/src/Config.gen.ts +0 -19
  200. package/src/Envio.gen.ts +0 -55
  201. package/src/EvmTypes.gen.ts +0 -6
  202. package/src/InMemoryStore.gen.ts +0 -6
  203. package/src/Internal.gen.ts +0 -64
  204. package/src/PgStorage.gen.ts +0 -10
  205. package/src/PgStorage.res.d.mts +0 -5
  206. package/src/Types.ts +0 -56
  207. package/src/bindings/BigDecimal.gen.ts +0 -14
  208. package/src/bindings/BigDecimal.res.d.mts +0 -5
  209. package/src/bindings/BigInt.gen.ts +0 -10
  210. package/src/bindings/BigInt.res +0 -70
  211. package/src/bindings/BigInt.res.d.mts +0 -5
  212. package/src/bindings/BigInt.res.mjs +0 -154
  213. package/src/bindings/Ethers.res.d.mts +0 -5
  214. package/src/bindings/Pino.gen.ts +0 -17
  215. package/src/bindings/Postgres.gen.ts +0 -8
  216. package/src/bindings/Postgres.res.d.mts +0 -5
  217. package/src/bindings/Promise.res +0 -67
  218. package/src/bindings/Promise.res.mjs +0 -26
  219. package/src/db/InternalTable.gen.ts +0 -36
  220. package/src/sources/HyperSyncClient.gen.ts +0 -19
@@ -1,92 +1,85 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
- import * as Js_exn from "rescript/lib/es6/js_exn.js";
4
3
  import * as Address from "./Address.res.mjs";
5
- import * as Js_dict from "rescript/lib/es6/js_dict.js";
6
- import * as Caml_obj from "rescript/lib/es6/caml_obj.js";
7
4
  import * as ChainMap from "./ChainMap.res.mjs";
8
- import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
9
- import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
10
- import * as Caml_option from "rescript/lib/es6/caml_option.js";
5
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
11
6
  import * as SimulateSource from "./sources/SimulateSource.res.mjs";
7
+ import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
8
+ import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
12
9
  import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
13
10
 
14
- var evmSimulateBlockSchema = S$RescriptSchema.schema(function (s) {
15
- return {
16
- number: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.$$int), 0)),
17
- timestamp: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.$$int), 0)),
18
- hash: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
19
- parentHash: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
20
- sha3Uncles: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
21
- logsBloom: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
22
- transactionsRoot: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
23
- stateRoot: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
24
- receiptsRoot: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
25
- miner: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(Address.schema), "0x0000000000000000000000000000000000000000")),
26
- extraData: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
27
- size: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
28
- gasLimit: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
29
- gasUsed: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
30
- nonce: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
31
- difficulty: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
32
- totalDifficulty: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
33
- uncles: s.m(S$RescriptSchema.$$null(S$RescriptSchema.array(S$RescriptSchema.string))),
34
- baseFeePerGas: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
35
- blobGasUsed: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
36
- excessBlobGas: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
37
- parentBeaconBlockRoot: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
38
- withdrawalsRoot: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
39
- l1BlockNumber: s.m(S$RescriptSchema.$$null(S$RescriptSchema.$$int)),
40
- sendCount: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
41
- sendRoot: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
42
- mixHash: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string))
43
- };
44
- });
11
+ let evmSimulateBlockSchema = S$RescriptSchema.schema(s => ({
12
+ number: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.int), 0)),
13
+ timestamp: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.int), 0)),
14
+ hash: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
15
+ parentHash: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
16
+ sha3Uncles: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
17
+ logsBloom: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
18
+ transactionsRoot: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
19
+ stateRoot: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
20
+ receiptsRoot: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
21
+ miner: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(Address.schema), "0x0000000000000000000000000000000000000000")),
22
+ extraData: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
23
+ size: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
24
+ gasLimit: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
25
+ gasUsed: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
26
+ nonce: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
27
+ difficulty: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
28
+ totalDifficulty: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
29
+ uncles: s.m(S$RescriptSchema.$$null(S$RescriptSchema.array(S$RescriptSchema.string))),
30
+ baseFeePerGas: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
31
+ blobGasUsed: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
32
+ excessBlobGas: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
33
+ parentBeaconBlockRoot: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
34
+ withdrawalsRoot: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
35
+ l1BlockNumber: s.m(S$RescriptSchema.$$null(S$RescriptSchema.int)),
36
+ sendCount: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
37
+ sendRoot: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
38
+ mixHash: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string))
39
+ }));
45
40
 
46
41
  function parseEvmSimulateBlock(defaultBlockNumber, blockJson) {
47
- var block = blockJson !== undefined ? S$RescriptSchema.convertOrThrow(blockJson, evmSimulateBlockSchema) : S$RescriptSchema.convertOrThrow({}, evmSimulateBlockSchema);
48
- if (Belt_Option.isNone(blockJson) || block.number === 0) {
42
+ let block = blockJson !== undefined ? S$RescriptSchema.convertOrThrow(blockJson, evmSimulateBlockSchema) : S$RescriptSchema.convertOrThrow({}, evmSimulateBlockSchema);
43
+ if (Stdlib_Option.isNone(blockJson) || block.number === 0) {
49
44
  block["number"] = defaultBlockNumber;
50
45
  }
51
46
  return block;
52
47
  }
53
48
 
54
- var evmSimulateTransactionSchema = S$RescriptSchema.schema(function (s) {
55
- return {
56
- transactionIndex: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.$$int), 0)),
57
- hash: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
58
- gas: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
59
- input: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
60
- nonce: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
61
- value: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
62
- cumulativeGasUsed: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
63
- effectiveGasPrice: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
64
- gasUsed: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
65
- logsBloom: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
66
- accessList: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.json(false)), null)),
67
- v: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
68
- r: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
69
- s: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
70
- yParity: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
71
- from: s.m(S$RescriptSchema.$$null(Address.schema)),
72
- to: s.m(S$RescriptSchema.$$null(Address.schema)),
73
- contractAddress: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
74
- gasPrice: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
75
- maxPriorityFeePerGas: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
76
- maxFeePerGas: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
77
- maxFeePerBlobGas: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
78
- blobVersionedHashes: s.m(S$RescriptSchema.$$null(S$RescriptSchema.array(S$RescriptSchema.string))),
79
- root: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
80
- status: s.m(S$RescriptSchema.$$null(S$RescriptSchema.$$int)),
81
- type: s.m(S$RescriptSchema.$$null(S$RescriptSchema.$$int)),
82
- l1Fee: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
83
- l1GasPrice: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
84
- l1GasUsed: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
85
- l1FeeScalar: s.m(S$RescriptSchema.$$null(S$RescriptSchema.$$float)),
86
- gasUsedForL1: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
87
- authorizationList: s.m(S$RescriptSchema.$$null(S$RescriptSchema.json(false)))
88
- };
89
- });
49
+ let evmSimulateTransactionSchema = S$RescriptSchema.schema(s => ({
50
+ transactionIndex: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.int), 0)),
51
+ hash: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
52
+ gas: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
53
+ input: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
54
+ nonce: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
55
+ value: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
56
+ cumulativeGasUsed: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
57
+ effectiveGasPrice: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
58
+ gasUsed: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.bigint), 0n)),
59
+ logsBloom: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
60
+ accessList: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.json(false)), null)),
61
+ v: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
62
+ r: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
63
+ s: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
64
+ yParity: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
65
+ from: s.m(S$RescriptSchema.$$null(Address.schema)),
66
+ to: s.m(S$RescriptSchema.$$null(Address.schema)),
67
+ contractAddress: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
68
+ gasPrice: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
69
+ maxPriorityFeePerGas: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
70
+ maxFeePerGas: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
71
+ maxFeePerBlobGas: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
72
+ blobVersionedHashes: s.m(S$RescriptSchema.$$null(S$RescriptSchema.array(S$RescriptSchema.string))),
73
+ root: s.m(S$RescriptSchema.$$null(S$RescriptSchema.string)),
74
+ status: s.m(S$RescriptSchema.$$null(S$RescriptSchema.int)),
75
+ type: s.m(S$RescriptSchema.$$null(S$RescriptSchema.int)),
76
+ l1Fee: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
77
+ l1GasPrice: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
78
+ l1GasUsed: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
79
+ l1FeeScalar: s.m(S$RescriptSchema.$$null(S$RescriptSchema.float)),
80
+ gasUsedForL1: s.m(S$RescriptSchema.$$null(S$RescriptSchema.bigint)),
81
+ authorizationList: s.m(S$RescriptSchema.$$null(S$RescriptSchema.json(false)))
82
+ }));
90
83
 
91
84
  function parseEvmSimulateTransaction(transactionJson) {
92
85
  if (transactionJson !== undefined) {
@@ -96,27 +89,23 @@ function parseEvmSimulateTransaction(transactionJson) {
96
89
  }
97
90
  }
98
91
 
99
- var fuelSimulateBlockSchema = S$RescriptSchema.schema(function (s) {
100
- return {
101
- id: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
102
- height: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.$$int), 0)),
103
- time: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.$$int), 0))
104
- };
105
- });
92
+ let fuelSimulateBlockSchema = S$RescriptSchema.schema(s => ({
93
+ id: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), "")),
94
+ height: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.int), 0)),
95
+ time: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.int), 0))
96
+ }));
106
97
 
107
98
  function parseFuelSimulateBlock(defaultBlockNumber, blockJson) {
108
- var block = blockJson !== undefined ? S$RescriptSchema.convertOrThrow(blockJson, fuelSimulateBlockSchema) : S$RescriptSchema.convertOrThrow({}, fuelSimulateBlockSchema);
109
- if (Belt_Option.isNone(blockJson) || block.height === 0) {
99
+ let block = blockJson !== undefined ? S$RescriptSchema.convertOrThrow(blockJson, fuelSimulateBlockSchema) : S$RescriptSchema.convertOrThrow({}, fuelSimulateBlockSchema);
100
+ if (Stdlib_Option.isNone(blockJson) || block.height === 0) {
110
101
  block["height"] = defaultBlockNumber;
111
102
  }
112
103
  return block;
113
104
  }
114
105
 
115
- var fuelSimulateTransactionSchema = S$RescriptSchema.schema(function (s) {
116
- return {
117
- id: s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), ""))
118
- };
119
- });
106
+ let fuelSimulateTransactionSchema = S$RescriptSchema.schema(s => ({
107
+ id: s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(S$RescriptSchema.string), ""))
108
+ }));
120
109
 
121
110
  function parseFuelSimulateTransaction(transactionJson) {
122
111
  if (transactionJson !== undefined) {
@@ -127,209 +116,205 @@ function parseFuelSimulateTransaction(transactionJson) {
127
116
  }
128
117
 
129
118
  function findEventConfig(config, contractName, eventName) {
130
- var found = {
119
+ let found = {
131
120
  contents: undefined
132
121
  };
133
- Belt_Array.forEach(ChainMap.values(config.chainMap), (function (chainConfig) {
134
- Belt_Array.forEach(chainConfig.contracts, (function (contract) {
135
- if (contract.name === contractName) {
136
- return Belt_Array.forEach(contract.events, (function (eventConfig) {
137
- if (eventConfig.name === eventName) {
138
- found.contents = eventConfig;
139
- return ;
140
- }
141
-
142
- }));
143
- }
144
-
145
- }));
146
- }));
122
+ ChainMap.values(config.chainMap).forEach(chainConfig => {
123
+ chainConfig.contracts.forEach(contract => {
124
+ if (contract.name === contractName) {
125
+ contract.events.forEach(eventConfig => {
126
+ if (eventConfig.name === eventName) {
127
+ found.contents = eventConfig;
128
+ return;
129
+ }
130
+ });
131
+ return;
132
+ }
133
+ });
134
+ });
147
135
  return found.contents;
148
136
  }
149
137
 
150
138
  function parse(simulateItems, config, chainConfig) {
151
- var chain = ChainMap.Chain.makeUnsafe(chainConfig.id);
152
- var chainId = chainConfig.id;
153
- var startBlock = chainConfig.startBlock;
154
- var currentBlock = {
139
+ let chain = ChainMap.Chain.makeUnsafe(chainConfig.id);
140
+ let chainId = chainConfig.id;
141
+ let startBlock = chainConfig.startBlock;
142
+ let currentBlock = {
155
143
  contents: startBlock
156
144
  };
157
- var currentLogIndex = {
145
+ let currentLogIndex = {
158
146
  contents: 0
159
147
  };
160
- var items = [];
161
- Belt_Array.forEach(simulateItems, (function (rawJson) {
162
- var match = rawJson.contract;
163
- var match$1 = rawJson.event;
164
- if (match === undefined) {
165
- return Js_exn.raiseError("simulate: Invalid item. Each item must have \"contract\" and \"event\" fields.");
166
- }
167
- if (match$1 === undefined) {
168
- return Js_exn.raiseError("simulate: Invalid item. Each item must have \"contract\" and \"event\" fields.");
169
- }
170
- var ec = findEventConfig(config, match, match$1);
171
- var eventConfig = ec !== undefined ? ec : Js_exn.raiseError("simulate: Event \"" + match$1 + "\" not found on contract \"" + match + "\". Check that the contract and event names match your config.yaml.");
172
- var json = rawJson.params;
173
- var paramsJson = json !== undefined ? json : ({});
174
- var params = S$RescriptSchema.convertOrThrow(paramsJson, eventConfig.simulateParamsSchema);
175
- var li = rawJson.logIndex;
176
- var logIndex;
177
- if (li !== undefined) {
178
- logIndex = li;
179
- } else {
180
- var li$1 = currentLogIndex.contents;
181
- currentLogIndex.contents = li$1 + 1 | 0;
182
- logIndex = li$1;
183
- }
184
- var addr = rawJson.srcAddress;
185
- var srcAddress;
186
- if (addr !== undefined) {
187
- srcAddress = Caml_option.valFromOption(addr);
188
- } else {
189
- var addr$1 = {
190
- contents: "0x0000000000000000000000000000000000000000"
191
- };
192
- Belt_Array.forEach(chainConfig.contracts, (function (contract) {
193
- if (contract.name !== match) {
194
- return ;
195
- }
196
- var a = Belt_Array.get(contract.addresses, 0);
197
- if (a !== undefined) {
198
- addr$1.contents = Caml_option.valFromOption(a);
199
- return ;
200
- }
201
-
202
- }));
203
- srcAddress = addr$1.contents;
204
- }
205
- var blockJson = rawJson.block;
206
- var blockJson$1 = (blockJson == null) ? undefined : Caml_option.some(blockJson);
207
- var transactionJson = rawJson.transaction;
208
- var transactionJson$1 = (transactionJson == null) ? undefined : Caml_option.some(transactionJson);
209
- var match$2 = config.ecosystem.name;
210
- var match$3;
211
- switch (match$2) {
212
- case "evm" :
213
- var block = parseEvmSimulateBlock(currentBlock.contents, blockJson$1);
214
- match$3 = [
215
- block,
216
- block.number,
217
- block.timestamp
218
- ];
219
- break;
220
- case "fuel" :
221
- var block$1 = parseFuelSimulateBlock(currentBlock.contents, blockJson$1);
222
- match$3 = [
223
- block$1,
224
- block$1.height,
225
- block$1.time
226
- ];
227
- break;
228
- case "svm" :
229
- match$3 = Js_exn.raiseError("simulate is not supported for SVM ecosystem");
230
- break;
231
-
232
- }
233
- var blockNumber = match$3[1];
234
- var match$4 = config.ecosystem.name;
235
- var transaction;
236
- switch (match$4) {
237
- case "evm" :
238
- transaction = parseEvmSimulateTransaction(transactionJson$1);
239
- break;
240
- case "fuel" :
241
- transaction = parseFuelSimulateTransaction(transactionJson$1);
242
- break;
243
- case "svm" :
244
- transaction = Js_exn.raiseError("simulate is not supported for SVM ecosystem");
245
- break;
246
-
247
- }
248
- currentBlock.contents = blockNumber;
249
- items.push({
250
- kind: 0,
251
- eventConfig: eventConfig,
252
- timestamp: match$3[2],
253
- chain: chain,
254
- blockNumber: blockNumber,
255
- logIndex: logIndex,
256
- event: {
257
- contractName: eventConfig.contractName,
258
- eventName: eventConfig.name,
259
- params: params,
260
- chainId: chainId,
261
- srcAddress: srcAddress,
262
- logIndex: logIndex,
263
- transaction: transaction,
264
- block: match$3[0]
265
- }
266
- });
267
- }));
148
+ let items = [];
149
+ simulateItems.forEach(rawJson => {
150
+ let match = rawJson.contract;
151
+ let match$1 = rawJson.event;
152
+ if (match === undefined) {
153
+ return Stdlib_JsError.throwWithMessage(`simulate: Invalid item. Each item must have "contract" and "event" fields.`);
154
+ }
155
+ if (match$1 === undefined) {
156
+ return Stdlib_JsError.throwWithMessage(`simulate: Invalid item. Each item must have "contract" and "event" fields.`);
157
+ }
158
+ let ec = findEventConfig(config, match, match$1);
159
+ let eventConfig = ec !== undefined ? ec : Stdlib_JsError.throwWithMessage(`simulate: Event "` + match$1 + `" not found on contract "` + match + `". Check that the contract and event names match your config.yaml.`);
160
+ let json = rawJson.params;
161
+ let paramsJson = json !== undefined ? json : ({});
162
+ let params = S$RescriptSchema.convertOrThrow(paramsJson, eventConfig.simulateParamsSchema);
163
+ let li = rawJson.logIndex;
164
+ let logIndex;
165
+ if (li !== undefined) {
166
+ logIndex = li;
167
+ } else {
168
+ let li$1 = currentLogIndex.contents;
169
+ currentLogIndex.contents = li$1 + 1 | 0;
170
+ logIndex = li$1;
171
+ }
172
+ let addr = rawJson.srcAddress;
173
+ let srcAddress;
174
+ if (addr !== undefined) {
175
+ srcAddress = Primitive_option.valFromOption(addr);
176
+ } else {
177
+ let addr$1 = {
178
+ contents: "0x0000000000000000000000000000000000000000"
179
+ };
180
+ chainConfig.contracts.forEach(contract => {
181
+ if (contract.name !== match) {
182
+ return;
183
+ }
184
+ let a = contract.addresses[0];
185
+ if (a !== undefined) {
186
+ addr$1.contents = Primitive_option.valFromOption(a);
187
+ return;
188
+ }
189
+ });
190
+ srcAddress = addr$1.contents;
191
+ }
192
+ let blockJson = rawJson.block;
193
+ let blockJson$1 = (blockJson == null) ? undefined : Primitive_option.some(blockJson);
194
+ let transactionJson = rawJson.transaction;
195
+ let transactionJson$1 = (transactionJson == null) ? undefined : Primitive_option.some(transactionJson);
196
+ let match$2 = config.ecosystem.name;
197
+ let match$3;
198
+ switch (match$2) {
199
+ case "evm" :
200
+ let block = parseEvmSimulateBlock(currentBlock.contents, blockJson$1);
201
+ match$3 = [
202
+ block,
203
+ block.number,
204
+ block.timestamp
205
+ ];
206
+ break;
207
+ case "fuel" :
208
+ let block$1 = parseFuelSimulateBlock(currentBlock.contents, blockJson$1);
209
+ match$3 = [
210
+ block$1,
211
+ block$1.height,
212
+ block$1.time
213
+ ];
214
+ break;
215
+ case "svm" :
216
+ match$3 = Stdlib_JsError.throwWithMessage("simulate is not supported for SVM ecosystem");
217
+ break;
218
+ }
219
+ let blockNumber = match$3[1];
220
+ let match$4 = config.ecosystem.name;
221
+ let transaction;
222
+ switch (match$4) {
223
+ case "evm" :
224
+ transaction = parseEvmSimulateTransaction(transactionJson$1);
225
+ break;
226
+ case "fuel" :
227
+ transaction = parseFuelSimulateTransaction(transactionJson$1);
228
+ break;
229
+ case "svm" :
230
+ transaction = Stdlib_JsError.throwWithMessage("simulate is not supported for SVM ecosystem");
231
+ break;
232
+ }
233
+ currentBlock.contents = blockNumber;
234
+ items.push({
235
+ kind: 0,
236
+ eventConfig: eventConfig,
237
+ timestamp: match$3[2],
238
+ chain: chain,
239
+ blockNumber: blockNumber,
240
+ logIndex: logIndex,
241
+ event: {
242
+ contractName: eventConfig.contractName,
243
+ eventName: eventConfig.name,
244
+ params: params,
245
+ chainId: chainId,
246
+ srcAddress: srcAddress,
247
+ logIndex: logIndex,
248
+ transaction: transaction,
249
+ block: match$3[0]
250
+ }
251
+ });
252
+ });
268
253
  return items;
269
254
  }
270
255
 
271
256
  function patchConfig(config, processConfig) {
272
- var processChains = processConfig.chains;
257
+ let processChains = processConfig.chains;
273
258
  if (processChains == null) {
274
259
  return config;
275
260
  }
276
- var newChainMap = ChainMap.mapWithKey(config.chainMap, (function (chain, chainConfig) {
277
- var chainIdStr = String(chain);
278
- var processChainJson = Js_dict.get(processChains, chainIdStr);
279
- if (processChainJson === undefined) {
280
- return chainConfig;
281
- }
282
- var simulateRaw = processChainJson.simulate;
283
- if (simulateRaw == null) {
284
- return chainConfig;
285
- }
286
- var items = parse(simulateRaw, config, chainConfig);
287
- var startBlock = processChainJson.startBlock;
288
- var endBlock = processChainJson.endBlock;
289
- var source = SimulateSource.make(items, endBlock, chain);
290
- var newrecord = Caml_obj.obj_dup(chainConfig);
291
- newrecord.sourceConfig = {
292
- TAG: "CustomSources",
293
- _0: [source]
294
- };
295
- newrecord.endBlock = endBlock;
296
- newrecord.startBlock = startBlock;
297
- return newrecord;
298
- }));
261
+ let newChainMap = ChainMap.mapWithKey(config.chainMap, (chain, chainConfig) => {
262
+ let chainIdStr = chain.toString();
263
+ let processChainJson = processChains[chainIdStr];
264
+ if (processChainJson === undefined) {
265
+ return chainConfig;
266
+ }
267
+ let simulateRaw = processChainJson.simulate;
268
+ if (simulateRaw == null) {
269
+ return chainConfig;
270
+ }
271
+ let items = parse(simulateRaw, config, chainConfig);
272
+ let startBlock = processChainJson.startBlock;
273
+ let endBlock = processChainJson.endBlock;
274
+ let source = SimulateSource.make(items, endBlock, chain);
275
+ let newrecord = {...chainConfig};
276
+ newrecord.sourceConfig = {
277
+ TAG: "CustomSources",
278
+ _0: [source]
279
+ };
280
+ newrecord.endBlock = endBlock;
281
+ newrecord.startBlock = startBlock;
282
+ return newrecord;
283
+ });
299
284
  return {
300
- name: config.name,
301
- description: config.description,
302
- handlers: config.handlers,
303
- contractHandlers: config.contractHandlers,
304
- shouldRollbackOnReorg: config.shouldRollbackOnReorg,
305
- shouldSaveFullHistory: config.shouldSaveFullHistory,
306
- multichain: config.multichain,
307
- chainMap: newChainMap,
308
- defaultChain: config.defaultChain,
309
- ecosystem: config.ecosystem,
310
- enableRawEvents: config.enableRawEvents,
311
- maxAddrInPartition: config.maxAddrInPartition,
312
- batchSize: config.batchSize,
313
- lowercaseAddresses: config.lowercaseAddresses,
314
- addContractNameToContractNameMapping: config.addContractNameToContractNameMapping,
315
- userEntitiesByName: config.userEntitiesByName,
316
- userEntities: config.userEntities,
317
- allEntities: config.allEntities,
318
- allEnums: config.allEnums
319
- };
285
+ name: config.name,
286
+ description: config.description,
287
+ handlers: config.handlers,
288
+ contractHandlers: config.contractHandlers,
289
+ shouldRollbackOnReorg: config.shouldRollbackOnReorg,
290
+ shouldSaveFullHistory: config.shouldSaveFullHistory,
291
+ storage: config.storage,
292
+ multichain: config.multichain,
293
+ chainMap: newChainMap,
294
+ defaultChain: config.defaultChain,
295
+ ecosystem: config.ecosystem,
296
+ enableRawEvents: config.enableRawEvents,
297
+ maxAddrInPartition: config.maxAddrInPartition,
298
+ batchSize: config.batchSize,
299
+ lowercaseAddresses: config.lowercaseAddresses,
300
+ userEntitiesByName: config.userEntitiesByName,
301
+ userEntities: config.userEntities,
302
+ allEntities: config.allEntities,
303
+ allEnums: config.allEnums
304
+ };
320
305
  }
321
306
 
322
307
  export {
323
- evmSimulateBlockSchema ,
324
- parseEvmSimulateBlock ,
325
- evmSimulateTransactionSchema ,
326
- parseEvmSimulateTransaction ,
327
- fuelSimulateBlockSchema ,
328
- parseFuelSimulateBlock ,
329
- fuelSimulateTransactionSchema ,
330
- parseFuelSimulateTransaction ,
331
- findEventConfig ,
332
- parse ,
333
- patchConfig ,
308
+ evmSimulateBlockSchema,
309
+ parseEvmSimulateBlock,
310
+ evmSimulateTransactionSchema,
311
+ parseEvmSimulateTransaction,
312
+ fuelSimulateBlockSchema,
313
+ parseFuelSimulateBlock,
314
+ fuelSimulateTransactionSchema,
315
+ parseFuelSimulateTransaction,
316
+ findEventConfig,
317
+ parse,
318
+ patchConfig,
334
319
  }
335
320
  /* evmSimulateBlockSchema Not a pure module */
package/src/Sink.res CHANGED
@@ -30,7 +30,7 @@ let makeClickHouse = (~host, ~database, ~username, ~password): t => {
30
30
  let cache = Utils.WeakMap.make()
31
31
 
32
32
  {
33
- name: "ClickHouse",
33
+ name: "clickhouse",
34
34
  initialize: (~chainConfigs as _=[], ~entities=[], ~enums=[]) => {
35
35
  ClickHouse.initialize(client, ~database, ~entities, ~enums)
36
36
  },
@@ -42,7 +42,7 @@ let makeClickHouse = (~host, ~database, ~username, ~password): t => {
42
42
  updatedEntities->Belt.Array.map(({entityConfig, updates}) => {
43
43
  ClickHouse.setUpdatesOrThrow(client, ~cache, ~updates, ~entityConfig, ~database)
44
44
  }),
45
- )->Promise.ignoreValue
45
+ )->Utils.Promise.ignoreValue
46
46
  await ClickHouse.setCheckpointsOrThrow(client, ~batch, ~database)
47
47
  },
48
48
  }