envio 3.0.0-alpha-main-clickhouse-sink → 3.0.0-alpha.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/bin.js +5 -3
- package/evm.schema.json +23 -6
- package/fuel.schema.json +17 -5
- package/index.d.ts +0 -27
- package/index.js +9 -6
- package/package.json +11 -7
- package/rescript.json +4 -3
- package/src/{Address.res.js → Address.res.mjs} +7 -6
- package/src/{Batch.res.js → Batch.res.mjs} +19 -18
- package/src/{ChainMap.res.js → ChainMap.res.mjs} +20 -19
- package/src/{Config.res.js → Config.res.mjs} +11 -10
- package/src/Envio.gen.ts +2 -15
- package/src/Envio.res +0 -36
- package/src/{Envio.res.js → Envio.res.mjs} +5 -16
- package/src/{ErrorHandling.res.js → ErrorHandling.res.mjs} +10 -9
- package/src/EventRegister.res +7 -0
- package/src/{EventRegister.res.js → EventRegister.res.mjs} +29 -18
- package/src/EventRegister.resi +1 -0
- package/src/{EventUtils.res.js → EventUtils.res.mjs} +10 -9
- package/src/{EvmTypes.res.js → EvmTypes.res.mjs} +5 -4
- package/src/{FetchState.res.js → FetchState.res.mjs} +44 -43
- package/src/{Hasura.res.js → Hasura.res.mjs} +25 -24
- package/src/{InMemoryStore.res.js → InMemoryStore.res.mjs} +19 -18
- package/src/{InMemoryTable.res.js → InMemoryTable.res.mjs} +21 -20
- package/src/Internal.gen.ts +1 -3
- package/src/Internal.res +9 -2
- package/src/{Internal.res.js → Internal.res.mjs} +21 -11
- package/src/{LazyLoader.res.js → LazyLoader.res.mjs} +14 -13
- package/src/{LoadManager.res.js → LoadManager.res.mjs} +11 -10
- package/src/{LogSelection.res.js → LogSelection.res.mjs} +14 -13
- package/src/{Logging.res.js → Logging.res.mjs} +37 -36
- package/src/{Persistence.res.js → Persistence.res.mjs} +22 -21
- package/src/{PgStorage.res.js → PgStorage.res.mjs} +58 -57
- package/src/Platform.res +4 -5
- package/src/{Platform.res.js → Platform.res.mjs} +10 -10
- package/src/{Prometheus.res.js → Prometheus.res.mjs} +66 -65
- package/src/{ReorgDetection.res.js → ReorgDetection.res.mjs} +12 -11
- package/src/{SafeCheckpointTracking.res.js → SafeCheckpointTracking.res.mjs} +6 -5
- package/src/{Sink.res.js → Sink.res.mjs} +6 -5
- package/src/{TableIndices.res.js → TableIndices.res.mjs} +8 -7
- package/src/{Throttler.res.js → Throttler.res.mjs} +7 -6
- package/src/{Time.res.js → Time.res.mjs} +8 -7
- package/src/{TopicFilter.res.js → TopicFilter.res.mjs} +18 -17
- package/src/Utils.res +40 -0
- package/src/{Utils.res.js → Utils.res.mjs} +68 -34
- package/src/bindings/BigDecimal.gen.ts +2 -2
- package/src/bindings/BigDecimal.res +5 -5
- package/src/bindings/BigDecimal.res.d.mts +5 -0
- package/src/bindings/{BigDecimal.res.js → BigDecimal.res.mjs} +10 -9
- package/src/bindings/BigInt.gen.ts +2 -2
- package/src/bindings/BigInt.res.d.mts +5 -0
- package/src/bindings/{BigInt.res.js → BigInt.res.mjs} +25 -24
- package/src/bindings/ClickHouse.res +2 -2
- package/src/bindings/{ClickHouse.res.js → ClickHouse.res.mjs} +22 -21
- package/src/bindings/Ethers.gen.ts +2 -2
- package/src/bindings/Ethers.res.d.mts +5 -0
- package/src/bindings/{Ethers.res.js → Ethers.res.mjs} +18 -17
- package/src/bindings/{Hrtime.res.js → Hrtime.res.mjs} +13 -12
- package/src/bindings/{Lodash.res.js → Lodash.res.mjs} +4 -3
- package/src/bindings/NodeJs.res +13 -1
- package/src/bindings/NodeJs.res.mjs +48 -0
- package/src/bindings/Pino.res +4 -4
- package/src/bindings/{Pino.res.js → Pino.res.mjs} +16 -15
- package/src/bindings/Postgres.res +2 -2
- package/src/bindings/{Postgres.res.js → Postgres.res.mjs} +4 -3
- package/src/bindings/{PromClient.res.js → PromClient.res.mjs} +6 -5
- package/src/bindings/{Promise.res.js → Promise.res.mjs} +6 -5
- package/src/bindings/{SDSL.res.js → SDSL.res.mjs} +3 -2
- package/src/bindings/{Viem.res.js → Viem.res.mjs} +9 -8
- package/src/bindings/vendored-lodash-fns.js +3 -35
- package/src/db/{EntityHistory.res.js → EntityHistory.res.mjs} +21 -20
- package/src/db/InternalTable.gen.ts +2 -2
- package/src/db/InternalTable.res +0 -2
- package/src/db/{InternalTable.res.js → InternalTable.res.mjs} +19 -19
- package/src/db/{Schema.res.js → Schema.res.mjs} +10 -9
- package/src/db/{Table.res.js → Table.res.mjs} +34 -33
- package/src/sources/{EventRouter.res.js → EventRouter.res.mjs} +17 -16
- package/src/sources/{Fuel.res.js → Fuel.res.mjs} +6 -5
- package/src/sources/{HyperFuel.res.js → HyperFuel.res.mjs} +14 -13
- package/src/sources/{HyperFuelClient.res.js → HyperFuelClient.res.mjs} +7 -6
- package/src/sources/{HyperFuelSource.res.js → HyperFuelSource.res.mjs} +28 -27
- package/src/sources/{HyperSync.res.js → HyperSync.res.mjs} +21 -20
- package/src/sources/HyperSyncClient.gen.ts +1 -1
- package/src/sources/HyperSyncClient.res +78 -20
- package/src/sources/{HyperSyncClient.res.js → HyperSyncClient.res.mjs} +32 -15
- package/src/sources/{HyperSyncJsonApi.res.js → HyperSyncJsonApi.res.mjs} +10 -9
- package/src/sources/HyperSyncSource.res +77 -9
- package/src/sources/{HyperSyncSource.res.js → HyperSyncSource.res.mjs} +99 -38
- package/src/sources/{Rpc.res.js → Rpc.res.mjs} +16 -15
- package/src/sources/{RpcSource.res.js → RpcSource.res.mjs} +40 -39
- package/src/sources/Source.res +1 -1
- package/src/sources/{Source.res.js → Source.res.mjs} +4 -3
- package/src/sources/SourceManager.res +12 -1
- package/src/sources/{SourceManager.res.js → SourceManager.res.mjs} +32 -21
- package/src/sources/vendored-fuel-abi-coder.js +94 -149
- package/src/vendored/{Rest.res.js → Rest.res.mjs} +12 -11
- package/src/bindings/NodeJs.res.js +0 -35
- /package/src/{Change.res.js → Change.res.mjs} +0 -0
- /package/src/{Indexer.res.js → Indexer.res.mjs} +0 -0
- /package/src/bindings/{Express.res.js → Express.res.mjs} +0 -0
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
'use strict';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
import * as Rest from "../vendored/Rest.res.mjs";
|
|
4
|
+
import * as Hrtime from "../bindings/Hrtime.res.mjs";
|
|
5
|
+
import * as Js_exn from "rescript/lib/es6/js_exn.js";
|
|
6
|
+
import * as Source from "./Source.res.mjs";
|
|
7
|
+
import * as Logging from "../Logging.res.mjs";
|
|
8
|
+
import * as $$Promise from "../bindings/Promise.res.mjs";
|
|
9
|
+
import * as HyperFuel from "./HyperFuel.res.mjs";
|
|
10
|
+
import * as HyperSync from "./HyperSync.res.mjs";
|
|
11
|
+
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
|
|
12
|
+
import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
|
|
13
|
+
import * as EventRouter from "./EventRouter.res.mjs";
|
|
14
|
+
import * as ErrorHandling from "../ErrorHandling.res.mjs";
|
|
15
|
+
import * as Caml_exceptions from "rescript/lib/es6/caml_exceptions.js";
|
|
16
|
+
import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
|
|
18
17
|
|
|
19
18
|
var EventRoutingFailed = /* @__PURE__ */Caml_exceptions.create("HyperFuelSource.EventRoutingFailed");
|
|
20
19
|
|
|
@@ -435,16 +434,18 @@ function make(param) {
|
|
|
435
434
|
};
|
|
436
435
|
}
|
|
437
436
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
437
|
+
export {
|
|
438
|
+
EventRoutingFailed ,
|
|
439
|
+
mintEventTag ,
|
|
440
|
+
burnEventTag ,
|
|
441
|
+
transferEventTag ,
|
|
442
|
+
callEventTag ,
|
|
443
|
+
logDataReceiptTypeSelection ,
|
|
444
|
+
txStatusSelection ,
|
|
445
|
+
makeGetNormalRecieptsSelection ,
|
|
446
|
+
makeWildcardRecieptsSelection ,
|
|
447
|
+
getSelectionConfig ,
|
|
448
|
+
memoGetSelectionConfig ,
|
|
449
|
+
make ,
|
|
450
|
+
}
|
|
450
451
|
/* Rest Not a pure module */
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
'use strict';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
import * as Rest from "../vendored/Rest.res.mjs";
|
|
4
|
+
import * as Time from "../Time.res.mjs";
|
|
5
|
+
import * as Utils from "../Utils.res.mjs";
|
|
6
|
+
import * as $$BigInt from "../bindings/BigInt.res.mjs";
|
|
7
|
+
import * as Js_exn from "rescript/lib/es6/js_exn.js";
|
|
8
|
+
import * as Logging from "../Logging.res.mjs";
|
|
9
|
+
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
|
|
10
|
+
import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
|
|
11
|
+
import * as Belt_Result from "rescript/lib/es6/belt_Result.js";
|
|
12
|
+
import * as Caml_option from "rescript/lib/es6/caml_option.js";
|
|
13
|
+
import * as Caml_exceptions from "rescript/lib/es6/caml_exceptions.js";
|
|
14
|
+
import * as HyperSyncClient from "./HyperSyncClient.res.mjs";
|
|
15
|
+
import * as HyperSyncJsonApi from "./HyperSyncJsonApi.res.mjs";
|
|
17
16
|
|
|
18
17
|
var fieldNames = [
|
|
19
18
|
"address",
|
|
@@ -325,10 +324,12 @@ var GetLogs = {
|
|
|
325
324
|
query: query
|
|
326
325
|
};
|
|
327
326
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
327
|
+
export {
|
|
328
|
+
Log ,
|
|
329
|
+
queryErrorToMsq ,
|
|
330
|
+
GetLogs ,
|
|
331
|
+
queryBlockData$1 as queryBlockData,
|
|
332
|
+
queryBlockDataMulti ,
|
|
333
|
+
mapExn ,
|
|
334
|
+
}
|
|
334
335
|
/* Rest Not a pure module */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
/* tslint:disable */
|
|
5
5
|
|
|
6
|
-
import type {t as Address_t} from '../../src/Address.gen';
|
|
6
|
+
import type {t as Address_t} from '../../src/Address.gen.js';
|
|
7
7
|
|
|
8
8
|
export type ResponseTypes_accessList = { readonly address?: Address_t; readonly storageKeys?: string[] };
|
|
9
9
|
|
|
@@ -1,12 +1,33 @@
|
|
|
1
|
+
/** Determines query serialization format for HTTP requests. */
|
|
2
|
+
type serializationFormat =
|
|
3
|
+
// Use JSON serialization (default)
|
|
4
|
+
| Json
|
|
5
|
+
// Use Cap'n Proto binary serialization
|
|
6
|
+
| CapnProto
|
|
7
|
+
|
|
8
|
+
let serializationFormatSchema = S.enum([Json, CapnProto])
|
|
9
|
+
|
|
1
10
|
type cfg = {
|
|
2
|
-
|
|
3
|
-
|
|
11
|
+
/** HyperSync server URL. */
|
|
12
|
+
url: string,
|
|
13
|
+
/** HyperSync server api token. */
|
|
14
|
+
apiToken: string,
|
|
15
|
+
/** Milliseconds to wait for a response before timing out. Default: 30000. */
|
|
4
16
|
httpReqTimeoutMillis?: int,
|
|
17
|
+
/** Number of retries to attempt before returning error. Default: 12. */
|
|
5
18
|
maxNumRetries?: int,
|
|
19
|
+
/** Milliseconds that would be used for retry backoff increasing. Default: 500. */
|
|
6
20
|
retryBackoffMs?: int,
|
|
21
|
+
/** Initial wait time for request backoff. Default: 200. */
|
|
7
22
|
retryBaseMs?: int,
|
|
23
|
+
/** Ceiling time for request backoff. Default: 5000. */
|
|
8
24
|
retryCeilingMs?: int,
|
|
25
|
+
/** Enable checksum addresses in responses. */
|
|
9
26
|
enableChecksumAddresses?: bool,
|
|
27
|
+
/** Query serialization format to use for HTTP requests. Default: Json. */
|
|
28
|
+
serializationFormat?: serializationFormat,
|
|
29
|
+
/** Whether to use query caching when using CapnProto serialization format. */
|
|
30
|
+
enableQueryCaching?: bool,
|
|
10
31
|
}
|
|
11
32
|
|
|
12
33
|
module QueryTypes = {
|
|
@@ -67,7 +88,7 @@ module QueryTypes = {
|
|
|
67
88
|
| GasUsed
|
|
68
89
|
| ContractAddress
|
|
69
90
|
| LogsBloom
|
|
70
|
-
|
|
|
91
|
+
| Type
|
|
71
92
|
| Root
|
|
72
93
|
| Status
|
|
73
94
|
| L1Fee
|
|
@@ -111,7 +132,7 @@ module QueryTypes = {
|
|
|
111
132
|
| TraceAddress
|
|
112
133
|
| TransactionHash
|
|
113
134
|
| TransactionPosition
|
|
114
|
-
|
|
|
135
|
+
| Type
|
|
115
136
|
| Error
|
|
116
137
|
|
|
117
138
|
type fieldSelection = {
|
|
@@ -133,7 +154,7 @@ module QueryTypes = {
|
|
|
133
154
|
topic3,
|
|
134
155
|
)
|
|
135
156
|
|
|
136
|
-
type
|
|
157
|
+
type logFilter = {
|
|
137
158
|
/**
|
|
138
159
|
* Address of the contract, any logs that has any of these addresses will be returned.
|
|
139
160
|
* Empty means match all.
|
|
@@ -148,7 +169,7 @@ module QueryTypes = {
|
|
|
148
169
|
|
|
149
170
|
let makeLogSelection = (~address, ~topics) => {address, topics}
|
|
150
171
|
|
|
151
|
-
type
|
|
172
|
+
type transactionFilter = {
|
|
152
173
|
/**
|
|
153
174
|
* Address the transaction should originate from. If transaction.from matches any of these, the transaction
|
|
154
175
|
* will be returned. Keep in mind that this has an and relationship with to filter, so each transaction should
|
|
@@ -167,7 +188,8 @@ module QueryTypes = {
|
|
|
167
188
|
/** If tx.status matches this it will be returned. */
|
|
168
189
|
status?: int,
|
|
169
190
|
/** If transaction.type matches any of these values, the transaction will be returned */
|
|
170
|
-
|
|
191
|
+
@as("type")
|
|
192
|
+
type_?: array<int>,
|
|
171
193
|
contractAddress?: array<Address.t>,
|
|
172
194
|
}
|
|
173
195
|
|
|
@@ -177,7 +199,8 @@ module QueryTypes = {
|
|
|
177
199
|
address?: array<Address.t>,
|
|
178
200
|
callType?: array<string>,
|
|
179
201
|
rewardType?: array<string>,
|
|
180
|
-
|
|
202
|
+
@as("type")
|
|
203
|
+
type_?: array<string>,
|
|
181
204
|
sighash?: array<string>,
|
|
182
205
|
}
|
|
183
206
|
|
|
@@ -214,12 +237,12 @@ module QueryTypes = {
|
|
|
214
237
|
* List of log selections, these have an or relationship between them, so the query will return logs
|
|
215
238
|
* that match any of these selections.
|
|
216
239
|
*/
|
|
217
|
-
logs?: array<
|
|
240
|
+
logs?: array<logFilter>,
|
|
218
241
|
/**
|
|
219
242
|
* List of transaction selections, the query will return transactions that match any of these selections and
|
|
220
243
|
* it will return transactions that are related to the returned logs.
|
|
221
244
|
*/
|
|
222
|
-
transactions?: array<
|
|
245
|
+
transactions?: array<transactionFilter>,
|
|
223
246
|
/**
|
|
224
247
|
* List of trace selections, the query will return traces that match any of these selections and
|
|
225
248
|
* it will re turn traces that are related to the returned logs.
|
|
@@ -360,7 +383,8 @@ module ResponseTypes = {
|
|
|
360
383
|
gasUsed?: bigint,
|
|
361
384
|
contractAddress?: string,
|
|
362
385
|
logsBloom?: string,
|
|
363
|
-
|
|
386
|
+
@as("type")
|
|
387
|
+
type_?: int,
|
|
364
388
|
root?: string,
|
|
365
389
|
status?: int,
|
|
366
390
|
l1Fee?: bigint,
|
|
@@ -436,6 +460,22 @@ type streamConfig
|
|
|
436
460
|
type queryResponse
|
|
437
461
|
type queryResponseStream
|
|
438
462
|
type eventStream
|
|
463
|
+
|
|
464
|
+
@tag("type")
|
|
465
|
+
type heightStreamEvent =
|
|
466
|
+
| Height({height: int})
|
|
467
|
+
| Connected
|
|
468
|
+
| Reconnecting({delayMillis: int, errorMsg: string})
|
|
469
|
+
|
|
470
|
+
module HeightStream = {
|
|
471
|
+
type t = {
|
|
472
|
+
/** Close the height stream */
|
|
473
|
+
close: unit => promise<unit>,
|
|
474
|
+
/** Receive the next height stream event from the stream */
|
|
475
|
+
recv: unit => promise<heightStreamEvent>,
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
439
479
|
type t = {
|
|
440
480
|
getHeight: unit => promise<int>,
|
|
441
481
|
collect: (~query: query, ~config: streamConfig) => promise<queryResponse>,
|
|
@@ -445,23 +485,41 @@ type t = {
|
|
|
445
485
|
getEvents: (~query: query) => promise<eventResponse>,
|
|
446
486
|
stream: (~query: query, ~config: streamConfig) => promise<queryResponseStream>,
|
|
447
487
|
streamEvents: (~query: query, ~config: streamConfig) => promise<eventStream>,
|
|
488
|
+
streamHeight: unit => promise<HeightStream.t>,
|
|
448
489
|
}
|
|
449
490
|
|
|
450
|
-
@module("@envio-dev/hypersync-client") @scope("HypersyncClient")
|
|
491
|
+
@module("@envio-dev/hypersync-client") @scope("HypersyncClient")
|
|
492
|
+
external makeWithAgent: (cfg, ~userAgent: string) => t = "newWithAgent"
|
|
493
|
+
|
|
451
494
|
let make = (
|
|
452
495
|
~url,
|
|
453
496
|
~apiToken,
|
|
454
497
|
~httpReqTimeoutMillis,
|
|
455
498
|
~maxNumRetries,
|
|
456
499
|
~enableChecksumAddresses=true,
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
500
|
+
~serializationFormat=?,
|
|
501
|
+
~enableQueryCaching=?,
|
|
502
|
+
~retryBaseMs=?,
|
|
503
|
+
~retryBackoffMs=?,
|
|
504
|
+
~retryCeilingMs=?,
|
|
505
|
+
) => {
|
|
506
|
+
let envioVersion = Utils.EnvioPackage.value.version
|
|
507
|
+
makeWithAgent(
|
|
508
|
+
{
|
|
509
|
+
url,
|
|
510
|
+
enableChecksumAddresses,
|
|
511
|
+
apiToken,
|
|
512
|
+
httpReqTimeoutMillis,
|
|
513
|
+
maxNumRetries,
|
|
514
|
+
?serializationFormat,
|
|
515
|
+
?enableQueryCaching,
|
|
516
|
+
?retryBaseMs,
|
|
517
|
+
?retryBackoffMs,
|
|
518
|
+
?retryCeilingMs,
|
|
519
|
+
},
|
|
520
|
+
~userAgent=`hyperindex/${envioVersion}`,
|
|
521
|
+
)
|
|
522
|
+
}
|
|
465
523
|
|
|
466
524
|
module Decoder = {
|
|
467
525
|
type rec decodedSolType<'a> = {val: 'a}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
'use strict';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import * as Utils from "../Utils.res.mjs";
|
|
4
|
+
import * as Address from "../Address.res.mjs";
|
|
5
|
+
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
|
|
6
|
+
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
7
|
+
import * as HypersyncClient from "@envio-dev/hypersync-client";
|
|
8
|
+
|
|
9
|
+
var serializationFormatSchema = S$RescriptSchema.$$enum([
|
|
10
|
+
"Json",
|
|
11
|
+
"CapnProto"
|
|
12
|
+
]);
|
|
8
13
|
|
|
9
14
|
function makeTopicSelection(topic0Opt, topic1Opt, topic2Opt, topic3Opt) {
|
|
10
15
|
var topic0 = topic0Opt !== undefined ? topic0Opt : [];
|
|
@@ -57,15 +62,23 @@ var ResponseTypes = {
|
|
|
57
62
|
authorizationListSchema: authorizationListSchema
|
|
58
63
|
};
|
|
59
64
|
|
|
60
|
-
|
|
65
|
+
var HeightStream = {};
|
|
66
|
+
|
|
67
|
+
function make(url, apiToken, httpReqTimeoutMillis, maxNumRetries, enableChecksumAddressesOpt, serializationFormat, enableQueryCaching, retryBaseMs, retryBackoffMs, retryCeilingMs) {
|
|
61
68
|
var enableChecksumAddresses = enableChecksumAddressesOpt !== undefined ? enableChecksumAddressesOpt : true;
|
|
62
|
-
|
|
69
|
+
var envioVersion = Utils.EnvioPackage.value.version;
|
|
70
|
+
return HypersyncClient.HypersyncClient.newWithAgent({
|
|
63
71
|
url: url,
|
|
64
|
-
|
|
72
|
+
apiToken: apiToken,
|
|
65
73
|
httpReqTimeoutMillis: httpReqTimeoutMillis,
|
|
66
74
|
maxNumRetries: maxNumRetries,
|
|
67
|
-
|
|
68
|
-
|
|
75
|
+
retryBackoffMs: retryBackoffMs,
|
|
76
|
+
retryBaseMs: retryBaseMs,
|
|
77
|
+
retryCeilingMs: retryCeilingMs,
|
|
78
|
+
enableChecksumAddresses: enableChecksumAddresses,
|
|
79
|
+
serializationFormat: serializationFormat,
|
|
80
|
+
enableQueryCaching: enableQueryCaching
|
|
81
|
+
}, "hyperindex/" + envioVersion);
|
|
69
82
|
}
|
|
70
83
|
|
|
71
84
|
function toUnderlying(_d) {
|
|
@@ -98,8 +111,12 @@ var Decoder = {
|
|
|
98
111
|
fromSignatures: fromSignatures
|
|
99
112
|
};
|
|
100
113
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
114
|
+
export {
|
|
115
|
+
serializationFormatSchema ,
|
|
116
|
+
QueryTypes ,
|
|
117
|
+
ResponseTypes ,
|
|
118
|
+
HeightStream ,
|
|
119
|
+
make ,
|
|
120
|
+
Decoder ,
|
|
121
|
+
}
|
|
122
|
+
/* serializationFormatSchema Not a pure module */
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
'use strict';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import * as $$BigInt from "../bindings/BigInt.res.mjs";
|
|
4
|
+
import * as Address from "../Address.res.mjs";
|
|
5
|
+
import * as EvmTypes from "../EvmTypes.res.mjs";
|
|
6
|
+
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
8
7
|
|
|
9
8
|
var blockFieldOptionsSchema = S$RescriptSchema.$$enum([
|
|
10
9
|
"number",
|
|
@@ -259,8 +258,10 @@ function heightRoute() {
|
|
|
259
258
|
};
|
|
260
259
|
}
|
|
261
260
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
261
|
+
export {
|
|
262
|
+
QueryTypes ,
|
|
263
|
+
ResponseTypes ,
|
|
264
|
+
queryRoute ,
|
|
265
|
+
heightRoute ,
|
|
266
|
+
}
|
|
266
267
|
/* blockFieldOptionsSchema Not a pure module */
|
|
@@ -155,6 +155,65 @@ type options = {
|
|
|
155
155
|
clientMaxRetries: int,
|
|
156
156
|
clientTimeoutMillis: int,
|
|
157
157
|
lowercaseAddresses: bool,
|
|
158
|
+
serializationFormat: HyperSyncClient.serializationFormat,
|
|
159
|
+
enableQueryCaching: bool,
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
module HeightState: {
|
|
163
|
+
type t
|
|
164
|
+
let make: (HyperSyncClient.t, ~chainId: int) => Promise.t<t>
|
|
165
|
+
let getHeight: t => Promise.t<int>
|
|
166
|
+
} = {
|
|
167
|
+
open HyperSyncClient
|
|
168
|
+
type t = {
|
|
169
|
+
heightStream: HeightStream.t,
|
|
170
|
+
mutable currentHeight: int,
|
|
171
|
+
mutable errMessage: option<string>,
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
let makeInternal = async (client: HyperSyncClient.t) => {
|
|
175
|
+
currentHeight: 0,
|
|
176
|
+
heightStream: await client.streamHeight(),
|
|
177
|
+
errMessage: None,
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
let start = async (state: t, ~chainId) => {
|
|
181
|
+
while true {
|
|
182
|
+
let height = await state.heightStream.recv()
|
|
183
|
+
switch height {
|
|
184
|
+
| Height({height}) => state.currentHeight = height
|
|
185
|
+
| Connected =>
|
|
186
|
+
Logging.trace({"msg": "HyperSync height stream is connected", "chainId": chainId})
|
|
187
|
+
state.errMessage = None
|
|
188
|
+
| Reconnecting({delayMillis, errorMsg}) =>
|
|
189
|
+
Logging.trace({
|
|
190
|
+
"msg": "HyperSync height stream is reconnecting",
|
|
191
|
+
"err": errorMsg,
|
|
192
|
+
"delayMillis": delayMillis,
|
|
193
|
+
"chainId": chainId,
|
|
194
|
+
})
|
|
195
|
+
state.errMessage = Some(errorMsg)
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
let make = async (client: HyperSyncClient.t, ~chainId) => {
|
|
201
|
+
let state = await makeInternal(client)
|
|
202
|
+
let _async = state->start(~chainId)
|
|
203
|
+
state
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
let getHeight = async (state: t) => {
|
|
207
|
+
while state.currentHeight == 0 && state.errMessage->Belt.Option.isNone {
|
|
208
|
+
// Just poll internally until its no longer 0
|
|
209
|
+
await Utils.delay(200)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
switch state.errMessage {
|
|
213
|
+
| Some(errMessage) => Js.Exn.raiseError(errMessage)
|
|
214
|
+
| None => state.currentHeight
|
|
215
|
+
}
|
|
216
|
+
}
|
|
158
217
|
}
|
|
159
218
|
|
|
160
219
|
let make = (
|
|
@@ -169,6 +228,8 @@ let make = (
|
|
|
169
228
|
clientMaxRetries,
|
|
170
229
|
clientTimeoutMillis,
|
|
171
230
|
lowercaseAddresses,
|
|
231
|
+
serializationFormat,
|
|
232
|
+
enableQueryCaching,
|
|
172
233
|
}: options,
|
|
173
234
|
): t => {
|
|
174
235
|
let name = "HyperSync"
|
|
@@ -183,6 +244,8 @@ let make = (
|
|
|
183
244
|
~maxNumRetries=clientMaxRetries,
|
|
184
245
|
~httpReqTimeoutMillis=clientTimeoutMillis,
|
|
185
246
|
~enableChecksumAddresses=!lowercaseAddresses,
|
|
247
|
+
~serializationFormat,
|
|
248
|
+
~enableQueryCaching,
|
|
186
249
|
)
|
|
187
250
|
|
|
188
251
|
let hscDecoder: ref<option<HyperSyncClient.Decoder.t>> = ref(None)
|
|
@@ -545,28 +608,33 @@ let make = (
|
|
|
545
608
|
~logger,
|
|
546
609
|
)->Promise.thenResolve(HyperSync.mapExn)
|
|
547
610
|
|
|
548
|
-
let jsonApiClient = Rest.client(endpointUrl)
|
|
549
|
-
|
|
550
611
|
let malformedTokenMessage = `Your token is malformed. For more info: https://docs.envio.dev/docs/HyperSync/api-tokens.`
|
|
551
612
|
|
|
613
|
+
let heightStatePromise = HeightState.make(client, ~chainId=chain->ChainMap.Chain.toChainId)
|
|
614
|
+
|
|
552
615
|
{
|
|
553
616
|
name,
|
|
554
617
|
sourceFor: Sync,
|
|
555
618
|
chain,
|
|
556
|
-
pollingInterval:
|
|
619
|
+
pollingInterval: 32, // purely internal state polling since we now stream the height to the state
|
|
557
620
|
poweredByHyperSync: true,
|
|
558
621
|
getBlockHashes,
|
|
559
|
-
getHeightOrThrow: async () =>
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
|
622
|
+
getHeightOrThrow: async () => {
|
|
623
|
+
let heightState = await heightStatePromise
|
|
624
|
+
try await heightState->HeightState.getHeight catch {
|
|
625
|
+
| Js.Exn.Error(exn)
|
|
626
|
+
if exn
|
|
627
|
+
->Js.Exn.message
|
|
628
|
+
->Option.getWithDefault("")
|
|
629
|
+
->Js.String2.includes(malformedTokenMessage) =>
|
|
563
630
|
Logging.error(`Your ENVIO_API_TOKEN is malformed. The indexer will not be able to fetch events. Update the token and restart the indexer using 'pnpm envio start'. For more info: https://docs.envio.dev/docs/HyperSync/api-tokens`)
|
|
564
631
|
// Don't want to retry if the token is malformed
|
|
565
632
|
// So just block forever
|
|
566
633
|
let _ = await Promise.make((_, _) => ())
|
|
567
634
|
0
|
|
568
|
-
|
|
|
569
|
-
}
|
|
635
|
+
| exn => raise(exn)
|
|
636
|
+
}
|
|
637
|
+
},
|
|
570
638
|
getItemsOrThrow,
|
|
571
639
|
}
|
|
572
640
|
}
|