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,62 +1,55 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
+ import * as Env from "./Env.res.mjs";
3
4
  import * as Evm from "./sources/Evm.res.mjs";
4
5
  import * as Svm from "./sources/Svm.res.mjs";
6
+ import * as Core from "./Core.res.mjs";
5
7
  import * as Fuel from "./sources/Fuel.res.mjs";
6
8
  import * as Table from "./db/Table.res.mjs";
7
9
  import * as Utils from "./Utils.res.mjs";
8
- import * as $$BigInt from "./bindings/BigInt.res.mjs";
9
- import * as Js_exn from "rescript/lib/es6/js_exn.js";
10
10
  import * as Address from "./Address.res.mjs";
11
- import * as Js_dict from "rescript/lib/es6/js_dict.js";
12
11
  import * as ChainMap from "./ChainMap.res.mjs";
13
12
  import * as Internal from "./Internal.res.mjs";
14
- import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
15
13
  import * as BigDecimal from "./bindings/BigDecimal.res.mjs";
16
- import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
17
- import * as Caml_option from "rescript/lib/es6/caml_option.js";
18
- import * as HandlerRegister from "./HandlerRegister.res.mjs";
14
+ import * as Belt_Option from "@rescript/runtime/lib/es6/Belt_Option.js";
15
+ import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
16
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
17
+ import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
18
+ import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
19
19
  import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
20
- import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
21
20
  import * as EventConfigBuilder from "./EventConfigBuilder.res.mjs";
21
+ import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
22
22
 
23
- var name = "dynamic_contract_registry";
23
+ let name = "envio_addresses";
24
24
 
25
- function makeId(chainId, contractAddress) {
26
- return String(chainId) + "-" + contractAddress;
25
+ function makeId(chainId, address) {
26
+ return String(chainId) + "-" + address;
27
27
  }
28
28
 
29
- var schema = S$RescriptSchema.schema(function (s) {
30
- return {
31
- id: s.m(S$RescriptSchema.string),
32
- chain_id: s.m(S$RescriptSchema.$$int),
33
- registering_event_block_number: s.m(S$RescriptSchema.$$int),
34
- registering_event_log_index: s.m(S$RescriptSchema.$$int),
35
- registering_event_block_timestamp: s.m(S$RescriptSchema.$$int),
36
- registering_event_contract_name: s.m(S$RescriptSchema.string),
37
- registering_event_name: s.m(S$RescriptSchema.string),
38
- registering_event_src_address: s.m(Address.schema),
39
- contract_address: s.m(Address.schema),
40
- contract_name: s.m(S$RescriptSchema.string)
41
- };
42
- });
29
+ function getAddress(entity) {
30
+ let sepIdx = entity.id.indexOf("-");
31
+ return entity.id.slice(sepIdx + 1 | 0, entity.id.length);
32
+ }
33
+
34
+ let schema = S$RescriptSchema.schema(s => ({
35
+ id: s.m(S$RescriptSchema.string),
36
+ chain_id: s.m(S$RescriptSchema.int),
37
+ registration_block: s.m(S$RescriptSchema.int),
38
+ registration_log_index: s.m(S$RescriptSchema.int),
39
+ contract_name: s.m(S$RescriptSchema.string)
40
+ }));
43
41
 
44
- var rowsSchema = S$RescriptSchema.array(schema);
45
-
46
- var table = Table.mkTable(name, undefined, [
47
- Table.mkField("id", "String", S$RescriptSchema.string, undefined, undefined, undefined, true, undefined, undefined),
48
- Table.mkField("chain_id", "Int32", S$RescriptSchema.$$int, undefined, undefined, undefined, undefined, undefined, undefined),
49
- Table.mkField("registering_event_block_number", "Int32", S$RescriptSchema.$$int, undefined, undefined, undefined, undefined, undefined, undefined),
50
- Table.mkField("registering_event_log_index", "Int32", S$RescriptSchema.$$int, undefined, undefined, undefined, undefined, undefined, undefined),
51
- Table.mkField("registering_event_block_timestamp", "Int32", S$RescriptSchema.$$int, undefined, undefined, undefined, undefined, undefined, undefined),
52
- Table.mkField("registering_event_contract_name", "String", S$RescriptSchema.string, undefined, undefined, undefined, undefined, undefined, undefined),
53
- Table.mkField("registering_event_name", "String", S$RescriptSchema.string, undefined, undefined, undefined, undefined, undefined, undefined),
54
- Table.mkField("registering_event_src_address", "String", Address.schema, undefined, undefined, undefined, undefined, undefined, undefined),
55
- Table.mkField("contract_address", "String", Address.schema, undefined, undefined, undefined, undefined, undefined, undefined),
56
- Table.mkField("contract_name", "String", S$RescriptSchema.string, undefined, undefined, undefined, undefined, undefined, undefined)
57
- ]);
58
-
59
- var entityConfig = {
42
+ let rowsSchema = S$RescriptSchema.array(schema);
43
+
44
+ let table = Table.mkTable(name, undefined, [
45
+ Table.mkField("id", "String", S$RescriptSchema.string, undefined, undefined, undefined, true, undefined, undefined),
46
+ Table.mkField("chain_id", "Int32", S$RescriptSchema.int, undefined, undefined, undefined, undefined, undefined, undefined),
47
+ Table.mkField("registration_block", "Int32", S$RescriptSchema.int, undefined, undefined, undefined, undefined, undefined, undefined),
48
+ Table.mkField("registration_log_index", "Int32", S$RescriptSchema.int, undefined, undefined, undefined, undefined, undefined, undefined),
49
+ Table.mkField("contract_name", "String", S$RescriptSchema.string, undefined, undefined, undefined, undefined, undefined, undefined)
50
+ ]);
51
+
52
+ let entityConfig = {
60
53
  name: name,
61
54
  index: -1,
62
55
  schema: schema,
@@ -64,375 +57,357 @@ var entityConfig = {
64
57
  table: table
65
58
  };
66
59
 
67
- var DynamicContractRegistry = {
60
+ let EnvioAddresses = {
68
61
  name: name,
69
62
  index: -1,
70
63
  makeId: makeId,
64
+ getAddress: getAddress,
71
65
  schema: schema,
72
66
  rowsSchema: rowsSchema,
73
67
  table: table,
74
68
  entityConfig: entityConfig
75
69
  };
76
70
 
77
- var rpcSourceForSchema = S$RescriptSchema.$$enum([
78
- "sync",
79
- "fallback",
80
- "live"
81
- ]);
71
+ let rpcSourceForSchema = S$RescriptSchema.$$enum([
72
+ "sync",
73
+ "fallback",
74
+ "live"
75
+ ]);
82
76
 
83
- var rpcConfigSchema = S$RescriptSchema.schema(function (s) {
84
- return {
85
- url: s.m(S$RescriptSchema.string),
86
- for: s.m(rpcSourceForSchema),
87
- ws: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
88
- initialBlockInterval: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
89
- backoffMultiplicative: s.m(S$RescriptSchema.option(S$RescriptSchema.$$float)),
90
- accelerationAdditive: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
91
- intervalCeiling: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
92
- backoffMillis: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
93
- fallbackStallTimeout: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
94
- queryTimeoutMillis: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
95
- pollingInterval: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int))
96
- };
97
- });
77
+ let rpcConfigSchema = S$RescriptSchema.schema(s => ({
78
+ url: s.m(S$RescriptSchema.string),
79
+ for: s.m(rpcSourceForSchema),
80
+ ws: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
81
+ initialBlockInterval: s.m(S$RescriptSchema.option(S$RescriptSchema.int)),
82
+ backoffMultiplicative: s.m(S$RescriptSchema.option(S$RescriptSchema.float)),
83
+ accelerationAdditive: s.m(S$RescriptSchema.option(S$RescriptSchema.int)),
84
+ intervalCeiling: s.m(S$RescriptSchema.option(S$RescriptSchema.int)),
85
+ backoffMillis: s.m(S$RescriptSchema.option(S$RescriptSchema.int)),
86
+ fallbackStallTimeout: s.m(S$RescriptSchema.option(S$RescriptSchema.int)),
87
+ queryTimeoutMillis: s.m(S$RescriptSchema.option(S$RescriptSchema.int)),
88
+ pollingInterval: s.m(S$RescriptSchema.option(S$RescriptSchema.int))
89
+ }));
98
90
 
99
- var chainContractSchema = S$RescriptSchema.schema(function (s) {
100
- return {
101
- addresses: s.m(S$RescriptSchema.option(S$RescriptSchema.array(S$RescriptSchema.string))),
102
- startBlock: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int))
103
- };
104
- });
91
+ let chainContractSchema = S$RescriptSchema.schema(s => ({
92
+ addresses: s.m(S$RescriptSchema.option(S$RescriptSchema.array(S$RescriptSchema.string))),
93
+ startBlock: s.m(S$RescriptSchema.option(S$RescriptSchema.int))
94
+ }));
105
95
 
