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,608 +1,583 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
3
  import * as Rpc from "./Rpc.res.mjs";
4
- import * as Caml from "rescript/lib/es6/caml.js";
5
4
  import * as Rest from "../vendored/Rest.res.mjs";
6
5
  import * as Time from "../Time.res.mjs";
7
6
  import * as Utils from "../Utils.res.mjs";
8
7
  import * as Hrtime from "../bindings/Hrtime.res.mjs";
9
- import * as Js_exn from "rescript/lib/es6/js_exn.js";
10
8
  import * as Source from "./Source.res.mjs";
11
9
  import * as Address from "../Address.res.mjs";
12
10
  import * as Logging from "../Logging.res.mjs";
13
- import * as $$Promise from "../bindings/Promise.res.mjs";
14
- import * as Belt_Int from "rescript/lib/es6/belt_Int.js";
15
11
  import * as Internal from "../Internal.res.mjs";
16
- import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
12
+ import * as Belt_Array from "@rescript/runtime/lib/es6/Belt_Array.js";
17
13
  import * as FetchState from "../FetchState.res.mjs";
18
14
  import * as LazyLoader from "../LazyLoader.res.mjs";
19
15
  import * as Prometheus from "../Prometheus.res.mjs";
20
- import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
21
- import * as Caml_option from "rescript/lib/es6/caml_option.js";
16
+ import * as Stdlib_Int from "@rescript/runtime/lib/es6/Stdlib_Int.js";
17
+ import * as Belt_Option from "@rescript/runtime/lib/es6/Belt_Option.js";
22
18
  import * as EventRouter from "./EventRouter.res.mjs";
23
19
  import * as LogSelection from "../LogSelection.res.mjs";
24
- import * as Caml_exceptions from "rescript/lib/es6/caml_exceptions.js";
20
+ import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
21
+ import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.js";
22
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
23
+ import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
24
+ import * as Stdlib_Promise from "@rescript/runtime/lib/es6/Stdlib_Promise.js";
25
25
  import * as HyperSyncClient from "./HyperSyncClient.res.mjs";
26
- import * as Caml_splice_call from "rescript/lib/es6/caml_splice_call.js";
26
+ import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
27
27
  import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
28
- import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
28
+ import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
29
29
  import * as RpcWebSocketHeightStream from "./RpcWebSocketHeightStream.res.mjs";
30
30
 
31
- var QueryTimout = /* @__PURE__ */Caml_exceptions.create("RpcSource.QueryTimout");
31
+ let QueryTimout = /* @__PURE__ */Primitive_exceptions.create("RpcSource.QueryTimout");
32
32
 
33
33
  async function getKnownRawBlock(client, blockNumber) {
34
- var json = await Rpc.getRawBlock(client, blockNumber);
34
+ let json = await Rpc.getRawBlock(client, blockNumber);
35
35
  if (json !== undefined) {
36
36
  return json;
37
37
  } else {
38
- return Js_exn.raiseError("RPC returned null for blockNumber " + String(blockNumber));
38
+ return Stdlib_JsError.throwWithMessage(`RPC returned null for blockNumber ` + String(blockNumber));
39
39
  }
40
40
  }
41
41
 
42
42
  function parseBlockInfo(json) {
43
43
  return {
44
- number: S$RescriptSchema.parseOrThrow(json["number"], Rpc.hexIntSchema),
45
- timestamp: S$RescriptSchema.parseOrThrow(json["timestamp"], Rpc.hexIntSchema),
46
- hash: S$RescriptSchema.parseOrThrow(json["hash"], S$RescriptSchema.string)
47
- };
44
+ number: S$RescriptSchema.parseOrThrow(json["number"], Rpc.hexIntSchema),
45
+ timestamp: S$RescriptSchema.parseOrThrow(json["timestamp"], Rpc.hexIntSchema),
46
+ hash: S$RescriptSchema.parseOrThrow(json["hash"], S$RescriptSchema.string)
47
+ };
48
48
  }
49
49
 
50
50
  async function getKnownRawBlockWithBackoff(client, sourceName, chain, blockNumber, backoffMsOnFailure) {
51
- var currentBackoff = backoffMsOnFailure;
52
- var result;
53
- while(Belt_Option.isNone(result)) {
51
+ let currentBackoff = backoffMsOnFailure;
52
+ let result;
53
+ while (Stdlib_Option.isNone(result)) {
54
54
  Prometheus.SourceRequestCount.increment(sourceName, chain, "eth_getBlockByNumber");
55
- var exit = 0;
56
- var json;
55
+ let exit = 0;
56
+ let json;
57
57
  try {
58
58
  json = await getKnownRawBlock(client, blockNumber);
59
59
  exit = 1;
60
- }
61
- catch (raw_err){
62
- var err = Caml_js_exceptions.internalToOCamlException(raw_err);
60
+ } catch (raw_err) {
61
+ let err = Primitive_exceptions.internalToException(raw_err);
63
62
  Logging.warn({
64
- err: Utils.prettifyExn(err),
65
- msg: "Issue while running fetching batch of events from the RPC. Will wait " + String(currentBackoff) + "ms and try again.",
66
- source: sourceName,
67
- chainId: chain,
68
- type: "EXPONENTIAL_BACKOFF"
69
- });
63
+ err: Utils.prettifyExn(err),
64
+ msg: `Issue while running fetching batch of events from the RPC. Will wait ` + String(currentBackoff) + `ms and try again.`,
65
+ source: sourceName,
66
+ chainId: chain,
67
+ type: "EXPONENTIAL_BACKOFF"
68
+ });
70
69
  await Time.resolvePromiseAfterDelay(currentBackoff);
71
70
  currentBackoff = (currentBackoff << 1);
72
71
  }
73
72
  if (exit === 1) {
74
73
  result = json;
75
74
  }
76
-
77
75
  };
78
- return Belt_Option.getExn(result);
76
+ return Stdlib_Option.getOrThrow(result, undefined);
79
77
  }
80
78
 
81
- var suggestedRangeRegExp = /retry with the range (\d+)-(\d+)/;
79
+ let suggestedRangeRegExp = /retry with the range (\d+)-(\d+)/;
82
80
 
83
- var blockRangeLimitRegExp = /limited to a (\d+) blocks range/;
81
+ let blockRangeLimitRegExp = /limited to a (\d+) blocks range/;
84
82
 
85
- var alchemyRangeRegExp = /up to a (\d+) block range/;
83
+ let alchemyRangeRegExp = /up to a (\d+) block range/;
86
84
 
87
- var cloudflareRangeRegExp = /Max range: (\d+)/;
85
+ let cloudflareRangeRegExp = /Max range: (\d+)/;
88
86
 
89
- var thirdwebRangeRegExp = /Maximum allowed number of requested blocks is (\d+)/;
87
+ let thirdwebRangeRegExp = /Maximum allowed number of requested blocks is (\d+)/;
90
88
 
91
- var blockpiRangeRegExp = /limited to (\d+) block/;
89
+ let blockpiRangeRegExp = /limited to (\d+) block/;
92
90
 
93
- var baseRangeRegExp = /block range too large/;
91
+ let baseRangeRegExp = /block range too large/;
94
92
 
95
- var maxAllowedBlocksRegExp = /maximum allowed is (\d+) blocks/;
93
+ let maxAllowedBlocksRegExp = /maximum allowed is (\d+) blocks/;
96
94
 
97
- var blastPaidRegExp = /exceeds the range allowed for your plan \(\d+ > (\d+)\)/;
95
+ let blastPaidRegExp = /exceeds the range allowed for your plan \(\d+ > (\d+)\)/;
98
96
 
99
- var chainstackRegExp = /Block range limit exceeded./;
97
+ let chainstackRegExp = /Block range limit exceeded./;
100
98
 
101
- var coinbaseRegExp = /please limit the query to at most (\d+) blocks/;
99
+ let coinbaseRegExp = /please limit the query to at most (\d+) blocks/;
102
100
 
103
- var publicNodeRegExp = /maximum block range: (\d+)/;
101
+ let publicNodeRegExp = /maximum block range: (\d+)/;
104
102
 
105
- var hyperliquidRegExp = /query exceeds max block range (\d+)/;
103
+ let hyperliquidRegExp = /query exceeds max block range (\d+)/;
106
104
 
