envio 3.0.0-alpha.21 → 3.0.0-alpha.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/bin.mjs +2 -48
  2. package/evm.schema.json +67 -0
  3. package/fuel.schema.json +67 -0
  4. package/index.d.ts +822 -38
  5. package/index.js +5 -3
  6. package/package.json +10 -8
  7. package/rescript.json +5 -9
  8. package/src/Address.res +4 -5
  9. package/src/Address.res.mjs +9 -12
  10. package/src/Api.res +15 -0
  11. package/src/Api.res.mjs +20 -0
  12. package/src/Batch.res +32 -34
  13. package/src/Batch.res.mjs +172 -187
  14. package/src/Bin.res +89 -0
  15. package/src/Bin.res.mjs +97 -0
  16. package/src/ChainFetcher.res +33 -57
  17. package/src/ChainFetcher.res.mjs +197 -227
  18. package/src/ChainManager.res +6 -14
  19. package/src/ChainManager.res.mjs +74 -85
  20. package/src/ChainMap.res +14 -16
  21. package/src/ChainMap.res.mjs +38 -38
  22. package/src/Config.res +193 -135
  23. package/src/Config.res.mjs +566 -592
  24. package/src/Core.res +182 -0
  25. package/src/Core.res.mjs +207 -0
  26. package/src/Ecosystem.res +25 -4
  27. package/src/Ecosystem.res.mjs +12 -13
  28. package/src/Env.res +20 -13
  29. package/src/Env.res.mjs +124 -113
  30. package/src/EnvSafe.res +269 -0
  31. package/src/EnvSafe.res.mjs +296 -0
  32. package/src/EnvSafe.resi +18 -0
  33. package/src/Envio.res +37 -26
  34. package/src/Envio.res.mjs +59 -60
  35. package/src/ErrorHandling.res +2 -2
  36. package/src/ErrorHandling.res.mjs +15 -15
  37. package/src/EventConfigBuilder.res +219 -81
  38. package/src/EventConfigBuilder.res.mjs +259 -202
  39. package/src/EventProcessing.res +27 -38
  40. package/src/EventProcessing.res.mjs +165 -183
  41. package/src/EventUtils.res +11 -11
  42. package/src/EventUtils.res.mjs +21 -22
  43. package/src/EvmTypes.res +0 -1
  44. package/src/EvmTypes.res.mjs +5 -5
  45. package/src/FetchState.res +360 -256
  46. package/src/FetchState.res.mjs +958 -914
  47. package/src/GlobalState.res +365 -351
  48. package/src/GlobalState.res.mjs +958 -992
  49. package/src/GlobalStateManager.res +1 -2
  50. package/src/GlobalStateManager.res.mjs +36 -44
  51. package/src/HandlerLoader.res +107 -23
  52. package/src/HandlerLoader.res.mjs +128 -38
  53. package/src/HandlerRegister.res +127 -103
  54. package/src/HandlerRegister.res.mjs +164 -164
  55. package/src/HandlerRegister.resi +12 -4
  56. package/src/Hasura.res +35 -22
  57. package/src/Hasura.res.mjs +158 -167
  58. package/src/InMemoryStore.res +20 -27
  59. package/src/InMemoryStore.res.mjs +64 -80
  60. package/src/InMemoryTable.res +34 -39
  61. package/src/InMemoryTable.res.mjs +165 -170
  62. package/src/Internal.res +52 -33
  63. package/src/Internal.res.mjs +84 -81
  64. package/src/LazyLoader.res.mjs +55 -61
  65. package/src/LoadLayer.res +77 -78
  66. package/src/LoadLayer.res.mjs +160 -189
  67. package/src/LoadManager.res +16 -21
  68. package/src/LoadManager.res.mjs +79 -84
  69. package/src/LogSelection.res +236 -68
  70. package/src/LogSelection.res.mjs +211 -141
  71. package/src/Logging.res +13 -9
  72. package/src/Logging.res.mjs +130 -143
  73. package/src/Main.res +428 -51
  74. package/src/Main.res.mjs +528 -271
  75. package/src/Persistence.res +77 -84
  76. package/src/Persistence.res.mjs +131 -132
  77. package/src/PgStorage.res +291 -167
  78. package/src/PgStorage.res.mjs +797 -817
  79. package/src/Prometheus.res +50 -58
  80. package/src/Prometheus.res.mjs +345 -373
  81. package/src/ReorgDetection.res +22 -24
  82. package/src/ReorgDetection.res.mjs +100 -106
  83. package/src/SafeCheckpointTracking.res +7 -7
  84. package/src/SafeCheckpointTracking.res.mjs +40 -43
  85. package/src/SimulateItems.res +41 -49
  86. package/src/SimulateItems.res.mjs +257 -272
  87. package/src/Sink.res +2 -2
  88. package/src/Sink.res.mjs +22 -26
  89. package/src/TableIndices.res +1 -2
  90. package/src/TableIndices.res.mjs +42 -48
  91. package/src/TestIndexer.res +196 -189
  92. package/src/TestIndexer.res.mjs +536 -536
  93. package/src/TestIndexerProxyStorage.res +15 -16
  94. package/src/TestIndexerProxyStorage.res.mjs +98 -122
  95. package/src/TestIndexerWorker.res +4 -0
  96. package/src/TestIndexerWorker.res.mjs +7 -0
  97. package/src/Throttler.res +3 -3
  98. package/src/Throttler.res.mjs +23 -24
  99. package/src/Time.res +1 -1
  100. package/src/Time.res.mjs +18 -21
  101. package/src/TopicFilter.res +3 -3
  102. package/src/TopicFilter.res.mjs +29 -30
  103. package/src/UserContext.res +93 -54
  104. package/src/UserContext.res.mjs +197 -182
  105. package/src/Utils.res +141 -86
  106. package/src/Utils.res.mjs +334 -295
  107. package/src/bindings/BigDecimal.res +0 -2
  108. package/src/bindings/BigDecimal.res.mjs +19 -23
  109. package/src/bindings/ClickHouse.res +28 -27
  110. package/src/bindings/ClickHouse.res.mjs +243 -240
  111. package/src/bindings/DateFns.res +11 -11
  112. package/src/bindings/DateFns.res.mjs +7 -7
  113. package/src/bindings/EventSource.res.mjs +2 -2
  114. package/src/bindings/Express.res +2 -5
  115. package/src/bindings/Hrtime.res +2 -2
  116. package/src/bindings/Hrtime.res.mjs +30 -32
  117. package/src/bindings/Lodash.res.mjs +1 -1
  118. package/src/bindings/NodeJs.res +14 -9
  119. package/src/bindings/NodeJs.res.mjs +20 -20
  120. package/src/bindings/Pino.res +8 -10
  121. package/src/bindings/Pino.res.mjs +40 -43
  122. package/src/bindings/Postgres.res +2 -5
  123. package/src/bindings/Postgres.res.mjs +9 -9
  124. package/src/bindings/PromClient.res +17 -2
  125. package/src/bindings/PromClient.res.mjs +30 -7
  126. package/src/bindings/SDSL.res.mjs +2 -2
  127. package/src/bindings/Viem.res +4 -4
  128. package/src/bindings/Viem.res.mjs +20 -22
  129. package/src/bindings/Vitest.res +1 -1
  130. package/src/bindings/Vitest.res.mjs +2 -2
  131. package/src/bindings/WebSocket.res +1 -1
  132. package/src/db/EntityHistory.res +9 -3
  133. package/src/db/EntityHistory.res.mjs +84 -59
  134. package/src/db/InternalTable.res +62 -60
  135. package/src/db/InternalTable.res.mjs +271 -203
  136. package/src/db/Schema.res +1 -2
  137. package/src/db/Schema.res.mjs +28 -32
  138. package/src/db/Table.res +28 -27
  139. package/src/db/Table.res.mjs +276 -292
  140. package/src/sources/EventRouter.res +21 -16
  141. package/src/sources/EventRouter.res.mjs +55 -57
  142. package/src/sources/Evm.res +17 -1
  143. package/src/sources/Evm.res.mjs +16 -8
  144. package/src/sources/EvmChain.res +15 -17
  145. package/src/sources/EvmChain.res.mjs +40 -42
  146. package/src/sources/Fuel.res +14 -1
  147. package/src/sources/Fuel.res.mjs +16 -8
  148. package/src/sources/FuelSDK.res +1 -1
  149. package/src/sources/FuelSDK.res.mjs +6 -8
  150. package/src/sources/HyperFuel.res +8 -10
  151. package/src/sources/HyperFuel.res.mjs +113 -123
  152. package/src/sources/HyperFuelClient.res.mjs +6 -7
  153. package/src/sources/HyperFuelSource.res +19 -20
  154. package/src/sources/HyperFuelSource.res.mjs +339 -356
  155. package/src/sources/HyperSync.res +11 -13
  156. package/src/sources/HyperSync.res.mjs +206 -220
  157. package/src/sources/HyperSyncClient.res +5 -7
  158. package/src/sources/HyperSyncClient.res.mjs +70 -75
  159. package/src/sources/HyperSyncHeightStream.res +8 -9
  160. package/src/sources/HyperSyncHeightStream.res.mjs +78 -86
  161. package/src/sources/HyperSyncJsonApi.res +18 -15
  162. package/src/sources/HyperSyncJsonApi.res.mjs +201 -231
  163. package/src/sources/HyperSyncSource.res +17 -21
  164. package/src/sources/HyperSyncSource.res.mjs +268 -290
  165. package/src/sources/Rpc.res +5 -5
  166. package/src/sources/Rpc.res.mjs +168 -192
  167. package/src/sources/RpcSource.res +166 -167
  168. package/src/sources/RpcSource.res.mjs +972 -1046
  169. package/src/sources/RpcWebSocketHeightStream.res +10 -11
  170. package/src/sources/RpcWebSocketHeightStream.res.mjs +131 -145
  171. package/src/sources/SimulateSource.res +1 -1
  172. package/src/sources/SimulateSource.res.mjs +35 -38
  173. package/src/sources/Source.res +1 -1
  174. package/src/sources/Source.res.mjs +3 -3
  175. package/src/sources/SourceManager.res +39 -20
  176. package/src/sources/SourceManager.res.mjs +340 -371
  177. package/src/sources/SourceManager.resi +2 -1
  178. package/src/sources/Svm.res +12 -5
  179. package/src/sources/Svm.res.mjs +44 -41
  180. package/src/tui/Tui.res +23 -12
  181. package/src/tui/Tui.res.mjs +292 -290
  182. package/src/tui/bindings/Ink.res +2 -4
  183. package/src/tui/bindings/Ink.res.mjs +35 -41
  184. package/src/tui/components/BufferedProgressBar.res +7 -7
  185. package/src/tui/components/BufferedProgressBar.res.mjs +46 -46
  186. package/src/tui/components/CustomHooks.res +1 -2
  187. package/src/tui/components/CustomHooks.res.mjs +102 -122
  188. package/src/tui/components/Messages.res +1 -2
  189. package/src/tui/components/Messages.res.mjs +38 -42
  190. package/src/tui/components/SyncETA.res +10 -11
  191. package/src/tui/components/SyncETA.res.mjs +178 -196
  192. package/src/tui/components/TuiData.res +1 -1
  193. package/src/tui/components/TuiData.res.mjs +7 -6
  194. package/src/vendored/Rest.res +52 -66
  195. package/src/vendored/Rest.res.mjs +324 -364
  196. package/svm.schema.json +67 -0
  197. package/src/Address.gen.ts +0 -8
  198. package/src/Config.gen.ts +0 -19
  199. package/src/Envio.gen.ts +0 -55
  200. package/src/EvmTypes.gen.ts +0 -6
  201. package/src/InMemoryStore.gen.ts +0 -6
  202. package/src/Internal.gen.ts +0 -64
  203. package/src/PgStorage.gen.ts +0 -10
  204. package/src/PgStorage.res.d.mts +0 -5
  205. package/src/Types.ts +0 -56
  206. package/src/bindings/BigDecimal.gen.ts +0 -14
  207. package/src/bindings/BigDecimal.res.d.mts +0 -5
  208. package/src/bindings/BigInt.gen.ts +0 -10
  209. package/src/bindings/BigInt.res +0 -70
  210. package/src/bindings/BigInt.res.d.mts +0 -5
  211. package/src/bindings/BigInt.res.mjs +0 -154
  212. package/src/bindings/Ethers.res.d.mts +0 -5
  213. package/src/bindings/Pino.gen.ts +0 -17
  214. package/src/bindings/Postgres.gen.ts +0 -8
  215. package/src/bindings/Postgres.res.d.mts +0 -5
  216. package/src/bindings/Promise.res +0 -67
  217. package/src/bindings/Promise.res.mjs +0 -26
  218. package/src/db/InternalTable.gen.ts +0 -36
  219. package/src/sources/HyperSyncClient.gen.ts +0 -19
