envio 3.0.0-alpha.2 → 3.0.0-alpha.21

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 (184) hide show
  1. package/README.md +164 -30
  2. package/bin.mjs +49 -0
  3. package/evm.schema.json +79 -169
  4. package/fuel.schema.json +50 -21
  5. package/index.d.ts +578 -1
  6. package/index.js +4 -0
  7. package/package.json +47 -31
  8. package/rescript.json +4 -1
  9. package/src/Batch.res +11 -8
  10. package/src/Batch.res.mjs +11 -9
  11. package/src/ChainFetcher.res +531 -0
  12. package/src/ChainFetcher.res.mjs +339 -0
  13. package/src/ChainManager.res +190 -0
  14. package/src/ChainManager.res.mjs +166 -0
  15. package/src/Change.res +3 -3
  16. package/src/Config.gen.ts +19 -0
  17. package/src/Config.res +725 -25
  18. package/src/Config.res.mjs +692 -26
  19. package/src/{Indexer.res → Ctx.res} +1 -1
  20. package/src/Ecosystem.res +9 -124
  21. package/src/Ecosystem.res.mjs +19 -160
  22. package/src/Env.res +33 -73
  23. package/src/Env.res.mjs +29 -85
  24. package/src/Envio.gen.ts +3 -1
  25. package/src/Envio.res +77 -9
  26. package/src/Envio.res.mjs +39 -1
  27. package/src/EventConfigBuilder.res +408 -0
  28. package/src/EventConfigBuilder.res.mjs +376 -0
  29. package/src/EventProcessing.res +469 -0
  30. package/src/EventProcessing.res.mjs +337 -0
  31. package/src/EvmTypes.gen.ts +6 -0
  32. package/src/EvmTypes.res +1 -0
  33. package/src/FetchState.res +1256 -639
  34. package/src/FetchState.res.mjs +1135 -612
  35. package/src/GlobalState.res +1224 -0
  36. package/src/GlobalState.res.mjs +1291 -0
  37. package/src/GlobalStateManager.res +68 -0
  38. package/src/GlobalStateManager.res.mjs +75 -0
  39. package/src/GlobalStateManager.resi +7 -0
  40. package/src/HandlerLoader.res +89 -0
  41. package/src/HandlerLoader.res.mjs +79 -0
  42. package/src/HandlerRegister.res +357 -0
  43. package/src/HandlerRegister.res.mjs +299 -0
  44. package/src/HandlerRegister.resi +30 -0
  45. package/src/Hasura.res +111 -175
  46. package/src/Hasura.res.mjs +88 -150
  47. package/src/InMemoryStore.res +1 -1
  48. package/src/InMemoryStore.res.mjs +3 -3
  49. package/src/InMemoryTable.res +1 -1
  50. package/src/InMemoryTable.res.mjs +1 -1
  51. package/src/Internal.gen.ts +6 -0
  52. package/src/Internal.res +265 -12
  53. package/src/Internal.res.mjs +115 -1
  54. package/src/LoadLayer.res +444 -0
  55. package/src/LoadLayer.res.mjs +296 -0
  56. package/src/LoadLayer.resi +32 -0
  57. package/src/LogSelection.res +33 -27
  58. package/src/LogSelection.res.mjs +6 -0
  59. package/src/Logging.res +21 -7
  60. package/src/Logging.res.mjs +16 -8
  61. package/src/Main.res +390 -0
  62. package/src/Main.res.mjs +341 -0
  63. package/src/Persistence.res +7 -21
  64. package/src/Persistence.res.mjs +3 -3
  65. package/src/PgStorage.gen.ts +10 -0
  66. package/src/PgStorage.res +116 -69
  67. package/src/PgStorage.res.d.mts +5 -0
  68. package/src/PgStorage.res.mjs +93 -50
  69. package/src/Prometheus.res +294 -224
  70. package/src/Prometheus.res.mjs +353 -340
  71. package/src/ReorgDetection.res +6 -10
  72. package/src/ReorgDetection.res.mjs +6 -6
  73. package/src/SafeCheckpointTracking.res +4 -4
  74. package/src/SafeCheckpointTracking.res.mjs +2 -2
  75. package/src/SimulateItems.res +353 -0
  76. package/src/SimulateItems.res.mjs +335 -0
  77. package/src/Sink.res +4 -2
  78. package/src/Sink.res.mjs +2 -1
  79. package/src/TableIndices.res +0 -1
  80. package/src/TestIndexer.res +913 -0
  81. package/src/TestIndexer.res.mjs +698 -0
  82. package/src/TestIndexerProxyStorage.res +205 -0
  83. package/src/TestIndexerProxyStorage.res.mjs +151 -0
  84. package/src/TopicFilter.res +1 -1
  85. package/src/Types.ts +1 -1
  86. package/src/UserContext.res +424 -0
  87. package/src/UserContext.res.mjs +279 -0
  88. package/src/Utils.res +97 -26
  89. package/src/Utils.res.mjs +91 -44
  90. package/src/bindings/BigInt.res +10 -0
  91. package/src/bindings/BigInt.res.mjs +15 -0
  92. package/src/bindings/ClickHouse.res +120 -23
  93. package/src/bindings/ClickHouse.res.mjs +118 -28
  94. package/src/bindings/DateFns.res +74 -0
  95. package/src/bindings/DateFns.res.mjs +22 -0
  96. package/src/bindings/EventSource.res +11 -2
  97. package/src/bindings/EventSource.res.mjs +8 -1
  98. package/src/bindings/Express.res +1 -0
  99. package/src/bindings/Hrtime.res +14 -1
  100. package/src/bindings/Hrtime.res.mjs +22 -2
  101. package/src/bindings/Hrtime.resi +4 -0
  102. package/src/bindings/Lodash.res +0 -1
  103. package/src/bindings/NodeJs.res +49 -3
  104. package/src/bindings/NodeJs.res.mjs +11 -3
  105. package/src/bindings/Pino.res +24 -10
  106. package/src/bindings/Pino.res.mjs +14 -8
  107. package/src/bindings/Postgres.gen.ts +8 -0
  108. package/src/bindings/Postgres.res +5 -1
  109. package/src/bindings/Postgres.res.d.mts +5 -0
  110. package/src/bindings/PromClient.res +0 -10
  111. package/src/bindings/PromClient.res.mjs +0 -3
  112. package/src/bindings/Vitest.res +144 -0
  113. package/src/bindings/Vitest.res.mjs +9 -0
  114. package/src/bindings/WebSocket.res +27 -0
  115. package/src/bindings/WebSocket.res.mjs +2 -0
  116. package/src/bindings/Yargs.res +8 -0
  117. package/src/bindings/Yargs.res.mjs +2 -0
  118. package/src/db/EntityHistory.res +7 -7
  119. package/src/db/EntityHistory.res.mjs +9 -9
  120. package/src/db/InternalTable.res +59 -111
  121. package/src/db/InternalTable.res.mjs +73 -104
  122. package/src/db/Table.res +27 -8
  123. package/src/db/Table.res.mjs +25 -14
  124. package/src/sources/Evm.res +84 -0
  125. package/src/sources/Evm.res.mjs +105 -0
  126. package/src/sources/EvmChain.res +94 -0
  127. package/src/sources/EvmChain.res.mjs +60 -0
  128. package/src/sources/Fuel.res +19 -34
  129. package/src/sources/Fuel.res.mjs +34 -16
  130. package/src/sources/FuelSDK.res +38 -0
  131. package/src/sources/FuelSDK.res.mjs +29 -0
  132. package/src/sources/HyperFuel.res +2 -2
  133. package/src/sources/HyperFuel.resi +1 -1
  134. package/src/sources/HyperFuelClient.res +2 -2
  135. package/src/sources/HyperFuelSource.res +35 -13
  136. package/src/sources/HyperFuelSource.res.mjs +26 -16
  137. package/src/sources/HyperSync.res +61 -60
  138. package/src/sources/HyperSync.res.mjs +53 -67
  139. package/src/sources/HyperSync.resi +6 -4
  140. package/src/sources/HyperSyncClient.res +29 -2
  141. package/src/sources/HyperSyncClient.res.mjs +9 -0
  142. package/src/sources/HyperSyncHeightStream.res +76 -118
  143. package/src/sources/HyperSyncHeightStream.res.mjs +68 -75
  144. package/src/sources/HyperSyncSource.res +122 -143
  145. package/src/sources/HyperSyncSource.res.mjs +106 -121
  146. package/src/sources/Rpc.res +86 -14
  147. package/src/sources/Rpc.res.mjs +101 -9
  148. package/src/sources/RpcSource.res +731 -364
  149. package/src/sources/RpcSource.res.mjs +845 -410
  150. package/src/sources/RpcWebSocketHeightStream.res +181 -0
  151. package/src/sources/RpcWebSocketHeightStream.res.mjs +196 -0
  152. package/src/sources/SimulateSource.res +59 -0
  153. package/src/sources/SimulateSource.res.mjs +50 -0
  154. package/src/sources/Source.res +7 -5
  155. package/src/sources/SourceManager.res +358 -221
  156. package/src/sources/SourceManager.res.mjs +346 -171
  157. package/src/sources/SourceManager.resi +17 -6
  158. package/src/sources/Svm.res +81 -0
  159. package/src/sources/Svm.res.mjs +90 -0
  160. package/src/tui/Tui.res +247 -0
  161. package/src/tui/Tui.res.mjs +337 -0
  162. package/src/tui/bindings/Ink.res +371 -0
  163. package/src/tui/bindings/Ink.res.mjs +72 -0
  164. package/src/tui/bindings/Style.res +123 -0
  165. package/src/tui/bindings/Style.res.mjs +2 -0
  166. package/src/tui/components/BufferedProgressBar.res +40 -0
  167. package/src/tui/components/BufferedProgressBar.res.mjs +57 -0
  168. package/src/tui/components/CustomHooks.res +122 -0
  169. package/src/tui/components/CustomHooks.res.mjs +179 -0
  170. package/src/tui/components/Messages.res +41 -0
  171. package/src/tui/components/Messages.res.mjs +75 -0
  172. package/src/tui/components/SyncETA.res +174 -0
  173. package/src/tui/components/SyncETA.res.mjs +263 -0
  174. package/src/tui/components/TuiData.res +47 -0
  175. package/src/tui/components/TuiData.res.mjs +34 -0
  176. package/svm.schema.json +112 -0
  177. package/bin.js +0 -48
  178. package/src/EventRegister.res +0 -241
  179. package/src/EventRegister.res.mjs +0 -240
  180. package/src/EventRegister.resi +0 -30
  181. package/src/bindings/Ethers.gen.ts +0 -14
  182. package/src/bindings/Ethers.res +0 -204
  183. package/src/bindings/Ethers.res.mjs +0 -130
  184. /package/src/{Indexer.res.mjs → Ctx.res.mjs} +0 -0