106
- var publicConfigChainSchema = S$RescriptSchema.schema(function (s) {
107
- return {
108
- id: s.m(S$RescriptSchema.$$int),
109
- startBlock: s.m(S$RescriptSchema.$$int),
110
- endBlock: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
111
- maxReorgDepth: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
112
- blockLag: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
113
- hypersync: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
114
- rpcs: s.m(S$RescriptSchema.option(S$RescriptSchema.array(rpcConfigSchema))),
115
- rpc: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
116
- contracts: s.m(S$RescriptSchema.option(S$RescriptSchema.dict(chainContractSchema)))
117
- };
118
- });
96
+ let publicConfigChainSchema = S$RescriptSchema.schema(s => ({
97
+ id: s.m(S$RescriptSchema.int),
98
+ startBlock: s.m(S$RescriptSchema.int),
99
+ endBlock: s.m(S$RescriptSchema.option(S$RescriptSchema.int)),
100
+ maxReorgDepth: s.m(S$RescriptSchema.option(S$RescriptSchema.int)),
101
+ blockLag: s.m(S$RescriptSchema.option(S$RescriptSchema.int)),
102
+ hypersync: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
103
+ rpcs: s.m(S$RescriptSchema.option(S$RescriptSchema.array(rpcConfigSchema))),
104
+ rpc: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
105
+ contracts: s.m(S$RescriptSchema.option(S$RescriptSchema.dict(chainContractSchema)))
106
+ }));
119
107
 
120
- var contractEventItemSchema = S$RescriptSchema.schema(function (s) {
121
- return {
122
- event: s.m(S$RescriptSchema.string),
123
- name: s.m(S$RescriptSchema.string),
124
- sighash: s.m(S$RescriptSchema.string),
125
- params: s.m(S$RescriptSchema.option(S$RescriptSchema.array(EventConfigBuilder.eventParamSchema))),
126
- kind: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
127
- blockFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(Internal.evmBlockFieldSchema))),
128
- transactionFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(Internal.evmTransactionFieldSchema)))
129
- };
130
- });
108
+ let contractEventItemSchema = S$RescriptSchema.schema(s => ({
109
+ event: s.m(S$RescriptSchema.string),
110
+ name: s.m(S$RescriptSchema.string),
111
+ sighash: s.m(S$RescriptSchema.string),
112
+ params: s.m(S$RescriptSchema.option(S$RescriptSchema.array(EventConfigBuilder.eventParamSchema))),
113
+ kind: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
114
+ blockFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(Internal.evmBlockFieldSchema))),
115
+ transactionFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(Internal.evmTransactionFieldSchema)))
116
+ }));
131
117
 
132
- var contractConfigSchema = S$RescriptSchema.schema(function (s) {
133
- return {
134
- abi: s.m(S$RescriptSchema.json(false)),
135
- handler: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
136
- events: s.m(S$RescriptSchema.option(S$RescriptSchema.array(contractEventItemSchema)))
137
- };
138
- });
118
+ let contractConfigSchema = S$RescriptSchema.schema(s => ({
119
+ abi: s.m(S$RescriptSchema.json(false)),
120
+ handler: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
121
+ events: s.m(S$RescriptSchema.option(S$RescriptSchema.array(contractEventItemSchema)))
122
+ }));
139
123
 
140
- var publicConfigEcosystemSchema = S$RescriptSchema.schema(function (s) {
141
- return {
142
- chains: s.m(S$RescriptSchema.dict(publicConfigChainSchema)),
143
- contracts: s.m(S$RescriptSchema.option(S$RescriptSchema.dict(contractConfigSchema)))
144
- };
145
- });
124
+ let publicConfigEcosystemSchema = S$RescriptSchema.schema(s => ({
125
+ chains: s.m(S$RescriptSchema.dict(publicConfigChainSchema)),
126
+ contracts: s.m(S$RescriptSchema.option(S$RescriptSchema.dict(contractConfigSchema)))
127
+ }));
146
128
 
147
- var publicConfigEvmSchema = S$RescriptSchema.schema(function (s) {
148
- return {
149
- chains: s.m(S$RescriptSchema.dict(publicConfigChainSchema)),
150
- contracts: s.m(S$RescriptSchema.option(S$RescriptSchema.dict(contractConfigSchema))),
151
- addressFormat: s.m(S$RescriptSchema.option(S$RescriptSchema.$$enum([
152
- "lowercase",
153
- "checksum"
154
- ]))),
155
- globalBlockFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(Internal.evmBlockFieldSchema))),
156
- globalTransactionFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(Internal.evmTransactionFieldSchema)))
157
- };
158
- });
129
+ let publicConfigEvmSchema = S$RescriptSchema.schema(s => ({
130
+ chains: s.m(S$RescriptSchema.dict(publicConfigChainSchema)),
131
+ contracts: s.m(S$RescriptSchema.option(S$RescriptSchema.dict(contractConfigSchema))),
132
+ addressFormat: s.m(S$RescriptSchema.option(S$RescriptSchema.$$enum([
133
+ "lowercase",
134
+ "checksum"
135
+ ]))),
136
+ globalBlockFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(Internal.evmBlockFieldSchema))),
137
+ globalTransactionFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(Internal.evmTransactionFieldSchema)))
138
+ }));
159
139
 
160
- var multichainSchema = S$RescriptSchema.$$enum([
161
- "ordered",
162
- "unordered"
163
- ]);
140
+ let multichainSchema = S$RescriptSchema.$$enum([
141
+ "ordered",
142
+ "unordered"
143
+ ]);
164
144
 
165
- var compositeIndexFieldSchema = S$RescriptSchema.schema(function (s) {
166
- return {
167
- fieldName: s.m(S$RescriptSchema.string),
168
- direction: s.m(S$RescriptSchema.string)
169
- };
170
- });
145
+ let compositeIndexFieldSchema = S$RescriptSchema.schema(s => ({
146
+ fieldName: s.m(S$RescriptSchema.string),
147
+ direction: s.m(S$RescriptSchema.string)
148
+ }));
171
149
 
172
- var derivedFieldSchema = S$RescriptSchema.schema(function (s) {
173
- return {
174
- fieldName: s.m(S$RescriptSchema.string),
175
- derivedFromEntity: s.m(S$RescriptSchema.string),
176
- derivedFromField: s.m(S$RescriptSchema.string)
177
- };
178
- });
150
+ let derivedFieldSchema = S$RescriptSchema.schema(s => ({
151
+ fieldName: s.m(S$RescriptSchema.string),
152
+ derivedFromEntity: s.m(S$RescriptSchema.string),
153
+ derivedFromField: s.m(S$RescriptSchema.string)
154
+ }));
179
155
 