107
105
  function parseMessageForBlockRange(message) {
108
- var extractBlockRange = function (execResult, isMaxRange) {
109
- if (execResult.length !== 2) {
110
- return ;
106
+ let extractBlockRange = (execResult, isMaxRange) => {
107
+ let match = execResult.slice(1);
108
+ if (match.length !== 1) {
109
+ return;
111
110
  }
112
- var blockRangeLimit = execResult[1];
113
- if (blockRangeLimit === null || blockRangeLimit === undefined) {
114
- return ;
111
+ let blockRangeLimit = match[0];
112
+ if (blockRangeLimit === undefined) {
113
+ return;
115
114
  }
116
- var blockRangeLimit$1 = Belt_Int.fromString(blockRangeLimit);
115
+ let blockRangeLimit$1 = Stdlib_Int.fromString(blockRangeLimit, undefined);
117
116
  if (blockRangeLimit$1 !== undefined && blockRangeLimit$1 > 0) {
118
117
  return [
119
- blockRangeLimit$1,
120
- isMaxRange
121
- ];
118
+ blockRangeLimit$1,
119
+ isMaxRange
120
+ ];
122
121
  }
123
-
124
122
  };
125
- var execResult = suggestedRangeRegExp.exec(message);
126
- if (execResult !== null) {
127
- if (execResult.length !== 3) {
128
- return ;
123
+ let execResult = suggestedRangeRegExp.exec(message);
124
+ if (execResult == null) {
125
+ let execResult$1 = blockRangeLimitRegExp.exec(message);
126
+ if (!(execResult$1 == null)) {
127
+ return extractBlockRange(execResult$1, true);
128
+ }
129
+ let execResult$2 = alchemyRangeRegExp.exec(message);
130
+ if (!(execResult$2 == null)) {
131
+ return extractBlockRange(execResult$2, true);
132
+ }
133
+ let execResult$3 = cloudflareRangeRegExp.exec(message);
134
+ if (!(execResult$3 == null)) {
135
+ return extractBlockRange(execResult$3, true);
129
136
  }
130
- var fromBlock = execResult[1];
131
- if (fromBlock === null || fromBlock === undefined) {
132
- return ;
137
+ let execResult$4 = thirdwebRangeRegExp.exec(message);
138
+ if (!(execResult$4 == null)) {
139
+ return extractBlockRange(execResult$4, true);
133
140
  }
134
- var toBlock = execResult[2];
135
- if (toBlock === null || toBlock === undefined) {
136
- return ;
141
+ let execResult$5 = blockpiRangeRegExp.exec(message);
142
+ if (!(execResult$5 == null)) {
143
+ return extractBlockRange(execResult$5, true);
137
144
  }
138
- var match = Belt_Int.fromString(fromBlock);
139
- var match$1 = Belt_Int.fromString(toBlock);
140
- if (match !== undefined && match$1 !== undefined && match$1 >= match) {
145
+ let execResult$6 = maxAllowedBlocksRegExp.exec(message);
146
+ if (!(execResult$6 == null)) {
147
+ return extractBlockRange(execResult$6, true);
148
+ }
149
+ let match = baseRangeRegExp.exec(message);
150
+ if (!(match == null)) {
141
151
  return [
142
- (match$1 - match | 0) + 1 | 0,
143
- false
144
- ];
152
+ 2000,
153
+ true
154
+ ];
155
+ }
156
+ let execResult$7 = blastPaidRegExp.exec(message);
157
+ if (!(execResult$7 == null)) {
158
+ return extractBlockRange(execResult$7, true);
159
+ }
160
+ let match$1 = chainstackRegExp.exec(message);
161
+ if (!(match$1 == null)) {
162
+ return [
163
+ 10000,
164
+ true
165
+ ];
166
+ }
167
+ let execResult$8 = coinbaseRegExp.exec(message);
168
+ if (!(execResult$8 == null)) {
169
+ return extractBlockRange(execResult$8, true);
170
+ }
171
+ let execResult$9 = publicNodeRegExp.exec(message);
172
+ if (!(execResult$9 == null)) {
173
+ return extractBlockRange(execResult$9, true);
174
+ }
175
+ let execResult$10 = hyperliquidRegExp.exec(message);
176
+ if (!(execResult$10 == null)) {
177
+ return extractBlockRange(execResult$10, true);
145
178
  } else {
146
- return ;
179
+ return;
147
180
  }
148
181
  }
149
- var execResult$1 = blockRangeLimitRegExp.exec(message);
150
- if (execResult$1 !== null) {
151
- return extractBlockRange(execResult$1, true);
152
- }
153
- var execResult$2 = alchemyRangeRegExp.exec(message);
154
- if (execResult$2 !== null) {
155
- return extractBlockRange(execResult$2, true);
156
- }
157
- var execResult$3 = cloudflareRangeRegExp.exec(message);
158
- if (execResult$3 !== null) {
159
- return extractBlockRange(execResult$3, true);
160
- }
161
- var execResult$4 = thirdwebRangeRegExp.exec(message);
162
- if (execResult$4 !== null) {
163
- return extractBlockRange(execResult$4, true);
182
+ let match$2 = execResult.slice(1);
183
+ if (match$2.length !== 2) {
184
+ return;
164
185
  }
165
- var execResult$5 = blockpiRangeRegExp.exec(message);
166
- if (execResult$5 !== null) {
167
- return extractBlockRange(execResult$5, true);
186
+ let fromBlock = match$2[0];
187
+ if (fromBlock === undefined) {
188
+ return;
168
189
  }
169
- var execResult$6 = maxAllowedBlocksRegExp.exec(message);
170
- if (execResult$6 !== null) {
171
- return extractBlockRange(execResult$6, true);
190
+ let toBlock = match$2[1];
191
+ if (toBlock === undefined) {
192
+ return;
172
193
  }
173
- var match$2 = baseRangeRegExp.exec(message);
174
- if (match$2 !== null) {
194
+ let match$3 = Stdlib_Int.fromString(fromBlock, undefined);
195
+ let match$4 = Stdlib_Int.fromString(toBlock, undefined);
196
+ if (match$3 !== undefined && match$4 !== undefined && match$4 >= match$3) {
175
197
  return [
176
- 2000,
177
- true
178
- ];
179
- }
180
- var execResult$7 = blastPaidRegExp.exec(message);
181
- if (execResult$7 !== null) {
182
- return extractBlockRange(execResult$7, true);
183
- }
184
- var match$3 = chainstackRegExp.exec(message);
185
- if (match$3 !== null) {
186
- return [
187
- 10000,
188
- true
189
- ];
190
- }
191
- var execResult$8 = coinbaseRegExp.exec(message);
192
- if (execResult$8 !== null) {
193
- return extractBlockRange(execResult$8, true);
194
- }
195
- var execResult$9 = publicNodeRegExp.exec(message);
196
- if (execResult$9 !== null) {
197
- return extractBlockRange(execResult$9, true);
198
+ (match$4 - match$3 | 0) + 1 | 0,
199
+ false
200
+ ];
198
201
  }
199
- var execResult$10 = hyperliquidRegExp.exec(message);
200
- if (execResult$10 !== null) {
201
- return extractBlockRange(execResult$10, true);
202
- }
203
-
204
202
  }
205
203
 
206
204
  function getSuggestedBlockIntervalFromExn(exn) {
207
205
  if (exn.RE_EXN_ID === Rpc.JsonRpcError) {
208
206
  return parseMessageForBlockRange(exn._1.message);
209
207
  }
210
- if (exn.RE_EXN_ID !== Js_exn.$$Error) {
211
- return ;
208
+ if (exn.RE_EXN_ID !== "JsExn") {
209
+ return;
212
210
  }
213
211
  try {
214
- var message = exn._1.error.message;
212
+ let message = exn._1.error.message;
215
213
  S$RescriptSchema.assertOrThrow(message, S$RescriptSchema.string);
216
214
  return parseMessageForBlockRange(message);
217
- }
218
- catch (exn$1){
219
- return ;
215
+ } catch (exn$1) {
216
+ return;
220
217
  }
221
218
  }
222
219
 
223
- var maxSuggestedBlockIntervalKey = "max";
220
+ let maxSuggestedBlockIntervalKey = "max";
224
221
 
225
222
  function getNextPage(fromBlock, toBlock, addresses, topicQuery, loadBlock, sc, client, mutSuggestedBlockIntervals, partitionId, sourceName, chainId) {
226
- var queryTimoutPromise = Time.resolvePromiseAfterDelay(sc.queryTimeoutMillis).then(function () {
227
- return Promise.reject({
228
- RE_EXN_ID: QueryTimout,
229
- _1: "Query took longer than " + String(sc.queryTimeoutMillis / 1000 | 0) + " seconds"
230
- });
231
- });
232
- var latestFetchedBlockPromise = loadBlock(toBlock);
223
+ let queryTimoutPromise = Time.resolvePromiseAfterDelay(sc.queryTimeoutMillis).then(() => Promise.reject({
224
+ RE_EXN_ID: QueryTimout,
225
+ _1: `Query took longer than ` + String(sc.queryTimeoutMillis / 1000 | 0) + ` seconds`
226
+ }));
227
+ let latestFetchedBlockPromise = loadBlock(toBlock);
233
228
  Prometheus.SourceRequestCount.increment(sourceName, chainId, "eth_getLogs");
234
- var logsPromise = Rpc.getLogs(client, {
235
- fromBlock: fromBlock,
236
- toBlock: toBlock,
237
- address: addresses,
238
- topics: topicQuery
239
- }).then(async function (logs) {
240
- return {
241
- logs: logs,
242
- latestFetchedBlockInfo: await latestFetchedBlockPromise
243
- };
244
- });
245
- return $$Promise.$$catch(Promise.race([
246
- queryTimoutPromise,
247
- logsPromise
248
- ]), (function (err) {
249
- var match = getSuggestedBlockIntervalFromExn(err);
250
- if (match !== undefined) {
251
- var nextBlockIntervalTry = match[0];
252
- mutSuggestedBlockIntervals[match[1] ? maxSuggestedBlockIntervalKey : partitionId] = nextBlockIntervalTry;
253
- throw {
254
- RE_EXN_ID: Source.GetItemsError,
255
- _1: {
256
- TAG: "FailedGettingItems",
257
- exn: err,
258
- attemptedToBlock: toBlock,
259
- retry: {
260
- TAG: "WithSuggestedToBlock",
261
- toBlock: (fromBlock + nextBlockIntervalTry | 0) - 1 | 0
262
- }
263
- },
264
- Error: new Error()
265
- };
266
- }
267
- var executedBlockInterval = (toBlock - fromBlock | 0) + 1 | 0;
268
- var nextBlockIntervalTry$1 = executedBlockInterval * sc.backoffMultiplicative | 0;
269
- mutSuggestedBlockIntervals[partitionId] = nextBlockIntervalTry$1;
270
- throw {
271
- RE_EXN_ID: Source.GetItemsError,
272
- _1: {
273
- TAG: "FailedGettingItems",
274
- exn: err,
275
- attemptedToBlock: toBlock,
276
- retry: {
277
- TAG: "WithBackoff",
278
- message: "Failed getting data for the block range. Will try smaller block range for the next attempt.",
279
- backoffMillis: sc.backoffMillis
280
- }
281
- },
282
- Error: new Error()
283
- };
284
- }));
229
+ let logsPromise = Rpc.getLogs(client, {
230
+ fromBlock: fromBlock,
231
+ toBlock: toBlock,
232
+ address: addresses,
233
+ topics: topicQuery
234
+ }).then(async logs => ({
235
+ logs: logs,
236
+ latestFetchedBlockInfo: await latestFetchedBlockPromise
237
+ }));
238
+ return Stdlib_Promise.$$catch(Promise.race([
239
+ queryTimoutPromise,
240
+ logsPromise
241
+ ]), err => {
242
+ let match = getSuggestedBlockIntervalFromExn(err);
243
+ if (match !== undefined) {
244
+ let nextBlockIntervalTry = match[0];
245
+ mutSuggestedBlockIntervals[match[1] ? maxSuggestedBlockIntervalKey : partitionId] = nextBlockIntervalTry;
246
+ throw {
247
+ RE_EXN_ID: Source.GetItemsError,
248
+ _1: {
249
+ TAG: "FailedGettingItems",
250
+ exn: err,
251
+ attemptedToBlock: toBlock,
252
+ retry: {
253
+ TAG: "WithSuggestedToBlock",
254
+ toBlock: (fromBlock + nextBlockIntervalTry | 0) - 1 | 0
255
+ }
256
+ },
257
+ Error: new Error()
258
+ };
259
+ }
260
+ let executedBlockInterval = (toBlock - fromBlock | 0) + 1 | 0;
261
+ let nextBlockIntervalTry$1 = executedBlockInterval * sc.backoffMultiplicative | 0;
262
+ mutSuggestedBlockIntervals[partitionId] = nextBlockIntervalTry$1;
263
+ throw {
264
+ RE_EXN_ID: Source.GetItemsError,
265
+ _1: {
266
+ TAG: "FailedGettingItems",
267
+ exn: err,
268
+ attemptedToBlock: toBlock,
269
+ retry: {
270
+ TAG: "WithBackoff",
271
+ message: `Failed getting data for the block range. Will try smaller block range for the next attempt.`,
272
+ backoffMillis: sc.backoffMillis
273
+ }
274
+ },
275
+ Error: new Error()
276
+ };
277
+ });
285
278
  }
286
279
 
287
280
  function getSelectionConfig(selection, chain) {
288
- var staticTopicSelections = [];
289
- var dynamicEventFilters = [];
290
- Belt_Array.forEach(selection.eventConfigs, (function (param) {
291
- var s = param.getEventFiltersOrThrow(chain);
292
- if (s.TAG === "Static") {
293
- Caml_splice_call.spliceObjApply(staticTopicSelections, "push", [s._0]);
294
- return ;
295
- }
296
- dynamicEventFilters.push(s._0);
297
- }));
298
- var match = LogSelection.compressTopicSelections(staticTopicSelections);
299
- var len = match.length;
300
- var getLogSelectionOrThrow;
281
+ let staticTopicSelections = [];
282
+ let dynamicEventFilters = [];
283
+ Belt_Array.forEach(selection.eventConfigs, param => {
284
+ let s = param.getEventFiltersOrThrow(chain);
285
+ if (s.TAG === "Static") {
286
+ staticTopicSelections.push(...s._0);
287
+ return;
288
+ }
289
+ dynamicEventFilters.push(s._0);
290
+ });
291
+ let match = LogSelection.compressTopicSelections(staticTopicSelections);
292
+ let len = match.length;
293
+ let getLogSelectionOrThrow;
301
294
  if (len !== 1) {
302
295
  if (len !== 0) {
303
296
  throw {
304
- RE_EXN_ID: Source.GetItemsError,
305
- _1: {
306
- TAG: "UnsupportedSelection",
307
- message: "RPC data-source currently supports event filters only when there's a single wildcard event. Please, create a GitHub issue if it's a blocker for you."
308
- },
309
- Error: new Error()
310
- };
297
+ RE_EXN_ID: Source.GetItemsError,
298
+ _1: {
299
+ TAG: "UnsupportedSelection",
300
+ message: "RPC data-source currently supports event filters only when there's a single wildcard event. Please, create a GitHub issue if it's a blocker for you."
301
+ },
302
+ Error: new Error()
303
+ };
311
304
  }
312
- var len$1 = dynamicEventFilters.length;
305
+ let len$1 = dynamicEventFilters.length;
313
306
  if (len$1 !== 1) {
314
307
  if (len$1 !== 0) {
315
308
  throw {
316
- RE_EXN_ID: Source.GetItemsError,
317
- _1: {
318
- TAG: "UnsupportedSelection",
319
- message: "RPC data-source currently supports event filters only when there's a single wildcard event. Please, create a GitHub issue if it's a blocker for you."
320
- },
321
- Error: new Error()
322
- };
309
+ RE_EXN_ID: Source.GetItemsError,
310
+ _1: {
311
+ TAG: "UnsupportedSelection",
312
+ message: "RPC data-source currently supports event filters only when there's a single wildcard event. Please, create a GitHub issue if it's a blocker for you."
313
+ },
314
+ Error: new Error()
315
+ };
323
316
  }
324
317
  throw {
325
- RE_EXN_ID: Source.GetItemsError,
326
- _1: {
327
- TAG: "UnsupportedSelection",
328
- message: "Invalid events configuration for the partition. Nothing to fetch. Please, report to the Envio team."
329
- },
330
- Error: new Error()
331
- };
318
+ RE_EXN_ID: Source.GetItemsError,
319
+ _1: {
320
+ TAG: "UnsupportedSelection",
321
+ message: "Invalid events configuration for the partition. Nothing to fetch. Please, report to the Envio team."
322
+ },
323
+ Error: new Error()
324
+ };
332
325
  }
333
- var dynamicEventFilter = dynamicEventFilters[0];
326
+ let dynamicEventFilter = dynamicEventFilters[0];
334
327
  if (selection.eventConfigs.length === 1) {
335
- var eventConfig = Utils.$$Array.firstUnsafe(selection.eventConfigs);
336
- getLogSelectionOrThrow = (function (addressesByContractName) {
337
- var addresses = FetchState.addressesByContractNameGetAll(addressesByContractName);
338
- var match = dynamicEventFilter(addresses);
339
- if (match.length !== 1) {
340
- throw {
341
- RE_EXN_ID: Source.GetItemsError,
342
- _1: {
343
- TAG: "UnsupportedSelection",
344
- message: "RPC data-source currently doesn't support an array of event filters. Please, create a GitHub issue if it's a blocker for you."
345
- },
346
- Error: new Error()
347
- };
348
- }
349
- var topicSelection = match[0];
350
- return {
351
- addresses: eventConfig.isWildcard ? undefined : addresses,
352
- topicQuery: Rpc.GetLogs.mapTopicQuery(topicSelection)
353
- };
354
- });
355
- } else {
356
- throw {
328
+ let eventConfig = Utils.$$Array.firstUnsafe(selection.eventConfigs);
329
+ getLogSelectionOrThrow = addressesByContractName => {
330
+ let addresses = FetchState.addressesByContractNameGetAll(addressesByContractName);
331
+ let match = dynamicEventFilter(addresses);
332
+ if (match.length !== 1) {
333
+ throw {
357
334
  RE_EXN_ID: Source.GetItemsError,
358
335
  _1: {
359
336
  TAG: "UnsupportedSelection",
360
- message: "RPC data-source currently supports event filters only when there's a single wildcard event. Please, create a GitHub issue if it's a blocker for you."
337
+ message: "RPC data-source currently doesn't support an array of event filters. Please, create a GitHub issue if it's a blocker for you."
361
338
  },
362
339
  Error: new Error()
363
340
  };
341
+ }
342
+ return {
343
+ addresses: eventConfig.isWildcard ? undefined : addresses,
344
+ topicQuery: Rpc.GetLogs.mapTopicQuery(match[0])
345
+ };
346
+ };
347
+ } else {
348
+ throw {
349
+ RE_EXN_ID: Source.GetItemsError,
350
+ _1: {
351
+ TAG: "UnsupportedSelection",
352
+ message: "RPC data-source currently supports event filters only when there's a single wildcard event. Please, create a GitHub issue if it's a blocker for you."
353
+ },
354
+ Error: new Error()
355
+ };
364
356
  }
365
357
  } else {
366
- var topicSelection = match[0];
358
+ let topicSelection = match[0];
367
359
  if (dynamicEventFilters.length !== 0) {
368
360
  throw {
369
- RE_EXN_ID: Source.GetItemsError,
370
- _1: {
371
- TAG: "UnsupportedSelection",
372
- message: "RPC data-source currently supports event filters only when there's a single wildcard event. Please, create a GitHub issue if it's a blocker for you."
373
- },
374
- Error: new Error()
375
- };
361
+ RE_EXN_ID: Source.GetItemsError,
362
+ _1: {
363
+ TAG: "UnsupportedSelection",
364
+ message: "RPC data-source currently supports event filters only when there's a single wildcard event. Please, create a GitHub issue if it's a blocker for you."
365
+ },
366
+ Error: new Error()
367
+ };
376
368
  }
377
- var topicQuery = Rpc.GetLogs.mapTopicQuery(topicSelection);
378
- getLogSelectionOrThrow = (function (addressesByContractName) {
379
- var addresses = FetchState.addressesByContractNameGetAll(addressesByContractName);
380
- return {
381
- addresses: addresses.length !== 0 ? addresses : undefined,
382
- topicQuery: topicQuery
383
- };
384
- });
369
+ let topicQuery = Rpc.GetLogs.mapTopicQuery(topicSelection);
370
+ getLogSelectionOrThrow = addressesByContractName => {
371
+ let addresses = FetchState.addressesByContractNameGetAll(addressesByContractName);
372
+ return {
373
+ addresses: addresses.length !== 0 ? addresses : undefined,
374
+ topicQuery: topicQuery
375
+ };
376
+ };
385
377
  }
386
378
  return {
387
- getLogSelectionOrThrow: getLogSelectionOrThrow
388
- };
379
+ getLogSelectionOrThrow: getLogSelectionOrThrow
380
+ };
389
381
  }
390
382
 
391
383
  function memoGetSelectionConfig(chain) {
392
- return Utils.$$WeakMap.memoize(function (selection) {
393
- return getSelectionConfig(selection, chain);
394
- });
384
+ return Utils.$$WeakMap.memoize(selection => getSelectionConfig(selection, chain));
395
385
  }
396
386
 
397
- var lowercaseAddressSchema = S$RescriptSchema.transform(S$RescriptSchema.string, (function (param) {
398
- return {
399
- p: (function (str) {
400
- return str.toLowerCase();
401
- })
402
- };
403
- }));
387
+ let lowercaseAddressSchema = S$RescriptSchema.transform(S$RescriptSchema.string, param => ({
388
+ p: str => str.toLowerCase()
389
+ }));
404
390
 
405
- var checksumAddressSchema = S$RescriptSchema.transform(S$RescriptSchema.string, (function (param) {
406
- return {
407
- p: (function (str) {
408
- return Address.Evm.fromStringOrThrow(str);
409
- })
410
- };
411
- }));
391
+ let checksumAddressSchema = S$RescriptSchema.transform(S$RescriptSchema.string, param => ({
392
+ p: str => Address.Evm.fromStringOrThrow(str)
393
+ }));
412
394
 
413
395
  function makeBlockFieldRegistry(addressSchema) {
414
- return Utils.Record.fromArray(Belt_Array.map([
415
- {
416
- location: "number",
417
- jsonKey: "number",
418
- schema: Rpc.hexIntSchema
419
- },
420
- {
421
- location: "timestamp",
422
- jsonKey: "timestamp",
423
- schema: Rpc.hexIntSchema
424
- },
425
- {
426
- location: "hash",
427
- jsonKey: "hash",
428
- schema: S$RescriptSchema.string
429
- },
430
- {
431
- location: "parentHash",
432
- jsonKey: "parentHash",
433
- schema: S$RescriptSchema.string
434
- },
435
- {
436
- location: "nonce",
437
- jsonKey: "nonce",
438
- schema: Rpc.hexBigintSchema
439
- },
440
- {
441
- location: "sha3Uncles",
442
- jsonKey: "sha3Uncles",
443
- schema: S$RescriptSchema.string
444
- },
445
- {
446
- location: "logsBloom",
447
- jsonKey: "logsBloom",
448
- schema: S$RescriptSchema.string
449
- },
450
- {
451
- location: "transactionsRoot",
452
- jsonKey: "transactionsRoot",
453
- schema: S$RescriptSchema.string
454
- },
455
- {
456
- location: "stateRoot",
457
- jsonKey: "stateRoot",
458
- schema: S$RescriptSchema.string
459
- },
460
- {
461
- location: "receiptsRoot",
462
- jsonKey: "receiptsRoot",
463
- schema: S$RescriptSchema.string
464
- },
465
- {
466
- location: "miner",
467
- jsonKey: "miner",
468
- schema: addressSchema
469
- },
470
- {
471
- location: "difficulty",
472
- jsonKey: "difficulty",
473
- schema: Rpc.hexBigintSchema
474
- },
475
- {
476
- location: "totalDifficulty",
477
- jsonKey: "totalDifficulty",
478
- schema: Rpc.hexBigintSchema
479
- },
480
- {
481
- location: "extraData",
482
- jsonKey: "extraData",
483
- schema: S$RescriptSchema.string
484
- },
485
- {
486
- location: "size",
487
- jsonKey: "size",
488
- schema: Rpc.hexBigintSchema
489
- },
490
- {
491
- location: "gasLimit",
492
- jsonKey: "gasLimit",
493
- schema: Rpc.hexBigintSchema
494
- },
495
- {
496
- location: "gasUsed",
497
- jsonKey: "gasUsed",
498
- schema: Rpc.hexBigintSchema
499
- },
500
- {
501
- location: "uncles",
502
- jsonKey: "uncles",
503
- schema: S$RescriptSchema.array(S$RescriptSchema.string)
504
- },
505
- {
506
- location: "baseFeePerGas",
507
- jsonKey: "baseFeePerGas",
508
- schema: Rpc.hexBigintSchema
509
- },
510
- {
511
- location: "blobGasUsed",
512
- jsonKey: "blobGasUsed",
513
- schema: Rpc.hexBigintSchema
514
- },
515
- {
516
- location: "excessBlobGas",
517
- jsonKey: "excessBlobGas",
518
- schema: Rpc.hexBigintSchema
519
- },
520
- {
521
- location: "parentBeaconBlockRoot",
522
- jsonKey: "parentBeaconBlockRoot",
523
- schema: S$RescriptSchema.string
524
- },
525
- {
526
- location: "withdrawalsRoot",
527
- jsonKey: "withdrawalsRoot",
528
- schema: S$RescriptSchema.string
529
- },
530
- {
531
- location: "l1BlockNumber",
532
- jsonKey: "l1BlockNumber",
533
- schema: Rpc.hexIntSchema
534
- },
535
- {
536
- location: "sendCount",
537
- jsonKey: "sendCount",
538
- schema: S$RescriptSchema.string
539
- },
540
- {
541
- location: "sendRoot",
542
- jsonKey: "sendRoot",
543
- schema: S$RescriptSchema.string
544
- },
545
- {
546
- location: "mixHash",
547
- jsonKey: "mixHash",
548
- schema: S$RescriptSchema.string
549
- }
550
- ], (function (def) {
551
- return [
552
- def.location,
553
- Internal.evmNullableBlockFields.has(def.location) ? ({
554
- location: def.location,
555
- jsonKey: def.jsonKey,
556
- schema: S$RescriptSchema.nullable(def.schema)
557
- }) : def
558
- ];
559
- })));
396
+ return Utils.Record.fromArray([
397
+ {
398
+ location: "number",
399
+ jsonKey: "number",
400
+ schema: Rpc.hexIntSchema
401
+ },
402
+ {
403
+ location: "timestamp",
404
+ jsonKey: "timestamp",
405
+ schema: Rpc.hexIntSchema
406
+ },
407
+ {
408
+ location: "hash",
409
+ jsonKey: "hash",
410
+ schema: S$RescriptSchema.string
411
+ },
412
+ {
413
+ location: "parentHash",
414
+ jsonKey: "parentHash",
415
+ schema: S$RescriptSchema.string
416
+ },
417
+ {
418
+ location: "nonce",
419
+ jsonKey: "nonce",
420
+ schema: Rpc.hexBigintSchema
421
+ },
422
+ {
423
+ location: "sha3Uncles",
424
+ jsonKey: "sha3Uncles",
425
+ schema: S$RescriptSchema.string
426
+ },
427
+ {
428
+ location: "logsBloom",
429
+ jsonKey: "logsBloom",
430
+ schema: S$RescriptSchema.string
431
+ },
432
+ {
433
+ location: "transactionsRoot",
434
+ jsonKey: "transactionsRoot",
435
+ schema: S$RescriptSchema.string
436
+ },
437
+ {
438
+ location: "stateRoot",
439
+ jsonKey: "stateRoot",
440
+ schema: S$RescriptSchema.string
441
+ },
442
+ {
443
+ location: "receiptsRoot",
444
+ jsonKey: "receiptsRoot",
445
+ schema: S$RescriptSchema.string
446
+ },
447
+ {
448
+ location: "miner",
449
+ jsonKey: "miner",
450
+ schema: addressSchema
451
+ },
452
+ {
453
+ location: "difficulty",
454
+ jsonKey: "difficulty",
455
+ schema: Rpc.hexBigintSchema
456
+ },
457
+ {
458
+ location: "totalDifficulty",
459
+ jsonKey: "totalDifficulty",
460
+ schema: Rpc.hexBigintSchema
461
+ },
462
+ {
463
+ location: "extraData",
464
+ jsonKey: "extraData",
465
+ schema: S$RescriptSchema.string
466
+ },
467
+ {
468
+ location: "size",
469
+ jsonKey: "size",
470
+ schema: Rpc.hexBigintSchema
471
+ },
472
+ {
473
+ location: "gasLimit",
474
+ jsonKey: "gasLimit",
475
+ schema: Rpc.hexBigintSchema
476
+ },
477
+ {
478
+ location: "gasUsed",
479
+ jsonKey: "gasUsed",
480
+ schema: Rpc.hexBigintSchema
481
+ },
482
+ {
483
+ location: "uncles",
484
+ jsonKey: "uncles",
485
+ schema: S$RescriptSchema.array(S$RescriptSchema.string)
486
+ },
487
+ {
488
+ location: "baseFeePerGas",
489
+ jsonKey: "baseFeePerGas",
490
+ schema: Rpc.hexBigintSchema
491
+ },
492
+ {
493
+ location: "blobGasUsed",
494
+ jsonKey: "blobGasUsed",
495
+ schema: Rpc.hexBigintSchema
496
+ },
497
+ {
498
+ location: "excessBlobGas",
499
+ jsonKey: "excessBlobGas",
500
+ schema: Rpc.hexBigintSchema
501
+ },
502
+ {
503
+ location: "parentBeaconBlockRoot",
504
+ jsonKey: "parentBeaconBlockRoot",
505
+ schema: S$RescriptSchema.string
506
+ },
507
+ {
508
+ location: "withdrawalsRoot",
509
+ jsonKey: "withdrawalsRoot",
510
+ schema: S$RescriptSchema.string
511
+ },
512
+ {
513
+ location: "l1BlockNumber",
514
+ jsonKey: "l1BlockNumber",
515
+ schema: Rpc.hexIntSchema
516
+ },
517
+ {
518
+ location: "sendCount",
519
+ jsonKey: "sendCount",
520
+ schema: S$RescriptSchema.string
521
+ },
522
+ {
523
+ location: "sendRoot",
524
+ jsonKey: "sendRoot",
525
+ schema: S$RescriptSchema.string
526
+ },
527
+ {
528
+ location: "mixHash",
529
+ jsonKey: "mixHash",
530
+ schema: S$RescriptSchema.string
531
+ }
532
+ ].map(def => [
533
+ def.location,
534
+ Internal.evmNullableBlockFields.has(def.location) ? ({
535
+ location: def.location,
536
+ jsonKey: def.jsonKey,
537
+ schema: S$RescriptSchema.nullable(def.schema)
538
+ }) : def
539
+ ]));
560
540
  }
561
541
 
562
- var blockFieldRegistryLowercase = makeBlockFieldRegistry(lowercaseAddressSchema);
542
+ let blockFieldRegistryLowercase = makeBlockFieldRegistry(lowercaseAddressSchema);
563
543
 
564
- var blockFieldRegistryChecksum = makeBlockFieldRegistry(checksumAddressSchema);
544
+ let blockFieldRegistryChecksum = makeBlockFieldRegistry(checksumAddressSchema);
565
545
 
566
546
  function parseBlockFieldsFromJson(mutBlockAcc, fields, json) {
567
- Belt_Array.forEach(fields, (function (def) {
568
- var raw = json[def.jsonKey];
569
- try {
570
- var parsed = S$RescriptSchema.parseOrThrow(raw, def.schema);
571
- mutBlockAcc[def.location] = parsed;
572
- return ;
573
- }
574
- catch (raw_error){
575
- var error = Caml_js_exceptions.internalToOCamlException(raw_error);
576
- if (error.RE_EXN_ID === S$RescriptSchema.Raised) {
577
- return Js_exn.raiseError("Invalid block field \"" + def.location + "\" found in the RPC response. Error: " + S$RescriptSchema.$$Error.reason(error._1));
578
- }
579
- throw error;
580
- }
581
- }));
547
+ fields.forEach(def => {
548
+ let raw = json[def.jsonKey];
549
+ try {
550
+ let parsed = S$RescriptSchema.parseOrThrow(raw, def.schema);
551
+ mutBlockAcc[def.location] = parsed;
552
+ return;
553
+ } catch (raw_error) {
554
+ let error = Primitive_exceptions.internalToException(raw_error);
555
+ if (error.RE_EXN_ID === S$RescriptSchema.Raised) {
556
+ return Stdlib_JsError.throwWithMessage(`Invalid block field "` + def.location + `" found in the RPC response. Error: ` + S$RescriptSchema.$$Error.reason(error._1));
557
+ }
558
+ throw error;
559
+ }
560
+ });
582
561
  }
583
562
 
584
563
  function makeThrowingGetEventBlock(getBlockJson, lowercaseAddresses) {
585
- var blockFieldRegistry = lowercaseAddresses ? blockFieldRegistryLowercase : blockFieldRegistryChecksum;
586
- var fnsCache = new WeakMap();
587
- return function (log, selectedBlockFields) {
588
- var fn = fnsCache.get(selectedBlockFields);
589
- var tmp;
564
+ let blockFieldRegistry = lowercaseAddresses ? blockFieldRegistryLowercase : blockFieldRegistryChecksum;
565
+ let fnsCache = new WeakMap();
566
+ return (log, selectedBlockFields) => {
567
+ let fn = fnsCache.get(selectedBlockFields);
568
+ let tmp;
590
569
  if (fn !== undefined) {
591
570
  tmp = fn;
592
571
  } else {
593
- var fields = [];
594
- selectedBlockFields.forEach(function (fieldName) {
595
- fields.push(blockFieldRegistry[fieldName]);
596
- });
597
- var fn$1 = selectedBlockFields.size === 0 ? (function (param) {
598
- return Promise.resolve({});
599
- }) : (function (log) {
600
- return getBlockJson(log.blockNumber).then(function (json) {
601
- var mutBlockAcc = {};
602
- parseBlockFieldsFromJson(mutBlockAcc, fields, json);
603
- return mutBlockAcc;
604
- });
605
- });
572
+ let fields = [];
573
+ selectedBlockFields.forEach(fieldName => {
574
+ fields.push(blockFieldRegistry[fieldName]);
575
+ });
576
+ let fn$1 = selectedBlockFields.size === 0 ? param => Promise.resolve({}) : log => getBlockJson(log.blockNumber).then(json => {
577
+ let mutBlockAcc = {};
578
+ parseBlockFieldsFromJson(mutBlockAcc, fields, json);
579
+ return mutBlockAcc;
580
+ });
606
581
  fnsCache.set(selectedBlockFields, fn$1);
607
582
  tmp = fn$1;
608
583
  }
@@ -611,340 +586,327 @@ function makeThrowingGetEventBlock(getBlockJson, lowercaseAddresses) {
611
586
  }
612
587
 
613
588
  function makeFieldRegistry(addressSchema) {
614
- return Utils.Record.fromArray(Belt_Array.map([
615
- {
616
- location: "gas",
617
- jsonKey: "gas",
618
- schema: Rpc.hexBigintSchema,
619
- source: "TransactionOnly"
620
- },
621
- {
622
- location: "gasPrice",
623
- jsonKey: "gasPrice",
624
- schema: Rpc.hexBigintSchema,
625
- source: "TransactionOnly"
626
- },
627
- {
628
- location: "input",
629
- jsonKey: "input",
630
- schema: S$RescriptSchema.string,
631
- source: "TransactionOnly"
632
- },
633
- {
634
- location: "nonce",
635
- jsonKey: "nonce",
636
- schema: Rpc.hexBigintSchema,
637
- source: "TransactionOnly"
638
- },
639
- {
640
- location: "value",
641
- jsonKey: "value",
642
- schema: Rpc.hexBigintSchema,
643
- source: "TransactionOnly"
644
- },
645
- {
646
- location: "v",
647
- jsonKey: "v",
648
- schema: S$RescriptSchema.string,
649
- source: "TransactionOnly"
650
- },
651
- {
652
- location: "r",
653
- jsonKey: "r",
654
- schema: S$RescriptSchema.string,
655
- source: "TransactionOnly"
656
- },
657
- {
658
- location: "s",
659
- jsonKey: "s",
660
- schema: S$RescriptSchema.string,
661
- source: "TransactionOnly"
662
- },
663
- {
664
- location: "yParity",
665
- jsonKey: "yParity",
666
- schema: S$RescriptSchema.string,
667
- source: "TransactionOnly"
668
- },
669
- {
670
- location: "maxPriorityFeePerGas",
671
- jsonKey: "maxPriorityFeePerGas",
672
- schema: Rpc.hexBigintSchema,
673
- source: "TransactionOnly"
674
- },
675
- {
676
- location: "maxFeePerGas",
677
- jsonKey: "maxFeePerGas",
678
- schema: Rpc.hexBigintSchema,
679
- source: "TransactionOnly"
680
- },
681
- {
682
- location: "maxFeePerBlobGas",
683
- jsonKey: "maxFeePerBlobGas",
684
- schema: Rpc.hexBigintSchema,
685
- source: "TransactionOnly"
686
- },
687
- {
688
- location: "blobVersionedHashes",
689
- jsonKey: "blobVersionedHashes",
690
- schema: S$RescriptSchema.array(S$RescriptSchema.string),
691
- source: "TransactionOnly"
692
- },
693
- {
694
- location: "gasUsed",
695
- jsonKey: "gasUsed",
696
- schema: Rpc.hexBigintSchema,
697
- source: "ReceiptOnly"
698
- },
699
- {
700
- location: "cumulativeGasUsed",
701
- jsonKey: "cumulativeGasUsed",
702
- schema: Rpc.hexBigintSchema,
703
- source: "ReceiptOnly"
704
- },
705
- {
706
- location: "effectiveGasPrice",
707
- jsonKey: "effectiveGasPrice",
708
- schema: Rpc.hexBigintSchema,
709
- source: "ReceiptOnly"
710
- },
711
- {
712
- location: "contractAddress",
713
- jsonKey: "contractAddress",
714
- schema: addressSchema,
715
- source: "ReceiptOnly"
716
- },
717
- {
718
- location: "logsBloom",
719
- jsonKey: "logsBloom",
720
- schema: S$RescriptSchema.string,
721
- source: "ReceiptOnly"
722
- },
723
- {
724
- location: "root",
725
- jsonKey: "root",
726
- schema: S$RescriptSchema.string,
727
- source: "ReceiptOnly"
728
- },
729
- {
730
- location: "status",
731
- jsonKey: "status",
732
- schema: Rpc.hexIntSchema,
733
- source: "ReceiptOnly"
734
- },
735
- {
736
- location: "l1Fee",
737
- jsonKey: "l1Fee",
738
- schema: Rpc.hexBigintSchema,
739
- source: "ReceiptOnly"
740
- },
741
- {
742
- location: "l1GasPrice",
743
- jsonKey: "l1GasPrice",
744
- schema: Rpc.hexBigintSchema,
745
- source: "ReceiptOnly"
746
- },
747
- {
748
- location: "l1GasUsed",
749
- jsonKey: "l1GasUsed",
750
- schema: Rpc.hexBigintSchema,
751
- source: "ReceiptOnly"
752
- },
753
- {
754
- location: "l1FeeScalar",
755
- jsonKey: "l1FeeScalar",
756
- schema: Rpc.decimalFloatSchema,
757
- source: "ReceiptOnly"
758
- },
759
- {
760
- location: "gasUsedForL1",
761
- jsonKey: "gasUsedForL1",
762
- schema: Rpc.hexBigintSchema,
763
- source: "ReceiptOnly"
764
- },
765
- {
766
- location: "from",
767
- jsonKey: "from",
768
- schema: addressSchema,
769
- source: "Both"
770
- },
771
- {
772
- location: "to",
773
- jsonKey: "to",
774
- schema: addressSchema,
775
- source: "Both"
776
- },
777
- {
778
- location: "type",
779
- jsonKey: "type",
780
- schema: Rpc.hexIntSchema,
781
- source: "Both"
782
- }
783
- ], (function (def) {
784
- return [
785
- def.location,
786
- Internal.evmNullableTransactionFields.has(def.location) ? ({
787
- location: def.location,
788
- jsonKey: def.jsonKey,
789
- schema: S$RescriptSchema.nullable(def.schema),
790
- source: def.source
791
- }) : def
792
- ];
793
- })));
589
+ return Utils.Record.fromArray([
590
+ {
591
+ location: "gas",
592
+ jsonKey: "gas",
593
+ schema: Rpc.hexBigintSchema,
594
+ source: "TransactionOnly"
595
+ },
596
+ {
597
+ location: "gasPrice",
598
+ jsonKey: "gasPrice",
599
+ schema: Rpc.hexBigintSchema,
600
+ source: "TransactionOnly"
601
+ },
602
+ {
603
+ location: "input",
604
+ jsonKey: "input",
605
+ schema: S$RescriptSchema.string,
606
+ source: "TransactionOnly"
607
+ },
608
+ {
609
+ location: "nonce",
610
+ jsonKey: "nonce",
611
+ schema: Rpc.hexBigintSchema,
612
+ source: "TransactionOnly"
613
+ },
614
+ {
615
+ location: "value",
616
+ jsonKey: "value",
617
+ schema: Rpc.hexBigintSchema,
618
+ source: "TransactionOnly"
619
+ },
620
+ {
621
+ location: "v",
622
+ jsonKey: "v",
623
+ schema: S$RescriptSchema.string,
624
+ source: "TransactionOnly"
625
+ },
626
+ {
627
+ location: "r",
628
+ jsonKey: "r",
629
+ schema: S$RescriptSchema.string,
630
+ source: "TransactionOnly"
631
+ },
632
+ {
633
+ location: "s",
634
+ jsonKey: "s",
635
+ schema: S$RescriptSchema.string,
636
+ source: "TransactionOnly"
637
+ },
638
+ {
639
+ location: "yParity",
640
+ jsonKey: "yParity",
641
+ schema: S$RescriptSchema.string,
642
+ source: "TransactionOnly"
643
+ },
644
+ {
645
+ location: "maxPriorityFeePerGas",
646
+ jsonKey: "maxPriorityFeePerGas",
647
+ schema: Rpc.hexBigintSchema,
648
+ source: "TransactionOnly"
649
+ },
650
+ {
651
+ location: "maxFeePerGas",
652
+ jsonKey: "maxFeePerGas",
653
+ schema: Rpc.hexBigintSchema,
654
+ source: "TransactionOnly"
655
+ },
656
+ {
657
+ location: "maxFeePerBlobGas",
658
+ jsonKey: "maxFeePerBlobGas",
659
+ schema: Rpc.hexBigintSchema,
660
+ source: "TransactionOnly"
661
+ },
662
+ {
663
+ location: "blobVersionedHashes",
664
+ jsonKey: "blobVersionedHashes",
665
+ schema: S$RescriptSchema.array(S$RescriptSchema.string),
666
+ source: "TransactionOnly"
667
+ },
668
+ {
669
+ location: "gasUsed",
670
+ jsonKey: "gasUsed",
671
+ schema: Rpc.hexBigintSchema,
672
+ source: "ReceiptOnly"
673
+ },
674
+ {
675
+ location: "cumulativeGasUsed",
676
+ jsonKey: "cumulativeGasUsed",
677
+ schema: Rpc.hexBigintSchema,
678
+ source: "ReceiptOnly"
679
+ },
680
+ {
681
+ location: "effectiveGasPrice",
682
+ jsonKey: "effectiveGasPrice",
683
+ schema: Rpc.hexBigintSchema,
684
+ source: "ReceiptOnly"
685
+ },
686
+ {
687
+ location: "contractAddress",
688
+ jsonKey: "contractAddress",
689
+ schema: addressSchema,
690
+ source: "ReceiptOnly"
691
+ },
692
+ {
693
+ location: "logsBloom",
694
+ jsonKey: "logsBloom",
695
+ schema: S$RescriptSchema.string,
696
+ source: "ReceiptOnly"
697
+ },
698
+ {
699
+ location: "root",
700
+ jsonKey: "root",
701
+ schema: S$RescriptSchema.string,
702
+ source: "ReceiptOnly"
703
+ },
704
+ {
705
+ location: "status",
706
+ jsonKey: "status",
707
+ schema: Rpc.hexIntSchema,
708
+ source: "ReceiptOnly"
709
+ },
710
+ {
711
+ location: "l1Fee",
712
+ jsonKey: "l1Fee",
713
+ schema: Rpc.hexBigintSchema,
714
+ source: "ReceiptOnly"
715
+ },
716
+ {
717
+ location: "l1GasPrice",
718
+ jsonKey: "l1GasPrice",
719
+ schema: Rpc.hexBigintSchema,
720
+ source: "ReceiptOnly"
721
+ },
722
+ {
723
+ location: "l1GasUsed",
724
+ jsonKey: "l1GasUsed",
725
+ schema: Rpc.hexBigintSchema,
726
+ source: "ReceiptOnly"
727
+ },
728
+ {
729
+ location: "l1FeeScalar",
730
+ jsonKey: "l1FeeScalar",
731
+ schema: Rpc.decimalFloatSchema,
732
+ source: "ReceiptOnly"
733
+ },
734
+ {
735
+ location: "gasUsedForL1",
736
+ jsonKey: "gasUsedForL1",
737
+ schema: Rpc.hexBigintSchema,
738
+ source: "ReceiptOnly"
739
+ },
740
+ {
741
+ location: "from",
742
+ jsonKey: "from",
743
+ schema: addressSchema,
744
+ source: "Both"
745
+ },
746
+ {
747
+ location: "to",
748
+ jsonKey: "to",
749
+ schema: addressSchema,
750
+ source: "Both"
751
+ },
752
+ {
753
+ location: "type",
754
+ jsonKey: "type",
755
+ schema: Rpc.hexIntSchema,
756
+ source: "Both"
757
+ }
758
+ ].map(def => [
759
+ def.location,
760
+ Internal.evmNullableTransactionFields.has(def.location) ? ({
761
+ location: def.location,
762
+ jsonKey: def.jsonKey,
763
+ schema: S$RescriptSchema.nullable(def.schema),
764
+ source: def.source
765
+ }) : def
766
+ ]));
794
767
  }
795
768
 
796
- var fieldRegistryLowercase = makeFieldRegistry(lowercaseAddressSchema);
769
+ let fieldRegistryLowercase = makeFieldRegistry(lowercaseAddressSchema);
797
770
 
798
- var fieldRegistryChecksum = makeFieldRegistry(checksumAddressSchema);
771
+ let fieldRegistryChecksum = makeFieldRegistry(checksumAddressSchema);
799
772
 
800
773
  function parseFieldsFromJson(mutTransactionAcc, fields, json) {
801
- Belt_Array.forEach(fields, (function (def) {
802
- var raw = json[def.jsonKey];
803
- try {
804
- var parsed = S$RescriptSchema.parseOrThrow(raw, def.schema);
805
- mutTransactionAcc[def.location] = parsed;
806
- return ;
807
- }
808
- catch (raw_error){
809
- var error = Caml_js_exceptions.internalToOCamlException(raw_error);
810
- if (error.RE_EXN_ID === S$RescriptSchema.Raised) {
811
- return Js_exn.raiseError("Invalid transaction field \"" + def.location + "\" found in the RPC response. Error: " + S$RescriptSchema.$$Error.reason(error._1));
812
- }
813
- throw error;
814
- }
815
- }));
774
+ fields.forEach(def => {
775
+ let raw = json[def.jsonKey];
776
+ try {
777
+ let parsed = S$RescriptSchema.parseOrThrow(raw, def.schema);
778
+ mutTransactionAcc[def.location] = parsed;
779
+ return;
780
+ } catch (raw_error) {
781
+ let error = Primitive_exceptions.internalToException(raw_error);
782
+ if (error.RE_EXN_ID === S$RescriptSchema.Raised) {
783
+ return Stdlib_JsError.throwWithMessage(`Invalid transaction field "` + def.location + `" found in the RPC response. Error: ` + S$RescriptSchema.$$Error.reason(error._1));
784
+ }
785
+ throw error;
786
+ }
787
+ });
816
788
  }
817
789
 
818
790
  function makeThrowingGetEventTransaction(getTransactionJson, getReceiptJson, lowercaseAddresses) {
819
- var fieldRegistry = lowercaseAddresses ? fieldRegistryLowercase : fieldRegistryChecksum;
820
- var fnsCache = new WeakMap();
821
- return function (log, selectedTransactionFields) {
822
- var fn = fnsCache.get(selectedTransactionFields);
823
- var tmp;
791
+ let fieldRegistry = lowercaseAddresses ? fieldRegistryLowercase : fieldRegistryChecksum;
792
+ let fnsCache = new WeakMap();
793
+ return (log, selectedTransactionFields) => {
794
+ let fn = fnsCache.get(selectedTransactionFields);
795
+ let tmp;
824
796
  if (fn !== undefined) {
825
797
  tmp = fn;
826
798
  } else {
827
- var hasTransactionIndex = {
799
+ let hasTransactionIndex = {
828
800
  contents: false
829
801
  };
830
- var hasHash = {
802
+ let hasHash = {
831
803
  contents: false
832
804
  };
833
- var txFields = [];
834
- var receiptFields = [];
835
- var bothFields = [];
836
- selectedTransactionFields.forEach(function (fieldName) {
837
- switch (fieldName) {
838
- case "transactionIndex" :
839
- hasTransactionIndex.contents = true;
840
- return ;
841
- case "hash" :
842
- hasHash.contents = true;
843
- return ;
844
- default:
845
- var def = fieldRegistry[fieldName];
846
- if (def === undefined) {
847
- return ;
848
- }
849
- var match = def.source;
850
- switch (match) {
851
- case "TransactionOnly" :
852
- txFields.push(def);
853
- return ;
854
- case "ReceiptOnly" :
855
- receiptFields.push(def);
856
- return ;
857
- case "Both" :
858
- bothFields.push(def);
859
- return ;
860
-
861
- }
805
+ let txFields = [];
806
+ let receiptFields = [];
807
+ let bothFields = [];
808
+ selectedTransactionFields.forEach(fieldName => {
809
+ switch (fieldName) {
810
+ case "transactionIndex" :
811
+ hasTransactionIndex.contents = true;
812
+ return;
813
+ case "hash" :
814
+ hasHash.contents = true;
815
+ return;
816
+ default:
817
+ let def = fieldRegistry[fieldName];
818
+ if (def === undefined) {
819
+ return;
820
+ }
821
+ let match = def.source;
822
+ switch (match) {
823
+ case "TransactionOnly" :
824
+ txFields.push(def);
825
+ return;
826
+ case "ReceiptOnly" :
827
+ receiptFields.push(def);
828
+ return;
829
+ case "Both" :
830
+ bothFields.push(def);
831
+ return;
862
832
  }
863
- });
864
- var match = txFields.length !== 0;
865
- var match$1 = receiptFields.length !== 0;
866
- var strategy = match ? (
833
+ }
834
+ });
835
+ let match = txFields.length !== 0;
836
+ let match$1 = receiptFields.length !== 0;
837
+ let strategy = match ? (
867
838
  match$1 ? "TransactionAndReceipt" : "TransactionOnly"
868
839
  ) : (
869
840
  match$1 ? "ReceiptOnly" : (
870
841
  bothFields.length !== 0 ? "TransactionOnly" : "NoRpc"
871
842
  )
872
843
  );
873
- var targetForBoth = strategy === "ReceiptOnly" ? receiptFields : txFields;
874
- Belt_Array.forEach(bothFields, (function (f) {
875
- targetForBoth.push(f);
876
- }));
877
- var setLogFields = function (mutTransactionAcc, log) {
844
+ let targetForBoth = strategy === "ReceiptOnly" ? receiptFields : txFields;
845
+ bothFields.forEach(f => {
846
+ targetForBoth.push(f);
847
+ });
848
+ let setLogFields = (mutTransactionAcc, log) => {
878
849
  if (hasTransactionIndex.contents) {
879
850
  mutTransactionAcc["transactionIndex"] = log.transactionIndex;
880
851
  }
881
852
  if (hasHash.contents) {
882
853
  mutTransactionAcc["hash"] = log.transactionHash;
883
- return ;
854
+ return;
884
855
  }
885
-
886
856
  };
887
- var fn$1 = selectedTransactionFields.size === 0 ? (function (param) {
888
- return Promise.resolve({});
889
- }) : (
890
- strategy === "NoRpc" ? (function (log) {
891
- var mutTransactionAcc = {};
857
+ let fn$1 = selectedTransactionFields.size === 0 ? param => Promise.resolve({}) : (
858
+ strategy === "NoRpc" ? log => {
859
+ let mutTransactionAcc = {};
860
+ setLogFields(mutTransactionAcc, log);
861
+ return Promise.resolve(mutTransactionAcc);
862
+ } : log => {
863
+ let txJsonPromise;
864
+ let exit = 0;
865
+ switch (strategy) {
866
+ case "NoRpc" :
867
+ case "ReceiptOnly" :
868
+ txJsonPromise = Promise.resolve(undefined);
869
+ break;
870
+ case "TransactionOnly" :
871
+ case "TransactionAndReceipt" :
872
+ exit = 1;
873
+ break;
874
+ }
875
+ if (exit === 1) {
876
+ txJsonPromise = getTransactionJson(log.transactionHash).then(v => v);
877
+ }
878
+ let receiptJsonPromise;
879
+ let exit$1 = 0;
880
+ switch (strategy) {
881
+ case "NoRpc" :
882
+ case "TransactionOnly" :
883
+ receiptJsonPromise = Promise.resolve(undefined);
884
+ break;
885
+ case "ReceiptOnly" :
886
+ case "TransactionAndReceipt" :
887
+ exit$1 = 1;
888
+ break;
889
+ }
890
+ if (exit$1 === 1) {
891
+ receiptJsonPromise = getReceiptJson(log.transactionHash).then(v => v);
892
+ }
893
+ return Promise.all([
894
+ txJsonPromise,
895
+ receiptJsonPromise
896
+ ]).then(param => {
897
+ let receiptJson = param[1];
898
+ let txJson = param[0];
899
+ let mutTransactionAcc = {};
892
900
  setLogFields(mutTransactionAcc, log);
893
- return Promise.resolve(mutTransactionAcc);
894
- }) : (function (log) {
895
- var txJsonPromise;
896
- var exit = 0;
897
- switch (strategy) {
898
- case "NoRpc" :
899
- case "ReceiptOnly" :
900
- txJsonPromise = Promise.resolve(undefined);
901
- break;
902
- case "TransactionOnly" :
903
- case "TransactionAndReceipt" :
904
- exit = 1;
905
- break;
906
-
907
- }
908
- if (exit === 1) {
909
- txJsonPromise = getTransactionJson(log.transactionHash).then(function (v) {
910
- return v;
911
- });
901
+ if (txJson !== undefined) {
902
+ parseFieldsFromJson(mutTransactionAcc, txFields, txJson);
912
903
  }
913
- var receiptJsonPromise;
914
- var exit$1 = 0;
915
- switch (strategy) {
916
- case "NoRpc" :
917
- case "TransactionOnly" :
918
- receiptJsonPromise = Promise.resolve(undefined);
919
- break;
920
- case "ReceiptOnly" :
921
- case "TransactionAndReceipt" :
922
- exit$1 = 1;
923
- break;
924
-
904
+ if (receiptJson !== undefined) {
905
+ parseFieldsFromJson(mutTransactionAcc, receiptFields, receiptJson);
925
906
  }
926
- if (exit$1 === 1) {
927
- receiptJsonPromise = getReceiptJson(log.transactionHash).then(function (v) {
928
- return v;
929
- });
930
- }
931
- return Promise.all([
932
- txJsonPromise,
933
- receiptJsonPromise
934
- ]).then(function (param) {
935
- var receiptJson = param[1];
936
- var txJson = param[0];
937
- var mutTransactionAcc = {};
938
- setLogFields(mutTransactionAcc, log);
939
- if (txJson !== undefined) {
940
- parseFieldsFromJson(mutTransactionAcc, txFields, txJson);
941
- }
942
- if (receiptJson !== undefined) {
943
- parseFieldsFromJson(mutTransactionAcc, receiptFields, receiptJson);
944
- }
945
- return mutTransactionAcc;
946
- });
947
- })
907
+ return mutTransactionAcc;
908
+ });
909
+ }
948
910
  );
949
911
  fnsCache.set(selectedTransactionFields, fn$1);
950
912
  tmp = fn$1;
@@ -954,106 +916,90 @@ function makeThrowingGetEventTransaction(getTransactionJson, getReceiptJson, low
954
916
  }
955
917
 
956
918
  function make(param) {
957
- var lowercaseAddresses = param.lowercaseAddresses;
958
- var allEventSignatures = param.allEventSignatures;
959
- var eventRouter = param.eventRouter;
960
- var chain = param.chain;
961
- var url = param.url;
962
- var syncConfig = param.syncConfig;
963
- var host = Utils.Url.getHostFromUrl(url);
964
- var urlHost = host !== undefined ? host : Js_exn.raiseError("The RPC url for chain " + String(chain) + " is in incorrect format. The RPC url needs to start with either http:// or https://");
965
- var name = "RPC (" + urlHost + ")";
966
- var getSelectionConfig = memoGetSelectionConfig(chain);
967
- var mutSuggestedBlockIntervals = {};
968
- var client = Rpc.makeClient(url);
969
- var makeTransactionLoader = function () {
970
- return LazyLoader.make((function (transactionHash) {
971
- Prometheus.SourceRequestCount.increment(name, chain, "eth_getTransactionByHash");
972
- return Rest.$$fetch(Rpc.GetTransactionByHash.rawRoute, transactionHash, client);
973
- }), (function (am, exn) {
974
- Logging.error({
975
- err: Utils.prettifyExn(exn),
976
- msg: "Top level promise timeout reached. Please review other errors or warnings in the code. This function will retry in " + String(am._retryDelayMillis / 1000 | 0) + " seconds. It is highly likely that your indexer isn't syncing on one or more chains currently. Also take a look at the \"suggestedFix\" in the metadata of this command",
977
- source: name,
978
- chainId: chain,
979
- metadata: {
980
- asyncTaskName: "transactionLoader: fetching transaction data - `getTransaction` rpc call",
981
- suggestedFix: "This likely means the RPC url you are using is not responding correctly. Please try another RPC endipoint."
982
- }
983
- });
984
- }), undefined, undefined, undefined, undefined);
985
- };
986
- var makeBlockLoader = function () {
987
- return LazyLoader.make((function (blockNumber) {
988
- return getKnownRawBlockWithBackoff(client, name, chain, blockNumber, 1000);
989
- }), (function (am, exn) {
990
- Logging.error({
991
- err: Utils.prettifyExn(exn),
992
- msg: "Top level promise timeout reached. Please review other errors or warnings in the code. This function will retry in " + String(am._retryDelayMillis / 1000 | 0) + " seconds. It is highly likely that your indexer isn't syncing on one or more chains currently. Also take a look at the \"suggestedFix\" in the metadata of this command",
993
- source: name,
994
- chainId: chain,
995
- metadata: {
996
- asyncTaskName: "blockLoader: fetching block data - `getBlock` rpc call",
997
- suggestedFix: "This likely means the RPC url you are using is not responding correctly. Please try another RPC endipoint."
998
- }
999
- });
1000
- }), undefined, undefined, undefined, undefined);
1001
- };
1002
- var makeReceiptLoader = function () {
1003
- return LazyLoader.make((function (transactionHash) {
1004
- Prometheus.SourceRequestCount.increment(name, chain, "eth_getTransactionReceipt");
1005
- return Rest.$$fetch(Rpc.GetTransactionReceipt.rawRoute, transactionHash, client);
1006
- }), (function (am, exn) {
1007
- Logging.error({
1008
- err: Utils.prettifyExn(exn),
1009
- msg: "Top level promise timeout reached. Please review other errors or warnings in the code. This function will retry in " + String(am._retryDelayMillis / 1000 | 0) + " seconds. It is highly likely that your indexer isn't syncing on one or more chains currently. Also take a look at the \"suggestedFix\" in the metadata of this command",
1010
- source: name,
1011
- chainId: chain,
1012
- metadata: {
1013
- asyncTaskName: "receiptLoader: fetching transaction receipt - `getTransactionReceipt` rpc call",
1014
- suggestedFix: "This likely means the RPC url you are using is not responding correctly. Please try another RPC endipoint."
1015
- }
1016
- });
1017
- }), undefined, undefined, undefined, undefined);
1018
- };
1019
- var blockLoader = {
919
+ let lowercaseAddresses = param.lowercaseAddresses;
920
+ let allEventSignatures = param.allEventSignatures;
921
+ let eventRouter = param.eventRouter;
922
+ let chain = param.chain;
923
+ let url = param.url;
924
+ let syncConfig = param.syncConfig;
925
+ let host = Utils.Url.getHostFromUrl(url);
926
+ let urlHost = host !== undefined ? host : Stdlib_JsError.throwWithMessage(`The RPC url for chain ` + String(chain) + ` is in incorrect format. The RPC url needs to start with either http:// or https://`);
927
+ let name = `RPC (` + urlHost + `)`;
928
+ let getSelectionConfig = memoGetSelectionConfig(chain);
929
+ let mutSuggestedBlockIntervals = {};
930
+ let client = Rpc.makeClient(url);
931
+ let makeTransactionLoader = () => LazyLoader.make(transactionHash => {
932
+ Prometheus.SourceRequestCount.increment(name, chain, "eth_getTransactionByHash");
933
+ return Rest.fetch(Rpc.GetTransactionByHash.rawRoute, transactionHash, client);
934
+ }, (am, exn) => Logging.error({
935
+ err: Utils.prettifyExn(exn),
936
+ msg: `Top level promise timeout reached. Please review other errors or warnings in the code. This function will retry in ` + String(am._retryDelayMillis / 1000 | 0) + ` seconds. It is highly likely that your indexer isn't syncing on one or more chains currently. Also take a look at the "suggestedFix" in the metadata of this command`,
937
+ source: name,
938
+ chainId: chain,
939
+ metadata: {
940
+ asyncTaskName: "transactionLoader: fetching transaction data - `getTransaction` rpc call",
941
+ suggestedFix: "This likely means the RPC url you are using is not responding correctly. Please try another RPC endipoint."
942
+ }
943
+ }), undefined, undefined, undefined, undefined);
944
+ let makeBlockLoader = () => LazyLoader.make(blockNumber => getKnownRawBlockWithBackoff(client, name, chain, blockNumber, 1000), (am, exn) => Logging.error({
945
+ err: Utils.prettifyExn(exn),
946
+ msg: `Top level promise timeout reached. Please review other errors or warnings in the code. This function will retry in ` + String(am._retryDelayMillis / 1000 | 0) + ` seconds. It is highly likely that your indexer isn't syncing on one or more chains currently. Also take a look at the "suggestedFix" in the metadata of this command`,
947
+ source: name,
948
+ chainId: chain,
949
+ metadata: {
950
+ asyncTaskName: "blockLoader: fetching block data - `getBlock` rpc call",
951
+ suggestedFix: "This likely means the RPC url you are using is not responding correctly. Please try another RPC endipoint."
952
+ }
953
+ }), undefined, undefined, undefined, undefined);
954
+ let makeReceiptLoader = () => LazyLoader.make(transactionHash => {
955
+ Prometheus.SourceRequestCount.increment(name, chain, "eth_getTransactionReceipt");
956
+ return Rest.fetch(Rpc.GetTransactionReceipt.rawRoute, transactionHash, client);
957
+ }, (am, exn) => Logging.error({
958
+ err: Utils.prettifyExn(exn),
959
+ msg: `Top level promise timeout reached. Please review other errors or warnings in the code. This function will retry in ` + String(am._retryDelayMillis / 1000 | 0) + ` seconds. It is highly likely that your indexer isn't syncing on one or more chains currently. Also take a look at the "suggestedFix" in the metadata of this command`,
960
+ source: name,
961
+ chainId: chain,
962
+ metadata: {
963
+ asyncTaskName: "receiptLoader: fetching transaction receipt - `getTransactionReceipt` rpc call",
964
+ suggestedFix: "This likely means the RPC url you are using is not responding correctly. Please try another RPC endipoint."
965
+ }
966
+ }), undefined, undefined, undefined, undefined);
967
+ let blockLoader = {
1020
968
  contents: makeBlockLoader()
1021
969
  };
1022
- var transactionLoader = {
970
+ let transactionLoader = {
1023
971
  contents: makeTransactionLoader()
1024
972
  };
1025
- var receiptLoader = {
973
+ let receiptLoader = {
1026
974
  contents: makeReceiptLoader()
1027
975
  };
1028
- var getEventBlockOrThrow = makeThrowingGetEventBlock((function (blockNumber) {
1029
- return LazyLoader.get(blockLoader.contents, blockNumber);
1030
- }), lowercaseAddresses);
1031
- var getEventTransactionOrThrow = makeThrowingGetEventTransaction((async function (transactionHash) {
1032
- var json = await LazyLoader.get(transactionLoader.contents, transactionHash);
1033
- if (json !== undefined) {
1034
- return json;
1035
- } else {
1036
- return Js_exn.raiseError("Transaction not found for hash: " + transactionHash);
1037
- }
1038
- }), (async function (transactionHash) {
1039
- var json = await LazyLoader.get(receiptLoader.contents, transactionHash);
1040
- if (json !== undefined) {
1041
- return json;
1042
- } else {
1043
- return Js_exn.raiseError("Transaction receipt not found for hash: " + transactionHash);
1044
- }
1045
- }), lowercaseAddresses);
1046
- var convertLogToHyperSyncEvent = function (log) {
1047
- var hyperSyncLog_removed = log.removed;
1048
- var hyperSyncLog_logIndex = log.logIndex;
1049
- var hyperSyncLog_transactionIndex = log.transactionIndex;
1050
- var hyperSyncLog_transactionHash = log.transactionHash;
1051
- var hyperSyncLog_blockHash = log.blockHash;
1052
- var hyperSyncLog_blockNumber = log.blockNumber;
1053
- var hyperSyncLog_address = Caml_option.some(log.address);
1054
- var hyperSyncLog_data = log.data;
1055
- var hyperSyncLog_topics = log.topics;
1056
- var hyperSyncLog = {
976
+ let getEventBlockOrThrow = makeThrowingGetEventBlock(blockNumber => LazyLoader.get(blockLoader.contents, blockNumber), lowercaseAddresses);
977
+ let getEventTransactionOrThrow = makeThrowingGetEventTransaction(async transactionHash => {
978
+ let json = await LazyLoader.get(transactionLoader.contents, transactionHash);
979
+ if (json !== undefined) {
980
+ return json;
981
+ } else {
982
+ return Stdlib_JsError.throwWithMessage(`Transaction not found for hash: ` + transactionHash);
983
+ }
984
+ }, async transactionHash => {
985
+ let json = await LazyLoader.get(receiptLoader.contents, transactionHash);
986
+ if (json !== undefined) {
987
+ return json;
988
+ } else {
989
+ return Stdlib_JsError.throwWithMessage(`Transaction receipt not found for hash: ` + transactionHash);
990
+ }
991
+ }, lowercaseAddresses);
992
+ let convertLogToHyperSyncEvent = log => {
993
+ let hyperSyncLog_removed = log.removed;
994
+ let hyperSyncLog_logIndex = log.logIndex;
995
+ let hyperSyncLog_transactionIndex = log.transactionIndex;
996
+ let hyperSyncLog_transactionHash = log.transactionHash;
997
+ let hyperSyncLog_blockHash = log.blockHash;
998
+ let hyperSyncLog_blockNumber = log.blockNumber;
999
+ let hyperSyncLog_address = Primitive_option.some(log.address);
1000
+ let hyperSyncLog_data = log.data;
1001
+ let hyperSyncLog_topics = log.topics;
1002
+ let hyperSyncLog = {
1057
1003
  removed: hyperSyncLog_removed,
1058
1004
  logIndex: hyperSyncLog_logIndex,
1059
1005
  transactionIndex: hyperSyncLog_transactionIndex,
@@ -1065,222 +1011,202 @@ function make(param) {
1065
1011
  topics: hyperSyncLog_topics
1066
1012
  };
1067
1013
  return {
1068
- log: hyperSyncLog
1069
- };
1014
+ log: hyperSyncLog
1015
+ };
1070
1016
  };
1071
- var hscDecoder = {
1017
+ let hscDecoder = {
1072
1018
  contents: undefined
1073
1019
  };
1074
- var getHscDecoder = function () {
1075
- var decoder = hscDecoder.contents;
1020
+ let getHscDecoder = () => {
1021
+ let decoder = hscDecoder.contents;
1076
1022
  if (decoder !== undefined) {
1077
1023
  return decoder;
1078
1024
  } else {
1079
1025
  return HyperSyncClient.Decoder.fromSignatures(allEventSignatures);
1080
1026
  }
1081
1027
  };
1082
- var getItemsOrThrow = async function (fromBlock, toBlock, addressesByContractName, indexingContracts, knownHeight, partitionId, selection, param, param$1) {
1083
- var startFetchingBatchTimeRef = Hrtime.makeTimer();
1084
- var maxSuggestedBlockInterval = mutSuggestedBlockIntervals[maxSuggestedBlockIntervalKey];
1085
- var suggestedBlockInterval = maxSuggestedBlockInterval !== undefined ? maxSuggestedBlockInterval : Belt_Option.getWithDefault(mutSuggestedBlockIntervals[partitionId], syncConfig.initialBlockInterval);
1086
- var toBlock$1 = toBlock !== undefined && toBlock < knownHeight ? toBlock : knownHeight;
1087
- var suggestedToBlock = Caml.int_max(Caml.int_min((fromBlock + suggestedBlockInterval | 0) - 1 | 0, toBlock$1), fromBlock);
1088
- var firstBlockParentPromise = fromBlock > 0 ? LazyLoader.get(blockLoader.contents, fromBlock - 1 | 0).then(function (json) {
1089
- return parseBlockInfo(json);
1090
- }) : Promise.resolve(undefined);
1091
- var match = getSelectionConfig(selection);
1092
- var match$1 = match.getLogSelectionOrThrow(addressesByContractName);
1093
- var match$2 = await getNextPage(fromBlock, suggestedToBlock, match$1.addresses, match$1.topicQuery, (function (blockNumber) {
1094
- return LazyLoader.get(blockLoader.contents, blockNumber).then(parseBlockInfo);
1095
- }), syncConfig, client, mutSuggestedBlockIntervals, partitionId, name, chain);
1096
- var latestFetchedBlockInfo = match$2.latestFetchedBlockInfo;
1097
- var logs = match$2.logs;
1098
- var executedBlockInterval = (suggestedToBlock - fromBlock | 0) + 1 | 0;
1028
+ let getItemsOrThrow = async (fromBlock, toBlock, addressesByContractName, indexingAddresses, knownHeight, partitionId, selection, param, param$1) => {
1029
+ let startFetchingBatchTimeRef = Hrtime.makeTimer();
1030
+ let maxSuggestedBlockInterval = mutSuggestedBlockIntervals[maxSuggestedBlockIntervalKey];
1031
+ let suggestedBlockInterval = maxSuggestedBlockInterval !== undefined ? maxSuggestedBlockInterval : Belt_Option.getWithDefault(mutSuggestedBlockIntervals[partitionId], syncConfig.initialBlockInterval);
1032
+ let toBlock$1 = toBlock !== undefined ? Primitive_int.min(toBlock, knownHeight) : knownHeight;
1033
+ let suggestedToBlock = Primitive_int.max(Primitive_int.min((fromBlock + suggestedBlockInterval | 0) - 1 | 0, toBlock$1), fromBlock);
1034
+ let firstBlockParentPromise = fromBlock > 0 ? LazyLoader.get(blockLoader.contents, fromBlock - 1 | 0).then(json => parseBlockInfo(json)) : Promise.resolve(undefined);
1035
+ let match = getSelectionConfig(selection);
1036
+ let match$1 = match.getLogSelectionOrThrow(addressesByContractName);
1037
+ let match$2 = await getNextPage(fromBlock, suggestedToBlock, match$1.addresses, match$1.topicQuery, blockNumber => LazyLoader.get(blockLoader.contents, blockNumber).then(parseBlockInfo), syncConfig, client, mutSuggestedBlockIntervals, partitionId, name, chain);
1038
+ let latestFetchedBlockInfo = match$2.latestFetchedBlockInfo;
1039
+ let logs = match$2.logs;
1040
+ let executedBlockInterval = (suggestedToBlock - fromBlock | 0) + 1 | 0;
1099
1041
  if (executedBlockInterval >= suggestedBlockInterval && !Utils.Dict.has(mutSuggestedBlockIntervals, maxSuggestedBlockIntervalKey)) {
1100
- mutSuggestedBlockIntervals[partitionId] = Caml.int_min(executedBlockInterval + syncConfig.accelerationAdditive | 0, syncConfig.intervalCeiling);
1042
+ mutSuggestedBlockIntervals[partitionId] = Primitive_int.min(executedBlockInterval + syncConfig.accelerationAdditive | 0, syncConfig.intervalCeiling);
1101
1043
  }
1102
- var hyperSyncEvents = Belt_Array.map(logs, convertLogToHyperSyncEvent);
1103
- var parsedEvents;
1044
+ let hyperSyncEvents = Belt_Array.map(logs, convertLogToHyperSyncEvent);
1045
+ let parsedEvents;
1104
1046
  try {
1105
1047
  parsedEvents = await getHscDecoder().decodeEvents(hyperSyncEvents);
1106
- }
1107
- catch (raw_exn){
1108
- var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
1048
+ } catch (raw_exn) {
1049
+ let exn = Primitive_exceptions.internalToException(raw_exn);
1109
1050
  throw {
1110
- RE_EXN_ID: Source.GetItemsError,
1111
- _1: {
1112
- TAG: "FailedGettingItems",
1113
- exn: exn,
1114
- attemptedToBlock: toBlock$1,
1115
- retry: {
1116
- TAG: "ImpossibleForTheQuery",
1117
- message: "Failed to parse events using hypersync client decoder. Please double-check your ABI."
1118
- }
1119
- },
1120
- Error: new Error()
1121
- };
1051
+ RE_EXN_ID: Source.GetItemsError,
1052
+ _1: {
1053
+ TAG: "FailedGettingItems",
1054
+ exn: exn,
1055
+ attemptedToBlock: toBlock$1,
1056
+ retry: {
1057
+ TAG: "ImpossibleForTheQuery",
1058
+ message: "Failed to parse events using hypersync client decoder. Please double-check your ABI."
1059
+ }
1060
+ },
1061
+ Error: new Error()
1062
+ };
1122
1063
  }
1123
- var parsedQueueItems = await Promise.all(Belt_Array.keepMap(Belt_Array.zip(logs, parsedEvents), (function (param) {
1124
- var maybeDecodedEvent = param[1];
1125
- var log = param[0];
1126
- var topic0 = Belt_Option.getWithDefault(Belt_Array.get(log.topics, 0), "0x0");
1127
- var routedAddress = lowercaseAddresses ? Address.Evm.fromAddressLowercaseOrThrow(log.address) : Address.Evm.fromAddressOrThrow(log.address);
1128
- var eventConfig = EventRouter.get(eventRouter, EventRouter.getEvmEventId(topic0, log.topics.length), routedAddress, log.blockNumber, indexingContracts);
1129
- if (eventConfig !== undefined && !(maybeDecodedEvent === null || maybeDecodedEvent === undefined)) {
1130
- return Caml_option.some((async function () {
1131
- var match;
1132
- try {
1133
- match = await Promise.all([
1134
- getEventBlockOrThrow(log, eventConfig.selectedBlockFields),
1135
- getEventTransactionOrThrow(log, eventConfig.selectedTransactionFields)
1136
- ]);
1137
- }
1138
- catch (raw_exn){
1139
- var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
1140
- throw {
1141
- RE_EXN_ID: Source.GetItemsError,
1142
- _1: {
1143
- TAG: "FailedGettingFieldSelection",
1144
- exn: exn,
1145
- blockNumber: log.blockNumber,
1146
- logIndex: log.logIndex,
1147
- message: "Failed getting selected fields. Please double-check your RPC provider returns correct data."
1148
- },
1149
- Error: new Error()
1150
- };
1151
- }
1152
- var block = match[0];
1153
- return {
1154
- kind: 0,
1155
- eventConfig: eventConfig,
1156
- timestamp: block.timestamp,
1157
- chain: chain,
1158
- blockNumber: block.number,
1159
- logIndex: log.logIndex,
1160
- event: {
1161
- contractName: eventConfig.contractName,
1162
- eventName: eventConfig.name,
1163
- params: eventConfig.convertHyperSyncEventArgs(maybeDecodedEvent),
1164
- chainId: chain,
1165
- srcAddress: routedAddress,
1166
- logIndex: log.logIndex,
1167
- transaction: match[1],
1168
- block: block
1169
- }
1170
- };
1171
- })());
1172
- }
1173
-
1174
- })));
1175
- var optFirstBlockParent = await firstBlockParentPromise;
1176
- var totalTimeElapsed = Hrtime.toSecondsFloat(Hrtime.timeSince(startFetchingBatchTimeRef));
1177
- var reorgGuard_rangeLastBlock = {
1064
+ let parsedQueueItems = await Promise.all(Stdlib_Array.filterMap(Stdlib_Array.zip(logs, parsedEvents), param => {
1065
+ let maybeDecodedEvent = param[1];
1066
+ let log = param[0];
1067
+ let topic0 = Stdlib_Option.getOr(log.topics[0], "0x0");
1068
+ let routedAddress = lowercaseAddresses ? Address.Evm.fromAddressLowercaseOrThrow(log.address) : Address.Evm.fromAddressOrThrow(log.address);
1069
+ let eventConfig = EventRouter.get(eventRouter, EventRouter.getEvmEventId(topic0, log.topics.length), routedAddress, log.blockNumber, indexingAddresses);
1070
+ if (eventConfig !== undefined && maybeDecodedEvent !== null && maybeDecodedEvent !== undefined) {
1071
+ return (async () => {
1072
+ let match;
1073
+ try {
1074
+ match = await Promise.all([
1075
+ getEventBlockOrThrow(log, eventConfig.selectedBlockFields),
1076
+ getEventTransactionOrThrow(log, eventConfig.selectedTransactionFields)
1077
+ ]);
1078
+ } catch (raw_exn) {
1079
+ let exn = Primitive_exceptions.internalToException(raw_exn);
1080
+ throw {
1081
+ RE_EXN_ID: Source.GetItemsError,
1082
+ _1: {
1083
+ TAG: "FailedGettingFieldSelection",
1084
+ exn: exn,
1085
+ blockNumber: log.blockNumber,
1086
+ logIndex: log.logIndex,
1087
+ message: "Failed getting selected fields. Please double-check your RPC provider returns correct data."
1088
+ },
1089
+ Error: new Error()
1090
+ };
1091
+ }
1092
+ let block = match[0];
1093
+ return {
1094
+ kind: 0,
1095
+ eventConfig: eventConfig,
1096
+ timestamp: block.timestamp,
1097
+ chain: chain,
1098
+ blockNumber: block.number,
1099
+ logIndex: log.logIndex,
1100
+ event: {
1101
+ contractName: eventConfig.contractName,
1102
+ eventName: eventConfig.name,
1103
+ params: eventConfig.convertHyperSyncEventArgs(maybeDecodedEvent),
1104
+ chainId: chain,
1105
+ srcAddress: routedAddress,
1106
+ logIndex: log.logIndex,
1107
+ transaction: match[1],
1108
+ block: block
1109
+ }
1110
+ };
1111
+ })();
1112
+ }
1113
+ }));
1114
+ let optFirstBlockParent = await firstBlockParentPromise;
1115
+ let totalTimeElapsed = Hrtime.toSecondsFloat(Hrtime.timeSince(startFetchingBatchTimeRef));
1116
+ let reorgGuard_rangeLastBlock = {
1178
1117
  blockHash: latestFetchedBlockInfo.hash,
1179
1118
  blockNumber: latestFetchedBlockInfo.number
1180
1119
  };
1181
- var reorgGuard_prevRangeLastBlock = Belt_Option.map(optFirstBlockParent, (function (b) {
1182
- return {
1183
- blockHash: b.hash,
1184
- blockNumber: b.number
1185
- };
1186
- }));
1187
- var reorgGuard = {
1120
+ let reorgGuard_prevRangeLastBlock = Stdlib_Option.map(optFirstBlockParent, b => ({
1121
+ blockHash: b.hash,
1122
+ blockNumber: b.number
1123
+ }));
1124
+ let reorgGuard = {
1188
1125
  rangeLastBlock: reorgGuard_rangeLastBlock,
1189
1126
  prevRangeLastBlock: reorgGuard_prevRangeLastBlock
1190
1127
  };
1191
1128
  return {
1192
- knownHeight: knownHeight,
1193
- reorgGuard: reorgGuard,
1194
- parsedQueueItems: parsedQueueItems,
1195
- fromBlockQueried: fromBlock,
1196
- latestFetchedBlockNumber: latestFetchedBlockInfo.number,
1197
- latestFetchedBlockTimestamp: latestFetchedBlockInfo.timestamp,
1198
- stats: {
1199
- "total time elapsed (s)": totalTimeElapsed
1200
- }
1201
- };
1129
+ knownHeight: knownHeight,
1130
+ reorgGuard: reorgGuard,
1131
+ parsedQueueItems: parsedQueueItems,
1132
+ fromBlockQueried: fromBlock,
1133
+ latestFetchedBlockNumber: latestFetchedBlockInfo.number,
1134
+ latestFetchedBlockTimestamp: latestFetchedBlockInfo.timestamp,
1135
+ stats: {
1136
+ "total time elapsed (s)": totalTimeElapsed
1137
+ }
1138
+ };
1202
1139
  };
1203
- var getBlockHashes = function (blockNumbers, _currentlyUnusedLogger) {
1140
+ let getBlockHashes = (blockNumbers, _currentlyUnusedLogger) => {
1204
1141
  blockLoader.contents = makeBlockLoader();
1205
1142
  transactionLoader.contents = makeTransactionLoader();
1206
1143
  receiptLoader.contents = makeReceiptLoader();
1207
- return $$Promise.$$catch(Promise.all(Belt_Array.map(blockNumbers, (function (blockNum) {
1208
- return LazyLoader.get(blockLoader.contents, blockNum);
1209
- }))).then(function (rawBlocks) {
1210
- return {
1211
- TAG: "Ok",
1212
- _0: Belt_Array.map(rawBlocks, (function (json) {
1213
- var b = parseBlockInfo(json);
1214
- return {
1215
- blockHash: b.hash,
1216
- blockNumber: b.number,
1217
- blockTimestamp: b.timestamp
1218
- };
1219
- }))
1220
- };
1221
- }), (function (exn) {
1222
- return Promise.resolve({
1223
- TAG: "Error",
1224
- _0: exn
1225
- });
1226
- }));
1144
+ return Stdlib_Promise.$$catch(Promise.all(blockNumbers.map(blockNum => LazyLoader.get(blockLoader.contents, blockNum))).then(rawBlocks => ({
1145
+ TAG: "Ok",
1146
+ _0: rawBlocks.map(json => {
1147
+ let b = parseBlockInfo(json);
1148
+ return {
1149
+ blockHash: b.hash,
1150
+ blockNumber: b.number,
1151
+ blockTimestamp: b.timestamp
1152
+ };
1153
+ })
1154
+ })), exn => Promise.resolve({
1155
+ TAG: "Error",
1156
+ _0: exn
1157
+ }));
1227
1158
  };
1228
- var createHeightSubscription = Belt_Option.map(param.ws, (function (wsUrl) {
1229
- return function (onHeight) {
1230
- return RpcWebSocketHeightStream.subscribe(wsUrl, chain, onHeight);
1231
- };
1232
- }));
1159
+ let createHeightSubscription = Belt_Option.map(param.ws, wsUrl => (onHeight => RpcWebSocketHeightStream.subscribe(wsUrl, chain, onHeight)));
1233
1160
  return {
1234
- name: name,
1235
- sourceFor: param.sourceFor,
1236
- chain: chain,
1237
- poweredByHyperSync: false,
1238
- pollingInterval: syncConfig.pollingInterval,
1239
- getBlockHashes: getBlockHashes,
1240
- getHeightOrThrow: (async function () {
1241
- var timerRef = Hrtime.makeTimer();
1242
- var height;
1243
- try {
1244
- height = await Rest.$$fetch(Rpc.GetBlockHeight.route, undefined, client);
1245
- }
1246
- catch (exn){
1247
- var seconds = Hrtime.toSecondsFloat(Hrtime.timeSince(timerRef));
1248
- Prometheus.SourceRequestCount.increment(name, chain, "eth_blockNumber");
1249
- Prometheus.SourceRequestCount.addSeconds(name, chain, "eth_blockNumber", seconds);
1250
- throw exn;
1251
- }
1252
- var seconds$1 = Hrtime.toSecondsFloat(Hrtime.timeSince(timerRef));
1253
- Prometheus.SourceRequestCount.increment(name, chain, "eth_blockNumber");
1254
- Prometheus.SourceRequestCount.addSeconds(name, chain, "eth_blockNumber", seconds$1);
1255
- return height;
1256
- }),
1257
- getItemsOrThrow: getItemsOrThrow,
1258
- createHeightSubscription: createHeightSubscription
1259
- };
1161
+ name: name,
1162
+ sourceFor: param.sourceFor,
1163
+ chain: chain,
1164
+ poweredByHyperSync: false,
1165
+ pollingInterval: syncConfig.pollingInterval,
1166
+ getBlockHashes: getBlockHashes,
1167
+ getHeightOrThrow: async () => {
1168
+ let timerRef = Hrtime.makeTimer();
1169
+ let height;
1170
+ try {
1171
+ height = await Rest.fetch(Rpc.GetBlockHeight.route, undefined, client);
1172
+ } catch (exn) {
1173
+ let seconds = Hrtime.toSecondsFloat(Hrtime.timeSince(timerRef));
1174
+ Prometheus.SourceRequestCount.increment(name, chain, "eth_blockNumber");
1175
+ Prometheus.SourceRequestCount.addSeconds(name, chain, "eth_blockNumber", seconds);
1176
+ throw exn;
1177
+ }
1178
+ let seconds$1 = Hrtime.toSecondsFloat(Hrtime.timeSince(timerRef));
1179
+ Prometheus.SourceRequestCount.increment(name, chain, "eth_blockNumber");
1180
+ Prometheus.SourceRequestCount.addSeconds(name, chain, "eth_blockNumber", seconds$1);
1181
+ return height;
1182
+ },
1183
+ getItemsOrThrow: getItemsOrThrow,
1184
+ createHeightSubscription: createHeightSubscription
1185
+ };
1260
1186
  }
1261
1187
 
1262
1188
  export {
1263
- QueryTimout ,
1264
- getKnownRawBlock ,
1265
- parseBlockInfo ,
1266
- getKnownRawBlockWithBackoff ,
1267
- getSuggestedBlockIntervalFromExn ,
1268
- maxSuggestedBlockIntervalKey ,
1269
- getNextPage ,
1270
- getSelectionConfig ,
1271
- memoGetSelectionConfig ,
1272
- lowercaseAddressSchema ,
1273
- checksumAddressSchema ,
1274
- makeBlockFieldRegistry ,
1275
- blockFieldRegistryLowercase ,
1276
- blockFieldRegistryChecksum ,
1277
- parseBlockFieldsFromJson ,
1278
- makeThrowingGetEventBlock ,
1279
- makeFieldRegistry ,
1280
- fieldRegistryLowercase ,
1281
- fieldRegistryChecksum ,
1282
- parseFieldsFromJson ,
1283
- makeThrowingGetEventTransaction ,
1284
- make ,
1189
+ QueryTimout,
1190
+ getKnownRawBlock,
1191
+ parseBlockInfo,
1192
+ getKnownRawBlockWithBackoff,
1193
+ getSuggestedBlockIntervalFromExn,
1194
+ maxSuggestedBlockIntervalKey,
1195
+ getNextPage,
1196
+ getSelectionConfig,
1197
+ memoGetSelectionConfig,
1198
+ lowercaseAddressSchema,
1199
+ checksumAddressSchema,
1200
+ makeBlockFieldRegistry,
1201
+ blockFieldRegistryLowercase,
1202
+ blockFieldRegistryChecksum,
1203
+ parseBlockFieldsFromJson,
1204
+ makeThrowingGetEventBlock,
1205
+ makeFieldRegistry,
1206
+ fieldRegistryLowercase,
1207
+ fieldRegistryChecksum,
1208
+ parseFieldsFromJson,
1209
+ makeThrowingGetEventTransaction,
1210
+ make,
1285
1211
  }
1286
1212
  /* lowercaseAddressSchema Not a pure module */