@@ -4,9 +4,7 @@ import * as Rpc from "./Rpc.res.mjs";
4
4
  import * as Caml from "rescript/lib/es6/caml.js";
5
5
  import * as Rest from "../vendored/Rest.res.mjs";
6
6
  import * as Time from "../Time.res.mjs";
7
- import * as Viem from "../bindings/Viem.res.mjs";
8
7
  import * as Utils from "../Utils.res.mjs";
9
- import * as Ethers from "../bindings/Ethers.res.mjs";
10
8
  import * as Hrtime from "../bindings/Hrtime.res.mjs";
11
9
  import * as Js_exn from "rescript/lib/es6/js_exn.js";
12
10
  import * as Source from "./Source.res.mjs";
@@ -14,9 +12,11 @@ import * as Address from "../Address.res.mjs";
14
12
  import * as Logging from "../Logging.res.mjs";
15
13
  import * as $$Promise from "../bindings/Promise.res.mjs";
16
14
  import * as Belt_Int from "rescript/lib/es6/belt_Int.js";
15
+ import * as Internal from "../Internal.res.mjs";
17
16
  import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
18
17
  import * as FetchState from "../FetchState.res.mjs";
19
18
  import * as LazyLoader from "../LazyLoader.res.mjs";
19
+ import * as Prometheus from "../Prometheus.res.mjs";
20
20
  import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
21
21
  import * as Caml_option from "rescript/lib/es6/caml_option.js";
22
22
  import * as EventRouter from "./EventRouter.res.mjs";
@@ -26,54 +26,56 @@ import * as HyperSyncClient from "./HyperSyncClient.res.mjs";
26
26
  import * as Caml_splice_call from "rescript/lib/es6/caml_splice_call.js";
27
27
  import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
28
28
  import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
29
+ import * as RpcWebSocketHeightStream from "./RpcWebSocketHeightStream.res.mjs";
29
30
 
30
31
  var QueryTimout = /* @__PURE__ */Caml_exceptions.create("RpcSource.QueryTimout");
31
32
 