180
- var propertySchema = S$RescriptSchema.schema(function (s) {
181
- return {
182
- name: s.m(S$RescriptSchema.string),
183
- type: s.m(S$RescriptSchema.string),
184
- isNullable: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
185
- isArray: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
186
- isIndex: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
187
- linkedEntity: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
188
- enum: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
189
- entity: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
190
- precision: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
191
- scale: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int))
192
- };
193
- });
156
+ let propertySchema = S$RescriptSchema.schema(s => ({
157
+ name: s.m(S$RescriptSchema.string),
158
+ type: s.m(S$RescriptSchema.string),
159
+ isNullable: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
160
+ isArray: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
161
+ isIndex: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
162
+ linkedEntity: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
163
+ enum: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
164
+ entity: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
165
+ precision: s.m(S$RescriptSchema.option(S$RescriptSchema.int)),
166
+ scale: s.m(S$RescriptSchema.option(S$RescriptSchema.int))
167
+ }));
194
168
 
195
- var entityJsonSchema = S$RescriptSchema.schema(function (s) {
196
- return {
197
- name: s.m(S$RescriptSchema.string),
198
- properties: s.m(S$RescriptSchema.array(propertySchema)),
199
- derivedFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(derivedFieldSchema))),
200
- compositeIndices: s.m(S$RescriptSchema.option(S$RescriptSchema.array(S$RescriptSchema.array(compositeIndexFieldSchema))))
201
- };
202
- });
169
+ let entityJsonSchema = S$RescriptSchema.schema(s => ({
170
+ name: s.m(S$RescriptSchema.string),
171
+ properties: s.m(S$RescriptSchema.array(propertySchema)),
172
+ derivedFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(derivedFieldSchema))),
173
+ compositeIndices: s.m(S$RescriptSchema.option(S$RescriptSchema.array(S$RescriptSchema.array(compositeIndexFieldSchema))))
174
+ }));
203
175
 
204
176
  function getFieldTypeAndSchema(prop, enumConfigsByName) {
205
- var typ = prop.type;
206
- var isNullable = Belt_Option.getWithDefault(prop.isNullable, false);
207
- var isArray = Belt_Option.getWithDefault(prop.isArray, false);
208
- var isIndex = Belt_Option.getWithDefault(prop.isIndex, false);
209
- var match;
177
+ let typ = prop.type;
178
+ let isNullable = Stdlib_Option.getOr(prop.isNullable, false);
179
+ let isArray = Stdlib_Option.getOr(prop.isArray, false);
180
+ let isIndex = Stdlib_Option.getOr(prop.isIndex, false);
181
+ let match;
210
182
  switch (typ) {
211
183
  case "bigdecimal" :
212
- match = [
213
- {
214
- type: "BigDecimal",
215
- config: Belt_Option.map(prop.precision, (function (p) {
216
- return [
217
- p,
218
- Belt_Option.getWithDefault(prop.scale, 0)
219
- ];
220
- }))
221
- },
222
- BigDecimal.schema
223
- ];
224
- break;
184
+ match = [
185
+ {
186
+ type: "BigDecimal",
187
+ config: Stdlib_Option.map(prop.precision, p => [
188
+ p,
189
+ Stdlib_Option.getOr(prop.scale, 0)
190
+ ])
191
+ },
192
+ BigDecimal.schema
193
+ ];
194
+ break;
225
195
  case "bigint" :
226
- match = [
227
- {
228
- type: "BigInt",
229
- precision: prop.precision
230
- },
231
- $$BigInt.schema
232
- ];
233
- break;
196
+ match = [
197
+ {
198
+ type: "BigInt",
199
+ precision: prop.precision
200
+ },
201
+ Utils.$$BigInt.schema
202
+ ];
203
+ break;
234
204
  case "boolean" :
235
- match = [
236
- "Boolean",
237
- S$RescriptSchema.bool
238
- ];
239
- break;
205
+ match = [
206
+ "Boolean",
207
+ S$RescriptSchema.bool
208
+ ];
209
+ break;
240
210
  case "date" :
241
- match = [
242
- "Date",
243
- Utils.Schema.dbDate
244
- ];
245
- break;
211
+ match = [
212
+ "Date",
213
+ Utils.Schema.dbDate
214
+ ];
215
+ break;
246
216
  case "entity" :
247
- var entityName = Belt_Option.getExn(prop.entity);
248
- match = [
249
- {
250
- type: "Entity",
251
- name: entityName
252
- },
253
- S$RescriptSchema.string
254
- ];
255
- break;
217
+ let entityName = Stdlib_Option.getOrThrow(prop.entity, undefined);
218
+ match = [
219
+ {
220
+ type: "Entity",
221
+ name: entityName
222
+ },
223
+ S$RescriptSchema.string
224
+ ];
225
+ break;
256
226
  case "enum" :
257
- var enumName = Belt_Option.getExn(prop.enum);
258
- var enumConfig = Belt_Option.getExn(Js_dict.get(enumConfigsByName, enumName));
259
- match = [
260
- {
261
- type: "Enum",
262
- config: enumConfig
263
- },
264
- enumConfig.schema
265
- ];
266
- break;
227
+ let enumName = Stdlib_Option.getOrThrow(prop.enum, undefined);
228
+ let enumConfig = Stdlib_Option.getOrThrow(enumConfigsByName[enumName], undefined);
229
+ match = [
230
+ {
231
+ type: "Enum",
232
+ config: enumConfig
233
+ },
234
+ enumConfig.schema
235
+ ];
236
+ break;
267
237
  case "float" :
268
- match = [
269
- "Number",
270
- S$RescriptSchema.$$float
271
- ];
272
- break;
238
+ match = [
239
+ "Number",
240
+ S$RescriptSchema.float
241
+ ];
242
+ break;
273
243
  case "int" :
274
- match = [
275
- "Int32",
276
- S$RescriptSchema.$$int
277
- ];
278
- break;
244
+ match = [
245
+ "Int32",
246
+ S$RescriptSchema.int
247
+ ];
248
+ break;
279
249
  case "json" :
280
- match = [
281
- "Json",
282
- S$RescriptSchema.json(false)
283
- ];
284
- break;
250
+ match = [
251
+ "Json",
252
+ S$RescriptSchema.json(false)
253
+ ];
254
+ break;
285
255
  case "serial" :
286
- match = [
287
- "Serial",
288
- S$RescriptSchema.$$int
289
- ];
290
- break;
256
+ match = [
257
+ "Serial",
258
+ S$RescriptSchema.int
259
+ ];
260
+ break;
291
261
  case "string" :
292
- match = [
293
- "String",
294
- S$RescriptSchema.string
295
- ];
296
- break;
262
+ match = [
263
+ "String",
264
+ S$RescriptSchema.string
265
+ ];
266
+ break;
297
267
  default:
298
- match = Js_exn.raiseError("Unknown field type in entity config: " + typ);
268
+ match = Stdlib_JsError.throwWithMessage("Unknown field type in entity config: " + typ);
299
269
  }
300
- var baseSchema = match[1];
301
- var fieldSchema = isArray ? S$RescriptSchema.array(baseSchema) : baseSchema;
302
- var fieldSchema$1 = isNullable ? S$RescriptSchema.$$null(fieldSchema) : fieldSchema;
270
+ let baseSchema = match[1];
271
+ let fieldSchema = isArray ? S$RescriptSchema.array(baseSchema) : baseSchema;
272
+ let fieldSchema$1 = isNullable ? S$RescriptSchema.$$null(fieldSchema) : fieldSchema;
303
273
  return [
304
- match[0],
305
- fieldSchema$1,
306
- isNullable,
307
- isArray,
308
- isIndex
309
- ];
274
+ match[0],
275
+ fieldSchema$1,
276
+ isNullable,
277
+ isArray,
278
+ isIndex
279
+ ];
310
280
  }
