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,27 +1,30 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
- import * as Curry from "rescript/lib/es6/curry.js";
4
3
  import * as Utils from "./Utils.res.mjs";
5
- import * as $$BigInt from "./bindings/BigInt.res.mjs";
6
- import * as Js_exn from "rescript/lib/es6/js_exn.js";
7
4
  import * as Address from "./Address.res.mjs";
8
5
  import * as FuelSDK from "./sources/FuelSDK.res.mjs";
9
6
  import * as Internal from "./Internal.res.mjs";
10
- import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
11
- import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
12
- import * as Caml_option from "rescript/lib/es6/caml_option.js";
13
7
  import * as TopicFilter from "./TopicFilter.res.mjs";
14
8
  import * as LogSelection from "./LogSelection.res.mjs";
9
+ import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
10
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
11
+ import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
15
12
  import * as HyperSyncClient from "./sources/HyperSyncClient.res.mjs";
13
+ import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
16
14
  import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
17
15
 
18
- var eventParamSchema = S$RescriptSchema.object(function (s) {
19
- return {
20
- name: s.f("name", S$RescriptSchema.string),
21
- abiType: s.f("abiType", S$RescriptSchema.string),
22
- indexed: s.fieldOr("indexed", S$RescriptSchema.bool, false)
23
- };
24
- });
16
+ let eventParamComponentSchema = S$RescriptSchema.recursive(self => S$RescriptSchema.object(s => ({
17
+ name: s.f("name", S$RescriptSchema.string),
18
+ abiType: s.f("abiType", S$RescriptSchema.string),
19
+ components: s.f("components", S$RescriptSchema.option(S$RescriptSchema.array(self)))
20
+ })));
21
+
22
+ let eventParamSchema = S$RescriptSchema.object(s => ({
23
+ name: s.f("name", S$RescriptSchema.string),
24
+ abiType: s.f("abiType", S$RescriptSchema.string),
25
+ indexed: s.fieldOr("indexed", S$RescriptSchema.bool, false),
26
+ components: s.f("components", S$RescriptSchema.option(S$RescriptSchema.array(eventParamComponentSchema)))
27
+ }));
25
28
 