32
- function getKnownBlock(provider, blockNumber) {
33
- return provider.getBlock(blockNumber).then(function (blockNullable) {
34
- if (blockNullable == null) {
35
- return Promise.reject(Js_exn.raiseError("RPC returned null for blockNumber " + String(blockNumber)));
36
- } else {
37
- return Promise.resolve(blockNullable);
38
- }
39
- });
33
+ async function getKnownRawBlock(client, blockNumber) {
34
+ var json = await Rpc.getRawBlock(client, blockNumber);
35
+ if (json !== undefined) {
36
+ return json;
37
+ } else {
38
+ return Js_exn.raiseError("RPC returned null for blockNumber " + String(blockNumber));
39
+ }
40
+ }
41
+
42
+ function parseBlockInfo(json) {
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
+ };
40
48
  }
41
49
 
42
- async function getKnownBlockWithBackoff(provider, sourceName, chain, blockNumber, backoffMsOnFailure, lowercaseAddresses) {
50
+ async function getKnownRawBlockWithBackoff(client, sourceName, chain, blockNumber, backoffMsOnFailure) {
51
+ var currentBackoff = backoffMsOnFailure;
43
52
  var result;
44
- try {
45
- result = await getKnownBlock(provider, blockNumber);
46
- }
47
- catch (raw_err){
48
- var err = Caml_js_exceptions.internalToOCamlException(raw_err);
49
- Logging.warn({
50
- err: Utils.prettifyExn(err),
51
- msg: "Issue while running fetching batch of events from the RPC. Will wait " + String(backoffMsOnFailure) + "ms and try again.",
52
- source: sourceName,
53
- chainId: chain,
54
- type: "EXPONENTIAL_BACKOFF"
55
- });
56
- await Time.resolvePromiseAfterDelay(backoffMsOnFailure);
57
- return await getKnownBlockWithBackoff(provider, sourceName, chain, blockNumber, (backoffMsOnFailure << 1), lowercaseAddresses);
58
- }
59
- if (lowercaseAddresses) {
60
- return {
61
- _difficulty: result._difficulty,
62
- difficulty: result.difficulty,
63
- extraData: result.extraData,
64
- gasLimit: result.gasLimit,
65
- gasUsed: result.gasUsed,
66
- hash: result.hash,
67
- miner: Address.Evm.fromAddressLowercaseOrThrow(result.miner),
68
- nonce: result.nonce,
69
- number: result.number,
70
- parentHash: result.parentHash,
71
- timestamp: result.timestamp,
72
- transactions: result.transactions
73
- };
74
- } else {
75
- return result;
76
- }
53
+ while(Belt_Option.isNone(result)) {
54
+ Prometheus.SourceRequestCount.increment(sourceName, chain, "eth_getBlockByNumber");
55
+ var exit = 0;
56
+ var json;
57
+ try {
58
+ json = await getKnownRawBlock(client, blockNumber);
59
+ exit = 1;
60
+ }
61
+ catch (raw_err){
62
+ var err = Caml_js_exceptions.internalToOCamlException(raw_err);
63
+ 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
+ });
70
+ await Time.resolvePromiseAfterDelay(currentBackoff);
71
+ currentBackoff = (currentBackoff << 1);
72
+ }
73
+ if (exit === 1) {
74
+ result = json;
75
+ }
76
+
77
+ };
78
+ return Belt_Option.getExn(result);
77
79
  }
78
80
 
79
81
  var suggestedRangeRegExp = /retry with the range (\d+)-(\d+)/;
@@ -102,111 +104,117 @@ var publicNodeRegExp = /maximum block range: (\d+)/;
102
104
 
103
105
  var hyperliquidRegExp = /query exceeds max block range (\d+)/;
104
106
 