311
281
 
312
282
  function parseEnumsFromJson(enumsJson) {
313
- return Belt_Array.map(Js_dict.entries(enumsJson), (function (param) {
314
- return Table.makeEnumConfig(param[0], param[1]);
315
- }));
283
+ return Object.entries(enumsJson).map(param => Table.makeEnumConfig(param[0], param[1]));
316
284
  }
317
285
 
318
286
  function parseEntitiesFromJson(entitiesJson, enumConfigsByName) {
319
- return Belt_Array.mapWithIndex(entitiesJson, (function (index, entityJson) {
320
- var entityName = entityJson.name;
321
- var fields = Belt_Array.map(entityJson.properties, (function (prop) {
322
- var match = getFieldTypeAndSchema(prop, enumConfigsByName);
323
- return Table.mkField(prop.name, match[0], match[1], undefined, match[3], match[2], prop.name === "id", match[4], prop.linkedEntity);
324
- }));
325
- var derivedFields = Belt_Array.map(Belt_Option.getWithDefault(entityJson.derivedFields, []), (function (df) {
326
- return Table.mkDerivedFromField(df.fieldName, df.derivedFromEntity, df.derivedFromField);
327
- }));
328
- var compositeIndices = Belt_Array.map(Belt_Option.getWithDefault(entityJson.compositeIndices, []), (function (ci) {
329
- return Belt_Array.map(ci, (function (f) {
330
- return {
331
- fieldName: f.fieldName,
332
- direction: f.direction === "Asc" ? "Asc" : "Desc"
333
- };
334
- }));
335
- }));
336
- var table = Table.mkTable(entityName, compositeIndices, Belt_Array.concat(fields, derivedFields));
337
- var schema = S$RescriptSchema.schema(function (s) {
338
- var dict = {};
339
- Belt_Array.forEach(entityJson.properties, (function (prop) {
340
- var match = getFieldTypeAndSchema(prop, enumConfigsByName);
341
- var match$1 = prop.linkedEntity;
342
- var dbFieldName = match$1 !== undefined ? prop.name + "_id" : prop.name;
343
- dict[dbFieldName] = s.m(match[1]);
344
- }));
345
- return dict;
346
- });
347
- return {
348
- name: entityName,
349
- index: index,
350
- schema: schema,
351
- rowsSchema: S$RescriptSchema.array(schema),
352
- table: table
353
- };
354
- }));
287
+ return entitiesJson.map((entityJson, index) => {
288
+ let entityName = entityJson.name;
289
+ let fields = entityJson.properties.map(prop => {
290
+ let match = getFieldTypeAndSchema(prop, enumConfigsByName);
291
+ return Table.mkField(prop.name, match[0], match[1], undefined, match[3], match[2], prop.name === "id", match[4], prop.linkedEntity);
292
+ });
293
+ let derivedFields = Stdlib_Option.getOr(entityJson.derivedFields, []).map(df => Table.mkDerivedFromField(df.fieldName, df.derivedFromEntity, df.derivedFromField));
294
+ let compositeIndices = Stdlib_Option.getOr(entityJson.compositeIndices, []).map(ci => ci.map(f => ({
295
+ fieldName: f.fieldName,
296
+ direction: f.direction === "Asc" ? "Asc" : "Desc"
297
+ })));
298
+ let table = Table.mkTable(entityName, compositeIndices, fields.concat(derivedFields));
299
+ let schema = S$RescriptSchema.schema(s => {
300
+ let dict = {};
301
+ entityJson.properties.forEach(prop => {
302
+ let match = getFieldTypeAndSchema(prop, enumConfigsByName);
303
+ let match$1 = prop.linkedEntity;
304
+ let dbFieldName = match$1 !== undefined ? prop.name + "_id" : prop.name;
305
+ dict[dbFieldName] = s.m(match[1]);
306
+ });
307
+ return dict;
308
+ });
309
+ return {
310
+ name: entityName,
311
+ index: index,
312
+ schema: schema,
313
+ rowsSchema: S$RescriptSchema.array(schema),
314
+ table: table
315
+ };
316
+ });
355
317
  }
356
318
 
357
- var publicConfigSchema = S$RescriptSchema.schema(function (s) {
358
- return {
359
- name: s.m(S$RescriptSchema.string),
360
- description: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
361
- handlers: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
362
- multichain: s.m(S$RescriptSchema.option(multichainSchema)),
363
- fullBatchSize: s.m(S$RescriptSchema.option(S$RescriptSchema.$$int)),
364
- rollbackOnReorg: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
365
- saveFullHistory: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
366
- rawEvents: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
367
- evm: s.m(S$RescriptSchema.option(publicConfigEvmSchema)),
368
- fuel: s.m(S$RescriptSchema.option(publicConfigEcosystemSchema)),
369
- svm: s.m(S$RescriptSchema.option(publicConfigEcosystemSchema)),
370
- enums: s.m(S$RescriptSchema.option(S$RescriptSchema.dict(S$RescriptSchema.array(S$RescriptSchema.string)))),
371
- entities: s.m(S$RescriptSchema.option(S$RescriptSchema.array(entityJsonSchema)))
372
- };
373
- });
319
+ let publicConfigStorageSchema = S$RescriptSchema.schema(s => ({
320
+ postgres: s.m(S$RescriptSchema.bool),
321
+ clickhouse: s.m(S$RescriptSchema.option(S$RescriptSchema.bool))
322
+ }));
374
323
 
