envio 3.3.1 → 3.4.0
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/package.json +6 -6
- package/src/Api.res +1 -8
- package/src/Api.res.mjs +1 -5
- package/src/ChainState.res +6 -1
- package/src/ChainState.res.mjs +4 -3
- package/src/Config.res +33 -4
- package/src/Config.res.mjs +34 -5
- package/src/Core.res +30 -19
- package/src/Core.res.mjs +5 -5
- package/src/EnvioGlobal.res +0 -2
- package/src/EnvioGlobal.res.mjs +0 -1
- package/src/ExitOnCaughtUp.res +6 -2
- package/src/ExitOnCaughtUp.res.mjs +4 -0
- package/src/FetchState.res +3 -3
- package/src/HandlerRegister.res +357 -434
- package/src/HandlerRegister.res.mjs +202 -242
- package/src/HandlerRegister.resi +7 -15
- package/src/IndexerState.res +10 -0
- package/src/IndexerState.res.mjs +9 -3
- package/src/IndexerState.resi +3 -0
- package/src/Internal.res +10 -1
- package/src/Main.res.mjs +4 -4
- package/src/PgStorage.res +52 -26
- package/src/PgStorage.res.mjs +32 -23
- package/src/SimulateItems.res +61 -40
- package/src/SimulateItems.res.mjs +37 -21
- package/src/TestIndexer.res +446 -453
- package/src/TestIndexer.res.mjs +320 -343
- package/src/bindings/ClickHouse.res +68 -2
- package/src/bindings/ClickHouse.res.mjs +47 -2
- package/src/sources/EvmChain.res +1 -1
- package/src/sources/EvmChain.res.mjs +2 -2
- package/src/sources/FuelHyperSync.res +74 -0
- package/src/sources/FuelHyperSync.res.mjs +80 -0
- package/src/sources/FuelHyperSync.resi +22 -0
- package/src/sources/FuelHyperSyncClient.res +120 -0
- package/src/sources/FuelHyperSyncClient.res.mjs +71 -0
- package/src/sources/FuelHyperSyncSource.res +257 -0
- package/src/sources/FuelHyperSyncSource.res.mjs +252 -0
- package/src/sources/HyperSyncClient.res +2 -2
- package/src/sources/HyperSyncClient.res.mjs +1 -1
- package/src/sources/SvmHyperSyncClient.res +139 -102
- package/src/sources/SvmHyperSyncClient.res.mjs +45 -5
- package/src/sources/SvmHyperSyncSource.res +60 -440
- package/src/sources/SvmHyperSyncSource.res.mjs +42 -363
- package/src/TestIndexerProxyStorage.res +0 -196
- package/src/TestIndexerProxyStorage.res.mjs +0 -121
- package/src/TestIndexerWorker.res +0 -4
- package/src/TestIndexerWorker.res.mjs +0 -7
- package/src/sources/EventRouter.res +0 -165
- package/src/sources/EventRouter.res.mjs +0 -153
- package/src/sources/HyperFuel.res +0 -179
- package/src/sources/HyperFuel.res.mjs +0 -146
- package/src/sources/HyperFuel.resi +0 -36
- package/src/sources/HyperFuelClient.res +0 -127
- package/src/sources/HyperFuelClient.res.mjs +0 -20
- package/src/sources/HyperFuelSource.res +0 -502
- package/src/sources/HyperFuelSource.res.mjs +0 -481
- /package/src/sources/{HyperSyncSource.res → EvmHyperSyncSource.res} +0 -0
- /package/src/sources/{HyperSyncSource.res.mjs → EvmHyperSyncSource.res.mjs} +0 -0
|
@@ -1,481 +0,0 @@
|
|
|
1
|
-
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
|
|
3
|
-
import * as Source from "./Source.res.mjs";
|
|
4
|
-
import * as Logging from "../Logging.res.mjs";
|
|
5
|
-
import * as HyperFuel from "./HyperFuel.res.mjs";
|
|
6
|
-
import * as EventRouter from "./EventRouter.res.mjs";
|
|
7
|
-
import * as Performance from "../bindings/Performance.res.mjs";
|
|
8
|
-
import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
|
|
9
|
-
import * as ErrorHandling from "../ErrorHandling.res.mjs";
|
|
10
|
-
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
11
|
-
import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
|
|
12
|
-
import * as HyperFuelClient from "./HyperFuelClient.res.mjs";
|
|
13
|
-
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
14
|
-
|
|
15
|
-
let EventRoutingFailed = /* @__PURE__ */Primitive_exceptions.create("HyperFuelSource.EventRoutingFailed");
|
|
16
|
-
|
|
17
|
-
function isUnauthorizedError(message) {
|
|
18
|
-
return message.includes("401 Unauthorized");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
let mintEventTag = "mint";
|
|
22
|
-
|
|
23
|
-
let burnEventTag = "burn";
|
|
24
|
-
|
|
25
|
-
let transferEventTag = "transfer";
|
|
26
|
-
|
|
27
|
-
let callEventTag = "call";
|
|
28
|
-
|
|
29
|
-
let logDataReceiptTypeSelection = [6];
|
|
30
|
-
|
|
31
|
-
let txStatusSelection = [1];
|
|
32
|
-
|
|
33
|
-
function makeGetNormalRecieptsSelection(nonWildcardLogDataRbsByContract, nonLogDataReceiptTypesByContract, contractNames) {
|
|
34
|
-
return addressesByContractName => {
|
|
35
|
-
let selection = [];
|
|
36
|
-
contractNames.forEach(contractName => {
|
|
37
|
-
let addresses = addressesByContractName[contractName];
|
|
38
|
-
if (addresses === undefined) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (addresses.length === 0) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
let receiptTypes = nonLogDataReceiptTypesByContract[contractName];
|
|
45
|
-
if (receiptTypes !== undefined) {
|
|
46
|
-
selection.push({
|
|
47
|
-
rootContractId: addresses,
|
|
48
|
-
receiptType: receiptTypes,
|
|
49
|
-
txStatus: txStatusSelection
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
let nonWildcardLogDataRbs = nonWildcardLogDataRbsByContract[contractName];
|
|
53
|
-
if (nonWildcardLogDataRbs !== undefined && nonWildcardLogDataRbs.length !== 0) {
|
|
54
|
-
selection.push({
|
|
55
|
-
rootContractId: addresses,
|
|
56
|
-
receiptType: logDataReceiptTypeSelection,
|
|
57
|
-
rb: nonWildcardLogDataRbs,
|
|
58
|
-
txStatus: txStatusSelection
|
|
59
|
-
});
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
return selection;
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function makeWildcardRecieptsSelection(wildcardLogDataRbs, nonLogDataWildcardReceiptTypes) {
|
|
68
|
-
let selection = [];
|
|
69
|
-
if (nonLogDataWildcardReceiptTypes.length !== 0) {
|
|
70
|
-
selection.push({
|
|
71
|
-
receiptType: nonLogDataWildcardReceiptTypes,
|
|
72
|
-
txStatus: txStatusSelection
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
if (wildcardLogDataRbs.length !== 0) {
|
|
76
|
-
selection.push({
|
|
77
|
-
receiptType: logDataReceiptTypeSelection,
|
|
78
|
-
rb: wildcardLogDataRbs,
|
|
79
|
-
txStatus: txStatusSelection
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
return selection;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function getSelectionConfig(selection, chain) {
|
|
86
|
-
let eventRouter = EventRouter.empty();
|
|
87
|
-
let nonWildcardLogDataRbsByContract = {};
|
|
88
|
-
let wildcardLogDataRbs = [];
|
|
89
|
-
let nonLogDataReceiptTypesByContract = {};
|
|
90
|
-
let nonLogDataWildcardReceiptTypes = [];
|
|
91
|
-
let addNonLogDataWildcardReceiptTypes = receiptType => {
|
|
92
|
-
nonLogDataWildcardReceiptTypes.push(receiptType);
|
|
93
|
-
};
|
|
94
|
-
let addNonLogDataReceiptType = (contractName, receiptType) => {
|
|
95
|
-
let receiptTypes = nonLogDataReceiptTypesByContract[contractName];
|
|
96
|
-
if (receiptTypes !== undefined) {
|
|
97
|
-
receiptTypes.push(receiptType);
|
|
98
|
-
} else {
|
|
99
|
-
nonLogDataReceiptTypesByContract[contractName] = [receiptType];
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
let contractNames = new Set();
|
|
103
|
-
selection.onEventRegistrations.forEach(reg => {
|
|
104
|
-
let eventConfig = reg.eventConfig;
|
|
105
|
-
let contractName = eventConfig.contractName;
|
|
106
|
-
let isWildcard = reg.isWildcard;
|
|
107
|
-
if (!isWildcard) {
|
|
108
|
-
contractNames.add(contractName);
|
|
109
|
-
}
|
|
110
|
-
EventRouter.addOrThrow(eventRouter, eventConfig.id, reg, contractName, isWildcard, eventConfig.name, chain);
|
|
111
|
-
let match = eventConfig.kind;
|
|
112
|
-
if (typeof match !== "object") {
|
|
113
|
-
switch (match) {
|
|
114
|
-
case "Mint" :
|
|
115
|
-
if (isWildcard) {
|
|
116
|
-
return addNonLogDataWildcardReceiptTypes(11);
|
|
117
|
-
} else {
|
|
118
|
-
return addNonLogDataReceiptType(contractName, 11);
|
|
119
|
-
}
|
|
120
|
-
case "Burn" :
|
|
121
|
-
if (isWildcard) {
|
|
122
|
-
return addNonLogDataWildcardReceiptTypes(12);
|
|
123
|
-
} else {
|
|
124
|
-
return addNonLogDataReceiptType(contractName, 12);
|
|
125
|
-
}
|
|
126
|
-
case "Transfer" :
|
|
127
|
-
if (isWildcard) {
|
|
128
|
-
addNonLogDataWildcardReceiptTypes(7);
|
|
129
|
-
return addNonLogDataWildcardReceiptTypes(8);
|
|
130
|
-
} else {
|
|
131
|
-
addNonLogDataReceiptType(contractName, 7);
|
|
132
|
-
return addNonLogDataReceiptType(contractName, 8);
|
|
133
|
-
}
|
|
134
|
-
case "Call" :
|
|
135
|
-
if (isWildcard) {
|
|
136
|
-
return addNonLogDataWildcardReceiptTypes(0);
|
|
137
|
-
} else {
|
|
138
|
-
return Stdlib_JsError.throwWithMessage("Call receipt indexing currently supported only in wildcard mode");
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
} else {
|
|
142
|
-
let rb = BigInt(match.logId);
|
|
143
|
-
if (isWildcard) {
|
|
144
|
-
wildcardLogDataRbs.push(rb);
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
let arr = nonWildcardLogDataRbsByContract[contractName];
|
|
148
|
-
if (arr !== undefined) {
|
|
149
|
-
arr.push(rb);
|
|
150
|
-
} else {
|
|
151
|
-
nonWildcardLogDataRbsByContract[contractName] = [rb];
|
|
152
|
-
}
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
let tmp;
|
|
157
|
-
if (selection.dependsOnAddresses) {
|
|
158
|
-
tmp = makeGetNormalRecieptsSelection(nonWildcardLogDataRbsByContract, nonLogDataReceiptTypesByContract, contractNames);
|
|
159
|
-
} else {
|
|
160
|
-
let recieptsSelection = makeWildcardRecieptsSelection(wildcardLogDataRbs, nonLogDataWildcardReceiptTypes);
|
|
161
|
-
tmp = param => recieptsSelection;
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
getRecieptsSelection: tmp,
|
|
165
|
-
eventRouter: eventRouter
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function memoGetSelectionConfig(chain) {
|
|
170
|
-
let cache = new WeakMap();
|
|
171
|
-
return selection => {
|
|
172
|
-
let c = cache.get(selection);
|
|
173
|
-
if (c !== undefined) {
|
|
174
|
-
return c;
|
|
175
|
-
}
|
|
176
|
-
let c$1 = getSelectionConfig(selection, chain);
|
|
177
|
-
cache.set(selection, c$1);
|
|
178
|
-
return c$1;
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function make(param) {
|
|
183
|
-
let apiToken = param.apiToken;
|
|
184
|
-
let chain = param.chain;
|
|
185
|
-
let apiToken$1 = apiToken !== undefined ? apiToken : Stdlib_JsError.throwWithMessage(`An Envio API token is required for using HyperFuel as a data-source.
|
|
186
|
-
Set the ENVIO_API_TOKEN environment variable in your .env file.
|
|
187
|
-
Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
188
|
-
let client;
|
|
189
|
-
try {
|
|
190
|
-
client = HyperFuelClient.make({
|
|
191
|
-
url: param.endpointUrl,
|
|
192
|
-
apiToken: apiToken$1
|
|
193
|
-
});
|
|
194
|
-
} catch (raw_exn) {
|
|
195
|
-
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
196
|
-
client = ErrorHandling.mkLogAndRaise(undefined, "Failed to instantiate the HyperFuel client", exn);
|
|
197
|
-
}
|
|
198
|
-
let getSelectionConfig = memoGetSelectionConfig(chain);
|
|
199
|
-
let getItemsOrThrow = async (fromBlock, toBlock, addressesByContractName, contractNameByAddress, knownHeight, param, selection, param$1, retry, logger) => {
|
|
200
|
-
let totalTimeRef = Performance.now();
|
|
201
|
-
let selectionConfig = getSelectionConfig(selection);
|
|
202
|
-
let recieptsSelection = selectionConfig.getRecieptsSelection(addressesByContractName);
|
|
203
|
-
let startFetchingBatchTimeRef = Performance.now();
|
|
204
|
-
let pageUnsafe;
|
|
205
|
-
try {
|
|
206
|
-
pageUnsafe = await HyperFuel.GetLogs.query(client, fromBlock, toBlock, recieptsSelection);
|
|
207
|
-
} catch (raw_error) {
|
|
208
|
-
let error = Primitive_exceptions.internalToException(raw_error);
|
|
209
|
-
if (error.RE_EXN_ID === HyperFuel.GetLogs.$$Error) {
|
|
210
|
-
let error$1 = error._1;
|
|
211
|
-
let tmp;
|
|
212
|
-
if (typeof error$1 !== "object") {
|
|
213
|
-
let backoffMillis = retry !== 0 ? 500 * retry | 0 : 100;
|
|
214
|
-
tmp = {
|
|
215
|
-
TAG: "WithBackoff",
|
|
216
|
-
message: `Block #` + fromBlock.toString() + ` not found in HyperFuel. HyperFuel has multiple instances and it's possible that they drift independently slightly from the head. Indexing should continue correctly after retrying the query in ` + backoffMillis.toString() + `ms.`,
|
|
217
|
-
backoffMillis: backoffMillis
|
|
218
|
-
};
|
|
219
|
-
} else {
|
|
220
|
-
tmp = {
|
|
221
|
-
TAG: "ImpossibleForTheQuery",
|
|
222
|
-
message: `Source returned invalid data with missing required fields: ` + error$1.missingParams.join(", ")
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
throw {
|
|
226
|
-
RE_EXN_ID: Source.GetItemsError,
|
|
227
|
-
_1: {
|
|
228
|
-
TAG: "FailedGettingItems",
|
|
229
|
-
exn: null,
|
|
230
|
-
attemptedToBlock: Stdlib_Option.getOr(toBlock, knownHeight),
|
|
231
|
-
retry: tmp
|
|
232
|
-
},
|
|
233
|
-
Error: new Error()
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
throw {
|
|
237
|
-
RE_EXN_ID: Source.GetItemsError,
|
|
238
|
-
_1: {
|
|
239
|
-
TAG: "FailedGettingItems",
|
|
240
|
-
exn: error,
|
|
241
|
-
attemptedToBlock: Stdlib_Option.getOr(toBlock, knownHeight),
|
|
242
|
-
retry: {
|
|
243
|
-
TAG: "WithBackoff",
|
|
244
|
-
message: `Unexpected issue while fetching events from HyperFuel client. Attempt a retry.`,
|
|
245
|
-
backoffMillis: retry !== 0 ? 1000 * retry | 0 : 500
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
Error: new Error()
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
let pageFetchTime = Performance.secondsSince(startFetchingBatchTimeRef);
|
|
252
|
-
let requestStats = [{
|
|
253
|
-
method: "getLogs",
|
|
254
|
-
seconds: pageFetchTime
|
|
255
|
-
}];
|
|
256
|
-
let knownHeight$1 = pageUnsafe.archiveHeight;
|
|
257
|
-
let heighestBlockQueried = pageUnsafe.nextBlock - 1 | 0;
|
|
258
|
-
let parsingTimeRef = Performance.now();
|
|
259
|
-
let parsedQueueItems = pageUnsafe.items.map(item => {
|
|
260
|
-
let block = item.block;
|
|
261
|
-
let receiptIndex = item.receiptIndex;
|
|
262
|
-
let receipt = item.receipt;
|
|
263
|
-
let contractAddress = item.contractId;
|
|
264
|
-
let eventId;
|
|
265
|
-
switch (receipt.receiptType) {
|
|
266
|
-
case 0 :
|
|
267
|
-
eventId = callEventTag;
|
|
268
|
-
break;
|
|
269
|
-
case 6 :
|
|
270
|
-
eventId = receipt.rb.toString();
|
|
271
|
-
break;
|
|
272
|
-
case 7 :
|
|
273
|
-
case 8 :
|
|
274
|
-
eventId = transferEventTag;
|
|
275
|
-
break;
|
|
276
|
-
case 11 :
|
|
277
|
-
eventId = mintEventTag;
|
|
278
|
-
break;
|
|
279
|
-
case 12 :
|
|
280
|
-
eventId = burnEventTag;
|
|
281
|
-
break;
|
|
282
|
-
}
|
|
283
|
-
let onEventRegistration = EventRouter.get(selectionConfig.eventRouter, eventId, contractAddress, contractNameByAddress);
|
|
284
|
-
let onEventRegistration$1;
|
|
285
|
-
if (onEventRegistration !== undefined) {
|
|
286
|
-
onEventRegistration$1 = onEventRegistration;
|
|
287
|
-
} else {
|
|
288
|
-
let logger$1 = Logging.createChildFrom(logger, {
|
|
289
|
-
chainId: chain,
|
|
290
|
-
blockNumber: block.height,
|
|
291
|
-
logIndex: receiptIndex,
|
|
292
|
-
contractAddress: contractAddress,
|
|
293
|
-
eventId: eventId
|
|
294
|
-
});
|
|
295
|
-
onEventRegistration$1 = ErrorHandling.mkLogAndRaise(logger$1, "Failed to route registered event", {
|
|
296
|
-
RE_EXN_ID: EventRoutingFailed
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
let eventConfig = onEventRegistration$1.eventConfig;
|
|
300
|
-
let match = eventConfig.kind;
|
|
301
|
-
let params;
|
|
302
|
-
let exit = 0;
|
|
303
|
-
if (typeof match !== "object" || receipt.receiptType !== 6) {
|
|
304
|
-
exit = 1;
|
|
305
|
-
} else {
|
|
306
|
-
try {
|
|
307
|
-
params = match.decode(receipt.data);
|
|
308
|
-
} catch (raw_exn) {
|
|
309
|
-
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
310
|
-
let params$1 = {
|
|
311
|
-
chainId: chain,
|
|
312
|
-
blockNumber: block.height,
|
|
313
|
-
logIndex: receiptIndex
|
|
314
|
-
};
|
|
315
|
-
let logger$2 = Logging.createChildFrom(logger, params$1);
|
|
316
|
-
params = ErrorHandling.mkLogAndRaise(logger$2, "Failed to decode Fuel LogData receipt, please double check your ABI.", exn);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
if (exit === 1) {
|
|
320
|
-
switch (receipt.receiptType) {
|
|
321
|
-
case 0 :
|
|
322
|
-
params = {
|
|
323
|
-
to: receipt.to,
|
|
324
|
-
assetId: receipt.assetId,
|
|
325
|
-
amount: receipt.amount
|
|
326
|
-
};
|
|
327
|
-
break;
|
|
328
|
-
case 6 :
|
|
329
|
-
params = Stdlib_JsError.throwWithMessage("Unexpected bug in the event routing logic");
|
|
330
|
-
break;
|
|
331
|
-
case 7 :
|
|
332
|
-
params = {
|
|
333
|
-
to: receipt.to,
|
|
334
|
-
assetId: receipt.assetId,
|
|
335
|
-
amount: receipt.amount
|
|
336
|
-
};
|
|
337
|
-
break;
|
|
338
|
-
case 8 :
|
|
339
|
-
params = {
|
|
340
|
-
to: receipt.toAddress,
|
|
341
|
-
assetId: receipt.assetId,
|
|
342
|
-
amount: receipt.amount
|
|
343
|
-
};
|
|
344
|
-
break;
|
|
345
|
-
case 11 :
|
|
346
|
-
case 12 :
|
|
347
|
-
params = {
|
|
348
|
-
subId: receipt.subId,
|
|
349
|
-
amount: receipt.val
|
|
350
|
-
};
|
|
351
|
-
break;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
return {
|
|
355
|
-
kind: 0,
|
|
356
|
-
onEventRegistration: onEventRegistration$1,
|
|
357
|
-
chain: chain,
|
|
358
|
-
blockNumber: block.height,
|
|
359
|
-
logIndex: receiptIndex,
|
|
360
|
-
transactionIndex: 0,
|
|
361
|
-
payload: {
|
|
362
|
-
contractName: eventConfig.contractName,
|
|
363
|
-
eventName: eventConfig.name,
|
|
364
|
-
params: params,
|
|
365
|
-
chainId: chain,
|
|
366
|
-
srcAddress: contractAddress,
|
|
367
|
-
logIndex: receiptIndex,
|
|
368
|
-
transaction: {
|
|
369
|
-
id: item.transactionId
|
|
370
|
-
},
|
|
371
|
-
block: block
|
|
372
|
-
}
|
|
373
|
-
};
|
|
374
|
-
});
|
|
375
|
-
let parsingTimeElapsed = Performance.secondsSince(parsingTimeRef);
|
|
376
|
-
let blockHashes = pageUnsafe.items.map(param => {
|
|
377
|
-
let block = param.block;
|
|
378
|
-
return {
|
|
379
|
-
blockHash: block.id,
|
|
380
|
-
blockNumber: block.height
|
|
381
|
-
};
|
|
382
|
-
});
|
|
383
|
-
let match = pageUnsafe.items[pageUnsafe.items.length - 1 | 0];
|
|
384
|
-
let latestFetchedBlockTimestamp;
|
|
385
|
-
if (match !== undefined) {
|
|
386
|
-
let block = match.block;
|
|
387
|
-
latestFetchedBlockTimestamp = block.height === heighestBlockQueried ? block.time : 0;
|
|
388
|
-
} else {
|
|
389
|
-
latestFetchedBlockTimestamp = 0;
|
|
390
|
-
}
|
|
391
|
-
let totalTimeElapsed = Performance.secondsSince(totalTimeRef);
|
|
392
|
-
let stats_parsing$unknowntime$unknown$lpars$rpar = parsingTimeElapsed;
|
|
393
|
-
let stats_page$unknownfetch$unknowntime$unknown$lpars$rpar = pageFetchTime;
|
|
394
|
-
let stats = {
|
|
395
|
-
"total time elapsed (s)": totalTimeElapsed,
|
|
396
|
-
"parsing time (s)": stats_parsing$unknowntime$unknown$lpars$rpar,
|
|
397
|
-
"page fetch time (s)": stats_page$unknownfetch$unknowntime$unknown$lpars$rpar
|
|
398
|
-
};
|
|
399
|
-
return {
|
|
400
|
-
knownHeight: knownHeight$1,
|
|
401
|
-
blockHashes: blockHashes,
|
|
402
|
-
parsedQueueItems: parsedQueueItems,
|
|
403
|
-
transactionStore: undefined,
|
|
404
|
-
blockStore: undefined,
|
|
405
|
-
fromBlockQueried: fromBlock,
|
|
406
|
-
latestFetchedBlockNumber: heighestBlockQueried,
|
|
407
|
-
latestFetchedBlockTimestamp: latestFetchedBlockTimestamp,
|
|
408
|
-
stats: stats,
|
|
409
|
-
requestStats: requestStats
|
|
410
|
-
};
|
|
411
|
-
};
|
|
412
|
-
let getBlockHashes = (param, param$1) => Stdlib_JsError.throwWithMessage("HyperFuel does not support getting block hashes");
|
|
413
|
-
return {
|
|
414
|
-
name: "HyperFuel",
|
|
415
|
-
sourceFor: "Sync",
|
|
416
|
-
chain: chain,
|
|
417
|
-
poweredByHyperSync: true,
|
|
418
|
-
pollingInterval: 100,
|
|
419
|
-
getBlockHashes: getBlockHashes,
|
|
420
|
-
getHeightOrThrow: async () => {
|
|
421
|
-
let timerRef = Performance.now();
|
|
422
|
-
let height;
|
|
423
|
-
try {
|
|
424
|
-
height = await client.getHeight();
|
|
425
|
-
} catch (raw_e) {
|
|
426
|
-
let e = Primitive_exceptions.internalToException(raw_e);
|
|
427
|
-
if (e.RE_EXN_ID === "JsExn") {
|
|
428
|
-
let e$1 = e._1;
|
|
429
|
-
let message = Stdlib_JsExn.message(e$1);
|
|
430
|
-
if (message !== undefined) {
|
|
431
|
-
if (message.includes("401 Unauthorized")) {
|
|
432
|
-
Logging.error(`Your ENVIO_API_TOKEN was rejected by HyperFuel (401 Unauthorized). The indexer will not be able to fetch events. Update the token and try again using 'envio start' or 'envio dev'. For more info: https://docs.envio.dev/docs/HyperSync/api-tokens`);
|
|
433
|
-
await new Promise((param, param$1) => {});
|
|
434
|
-
height = 0;
|
|
435
|
-
} else {
|
|
436
|
-
throw {
|
|
437
|
-
RE_EXN_ID: "JsExn",
|
|
438
|
-
_1: e$1,
|
|
439
|
-
Error: new Error()
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
} else {
|
|
443
|
-
throw {
|
|
444
|
-
RE_EXN_ID: "JsExn",
|
|
445
|
-
_1: e$1,
|
|
446
|
-
Error: new Error()
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
} else {
|
|
450
|
-
throw e;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
let seconds = Performance.secondsSince(timerRef);
|
|
454
|
-
return {
|
|
455
|
-
height: height,
|
|
456
|
-
requestStats: [{
|
|
457
|
-
method: "getHeight",
|
|
458
|
-
seconds: seconds
|
|
459
|
-
}]
|
|
460
|
-
};
|
|
461
|
-
},
|
|
462
|
-
getItemsOrThrow: getItemsOrThrow
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
export {
|
|
467
|
-
EventRoutingFailed,
|
|
468
|
-
isUnauthorizedError,
|
|
469
|
-
mintEventTag,
|
|
470
|
-
burnEventTag,
|
|
471
|
-
transferEventTag,
|
|
472
|
-
callEventTag,
|
|
473
|
-
logDataReceiptTypeSelection,
|
|
474
|
-
txStatusSelection,
|
|
475
|
-
makeGetNormalRecieptsSelection,
|
|
476
|
-
makeWildcardRecieptsSelection,
|
|
477
|
-
getSelectionConfig,
|
|
478
|
-
memoGetSelectionConfig,
|
|
479
|
-
make,
|
|
480
|
-
}
|
|
481
|
-
/* Logging Not a pure module */
|
|
File without changes
|
|
File without changes
|