105
- function getSuggestedBlockIntervalFromExn(exn) {
106
- if (exn.RE_EXN_ID !== Js_exn.$$Error) {
107
- return ;
108
- }
109
- try {
110
- var message = exn._1.error.message;
111
- S$RescriptSchema.assertOrThrow(message, S$RescriptSchema.string);
112
- var extractBlockRange = function (execResult, isMaxRange) {
113
- if (execResult.length !== 2) {
114
- return ;
115
- }
116
- var blockRangeLimit = execResult[1];
117
- if (blockRangeLimit === null || blockRangeLimit === undefined) {
118
- return ;
119
- }
120
- var blockRangeLimit$1 = Belt_Int.fromString(blockRangeLimit);
121
- if (blockRangeLimit$1 !== undefined && blockRangeLimit$1 > 0) {
122
- return [
123
- blockRangeLimit$1,
124
- isMaxRange
125
- ];
126
- }
127
-
128
- };
129
- var execResult = suggestedRangeRegExp.exec(message);
130
- if (execResult !== null) {
131
- if (execResult.length !== 3) {
132
- return ;
133
- }
134
- var fromBlock = execResult[1];
135
- if (fromBlock === null || fromBlock === undefined) {
136
- return ;
137
- }
138
- var toBlock = execResult[2];
139
- if (toBlock === null || toBlock === undefined) {
140
- return ;
141
- }
142
- var match = Belt_Int.fromString(fromBlock);
143
- var match$1 = Belt_Int.fromString(toBlock);
144
- if (match !== undefined && match$1 !== undefined && match$1 >= match) {
145
- return [
146
- (match$1 - match | 0) + 1 | 0,
147
- false
148
- ];
149
- } else {
150
- return ;
151
- }
152
- }
153
- var execResult$1 = blockRangeLimitRegExp.exec(message);
154
- if (execResult$1 !== null) {
155
- return extractBlockRange(execResult$1, true);
156
- }
157
- var execResult$2 = alchemyRangeRegExp.exec(message);
158
- if (execResult$2 !== null) {
159
- return extractBlockRange(execResult$2, true);
160
- }
161
- var execResult$3 = cloudflareRangeRegExp.exec(message);
162
- if (execResult$3 !== null) {
163
- return extractBlockRange(execResult$3, true);
164
- }
165
- var execResult$4 = thirdwebRangeRegExp.exec(message);
166
- if (execResult$4 !== null) {
167
- return extractBlockRange(execResult$4, true);
168
- }
169
- var execResult$5 = blockpiRangeRegExp.exec(message);
170
- if (execResult$5 !== null) {
171
- return extractBlockRange(execResult$5, true);
107
+ function parseMessageForBlockRange(message) {
108
+ var extractBlockRange = function (execResult, isMaxRange) {
109
+ if (execResult.length !== 2) {
110
+ return ;
172
111
  }
173
- var execResult$6 = maxAllowedBlocksRegExp.exec(message);
174
- if (execResult$6 !== null) {
175
- return extractBlockRange(execResult$6, true);
112
+ var blockRangeLimit = execResult[1];
113
+ if (blockRangeLimit === null || blockRangeLimit === undefined) {
114
+ return ;
176
115
  }
177
- var match$2 = baseRangeRegExp.exec(message);
178
- if (match$2 !== null) {
116
+ var blockRangeLimit$1 = Belt_Int.fromString(blockRangeLimit);
117
+ if (blockRangeLimit$1 !== undefined && blockRangeLimit$1 > 0) {
179
118
  return [
180
- 2000,
181
- true
119
+ blockRangeLimit$1,
120
+ isMaxRange
182
121
  ];
183
122
  }
184
- var execResult$7 = blastPaidRegExp.exec(message);
185
- if (execResult$7 !== null) {
186
- return extractBlockRange(execResult$7, true);
187
- }
188
- var match$3 = chainstackRegExp.exec(message);
189
- if (match$3 !== null) {
190
- return [
191
- 10000,
192
- true
193
- ];
123
+
124
+ };
125
+ var execResult = suggestedRangeRegExp.exec(message);
126
+ if (execResult !== null) {
127
+ if (execResult.length !== 3) {
128
+ return ;
194
129
  }
195
- var execResult$8 = coinbaseRegExp.exec(message);
196
- if (execResult$8 !== null) {
197
- return extractBlockRange(execResult$8, true);
130
+ var fromBlock = execResult[1];
131
+ if (fromBlock === null || fromBlock === undefined) {
132
+ return ;
198
133
  }
199
- var execResult$9 = publicNodeRegExp.exec(message);
200
- if (execResult$9 !== null) {
201
- return extractBlockRange(execResult$9, true);
134
+ var toBlock = execResult[2];
135
+ if (toBlock === null || toBlock === undefined) {
136
+ return ;
202
137
  }
203
- var execResult$10 = hyperliquidRegExp.exec(message);
204
- if (execResult$10 !== null) {
205
- return extractBlockRange(execResult$10, true);
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) {
141
+ return [
142
+ (match$1 - match | 0) + 1 | 0,
143
+ false
144
+ ];
206
145
  } else {
207
146
  return ;
208
147
  }
209
148
  }
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);
164
+ }
165
+ var execResult$5 = blockpiRangeRegExp.exec(message);
166
+ if (execResult$5 !== null) {
167
+ return extractBlockRange(execResult$5, true);
168
+ }
169
+ var execResult$6 = maxAllowedBlocksRegExp.exec(message);
170
+ if (execResult$6 !== null) {
171
+ return extractBlockRange(execResult$6, true);
172
+ }
173
+ var match$2 = baseRangeRegExp.exec(message);
174
+ if (match$2 !== null) {
175
+ 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
+ }
199
+ var execResult$10 = hyperliquidRegExp.exec(message);
200
+ if (execResult$10 !== null) {
201
+ return extractBlockRange(execResult$10, true);
202
+ }
203
+
204
+ }
205
+
206
+ function getSuggestedBlockIntervalFromExn(exn) {
207
+ if (exn.RE_EXN_ID === Rpc.JsonRpcError) {
208
+ return parseMessageForBlockRange(exn._1.message);
209
+ }
210
+ if (exn.RE_EXN_ID !== Js_exn.$$Error) {
211
+ return ;
212
+ }
213
+ try {
214
+ var message = exn._1.error.message;
215
+ S$RescriptSchema.assertOrThrow(message, S$RescriptSchema.string);
216
+ return parseMessageForBlockRange(message);
217
+ }
210
218
  catch (exn$1){
211
219
  return ;
212
220
  }
@@ -214,7 +222,7 @@ function getSuggestedBlockIntervalFromExn(exn) {
214
222
 
215
223
  var maxSuggestedBlockIntervalKey = "max";
216
224
 
217
- function getNextPage(fromBlock, toBlock, addresses, topicQuery, loadBlock, sc, provider, mutSuggestedBlockIntervals, partitionId) {
225
+ function getNextPage(fromBlock, toBlock, addresses, topicQuery, loadBlock, sc, client, mutSuggestedBlockIntervals, partitionId, sourceName, chainId) {
218
226
  var queryTimoutPromise = Time.resolvePromiseAfterDelay(sc.queryTimeoutMillis).then(function () {
219
227
  return Promise.reject({
220
228
  RE_EXN_ID: QueryTimout,
@@ -222,15 +230,16 @@ function getNextPage(fromBlock, toBlock, addresses, topicQuery, loadBlock, sc, p
222
230
  });
223
231
  });
224
232
  var latestFetchedBlockPromise = loadBlock(toBlock);
225
- var logsPromise = provider.getLogs(Ethers.CombinedFilter.toFilter({
226
- address: addresses,
227
- topics: topicQuery,
228
- fromBlock: fromBlock,
229
- toBlock: toBlock
230
- })).then(async function (logs) {
233
+ 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) {
231
240
  return {
232
241
  logs: logs,
233
- latestFetchedBlock: await latestFetchedBlockPromise
242
+ latestFetchedBlockInfo: await latestFetchedBlockPromise
234
243
  };
235
244
  });
236
245
  return $$Promise.$$catch(Promise.race([
@@ -323,7 +332,7 @@ function getSelectionConfig(selection, chain) {
323
332
  }
324
333
  var dynamicEventFilter = dynamicEventFilters[0];
325
334
  if (selection.eventConfigs.length === 1) {
326
- var eventConfig = selection.eventConfigs[0];
335
+ var eventConfig = Utils.$$Array.firstUnsafe(selection.eventConfigs);
327
336
  getLogSelectionOrThrow = (function (addressesByContractName) {
328
337
  var addresses = FetchState.addressesByContractNameGetAll(addressesByContractName);
329
338
  var match = dynamicEventFilter(addresses);
@@ -380,151 +389,591 @@ function getSelectionConfig(selection, chain) {
380
389
  }
381
390
 
382
391
  function memoGetSelectionConfig(chain) {
383
- var cache = new WeakMap();
384
- return function (selection) {
385
- var c = cache.get(selection);
386
- if (c !== undefined) {
387
- return c;
392
+ return Utils.$$WeakMap.memoize(function (selection) {
393
+ return getSelectionConfig(selection, chain);
394
+ });
395
+ }
396
+
397
+ var lowercaseAddressSchema = S$RescriptSchema.transform(S$RescriptSchema.string, (function (param) {
398
+ return {
399
+ p: (function (str) {
400
+ return str.toLowerCase();
401
+ })
402
+ };
403
+ }));
404
+
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
+ }));
412
+
413
+ 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
+ })));
560
+ }
561
+
562
+ var blockFieldRegistryLowercase = makeBlockFieldRegistry(lowercaseAddressSchema);
563
+
564
+ var blockFieldRegistryChecksum = makeBlockFieldRegistry(checksumAddressSchema);
565
+
566
+ 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
+ }));
582
+ }
583
+
584
+ 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;
590
+ if (fn !== undefined) {
591
+ tmp = fn;
592
+ } 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
+ });
606
+ fnsCache.set(selectedBlockFields, fn$1);
607
+ tmp = fn$1;
388
608
  }
389
- var c$1 = getSelectionConfig(selection, chain);
390
- cache.set(selection, c$1);
391
- return c$1;
609
+ return tmp(log);
392
610
  };
393
611
  }
394
612
 
395
- function makeThrowingGetEventBlock(getBlock) {
396
- return async function (log) {
397
- return await getBlock(log.blockNumber);
398
- };
613
+ 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
+ })));
399
794
  }