@@ -1,68 +1,67 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
3
  import * as Utils from "./Utils.res.mjs";
4
- import * as Js_exn from "rescript/lib/es6/js_exn.js";
5
- import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
6
- import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
7
- import * as Caml_option from "rescript/lib/es6/caml_option.js";
8
- import * as Caml_exceptions from "rescript/lib/es6/caml_exceptions.js";
4
+ import * as Belt_Array from "@rescript/runtime/lib/es6/Belt_Array.js";
5
+ import * as Belt_Option from "@rescript/runtime/lib/es6/Belt_Option.js";
6
+ import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
7
+ import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
8
+ import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
9
+ import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
9
10
 
10
- var MissingRequiredTopic0 = /* @__PURE__ */Caml_exceptions.create("LogSelection.MissingRequiredTopic0");
11
+ let MissingRequiredTopic0 = /* @__PURE__ */Primitive_exceptions.create("LogSelection.MissingRequiredTopic0");
11
12
 
12
13
  function makeTopicSelection(topic0, topic1Opt, topic2Opt, topic3Opt) {
13
- var topic1 = topic1Opt !== undefined ? topic1Opt : [];
14
- var topic2 = topic2Opt !== undefined ? topic2Opt : [];
15
- var topic3 = topic3Opt !== undefined ? topic3Opt : [];
14
+ let topic1 = topic1Opt !== undefined ? topic1Opt : [];
15
+ let topic2 = topic2Opt !== undefined ? topic2Opt : [];
16
+ let topic3 = topic3Opt !== undefined ? topic3Opt : [];
16
17
  if (Utils.$$Array.isEmpty(topic0)) {
17
18
  return {
18
- TAG: "Error",
19
- _0: {
20
- RE_EXN_ID: MissingRequiredTopic0
21
- }
22
- };
19
+ TAG: "Error",
20
+ _0: {
21
+ RE_EXN_ID: MissingRequiredTopic0
22
+ }
23
+ };
23
24
  } else {
24
25
  return {
25
- TAG: "Ok",
26
- _0: {
27
- topic0: topic0,
28
- topic1: topic1,
29
- topic2: topic2,
30
- topic3: topic3
31
- }
32
- };
26
+ TAG: "Ok",
27
+ _0: {
28
+ topic0: topic0,
29
+ topic1: topic1,
30
+ topic2: topic2,
31
+ topic3: topic3
32
+ }
33
+ };
33
34
  }
