envio 3.6.1 → 3.7.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/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 +9 -2
- package/src/Config.res.mjs +4 -4
- package/src/Core.res +5 -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 +4 -8
- package/src/EventProcessing.res.mjs +4 -4
- package/src/EventUtils.res +3 -47
- package/src/FetchState.res +124 -104
- package/src/FetchState.res.mjs +116 -100
- package/src/HandlerRegister.res +108 -2
- package/src/HandlerRegister.res.mjs +59 -10
- package/src/HandlerRegister.resi +4 -0
- 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 +724 -0
- package/src/MemoryStorage.res.mjs +601 -0
- package/src/PgStorage.res +18 -7
- package/src/PgStorage.res.mjs +14 -11
- 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/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/svm.schema.json +3 -2
package/src/sources/Fuel.res
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Fuel's concrete item payload. Erased to `Internal.eventPayload` on the item
|
|
2
|
-
// and recovered here via `toPayload`.
|
|
2
|
+
// and recovered here via `toPayload`. The block lives raw in the per-chain
|
|
3
|
+
// store and is written onto the payload at batch prep (like HyperSync EVM);
|
|
4
|
+
// simulate builds it inline.
|
|
3
5
|
type payload = {
|
|
4
6
|
contractName: string,
|
|
5
7
|
eventName: string,
|
|
@@ -8,11 +10,24 @@ type payload = {
|
|
|
8
10
|
srcAddress: Address.t,
|
|
9
11
|
logIndex: int,
|
|
10
12
|
transaction: Internal.eventTransaction,
|
|
11
|
-
block
|
|
13
|
+
block?: Internal.eventBlock,
|
|
12
14
|
}
|
|
13
15
|
external fromPayload: payload => Internal.eventPayload = "%identity"
|
|
14
16
|
external toPayload: Internal.eventPayload => payload = "%identity"
|
|
15
17
|
|
|
18
|
+
// Ordered block field names. The index of each is the field code shared with
|
|
19
|
+
// the Rust store (`FuelBlockField`) — keep this order in sync.
|
|
20
|
+
let blockFields = ["height", "id", "time"]
|
|
21
|
+
|
|
22
|
+
// Fuel has no per-event block field selection: every event materialises the
|
|
23
|
+
// full (height, time, id) trio, matching what the source always queries.
|
|
24
|
+
let eventBlockFieldMask = BlockStore.makeMaskFn(blockFields)
|
|
25
|
+
|
|
26
|
+
// Fuel keeps the transaction inline on the event payload rather than in the
|
|
27
|
+
// per-chain store, so there is nothing to select and no field code to hold.
|
|
28
|
+
let transactionFields = []
|
|
29
|
+
let eventTransactionFieldMask = TransactionStore.makeMaskFn(transactionFields)
|
|
30
|
+
|
|
16
31
|
let cleanUpRawEventFieldsInPlace: JSON.t => unit = %raw(`fields => {
|
|
17
32
|
delete fields.id
|
|
18
33
|
delete fields.height
|
|
@@ -24,7 +39,6 @@ let make = (~logger: Pino.t): Ecosystem.t => {
|
|
|
24
39
|
blockNumberName: "height",
|
|
25
40
|
blockTimestampName: "time",
|
|
26
41
|
blockHashName: "id",
|
|
27
|
-
cleanUpRawEventFieldsInPlace,
|
|
28
42
|
onBlockMethodName: "onBlock",
|
|
29
43
|
// Fuel filter shape: `{block: {height: {_gte?, _lte?, _every?}}}`.
|
|
30
44
|
// Inner range chunk parsed by `blockRangeSchema` in `Main.res`.
|
|
@@ -56,7 +70,13 @@ let make = (~logger: Pino.t): Ecosystem.t => {
|
|
|
56
70
|
),
|
|
57
71
|
toRawEvent: eventItem => {
|
|
58
72
|
let payload = eventItem.payload->toPayload
|
|
59
|
-
|
|
73
|
+
// Store-backed payloads get `block` written at batch prep and simulate
|
|
74
|
+
// carries it from the start, so it's present by the time a raw event is built.
|
|
75
|
+
let header = switch payload.block {
|
|
76
|
+
| Some(block) => block->(Utils.magic: Internal.eventBlock => {"id": string, "time": int})
|
|
77
|
+
| None =>
|
|
78
|
+
JsError.throwWithMessage("Unexpected case: The event block is missing for a raw event")
|
|
79
|
+
}
|
|
60
80
|
eventItem->RawEvent.make(
|
|
61
81
|
~block=payload.block,
|
|
62
82
|
~transaction=payload.transaction,
|
package/src/sources/Fuel.res.mjs
CHANGED
|
@@ -2,7 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
import * as Logging from "../Logging.res.mjs";
|
|
4
4
|
import * as RawEvent from "../RawEvent.res.mjs";
|
|
5
|
+
import * as BlockStore from "./BlockStore.res.mjs";
|
|
6
|
+
import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
|
|
7
|
+
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
5
8
|
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
9
|
+
import * as TransactionStore from "./TransactionStore.res.mjs";
|
|
10
|
+
|
|
11
|
+
let blockFields = [
|
|
12
|
+
"height",
|
|
13
|
+
"id",
|
|
14
|
+
"time"
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
let eventBlockFieldMask = BlockStore.makeMaskFn(blockFields);
|
|
18
|
+
|
|
19
|
+
let transactionFields = [];
|
|
20
|
+
|
|
21
|
+
let eventTransactionFieldMask = TransactionStore.makeMaskFn(transactionFields);
|
|
6
22
|
|
|
7
23
|
let cleanUpRawEventFieldsInPlace = (fields => {
|
|
8
24
|
delete fields.id
|
|
@@ -16,7 +32,6 @@ function make(logger) {
|
|
|
16
32
|
blockNumberName: "height",
|
|
17
33
|
blockTimestampName: "time",
|
|
18
34
|
blockHashName: "id",
|
|
19
|
-
cleanUpRawEventFieldsInPlace: cleanUpRawEventFieldsInPlace,
|
|
20
35
|
onBlockMethodName: "onBlock",
|
|
21
36
|
onBlockFilterSchema: S$RescriptSchema.object(s => s.f("block", S$RescriptSchema.option(S$RescriptSchema.object(s2 => s2.f("height", S$RescriptSchema.unknown))))),
|
|
22
37
|
onEventBlockFilterSchema: S$RescriptSchema.object(s => s.f("block", S$RescriptSchema.option(S$RescriptSchema.strict(S$RescriptSchema.object(s2 => s2.f("height", S$RescriptSchema.unknown)))))),
|
|
@@ -32,14 +47,19 @@ function make(logger) {
|
|
|
32
47
|
}),
|
|
33
48
|
toRawEvent: eventItem => {
|
|
34
49
|
let payload = eventItem.payload;
|
|
35
|
-
let
|
|
50
|
+
let block = payload.block;
|
|
51
|
+
let header = block !== undefined ? Primitive_option.valFromOption(block) : Stdlib_JsError.throwWithMessage("Unexpected case: The event block is missing for a raw event");
|
|
36
52
|
return RawEvent.make(eventItem, payload.block, payload.transaction, payload.params, payload.srcAddress, header.id, header.time, cleanUpRawEventFieldsInPlace);
|
|
37
53
|
}
|
|
38
54
|
};
|
|
39
55
|
}
|
|
40
56
|
|
|
41
57
|
export {
|
|
58
|
+
blockFields,
|
|
59
|
+
eventBlockFieldMask,
|
|
60
|
+
transactionFields,
|
|
61
|
+
eventTransactionFieldMask,
|
|
42
62
|
cleanUpRawEventFieldsInPlace,
|
|
43
63
|
make,
|
|
44
64
|
}
|
|
45
|
-
/*
|
|
65
|
+
/* eventBlockFieldMask Not a pure module */
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
type logsQueryPage = {
|
|
2
2
|
items: array<FuelHyperSyncClient.EventItems.item>,
|
|
3
3
|
// Blocks referenced by `items`, one per height.
|
|
4
|
-
blocks: array<FuelHyperSyncClient.EventItems.block>,
|
|
5
4
|
nextBlock: int,
|
|
6
5
|
archiveHeight: int,
|
|
6
|
+
// Page store owning this page's raw blocks (built on the Rust side); its ids
|
|
7
|
+
// drive reorg detection when merged into the chain store.
|
|
8
|
+
blockStore: BlockStore.t,
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
module GetLogs = {
|
|
@@ -53,7 +55,10 @@ module GetLogs = {
|
|
|
53
55
|
clientFilteredContracts,
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
let res = switch await client->FuelHyperSyncClient.getEventItems(
|
|
58
|
+
let (res, blockStore) = switch await client->FuelHyperSyncClient.getEventItems(
|
|
59
|
+
query,
|
|
60
|
+
addressSet,
|
|
61
|
+
) {
|
|
57
62
|
| res => res
|
|
58
63
|
| exception exn =>
|
|
59
64
|
switch exn->extractMissingParams {
|
|
@@ -67,9 +72,9 @@ module GetLogs = {
|
|
|
67
72
|
}
|
|
68
73
|
{
|
|
69
74
|
items: res.items,
|
|
70
|
-
blocks: res.blocks,
|
|
71
75
|
nextBlock: res.nextBlock,
|
|
72
76
|
archiveHeight: res.archiveHeight->Option.getOr(0), // TODO: FIXME: Shouldn't have a default here
|
|
77
|
+
blockStore,
|
|
73
78
|
}
|
|
74
79
|
}
|
|
75
80
|
}
|
|
@@ -36,9 +36,9 @@ async function query(client, fromBlock, toBlock, registrationIndexes, addressSet
|
|
|
36
36
|
registrationIndexes: registrationIndexes,
|
|
37
37
|
clientFilteredContracts: clientFilteredContracts
|
|
38
38
|
};
|
|
39
|
-
let
|
|
39
|
+
let match;
|
|
40
40
|
try {
|
|
41
|
-
|
|
41
|
+
match = await client.getEventItems(query$1, addressSet);
|
|
42
42
|
} catch (raw_exn) {
|
|
43
43
|
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
44
44
|
let missingParams = extractMissingParams(exn);
|
|
@@ -54,6 +54,7 @@ async function query(client, fromBlock, toBlock, registrationIndexes, addressSet
|
|
|
54
54
|
}
|
|
55
55
|
throw exn;
|
|
56
56
|
}
|
|
57
|
+
let res = match[0];
|
|
57
58
|
if (res.nextBlock <= fromBlock) {
|
|
58
59
|
throw {
|
|
59
60
|
RE_EXN_ID: $$Error,
|
|
@@ -63,9 +64,9 @@ async function query(client, fromBlock, toBlock, registrationIndexes, addressSet
|
|
|
63
64
|
}
|
|
64
65
|
return {
|
|
65
66
|
items: res.items,
|
|
66
|
-
blocks: res.blocks,
|
|
67
67
|
nextBlock: res.nextBlock,
|
|
68
|
-
archiveHeight: Stdlib_Option.getOr(res.archiveHeight, 0)
|
|
68
|
+
archiveHeight: Stdlib_Option.getOr(res.archiveHeight, 0),
|
|
69
|
+
blockStore: match[1]
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
72
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
type logsQueryPage = {
|
|
2
2
|
items: array<FuelHyperSyncClient.EventItems.item>,
|
|
3
|
-
blocks: array<FuelHyperSyncClient.EventItems.block>,
|
|
4
3
|
nextBlock: int,
|
|
5
4
|
archiveHeight: int,
|
|
5
|
+
// Page store owning this page's raw blocks (built on the Rust side); its ids
|
|
6
|
+
// drive reorg detection when merged into the chain store.
|
|
7
|
+
blockStore: BlockStore.t,
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
module GetLogs: {
|
|
@@ -87,17 +87,9 @@ module EventItems = {
|
|
|
87
87
|
to?: string,
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
type block = {
|
|
91
|
-
id: string,
|
|
92
|
-
height: int,
|
|
93
|
-
time: int,
|
|
94
|
-
}
|
|
95
|
-
|
|
96
90
|
type response = {
|
|
97
91
|
archiveHeight: option<int>,
|
|
98
92
|
nextBlock: int,
|
|
99
|
-
// One block per height; items reference them by `blockHeight`.
|
|
100
|
-
blocks: array<block>,
|
|
101
93
|
items: array<item>,
|
|
102
94
|
}
|
|
103
95
|
}
|
|
@@ -121,9 +113,14 @@ let make = (cfg: cfg, ~eventRegistrations, ~addressStore) => {
|
|
|
121
113
|
)
|
|
122
114
|
}
|
|
123
115
|
|
|
116
|
+
// Returns the routed items/blocks plus the page's block store (Fuel blocks
|
|
117
|
+
// keyed by height); the store's ids drive reorg detection on merge.
|
|
124
118
|
@send
|
|
125
|
-
external getEventItems: (
|
|
126
|
-
|
|
119
|
+
external getEventItems: (
|
|
120
|
+
t,
|
|
121
|
+
EventItems.query,
|
|
122
|
+
AddressSet.t,
|
|
123
|
+
) => promise<(EventItems.response, BlockStore.t)> = "getEventItems"
|
|
127
124
|
|
|
128
125
|
@send
|
|
129
126
|
external getHeight: t => promise<int> = "getHeight"
|
|
@@ -25,7 +25,9 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
25
25
|
|
|
26
26
|
let client = switch FuelHyperSyncClient.make(
|
|
27
27
|
{url: endpointUrl, apiToken},
|
|
28
|
-
~eventRegistrations=FuelHyperSyncClient.Registration.fromOnEventRegistrations(
|
|
28
|
+
~eventRegistrations=FuelHyperSyncClient.Registration.fromOnEventRegistrations(
|
|
29
|
+
onEventRegistrations,
|
|
30
|
+
),
|
|
29
31
|
~addressStore,
|
|
30
32
|
) {
|
|
31
33
|
| client => client
|
|
@@ -57,29 +59,19 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
57
59
|
~addressSet,
|
|
58
60
|
~clientFilteredContracts=selection.clientFilteredContracts,
|
|
59
61
|
) catch {
|
|
60
|
-
| FuelHyperSync.GetLogs.Error(
|
|
62
|
+
| FuelHyperSync.GetLogs.Error(WrongInstance) =>
|
|
63
|
+
throw(Source.SourceBehindHead({blockNumber: fromBlock, requestStats: []}))
|
|
64
|
+
| FuelHyperSync.GetLogs.Error(UnexpectedMissingParams({missingParams})) =>
|
|
61
65
|
throw(
|
|
62
66
|
Source.GetItemsError(
|
|
63
67
|
Source.FailedGettingItems({
|
|
64
68
|
exn: %raw(`null`),
|
|
65
69
|
attemptedToBlock: toBlock->Option.getOr(knownHeight),
|
|
66
|
-
retry:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
WithBackoff({
|
|
73
|
-
message: `Block #${fromBlock->Int.toString} not found in FuelHyperSync. 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->Int.toString}ms.`,
|
|
74
|
-
backoffMillis,
|
|
75
|
-
})
|
|
76
|
-
| UnexpectedMissingParams({missingParams}) =>
|
|
77
|
-
ImpossibleForTheQuery({
|
|
78
|
-
message: `Source returned invalid data with missing required fields: ${missingParams->Array.joinUnsafe(
|
|
79
|
-
", ",
|
|
80
|
-
)}`,
|
|
81
|
-
})
|
|
82
|
-
},
|
|
70
|
+
retry: ImpossibleForTheQuery({
|
|
71
|
+
message: `Source returned invalid data with missing required fields: ${missingParams->Array.joinUnsafe(
|
|
72
|
+
", ",
|
|
73
|
+
)}`,
|
|
74
|
+
}),
|
|
83
75
|
}),
|
|
84
76
|
),
|
|
85
77
|
)
|
|
@@ -114,12 +106,6 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
114
106
|
|
|
115
107
|
let parsingTimeRef = Performance.now()
|
|
116
108
|
|
|
117
|
-
// Blocks are returned once per height; items reference them by blockHeight.
|
|
118
|
-
let blocksByHeight = Utils.Map.make()
|
|
119
|
-
pageUnsafe.blocks->Array.forEach(block => {
|
|
120
|
-
blocksByHeight->Utils.Map.set(block.height, block)->ignore
|
|
121
|
-
})
|
|
122
|
-
|
|
123
109
|
let parsedQueueItems = pageUnsafe.items->Array.map(item => {
|
|
124
110
|
// Routing happened in Rust; the item references its registration by
|
|
125
111
|
// chain-scoped index.
|
|
@@ -128,8 +114,6 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
128
114
|
onEventRegistration.eventConfig->(
|
|
129
115
|
Utils.magic: Internal.eventConfig => Internal.fuelEventConfig
|
|
130
116
|
)
|
|
131
|
-
// Presence of every routed item's block is validated in Rust.
|
|
132
|
-
let block = blocksByHeight->Utils.Map.unsafeGet(item.blockHeight)
|
|
133
117
|
|
|
134
118
|
let params = switch eventConfig.kind {
|
|
135
119
|
| LogData({decode}) =>
|
|
@@ -178,12 +162,13 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
178
162
|
payload: {
|
|
179
163
|
contractName: eventConfig.contractName,
|
|
180
164
|
eventName: eventConfig.name,
|
|
181
|
-
chainId
|
|
165
|
+
chainId,
|
|
182
166
|
params,
|
|
183
167
|
transaction: {
|
|
184
168
|
"id": item.txId,
|
|
185
169
|
}->Obj.magic, // TODO: Obj.magic needed until the field selection types are not configurable for Fuel and Evm separately
|
|
186
|
-
block
|
|
170
|
+
// `block` is omitted; it's materialised from the block store onto the
|
|
171
|
+
// payload at batch prep (like EVM/SVM).
|
|
187
172
|
srcAddress: item.srcAddress,
|
|
188
173
|
logIndex: item.receiptIndex,
|
|
189
174
|
}->Fuel.fromPayload,
|
|
@@ -192,18 +177,6 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
192
177
|
|
|
193
178
|
let parsingTimeElapsed = parsingTimeRef->Performance.secondsSince
|
|
194
179
|
|
|
195
|
-
// Fuel never rolls back on reorg, so block hashes here are purely informational
|
|
196
|
-
// for detect-only logging via ReorgDetection.
|
|
197
|
-
let blockHashes = pageUnsafe.blocks->Array.map(block => {
|
|
198
|
-
ReorgDetection.blockNumber: block.height,
|
|
199
|
-
blockHash: block.id,
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
let latestFetchedBlockTimestamp = switch blocksByHeight->Utils.Map.get(heighestBlockQueried) {
|
|
203
|
-
| Some(block) => block.time
|
|
204
|
-
| None => 0
|
|
205
|
-
}
|
|
206
|
-
|
|
207
180
|
let totalTimeElapsed = totalTimeRef->Performance.secondsSince
|
|
208
181
|
|
|
209
182
|
let stats = {
|
|
@@ -213,15 +186,15 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
213
186
|
}
|
|
214
187
|
|
|
215
188
|
{
|
|
216
|
-
latestFetchedBlockTimestamp,
|
|
217
189
|
parsedQueueItems,
|
|
218
|
-
// Fuel keeps transaction and block on the payload;
|
|
190
|
+
// Fuel keeps transaction and block inline on the payload; the block store
|
|
191
|
+
// carries only the (height, id) rows that drive reorg detection (Fuel
|
|
192
|
+
// never rolls back, so it's detect-only logging).
|
|
219
193
|
transactionStore: None,
|
|
220
|
-
blockStore:
|
|
194
|
+
blockStore: pageUnsafe.blockStore,
|
|
221
195
|
latestFetchedBlockNumber: heighestBlockQueried,
|
|
222
196
|
stats,
|
|
223
197
|
knownHeight,
|
|
224
|
-
blockHashes,
|
|
225
198
|
fromBlockQueried: fromBlock,
|
|
226
199
|
requestStats,
|
|
227
200
|
}
|
|
@@ -38,22 +38,16 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
38
38
|
let pageUnsafe;
|
|
39
39
|
try {
|
|
40
40
|
pageUnsafe = await FuelHyperSync.GetLogs.query(client, fromBlock, toBlock, selection.onEventRegistrations.map(reg => reg.index), addressSet, selection.clientFilteredContracts);
|
|
41
|
-
} catch (
|
|
42
|
-
let
|
|
43
|
-
if (
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
backoffMillis: backoffMillis
|
|
52
|
-
};
|
|
53
|
-
} else {
|
|
54
|
-
tmp = {
|
|
55
|
-
TAG: "ImpossibleForTheQuery",
|
|
56
|
-
message: `Source returned invalid data with missing required fields: ` + error$1.missingParams.join(", ")
|
|
41
|
+
} catch (raw_exn) {
|
|
42
|
+
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
43
|
+
if (exn.RE_EXN_ID === FuelHyperSync.GetLogs.$$Error) {
|
|
44
|
+
let match = exn._1;
|
|
45
|
+
if (typeof match !== "object") {
|
|
46
|
+
throw {
|
|
47
|
+
RE_EXN_ID: Source.SourceBehindHead,
|
|
48
|
+
blockNumber: fromBlock,
|
|
49
|
+
requestStats: [],
|
|
50
|
+
Error: new Error()
|
|
57
51
|
};
|
|
58
52
|
}
|
|
59
53
|
throw {
|
|
@@ -62,7 +56,10 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
62
56
|
TAG: "FailedGettingItems",
|
|
63
57
|
exn: null,
|
|
64
58
|
attemptedToBlock: Stdlib_Option.getOr(toBlock, knownHeight),
|
|
65
|
-
retry:
|
|
59
|
+
retry: {
|
|
60
|
+
TAG: "ImpossibleForTheQuery",
|
|
61
|
+
message: `Source returned invalid data with missing required fields: ` + match.missingParams.join(", ")
|
|
62
|
+
}
|
|
66
63
|
},
|
|
67
64
|
Error: new Error()
|
|
68
65
|
};
|
|
@@ -71,7 +68,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
71
68
|
RE_EXN_ID: Source.GetItemsError,
|
|
72
69
|
_1: {
|
|
73
70
|
TAG: "FailedGettingItems",
|
|
74
|
-
exn:
|
|
71
|
+
exn: exn,
|
|
75
72
|
attemptedToBlock: Stdlib_Option.getOr(toBlock, knownHeight),
|
|
76
73
|
retry: {
|
|
77
74
|
TAG: "WithBackoff",
|
|
@@ -90,14 +87,9 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
90
87
|
let knownHeight$1 = pageUnsafe.archiveHeight;
|
|
91
88
|
let heighestBlockQueried = pageUnsafe.nextBlock - 1 | 0;
|
|
92
89
|
let parsingTimeRef = Performance.now();
|
|
93
|
-
let blocksByHeight = new Map();
|
|
94
|
-
pageUnsafe.blocks.forEach(block => {
|
|
95
|
-
blocksByHeight.set(block.height, block);
|
|
96
|
-
});
|
|
97
90
|
let parsedQueueItems = pageUnsafe.items.map(item => {
|
|
98
91
|
let onEventRegistration = onEventRegistrations[item.onEventRegistrationIndex];
|
|
99
92
|
let eventConfig = onEventRegistration.eventConfig;
|
|
100
|
-
let block = blocksByHeight.get(item.blockHeight);
|
|
101
93
|
let match = eventConfig.kind;
|
|
102
94
|
let params;
|
|
103
95
|
let exit = 0;
|
|
@@ -158,18 +150,11 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
158
150
|
logIndex: item.receiptIndex,
|
|
159
151
|
transaction: {
|
|
160
152
|
id: item.txId
|
|
161
|
-
}
|
|
162
|
-
block: block
|
|
153
|
+
}
|
|
163
154
|
}
|
|
164
155
|
};
|
|
165
156
|
});
|
|
166
157
|
let parsingTimeElapsed = Performance.secondsSince(parsingTimeRef);
|
|
167
|
-
let blockHashes = pageUnsafe.blocks.map(block => ({
|
|
168
|
-
blockHash: block.id,
|
|
169
|
-
blockNumber: block.height
|
|
170
|
-
}));
|
|
171
|
-
let block = blocksByHeight.get(heighestBlockQueried);
|
|
172
|
-
let latestFetchedBlockTimestamp = block !== undefined ? block.time : 0;
|
|
173
158
|
let totalTimeElapsed = Performance.secondsSince(totalTimeRef);
|
|
174
159
|
let stats_parsing$unknowntime$unknown$lpars$rpar = parsingTimeElapsed;
|
|
175
160
|
let stats_page$unknownfetch$unknowntime$unknown$lpars$rpar = pageFetchTime;
|
|
@@ -180,13 +165,11 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
180
165
|
};
|
|
181
166
|
return {
|
|
182
167
|
knownHeight: knownHeight$1,
|
|
183
|
-
blockHashes: blockHashes,
|
|
184
168
|
parsedQueueItems: parsedQueueItems,
|
|
185
169
|
transactionStore: undefined,
|
|
186
|
-
blockStore:
|
|
170
|
+
blockStore: pageUnsafe.blockStore,
|
|
187
171
|
fromBlockQueried: fromBlock,
|
|
188
172
|
latestFetchedBlockNumber: heighestBlockQueried,
|
|
189
|
-
latestFetchedBlockTimestamp: latestFetchedBlockTimestamp,
|
|
190
173
|
stats: stats,
|
|
191
174
|
requestStats: requestStats
|
|
192
175
|
};
|
|
@@ -249,4 +232,4 @@ export {
|
|
|
249
232
|
isUnauthorizedError,
|
|
250
233
|
make,
|
|
251
234
|
}
|
|
252
|
-
/*
|
|
235
|
+
/* Source Not a pure module */
|