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