400
795
 
401
- function makeThrowingGetEventTransaction(getTransactionFields) {
796
+ var fieldRegistryLowercase = makeFieldRegistry(lowercaseAddressSchema);
797
+
798
+ var fieldRegistryChecksum = makeFieldRegistry(checksumAddressSchema);
799
+
800
+ 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
+ }));
816
+ }
817
+
818
+ function makeThrowingGetEventTransaction(getTransactionJson, getReceiptJson, lowercaseAddresses) {
819
+ var fieldRegistry = lowercaseAddresses ? fieldRegistryLowercase : fieldRegistryChecksum;
402
820
  var fnsCache = new WeakMap();
403
- return function (log, transactionSchema) {
404
- var fn = fnsCache.get(transactionSchema);
821
+ return function (log, selectedTransactionFields) {
822
+ var fn = fnsCache.get(selectedTransactionFields);
405
823
  var tmp;
406
824
  if (fn !== undefined) {
407
825
  tmp = fn;
408
826
  } else {
409
- var transactionSchema$1 = S$RescriptSchema.removeTypeValidation(transactionSchema);
410
- var match = transactionSchema$1.t;
411
- var transactionFieldItems;
412
- transactionFieldItems = typeof match !== "object" || match.TAG !== "object" ? Js_exn.raiseError("Unexpected internal error: transactionSchema is not an object") : match.items;
413
- var parseOrThrowReadableError = function (data) {
414
- try {
415
- return S$RescriptSchema.parseOrThrow(data, transactionSchema$1);
827
+ var hasTransactionIndex = {
828
+ contents: false
829
+ };
830
+ var hasHash = {
831
+ contents: false
832
+ };
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
+ }
862
+ }
863
+ });
864
+ var match = txFields.length !== 0;
865
+ var match$1 = receiptFields.length !== 0;
866
+ var strategy = match ? (
867
+ match$1 ? "TransactionAndReceipt" : "TransactionOnly"
868
+ ) : (
869
+ match$1 ? "ReceiptOnly" : (
870
+ bothFields.length !== 0 ? "TransactionOnly" : "NoRpc"
871
+ )
872
+ );
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) {
878
+ if (hasTransactionIndex.contents) {
879
+ mutTransactionAcc["transactionIndex"] = log.transactionIndex;
416
880
  }
417
- catch (raw_error){
418
- var error = Caml_js_exceptions.internalToOCamlException(raw_error);
419
- if (error.RE_EXN_ID === S$RescriptSchema.Raised) {
420
- var error$1 = error._1;
421
- return Js_exn.raiseError("Invalid transaction field \"" + S$RescriptSchema.Path.toArray(error$1.path).join(".") + "\" found in the RPC response. Error: " + S$RescriptSchema.$$Error.reason(error$1));
422
- }
423
- throw error;
881
+ if (hasHash.contents) {
882
+ mutTransactionAcc["hash"] = log.transactionHash;
883
+ return ;
424
884
  }
885
+
425
886
  };
426
- var fn$1;
427
- var exit = 0;
428
- var len = transactionFieldItems.length;
429
- if (len >= 3) {
430
- exit = 1;
431
- } else {
432
- switch (len) {
433
- case 0 :
434
- fn$1 = (function (param) {
435
- return Promise.resolve({});
436
- });
437
- break;
438
- case 1 :
439
- var match$1 = transactionFieldItems[0];
440
- switch (match$1.location) {
441
- case "hash" :
442
- exit = 2;
443
- break;
444
- case "transactionIndex" :
445
- fn$1 = (function (log) {
446
- return Promise.resolve(parseOrThrowReadableError(log));
887
+ var fn$1 = selectedTransactionFields.size === 0 ? (function (param) {
888
+ return Promise.resolve({});
889
+ }) : (
890
+ strategy === "NoRpc" ? (function (log) {
891
+ var mutTransactionAcc = {};
892
+ 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;
447
911
  });
448
- break;
449
- default:
450
- exit = 1;
451
- }
452
- break;
453
- case 2 :
454
- var match$2 = transactionFieldItems[0];
455
- switch (match$2.location) {
456
- case "hash" :
457
- var match$3 = transactionFieldItems[1];
458
- exit = match$3.location === "transactionIndex" ? 2 : 1;
459
- break;
460
- case "transactionIndex" :
461
- var match$4 = transactionFieldItems[1];
462
- exit = match$4.location === "hash" ? 2 : 1;
463
- break;
464
- default:
465
- exit = 1;
466
- }
467
- break;
468
-
469
- }
470
- }
471
- switch (exit) {
472
- case 1 :
473
- fn$1 = (function (log) {
474
- return getTransactionFields(log).then(parseOrThrowReadableError);
475
- });
476
- break;
477
- case 2 :
478
- fn$1 = (function (log) {
479
- return Promise.resolve(parseOrThrowReadableError({
480
- hash: log.transactionHash,
481
- transactionIndex: log.transactionIndex
482
- }));
483
- });
484
- break;
485
-
486
- }
487
- fnsCache.set(transactionSchema$1, fn$1);
912
+ }
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
+
925
+ }
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
+ })
948
+ );
949
+ fnsCache.set(selectedTransactionFields, fn$1);
488
950
  tmp = fn$1;
489
951
  }
490
952
  return tmp(log);
491
953
  };
492
954
  }
493
955
 
