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.
- package/README.md +164 -30
- package/bin.mjs +49 -0
- package/evm.schema.json +79 -169
- package/fuel.schema.json +50 -21
- package/index.d.ts +578 -1
- package/index.js +4 -0
- package/package.json +47 -31
- package/rescript.json +4 -1
- package/src/Batch.res +11 -8
- package/src/Batch.res.mjs +11 -9
- package/src/ChainFetcher.res +531 -0
- package/src/ChainFetcher.res.mjs +339 -0
- package/src/ChainManager.res +190 -0
- package/src/ChainManager.res.mjs +166 -0
- package/src/Change.res +3 -3
- package/src/Config.gen.ts +19 -0
- package/src/Config.res +725 -25
- package/src/Config.res.mjs +692 -26
- package/src/{Indexer.res → Ctx.res} +1 -1
- package/src/Ecosystem.res +9 -124
- package/src/Ecosystem.res.mjs +19 -160
- package/src/Env.res +33 -73
- package/src/Env.res.mjs +29 -85
- package/src/Envio.gen.ts +3 -1
- package/src/Envio.res +77 -9
- package/src/Envio.res.mjs +39 -1
- package/src/EventConfigBuilder.res +408 -0
- package/src/EventConfigBuilder.res.mjs +376 -0
- package/src/EventProcessing.res +469 -0
- package/src/EventProcessing.res.mjs +337 -0
- package/src/EvmTypes.gen.ts +6 -0
- package/src/EvmTypes.res +1 -0
- package/src/FetchState.res +1256 -639
- package/src/FetchState.res.mjs +1135 -612
- package/src/GlobalState.res +1224 -0
- package/src/GlobalState.res.mjs +1291 -0
- package/src/GlobalStateManager.res +68 -0
- package/src/GlobalStateManager.res.mjs +75 -0
- package/src/GlobalStateManager.resi +7 -0
- package/src/HandlerLoader.res +89 -0
- package/src/HandlerLoader.res.mjs +79 -0
- package/src/HandlerRegister.res +357 -0
- package/src/HandlerRegister.res.mjs +299 -0
- package/src/HandlerRegister.resi +30 -0
- package/src/Hasura.res +111 -175
- package/src/Hasura.res.mjs +88 -150
- package/src/InMemoryStore.res +1 -1
- package/src/InMemoryStore.res.mjs +3 -3
- package/src/InMemoryTable.res +1 -1
- package/src/InMemoryTable.res.mjs +1 -1
- package/src/Internal.gen.ts +6 -0
- package/src/Internal.res +265 -12
- package/src/Internal.res.mjs +115 -1
- package/src/LoadLayer.res +444 -0
- package/src/LoadLayer.res.mjs +296 -0
- package/src/LoadLayer.resi +32 -0
- package/src/LogSelection.res +33 -27
- package/src/LogSelection.res.mjs +6 -0
- package/src/Logging.res +21 -7
- package/src/Logging.res.mjs +16 -8
- package/src/Main.res +390 -0
- package/src/Main.res.mjs +341 -0
- package/src/Persistence.res +7 -21
- package/src/Persistence.res.mjs +3 -3
- package/src/PgStorage.gen.ts +10 -0
- package/src/PgStorage.res +116 -69
- package/src/PgStorage.res.d.mts +5 -0
- package/src/PgStorage.res.mjs +93 -50
- package/src/Prometheus.res +294 -224
- package/src/Prometheus.res.mjs +353 -340
- package/src/ReorgDetection.res +6 -10
- package/src/ReorgDetection.res.mjs +6 -6
- package/src/SafeCheckpointTracking.res +4 -4
- package/src/SafeCheckpointTracking.res.mjs +2 -2
- package/src/SimulateItems.res +353 -0
- package/src/SimulateItems.res.mjs +335 -0
- package/src/Sink.res +4 -2
- package/src/Sink.res.mjs +2 -1
- package/src/TableIndices.res +0 -1
- package/src/TestIndexer.res +913 -0
- package/src/TestIndexer.res.mjs +698 -0
- package/src/TestIndexerProxyStorage.res +205 -0
- package/src/TestIndexerProxyStorage.res.mjs +151 -0
- package/src/TopicFilter.res +1 -1
- package/src/Types.ts +1 -1
- package/src/UserContext.res +424 -0
- package/src/UserContext.res.mjs +279 -0
- package/src/Utils.res +97 -26
- package/src/Utils.res.mjs +91 -44
- package/src/bindings/BigInt.res +10 -0
- package/src/bindings/BigInt.res.mjs +15 -0
- package/src/bindings/ClickHouse.res +120 -23
- package/src/bindings/ClickHouse.res.mjs +118 -28
- package/src/bindings/DateFns.res +74 -0
- package/src/bindings/DateFns.res.mjs +22 -0
- package/src/bindings/EventSource.res +11 -2
- package/src/bindings/EventSource.res.mjs +8 -1
- package/src/bindings/Express.res +1 -0
- package/src/bindings/Hrtime.res +14 -1
- package/src/bindings/Hrtime.res.mjs +22 -2
- package/src/bindings/Hrtime.resi +4 -0
- package/src/bindings/Lodash.res +0 -1
- package/src/bindings/NodeJs.res +49 -3
- package/src/bindings/NodeJs.res.mjs +11 -3
- package/src/bindings/Pino.res +24 -10
- package/src/bindings/Pino.res.mjs +14 -8
- package/src/bindings/Postgres.gen.ts +8 -0
- package/src/bindings/Postgres.res +5 -1
- package/src/bindings/Postgres.res.d.mts +5 -0
- package/src/bindings/PromClient.res +0 -10
- package/src/bindings/PromClient.res.mjs +0 -3
- package/src/bindings/Vitest.res +144 -0
- package/src/bindings/Vitest.res.mjs +9 -0
- package/src/bindings/WebSocket.res +27 -0
- package/src/bindings/WebSocket.res.mjs +2 -0
- package/src/bindings/Yargs.res +8 -0
- package/src/bindings/Yargs.res.mjs +2 -0
- package/src/db/EntityHistory.res +7 -7
- package/src/db/EntityHistory.res.mjs +9 -9
- package/src/db/InternalTable.res +59 -111
- package/src/db/InternalTable.res.mjs +73 -104
- package/src/db/Table.res +27 -8
- package/src/db/Table.res.mjs +25 -14
- package/src/sources/Evm.res +84 -0
- package/src/sources/Evm.res.mjs +105 -0
- package/src/sources/EvmChain.res +94 -0
- package/src/sources/EvmChain.res.mjs +60 -0
- package/src/sources/Fuel.res +19 -34
- package/src/sources/Fuel.res.mjs +34 -16
- package/src/sources/FuelSDK.res +38 -0
- package/src/sources/FuelSDK.res.mjs +29 -0
- package/src/sources/HyperFuel.res +2 -2
- package/src/sources/HyperFuel.resi +1 -1
- package/src/sources/HyperFuelClient.res +2 -2
- package/src/sources/HyperFuelSource.res +35 -13
- package/src/sources/HyperFuelSource.res.mjs +26 -16
- package/src/sources/HyperSync.res +61 -60
- package/src/sources/HyperSync.res.mjs +53 -67
- package/src/sources/HyperSync.resi +6 -4
- package/src/sources/HyperSyncClient.res +29 -2
- package/src/sources/HyperSyncClient.res.mjs +9 -0
- package/src/sources/HyperSyncHeightStream.res +76 -118
- package/src/sources/HyperSyncHeightStream.res.mjs +68 -75
- package/src/sources/HyperSyncSource.res +122 -143
- package/src/sources/HyperSyncSource.res.mjs +106 -121
- package/src/sources/Rpc.res +86 -14
- package/src/sources/Rpc.res.mjs +101 -9
- package/src/sources/RpcSource.res +731 -364
- package/src/sources/RpcSource.res.mjs +845 -410
- package/src/sources/RpcWebSocketHeightStream.res +181 -0
- package/src/sources/RpcWebSocketHeightStream.res.mjs +196 -0
- package/src/sources/SimulateSource.res +59 -0
- package/src/sources/SimulateSource.res.mjs +50 -0
- package/src/sources/Source.res +7 -5
- package/src/sources/SourceManager.res +358 -221
- package/src/sources/SourceManager.res.mjs +346 -171
- package/src/sources/SourceManager.resi +17 -6
- package/src/sources/Svm.res +81 -0
- package/src/sources/Svm.res.mjs +90 -0
- package/src/tui/Tui.res +247 -0
- package/src/tui/Tui.res.mjs +337 -0
- package/src/tui/bindings/Ink.res +371 -0
- package/src/tui/bindings/Ink.res.mjs +72 -0
- package/src/tui/bindings/Style.res +123 -0
- package/src/tui/bindings/Style.res.mjs +2 -0
- package/src/tui/components/BufferedProgressBar.res +40 -0
- package/src/tui/components/BufferedProgressBar.res.mjs +57 -0
- package/src/tui/components/CustomHooks.res +122 -0
- package/src/tui/components/CustomHooks.res.mjs +179 -0
- package/src/tui/components/Messages.res +41 -0
- package/src/tui/components/Messages.res.mjs +75 -0
- package/src/tui/components/SyncETA.res +174 -0
- package/src/tui/components/SyncETA.res.mjs +263 -0
- package/src/tui/components/TuiData.res +47 -0
- package/src/tui/components/TuiData.res.mjs +34 -0
- package/svm.schema.json +112 -0
- package/bin.js +0 -48
- package/src/EventRegister.res +0 -241
- package/src/EventRegister.res.mjs +0 -240
- package/src/EventRegister.resi +0 -30
- package/src/bindings/Ethers.gen.ts +0 -14
- package/src/bindings/Ethers.res +0 -204
- package/src/bindings/Ethers.res.mjs +0 -130
- /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
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
|
50
|
+
async function getKnownRawBlockWithBackoff(client, sourceName, chain, blockNumber, backoffMsOnFailure) {
|
|
51
|
+
var currentBackoff = backoffMsOnFailure;
|
|
43
52
|
var result;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
|
106
|
-
|
|
107
|
-
|
|
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
|
|
174
|
-
if (
|
|
175
|
-
return
|
|
112
|
+
var blockRangeLimit = execResult[1];
|
|
113
|
+
if (blockRangeLimit === null || blockRangeLimit === undefined) {
|
|
114
|
+
return ;
|
|
176
115
|
}
|
|
177
|
-
var
|
|
178
|
-
if (
|
|
116
|
+
var blockRangeLimit$1 = Belt_Int.fromString(blockRangeLimit);
|
|
117
|
+
if (blockRangeLimit$1 !== undefined && blockRangeLimit$1 > 0) {
|
|
179
118
|
return [
|
|
180
|
-
|
|
181
|
-
|
|
119
|
+
blockRangeLimit$1,
|
|
120
|
+
isMaxRange
|
|
182
121
|
];
|
|
183
122
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
|
196
|
-
if (
|
|
197
|
-
return
|
|
130
|
+
var fromBlock = execResult[1];
|
|
131
|
+
if (fromBlock === null || fromBlock === undefined) {
|
|
132
|
+
return ;
|
|
198
133
|
}
|
|
199
|
-
var
|
|
200
|
-
if (
|
|
201
|
-
return
|
|
134
|
+
var toBlock = execResult[2];
|
|
135
|
+
if (toBlock === null || toBlock === undefined) {
|
|
136
|
+
return ;
|
|
202
137
|
}
|
|
203
|
-
var
|
|
204
|
-
|
|
205
|
-
|
|
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,
|
|
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
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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
|
-
|
|
390
|
-
cache.set(selection, c$1);
|
|
391
|
-
return c$1;
|
|
609
|
+
return tmp(log);
|
|
392
610
|
};
|
|
393
611
|
}
|
|
394
612
|
|
|
395
|
-
function
|
|
396
|
-
return
|
|
397
|
-
|
|
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
|
-
|
|
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,
|
|
404
|
-
var fn = fnsCache.get(
|
|
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
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
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
|
-
|
|
418
|
-
|
|
419
|
-
|
|
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
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
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
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
})
|
|
484
|
-
|
|
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 =
|
|
516
|
-
var urlHost = host !== undefined ? host : Js_exn.raiseError("
|
|
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
|
-
|
|
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: "
|
|
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
|
|
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: "
|
|
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
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
var
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
var
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
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 =
|
|
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,
|
|
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 <
|
|
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 (
|
|
614
|
-
return
|
|
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,
|
|
621
|
-
var
|
|
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
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
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.
|
|
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.
|
|
1159
|
+
logIndex: log.logIndex,
|
|
759
1160
|
event: {
|
|
760
|
-
|
|
1161
|
+
contractName: eventConfig.contractName,
|
|
1162
|
+
eventName: eventConfig.name,
|
|
1163
|
+
params: eventConfig.convertHyperSyncEventArgs(maybeDecodedEvent),
|
|
761
1164
|
chainId: chain,
|
|
762
|
-
srcAddress:
|
|
763
|
-
logIndex: log.
|
|
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.
|
|
1176
|
+
var totalTimeElapsed = Hrtime.toSecondsFloat(Hrtime.timeSince(startFetchingBatchTimeRef));
|
|
773
1177
|
var reorgGuard_rangeLastBlock = {
|
|
774
|
-
blockHash:
|
|
775
|
-
blockNumber:
|
|
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
|
-
|
|
1192
|
+
knownHeight: knownHeight,
|
|
789
1193
|
reorgGuard: reorgGuard,
|
|
790
1194
|
parsedQueueItems: parsedQueueItems,
|
|
791
1195
|
fromBlockQueried: fromBlock,
|
|
792
|
-
latestFetchedBlockNumber:
|
|
793
|
-
latestFetchedBlockTimestamp:
|
|
1196
|
+
latestFetchedBlockNumber: latestFetchedBlockInfo.number,
|
|
1197
|
+
latestFetchedBlockTimestamp: latestFetchedBlockInfo.timestamp,
|
|
794
1198
|
stats: {
|
|
795
|
-
"total time elapsed (
|
|
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 (
|
|
1209
|
+
}))).then(function (rawBlocks) {
|
|
805
1210
|
return {
|
|
806
1211
|
TAG: "Ok",
|
|
807
|
-
_0: Belt_Array.map(
|
|
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
|
|
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:
|
|
1238
|
+
pollingInterval: syncConfig.pollingInterval,
|
|
829
1239
|
getBlockHashes: getBlockHashes,
|
|
830
|
-
getHeightOrThrow: (function () {
|
|
831
|
-
|
|
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
|
-
|
|
840
|
-
|
|
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
|
-
/*
|
|
1286
|
+
/* lowercaseAddressSchema Not a pure module */
|