envio 3.0.0-alpha.21 → 3.0.0-alpha.23
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/README.md +3 -3
- package/bin.mjs +2 -48
- package/evm.schema.json +67 -0
- package/fuel.schema.json +67 -0
- package/index.d.ts +822 -38
- package/index.js +5 -3
- package/package.json +10 -8
- package/rescript.json +5 -9
- package/src/Address.res +4 -5
- package/src/Address.res.mjs +9 -12
- package/src/Api.res +15 -0
- package/src/Api.res.mjs +20 -0
- package/src/Batch.res +32 -34
- package/src/Batch.res.mjs +172 -187
- package/src/Bin.res +89 -0
- package/src/Bin.res.mjs +97 -0
- package/src/ChainFetcher.res +33 -57
- package/src/ChainFetcher.res.mjs +197 -227
- package/src/ChainManager.res +6 -14
- package/src/ChainManager.res.mjs +74 -85
- package/src/ChainMap.res +14 -16
- package/src/ChainMap.res.mjs +38 -38
- package/src/Config.res +193 -135
- package/src/Config.res.mjs +566 -592
- package/src/Core.res +182 -0
- package/src/Core.res.mjs +207 -0
- package/src/Ecosystem.res +25 -4
- package/src/Ecosystem.res.mjs +12 -13
- package/src/Env.res +20 -13
- package/src/Env.res.mjs +124 -113
- package/src/EnvSafe.res +269 -0
- package/src/EnvSafe.res.mjs +296 -0
- package/src/EnvSafe.resi +18 -0
- package/src/Envio.res +37 -26
- package/src/Envio.res.mjs +59 -60
- package/src/ErrorHandling.res +2 -2
- package/src/ErrorHandling.res.mjs +15 -15
- package/src/EventConfigBuilder.res +219 -81
- package/src/EventConfigBuilder.res.mjs +259 -202
- package/src/EventProcessing.res +27 -38
- package/src/EventProcessing.res.mjs +165 -183
- package/src/EventUtils.res +11 -11
- package/src/EventUtils.res.mjs +21 -22
- package/src/EvmTypes.res +0 -1
- package/src/EvmTypes.res.mjs +5 -5
- package/src/FetchState.res +360 -256
- package/src/FetchState.res.mjs +958 -914
- package/src/GlobalState.res +365 -351
- package/src/GlobalState.res.mjs +958 -992
- package/src/GlobalStateManager.res +1 -2
- package/src/GlobalStateManager.res.mjs +36 -44
- package/src/HandlerLoader.res +107 -23
- package/src/HandlerLoader.res.mjs +128 -38
- package/src/HandlerRegister.res +127 -103
- package/src/HandlerRegister.res.mjs +164 -164
- package/src/HandlerRegister.resi +12 -4
- package/src/Hasura.res +35 -22
- package/src/Hasura.res.mjs +158 -167
- package/src/InMemoryStore.res +20 -27
- package/src/InMemoryStore.res.mjs +64 -80
- package/src/InMemoryTable.res +34 -39
- package/src/InMemoryTable.res.mjs +165 -170
- package/src/Internal.res +52 -33
- package/src/Internal.res.mjs +84 -81
- package/src/LazyLoader.res.mjs +55 -61
- package/src/LoadLayer.res +77 -78
- package/src/LoadLayer.res.mjs +160 -189
- package/src/LoadManager.res +16 -21
- package/src/LoadManager.res.mjs +79 -84
- package/src/LogSelection.res +236 -68
- package/src/LogSelection.res.mjs +211 -141
- package/src/Logging.res +13 -9
- package/src/Logging.res.mjs +130 -143
- package/src/Main.res +430 -51
- package/src/Main.res.mjs +530 -271
- package/src/Persistence.res +80 -84
- package/src/Persistence.res.mjs +131 -132
- package/src/PgStorage.res +294 -167
- package/src/PgStorage.res.mjs +799 -817
- package/src/Prometheus.res +50 -58
- package/src/Prometheus.res.mjs +345 -373
- package/src/ReorgDetection.res +22 -24
- package/src/ReorgDetection.res.mjs +100 -106
- package/src/SafeCheckpointTracking.res +7 -7
- package/src/SafeCheckpointTracking.res.mjs +40 -43
- package/src/SimulateItems.res +41 -49
- package/src/SimulateItems.res.mjs +257 -272
- package/src/Sink.res +2 -2
- package/src/Sink.res.mjs +22 -26
- package/src/TableIndices.res +1 -2
- package/src/TableIndices.res.mjs +42 -48
- package/src/TestIndexer.res +196 -189
- package/src/TestIndexer.res.mjs +536 -536
- package/src/TestIndexerProxyStorage.res +16 -16
- package/src/TestIndexerProxyStorage.res.mjs +99 -122
- package/src/TestIndexerWorker.res +4 -0
- package/src/TestIndexerWorker.res.mjs +7 -0
- package/src/Throttler.res +3 -3
- package/src/Throttler.res.mjs +23 -24
- package/src/Time.res +1 -1
- package/src/Time.res.mjs +18 -21
- package/src/TopicFilter.res +3 -3
- package/src/TopicFilter.res.mjs +29 -30
- package/src/UserContext.res +93 -54
- package/src/UserContext.res.mjs +197 -182
- package/src/Utils.res +141 -86
- package/src/Utils.res.mjs +334 -295
- package/src/bindings/BigDecimal.res +0 -2
- package/src/bindings/BigDecimal.res.mjs +19 -23
- package/src/bindings/ClickHouse.res +28 -27
- package/src/bindings/ClickHouse.res.mjs +243 -240
- package/src/bindings/DateFns.res +11 -11
- package/src/bindings/DateFns.res.mjs +7 -7
- package/src/bindings/EventSource.res.mjs +2 -2
- package/src/bindings/Express.res +2 -5
- package/src/bindings/Hrtime.res +2 -2
- package/src/bindings/Hrtime.res.mjs +30 -32
- package/src/bindings/Lodash.res.mjs +1 -1
- package/src/bindings/NodeJs.res +14 -9
- package/src/bindings/NodeJs.res.mjs +20 -20
- package/src/bindings/Pino.res +8 -10
- package/src/bindings/Pino.res.mjs +40 -43
- package/src/bindings/Postgres.res +7 -5
- package/src/bindings/Postgres.res.mjs +9 -9
- package/src/bindings/PromClient.res +17 -2
- package/src/bindings/PromClient.res.mjs +30 -7
- package/src/bindings/SDSL.res.mjs +2 -2
- package/src/bindings/Viem.res +4 -4
- package/src/bindings/Viem.res.mjs +20 -22
- package/src/bindings/Vitest.res +1 -1
- package/src/bindings/Vitest.res.mjs +2 -2
- package/src/bindings/WebSocket.res +1 -1
- package/src/db/EntityHistory.res +9 -3
- package/src/db/EntityHistory.res.mjs +84 -59
- package/src/db/InternalTable.res +62 -60
- package/src/db/InternalTable.res.mjs +271 -203
- package/src/db/Schema.res +1 -2
- package/src/db/Schema.res.mjs +28 -32
- package/src/db/Table.res +28 -27
- package/src/db/Table.res.mjs +276 -292
- package/src/sources/EventRouter.res +21 -16
- package/src/sources/EventRouter.res.mjs +55 -57
- package/src/sources/Evm.res +17 -1
- package/src/sources/Evm.res.mjs +16 -8
- package/src/sources/EvmChain.res +15 -17
- package/src/sources/EvmChain.res.mjs +40 -42
- package/src/sources/Fuel.res +14 -1
- package/src/sources/Fuel.res.mjs +16 -8
- package/src/sources/FuelSDK.res +1 -1
- package/src/sources/FuelSDK.res.mjs +6 -8
- package/src/sources/HyperFuel.res +8 -10
- package/src/sources/HyperFuel.res.mjs +113 -123
- package/src/sources/HyperFuelClient.res.mjs +6 -7
- package/src/sources/HyperFuelSource.res +19 -20
- package/src/sources/HyperFuelSource.res.mjs +339 -356
- package/src/sources/HyperSync.res +11 -13
- package/src/sources/HyperSync.res.mjs +206 -220
- package/src/sources/HyperSyncClient.res +5 -7
- package/src/sources/HyperSyncClient.res.mjs +70 -75
- package/src/sources/HyperSyncHeightStream.res +8 -9
- package/src/sources/HyperSyncHeightStream.res.mjs +78 -86
- package/src/sources/HyperSyncJsonApi.res +18 -15
- package/src/sources/HyperSyncJsonApi.res.mjs +201 -231
- package/src/sources/HyperSyncSource.res +17 -21
- package/src/sources/HyperSyncSource.res.mjs +268 -290
- package/src/sources/Rpc.res +5 -5
- package/src/sources/Rpc.res.mjs +168 -192
- package/src/sources/RpcSource.res +166 -167
- package/src/sources/RpcSource.res.mjs +972 -1046
- package/src/sources/RpcWebSocketHeightStream.res +10 -11
- package/src/sources/RpcWebSocketHeightStream.res.mjs +131 -145
- package/src/sources/SimulateSource.res +1 -1
- package/src/sources/SimulateSource.res.mjs +35 -38
- package/src/sources/Source.res +1 -1
- package/src/sources/Source.res.mjs +3 -3
- package/src/sources/SourceManager.res +39 -20
- package/src/sources/SourceManager.res.mjs +340 -371
- package/src/sources/SourceManager.resi +2 -1
- package/src/sources/Svm.res +12 -5
- package/src/sources/Svm.res.mjs +44 -41
- package/src/tui/Tui.res +23 -12
- package/src/tui/Tui.res.mjs +292 -290
- package/src/tui/bindings/Ink.res +2 -4
- package/src/tui/bindings/Ink.res.mjs +35 -41
- package/src/tui/components/BufferedProgressBar.res +7 -7
- package/src/tui/components/BufferedProgressBar.res.mjs +46 -46
- package/src/tui/components/CustomHooks.res +1 -2
- package/src/tui/components/CustomHooks.res.mjs +102 -122
- package/src/tui/components/Messages.res +1 -2
- package/src/tui/components/Messages.res.mjs +38 -42
- package/src/tui/components/SyncETA.res +10 -11
- package/src/tui/components/SyncETA.res.mjs +178 -196
- package/src/tui/components/TuiData.res +1 -1
- package/src/tui/components/TuiData.res.mjs +7 -6
- package/src/vendored/Rest.res +52 -66
- package/src/vendored/Rest.res.mjs +324 -364
- package/svm.schema.json +67 -0
- package/src/Address.gen.ts +0 -8
- package/src/Config.gen.ts +0 -19
- package/src/Envio.gen.ts +0 -55
- package/src/EvmTypes.gen.ts +0 -6
- package/src/InMemoryStore.gen.ts +0 -6
- package/src/Internal.gen.ts +0 -64
- package/src/PgStorage.gen.ts +0 -10
- package/src/PgStorage.res.d.mts +0 -5
- package/src/Types.ts +0 -56
- package/src/bindings/BigDecimal.gen.ts +0 -14
- package/src/bindings/BigDecimal.res.d.mts +0 -5
- package/src/bindings/BigInt.gen.ts +0 -10
- package/src/bindings/BigInt.res +0 -70
- package/src/bindings/BigInt.res.d.mts +0 -5
- package/src/bindings/BigInt.res.mjs +0 -154
- package/src/bindings/Ethers.res.d.mts +0 -5
- package/src/bindings/Pino.gen.ts +0 -17
- package/src/bindings/Postgres.gen.ts +0 -8
- package/src/bindings/Postgres.res.d.mts +0 -5
- package/src/bindings/Promise.res +0 -67
- package/src/bindings/Promise.res.mjs +0 -26
- package/src/db/InternalTable.gen.ts +0 -36
- package/src/sources/HyperSyncClient.gen.ts +0 -19
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
open Belt
|
|
2
|
-
|
|
3
1
|
//Manage clients in cache so we don't need to reinstantiate each time
|
|
4
2
|
//Ideally client should be passed in as a param to the functions but
|
|
5
3
|
//we are still sharing the same signature with eth archive query builder
|
|
6
4
|
|
|
7
5
|
module CachedClients = {
|
|
8
|
-
let cache:
|
|
6
|
+
let cache: dict<HyperFuelClient.t> = Dict.make()
|
|
9
7
|
|
|
10
8
|
let getClient = url => {
|
|
11
9
|
switch cache->Utils.Dict.dangerouslyGetNonOption(url) {
|
|
12
10
|
| Some(client) => client
|
|
13
11
|
| None =>
|
|
14
12
|
let newClient = HyperFuelClient.make({url: url})
|
|
15
|
-
cache->
|
|
13
|
+
cache->Dict.set(url, newClient)
|
|
16
14
|
newClient
|
|
17
15
|
}
|
|
18
16
|
}
|
|
@@ -55,7 +53,7 @@ let queryErrorToMsq = (e: queryError): string => {
|
|
|
55
53
|
switch e {
|
|
56
54
|
| UnexpectedMissingParams({queryName, missingParams}) =>
|
|
57
55
|
`${queryName} query failed due to unexpected missing params on response:
|
|
58
|
-
${missingParams->
|
|
56
|
+
${missingParams->Array.joinUnsafe(", ")}`
|
|
59
57
|
}
|
|
60
58
|
}
|
|
61
59
|
|
|
@@ -106,7 +104,7 @@ module GetLogs = {
|
|
|
106
104
|
switch param {
|
|
107
105
|
| Some(v) => v
|
|
108
106
|
| None =>
|
|
109
|
-
|
|
107
|
+
throw(
|
|
110
108
|
Error(
|
|
111
109
|
UnexpectedMissingParams({
|
|
112
110
|
missingParams: [name],
|
|
@@ -122,11 +120,11 @@ module GetLogs = {
|
|
|
122
120
|
> => {
|
|
123
121
|
let {receipts, blocks} = response_data
|
|
124
122
|
|
|
125
|
-
let blocksDict =
|
|
123
|
+
let blocksDict = Dict.make()
|
|
126
124
|
blocks
|
|
127
125
|
->(Utils.magic: option<'a> => 'a)
|
|
128
126
|
->Array.forEach(block => {
|
|
129
|
-
blocksDict->
|
|
127
|
+
blocksDict->Dict.set(block.height->(Utils.magic: int => string), block)
|
|
130
128
|
})
|
|
131
129
|
|
|
132
130
|
let items = []
|
|
@@ -163,7 +161,7 @@ module GetLogs = {
|
|
|
163
161
|
let page: logsQueryPage = {
|
|
164
162
|
items: res.data->decodeLogQueryPageItems,
|
|
165
163
|
nextBlock,
|
|
166
|
-
archiveHeight: archiveHeight->Option.
|
|
164
|
+
archiveHeight: archiveHeight->Option.getOr(0), // TODO: FIXME: Shouldn't have a default here
|
|
167
165
|
}
|
|
168
166
|
page
|
|
169
167
|
}
|
|
@@ -180,7 +178,7 @@ module GetLogs = {
|
|
|
180
178
|
let res = await hyperFuelClient->HyperFuelClient.getSelectedData(query)
|
|
181
179
|
if res.nextBlock <= fromBlock {
|
|
182
180
|
// Might happen when /height response was from another instance of HyperSync
|
|
183
|
-
|
|
181
|
+
throw(Error(WrongInstance))
|
|
184
182
|
}
|
|
185
183
|
res->convertResponse
|
|
186
184
|
}
|
|
@@ -2,136 +2,136 @@
|
|
|
2
2
|
|
|
3
3
|
import * as Time from "../Time.res.mjs";
|
|
4
4
|
import * as Logging from "../Logging.res.mjs";
|
|
5
|
-
import * as
|
|
6
|
-
import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
|
|
7
|
-
import * as Caml_option from "rescript/lib/es6/caml_option.js";
|
|
8
|
-
import * as Caml_exceptions from "rescript/lib/es6/caml_exceptions.js";
|
|
5
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
9
6
|
import * as HyperFuelClient from "./HyperFuelClient.res.mjs";
|
|
7
|
+
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
10
8
|
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
9
|
+
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
let cache = {};
|
|
13
12
|
|
|
14
13
|
function getClient(url) {
|
|
15
|
-
|
|
14
|
+
let client = cache[url];
|
|
16
15
|
if (client !== undefined) {
|
|
17
|
-
return
|
|
16
|
+
return Primitive_option.valFromOption(client);
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
let newClient = HyperFuelClient.make({
|
|
19
|
+
url: url
|
|
20
|
+
});
|
|
22
21
|
cache[url] = newClient;
|
|
23
22
|
return newClient;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
function queryErrorToMsq(e) {
|
|
27
|
-
|
|
28
|
-
return match.queryName +
|
|
26
|
+
let match = e._0;
|
|
27
|
+
return match.queryName + ` query failed due to unexpected missing params on response:
|
|
28
|
+
` + match.missingParams.join(", ");
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
let $$Error = /* @__PURE__ */Primitive_exceptions.create("HyperFuel.GetLogs.Error");
|
|
32
32
|
|
|
33
33
|
function makeRequestBody(fromBlock, toBlockInclusive, recieptsSelection) {
|
|
34
34
|
return {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
35
|
+
fromBlock: fromBlock,
|
|
36
|
+
toBlock: toBlockInclusive !== undefined ? toBlockInclusive + 1 | 0 : undefined,
|
|
37
|
+
receipts: recieptsSelection,
|
|
38
|
+
fieldSelection: {
|
|
39
|
+
block: [
|
|
40
|
+
"id",
|
|
41
|
+
"height",
|
|
42
|
+
"time"
|
|
43
|
+
],
|
|
44
|
+
receipt: [
|
|
45
|
+
"tx_id",
|
|
46
|
+
"block_height",
|
|
47
|
+
"root_contract_id",
|
|
48
|
+
"data",
|
|
49
|
+
"receipt_index",
|
|
50
|
+
"receipt_type",
|
|
51
|
+
"rb",
|
|
52
|
+
"sub_id",
|
|
53
|
+
"val",
|
|
54
|
+
"amount",
|
|
55
|
+
"to_address",
|
|
56
|
+
"asset_id",
|
|
57
|
+
"to"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
function getParam(param, name) {
|
|
64
64
|
if (param !== undefined) {
|
|
65
|
-
return
|
|
65
|
+
return Primitive_option.valFromOption(param);
|
|
66
66
|
}
|
|
67
67
|
throw {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
RE_EXN_ID: $$Error,
|
|
69
|
+
_1: {
|
|
70
|
+
TAG: "UnexpectedMissingParams",
|
|
71
|
+
missingParams: [name]
|
|
72
|
+
},
|
|
73
|
+
Error: new Error()
|
|
74
|
+
};
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
function decodeLogQueryPageItems(response_data) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
78
|
+
let blocksDict = {};
|
|
79
|
+
response_data.blocks.forEach(block => {
|
|
80
|
+
blocksDict[block.height] = block;
|
|
81
|
+
});
|
|
82
|
+
let items = [];
|
|
83
|
+
response_data.receipts.forEach(receipt => {
|
|
84
|
+
let contractId = receipt.rootContractId;
|
|
85
|
+
if (contractId === undefined) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
let block = getParam(blocksDict[receipt.blockHeight], "Failed to find block associated to receipt");
|
|
89
|
+
items.push({
|
|
90
|
+
transactionId: receipt.txId,
|
|
91
|
+
contractId: Primitive_option.valFromOption(contractId),
|
|
92
|
+
receipt: receipt,
|
|
93
|
+
receiptIndex: receipt.receiptIndex,
|
|
94
|
+
block: {
|
|
95
|
+
id: block.id,
|
|
96
|
+
time: block.time,
|
|
97
|
+
height: block.height
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
101
|
return items;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
async function query(serverUrl, fromBlock, toBlock, recieptsSelection) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
let query$1 = makeRequestBody(fromBlock, toBlock, recieptsSelection);
|
|
106
|
+
let hyperFuelClient = getClient(serverUrl);
|
|
107
|
+
let res = await hyperFuelClient.getSelectedData(query$1);
|
|
108
108
|
if (res.nextBlock <= fromBlock) {
|
|
109
109
|
throw {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
RE_EXN_ID: $$Error,
|
|
111
|
+
_1: "WrongInstance",
|
|
112
|
+
Error: new Error()
|
|
113
|
+
};
|
|
114
114
|
}
|
|
115
115
|
return {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
items: decodeLogQueryPageItems(res.data),
|
|
117
|
+
nextBlock: res.nextBlock,
|
|
118
|
+
archiveHeight: Stdlib_Option.getOr(res.archiveHeight, 0)
|
|
119
|
+
};
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
async function queryBlockData(serverUrl, blockNumber, logger) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
let query_toBlock = blockNumber + 1 | 0;
|
|
124
|
+
let query_inputs = [{}];
|
|
125
|
+
let query_outputs = [{}];
|
|
126
|
+
let query_includeAllBlocks = true;
|
|
127
|
+
let query_fieldSelection = {
|
|
128
128
|
block: [
|
|
129
129
|
"height",
|
|
130
130
|
"id",
|
|
131
131
|
"time"
|
|
132
132
|
]
|
|
133
133
|
};
|
|
134
|
-
|
|
134
|
+
let query = {
|
|
135
135
|
fromBlock: blockNumber,
|
|
136
136
|
toBlock: query_toBlock,
|
|
137
137
|
inputs: query_inputs,
|
|
@@ -139,56 +139,46 @@ async function queryBlockData(serverUrl, blockNumber, logger) {
|
|
|
139
139
|
includeAllBlocks: query_includeAllBlocks,
|
|
140
140
|
fieldSelection: query_fieldSelection
|
|
141
141
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
};
|
|
150
|
-
var res = await Time.retryAsyncWithExponentialBackOff(undefined, undefined, undefined, undefined, logger$1, executeQuery);
|
|
142
|
+
let hyperFuelClient = getClient(serverUrl);
|
|
143
|
+
let logger$1 = Logging.createChildFrom(logger, {
|
|
144
|
+
logType: "hypersync get blockhash query",
|
|
145
|
+
blockNumber: blockNumber
|
|
146
|
+
});
|
|
147
|
+
let executeQuery = () => hyperFuelClient.getSelectedData(query);
|
|
148
|
+
let res = await Time.retryAsyncWithExponentialBackOff(undefined, undefined, undefined, undefined, logger$1, executeQuery);
|
|
151
149
|
if (res.nextBlock > blockNumber) {
|
|
152
|
-
return
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
blockTimestamp: block.time
|
|
158
|
-
};
|
|
159
|
-
}));
|
|
160
|
-
}));
|
|
150
|
+
return Stdlib_Option.flatMap(res.data.blocks, blocks => Stdlib_Option.map(blocks[0], block => ({
|
|
151
|
+
blockHash: block.id,
|
|
152
|
+
blockNumber: block.height,
|
|
153
|
+
blockTimestamp: block.time
|
|
154
|
+
})));
|
|
161
155
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
Logging.childInfo(logger$2,
|
|
156
|
+
let logger$2 = Logging.createChild({
|
|
157
|
+
url: serverUrl
|
|
158
|
+
});
|
|
159
|
+
Logging.childInfo(logger$2, `Block #` + blockNumber.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 ` + (100).toString() + `ms.`);
|
|
166
160
|
await Time.resolvePromiseAfterDelay(100);
|
|
167
161
|
return await queryBlockData(serverUrl, blockNumber, logger$2);
|
|
168
162
|
}
|
|
169
163
|
|
|
170
164
|
function heightRoute() {
|
|
171
165
|
return {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
responses: [(function (s) {
|
|
178
|
-
return s.field("height", S$RescriptSchema.$$int);
|
|
179
|
-
})]
|
|
180
|
-
};
|
|
166
|
+
method: "GET",
|
|
167
|
+
path: "/height",
|
|
168
|
+
input: param => {},
|
|
169
|
+
responses: [s => s.field("height", S$RescriptSchema.int)]
|
|
170
|
+
};
|
|
181
171
|
}
|
|
182
172
|
|
|
183
|
-
|
|
173
|
+
let GetLogs = {
|
|
184
174
|
$$Error: $$Error,
|
|
185
175
|
query: query
|
|
186
176
|
};
|
|
187
177
|
|
|
188
178
|
export {
|
|
189
|
-
queryErrorToMsq
|
|
190
|
-
GetLogs
|
|
191
|
-
queryBlockData
|
|
192
|
-
heightRoute
|
|
179
|
+
queryErrorToMsq,
|
|
180
|
+
GetLogs,
|
|
181
|
+
queryBlockData,
|
|
182
|
+
heightRoute,
|
|
193
183
|
}
|
|
194
184
|
/* Time Not a pure module */
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as Caml_obj from "rescript/lib/es6/caml_obj.js";
|
|
4
3
|
import * as HyperfuelClient from "@envio-dev/hyperfuel-client";
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
let QueryTypes = {};
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
let FuelTypes = {};
|
|
9
8
|
|
|
10
9
|
function make(cfg) {
|
|
11
|
-
|
|
10
|
+
let newrecord = {...cfg};
|
|
12
11
|
return HyperfuelClient.HyperfuelClient.new((newrecord.bearerToken = "3dc856dd-b0ea-494f-b27e-017b8b6b7e07", newrecord));
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
export {
|
|
16
|
-
QueryTypes
|
|
17
|
-
FuelTypes
|
|
18
|
-
make
|
|
15
|
+
QueryTypes,
|
|
16
|
+
FuelTypes,
|
|
17
|
+
make,
|
|
19
18
|
}
|
|
20
19
|
/* @envio-dev/hyperfuel-client Not a pure module */
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
open Source
|
|
2
|
-
open Belt
|
|
3
2
|
|
|
4
3
|
exception EventRoutingFailed
|
|
5
4
|
|
|
@@ -39,7 +38,7 @@ let makeGetNormalRecieptsSelection = (
|
|
|
39
38
|
) {
|
|
40
39
|
| Some(receiptTypes) =>
|
|
41
40
|
selection
|
|
42
|
-
->
|
|
41
|
+
->Array.push({
|
|
43
42
|
rootContractId: addresses,
|
|
44
43
|
receiptType: receiptTypes,
|
|
45
44
|
txStatus: txStatusSelection,
|
|
@@ -52,7 +51,7 @@ let makeGetNormalRecieptsSelection = (
|
|
|
52
51
|
| Some([]) => ()
|
|
53
52
|
| Some(nonWildcardLogDataRbs) =>
|
|
54
53
|
selection
|
|
55
|
-
->
|
|
54
|
+
->Array.push({
|
|
56
55
|
rootContractId: addresses,
|
|
57
56
|
receiptType: logDataReceiptTypeSelection,
|
|
58
57
|
txStatus: txStatusSelection,
|
|
@@ -75,7 +74,7 @@ let makeWildcardRecieptsSelection = (~wildcardLogDataRbs, ~nonLogDataWildcardRec
|
|
|
75
74
|
| [] => ()
|
|
76
75
|
| nonLogDataWildcardReceiptTypes =>
|
|
77
76
|
selection
|
|
78
|
-
->
|
|
77
|
+
->Array.push(
|
|
79
78
|
(
|
|
80
79
|
{
|
|
81
80
|
receiptType: nonLogDataWildcardReceiptTypes,
|
|
@@ -90,7 +89,7 @@ let makeWildcardRecieptsSelection = (~wildcardLogDataRbs, ~nonLogDataWildcardRec
|
|
|
90
89
|
| [] => ()
|
|
91
90
|
| wildcardLogDataRbs =>
|
|
92
91
|
selection
|
|
93
|
-
->
|
|
92
|
+
->Array.push(
|
|
94
93
|
(
|
|
95
94
|
{
|
|
96
95
|
receiptType: logDataReceiptTypeSelection,
|
|
@@ -107,11 +106,11 @@ let makeWildcardRecieptsSelection = (~wildcardLogDataRbs, ~nonLogDataWildcardRec
|
|
|
107
106
|
|
|
108
107
|
let getSelectionConfig = (selection: FetchState.selection, ~chain) => {
|
|
109
108
|
let eventRouter = EventRouter.empty()
|
|
110
|
-
let nonWildcardLogDataRbsByContract =
|
|
109
|
+
let nonWildcardLogDataRbsByContract = Dict.make()
|
|
111
110
|
let wildcardLogDataRbs = []
|
|
112
111
|
|
|
113
112
|
// This is for non-LogData events, since they don't have rb filter and can be grouped
|
|
114
|
-
let nonLogDataReceiptTypesByContract =
|
|
113
|
+
let nonLogDataReceiptTypesByContract = Dict.make()
|
|
115
114
|
let nonLogDataWildcardReceiptTypes = []
|
|
116
115
|
|
|
117
116
|
let addNonLogDataWildcardReceiptTypes = (receiptType: FuelSDK.receiptType) => {
|
|
@@ -119,7 +118,7 @@ let getSelectionConfig = (selection: FetchState.selection, ~chain) => {
|
|
|
119
118
|
}
|
|
120
119
|
let addNonLogDataReceiptType = (contractName, receiptType: FuelSDK.receiptType) => {
|
|
121
120
|
switch nonLogDataReceiptTypesByContract->Utils.Dict.dangerouslyGetNonOption(contractName) {
|
|
122
|
-
| None => nonLogDataReceiptTypesByContract->
|
|
121
|
+
| None => nonLogDataReceiptTypesByContract->Dict.set(contractName, [receiptType])
|
|
123
122
|
| Some(receiptTypes) => receiptTypes->Array.push(receiptType)->ignore // Duplication prevented by EventRouter
|
|
124
123
|
}
|
|
125
124
|
}
|
|
@@ -157,15 +156,15 @@ let getSelectionConfig = (selection: FetchState.selection, ~chain) => {
|
|
|
157
156
|
}
|
|
158
157
|
| {kind: Call, isWildcard: true} => addNonLogDataWildcardReceiptTypes(Call)
|
|
159
158
|
| {kind: Call} =>
|
|
160
|
-
|
|
159
|
+
JsError.throwWithMessage("Call receipt indexing currently supported only in wildcard mode")
|
|
161
160
|
| {kind: LogData({logId}), isWildcard} => {
|
|
162
|
-
let rb = logId->BigInt.
|
|
161
|
+
let rb = logId->BigInt.fromStringOrThrow
|
|
163
162
|
if isWildcard {
|
|
164
163
|
wildcardLogDataRbs->Array.push(rb)->ignore
|
|
165
164
|
} else {
|
|
166
165
|
switch nonWildcardLogDataRbsByContract->Utils.Dict.dangerouslyGetNonOption(contractName) {
|
|
167
166
|
| Some(arr) => arr->Belt.Array.push(rb)
|
|
168
|
-
| None => nonWildcardLogDataRbsByContract->
|
|
167
|
+
| None => nonWildcardLogDataRbsByContract->Dict.set(contractName, [rb])
|
|
169
168
|
}
|
|
170
169
|
}
|
|
171
170
|
}
|
|
@@ -219,7 +218,7 @@ let make = ({chain, endpointUrl}: options): t => {
|
|
|
219
218
|
~fromBlock,
|
|
220
219
|
~toBlock,
|
|
221
220
|
~addressesByContractName,
|
|
222
|
-
~
|
|
221
|
+
~indexingAddresses,
|
|
223
222
|
~knownHeight,
|
|
224
223
|
~partitionId as _,
|
|
225
224
|
~selection: FetchState.selection,
|
|
@@ -247,11 +246,11 @@ let make = ({chain, endpointUrl}: options): t => {
|
|
|
247
246
|
~recieptsSelection,
|
|
248
247
|
) catch {
|
|
249
248
|
| HyperSync.GetLogs.Error(error) =>
|
|
250
|
-
|
|
249
|
+
throw(
|
|
251
250
|
Source.GetItemsError(
|
|
252
251
|
Source.FailedGettingItems({
|
|
253
252
|
exn: %raw(`null`),
|
|
254
|
-
attemptedToBlock: toBlock->Option.
|
|
253
|
+
attemptedToBlock: toBlock->Option.getOr(knownHeight),
|
|
255
254
|
retry: switch error {
|
|
256
255
|
| WrongInstance =>
|
|
257
256
|
let backoffMillis = switch retry {
|
|
@@ -264,7 +263,7 @@ let make = ({chain, endpointUrl}: options): t => {
|
|
|
264
263
|
})
|
|
265
264
|
| UnexpectedMissingParams({missingParams}) =>
|
|
266
265
|
ImpossibleForTheQuery({
|
|
267
|
-
message: `Source returned invalid data with missing required fields: ${missingParams->
|
|
266
|
+
message: `Source returned invalid data with missing required fields: ${missingParams->Array.joinUnsafe(
|
|
268
267
|
", ",
|
|
269
268
|
)}`,
|
|
270
269
|
})
|
|
@@ -273,11 +272,11 @@ let make = ({chain, endpointUrl}: options): t => {
|
|
|
273
272
|
),
|
|
274
273
|
)
|
|
275
274
|
| exn =>
|
|
276
|
-
|
|
275
|
+
throw(
|
|
277
276
|
Source.GetItemsError(
|
|
278
277
|
Source.FailedGettingItems({
|
|
279
278
|
exn,
|
|
280
|
-
attemptedToBlock: toBlock->Option.
|
|
279
|
+
attemptedToBlock: toBlock->Option.getOr(knownHeight),
|
|
281
280
|
retry: WithBackoff({
|
|
282
281
|
message: `Unexpected issue while fetching events from HyperFuel client. Attempt a retry.`,
|
|
283
282
|
backoffMillis: switch retry {
|
|
@@ -366,7 +365,7 @@ let make = ({chain, endpointUrl}: options): t => {
|
|
|
366
365
|
|
|
367
366
|
let eventConfig = switch selectionConfig.eventRouter->EventRouter.get(
|
|
368
367
|
~tag=eventId,
|
|
369
|
-
~
|
|
368
|
+
~indexingAddresses,
|
|
370
369
|
~contractAddress,
|
|
371
370
|
~blockNumber=block.height,
|
|
372
371
|
) {
|
|
@@ -438,7 +437,7 @@ let make = ({chain, endpointUrl}: options): t => {
|
|
|
438
437
|
}: Internal.fuelTransferParams
|
|
439
438
|
)->Obj.magic
|
|
440
439
|
// This should never happen unless there's a bug in the routing logic
|
|
441
|
-
| _ =>
|
|
440
|
+
| _ => JsError.throwWithMessage("Unexpected bug in the event routing logic")
|
|
442
441
|
}
|
|
443
442
|
|
|
444
443
|
Internal.Event({
|
|
@@ -491,7 +490,7 @@ let make = ({chain, endpointUrl}: options): t => {
|
|
|
491
490
|
}
|
|
492
491
|
|
|
493
492
|
let getBlockHashes = (~blockNumbers as _, ~logger as _) =>
|
|
494
|
-
|
|
493
|
+
JsError.throwWithMessage("HyperFuel does not support getting block hashes")
|
|
495
494
|
|
|
496
495
|
let jsonApiClient = Rest.client(endpointUrl)
|
|
497
496
|
|