envio 3.6.1 → 3.7.0-subgraph
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/index.d.ts +197 -9
- package/package.json +6 -6
- package/src/Batch.res +64 -25
- package/src/Batch.res.mjs +69 -46
- package/src/ChainFetching.res +13 -17
- package/src/ChainFetching.res.mjs +9 -14
- package/src/ChainState.res +160 -119
- package/src/ChainState.res.mjs +75 -46
- package/src/ChainState.resi +15 -12
- package/src/Config.res +18 -2
- package/src/Config.res.mjs +9 -6
- package/src/Core.res +20 -0
- package/src/Core.res.mjs +11 -0
- package/src/Ecosystem.res +0 -1
- package/src/Envio.res +16 -3
- package/src/EventConfigBuilder.res +155 -40
- package/src/EventConfigBuilder.res.mjs +76 -24
- package/src/EventProcessing.res +10 -14
- package/src/EventProcessing.res.mjs +12 -10
- package/src/EventUtils.res +3 -47
- package/src/FetchState.res +124 -104
- package/src/FetchState.res.mjs +116 -100
- package/src/HandlerLoader.res +20 -8
- package/src/HandlerLoader.res.mjs +11 -2
- package/src/HandlerRegister.res +108 -2
- package/src/HandlerRegister.res.mjs +59 -10
- package/src/HandlerRegister.resi +4 -0
- package/src/InMemoryStore.res +1 -6
- package/src/InMemoryStore.res.mjs +1 -3
- package/src/Internal.res +84 -24
- package/src/Internal.res.mjs +33 -2
- package/src/LazyLoader.res +12 -11
- package/src/LazyLoader.res.mjs +13 -7
- package/src/Main.res +22 -9
- package/src/Main.res.mjs +18 -5
- package/src/MemoryStorage.res +756 -0
- package/src/MemoryStorage.res.mjs +623 -0
- package/src/Persistence.res +4 -2
- package/src/PgStorage.res +24 -8
- package/src/PgStorage.res.mjs +15 -12
- package/src/ReorgDetection.res +0 -222
- package/src/ReorgDetection.res.mjs +0 -163
- package/src/Rollback.res +14 -15
- package/src/Rollback.res.mjs +4 -5
- package/src/SimulateItems.res +2 -2
- package/src/UserContext.res +358 -51
- package/src/UserContext.res.mjs +271 -35
- package/src/Utils.res +3 -0
- package/src/bindings/ClickHouse.res +16 -11
- package/src/bindings/ClickHouse.res.mjs +10 -10
- package/src/bindings/Vitest.res +1 -1
- package/src/sources/BlockStore.res +115 -5
- package/src/sources/BlockStore.res.mjs +25 -0
- package/src/sources/Evm.res +0 -1
- package/src/sources/Evm.res.mjs +0 -1
- package/src/sources/EvmHyperSyncSource.res +19 -84
- package/src/sources/EvmHyperSyncSource.res.mjs +24 -60
- package/src/sources/Fuel.res +24 -4
- package/src/sources/Fuel.res.mjs +23 -3
- package/src/sources/FuelHyperSync.res +8 -3
- package/src/sources/FuelHyperSync.res.mjs +5 -4
- package/src/sources/FuelHyperSync.resi +3 -1
- package/src/sources/FuelHyperSyncClient.res +7 -10
- package/src/sources/FuelHyperSyncSource.res +18 -45
- package/src/sources/FuelHyperSyncSource.res.mjs +18 -35
- package/src/sources/HyperSync.res +49 -229
- package/src/sources/HyperSync.res.mjs +74 -191
- package/src/sources/HyperSync.resi +11 -35
- package/src/sources/HyperSyncClient.res +9 -79
- package/src/sources/HyperSyncClient.res.mjs +2 -6
- package/src/sources/RequestStat.res +5 -0
- package/src/sources/RequestStat.res.mjs +2 -0
- package/src/sources/RpcSource.res +149 -43
- package/src/sources/RpcSource.res.mjs +104 -41
- package/src/sources/SimulateSource.res +8 -5
- package/src/sources/SimulateSource.res.mjs +6 -6
- package/src/sources/Source.res +89 -16
- package/src/sources/Source.res.mjs +50 -1
- package/src/sources/SourceManager.res +255 -50
- package/src/sources/SourceManager.res.mjs +149 -55
- package/src/sources/SourceManager.resi +2 -6
- package/src/sources/Svm.res +0 -7
- package/src/sources/Svm.res.mjs +0 -8
- package/src/sources/SvmHyperSyncClient.res +21 -16
- package/src/sources/SvmHyperSyncClient.res.mjs +3 -4
- package/src/sources/SvmHyperSyncSource.res +25 -117
- package/src/sources/SvmHyperSyncSource.res.mjs +8 -121
- package/src/subgraph/blocks.ts +176 -0
- package/src/subgraph/calls.ts +217 -0
- package/src/subgraph/conformance.ts +99 -0
- package/src/subgraph/division.ts +110 -0
- package/src/subgraph/errors.ts +90 -0
- package/src/subgraph/graph-ts-types/VERSION +2 -0
- package/src/subgraph/graph-ts-types/chain/arweave.d.ts +70 -0
- package/src/subgraph/graph-ts-types/chain/cosmos.d.ts +327 -0
- package/src/subgraph/graph-ts-types/chain/ethereum.d.ts +233 -0
- package/src/subgraph/graph-ts-types/chain/near.d.ts +253 -0
- package/src/subgraph/graph-ts-types/chain/starknet.d.ts +32 -0
- package/src/subgraph/graph-ts-types/common/collections.d.ts +136 -0
- package/src/subgraph/graph-ts-types/common/conversion.d.ts +11 -0
- package/src/subgraph/graph-ts-types/common/datasource.d.ts +30 -0
- package/src/subgraph/graph-ts-types/common/eager-offset.d.ts +0 -0
- package/src/subgraph/graph-ts-types/common/json.d.ts +17 -0
- package/src/subgraph/graph-ts-types/common/numbers.d.ts +120 -0
- package/src/subgraph/graph-ts-types/common/value.d.ts +120 -0
- package/src/subgraph/graph-ts-types/common/yaml.d.ts +90 -0
- package/src/subgraph/graph-ts-types/global/global.d.ts +194 -0
- package/src/subgraph/graph-ts-types/helper-functions.d.ts +22 -0
- package/src/subgraph/graph-ts-types/index.d.ts +102 -0
- package/src/subgraph/graph-ts.ts +1871 -0
- package/src/subgraph/hosts.ts +148 -0
- package/src/subgraph/runtime.ts +845 -0
- package/src/subgraph/scope.ts +63 -0
- package/svm.schema.json +3 -2
|
@@ -1,62 +1,89 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as Time from "../Time.res.mjs";
|
|
4
|
-
import * as Utils from "../Utils.res.mjs";
|
|
5
3
|
import * as Source from "./Source.res.mjs";
|
|
6
|
-
import * as Logging from "../Logging.res.mjs";
|
|
7
4
|
import * as Stdlib_Int from "@rescript/runtime/lib/es6/Stdlib_Int.js";
|
|
8
|
-
import * as Performance from "../bindings/Performance.res.mjs";
|
|
9
5
|
import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
|
|
10
6
|
import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
|
|
11
7
|
import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
|
|
12
8
|
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
13
|
-
import * as Stdlib_Result from "@rescript/runtime/lib/es6/Stdlib_Result.js";
|
|
14
|
-
import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
|
|
15
9
|
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
let e = Primitive_exceptions.internalToException(exn);
|
|
19
|
-
if (e.RE_EXN_ID !== "JsExn") {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
let msg = Stdlib_JsExn.message(e._1);
|
|
23
|
-
if (msg === undefined) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
if (!msg.startsWith("RATE_LIMITED:")) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
let resetMs = Stdlib_Option.getOr(Stdlib_Int.fromString(msg.slice(13, msg.length), undefined), 1000);
|
|
30
|
-
throw {
|
|
31
|
-
RE_EXN_ID: Source.RateLimited,
|
|
32
|
-
resetMs: resetMs,
|
|
33
|
-
Error: new Error()
|
|
34
|
-
};
|
|
35
|
-
}
|
|
11
|
+
let rateLimitedPrefix = "RATE_LIMITED:";
|
|
36
12
|
|
|
37
|
-
let
|
|
13
|
+
let behindHeadPrefix = "SOURCE_BEHIND_HEAD:";
|
|
38
14
|
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
return match.queryName + ` query failed due to unexpected missing params on response:
|
|
42
|
-
` + match.missingParams.join(", ");
|
|
15
|
+
function markerValue(msg, prefix) {
|
|
16
|
+
return Stdlib_Int.fromString(msg.slice(prefix.length, msg.length), undefined);
|
|
43
17
|
}
|
|
44
18
|
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
19
|
+
function mapNativeFailure(failure) {
|
|
20
|
+
let msg = failure.message;
|
|
21
|
+
if (msg !== undefined) {
|
|
22
|
+
if (msg.startsWith(rateLimitedPrefix)) {
|
|
23
|
+
return {
|
|
24
|
+
RE_EXN_ID: Source.RateLimited,
|
|
25
|
+
_1: {
|
|
26
|
+
resetMs: Stdlib_Option.getOr(markerValue(msg, rateLimitedPrefix), 1000),
|
|
27
|
+
requestStats: failure.requestStats
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
} else if (msg.startsWith(behindHeadPrefix)) {
|
|
31
|
+
return {
|
|
32
|
+
RE_EXN_ID: Source.SourceBehindHead,
|
|
33
|
+
blockNumber: Stdlib_Option.getOr(markerValue(msg, behindHeadPrefix), 0),
|
|
34
|
+
requestStats: failure.requestStats
|
|
35
|
+
};
|
|
36
|
+
} else {
|
|
37
|
+
return failure.cause;
|
|
38
|
+
}
|
|
51
39
|
} else {
|
|
40
|
+
return failure.cause;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function mapNativeFailureExn(exn) {
|
|
45
|
+
return mapNativeFailure(Source.unpackNativeRequestFailure(exn));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function makeGetBlockHashes(query) {
|
|
49
|
+
return async (blockNumbers, param) => {
|
|
50
|
+
let match;
|
|
51
|
+
try {
|
|
52
|
+
let match$1 = await query(blockNumbers);
|
|
53
|
+
match = [
|
|
54
|
+
{
|
|
55
|
+
TAG: "Ok",
|
|
56
|
+
_0: match$1[0]
|
|
57
|
+
},
|
|
58
|
+
match$1[1]
|
|
59
|
+
];
|
|
60
|
+
} catch (raw_exn) {
|
|
61
|
+
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
62
|
+
let failure = Source.unpackNativeRequestFailure(exn);
|
|
63
|
+
match = [
|
|
64
|
+
{
|
|
65
|
+
TAG: "Error",
|
|
66
|
+
_0: mapNativeFailure(failure)
|
|
67
|
+
},
|
|
68
|
+
failure.requestStats
|
|
69
|
+
];
|
|
70
|
+
}
|
|
52
71
|
return {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
RE_EXN_ID: HyperSyncQueryError,
|
|
56
|
-
_1: queryResponse._0
|
|
57
|
-
}
|
|
72
|
+
result: match[0],
|
|
73
|
+
requestStats: match[1]
|
|
58
74
|
};
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function reraiseIfRecoverable(exn) {
|
|
79
|
+
let exn$1 = mapNativeFailure(Source.unpackNativeRequestFailure(exn));
|
|
80
|
+
if (exn$1.RE_EXN_ID === Source.RateLimited) {
|
|
81
|
+
throw exn$1;
|
|
82
|
+
}
|
|
83
|
+
if (exn$1.RE_EXN_ID !== Source.SourceBehindHead) {
|
|
84
|
+
return;
|
|
59
85
|
}
|
|
86
|
+
throw exn$1;
|
|
60
87
|
}
|
|
61
88
|
|
|
62
89
|
let $$Error = /* @__PURE__ */Primitive_exceptions.create("HyperSync.GetLogs.Error");
|
|
@@ -95,7 +122,7 @@ async function query(client, fromBlock, toBlock, maxNumLogs, registrationIndexes
|
|
|
95
122
|
match = await client.getEventItems(query$1, addressSet);
|
|
96
123
|
} catch (raw_exn) {
|
|
97
124
|
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
98
|
-
|
|
125
|
+
reraiseIfRecoverable(exn);
|
|
99
126
|
let missingParams = extractMissingParams(exn);
|
|
100
127
|
if (missingParams !== undefined) {
|
|
101
128
|
throw {
|
|
@@ -119,10 +146,8 @@ async function query(client, fromBlock, toBlock, maxNumLogs, registrationIndexes
|
|
|
119
146
|
}
|
|
120
147
|
return {
|
|
121
148
|
items: res.items,
|
|
122
|
-
blocks: res.blocks,
|
|
123
149
|
nextBlock: res.nextBlock,
|
|
124
150
|
archiveHeight: Stdlib_Option.getOr(res.archiveHeight, 0),
|
|
125
|
-
rollbackGuard: res.rollbackGuard,
|
|
126
151
|
transactionStore: match[1],
|
|
127
152
|
blockStore: match[2]
|
|
128
153
|
};
|
|
@@ -134,153 +159,11 @@ let GetLogs = {
|
|
|
134
159
|
query: query
|
|
135
160
|
};
|
|
136
161
|
|
|
137
|
-
function makeRequestBody(fromBlock, toBlock) {
|
|
138
|
-
return {
|
|
139
|
-
fromBlock: fromBlock,
|
|
140
|
-
toBlock: toBlock + 1 | 0,
|
|
141
|
-
fieldSelection: {
|
|
142
|
-
block: [
|
|
143
|
-
"Number",
|
|
144
|
-
"Hash",
|
|
145
|
-
"Timestamp"
|
|
146
|
-
]
|
|
147
|
-
},
|
|
148
|
-
includeAllBlocks: true
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function convertResponse(res) {
|
|
153
|
-
return Utils.$$Array.transposeResults(res.data.blocks.map(block => {
|
|
154
|
-
let blockNumber = block.number;
|
|
155
|
-
if (blockNumber !== undefined) {
|
|
156
|
-
let blockHash = block.hash;
|
|
157
|
-
if (blockHash !== undefined) {
|
|
158
|
-
let blockTimestamp = block.timestamp;
|
|
159
|
-
if (blockTimestamp !== undefined) {
|
|
160
|
-
return {
|
|
161
|
-
TAG: "Ok",
|
|
162
|
-
_0: {
|
|
163
|
-
blockHash: blockHash,
|
|
164
|
-
blockNumber: blockNumber,
|
|
165
|
-
blockTimestamp: blockTimestamp
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
let missingParams = Stdlib_Array.filterMap([
|
|
172
|
-
Utils.Option.mapNone(block.number, "block.number"),
|
|
173
|
-
Utils.Option.mapNone(block.timestamp, "block.timestamp"),
|
|
174
|
-
Utils.Option.mapNone(block.hash, "block.hash")
|
|
175
|
-
], p => p);
|
|
176
|
-
return {
|
|
177
|
-
TAG: "Error",
|
|
178
|
-
_0: {
|
|
179
|
-
TAG: "UnexpectedMissingParams",
|
|
180
|
-
_0: {
|
|
181
|
-
queryName: "query block data HyperSync",
|
|
182
|
-
missingParams: missingParams
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
}));
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
async function queryBlockData(client, fromBlock, toBlock, sourceName, chainId, logger, requestStats) {
|
|
190
|
-
let body = makeRequestBody(fromBlock, toBlock);
|
|
191
|
-
let logger$1 = Logging.createChildFrom(logger, {
|
|
192
|
-
logType: "HyperSync get block hash query",
|
|
193
|
-
fromBlock: fromBlock,
|
|
194
|
-
toBlock: toBlock
|
|
195
|
-
});
|
|
196
|
-
let timerRef = Performance.now();
|
|
197
|
-
let maybeSuccessfulRes;
|
|
198
|
-
let exit = 0;
|
|
199
|
-
let res;
|
|
200
|
-
try {
|
|
201
|
-
res = await client.get(body);
|
|
202
|
-
exit = 1;
|
|
203
|
-
} catch (raw_exn) {
|
|
204
|
-
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
205
|
-
reraisIfRateLimited(exn);
|
|
206
|
-
maybeSuccessfulRes = undefined;
|
|
207
|
-
}
|
|
208
|
-
if (exit === 1) {
|
|
209
|
-
maybeSuccessfulRes = res.nextBlock <= fromBlock ? undefined : res;
|
|
210
|
-
}
|
|
211
|
-
requestStats.push({
|
|
212
|
-
method: "getBlockHashes",
|
|
213
|
-
seconds: Performance.secondsSince(timerRef)
|
|
214
|
-
});
|
|
215
|
-
if (maybeSuccessfulRes !== undefined) {
|
|
216
|
-
let err = convertResponse(maybeSuccessfulRes);
|
|
217
|
-
if (err.TAG !== "Ok") {
|
|
218
|
-
return err;
|
|
219
|
-
}
|
|
220
|
-
if (maybeSuccessfulRes.nextBlock > toBlock) {
|
|
221
|
-
return err;
|
|
222
|
-
}
|
|
223
|
-
let datas = err._0;
|
|
224
|
-
let restRes = await queryBlockData(client, maybeSuccessfulRes.nextBlock, toBlock, sourceName, chainId, logger$1, requestStats);
|
|
225
|
-
return Stdlib_Result.map(restRes, rest => datas.concat(rest));
|
|
226
|
-
}
|
|
227
|
-
Logging.childInfo(logger$1, `Block #` + fromBlock.toString() + ` not found in HyperSync. HyperSync has multiple instances and it's possible that they drift independently slightly from the head. Indexing should continue correctly after retrying the query in ` + (100).toString() + `ms.`);
|
|
228
|
-
await Time.resolvePromiseAfterDelay(100);
|
|
229
|
-
return await queryBlockData(client, fromBlock, toBlock, sourceName, chainId, logger$1, requestStats);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
async function queryBlockDataMulti(client, blockNumbers, sourceName, chainId, logger) {
|
|
233
|
-
let requestStats = [];
|
|
234
|
-
let firstBlock = blockNumbers[0];
|
|
235
|
-
let result;
|
|
236
|
-
if (firstBlock !== undefined) {
|
|
237
|
-
let fromBlock = firstBlock;
|
|
238
|
-
let toBlock = firstBlock;
|
|
239
|
-
let set = new Set();
|
|
240
|
-
for (let idx = 0, idx_finish = blockNumbers.length; idx < idx_finish; ++idx) {
|
|
241
|
-
let blockNumber = blockNumbers[idx];
|
|
242
|
-
if (blockNumber < fromBlock) {
|
|
243
|
-
fromBlock = blockNumber;
|
|
244
|
-
}
|
|
245
|
-
if (blockNumber > toBlock) {
|
|
246
|
-
toBlock = blockNumber;
|
|
247
|
-
}
|
|
248
|
-
set.add(blockNumber);
|
|
249
|
-
}
|
|
250
|
-
if ((toBlock - fromBlock | 0) > 1000) {
|
|
251
|
-
Stdlib_JsError.throwWithMessage(`Invalid block data request. Range of block numbers is too large. Max range is 1000. Requested range: ` + fromBlock.toString() + `-` + toBlock.toString());
|
|
252
|
-
}
|
|
253
|
-
let res = await queryBlockData(client, fromBlock, toBlock, sourceName, chainId, logger, requestStats);
|
|
254
|
-
let filtered = Stdlib_Result.map(res, datas => datas.filter(data => set.delete(data.blockNumber)));
|
|
255
|
-
if (set.size > 0) {
|
|
256
|
-
Stdlib_JsError.throwWithMessage(`Invalid response. Failed to get block data for block numbers: ` + Array.from(set).join(", "));
|
|
257
|
-
}
|
|
258
|
-
result = filtered;
|
|
259
|
-
} else {
|
|
260
|
-
result = {
|
|
261
|
-
TAG: "Ok",
|
|
262
|
-
_0: []
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
return [
|
|
266
|
-
result,
|
|
267
|
-
requestStats
|
|
268
|
-
];
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function queryBlockData$1(client, blockNumber, sourceName, chainId, logger) {
|
|
272
|
-
let requestStats = [];
|
|
273
|
-
return queryBlockData(client, blockNumber, blockNumber, sourceName, chainId, logger, requestStats).then(res => [
|
|
274
|
-
Stdlib_Result.map(res, res => res[0]),
|
|
275
|
-
requestStats
|
|
276
|
-
]);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
162
|
export {
|
|
280
|
-
|
|
163
|
+
mapNativeFailure,
|
|
164
|
+
mapNativeFailureExn,
|
|
165
|
+
reraiseIfRecoverable,
|
|
166
|
+
makeGetBlockHashes,
|
|
281
167
|
GetLogs,
|
|
282
|
-
queryBlockData$1 as queryBlockData,
|
|
283
|
-
queryBlockDataMulti,
|
|
284
|
-
mapExn,
|
|
285
168
|
}
|
|
286
|
-
/*
|
|
169
|
+
/* Source Not a pure module */
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
type logsQueryPage = {
|
|
2
2
|
items: array<HyperSyncClient.EventItems.item>,
|
|
3
|
-
blocks: array<HyperSyncClient.EventItems.blockHeader>,
|
|
4
3
|
nextBlock: int,
|
|
5
4
|
archiveHeight: int,
|
|
6
|
-
rollbackGuard: option<HyperSyncClient.ResponseTypes.rollbackGuard>,
|
|
7
5
|
transactionStore: TransactionStore.t,
|
|
8
6
|
blockStore: BlockStore.t,
|
|
9
7
|
}
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
let queryErrorToMsq: queryError => string
|
|
9
|
+
// Map a native client's `PREFIX:<int>` failure marker onto the exception
|
|
10
|
+
// SourceManager retries on (`RateLimited` / `SourceBehindHead`), falling back to
|
|
11
|
+
// the original cause.
|
|
12
|
+
let mapNativeFailure: Source.nativeRequestFailure => exn
|
|
13
|
+
let mapNativeFailureExn: exn => exn
|
|
14
|
+
let reraiseIfRecoverable: exn => unit
|
|
19
15
|
|
|
20
|
-
|
|
16
|
+
// Wrap a native client's paginated block-hash query as a `Source.getBlockHashes`,
|
|
17
|
+
// keeping the request timings whether it succeeds or fails.
|
|
18
|
+
let makeGetBlockHashes: (
|
|
19
|
+
~query: (~blockNumbers: array<int>) => promise<(BlockStore.t, array<Source.requestStat>)>,
|
|
20
|
+
) => (~blockNumbers: array<int>, ~logger: Pino.t) => promise<Source.getBlockHashesResponse>
|
|
21
21
|
|
|
22
22
|
module GetLogs: {
|
|
23
23
|
type error =
|
|
@@ -38,27 +38,3 @@ module GetLogs: {
|
|
|
38
38
|
~clientFilteredContracts: option<array<string>>,
|
|
39
39
|
) => promise<logsQueryPage>
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
let queryBlockData: (
|
|
43
|
-
~client: HyperSyncClient.t,
|
|
44
|
-
~blockNumber: int,
|
|
45
|
-
~sourceName: string,
|
|
46
|
-
~chainId: ChainId.t,
|
|
47
|
-
~logger: Pino.t,
|
|
48
|
-
) => promise<(
|
|
49
|
-
queryResponse<option<ReorgDetection.blockDataWithTimestamp>>,
|
|
50
|
-
array<Source.requestStat>,
|
|
51
|
-
)>
|
|
52
|
-
|
|
53
|
-
let queryBlockDataMulti: (
|
|
54
|
-
~client: HyperSyncClient.t,
|
|
55
|
-
~blockNumbers: array<int>,
|
|
56
|
-
~sourceName: string,
|
|
57
|
-
~chainId: ChainId.t,
|
|
58
|
-
~logger: Pino.t,
|
|
59
|
-
) => promise<(
|
|
60
|
-
queryResponse<array<ReorgDetection.blockDataWithTimestamp>>,
|
|
61
|
-
array<Source.requestStat>,
|
|
62
|
-
)>
|
|
63
|
-
|
|
64
|
-
let mapExn: queryResponse<'a> => result<'a, exn>
|
|
@@ -15,7 +15,6 @@ type cfg = {
|
|
|
15
15
|
/** Milliseconds to wait for a response before timing out. Default: 30000. */
|
|
16
16
|
httpReqTimeoutMillis?: int,
|
|
17
17
|
/** Number of retries to attempt before returning error. Default: 12. */
|
|
18
|
-
maxNumRetries?: int,
|
|
19
18
|
/** Milliseconds that would be used for retry backoff increasing. Default: 500. */
|
|
20
19
|
retryBackoffMs?: int,
|
|
21
20
|
/** Initial wait time for request backoff. Default: 200. */
|
|
@@ -169,66 +168,8 @@ module QueryTypes = {
|
|
|
169
168
|
}
|
|
170
169
|
}
|
|
171
170
|
|
|
172
|
-
module ResponseTypes = {
|
|
173
|
-
type withdrawal = {
|
|
174
|
-
index?: string,
|
|
175
|
-
validatorIndex?: string,
|
|
176
|
-
address?: Address.t,
|
|
177
|
-
amount?: string,
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
type block = {
|
|
181
|
-
number?: int,
|
|
182
|
-
hash?: string,
|
|
183
|
-
parentHash?: string,
|
|
184
|
-
nonce?: bigint,
|
|
185
|
-
sha3Uncles?: string,
|
|
186
|
-
logsBloom?: string,
|
|
187
|
-
transactionsRoot?: string,
|
|
188
|
-
stateRoot?: string,
|
|
189
|
-
receiptsRoot?: string,
|
|
190
|
-
miner?: Address.t,
|
|
191
|
-
difficulty?: bigint,
|
|
192
|
-
totalDifficulty?: bigint,
|
|
193
|
-
extraData?: string,
|
|
194
|
-
size?: bigint,
|
|
195
|
-
gasLimit?: bigint,
|
|
196
|
-
gasUsed?: bigint,
|
|
197
|
-
timestamp?: int,
|
|
198
|
-
uncles?: array<string>,
|
|
199
|
-
baseFeePerGas?: bigint,
|
|
200
|
-
blobGasUsed?: bigint,
|
|
201
|
-
excessBlobGas?: bigint,
|
|
202
|
-
parentBeaconBlockRoot?: string,
|
|
203
|
-
withdrawalsRoot?: string,
|
|
204
|
-
withdrawals?: array<withdrawal>,
|
|
205
|
-
l1BlockNumber?: int,
|
|
206
|
-
sendCount?: string,
|
|
207
|
-
sendRoot?: string,
|
|
208
|
-
mixHash?: string,
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
type rollbackGuard = {
|
|
212
|
-
blockNumber: int,
|
|
213
|
-
timestamp: int,
|
|
214
|
-
hash: string,
|
|
215
|
-
firstBlockNumber: int,
|
|
216
|
-
firstParentHash: string,
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
171
|
type query = QueryTypes.query
|
|
221
172
|
|
|
222
|
-
type queryResponseData = {blocks: array<ResponseTypes.block>}
|
|
223
|
-
|
|
224
|
-
type queryResponse = {
|
|
225
|
-
archiveHeight: option<int>,
|
|
226
|
-
nextBlock: int,
|
|
227
|
-
totalExecutionTime: int,
|
|
228
|
-
data: queryResponseData,
|
|
229
|
-
rollbackGuard: option<ResponseTypes.rollbackGuard>,
|
|
230
|
-
}
|
|
231
|
-
|
|
232
173
|
module Registration = {
|
|
233
174
|
// One topic position of the resolved `where`: static topic values, or
|
|
234
175
|
// `None` — the "currently registered addresses of this contract" marker,
|
|
@@ -295,12 +236,12 @@ module Registration = {
|
|
|
295
236
|
}),
|
|
296
237
|
// Capitalized to match the Rust BlockField/TransactionField string
|
|
297
238
|
// enums.
|
|
298
|
-
blockFields:
|
|
239
|
+
blockFields: reg.fieldSelection.blockFields
|
|
299
240
|
->Utils.Set.toArray
|
|
300
|
-
->Array.map(
|
|
301
|
-
transactionFields:
|
|
241
|
+
->Array.map(Utils.String.capitalize),
|
|
242
|
+
transactionFields: reg.fieldSelection.transactionFields
|
|
302
243
|
->Utils.Set.toArray
|
|
303
|
-
->Array.map(
|
|
244
|
+
->Array.map(Utils.String.capitalize),
|
|
304
245
|
}
|
|
305
246
|
})
|
|
306
247
|
}
|
|
@@ -338,28 +279,19 @@ module EventItems = {
|
|
|
338
279
|
params: Internal.eventParams,
|
|
339
280
|
}
|
|
340
281
|
|
|
341
|
-
// The always-needed block fields, one per block number. The block's remaining
|
|
342
|
-
// fields live raw in the block store and are materialised on demand.
|
|
343
|
-
type blockHeader = {
|
|
344
|
-
number: int,
|
|
345
|
-
timestamp: int,
|
|
346
|
-
hash: string,
|
|
347
|
-
}
|
|
348
|
-
|
|
349
282
|
type response = {
|
|
350
283
|
archiveHeight: option<int>,
|
|
351
284
|
nextBlock: int,
|
|
352
|
-
// One header per returned block number, including blocks no item
|
|
353
|
-
// references — reorg detection reads them all. The block store keeps only
|
|
354
|
-
// the ones items reference.
|
|
355
|
-
blocks: array<blockHeader>,
|
|
356
285
|
items: array<item>,
|
|
357
|
-
rollbackGuard: option<ResponseTypes.rollbackGuard>,
|
|
358
286
|
}
|
|
359
287
|
}
|
|
360
288
|
|
|
361
289
|
type t = {
|
|
362
|
-
|
|
290
|
+
// Block-hash query construction and pagination live in Rust; only the
|
|
291
|
+
// aggregate response store crosses the boundary.
|
|
292
|
+
getBlockHashes: (
|
|
293
|
+
~blockNumbers: array<int>,
|
|
294
|
+
) => promise<(BlockStore.t, array<RequestStat.t>)>,
|
|
363
295
|
// Returns the response plus page stores owning this page's raw transactions
|
|
364
296
|
// and blocks.
|
|
365
297
|
getEventItems: (
|
|
@@ -414,8 +346,6 @@ let make = (
|
|
|
414
346
|
enableChecksumAddresses,
|
|
415
347
|
apiToken,
|
|
416
348
|
httpReqTimeoutMillis,
|
|
417
|
-
// Retries are handled internally by the indexer, not the binary client
|
|
418
|
-
maxNumRetries: 0,
|
|
419
349
|
?serializationFormat,
|
|
420
350
|
?enableQueryCaching,
|
|
421
351
|
?retryBaseMs,
|
|
@@ -34,8 +34,6 @@ let QueryTypes = {
|
|
|
34
34
|
makeLogSelection: makeLogSelection
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
let ResponseTypes = {};
|
|
38
|
-
|
|
39
37
|
function toTopicFilterInput(filter) {
|
|
40
38
|
if (filter.TAG === "Values") {
|
|
41
39
|
return filter._0;
|
|
@@ -61,8 +59,8 @@ function fromOnEventRegistrations(onEventRegistrations) {
|
|
|
61
59
|
topic2: toTopicFilterInput(ts.topic2),
|
|
62
60
|
topic3: toTopicFilterInput(ts.topic3)
|
|
63
61
|
})),
|
|
64
|
-
blockFields: Array.from(
|
|
65
|
-
transactionFields: Array.from(
|
|
62
|
+
blockFields: Array.from(reg.fieldSelection.blockFields).map(Utils.$$String.capitalize),
|
|
63
|
+
transactionFields: Array.from(reg.fieldSelection.transactionFields).map(Utils.$$String.capitalize)
|
|
66
64
|
};
|
|
67
65
|
});
|
|
68
66
|
}
|
|
@@ -108,7 +106,6 @@ function make(url, apiToken, httpReqTimeoutMillis, eventRegistrations, enableChe
|
|
|
108
106
|
url: url,
|
|
109
107
|
apiToken: apiToken,
|
|
110
108
|
httpReqTimeoutMillis: httpReqTimeoutMillis,
|
|
111
|
-
maxNumRetries: 0,
|
|
112
109
|
retryBackoffMs: retryBackoffMs,
|
|
113
110
|
retryBaseMs: retryBaseMs,
|
|
114
111
|
retryCeilingMs: retryCeilingMs,
|
|
@@ -122,7 +119,6 @@ function make(url, apiToken, httpReqTimeoutMillis, eventRegistrations, enableChe
|
|
|
122
119
|
export {
|
|
123
120
|
serializationFormatSchema,
|
|
124
121
|
QueryTypes,
|
|
125
|
-
ResponseTypes,
|
|
126
122
|
Registration,
|
|
127
123
|
EventItems,
|
|
128
124
|
makeWithAgent,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// A single backend request a source method made, with the time it took. Kept
|
|
2
|
+
// in its own leaf module (rather than on `Source`) so the client FFI bindings
|
|
3
|
+
// can name it without importing `Source` — which would form a dependency cycle
|
|
4
|
+
// through `Env → HyperSyncClient → Source → FetchState → Env`.
|
|
5
|
+
type t = {method: string, seconds: float}
|