375
- function fromPublic(publicConfigJson, maxAddrInPartitionOpt) {
376
- var maxAddrInPartition = maxAddrInPartitionOpt !== undefined ? maxAddrInPartitionOpt : 5000;
377
- var publicConfig;
324
+ let publicConfigSchema = S$RescriptSchema.schema(s => ({
325
+ name: s.m(S$RescriptSchema.string),
326
+ description: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
327
+ handlers: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
328
+ multichain: s.m(S$RescriptSchema.option(multichainSchema)),
329
+ fullBatchSize: s.m(S$RescriptSchema.option(S$RescriptSchema.int)),
330
+ rollbackOnReorg: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
331
+ saveFullHistory: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
332
+ rawEvents: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
333
+ storage: s.m(publicConfigStorageSchema),
334
+ evm: s.m(S$RescriptSchema.option(publicConfigEvmSchema)),
335
+ fuel: s.m(S$RescriptSchema.option(publicConfigEcosystemSchema)),
336
+ svm: s.m(S$RescriptSchema.option(publicConfigEcosystemSchema)),
337
+ enums: s.m(S$RescriptSchema.option(S$RescriptSchema.dict(S$RescriptSchema.array(S$RescriptSchema.string)))),
338
+ entities: s.m(S$RescriptSchema.option(S$RescriptSchema.array(entityJsonSchema)))
339
+ }));
340
+
341
+ function fromPublic(publicConfigJson) {
342
+ let publicConfig;
378
343
  try {
379
344
  publicConfig = S$RescriptSchema.parseOrThrow(publicConfigJson, publicConfigSchema);
380
- }
381
- catch (raw_exn){
382
- var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
345
+ } catch (raw_exn) {
346
+ let exn = Primitive_exceptions.internalToException(raw_exn);
383
347
  if (exn.RE_EXN_ID === S$RescriptSchema.Raised) {
384
- publicConfig = Js_exn.raiseError("Invalid internal.config.ts: " + Utils.prettifyExn(exn._1));
348
+ publicConfig = Stdlib_JsError.throwWithMessage(`Invalid indexer config: ` + Utils.prettifyExn(exn._1));
385
349
  } else {
386
350
  throw exn;
387
351
  }
388
352
  }
389
- var match = publicConfig.evm;
390
- var match$1 = publicConfig.fuel;
391
- var match$2 = publicConfig.svm;
392
- var match$3 = match !== undefined ? (
393
- match$1 !== undefined || match$2 !== undefined ? Js_exn.raiseError("Invalid indexer config: Multiple ecosystems are not supported for a single indexer") : [
394
- Caml_option.valFromOption(match).chains,
353
+ let match = publicConfig.evm;
354
+ let match$1 = publicConfig.fuel;
355
+ let match$2 = publicConfig.svm;
356
+ let match$3 = match !== undefined ? (
357
+ match$1 !== undefined || match$2 !== undefined ? Stdlib_JsError.throwWithMessage("Invalid indexer config: Multiple ecosystems are not supported for a single indexer") : [
358
+ Primitive_option.valFromOption(match).chains,
395
359
  "evm"
396
360
  ]
397
361
  ) : (
398
362
  match$1 !== undefined ? (
399
- match$2 !== undefined ? Js_exn.raiseError("Invalid indexer config: Multiple ecosystems are not supported for a single indexer") : [
400
- Caml_option.valFromOption(match$1).chains,
363
+ match$2 !== undefined ? Stdlib_JsError.throwWithMessage("Invalid indexer config: Multiple ecosystems are not supported for a single indexer") : [
364
+ Primitive_option.valFromOption(match$1).chains,
401
365
  "fuel"
402
366
  ]
403
367
  ) : (
404
368
  match$2 !== undefined ? [
405
- Caml_option.valFromOption(match$2).chains,
369
+ Primitive_option.valFromOption(match$2).chains,
406
370
  "svm"
407
- ] : Js_exn.raiseError("Invalid indexer config: No ecosystem configured (evm, fuel, or svm)")
371
+ ] : Stdlib_JsError.throwWithMessage("Invalid indexer config: No ecosystem configured (evm, fuel, or svm)")
408
372
  )
409
373
  );
410
- var ecosystemName = match$3[1];
411
- var publicChainsConfig = match$3[0];
412
- var evm = publicConfig.evm;
413
- var lowercaseAddresses = evm !== undefined ? Belt_Option.getWithDefault(Caml_option.valFromOption(evm).addressFormat, "checksum") === "lowercase" : false;
414
- var match$4 = publicConfig.evm;
415
- var match$5 = publicConfig.fuel;
416
- var publicContractsConfig;
374
+ let ecosystemName = match$3[1];
375
+ let publicChainsConfig = match$3[0];
376
+ let ecosystem;
417
377
  switch (ecosystemName) {
418
378
  case "evm" :
419
- publicContractsConfig = match$4 !== undefined ? Caml_option.valFromOption(match$4).contracts : undefined;
420
- break;
379
+ ecosystem = Evm.ecosystem;
380
+ break;
421
381
  case "fuel" :
422
- publicContractsConfig = match$5 !== undefined ? Caml_option.valFromOption(match$5).contracts : undefined;
423
- break;
382
+ ecosystem = Fuel.ecosystem;
383
+ break;
424
384
  case "svm" :
425
- publicContractsConfig = undefined;
426
- break;
427
-
385
+ ecosystem = Svm.ecosystem;
386
+ break;
428
387
  }
429
- var evm$1 = publicConfig.evm;
430
- var match$6;
388
+ let evm = publicConfig.evm;
389
+ let lowercaseAddresses = evm !== undefined ? Stdlib_Option.getOr(Primitive_option.valFromOption(evm).addressFormat, "checksum") === "lowercase" : false;
390
+ let match$4 = publicConfig.evm;
391
+ let match$5 = publicConfig.fuel;
392
+ let publicContractsConfig;
393
+ switch (ecosystemName) {
394
+ case "evm" :
395
+ publicContractsConfig = match$4 !== undefined ? Primitive_option.valFromOption(match$4).contracts : undefined;
396
+ break;
397
+ case "fuel" :
398
+ publicContractsConfig = match$5 !== undefined ? Primitive_option.valFromOption(match$5).contracts : undefined;
399
+ break;
400
+ case "svm" :
401
+ publicContractsConfig = undefined;
402
+ break;
403
+ }
404
+ let evm$1 = publicConfig.evm;
405
+ let match$6;
431
406
  if (evm$1 !== undefined) {
432
- var evm$2 = Caml_option.valFromOption(evm$1);
407
+ let evm$2 = Primitive_option.valFromOption(evm$1);
433
408
  match$6 = [
434
- new Set(Belt_Array.concat(EventConfigBuilder.alwaysIncludedBlockFields, Belt_Option.getWithDefault(evm$2.globalBlockFields, []))),
435
- new Set(Belt_Option.getWithDefault(evm$2.globalTransactionFields, []))
409
+ new Set(EventConfigBuilder.alwaysIncludedBlockFields.concat(Stdlib_Option.getOr(evm$2.globalBlockFields, []))),
410
+ new Set(Stdlib_Option.getOr(evm$2.globalTransactionFields, []))
436
411
  ];
437
412
  } else {
438
413
  match$6 = [
@@ -440,260 +415,232 @@ function fromPublic(publicConfigJson, maxAddrInPartitionOpt) {
440
415
  new Set()
441
416
  ];
442
417
  }
443
- var globalTransactionFieldsSet = match$6[1];
444
- var globalBlockFieldsSet = match$6[0];
445
- var contractDataByName = {};
418
+ let globalTransactionFieldsSet = match$6[1];
419
+ let globalBlockFieldsSet = match$6[0];
420
+ let contractDataByName = {};
446
421
  if (publicContractsConfig !== undefined) {
447
- Belt_Array.forEach(Js_dict.entries(publicContractsConfig), (function (param) {
448
- var contractConfig = param[1];
449
- var capitalizedName = Utils.$$String.capitalize(param[0]);
450
- var abi = contractConfig.abi;
451
- var events = contractConfig.events;
452
- var eventSignatures = events !== undefined ? Belt_Array.map(events, (function (eventItem) {
453
- return eventItem.event;
454
- })) : [];
455
- contractDataByName[capitalizedName] = {
456
- abi: abi,
457
- eventSignatures: eventSignatures,
458
- events: contractConfig.events
459
- };
460
- }));
422
+ Object.entries(publicContractsConfig).forEach(param => {
423
+ let contractConfig = param[1];
424
+ let capitalizedName = Utils.$$String.capitalize(param[0]);
425
+ let abi = contractConfig.abi;
426
+ let events = contractConfig.events;
427
+ let eventSignatures = events !== undefined ? events.map(eventItem => eventItem.event) : [];
428
+ contractDataByName[capitalizedName] = {
429
+ abi: abi,
430
+ eventSignatures: eventSignatures,
431
+ events: contractConfig.events
432
+ };
433
+ });
461
434
  }
462
- var buildContractEvents = function (contractName, events, abi) {
435
+ let buildContractEvents = (contractName, events, abi, chainId, startBlock) => {
463
436
  if (events !== undefined) {
464
- return Belt_Array.map(events, (function (eventItem) {
465
- var eventName = eventItem.name;
466
- var sighash = eventItem.sighash;
467
- var params = Belt_Option.getWithDefault(eventItem.params, []);
468
- var kind = eventItem.kind;
469
- var isWildcard = HandlerRegister.isWildcard(contractName, eventName);
470
- var handler = HandlerRegister.getHandler(contractName, eventName);
471
- var contractRegister = HandlerRegister.getContractRegister(contractName, eventName);
472
- switch (ecosystemName) {
473
- case "fuel" :
474
- if (kind !== undefined) {
475
- return EventConfigBuilder.buildFuelEventConfig(contractName, eventName, kind, sighash, abi, isWildcard, handler, contractRegister);
476
- } else {
477
- return Js_exn.raiseError("Fuel event " + contractName + "." + eventName + " is missing \"kind\" in internal config");
478
- }
479
- case "evm" :
480
- case "svm" :
481
- break;
482
-
483
- }
484
- return EventConfigBuilder.buildEvmEventConfig(contractName, eventName, sighash, params, isWildcard, handler, contractRegister, HandlerRegister.getEventFilters(contractName, eventName), eventItem.blockFields, eventItem.transactionFields, Caml_option.some(globalBlockFieldsSet), Caml_option.some(globalTransactionFieldsSet));
485
- }));
437
+ return events.map(eventItem => {
438
+ let eventName = eventItem.name;
439
+ let sighash = eventItem.sighash;
440
+ let params = Stdlib_Option.getOr(eventItem.params, []);
441
+ let kind = eventItem.kind;
442
+ switch (ecosystemName) {
443
+ case "fuel" :
444
+ if (kind !== undefined) {
445
+ return EventConfigBuilder.buildFuelEventConfig(contractName, eventName, kind, sighash, abi, false, undefined, undefined, startBlock);
446
+ } else {
447
+ return Stdlib_JsError.throwWithMessage(`Fuel event ` + contractName + `.` + eventName + ` is missing "kind" in internal config`);
448
+ }
449
+ case "evm" :
450
+ case "svm" :
451
+ break;
452
+ }
453
+ return EventConfigBuilder.buildEvmEventConfig(contractName, eventName, sighash, params, false, undefined, undefined, undefined, chainId, ecosystem.onEventBlockFilterSchema, eventItem.blockFields, eventItem.transactionFields, startBlock, Primitive_option.some(globalBlockFieldsSet), Primitive_option.some(globalTransactionFieldsSet));
454
+ });
486
455
  } else {
487
456
  return [];
488
457
  }
489
458
  };
490
- var parseAddress = function (addressString) {
459
+ let parseAddress = addressString => {
491
460
  switch (ecosystemName) {
492
461
  case "evm" :
493
- if (lowercaseAddresses) {
494
- return Address.Evm.fromStringLowercaseOrThrow(addressString);
495
- } else {
496
- return Address.Evm.fromStringOrThrow(addressString);
497
- }
462
+ if (lowercaseAddresses) {
463
+ return Address.Evm.fromStringLowercaseOrThrow(addressString);
464
+ } else {
465
+ return Address.Evm.fromStringOrThrow(addressString);
466
+ }
498
467
  case "fuel" :
499
468
  case "svm" :
500
- return addressString;
501
-
469
+ return addressString;
502
470
  }
503
471
  };
504
- var parseRpcSourceFor = function (sourceFor) {
472
+ let parseRpcSourceFor = sourceFor => {
505
473
  switch (sourceFor) {
506
474
  case "sync" :
507
- return "Sync";
475
+ return "Sync";
508
476
  case "fallback" :
509
- return "Fallback";
477
+ return "Fallback";
510
478
  case "live" :
511
- return "Live";
512
-
479
+ return "Live";
513
480
  }
514
481
  };
515
- var chains = Object.keys(publicChainsConfig).map(function (chainName) {
516
- var publicChainConfig = publicChainsConfig[chainName];
517
- var chainId = publicChainConfig.id;
518
- var chainContracts = Belt_Option.getWithDefault(publicChainConfig.contracts, {});
519
- var contracts = Belt_Array.map(Js_dict.entries(contractDataByName), (function (param) {
520
- var contractData = param[1];
521
- var capitalizedName = param[0];
522
- var chainContract = Js_dict.get(chainContracts, capitalizedName);
523
- var addresses = Belt_Array.map(Belt_Option.getWithDefault(Belt_Option.flatMap(chainContract, (function (cc) {
524
- return cc.addresses;
525
- })), []), parseAddress);
526
- var startBlock = Belt_Option.flatMap(chainContract, (function (cc) {
527
- return cc.startBlock;
528
- }));
529
- var events = buildContractEvents(capitalizedName, contractData.events, contractData.abi);
530
- return {
531
- name: capitalizedName,
532
- abi: contractData.abi,
533
- addresses: addresses,
534
- events: events,
535
- startBlock: startBlock,
536
- eventSignatures: contractData.eventSignatures
537
- };
538
- }));
539
- var sourceConfig;
540
- switch (ecosystemName) {
541
- case "evm" :
542
- var rpcs = Belt_Array.map(Belt_Option.getWithDefault(publicChainConfig.rpcs, []), (function (rpcConfig) {
543
- var initialBlockInterval = rpcConfig.initialBlockInterval;
544
- var backoffMultiplicative = rpcConfig.backoffMultiplicative;
545
- var accelerationAdditive = rpcConfig.accelerationAdditive;
546
- var intervalCeiling = rpcConfig.intervalCeiling;
547
- var backoffMillis = rpcConfig.backoffMillis;
548
- var queryTimeoutMillis = rpcConfig.queryTimeoutMillis;
549
- var fallbackStallTimeout = rpcConfig.fallbackStallTimeout;
550
- var pollingInterval = rpcConfig.pollingInterval;
551
- var hasSyncConfig = Belt_Option.isSome(initialBlockInterval) || Belt_Option.isSome(backoffMultiplicative) || Belt_Option.isSome(accelerationAdditive) || Belt_Option.isSome(intervalCeiling) || Belt_Option.isSome(backoffMillis) || Belt_Option.isSome(queryTimeoutMillis) || Belt_Option.isSome(fallbackStallTimeout) || Belt_Option.isSome(pollingInterval);
552
- var syncConfig = hasSyncConfig ? ({
553
- initialBlockInterval: initialBlockInterval,
554
- backoffMultiplicative: backoffMultiplicative,
555
- accelerationAdditive: accelerationAdditive,
556
- intervalCeiling: intervalCeiling,
557
- backoffMillis: backoffMillis,
558
- queryTimeoutMillis: queryTimeoutMillis,
559
- fallbackStallTimeout: fallbackStallTimeout,
560
- pollingInterval: pollingInterval
561
- }) : undefined;
562
- return {
563
- url: rpcConfig.url,
564
- sourceFor: parseRpcSourceFor(rpcConfig.for),
565
- syncConfig: syncConfig,
566
- ws: rpcConfig.ws
567
- };
568
- }));
569
- sourceConfig = {
570
- TAG: "EvmSourceConfig",
571
- hypersync: publicChainConfig.hypersync,
572
- rpcs: rpcs
573
- };
574
- break;
575
- case "fuel" :
576
- var hypersync = publicChainConfig.hypersync;
577
- sourceConfig = hypersync !== undefined ? ({
578
- TAG: "FuelSourceConfig",
579
- hypersync: hypersync
580
- }) : Js_exn.raiseError("Chain " + chainName + " is missing hypersync endpoint in config");
581
- break;
582
- case "svm" :
583
- var rpc = publicChainConfig.rpc;
584
- sourceConfig = rpc !== undefined ? ({
585
- TAG: "SvmSourceConfig",
586
- rpc: rpc
587
- }) : Js_exn.raiseError("Chain " + chainName + " is missing rpc endpoint in config");
588
- break;
589
-
590
- }
591
- var tmp;
592
- switch (ecosystemName) {
593
- case "evm" :
594
- tmp = Belt_Option.getWithDefault(publicChainConfig.maxReorgDepth, 200);
595
- break;
596
- case "fuel" :
597
- case "svm" :
598
- tmp = 0;
599
- break;
600
-
601
- }
602
- return {
603
- name: chainName,
604
- id: chainId,
605
- startBlock: publicChainConfig.startBlock,
606
- endBlock: publicChainConfig.endBlock,
607
- maxReorgDepth: tmp,
608
- blockLag: Belt_Option.getWithDefault(publicChainConfig.blockLag, 0),
609
- contracts: contracts,
610
- sourceConfig: sourceConfig
611
- };
612
- });
613
- var chainMap = ChainMap.fromArrayUnsafe(chains.map(function (chain) {
614
- return [
615
- ChainMap.Chain.makeUnsafe(chain.id),
616
- chain
617
- ];
618
- }));
619
- var addContractNameToContractNameMapping = {};
620
- Belt_Array.forEach(chains, (function (chainConfig) {
621
- Belt_Array.forEach(chainConfig.contracts, (function (contract) {
622
- var addKey = "add" + Utils.$$String.capitalize(contract.name);
623
- addContractNameToContractNameMapping[addKey] = contract.name;
624
- }));
625
- }));
626
- var ecosystem;
627
- switch (ecosystemName) {
628
- case "evm" :
629
- ecosystem = Evm.ecosystem;
482
+ let chains = Object.keys(publicChainsConfig).map(chainName => {
483
+ let publicChainConfig = publicChainsConfig[chainName];
484
+ let chainId = publicChainConfig.id;
485
+ let chainContracts = Stdlib_Option.getOr(publicChainConfig.contracts, {});
486
+ let contracts = Object.entries(contractDataByName).map(param => {
487
+ let contractData = param[1];
488
+ let capitalizedName = param[0];
489
+ let chainContract = chainContracts[capitalizedName];
490
+ let addresses = Stdlib_Option.getOr(Stdlib_Option.flatMap(chainContract, cc => cc.addresses), []).map(parseAddress);
491
+ let startBlock = Stdlib_Option.flatMap(chainContract, cc => cc.startBlock);
492
+ let events = buildContractEvents(capitalizedName, contractData.events, contractData.abi, chainId, startBlock);
493
+ return {
494
+ name: capitalizedName,
495
+ abi: contractData.abi,
496
+ addresses: addresses,
497
+ events: events,
498
+ startBlock: startBlock,
499
+ eventSignatures: contractData.eventSignatures
500
+ };
501
+ });
502
+ let sourceConfig;
503
+ switch (ecosystemName) {
504
+ case "evm" :
505
+ let rpcs = Stdlib_Option.getOr(publicChainConfig.rpcs, []).map(rpcConfig => {
506
+ let initialBlockInterval = rpcConfig.initialBlockInterval;
507
+ let backoffMultiplicative = rpcConfig.backoffMultiplicative;
508
+ let accelerationAdditive = rpcConfig.accelerationAdditive;
509
+ let intervalCeiling = rpcConfig.intervalCeiling;
510
+ let backoffMillis = rpcConfig.backoffMillis;
511
+ let queryTimeoutMillis = rpcConfig.queryTimeoutMillis;
512
+ let fallbackStallTimeout = rpcConfig.fallbackStallTimeout;
513
+ let pollingInterval = rpcConfig.pollingInterval;
514
+ let hasSyncConfig = Stdlib_Option.isSome(initialBlockInterval) || Stdlib_Option.isSome(backoffMultiplicative) || Stdlib_Option.isSome(accelerationAdditive) || Stdlib_Option.isSome(intervalCeiling) || Stdlib_Option.isSome(backoffMillis) || Stdlib_Option.isSome(queryTimeoutMillis) || Stdlib_Option.isSome(fallbackStallTimeout) || Stdlib_Option.isSome(pollingInterval);
515
+ let syncConfig = hasSyncConfig ? ({
516
+ initialBlockInterval: initialBlockInterval,
517
+ backoffMultiplicative: backoffMultiplicative,
518
+ accelerationAdditive: accelerationAdditive,
519
+ intervalCeiling: intervalCeiling,
520
+ backoffMillis: backoffMillis,
521
+ queryTimeoutMillis: queryTimeoutMillis,
522
+ fallbackStallTimeout: fallbackStallTimeout,
523
+ pollingInterval: pollingInterval
524
+ }) : undefined;
525
+ return {
526
+ url: rpcConfig.url,
527
+ sourceFor: parseRpcSourceFor(rpcConfig.for),
528
+ syncConfig: syncConfig,
529
+ ws: rpcConfig.ws
530
+ };
531
+ });
532
+ sourceConfig = {
533
+ TAG: "EvmSourceConfig",
534
+ hypersync: publicChainConfig.hypersync,
535
+ rpcs: rpcs
536
+ };
630
537
  break;
631
- case "fuel" :
632
- ecosystem = Fuel.ecosystem;
538
+ case "fuel" :
539
+ let hypersync = publicChainConfig.hypersync;
540
+ sourceConfig = hypersync !== undefined ? ({
541
+ TAG: "FuelSourceConfig",
542
+ hypersync: hypersync
543
+ }) : Stdlib_JsError.throwWithMessage(`Chain ` + chainName + ` is missing hypersync endpoint in config`);
633
544
  break;
634
- case "svm" :
635
- ecosystem = Svm.ecosystem;
545
+ case "svm" :
546
+ let rpc = publicChainConfig.rpc;
547
+ sourceConfig = rpc !== undefined ? ({
548
+ TAG: "SvmSourceConfig",
549
+ rpc: rpc
550
+ }) : Stdlib_JsError.throwWithMessage(`Chain ` + chainName + ` is missing rpc endpoint in config`);
636
551
  break;
637
-
638
- }
639
- var allEnums = parseEnumsFromJson(Belt_Option.getWithDefault(publicConfig.enums, {}));
640
- var enumConfigsByName = Js_dict.fromArray(allEnums.map(function (enumConfig) {
641
- return [
642
- enumConfig.name,
643
- enumConfig
644
- ];
645
- }));
646
- var userEntities = parseEntitiesFromJson(Belt_Option.getWithDefault(publicConfig.entities, []), enumConfigsByName);
647
- var allEntities = userEntities.concat([entityConfig]);
648
- var userEntitiesByName = Js_dict.fromArray(userEntities.map(function (entityConfig) {
649
- return [
650
- entityConfig.name,
651
- entityConfig
652
- ];
653
- }));
654
- var contractHandlers = publicContractsConfig !== undefined ? Js_dict.entries(publicContractsConfig).map(function (param) {
655
- return {
656
- name: Utils.$$String.capitalize(param[0]),
657
- handler: param[1].handler
658
- };
659
- }) : [];
552
+ }
553
+ let tmp;
554
+ switch (ecosystemName) {
555
+ case "evm" :
556
+ tmp = Stdlib_Option.getOr(publicChainConfig.maxReorgDepth, 200);
557
+ break;
558
+ case "fuel" :
559
+ case "svm" :
560
+ tmp = 0;
561
+ break;
562
+ }
563
+ return {
564
+ name: chainName,
565
+ id: chainId,
566
+ startBlock: publicChainConfig.startBlock,
567
+ endBlock: publicChainConfig.endBlock,
568
+ maxReorgDepth: tmp,
569
+ blockLag: Stdlib_Option.getOr(publicChainConfig.blockLag, 0),
570
+ contracts: contracts,
571
+ sourceConfig: sourceConfig
572
+ };
573
+ });
574
+ let chainMap = ChainMap.fromArrayUnsafe(chains.map(chain => [
575
+ ChainMap.Chain.makeUnsafe(chain.id),
576
+ chain
577
+ ]));
578
+ let allEnums = parseEnumsFromJson(Stdlib_Option.getOr(publicConfig.enums, {}));
579
+ let enumConfigsByName = Object.fromEntries(allEnums.map(enumConfig => [
580
+ enumConfig.name,
581
+ enumConfig
582
+ ]));
583
+ let userEntities = parseEntitiesFromJson(Stdlib_Option.getOr(publicConfig.entities, []), enumConfigsByName);
584
+ let allEntities = userEntities.concat([entityConfig]);
585
+ let userEntitiesByName = Object.fromEntries(userEntities.map(entityConfig => [
586
+ entityConfig.name,
587
+ entityConfig
588
+ ]));
589
+ let contractHandlers = publicContractsConfig !== undefined ? Object.entries(publicContractsConfig).map(param => ({
590
+ name: Utils.$$String.capitalize(param[0]),
591
+ handler: param[1].handler
592
+ })) : [];
660
593
  return {
661
- name: publicConfig.name,
662
- description: publicConfig.description,
663
- handlers: Belt_Option.getWithDefault(publicConfig.handlers, "src/handlers"),
664
- contractHandlers: contractHandlers,
665
- shouldRollbackOnReorg: Belt_Option.getWithDefault(publicConfig.rollbackOnReorg, true),
666
- shouldSaveFullHistory: Belt_Option.getWithDefault(publicConfig.saveFullHistory, false),
667
- multichain: Belt_Option.getWithDefault(publicConfig.multichain, "unordered"),
668
- chainMap: chainMap,
669
- defaultChain: Belt_Array.get(chains, 0),
670
- ecosystem: ecosystem,
671
- enableRawEvents: Belt_Option.getWithDefault(publicConfig.rawEvents, false),
672
- maxAddrInPartition: maxAddrInPartition,
673
- batchSize: Belt_Option.getWithDefault(publicConfig.fullBatchSize, 5000),
674
- lowercaseAddresses: lowercaseAddresses,
675
- addContractNameToContractNameMapping: addContractNameToContractNameMapping,
676
- userEntitiesByName: userEntitiesByName,
677
- userEntities: userEntities,
678
- allEntities: allEntities,
679
- allEnums: allEnums
680
- };
594
+ name: publicConfig.name,
595
+ description: publicConfig.description,
596
+ handlers: Stdlib_Option.getOr(publicConfig.handlers, "src/handlers"),
597
+ contractHandlers: contractHandlers,
598
+ shouldRollbackOnReorg: Stdlib_Option.getOr(publicConfig.rollbackOnReorg, true),
599
+ shouldSaveFullHistory: Stdlib_Option.getOr(publicConfig.saveFullHistory, false),
600
+ storage: {
601
+ postgres: publicConfig.storage.postgres,
602
+ clickhouse: Stdlib_Option.getOr(publicConfig.storage.clickhouse, false)
603
+ },
604
+ multichain: Stdlib_Option.getOr(publicConfig.multichain, "unordered"),
605
+ chainMap: chainMap,
606
+ defaultChain: chains[0],
607
+ ecosystem: ecosystem,
608
+ enableRawEvents: Stdlib_Option.getOr(publicConfig.rawEvents, false),
609
+ maxAddrInPartition: Env.maxAddrInPartition,
610
+ batchSize: Stdlib_Option.getOr(publicConfig.fullBatchSize, 5000),
611
+ lowercaseAddresses: lowercaseAddresses,
612
+ userEntitiesByName: userEntitiesByName,
613
+ userEntities: userEntities,
614
+ allEntities: allEntities,
615
+ allEnums: allEnums
616
+ };
681
617
  }
682
618
 
683
- function getEventConfig(config, contractName, eventName) {
684
- return ChainMap.values(config.chainMap).reduce((function (acc, chain) {
685
- if (acc !== undefined) {
686
- return acc;
687
- } else {
688
- return Belt_Option.flatMap(Caml_option.undefined_to_opt(chain.contracts.find(function (c) {
689
- return c.name === contractName;
690
- })), (function (contract) {
691
- return Caml_option.undefined_to_opt(contract.events.find(function (e) {
692
- return e.name === eventName;
693
- }));
694
- }));
695
- }
696
- }), undefined);
619
+ function getEventConfig(config, contractName, eventName, chainId) {
620
+ let chains;
621
+ if (chainId !== undefined) {
622
+ let chain = ChainMap.Chain.makeUnsafe(chainId);
623
+ let exit = 0;
624
+ let chainConfig;
625
+ try {
626
+ chainConfig = ChainMap.get(config.chainMap, chain);
627
+ exit = 1;
628
+ } catch (exn) {
629
+ chains = Stdlib_JsError.throwWithMessage(`Chain ` + chainId.toString() + ` is not configured. Add it to config.yaml or pass a configured chain.`);
630
+ }
631
+ if (exit === 1) {
632
+ chains = [chainConfig];
633
+ }
634
+ } else {
635
+ chains = ChainMap.values(config.chainMap);
636
+ }
637
+ return Stdlib_Array.reduce(chains, undefined, (acc, chain) => {
638
+ if (acc !== undefined) {
639
+ return acc;
640
+ } else {
641
+ return Belt_Option.flatMap(chain.contracts.find(c => c.name === contractName), contract => contract.events.find(e => e.name === eventName));
642
+ }
643
+ });
697
644
  }
698
645
 
699
646
  function shouldSaveHistory(config, isInReorgThreshold) {
@@ -715,37 +662,64 @@ function shouldPruneHistory(config, isInReorgThreshold) {
715
662
  }
716
663
 
717
664
  function getChain(config, chainId) {
718
- var chain = ChainMap.Chain.makeUnsafe(chainId);
665
+ let chain = ChainMap.Chain.makeUnsafe(chainId);
719
666
  if (ChainMap.has(config.chainMap, chain)) {
720
667
  return chain;
721
668
  } else {
722
- return Js_exn.raiseError("No chain with id " + ChainMap.Chain.toString(chain) + " found in config.yaml");
669
+ return Stdlib_JsError.throwWithMessage("No chain with id " + ChainMap.Chain.toString(chain) + " found in config.yaml");
670
+ }
671
+ }
672
+
673
+ let primedJson = {
674
+ contents: undefined
675
+ };
676
+
677
+ let cached = {
678
+ contents: undefined
679
+ };
680
+
681
+ function prime(json) {
682
+ primedJson.contents = json;
683
+ cached.contents = undefined;
684
+ }
685
+
686
+ function loadWithoutRegistrations() {
687
+ let c = cached.contents;
688
+ if (c !== undefined) {
689
+ return c;
723
690
  }
691
+ let json = primedJson.contents;
692
+ let c$1 = json !== undefined ? fromPublic(json) : fromPublic(JSON.parse(Core.getConfigJson(undefined, undefined)));
693
+ cached.contents = c$1;
694
+ return c$1;
724
695
  }
725
696
 
726
697
  export {
727
- DynamicContractRegistry ,
728
- rpcSourceForSchema ,
729
- rpcConfigSchema ,
730
- chainContractSchema ,
731
- publicConfigChainSchema ,
732
- contractEventItemSchema ,
733
- contractConfigSchema ,
734
- publicConfigEcosystemSchema ,
735
- publicConfigEvmSchema ,
736
- multichainSchema ,
737
- compositeIndexFieldSchema ,
738
- derivedFieldSchema ,
739
- propertySchema ,
740
- entityJsonSchema ,
741
- getFieldTypeAndSchema ,
742
- parseEnumsFromJson ,
743
- parseEntitiesFromJson ,
744
- publicConfigSchema ,
745
- fromPublic ,
746
- getEventConfig ,
747
- shouldSaveHistory ,
748
- shouldPruneHistory ,
749
- getChain ,
698
+ EnvioAddresses,
699
+ rpcSourceForSchema,
700
+ rpcConfigSchema,
701
+ chainContractSchema,
702
+ publicConfigChainSchema,
703
+ contractEventItemSchema,
704
+ contractConfigSchema,
705
+ publicConfigEcosystemSchema,
706
+ publicConfigEvmSchema,
707
+ multichainSchema,
708
+ compositeIndexFieldSchema,
709
+ derivedFieldSchema,
710
+ propertySchema,
711
+ entityJsonSchema,
712
+ getFieldTypeAndSchema,
713
+ parseEnumsFromJson,
714
+ parseEntitiesFromJson,
715
+ publicConfigStorageSchema,
716
+ publicConfigSchema,
717
+ fromPublic,
718
+ getEventConfig,
719
+ shouldSaveHistory,
720
+ shouldPruneHistory,
721
+ getChain,
722
+ prime,
723
+ loadWithoutRegistrations,
750
724
  }
751
725
  /* schema Not a pure module */