26
29
  function normalizeOrThrow(value) {
27
30
  if (Array.isArray(value)) {
@@ -32,11 +35,11 @@ function normalizeOrThrow(value) {
32
35
  }
33
36
 
34
37
  function splitTupleComponents(inner) {
35
- var components = [];
36
- var depth = 0;
37
- var start = 0;
38
- for(var i = 0 ,i_finish = inner.length; i < i_finish; ++i){
39
- var ch = inner.charAt(i);
38
+ let components = [];
39
+ let depth = 0;
40
+ let start = 0;
41
+ for (let i = 0, i_finish = inner.length; i < i_finish; ++i) {
42
+ let ch = inner.charAt(i);
40
43
  if (ch === "(") {
41
44
  depth = depth + 1 | 0;
42
45
  } else if (ch === ")") {
@@ -45,7 +48,6 @@ function splitTupleComponents(inner) {
45
48
  components.push(inner.slice(start, i));
46
49
  start = i + 1 | 0;
47
50
  }
48
-
49
51
  }
50
52
  if (start < inner.length) {
51
53
  components.push(inner.slice(start));
@@ -55,73 +57,61 @@ function splitTupleComponents(inner) {
55
57
 
56
58
  function abiTypeToSchema(abiType) {
57
59
  if (abiType.endsWith("]")) {
58
- var bracketIdx = abiType.lastIndexOf("[");
59
- var baseType = abiType.slice(0, bracketIdx);
60
+ let bracketIdx = abiType.lastIndexOf("[");
61
+ let baseType = abiType.slice(0, bracketIdx);
60
62
  return S$RescriptSchema.array(abiTypeToSchema(baseType));
61
63
  }
62
64
  if (abiType.startsWith("(") && abiType.endsWith(")")) {
63
- var inner = abiType.slice(1, abiType.length - 1 | 0);
64
- var components = splitTupleComponents(inner);
65
- var schemas = Belt_Array.map(components, (function (c) {
66
- return abiTypeToSchema(c.trim());
67
- }));
68
- return S$RescriptSchema.tuple(function (s) {
69
- return Belt_Array.mapWithIndex(schemas, (function (i, schema) {
70
- return s.item(i, schema);
71
- }));
72
- });
65
+ let inner = abiType.slice(1, abiType.length - 1 | 0);
66
+ let components = splitTupleComponents(inner);
67
+ let schemas = components.map(c => abiTypeToSchema(c.trim()));
68
+ return S$RescriptSchema.tuple(s => schemas.map((schema, i) => s.item(i, schema)));
73
69
  }
74
70
  switch (abiType) {
75
71
  case "address" :
76
- return Address.schema;
72
+ return Address.schema;
77
73
  case "bool" :
78
- return S$RescriptSchema.bool;
74
+ return S$RescriptSchema.bool;
79
75
  case "bytes" :
80
76
  case "string" :
81
- return S$RescriptSchema.string;
77
+ return S$RescriptSchema.string;
82
78
  default:
83
79
  if (abiType.startsWith("uint") || abiType.startsWith("int")) {
84
- return $$BigInt.schema;
80
+ return Utils.$$BigInt.schema;
85
81
  } else if (abiType.startsWith("bytes")) {
86
82
  return S$RescriptSchema.string;
87
83
  } else {
88
- return Js_exn.raiseError("Unsupported ABI type: " + abiType);
84
+ return Stdlib_JsError.throwWithMessage(`Unsupported ABI type: ` + abiType);
89
85
  }
90
86
  }
91
87
  }
92
88
 
93
89
  function abiTypeToSimulateSchema(abiType) {
94
90
  if (abiType.endsWith("]")) {
95
- var bracketIdx = abiType.lastIndexOf("[");
96
- var baseType = abiType.slice(0, bracketIdx);
91
+ let bracketIdx = abiType.lastIndexOf("[");
92
+ let baseType = abiType.slice(0, bracketIdx);
97
93
  return S$RescriptSchema.array(abiTypeToSimulateSchema(baseType));
98
94
  }
99
95
  if (abiType.startsWith("(") && abiType.endsWith(")")) {
100
- var inner = abiType.slice(1, abiType.length - 1 | 0);
101
- var components = splitTupleComponents(inner);
102
- var schemas = Belt_Array.map(components, (function (c) {
103
- return abiTypeToSimulateSchema(c.trim());
104
- }));
105
- return S$RescriptSchema.tuple(function (s) {
106
- return Belt_Array.mapWithIndex(schemas, (function (i, schema) {
107
- return s.item(i, schema);
108
- }));
109
- });
96
+ let inner = abiType.slice(1, abiType.length - 1 | 0);
97
+ let components = splitTupleComponents(inner);
98
+ let schemas = components.map(c => abiTypeToSimulateSchema(c.trim()));
99
+ return S$RescriptSchema.tuple(s => schemas.map((schema, i) => s.item(i, schema)));
110
100
  }
111
101
  switch (abiType) {
112
102
  case "bool" :
113
- return S$RescriptSchema.bool;
103
+ return S$RescriptSchema.bool;
114
104
  case "address" :
115
105
  case "bytes" :
116
106
  case "string" :
117
- return S$RescriptSchema.string;
107
+ return S$RescriptSchema.string;
118
108
  default:
119
109
  if (abiType.startsWith("uint") || abiType.startsWith("int")) {
120
110
  return S$RescriptSchema.bigint;
121
111
  } else if (abiType.startsWith("bytes")) {
122
112
  return S$RescriptSchema.string;
123
113
  } else {
124
- return Js_exn.raiseError("Unsupported ABI type: " + abiType);
114
+ return Stdlib_JsError.throwWithMessage(`Unsupported ABI type: ` + abiType);
125
115
  }
126
116
  }
127
117
  }
@@ -131,20 +121,18 @@ function abiTypeToDefaultValue(abiType) {
131
121
  return [];
132
122
  }
133
123
  if (abiType.startsWith("(") && abiType.endsWith(")")) {
134
- var inner = abiType.slice(1, abiType.length - 1 | 0);
135
- var components = splitTupleComponents(inner);
136
- return Belt_Array.map(components, (function (c) {
137
- return abiTypeToDefaultValue(c.trim());
138
- }));
124
+ let inner = abiType.slice(1, abiType.length - 1 | 0);
125
+ let components = splitTupleComponents(inner);
126
+ return components.map(c => abiTypeToDefaultValue(c.trim()));
139
127
  }
140
128
  switch (abiType) {
141
129
  case "address" :
142
- return "0x0000000000000000000000000000000000000000";
130
+ return "0x0000000000000000000000000000000000000000";
143
131
  case "bool" :
144
- return false;
132
+ return false;
145
133
  case "bytes" :
146
134
  case "string" :
147
- return "";
135
+ return "";
148
136
  default:
149
137
  if (abiType.startsWith("uint") || abiType.startsWith("int")) {
150
138
  return 0n;
@@ -156,60 +144,127 @@ function abiTypeToDefaultValue(abiType) {
156
144
  }
157
145
  }
158
146
 
147
+ function componentsToSimulateSchema(abiType, components) {
148
+ if (!abiType.endsWith("]")) {
149
+ return S$RescriptSchema.object(s => {
150
+ let dict = {};
151
+ components.forEach(c => {
152
+ let sub = c.components;
153
+ let childSchema = sub !== undefined ? componentsToSimulateSchema(c.abiType, sub) : abiTypeToSimulateSchema(c.abiType);
154
+ dict[c.name] = s.f(c.name, childSchema);
155
+ });
156
+ return dict;
157
+ });
158
+ }
159
+ let bracketIdx = abiType.lastIndexOf("[");
160
+ let baseType = abiType.slice(0, bracketIdx);
161
+ return S$RescriptSchema.array(componentsToSimulateSchema(baseType, components));
162
+ }
163
+
164
+ function componentsToDefaultValue(abiType, components) {
165
+ if (abiType.endsWith("]")) {
166
+ return [];
167
+ }
168
+ let dict = {};
169
+ components.forEach(c => {
170
+ let sub = c.components;
171
+ let v = sub !== undefined ? componentsToDefaultValue(c.abiType, sub) : abiTypeToDefaultValue(c.abiType);
172
+ dict[c.name] = v;
173
+ });
174
+ return dict;
175
+ }
176
+
177
+ function componentsToRemapper(abiType, components, value) {
178
+ if (abiType.endsWith("]")) {
179
+ let bracketIdx = abiType.lastIndexOf("[");
180
+ let baseType = abiType.slice(0, bracketIdx);
181
+ return value.map(item => componentsToRemapper(baseType, components, item));
182
+ }
183
+ let dict = {};
184
+ components.forEach((c, i) => {
185
+ let raw = value[i];
186
+ let sub = c.components;
187
+ let mapped = sub !== undefined ? componentsToRemapper(c.abiType, sub, raw) : raw;
188
+ dict[c.name] = mapped;
189
+ });
190
+ return dict;
191
+ }
192
+
159
193
  function buildParamsSchema(params) {
160
194
  if (params.length === 0) {
161
- return S$RescriptSchema.shape(S$RescriptSchema.literal(null), (function (param) {
162
-
163
- }));
195
+ return S$RescriptSchema.shape(S$RescriptSchema.literal(null), param => {});
164
196
  } else {
165
- return S$RescriptSchema.object(function (s) {
166
- var dict = {};
167
- Belt_Array.forEach(params, (function (p) {
168
- dict[p.name] = s.f(p.name, abiTypeToSchema(p.abiType));
169
- }));
170
- return dict;
171
- });
197
+ return S$RescriptSchema.object(s => {
198
+ let dict = {};
199
+ params.forEach(p => {
200
+ dict[p.name] = s.f(p.name, abiTypeToSchema(p.abiType));
201
+ });
202
+ return dict;
203
+ });
172
204
  }
173
205
  }
174
206
 
175
207
  function buildSimulateParamsSchema(params) {
176
208
  if (params.length === 0) {
177
- return S$RescriptSchema.shape(S$RescriptSchema.unknown, (function (param) {
178
-
179
- }));
209
+ return S$RescriptSchema.shape(S$RescriptSchema.unknown, param => {});
180
210
  } else {
181
- return S$RescriptSchema.schema(function (s) {
182
- var dict = {};
183
- Belt_Array.forEach(params, (function (p) {
184
- dict[p.name] = s.m(S$RescriptSchema.$$Option.getOr(S$RescriptSchema.$$null(abiTypeToSimulateSchema(p.abiType)), abiTypeToDefaultValue(p.abiType)));
185
- }));
186
- return dict;
187
- });
211
+ return S$RescriptSchema.schema(s => {
212
+ let dict = {};
213
+ params.forEach(p => {
214
+ let components = p.components;
215
+ let match = components !== undefined ? [
216
+ componentsToSimulateSchema(p.abiType, components),
217
+ componentsToDefaultValue(p.abiType, components)
218
+ ] : [
219
+ abiTypeToSimulateSchema(p.abiType),
220
+ abiTypeToDefaultValue(p.abiType)
221
+ ];
222
+ dict[p.name] = s.m(S$RescriptSchema.Option.getOr(S$RescriptSchema.$$null(match[0]), match[1]));
223
+ });
224
+ return dict;
225
+ });
188
226
  }
189
227
  }
190
228
 
191
229
  function buildHyperSyncDecoder(params) {
192
230
  if (params.length === 0) {
193
- return function (param) {
194
-
195
- };
231
+ return param => {};
196
232
  }
197
- var indexedParams = params.filter(function (p) {
198
- return p.indexed;
199
- });
200
- var bodyParams = params.filter(function (p) {
201
- return !p.indexed;
233
+ let indexedParams = params.filter(p => p.indexed);
234
+ let bodyParams = params.filter(p => !p.indexed);
235
+ let fields = [];
236
+ indexedParams.forEach((p, i) => {
237
+ fields.push(`"` + p.name + `": t(d.indexed[` + i.toString() + `])`);
238
+ });
239
+ bodyParams.forEach((p, i) => {
240
+ fields.push(`"` + p.name + `": t(d.body[` + i.toString() + `])`);
241
+ });
242
+ let body = `return function(d) { return {` + fields.join(", ") + `} }`;
243
+ let factory = new Function("t", body);
244
+ let baseDecode = factory(HyperSyncClient.Decoder.toUnderlying);
245
+ let paramsToRemap = params.filter(p => {
246
+ if (p.indexed) {
247
+ return false;
248
+ } else {
249
+ return Stdlib_Option.isSome(p.components);
250
+ }
251
+ });
252
+ if (paramsToRemap.length === 0) {
253
+ return baseDecode;
254
+ } else {
255
+ return decoded => {
256
+ let result = baseDecode(decoded);
257
+ paramsToRemap.forEach(p => {
258
+ let match = p.components;
259
+ let match$1 = result[p.name];
260
+ if (match !== undefined && match$1 !== undefined) {
261
+ result[p.name] = componentsToRemapper(p.abiType, match, Primitive_option.valFromOption(match$1));
262
+ return;
263
+ }
202
264
  });
203
- var fields = [];
204
- Belt_Array.forEachWithIndex(indexedParams, (function (i, p) {
205
- fields.push("\"" + p.name + "\": t(d.indexed[" + String(i) + "])");
206
- }));
207
- Belt_Array.forEachWithIndex(bodyParams, (function (i, p) {
208
- fields.push("\"" + p.name + "\": t(d.body[" + String(i) + "])");
209
- }));
210
- var body = "return function(d) { return {" + fields.join(", ") + "} }";
211
- var factory = new Function("t", body);
212
- return factory(HyperSyncClient.Decoder.toUnderlying);
265
+ return result;
266
+ };
267
+ }
213
268
  }
214
269
 
215
270
  function getTopicEncoder(abiType) {
@@ -218,13 +273,13 @@ function getTopicEncoder(abiType) {
218
273
  }
219
274
  switch (abiType) {
220
275
  case "address" :
221
- return TopicFilter.fromAddress;
276
+ return TopicFilter.fromAddress;
222
277
  case "bool" :
223
- return TopicFilter.fromBool;
278
+ return TopicFilter.fromBool;
224
279
  case "bytes" :
225
- return TopicFilter.fromDynamicBytes;
280
+ return TopicFilter.fromDynamicBytes;
226
281
  case "string" :
227
- return TopicFilter.fromDynamicString;
282
+ return TopicFilter.fromDynamicString;
228
283
  default:
229
284
  if (abiType.startsWith("uint")) {
230
285
  return TopicFilter.fromBigInt;
@@ -233,144 +288,146 @@ function getTopicEncoder(abiType) {
233
288
  } else if (abiType.startsWith("bytes")) {
234
289
  return TopicFilter.castToHexUnsafe;
235
290
  } else {
236
- return Js_exn.raiseError("Unsupported topic filter ABI type: " + abiType);
291
+ return Stdlib_JsError.throwWithMessage(`Unsupported topic filter ABI type: ` + abiType);
237
292
  }
238
293
  }
239
294
  }
240
295
 
241
296
  function buildTopicGetter(p) {
242
- var encoder = getTopicEncoder(p.abiType);
243
- return function (eventFilter) {
244
- return Belt_Option.mapWithDefault(eventFilter[p.name], [], (function (topicFilters) {
245
- return normalizeOrThrow(topicFilters).map(Curry.__1(encoder));
246
- }));
247
- };
297
+ let encoder = getTopicEncoder(p.abiType);
298
+ return eventFilter => Stdlib_Option.mapOr(eventFilter[p.name], [], topicFilters => normalizeOrThrow(topicFilters).map(encoder));
248
299
  }
249
300
 
250
- var alwaysIncludedBlockFields = [
301
+ let alwaysIncludedBlockFields = [
251
302
  "number",
252
303
  "timestamp",
253
304
  "hash"
254
305
  ];
255
306
 
256
307
  function resolveFieldSelection(blockFields, transactionFields, globalBlockFieldsSet, globalTransactionFieldsSet) {
257
- var selectedBlockFields = blockFields !== undefined ? new Set(Belt_Array.concat(alwaysIncludedBlockFields, blockFields)) : globalBlockFieldsSet;
258
- var selectedTransactionFields = transactionFields !== undefined ? new Set(transactionFields) : globalTransactionFieldsSet;
308
+ let selectedBlockFields = blockFields !== undefined ? new Set(alwaysIncludedBlockFields.concat(blockFields)) : globalBlockFieldsSet;
309
+ let selectedTransactionFields = transactionFields !== undefined ? new Set(transactionFields) : globalTransactionFieldsSet;
259
310
  return [
260
- selectedBlockFields,
261
- selectedTransactionFields
262
- ];
311
+ selectedBlockFields,
312
+ selectedTransactionFields
313
+ ];
263
314
  }
264
315
 
265
- function buildEvmEventConfig(contractName, eventName, sighash, params, isWildcard, handler, contractRegister, eventFilters, blockFields, transactionFields, globalBlockFieldsSetOpt, globalTransactionFieldsSetOpt) {
266
- var globalBlockFieldsSet = globalBlockFieldsSetOpt !== undefined ? Caml_option.valFromOption(globalBlockFieldsSetOpt) : new Set();
267
- var globalTransactionFieldsSet = globalTransactionFieldsSetOpt !== undefined ? Caml_option.valFromOption(globalTransactionFieldsSetOpt) : new Set();
268
- var topicCount = Belt_Array.reduce(params, 1, (function (acc, p) {
269
- if (p.indexed) {
270
- return acc + 1 | 0;
271
- } else {
272
- return acc;
273
- }
274
- }));
275
- var indexedParams = params.filter(function (p) {
276
- return p.indexed;
277
- });
278
- var match = LogSelection.parseEventFiltersOrThrow(eventFilters, sighash, Belt_Array.map(indexedParams, (function (p) {
279
- return p.name;
280
- })), Belt_Option.map(Belt_Array.get(indexedParams, 0), buildTopicGetter), Belt_Option.map(Belt_Array.get(indexedParams, 1), buildTopicGetter), Belt_Option.map(Belt_Array.get(indexedParams, 2), buildTopicGetter));
281
- var filterByAddresses = match.filterByAddresses;
282
- var match$1 = resolveFieldSelection(blockFields, transactionFields, globalBlockFieldsSet, globalTransactionFieldsSet);
316
+ function buildEvmEventConfig(contractName, eventName, sighash, params, isWildcard, handler, contractRegister, eventFilters, probeChainId, onEventBlockFilterSchema, blockFields, transactionFields, startBlock, globalBlockFieldsSetOpt, globalTransactionFieldsSetOpt) {
317
+ let globalBlockFieldsSet = globalBlockFieldsSetOpt !== undefined ? Primitive_option.valFromOption(globalBlockFieldsSetOpt) : new Set();
318
+ let globalTransactionFieldsSet = globalTransactionFieldsSetOpt !== undefined ? Primitive_option.valFromOption(globalTransactionFieldsSetOpt) : new Set();
319
+ let topicCount = Stdlib_Array.reduce(params, 1, (acc, p) => {
320
+ if (p.indexed) {
321
+ return acc + 1 | 0;
322
+ } else {
323
+ return acc;
324
+ }
325
+ });
326
+ let indexedParams = params.filter(p => p.indexed);
327
+ let match = LogSelection.parseEventFiltersOrThrow(eventFilters, sighash, indexedParams.map(p => p.name), contractName, probeChainId, onEventBlockFilterSchema, Stdlib_Option.map(indexedParams[0], buildTopicGetter), Stdlib_Option.map(indexedParams[1], buildTopicGetter), Stdlib_Option.map(indexedParams[2], buildTopicGetter));
328
+ let whereStartBlock = match.startBlock;
329
+ let filterByAddresses = match.filterByAddresses;
330
+ let resolvedStartBlock = whereStartBlock !== undefined ? whereStartBlock : startBlock;
331
+ let match$1 = resolveFieldSelection(blockFields, transactionFields, globalBlockFieldsSet, globalTransactionFieldsSet);
283
332
  return {
284
- id: sighash + "_" + String(topicCount),
285
- name: eventName,
286
- contractName: contractName,
287
- isWildcard: isWildcard,
288
- filterByAddresses: filterByAddresses,
289
- dependsOnAddresses: !isWildcard || filterByAddresses,
290
- handler: handler,
291
- contractRegister: contractRegister,
292
- paramsRawEventSchema: buildParamsSchema(params),
293
- simulateParamsSchema: buildSimulateParamsSchema(params),
294
- getEventFiltersOrThrow: match.getEventFiltersOrThrow,
295
- convertHyperSyncEventArgs: buildHyperSyncDecoder(params),
296
- selectedBlockFields: match$1[0],
297
- selectedTransactionFields: match$1[1]
298
- };
333
+ id: sighash + "_" + topicCount.toString(),
334
+ name: eventName,
335
+ contractName: contractName,
336
+ isWildcard: isWildcard,
337
+ filterByAddresses: filterByAddresses,
338
+ dependsOnAddresses: !isWildcard || filterByAddresses,
339
+ handler: handler,
340
+ contractRegister: contractRegister,
341
+ paramsRawEventSchema: buildParamsSchema(params),
342
+ simulateParamsSchema: buildSimulateParamsSchema(params),
343
+ startBlock: resolvedStartBlock,
344
+ getEventFiltersOrThrow: match.getEventFiltersOrThrow,
345
+ convertHyperSyncEventArgs: buildHyperSyncDecoder(params),
346
+ selectedBlockFields: match$1[0],
347
+ selectedTransactionFields: match$1[1],
348
+ sighash: sighash,
349
+ indexedParams: indexedParams
350
+ };
299
351
  }
300
352
 
301
- function buildFuelEventConfig(contractName, eventName, kind, sighash, rawAbi, isWildcard, handler, contractRegister) {
302
- var fuelKind;
353
+ function buildFuelEventConfig(contractName, eventName, kind, sighash, rawAbi, isWildcard, handler, contractRegister, startBlock) {
354
+ let fuelKind;
303
355
  switch (kind) {
304
356
  case "burn" :
305
- fuelKind = "Burn";
306
- break;
357
+ fuelKind = "Burn";
358
+ break;
307
359
  case "call" :
308
- fuelKind = "Call";
309
- break;
360
+ fuelKind = "Call";
361
+ break;
310
362
  case "logData" :
311
- var abi = FuelSDK.transpileAbi(rawAbi);
312
- fuelKind = {
313
- TAG: "LogData",
314
- logId: sighash,
315
- decode: FuelSDK.Receipt.getLogDataDecoder(abi, sighash)
316
- };
317
- break;
363
+ let abi = FuelSDK.transpileAbi(rawAbi);
364
+ fuelKind = {
365
+ TAG: "LogData",
366
+ logId: sighash,
367
+ decode: FuelSDK.Receipt.getLogDataDecoder(abi, sighash)
368
+ };
369
+ break;
318
370
  case "mint" :
319
- fuelKind = "Mint";
320
- break;
371
+ fuelKind = "Mint";
372
+ break;
321
373
  case "transfer" :
322
- fuelKind = "Transfer";
323
- break;
374
+ fuelKind = "Transfer";
375
+ break;
324
376
  default:
325
- fuelKind = Js_exn.raiseError("Unsupported Fuel event kind: " + kind);
377
+ fuelKind = Stdlib_JsError.throwWithMessage(`Unsupported Fuel event kind: ` + kind);
326
378
  }
327
- var paramsSchema;
379
+ let paramsSchema;
328
380
  switch (kind) {
329
381
  case "logData" :
330
- paramsSchema = Utils.Schema.coerceToJsonPgType(S$RescriptSchema.json(false));
331
- break;
382
+ paramsSchema = Utils.Schema.coerceToJsonPgType(S$RescriptSchema.json(false));
383
+ break;
332
384
  case "burn" :
333
385
  case "mint" :
334
- paramsSchema = Internal.fuelSupplyParamsSchema;
335
- break;
386
+ paramsSchema = Internal.fuelSupplyParamsSchema;
387
+ break;
336
388
  case "call" :
337
389
  case "transfer" :
338
- paramsSchema = Internal.fuelTransferParamsSchema;
339
- break;
390
+ paramsSchema = Internal.fuelTransferParamsSchema;
391
+ break;
340
392
  default:
341
- paramsSchema = Js_exn.raiseError("Unsupported Fuel event kind: " + kind);
393
+ paramsSchema = Stdlib_JsError.throwWithMessage(`Unsupported Fuel event kind: ` + kind);
342
394
  }
343
- var tmp = kind === "logData" ? sighash : kind;
395
+ let tmp = kind === "logData" ? sighash : kind;
344
396
  return {
345
- id: tmp,
346
- name: eventName,
347
- contractName: contractName,
348
- isWildcard: isWildcard,
349
- filterByAddresses: false,
350
- dependsOnAddresses: !isWildcard,
351
- handler: handler,
352
- contractRegister: contractRegister,
353
- paramsRawEventSchema: paramsSchema,
354
- simulateParamsSchema: paramsSchema,
355
- kind: fuelKind
356
- };
397
+ id: tmp,
398
+ name: eventName,
399
+ contractName: contractName,
400
+ isWildcard: isWildcard,
401
+ filterByAddresses: false,
402
+ dependsOnAddresses: !isWildcard,
403
+ handler: handler,
404
+ contractRegister: contractRegister,
405
+ paramsRawEventSchema: paramsSchema,
406
+ simulateParamsSchema: paramsSchema,
407
+ startBlock: startBlock,
408
+ kind: fuelKind
409
+ };
357
410
  }
358
411
 
359
412
  export {
360
- eventParamSchema ,
361
- normalizeOrThrow ,
362
- splitTupleComponents ,
363
- abiTypeToSchema ,
364
- abiTypeToSimulateSchema ,
365
- abiTypeToDefaultValue ,
366
- buildParamsSchema ,
367
- buildSimulateParamsSchema ,
368
- buildHyperSyncDecoder ,
369
- getTopicEncoder ,
370
- buildTopicGetter ,
371
- alwaysIncludedBlockFields ,
372
- resolveFieldSelection ,
373
- buildEvmEventConfig ,
374
- buildFuelEventConfig ,
413
+ eventParamComponentSchema,
414
+ eventParamSchema,
415
+ normalizeOrThrow,
416
+ splitTupleComponents,
417
+ abiTypeToSchema,
418
+ abiTypeToSimulateSchema,
419
+ abiTypeToDefaultValue,
420
+ componentsToSimulateSchema,
421
+ componentsToDefaultValue,
422
+ componentsToRemapper,
423
+ buildParamsSchema,
424
+ buildSimulateParamsSchema,
425
+ buildHyperSyncDecoder,
426
+ getTopicEncoder,
427
+ buildTopicGetter,
428
+ alwaysIncludedBlockFields,
429
+ resolveFieldSelection,
430
+ buildEvmEventConfig,
431
+ buildFuelEventConfig,
375
432
  }
376
- /* eventParamSchema Not a pure module */
433
+ /* eventParamComponentSchema Not a pure module */