494
- function sanitizeUrl(url) {
495
- var regex = /https?:\/\/([^\/?]+).*/;
496
- var result = regex.exec(url);
497
- if (result === null) {
498
- return ;
499
- }
500
- var host = Belt_Array.get(result, 1);
501
- if (host !== undefined) {
502
- return Caml_option.nullable_to_opt(Caml_option.valFromOption(host));
503
- }
504
-
505
- }
506
-
507
956
  function make(param) {
508
957
  var lowercaseAddresses = param.lowercaseAddresses;
509
- var shouldUseHypersyncClientDecoder = param.shouldUseHypersyncClientDecoder;
510
958
  var allEventSignatures = param.allEventSignatures;
511
959
  var eventRouter = param.eventRouter;
512
960
  var chain = param.chain;
513
961
  var url = param.url;
514
962
  var syncConfig = param.syncConfig;
515
- var host = sanitizeUrl(url);
516
- var urlHost = host !== undefined ? host : Js_exn.raiseError("EE109: The RPC url \"" + url + "\" is incorrect format. The RPC url needs to start with either http:// or https://");
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://");
517
965
  var name = "RPC (" + urlHost + ")";
518
- var provider = Ethers.JsonRpcProvider.make(url, chain);
519
966
  var getSelectionConfig = memoGetSelectionConfig(chain);
520
967
  var mutSuggestedBlockIntervals = {};
968
+ var client = Rpc.makeClient(url);
521
969
  var makeTransactionLoader = function () {
522
970
  return LazyLoader.make((function (transactionHash) {
523
- return provider.getTransaction(transactionHash);
971
+ Prometheus.SourceRequestCount.increment(name, chain, "eth_getTransactionByHash");
972
+ return Rest.$$fetch(Rpc.GetTransactionByHash.rawRoute, transactionHash, client);
524
973
  }), (function (am, exn) {
525
974
  Logging.error({
526
975
  err: Utils.prettifyExn(exn),
527
- msg: "EE1100: 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",
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",
528
977
  source: name,
529
978
  chainId: chain,
530
979
  metadata: {
@@ -536,11 +985,11 @@ function make(param) {
536
985
  };
537
986
  var makeBlockLoader = function () {
538
987
  return LazyLoader.make((function (blockNumber) {
539
- return getKnownBlockWithBackoff(provider, name, chain, blockNumber, 1000, lowercaseAddresses);
988
+ return getKnownRawBlockWithBackoff(client, name, chain, blockNumber, 1000);
540
989
  }), (function (am, exn) {
541
990
  Logging.error({
542
991
  err: Utils.prettifyExn(exn),
543
- msg: "EE1100: 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",
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",
544
993
  source: name,
545
994
  chainId: chain,
546
995
  metadata: {
@@ -550,34 +999,60 @@ function make(param) {
550
999
  });
551
1000
  }), undefined, undefined, undefined, undefined);
552
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
+ };
553
1019
  var blockLoader = {
554
1020
  contents: makeBlockLoader()
555
1021
  };
556
1022
  var transactionLoader = {
557
1023
  contents: makeTransactionLoader()
558
1024
  };
559
- var getEventBlockOrThrow = makeThrowingGetEventBlock(function (blockNumber) {
560
- return LazyLoader.get(blockLoader.contents, blockNumber);
561
- });
562
- var getEventTransactionOrThrow = makeThrowingGetEventTransaction(Ethers.JsonRpcProvider.makeGetTransactionFields((function (__x) {
563
- return LazyLoader.get(transactionLoader.contents, __x);
564
- }), lowercaseAddresses));
565
- var contractNameAbiMapping = {};
566
- Belt_Array.forEach(param.contracts, (function (contract) {
567
- contractNameAbiMapping[contract.name] = contract.abi;
568
- }));
569
- var convertEthersLogToHyperSyncEvent = function (log) {
570
- var hyperSyncLog_removed = Belt_Option.getWithDefault(log.removed, false);
571
- var hyperSyncLog_logIndex = log.index;
1025
+ var receiptLoader = {
1026
+ contents: makeReceiptLoader()
1027
+ };
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;
572
1049
  var hyperSyncLog_transactionIndex = log.transactionIndex;
573
1050
  var hyperSyncLog_transactionHash = log.transactionHash;
574
1051
  var hyperSyncLog_blockHash = log.blockHash;
575
1052
  var hyperSyncLog_blockNumber = log.blockNumber;
576
1053
  var hyperSyncLog_address = Caml_option.some(log.address);
577
1054
  var hyperSyncLog_data = log.data;
578
- var hyperSyncLog_topics = Belt_Array.map(log.topics, (function (topic) {
579
- return topic;
580
- }));
1055
+ var hyperSyncLog_topics = log.topics;
581
1056
  var hyperSyncLog = {
582
1057
  removed: hyperSyncLog_removed,
583
1058
  logIndex: hyperSyncLog_logIndex,
@@ -604,114 +1079,60 @@ function make(param) {
604
1079
  return HyperSyncClient.Decoder.fromSignatures(allEventSignatures);
605
1080
  }
606
1081
  };
607
- var getItemsOrThrow = async function (fromBlock, toBlock, addressesByContractName, indexingContracts, currentBlockHeight, partitionId, selection, param, param$1) {
1082
+ var getItemsOrThrow = async function (fromBlock, toBlock, addressesByContractName, indexingContracts, knownHeight, partitionId, selection, param, param$1) {
608
1083
  var startFetchingBatchTimeRef = Hrtime.makeTimer();
609
1084
  var maxSuggestedBlockInterval = mutSuggestedBlockIntervals[maxSuggestedBlockIntervalKey];
610
1085
  var suggestedBlockInterval = maxSuggestedBlockInterval !== undefined ? maxSuggestedBlockInterval : Belt_Option.getWithDefault(mutSuggestedBlockIntervals[partitionId], syncConfig.initialBlockInterval);
611
- var toBlock$1 = toBlock !== undefined && toBlock < currentBlockHeight ? toBlock : currentBlockHeight;
1086
+ var toBlock$1 = toBlock !== undefined && toBlock < knownHeight ? toBlock : knownHeight;
612
1087
  var suggestedToBlock = Caml.int_max(Caml.int_min((fromBlock + suggestedBlockInterval | 0) - 1 | 0, toBlock$1), fromBlock);
613
- var firstBlockParentPromise = fromBlock > 0 ? LazyLoader.get(blockLoader.contents, fromBlock - 1 | 0).then(function (res) {
614
- return res;
1088
+ var firstBlockParentPromise = fromBlock > 0 ? LazyLoader.get(blockLoader.contents, fromBlock - 1 | 0).then(function (json) {
1089
+ return parseBlockInfo(json);
615
1090
  }) : Promise.resolve(undefined);
616
1091
  var match = getSelectionConfig(selection);
617
1092
  var match$1 = match.getLogSelectionOrThrow(addressesByContractName);
618
1093
  var match$2 = await getNextPage(fromBlock, suggestedToBlock, match$1.addresses, match$1.topicQuery, (function (blockNumber) {
619
- return LazyLoader.get(blockLoader.contents, blockNumber);
620
- }), syncConfig, provider, mutSuggestedBlockIntervals, partitionId);
621
- var latestFetchedBlock = match$2.latestFetchedBlock;
1094
+ return LazyLoader.get(blockLoader.contents, blockNumber).then(parseBlockInfo);
1095
+ }), syncConfig, client, mutSuggestedBlockIntervals, partitionId, name, chain);
1096
+ var latestFetchedBlockInfo = match$2.latestFetchedBlockInfo;
622
1097
  var logs = match$2.logs;
623
1098
  var executedBlockInterval = (suggestedToBlock - fromBlock | 0) + 1 | 0;
624
1099
  if (executedBlockInterval >= suggestedBlockInterval && !Utils.Dict.has(mutSuggestedBlockIntervals, maxSuggestedBlockIntervalKey)) {
625
1100
  mutSuggestedBlockIntervals[partitionId] = Caml.int_min(executedBlockInterval + syncConfig.accelerationAdditive | 0, syncConfig.intervalCeiling);
626
1101
  }
627
- var parsedQueueItems;
628
- if (shouldUseHypersyncClientDecoder) {
629
- var hyperSyncEvents = Belt_Array.map(logs, convertEthersLogToHyperSyncEvent);
630
- var parsedEvents;
631
- try {
632
- parsedEvents = await getHscDecoder().decodeEvents(hyperSyncEvents);
633
- }
634
- catch (raw_exn){
635
- var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
636
- throw {
637
- RE_EXN_ID: Source.GetItemsError,
638
- _1: {
639
- TAG: "FailedGettingItems",
640
- exn: exn,
641
- attemptedToBlock: toBlock$1,
642
- retry: {
643
- TAG: "ImpossibleForTheQuery",
644
- message: "Failed to parse events using hypersync client decoder. Please double-check your ABI."
645
- }
646
- },
647
- Error: new Error()
648
- };
649
- }
650
- parsedQueueItems = await Promise.all(Belt_Array.keepMap(Belt_Array.zip(logs, parsedEvents), (function (param) {
651
- var maybeDecodedEvent = param[1];
652
- var log = param[0];
653
- var topic0 = Belt_Option.getWithDefault(Belt_Array.get(log.topics, 0), "0x0");
654
- var routedAddress = lowercaseAddresses ? Address.Evm.fromAddressLowercaseOrThrow(log.address) : log.address;
655
- var eventConfig = EventRouter.get(eventRouter, EventRouter.getEvmEventId(topic0, log.topics.length), routedAddress, log.blockNumber, indexingContracts);
656
- if (eventConfig !== undefined && !(maybeDecodedEvent === null || maybeDecodedEvent === undefined)) {
657
- return Caml_option.some((async function () {
658
- var match;
659
- try {
660
- match = await Promise.all([
661
- getEventBlockOrThrow(log),
662
- getEventTransactionOrThrow(log, eventConfig.transactionSchema)
663
- ]);
664
- }
665
- catch (raw_exn){
666
- var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
667
- throw {
668
- RE_EXN_ID: Source.GetItemsError,
669
- _1: {
670
- TAG: "FailedGettingFieldSelection",
671
- exn: exn,
672
- blockNumber: log.blockNumber,
673
- logIndex: log.index,
674
- message: "Failed getting selected fields. Please double-check your RPC provider returns correct data."
675
- },
676
- Error: new Error()
677
- };
678
- }
679
- var block = match[0];
680
- return {
681
- kind: 0,
682
- eventConfig: eventConfig,
683
- timestamp: block.timestamp,
684
- chain: chain,
685
- blockNumber: block.number,
686
- logIndex: log.index,
687
- event: {
688
- params: eventConfig.convertHyperSyncEventArgs(maybeDecodedEvent),
689
- chainId: chain,
690
- srcAddress: routedAddress,
691
- logIndex: log.index,
692
- transaction: match[1],
693
- block: block
694
- }
695
- };
696
- })());
697
- }
698
-
699
- })));
700
- } else {
701
- parsedQueueItems = await Promise.all(Belt_Array.keepMap(logs, (function (log) {
702
- var topic0 = log.topics[0];
703
- var eventConfig = EventRouter.get(eventRouter, EventRouter.getEvmEventId(topic0, log.topics.length), log.address, log.blockNumber, indexingContracts);
704
- if (eventConfig === undefined) {
705
- return ;
706
- }
707
- var blockNumber = log.blockNumber;
708
- var logIndex = log.index;
1102
+ var hyperSyncEvents = Belt_Array.map(logs, convertLogToHyperSyncEvent);
1103
+ var parsedEvents;
1104
+ try {
1105
+ parsedEvents = await getHscDecoder().decodeEvents(hyperSyncEvents);
1106
+ }
1107
+ catch (raw_exn){
1108
+ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
1109
+ 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
+ };
1122
+ }
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)) {
709
1130
  return Caml_option.some((async function () {
710
1131
  var match;
711
1132
  try {
712
1133
  match = await Promise.all([
713
- getEventBlockOrThrow(log),
714
- getEventTransactionOrThrow(log, eventConfig.transactionSchema)
1134
+ getEventBlockOrThrow(log, eventConfig.selectedBlockFields),
1135
+ getEventTransactionOrThrow(log, eventConfig.selectedTransactionFields)
715
1136
  ]);
716
1137
  }
717
1138
  catch (raw_exn){
@@ -721,58 +1142,41 @@ function make(param) {
721
1142
  _1: {
722
1143
  TAG: "FailedGettingFieldSelection",
723
1144
  exn: exn,
724
- blockNumber: blockNumber,
725
- logIndex: logIndex,
1145
+ blockNumber: log.blockNumber,
1146
+ logIndex: log.logIndex,
726
1147
  message: "Failed getting selected fields. Please double-check your RPC provider returns correct data."
727
1148
  },
728
1149
  Error: new Error()
729
1150
  };
730
1151
  }
731
1152
  var block = match[0];
732
- var decodedEvent;
733
- try {
734
- decodedEvent = Viem.parseLogOrThrow(contractNameAbiMapping, eventConfig.contractName, log.topics, log.data);
735
- }
736
- catch (raw_exn$1){
737
- var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1);
738
- throw {
739
- RE_EXN_ID: Source.GetItemsError,
740
- _1: {
741
- TAG: "FailedGettingItems",
742
- exn: exn$1,
743
- attemptedToBlock: toBlock$1,
744
- retry: {
745
- TAG: "ImpossibleForTheQuery",
746
- message: "Failed to parse event with viem, please double-check your ABI. Block number: " + String(blockNumber) + ", log index: " + String(logIndex)
747
- }
748
- },
749
- Error: new Error()
750
- };
751
- }
752
1153
  return {
753
1154
  kind: 0,
754
1155
  eventConfig: eventConfig,
755
1156
  timestamp: block.timestamp,
756
1157
  chain: chain,
757
1158
  blockNumber: block.number,
758
- logIndex: log.index,
1159
+ logIndex: log.logIndex,
759
1160
  event: {
760
- params: decodedEvent.args,
1161
+ contractName: eventConfig.contractName,
1162
+ eventName: eventConfig.name,
1163
+ params: eventConfig.convertHyperSyncEventArgs(maybeDecodedEvent),
761
1164
  chainId: chain,
762
- srcAddress: log.address,
763
- logIndex: log.index,
1165
+ srcAddress: routedAddress,
1166
+ logIndex: log.logIndex,
764
1167
  transaction: match[1],
765
1168
  block: block
766
1169
  }
767
1170
  };
768
1171
  })());
769
- })));
770
- }
1172
+ }
1173
+
1174
+ })));
771
1175
  var optFirstBlockParent = await firstBlockParentPromise;
772
- var totalTimeElapsed = Hrtime.intFromMillis(Hrtime.toMillis(Hrtime.timeSince(startFetchingBatchTimeRef)));
1176
+ var totalTimeElapsed = Hrtime.toSecondsFloat(Hrtime.timeSince(startFetchingBatchTimeRef));
773
1177
  var reorgGuard_rangeLastBlock = {
774
- blockHash: latestFetchedBlock.hash,
775
- blockNumber: latestFetchedBlock.number
1178
+ blockHash: latestFetchedBlockInfo.hash,
1179
+ blockNumber: latestFetchedBlockInfo.number
776
1180
  };
777
1181
  var reorgGuard_prevRangeLastBlock = Belt_Option.map(optFirstBlockParent, (function (b) {
778
1182
  return {
@@ -785,26 +1189,28 @@ function make(param) {
785
1189
  prevRangeLastBlock: reorgGuard_prevRangeLastBlock
786
1190
  };
787
1191
  return {
788
- currentBlockHeight: currentBlockHeight,
1192
+ knownHeight: knownHeight,
789
1193
  reorgGuard: reorgGuard,
790
1194
  parsedQueueItems: parsedQueueItems,
791
1195
  fromBlockQueried: fromBlock,
792
- latestFetchedBlockNumber: latestFetchedBlock.number,
793
- latestFetchedBlockTimestamp: latestFetchedBlock.timestamp,
1196
+ latestFetchedBlockNumber: latestFetchedBlockInfo.number,
1197
+ latestFetchedBlockTimestamp: latestFetchedBlockInfo.timestamp,
794
1198
  stats: {
795
- "total time elapsed (ms)": totalTimeElapsed
1199
+ "total time elapsed (s)": totalTimeElapsed
796
1200
  }
797
1201
  };
798
1202
  };
799
1203
  var getBlockHashes = function (blockNumbers, _currentlyUnusedLogger) {
800
1204
  blockLoader.contents = makeBlockLoader();
801
1205
  transactionLoader.contents = makeTransactionLoader();
1206
+ receiptLoader.contents = makeReceiptLoader();
802
1207
  return $$Promise.$$catch(Promise.all(Belt_Array.map(blockNumbers, (function (blockNum) {
803
1208
  return LazyLoader.get(blockLoader.contents, blockNum);
804
- }))).then(function (blocks) {
1209
+ }))).then(function (rawBlocks) {
805
1210
  return {
806
1211
  TAG: "Ok",
807
- _0: Belt_Array.map(blocks, (function (b) {
1212
+ _0: Belt_Array.map(rawBlocks, (function (json) {
1213
+ var b = parseBlockInfo(json);
808
1214
  return {
809
1215
  blockHash: b.hash,
810
1216
  blockNumber: b.number,
@@ -819,33 +1225,62 @@ function make(param) {
819
1225
  });
820
1226
  }));
821
1227
  };
822
- var client = Rest.client(url, undefined);
1228
+ var createHeightSubscription = Belt_Option.map(param.ws, (function (wsUrl) {
1229
+ return function (onHeight) {
1230
+ return RpcWebSocketHeightStream.subscribe(wsUrl, chain, onHeight);
1231
+ };
1232
+ }));
823
1233
  return {
824
1234
  name: name,
825
1235
  sourceFor: param.sourceFor,
826
1236
  chain: chain,
827
1237
  poweredByHyperSync: false,
828
- pollingInterval: 1000,
1238
+ pollingInterval: syncConfig.pollingInterval,
829
1239
  getBlockHashes: getBlockHashes,
830
- getHeightOrThrow: (function () {
831
- return Rest.$$fetch(Rpc.GetBlockHeight.route, undefined, client);
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;
832
1256
  }),
833
- getItemsOrThrow: getItemsOrThrow
1257
+ getItemsOrThrow: getItemsOrThrow,
1258
+ createHeightSubscription: createHeightSubscription
834
1259
  };
835
1260
  }
836
1261
 
837
1262
  export {
838
1263
  QueryTimout ,
839
- getKnownBlock ,
840
- getKnownBlockWithBackoff ,
1264
+ getKnownRawBlock ,
1265
+ parseBlockInfo ,
1266
+ getKnownRawBlockWithBackoff ,
841
1267
  getSuggestedBlockIntervalFromExn ,
842
1268
  maxSuggestedBlockIntervalKey ,
843
1269
  getNextPage ,
844
1270
  getSelectionConfig ,
845
1271
  memoGetSelectionConfig ,
1272
+ lowercaseAddressSchema ,
1273
+ checksumAddressSchema ,
1274
+ makeBlockFieldRegistry ,
1275
+ blockFieldRegistryLowercase ,
1276
+ blockFieldRegistryChecksum ,
1277
+ parseBlockFieldsFromJson ,
846
1278
  makeThrowingGetEventBlock ,
1279
+ makeFieldRegistry ,
1280
+ fieldRegistryLowercase ,
1281
+ fieldRegistryChecksum ,
1282
+ parseFieldsFromJson ,
847
1283
  makeThrowingGetEventTransaction ,
848
- sanitizeUrl ,
849
1284
  make ,
850
1285
  }
851
- /* Rpc Not a pure module */
1286
+ /* lowercaseAddressSchema Not a pure module */