envio 3.3.0-alpha.7 → 3.3.0-alpha.8
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 +23 -5
- package/package.json +6 -6
- package/src/Api.res +1 -1
- package/src/Api.res.mjs +1 -1
- package/src/ChainFetching.res +21 -10
- package/src/ChainFetching.res.mjs +11 -10
- package/src/ChainState.res +328 -165
- package/src/ChainState.res.mjs +205 -100
- package/src/ChainState.resi +16 -7
- package/src/Config.res +11 -27
- package/src/Config.res.mjs +8 -7
- package/src/Core.res +7 -0
- package/src/CrossChainState.res +53 -80
- package/src/CrossChainState.res.mjs +43 -59
- package/src/CrossChainState.resi +1 -1
- package/src/Ecosystem.res +3 -3
- package/src/Ecosystem.res.mjs +3 -3
- package/src/Envio.res +14 -9
- package/src/EventConfigBuilder.res +105 -56
- package/src/EventConfigBuilder.res.mjs +69 -33
- package/src/EventProcessing.res +19 -15
- package/src/EventProcessing.res.mjs +13 -12
- package/src/FetchState.res +375 -171
- package/src/FetchState.res.mjs +249 -251
- package/src/HandlerLoader.res +7 -112
- package/src/HandlerLoader.res.mjs +1 -87
- package/src/HandlerRegister.res +209 -6
- package/src/HandlerRegister.res.mjs +90 -5
- package/src/HandlerRegister.resi +13 -2
- package/src/IndexerState.res +6 -3
- package/src/IndexerState.res.mjs +3 -3
- package/src/IndexerState.resi +1 -1
- package/src/IndexingAddresses.res +10 -7
- package/src/IndexingAddresses.res.mjs +8 -7
- package/src/IndexingAddresses.resi +3 -1
- package/src/Internal.res +82 -36
- package/src/Internal.res.mjs +11 -1
- package/src/Main.res +22 -23
- package/src/Main.res.mjs +15 -17
- package/src/Metrics.res +43 -2
- package/src/Metrics.res.mjs +39 -3
- package/src/Prometheus.res +0 -35
- package/src/Prometheus.res.mjs +33 -68
- package/src/RawEvent.res +7 -2
- package/src/RawEvent.res.mjs +4 -4
- package/src/SimulateItems.res +20 -7
- package/src/SimulateItems.res.mjs +7 -11
- package/src/TestIndexer.res +1 -1
- package/src/TestIndexer.res.mjs +1 -1
- package/src/sources/BlockStore.res +46 -0
- package/src/sources/BlockStore.res.mjs +24 -0
- package/src/sources/EventRouter.res +19 -12
- package/src/sources/EventRouter.res.mjs +7 -5
- package/src/sources/Evm.res +54 -4
- package/src/sources/Evm.res.mjs +43 -4
- package/src/sources/EvmChain.res +14 -18
- package/src/sources/EvmChain.res.mjs +12 -13
- package/src/sources/FieldMask.res +39 -0
- package/src/sources/FieldMask.res.mjs +42 -0
- package/src/sources/Fuel.res +5 -2
- package/src/sources/Fuel.res.mjs +4 -3
- package/src/sources/HyperFuelSource.res +31 -40
- package/src/sources/HyperFuelSource.res.mjs +52 -44
- package/src/sources/HyperSync.res +31 -9
- package/src/sources/HyperSync.res.mjs +47 -31
- package/src/sources/HyperSync.resi +10 -3
- package/src/sources/HyperSyncClient.res +15 -4
- package/src/sources/HyperSyncHeightStream.res +1 -8
- package/src/sources/HyperSyncHeightStream.res.mjs +0 -2
- package/src/sources/HyperSyncSource.res +37 -58
- package/src/sources/HyperSyncSource.res.mjs +42 -42
- package/src/sources/RpcSource.res +91 -82
- package/src/sources/RpcSource.res.mjs +76 -45
- package/src/sources/RpcWebSocketHeightStream.res +0 -5
- package/src/sources/RpcWebSocketHeightStream.res.mjs +0 -2
- package/src/sources/SimulateSource.res +5 -3
- package/src/sources/SimulateSource.res.mjs +12 -4
- package/src/sources/Source.res +19 -5
- package/src/sources/SourceManager.res +62 -6
- package/src/sources/SourceManager.res.mjs +55 -8
- package/src/sources/SourceManager.resi +10 -0
- package/src/sources/Svm.res +14 -10
- package/src/sources/Svm.res.mjs +23 -6
- package/src/sources/SvmHyperSyncClient.res +5 -6
- package/src/sources/SvmHyperSyncSource.res +82 -41
- package/src/sources/SvmHyperSyncSource.res.mjs +86 -41
- package/src/sources/TransactionStore.res +6 -107
- package/src/sources/TransactionStore.res.mjs +5 -86
- package/svm.schema.json +19 -0
|
@@ -17,16 +17,14 @@ let getSelectionConfig = (selection: FetchState.selection, ~chain) => {
|
|
|
17
17
|
let noAddressesTopicSelections = []
|
|
18
18
|
let contractNames = Utils.Set.make()
|
|
19
19
|
|
|
20
|
-
selection.
|
|
21
|
-
->(Utils.magic: array<Internal.
|
|
22
|
-
->Array.forEach(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
selectedBlockFields,
|
|
27
|
-
|
|
28
|
-
isWildcard,
|
|
29
|
-
}) => {
|
|
20
|
+
selection.onEventRegistrations
|
|
21
|
+
->(Utils.magic: array<Internal.onEventRegistration> => array<Internal.evmOnEventRegistration>)
|
|
22
|
+
->Array.forEach(reg => {
|
|
23
|
+
let eventConfig =
|
|
24
|
+
reg.eventConfig->(Utils.magic: Internal.eventConfig => Internal.evmEventConfig)
|
|
25
|
+
let contractName = eventConfig.contractName
|
|
26
|
+
let {selectedBlockFields, selectedTransactionFields} = eventConfig
|
|
27
|
+
let {dependsOnAddresses, getEventFiltersOrThrow, isWildcard} = reg
|
|
30
28
|
selectedBlockFields
|
|
31
29
|
->Utils.Set.toArray
|
|
32
30
|
->Array.forEach(name =>
|
|
@@ -141,7 +139,7 @@ type options = {
|
|
|
141
139
|
chain: ChainMap.Chain.t,
|
|
142
140
|
endpointUrl: string,
|
|
143
141
|
allEventParams: array<HyperSyncClient.Decoder.eventParamsInput>,
|
|
144
|
-
eventRouter: EventRouter.t<Internal.
|
|
142
|
+
eventRouter: EventRouter.t<Internal.evmOnEventRegistration>,
|
|
145
143
|
apiToken: option<string>,
|
|
146
144
|
clientTimeoutMillis: int,
|
|
147
145
|
lowercaseAddresses: bool,
|
|
@@ -197,27 +195,25 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
197
195
|
|
|
198
196
|
let makeEventBatchQueueItem = (
|
|
199
197
|
item: HyperSyncClient.EventItems.item,
|
|
200
|
-
~block: HyperSyncClient.ResponseTypes.block,
|
|
201
198
|
~params: Internal.eventParams,
|
|
202
|
-
~
|
|
199
|
+
~onEventRegistration: Internal.evmOnEventRegistration,
|
|
203
200
|
): Internal.item => {
|
|
204
201
|
let {transactionIndex, logIndex, srcAddress} = item
|
|
205
202
|
let chainId = chain->ChainMap.Chain.toChainId
|
|
206
203
|
|
|
207
204
|
Internal.Event({
|
|
208
|
-
|
|
209
|
-
timestamp: block.timestamp->Option.getUnsafe,
|
|
205
|
+
onEventRegistration: (onEventRegistration :> Internal.onEventRegistration),
|
|
210
206
|
chain,
|
|
211
207
|
blockNumber: item.blockNumber,
|
|
212
|
-
blockHash: block.hash->Option.getUnsafe,
|
|
213
208
|
logIndex,
|
|
214
209
|
transactionIndex,
|
|
210
|
+
// `block` and `transaction` are omitted; they're materialised from the
|
|
211
|
+
// per-chain stores onto the payload at batch prep.
|
|
215
212
|
payload: {
|
|
216
|
-
contractName: eventConfig.contractName,
|
|
217
|
-
eventName: eventConfig.name,
|
|
213
|
+
contractName: onEventRegistration.eventConfig.contractName,
|
|
214
|
+
eventName: onEventRegistration.eventConfig.name,
|
|
218
215
|
chainId,
|
|
219
216
|
params,
|
|
220
|
-
block: block->(Utils.magic: HyperSyncClient.ResponseTypes.block => Internal.eventBlock),
|
|
221
217
|
srcAddress,
|
|
222
218
|
logIndex,
|
|
223
219
|
}->Evm.fromPayload,
|
|
@@ -248,11 +244,6 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
248
244
|
let startFetchingBatchTimeRef = Performance.now()
|
|
249
245
|
|
|
250
246
|
//fetch batch
|
|
251
|
-
Prometheus.SourceRequestCount.increment(
|
|
252
|
-
~sourceName=name,
|
|
253
|
-
~chainId=chain->ChainMap.Chain.toChainId,
|
|
254
|
-
~method="getLogs",
|
|
255
|
-
)
|
|
256
247
|
let pageUnsafe = try await HyperSync.GetLogs.query(
|
|
257
248
|
~client,
|
|
258
249
|
~fromBlock,
|
|
@@ -307,6 +298,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
307
298
|
}
|
|
308
299
|
|
|
309
300
|
let pageFetchTime = startFetchingBatchTimeRef->Performance.secondsSince
|
|
301
|
+
let requestStats = [{Source.method: "getLogs", seconds: pageFetchTime}]
|
|
310
302
|
|
|
311
303
|
//set height and next from block
|
|
312
304
|
let knownHeight = pageUnsafe.archiveHeight
|
|
@@ -321,28 +313,25 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
321
313
|
//Parse page items into queue items
|
|
322
314
|
let parsedQueueItems = []
|
|
323
315
|
|
|
324
|
-
//
|
|
316
|
+
// Block headers are returned once per number; items reference them by blockNumber.
|
|
325
317
|
let blocksByNumber = Utils.Map.make()
|
|
326
318
|
pageUnsafe.blocks->Array.forEach(block => {
|
|
327
|
-
|
|
328
|
-
| Some(number) => blocksByNumber->Utils.Map.set(number, block)->ignore
|
|
329
|
-
| None => ()
|
|
330
|
-
}
|
|
319
|
+
blocksByNumber->Utils.Map.set(block.number, block)->ignore
|
|
331
320
|
})
|
|
332
321
|
let getBlock = blockNumber => blocksByNumber->Utils.Map.unsafeGet(blockNumber)
|
|
333
322
|
|
|
334
323
|
let handleDecodeFailure = (
|
|
335
|
-
~
|
|
324
|
+
~onEventRegistration: Internal.evmOnEventRegistration,
|
|
336
325
|
~logIndex,
|
|
337
326
|
~blockNumber,
|
|
338
327
|
~chainId,
|
|
339
328
|
~exn,
|
|
340
329
|
) => {
|
|
341
|
-
if !
|
|
330
|
+
if !onEventRegistration.isWildcard {
|
|
342
331
|
//Wildcard events can be parsed as undefined if the number of topics
|
|
343
332
|
//don't match the event with the given topic0
|
|
344
333
|
//Non wildcard events should be expected to be parsed
|
|
345
|
-
let msg = `Event ${eventConfig.name} was unexpectedly parsed as undefined`
|
|
334
|
+
let msg = `Event ${onEventRegistration.eventConfig.name} was unexpectedly parsed as undefined`
|
|
346
335
|
let logger = Logging.createChildFrom(
|
|
347
336
|
~logger,
|
|
348
337
|
~params={
|
|
@@ -370,19 +359,17 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
370
359
|
|
|
371
360
|
switch maybeEventConfig {
|
|
372
361
|
| None => () //ignore events that aren't registered
|
|
373
|
-
| Some(
|
|
362
|
+
| Some(onEventRegistration) =>
|
|
374
363
|
switch item.params
|
|
375
364
|
->Nullable.toOption
|
|
376
|
-
->Option.flatMap(Dict.get(_, eventConfig.contractName)) {
|
|
365
|
+
->Option.flatMap(Dict.get(_, onEventRegistration.eventConfig.contractName)) {
|
|
377
366
|
| Some(params) =>
|
|
378
367
|
parsedQueueItems
|
|
379
|
-
->Array.push(
|
|
380
|
-
makeEventBatchQueueItem(item, ~block=getBlock(item.blockNumber), ~params, ~eventConfig),
|
|
381
|
-
)
|
|
368
|
+
->Array.push(makeEventBatchQueueItem(item, ~params, ~onEventRegistration))
|
|
382
369
|
->ignore
|
|
383
370
|
| None =>
|
|
384
371
|
handleDecodeFailure(
|
|
385
|
-
~
|
|
372
|
+
~onEventRegistration,
|
|
386
373
|
~logIndex=item.logIndex,
|
|
387
374
|
~blockNumber=item.blockNumber,
|
|
388
375
|
~chainId,
|
|
@@ -400,11 +387,9 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
400
387
|
// detection notices same-block-number-different-hash collisions itself.
|
|
401
388
|
let blockHashes = []
|
|
402
389
|
pageUnsafe.blocks->Array.forEach(block => {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
| _ => ()
|
|
407
|
-
}
|
|
390
|
+
blockHashes
|
|
391
|
+
->Array.push({ReorgDetection.blockNumber: block.number, blockHash: block.hash})
|
|
392
|
+
->ignore
|
|
408
393
|
})
|
|
409
394
|
switch pageUnsafe.rollbackGuard {
|
|
410
395
|
| None => ()
|
|
@@ -428,7 +413,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
428
413
|
| None =>
|
|
429
414
|
switch pageUnsafe.items->Array.get(pageUnsafe.items->Array.length - 1) {
|
|
430
415
|
| Some(item) if item.blockNumber == heighestBlockQueried =>
|
|
431
|
-
getBlock(item.blockNumber).timestamp
|
|
416
|
+
getBlock(item.blockNumber).timestamp
|
|
432
417
|
| _ => 0
|
|
433
418
|
}
|
|
434
419
|
}
|
|
@@ -445,11 +430,13 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
445
430
|
latestFetchedBlockTimestamp,
|
|
446
431
|
parsedQueueItems,
|
|
447
432
|
transactionStore: Some(pageUnsafe.transactionStore),
|
|
433
|
+
blockStore: Some(pageUnsafe.blockStore),
|
|
448
434
|
latestFetchedBlockNumber: heighestBlockQueried,
|
|
449
435
|
stats,
|
|
450
436
|
knownHeight,
|
|
451
437
|
blockHashes,
|
|
452
438
|
fromBlockQueried: fromBlock,
|
|
439
|
+
requestStats,
|
|
453
440
|
}
|
|
454
441
|
}
|
|
455
442
|
|
|
@@ -460,7 +447,10 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
460
447
|
~sourceName=name,
|
|
461
448
|
~chainId=chain->ChainMap.Chain.toChainId,
|
|
462
449
|
~logger,
|
|
463
|
-
)->Promise.thenResolve(
|
|
450
|
+
)->Promise.thenResolve(((queryRes, requestStats)) => {
|
|
451
|
+
Source.result: queryRes->HyperSync.mapExn,
|
|
452
|
+
requestStats,
|
|
453
|
+
})
|
|
464
454
|
|
|
465
455
|
{
|
|
466
456
|
name,
|
|
@@ -471,7 +461,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
471
461
|
getBlockHashes,
|
|
472
462
|
getHeightOrThrow: async () => {
|
|
473
463
|
let timerRef = Performance.now()
|
|
474
|
-
let
|
|
464
|
+
let height = try {
|
|
475
465
|
await client.getHeight()
|
|
476
466
|
} catch {
|
|
477
467
|
| JsExn(e) =>
|
|
@@ -485,18 +475,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
485
475
|
}
|
|
486
476
|
}
|
|
487
477
|
let seconds = timerRef->Performance.secondsSince
|
|
488
|
-
|
|
489
|
-
~sourceName=name,
|
|
490
|
-
~chainId=chain->ChainMap.Chain.toChainId,
|
|
491
|
-
~method="getHeight",
|
|
492
|
-
)
|
|
493
|
-
Prometheus.SourceRequestCount.addSeconds(
|
|
494
|
-
~sourceName=name,
|
|
495
|
-
~chainId=chain->ChainMap.Chain.toChainId,
|
|
496
|
-
~method="getHeight",
|
|
497
|
-
~seconds,
|
|
498
|
-
)
|
|
499
|
-
result
|
|
478
|
+
{height, requestStats: [{method: "getHeight", seconds}]}
|
|
500
479
|
},
|
|
501
480
|
getItemsOrThrow,
|
|
502
481
|
createHeightSubscription: (~onHeight) =>
|
|
@@ -4,7 +4,6 @@ import * as Utils from "../Utils.res.mjs";
|
|
|
4
4
|
import * as Source from "./Source.res.mjs";
|
|
5
5
|
import * as Logging from "../Logging.res.mjs";
|
|
6
6
|
import * as HyperSync from "./HyperSync.res.mjs";
|
|
7
|
-
import * as Prometheus from "../Prometheus.res.mjs";
|
|
8
7
|
import * as EventRouter from "./EventRouter.res.mjs";
|
|
9
8
|
import * as Performance from "../bindings/Performance.res.mjs";
|
|
10
9
|
import * as LogSelection from "../LogSelection.res.mjs";
|
|
@@ -25,24 +24,25 @@ function getSelectionConfig(selection, chain) {
|
|
|
25
24
|
let dynamicWildcardEventFiltersByContract = {};
|
|
26
25
|
let noAddressesTopicSelections = [];
|
|
27
26
|
let contractNames = new Set();
|
|
28
|
-
selection.
|
|
29
|
-
let
|
|
30
|
-
|
|
27
|
+
selection.onEventRegistrations.forEach(reg => {
|
|
28
|
+
let eventConfig = reg.eventConfig;
|
|
29
|
+
let contractName = eventConfig.contractName;
|
|
30
|
+
Array.from(eventConfig.selectedBlockFields).forEach(name => {
|
|
31
31
|
capitalizedBlockFields.add(Utils.$$String.capitalize(name));
|
|
32
32
|
});
|
|
33
|
-
Array.from(
|
|
33
|
+
Array.from(eventConfig.selectedTransactionFields).forEach(name => {
|
|
34
34
|
if (name !== "transactionIndex") {
|
|
35
35
|
capitalizedTransactionFields.add(Utils.$$String.capitalize(name));
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
|
-
let eventFilters =
|
|
40
|
-
if (
|
|
39
|
+
let eventFilters = reg.getEventFiltersOrThrow(chain);
|
|
40
|
+
if (reg.dependsOnAddresses) {
|
|
41
41
|
contractNames.add(contractName);
|
|
42
42
|
if (eventFilters.TAG === "Static") {
|
|
43
43
|
return Utils.Dict.pushMany(staticTopicSelectionsByContract, contractName, eventFilters._0);
|
|
44
44
|
} else {
|
|
45
|
-
return Utils.Dict.push(
|
|
45
|
+
return Utils.Dict.push(reg.isWildcard ? dynamicWildcardEventFiltersByContract : dynamicEventFiltersByContract, contractName, eventFilters._0);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
let tmp;
|
|
@@ -127,25 +127,22 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
127
127
|
client = ErrorHandling.mkLogAndRaise(undefined, "Failed to instantiate the hypersync client, please double check your ABI", exn);
|
|
128
128
|
}
|
|
129
129
|
let UndefinedValue = /* @__PURE__ */Primitive_exceptions.create("UndefinedValue");
|
|
130
|
-
let makeEventBatchQueueItem = (item,
|
|
130
|
+
let makeEventBatchQueueItem = (item, params, onEventRegistration) => {
|
|
131
131
|
let logIndex = item.logIndex;
|
|
132
132
|
return {
|
|
133
133
|
kind: 0,
|
|
134
|
-
|
|
135
|
-
timestamp: block.timestamp,
|
|
134
|
+
onEventRegistration: onEventRegistration,
|
|
136
135
|
chain: chain,
|
|
137
136
|
blockNumber: item.blockNumber,
|
|
138
|
-
blockHash: block.hash,
|
|
139
137
|
logIndex: logIndex,
|
|
140
138
|
transactionIndex: item.transactionIndex,
|
|
141
139
|
payload: {
|
|
142
|
-
contractName: eventConfig.contractName,
|
|
143
|
-
eventName: eventConfig.name,
|
|
140
|
+
contractName: onEventRegistration.eventConfig.contractName,
|
|
141
|
+
eventName: onEventRegistration.eventConfig.name,
|
|
144
142
|
params: params,
|
|
145
143
|
chainId: chain,
|
|
146
144
|
srcAddress: item.srcAddress,
|
|
147
|
-
logIndex: logIndex
|
|
148
|
-
block: block
|
|
145
|
+
logIndex: logIndex
|
|
149
146
|
}
|
|
150
147
|
};
|
|
151
148
|
};
|
|
@@ -160,7 +157,6 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
160
157
|
logSelections = ErrorHandling.mkLogAndRaise(logger, "Failed getting log selection for the query", exn);
|
|
161
158
|
}
|
|
162
159
|
let startFetchingBatchTimeRef = Performance.now();
|
|
163
|
-
Prometheus.SourceRequestCount.increment(name, chain, "getLogs");
|
|
164
160
|
let pageUnsafe;
|
|
165
161
|
try {
|
|
166
162
|
pageUnsafe = await HyperSync.GetLogs.query(client, fromBlock, toBlock, logSelections, selectionConfig.fieldSelection, itemsTarget);
|
|
@@ -212,26 +208,26 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
212
208
|
};
|
|
213
209
|
}
|
|
214
210
|
let pageFetchTime = Performance.secondsSince(startFetchingBatchTimeRef);
|
|
211
|
+
let requestStats = [{
|
|
212
|
+
method: "getLogs",
|
|
213
|
+
seconds: pageFetchTime
|
|
214
|
+
}];
|
|
215
215
|
let knownHeight$1 = pageUnsafe.archiveHeight;
|
|
216
216
|
let heighestBlockQueried = pageUnsafe.nextBlock - 1 | 0;
|
|
217
217
|
let parsingTimeRef = Performance.now();
|
|
218
218
|
let parsedQueueItems = [];
|
|
219
219
|
let blocksByNumber = new Map();
|
|
220
220
|
pageUnsafe.blocks.forEach(block => {
|
|
221
|
-
|
|
222
|
-
if (number !== undefined) {
|
|
223
|
-
blocksByNumber.set(number, block);
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
221
|
+
blocksByNumber.set(block.number, block);
|
|
226
222
|
});
|
|
227
223
|
pageUnsafe.items.forEach(item => {
|
|
228
224
|
let maybeEventConfig = EventRouter.get(eventRouter, EventRouter.getEvmEventId(item.topic0, item.topicCount), item.srcAddress, contractNameByAddress);
|
|
229
225
|
if (maybeEventConfig === undefined) {
|
|
230
226
|
return;
|
|
231
227
|
}
|
|
232
|
-
let params = Stdlib_Option.flatMap(Primitive_option.fromNullable(item.params), __x => __x[maybeEventConfig.contractName]);
|
|
228
|
+
let params = Stdlib_Option.flatMap(Primitive_option.fromNullable(item.params), __x => __x[maybeEventConfig.eventConfig.contractName]);
|
|
233
229
|
if (params !== undefined) {
|
|
234
|
-
parsedQueueItems.push(makeEventBatchQueueItem(item,
|
|
230
|
+
parsedQueueItems.push(makeEventBatchQueueItem(item, Primitive_option.valFromOption(params), maybeEventConfig));
|
|
235
231
|
return;
|
|
236
232
|
} else {
|
|
237
233
|
let logIndex = item.logIndex;
|
|
@@ -242,7 +238,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
242
238
|
if (maybeEventConfig.isWildcard) {
|
|
243
239
|
return;
|
|
244
240
|
}
|
|
245
|
-
let msg = `Event ` + maybeEventConfig.name + ` was unexpectedly parsed as undefined`;
|
|
241
|
+
let msg = `Event ` + maybeEventConfig.eventConfig.name + ` was unexpectedly parsed as undefined`;
|
|
246
242
|
let logger$1 = Logging.createChildFrom(logger, {
|
|
247
243
|
chainId: chain,
|
|
248
244
|
blockNumber: blockNumber,
|
|
@@ -255,15 +251,10 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
255
251
|
let parsingTimeElapsed = Performance.secondsSince(parsingTimeRef);
|
|
256
252
|
let blockHashes = [];
|
|
257
253
|
pageUnsafe.blocks.forEach(block => {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
blockHash: match$1,
|
|
263
|
-
blockNumber: match
|
|
264
|
-
});
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
254
|
+
blockHashes.push({
|
|
255
|
+
blockHash: block.hash,
|
|
256
|
+
blockNumber: block.number
|
|
257
|
+
});
|
|
267
258
|
});
|
|
268
259
|
let match = pageUnsafe.rollbackGuard;
|
|
269
260
|
if (match !== undefined) {
|
|
@@ -297,13 +288,18 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
297
288
|
blockHashes: blockHashes,
|
|
298
289
|
parsedQueueItems: parsedQueueItems,
|
|
299
290
|
transactionStore: Primitive_option.some(pageUnsafe.transactionStore),
|
|
291
|
+
blockStore: Primitive_option.some(pageUnsafe.blockStore),
|
|
300
292
|
fromBlockQueried: fromBlock,
|
|
301
293
|
latestFetchedBlockNumber: heighestBlockQueried,
|
|
302
294
|
latestFetchedBlockTimestamp: latestFetchedBlockTimestamp,
|
|
303
|
-
stats: stats
|
|
295
|
+
stats: stats,
|
|
296
|
+
requestStats: requestStats
|
|
304
297
|
};
|
|
305
298
|
};
|
|
306
|
-
let getBlockHashes = (blockNumbers, logger) => HyperSync.queryBlockDataMulti(client, blockNumbers, name, chain, logger).then(
|
|
299
|
+
let getBlockHashes = (blockNumbers, logger) => HyperSync.queryBlockDataMulti(client, blockNumbers, name, chain, logger).then(param => ({
|
|
300
|
+
result: HyperSync.mapExn(param[0]),
|
|
301
|
+
requestStats: param[1]
|
|
302
|
+
}));
|
|
307
303
|
return {
|
|
308
304
|
name: name,
|
|
309
305
|
sourceFor: "Sync",
|
|
@@ -313,9 +309,9 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
313
309
|
getBlockHashes: getBlockHashes,
|
|
314
310
|
getHeightOrThrow: async () => {
|
|
315
311
|
let timerRef = Performance.now();
|
|
316
|
-
let
|
|
312
|
+
let height;
|
|
317
313
|
try {
|
|
318
|
-
|
|
314
|
+
height = await client.getHeight();
|
|
319
315
|
} catch (raw_e) {
|
|
320
316
|
let e = Primitive_exceptions.internalToException(raw_e);
|
|
321
317
|
if (e.RE_EXN_ID === "JsExn") {
|
|
@@ -325,7 +321,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
325
321
|
if (message.includes("401 Unauthorized")) {
|
|
326
322
|
Logging.error(`Your ENVIO_API_TOKEN was rejected by HyperSync (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`);
|
|
327
323
|
await new Promise((param, param$1) => {});
|
|
328
|
-
|
|
324
|
+
height = 0;
|
|
329
325
|
} else {
|
|
330
326
|
throw {
|
|
331
327
|
RE_EXN_ID: "JsExn",
|
|
@@ -345,9 +341,13 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
345
341
|
}
|
|
346
342
|
}
|
|
347
343
|
let seconds = Performance.secondsSince(timerRef);
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
344
|
+
return {
|
|
345
|
+
height: height,
|
|
346
|
+
requestStats: [{
|
|
347
|
+
method: "getHeight",
|
|
348
|
+
seconds: seconds
|
|
349
|
+
}]
|
|
350
|
+
};
|
|
351
351
|
},
|
|
352
352
|
getItemsOrThrow: getItemsOrThrow,
|
|
353
353
|
createHeightSubscription: onHeight => HyperSyncHeightStream.subscribe(endpointUrl, apiToken$1, chain, onHeight)
|