34
35
  }
35
36
 
36
37
  function hasFilters(param) {
37
- return Belt_Option.isSome(Caml_option.undefined_to_opt([
38
- param.topic1,
39
- param.topic2,
40
- param.topic3
41
- ].find(function (topic) {
42
- return !Utils.$$Array.isEmpty(topic);
43
- })));
38
+ return Belt_Option.isSome([
39
+ param.topic1,
40
+ param.topic2,
41
+ param.topic3
42
+ ].find(topic => !Utils.$$Array.isEmpty(topic)));
44
43
  }
45
44
 
46
45
  function compressTopicSelections(topicSelections) {
47
- var topic0sOfSelectionsWithoutFilters = [];
48
- var selectionsWithFilters = [];
49
- Belt_Array.forEach(topicSelections, (function (selection) {
50
- if (hasFilters(selection)) {
51
- selectionsWithFilters.push(selection);
52
- return ;
53
- } else {
54
- return Belt_Array.forEach(selection.topic0, (function (topic0) {
55
- topic0sOfSelectionsWithoutFilters.push(topic0);
56
- }));
57
- }
58
- }));
46
+ let topic0sOfSelectionsWithoutFilters = [];
47
+ let selectionsWithFilters = [];
48
+ Belt_Array.forEach(topicSelections, selection => {
49
+ if (hasFilters(selection)) {
50
+ selectionsWithFilters.push(selection);
51
+ return;
52
+ } else {
53
+ return Belt_Array.forEach(selection.topic0, topic0 => {
54
+ topic0sOfSelectionsWithoutFilters.push(topic0);
55
+ });
56
+ }
57
+ });
59
58
  if (topic0sOfSelectionsWithoutFilters.length === 0) {
60
59
  return selectionsWithFilters;
61
60
  }
62
- var selectionWithoutFilters_topic1 = [];
63
- var selectionWithoutFilters_topic2 = [];
64
- var selectionWithoutFilters_topic3 = [];
65
- var selectionWithoutFilters = {
61
+ let selectionWithoutFilters_topic1 = [];
62
+ let selectionWithoutFilters_topic2 = [];
63
+ let selectionWithoutFilters_topic3 = [];
64
+ let selectionWithoutFilters = {
66
65
  topic0: topic0sOfSelectionsWithoutFilters,
67
66
  topic1: selectionWithoutFilters_topic1,
68
67
  topic2: selectionWithoutFilters_topic2,
@@ -72,139 +71,210 @@ function compressTopicSelections(topicSelections) {
72
71
  }
73
72
 
74
73
  function make(addresses, topicSelections) {
75
- var topicSelections$1 = compressTopicSelections(topicSelections);
74
+ let topicSelections$1 = compressTopicSelections(topicSelections);
76
75
  return {
77
- addresses: addresses,
78
- topicSelections: topicSelections$1
79
- };
76
+ addresses: addresses,
77
+ topicSelections: topicSelections$1
78
+ };
79
+ }
80
+
81
+ let eventBlockRangeSchema = S$RescriptSchema.strict(S$RescriptSchema.object(s => ({
82
+ _gte: s.f("_gte", S$RescriptSchema.option(S$RescriptSchema.int))
83
+ })));
84
+
85
+ function extractStartBlock(where, onEventBlockFilterSchema, contractName) {
86
+ if (typeof where === "boolean") {
87
+ return;
88
+ }
89
+ try {
90
+ let inner = S$RescriptSchema.parseOrThrow(where, onEventBlockFilterSchema);
91
+ if (inner !== undefined) {
92
+ return S$RescriptSchema.parseOrThrow(Primitive_option.valFromOption(inner), eventBlockRangeSchema)._gte;
93
+ } else {
94
+ return;
95
+ }
96
+ } catch (raw_exn) {
97
+ let exn = Primitive_exceptions.internalToException(raw_exn);
98
+ if (exn.RE_EXN_ID === S$RescriptSchema.Raised) {
99
+ return Stdlib_JsError.throwWithMessage(`Invalid where configuration for ` + contractName + `. \`block\` filter is invalid: ` + Utils.prettifyExn(exn._1) + `. Only \`_gte\` is supported on event filters — use \`indexer.onBlock\` for \`_lte\` or \`_every\`.`);
100
+ }
101
+ throw exn;
102
+ }
103
+ }
104
+
105
+ function makeChainArg(contractName, chainId, addresses) {
106
+ let chainObj = {};
107
+ chainObj["id"] = chainId;
108
+ chainObj[contractName] = {
109
+ addresses: addresses
110
+ };
111
+ return chainObj;
112
+ }
113
+
114
+ function makeDetectionChainArg(contractName, chainId, getAddresses) {
115
+ let contractObj = Object.create(null);
116
+ Object.defineProperty(contractObj, "addresses", {
117
+ enumerable: true,
118
+ get: getAddresses
119
+ });
120
+ let chainObj = {};
121
+ chainObj["id"] = chainId;
122
+ chainObj[contractName] = contractObj;
123
+ return chainObj;
80
124
  }
81
125
 
82
- var emptyTopics = [];
126
+ let emptyTopics = [];
83
127
 
84
128
  function noopGetter(param) {
85
129
  return emptyTopics;
86
130
  }
87
131
 
88
- function parseEventFiltersOrThrow(eventFilters, sighash, params, topic1Opt, topic2Opt, topic3Opt) {
89
- var topic1 = topic1Opt !== undefined ? topic1Opt : noopGetter;
90
- var topic2 = topic2Opt !== undefined ? topic2Opt : noopGetter;
91
- var topic3 = topic3Opt !== undefined ? topic3Opt : noopGetter;
92
- var filterByAddresses = {
132
+ function parseEventFiltersOrThrow(eventFilters, sighash, params, contractName, probeChainId, onEventBlockFilterSchema, topic1Opt, topic2Opt, topic3Opt) {
133
+ let topic1 = topic1Opt !== undefined ? topic1Opt : noopGetter;
134
+ let topic2 = topic2Opt !== undefined ? topic2Opt : noopGetter;
135
+ let topic3 = topic3Opt !== undefined ? topic3Opt : noopGetter;
136
+ let filterByAddresses = {
93
137
  contents: false
94
138
  };
95
- var topic0 = [sighash];
96
- var $$default = {
139
+ let startBlock;
140
+ let topic0 = [sighash];
141
+ let $$default = {
97
142
  topic0: topic0,
98
143
  topic1: emptyTopics,
99
144
  topic2: emptyTopics,
100
145
  topic3: emptyTopics
101
146
  };
102
- var parse = function (eventFilters) {
103
- if (eventFilters === true) {
147
+ let paramsRecordToTopicSelection = paramsFilter => {
148
+ let filterKeys = Object.keys(paramsFilter);
149
+ if (filterKeys.length !== 0) {
150
+ filterKeys.forEach(key => {
151
+ if (!params.includes(key)) {
152
+ return Stdlib_JsError.throwWithMessage(`Invalid where configuration. The event doesn't have an indexed parameter "` + key + `" and can't use it for filtering`);
153
+ }
154
+ });
155
+ return {
156
+ topic0: topic0,
157
+ topic1: topic1(paramsFilter),
158
+ topic2: topic2(paramsFilter),
159
+ topic3: topic3(paramsFilter)
160
+ };
161
+ } else {
162
+ return $$default;
163
+ }
164
+ };
165
+ let acceptedWhereKeys = [
166
+ "params",
167
+ "block"
168
+ ];
169
+ let parse = where => {
170
+ if (where === true) {
104
171
  return [$$default];
105
172
  }
106
- if (eventFilters === false) {
173
+ if (where === false) {
107
174
  return [];
108
175
  }
109
- var tmp;
110
- tmp = !Array.isArray(eventFilters) && (eventFilters === null || typeof eventFilters !== "object") && typeof eventFilters !== "number" && typeof eventFilters !== "string" && typeof eventFilters !== "boolean" ? [eventFilters] : (
111
- Array.isArray(eventFilters) ? (
112
- eventFilters.length !== 0 ? eventFilters : [{}]
113
- ) : [eventFilters]
114
- );
115
- return tmp.map(function (eventFilter) {
116
- if (!Array.isArray(eventFilter) && (eventFilter === null || typeof eventFilter !== "object") && typeof eventFilter !== "number" && typeof eventFilter !== "string" && typeof eventFilter !== "boolean") {
117
- return Js_exn.raiseError("Invalid event filters configuration. Expected an object");
118
- }
119
- if (!(typeof eventFilter === "object" && !Array.isArray(eventFilter))) {
120
- return Js_exn.raiseError("Invalid event filters configuration. Expected an object");
121
- }
122
- var filterKeys = Object.keys(eventFilter);
123
- if (filterKeys.length !== 0) {
124
- filterKeys.forEach(function (key) {
125
- if (!params.includes(key)) {
126
- return Js_exn.raiseError("Invalid event filters configuration. The event doesn't have an indexed parameter \"" + key + "\" and can't use it for filtering");
127
- }
128
-
129
- });
130
- return {
131
- topic0: topic0,
132
- topic1: topic1(eventFilter),
133
- topic2: topic2(eventFilter),
134
- topic3: topic3(eventFilter)
135
- };
136
- } else {
137
- return $$default;
138
- }
139
- });
176
+ if (typeof where !== "object" || where === null || Array.isArray(where)) {
177
+ return Stdlib_JsError.throwWithMessage("Invalid where configuration. Expected an object");
178
+ }
179
+ Object.keys(where).forEach(key => {
180
+ if (!acceptedWhereKeys.includes(key)) {
181
+ return Stdlib_JsError.throwWithMessage(`Invalid where configuration. Unknown field "` + key + `". Indexed parameter filters must be nested under \`params\` and block-range filters under \`block\``);
182
+ }
183
+ });
184
+ let match = where["params"];
185
+ if (match === undefined) {
186
+ return [$$default];
187
+ }
188
+ if (Array.isArray(match)) {
189
+ if (match.length !== 0) {
190
+ return match.map(item => {
191
+ if (typeof item === "object" && item !== null && !Array.isArray(item)) {
192
+ return paramsRecordToTopicSelection(item);
193
+ } else {
194
+ return Stdlib_JsError.throwWithMessage("Invalid where configuration. Each entry in `params` must be an object");
195
+ }
196
+ });
197
+ } else {
198
+ return [$$default];
199
+ }
200
+ }
201
+ if (match === null) {
202
+ return Stdlib_JsError.throwWithMessage("Invalid where configuration. Expected `params` to be an object or an array of objects");
203
+ }
204
+ switch (typeof match) {
205
+ case "object" :
206
+ return [paramsRecordToTopicSelection(match)];
207
+ default:
208
+ return Stdlib_JsError.throwWithMessage("Invalid where configuration. Expected `params` to be an object or an array of objects");
209
+ }
140
210
  };
141
- var getEventFiltersOrThrow;
211
+ let getEventFiltersOrThrow;
142
212
  if (eventFilters !== undefined) {
143
213
  if (typeof eventFilters === "function") {
214
+ let probedResult;
144
215
  try {
145
- var args = Object.defineProperty({
146
- chainId: 0,
147
- addresses: []
148
- }, "addresses", {
149
- get: (function () {
150
- filterByAddresses.contents = true;
151
- return [];
152
- })
153
- });
154
- eventFilters(args);
216
+ let chain = makeDetectionChainArg(contractName, probeChainId, () => {
217
+ filterByAddresses.contents = true;
218
+ return [];
219
+ });
220
+ probedResult = eventFilters({
221
+ chain: chain
222
+ });
223
+ } catch (exn) {
224
+ probedResult = undefined;
155
225
  }
156
- catch (exn){
157
-
226
+ if (probedResult !== undefined) {
227
+ startBlock = extractStartBlock(probedResult, onEventBlockFilterSchema, contractName);
158
228
  }
159
- getEventFiltersOrThrow = filterByAddresses.contents ? (function (chain) {
160
- return {
161
- TAG: "Dynamic",
162
- _0: (function (addresses) {
163
- return parse(eventFilters({
164
- chainId: chain,
165
- addresses: addresses
166
- }));
167
- })
168
- };
169
- }) : (function (chain) {
170
- return {
171
- TAG: "Static",
172
- _0: parse(eventFilters({
173
- chainId: chain,
174
- addresses: []
175
- }))
176
- };
177
- });
229
+ getEventFiltersOrThrow = filterByAddresses.contents ? chain => ({
230
+ TAG: "Dynamic",
231
+ _0: addresses => {
232
+ let chainArg = makeChainArg(contractName, chain, addresses);
233
+ return parse(eventFilters({
234
+ chain: chainArg
235
+ }));
236
+ }
237
+ }) : chain => {
238
+ let chainArg = makeDetectionChainArg(contractName, chain, () => Stdlib_JsError.throwWithMessage(`Invalid where configuration. Event callback for contract "` + contractName + `" read \`chain.` + contractName + `.addresses\` at runtime but the probe didn't detect the access on chainId ` + chain.toString() + `. Move the \`chain.` + contractName + `.addresses\` read above any \`chain.id\` branching so the probe picks up the dependency and switches to the dynamic fetch path.`));
239
+ return {
240
+ TAG: "Static",
241
+ _0: parse(eventFilters({
242
+ chain: chainArg
243
+ }))
244
+ };
245
+ };
178
246
  } else {
179
- var $$static = {
247
+ startBlock = extractStartBlock(eventFilters, onEventBlockFilterSchema, contractName);
248
+ let $$static = {
180
249
  TAG: "Static",
181
250
  _0: parse(eventFilters)
182
251
  };
183
- getEventFiltersOrThrow = (function (param) {
184
- return $$static;
185
- });
252
+ getEventFiltersOrThrow = param => $$static;
186
253
  }
187
254
  } else {
188
- var $$static$1 = {
255
+ let $$static$1 = {
189
256
  TAG: "Static",
190
257
  _0: [$$default]
191
258
  };
192
- getEventFiltersOrThrow = (function (param) {
193
- return $$static$1;
194
- });
259
+ getEventFiltersOrThrow = param => $$static$1;
195
260
  }
196
261
  return {
197
- getEventFiltersOrThrow: getEventFiltersOrThrow,
198
- filterByAddresses: filterByAddresses.contents
199
- };
262
+ getEventFiltersOrThrow: getEventFiltersOrThrow,
263
+ filterByAddresses: filterByAddresses.contents,
264
+ startBlock: startBlock
265
+ };
200
266
  }
201
267
 
202
268
  export {
203
- MissingRequiredTopic0 ,
204
- makeTopicSelection ,
205
- hasFilters ,
206
- compressTopicSelections ,
207
- make ,
208
- parseEventFiltersOrThrow ,
269
+ MissingRequiredTopic0,
270
+ makeTopicSelection,
271
+ hasFilters,
272
+ compressTopicSelections,
273
+ make,
274
+ eventBlockRangeSchema,
275
+ extractStartBlock,
276
+ makeChainArg,
277
+ makeDetectionChainArg,
278
+ parseEventFiltersOrThrow,
209
279
  }
210
- /* Utils Not a pure module */
280
+ /* eventBlockRangeSchema Not a pure module */
package/src/Logging.res CHANGED
@@ -22,7 +22,7 @@ let logLevels = [
22
22
  ("warn", 40),
23
23
  ("error", 50),
24
24
  ("fatal", 60),
25
- ]->Js.Dict.fromArray
25
+ ]->Dict.fromArray
26
26
 
27
27
  %%private(let logger = ref(None))
28
28
 
@@ -39,11 +39,15 @@ let makeLogger = (~logStrategy, ~logFilePath, ~defaultFileLogLevel, ~userLogLeve
39
39
  level: defaultFileLogLevel,
40
40
  }
41
41
 
42
- let makeMultiStreamLogger =
43
- MultiStreamLogger.make(~userLogLevel, ~defaultFileLogLevel, ~customLevels=logLevels, ...)
42
+ let makeMultiStreamLogger = MultiStreamLogger.make(
43
+ ~userLogLevel,
44
+ ~defaultFileLogLevel,
45
+ ~customLevels=logLevels,
46
+ ...
47
+ )
44
48
 
45
49
  // Empty base disables pid and hostname in logs
46
- let base: Js.Json.t = %raw("{}")
50
+ let base: JSON.t = %raw("{}")
47
51
 
48
52
  switch logStrategy {
49
53
  | EcsFile =>
@@ -86,7 +90,7 @@ let setLogger = l => {
86
90
  let getLogger = () => {
87
91
  switch logger.contents {
88
92
  | Some(logger) => logger
89
- | None => Js.Exn.raiseError("Unreachable code. Logger not initialized")
93
+ | None => JsError.throwWithMessage("Unreachable code. Logger not initialized")
90
94
  }
91
95
  }
92
96
 
@@ -155,7 +159,7 @@ let getItemLogger = {
155
159
  let cacheKey = "_logger"
156
160
  (item: Internal.item) => {
157
161
  switch item
158
- ->(Utils.magic: Internal.item => Js.Dict.t<Pino.t>)
162
+ ->(Utils.magic: Internal.item => dict<Pino.t>)
159
163
  ->Utils.Dict.dangerouslyGetNonOption(cacheKey) {
160
164
  | Some(l) => l
161
165
  | None => {
@@ -178,7 +182,7 @@ let getItemLogger = {
178
182
  }->createChildParams
179
183
  },
180
184
  )
181
- item->(Utils.magic: Internal.item => Js.Dict.t<Pino.t>)->Js.Dict.set(cacheKey, l)
185
+ item->(Utils.magic: Internal.item => dict<Pino.t>)->Dict.set(cacheKey, l)
182
186
  l
183
187
  }
184
188
  }
@@ -190,8 +194,8 @@ let logForItem = (item, level: Pino.logLevel, message: string, ~params=?) => {
190
194
  (
191
195
  item
192
196
  ->getItemLogger
193
- ->(Utils.magic: Pino.t => Js.Dict.t<(option<'a>, string) => unit>)
194
- ->Js.Dict.unsafeGet((level :> string))
197
+ ->(Utils.magic: Pino.t => dict<(option<'a>, string) => unit>)
198
+ ->Dict.getUnsafe((level :> string))
195
199
  )(params, message)
196
200
  }
197
201