envio 3.0.0-alpha.21 → 3.0.0-alpha.22
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.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 +428 -51
- package/src/Main.res.mjs +528 -271
- package/src/Persistence.res +77 -84
- package/src/Persistence.res.mjs +131 -132
- package/src/PgStorage.res +291 -167
- package/src/PgStorage.res.mjs +797 -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 +15 -16
- package/src/TestIndexerProxyStorage.res.mjs +98 -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 +2 -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
package/src/Internal.res
CHANGED
|
@@ -244,17 +244,16 @@ type evmTransactionInput = {
|
|
|
244
244
|
type_?: int,
|
|
245
245
|
root?: string,
|
|
246
246
|
status?: int,
|
|
247
|
-
accessList?:
|
|
247
|
+
accessList?: JSON.t,
|
|
248
248
|
// L2 specific fields (Optimism, Arbitrum, etc.)
|
|
249
249
|
l1Fee?: bigint,
|
|
250
250
|
l1GasPrice?: bigint,
|
|
251
251
|
l1GasUsed?: bigint,
|
|
252
252
|
l1FeeScalar?: float,
|
|
253
253
|
gasUsedForL1?: bigint,
|
|
254
|
-
authorizationList?:
|
|
254
|
+
authorizationList?: JSON.t,
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
@genType
|
|
258
257
|
type genericEvent<'params, 'block, 'transaction> = {
|
|
259
258
|
contractName: string,
|
|
260
259
|
eventName: string,
|
|
@@ -270,35 +269,28 @@ type event = genericEvent<eventParams, eventBlock, eventTransaction>
|
|
|
270
269
|
|
|
271
270
|
external fromGenericEvent: genericEvent<'a, 'b, 'c> => event = "%identity"
|
|
272
271
|
|
|
273
|
-
@genType
|
|
274
272
|
type genericLoaderArgs<'event, 'context> = {
|
|
275
273
|
event: 'event,
|
|
276
274
|
context: 'context,
|
|
277
275
|
}
|
|
278
|
-
@genType
|
|
279
276
|
type genericLoader<'args, 'loaderReturn> = 'args => promise<'loaderReturn>
|
|
280
277
|
|
|
281
|
-
@genType
|
|
282
278
|
type genericContractRegisterArgs<'event, 'context> = {
|
|
283
279
|
event: 'event,
|
|
284
280
|
context: 'context,
|
|
285
281
|
}
|
|
286
|
-
@genType.import(("./Types.ts", "GenericContractRegister"))
|
|
287
282
|
type genericContractRegister<'args> = 'args => promise<unit>
|
|
288
283
|
|
|
289
284
|
type contractRegisterContext
|
|
290
285
|
type contractRegisterArgs = genericContractRegisterArgs<event, contractRegisterContext>
|
|
291
286
|
type contractRegister = genericContractRegister<contractRegisterArgs>
|
|
292
287
|
|
|
293
|
-
@genType
|
|
294
288
|
type genericHandlerArgs<'event, 'context> = {
|
|
295
289
|
event: 'event,
|
|
296
290
|
context: 'context,
|
|
297
291
|
}
|
|
298
|
-
@genType
|
|
299
292
|
type genericHandler<'args> = 'args => promise<unit>
|
|
300
293
|
|
|
301
|
-
@genType
|
|
302
294
|
type entityHandlerContext<'entity> = {
|
|
303
295
|
get: string => promise<option<'entity>>,
|
|
304
296
|
getOrThrow: (string, ~message: string=?) => promise<'entity>,
|
|
@@ -327,12 +319,28 @@ type handlerArgs = {
|
|
|
327
319
|
}
|
|
328
320
|
type handler = genericHandler<handlerArgs>
|
|
329
321
|
|
|
330
|
-
|
|
331
|
-
type genericHandlerWithLoader<'loader, 'handler, 'eventFilters> = {
|
|
322
|
+
type genericHandlerWithLoader<'loader, 'handler, 'where> = {
|
|
332
323
|
loader: 'loader,
|
|
333
324
|
handler: 'handler,
|
|
334
325
|
wildcard?: bool,
|
|
335
|
-
|
|
326
|
+
where?: 'where,
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Recursive tuple/struct component metadata emitted by the CLI when an event
|
|
330
|
+
// param (or any nested field) is a Solidity struct. `name` is always non-empty —
|
|
331
|
+
// the CLI fills in `"0"`, `"1"`, ... for anonymous components in mixed-name
|
|
332
|
+
// tuples — so the runtime can always rebuild a keyed object.
|
|
333
|
+
type rec eventParamComponent = {
|
|
334
|
+
name: string,
|
|
335
|
+
abiType: string,
|
|
336
|
+
components?: array<eventParamComponent>,
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
type eventParam = {
|
|
340
|
+
name: string,
|
|
341
|
+
abiType: string,
|
|
342
|
+
indexed: bool,
|
|
343
|
+
components?: array<eventParamComponent>,
|
|
336
344
|
}
|
|
337
345
|
|
|
338
346
|
// This is private so it's not manually constructed internally
|
|
@@ -353,6 +361,7 @@ type eventConfig = private {
|
|
|
353
361
|
contractRegister: option<contractRegister>,
|
|
354
362
|
paramsRawEventSchema: S.schema<eventParams>,
|
|
355
363
|
simulateParamsSchema: S.schema<eventParams>,
|
|
364
|
+
startBlock: option<int>,
|
|
356
365
|
}
|
|
357
366
|
|
|
358
367
|
type fuelEventKind =
|
|
@@ -361,7 +370,6 @@ type fuelEventKind =
|
|
|
361
370
|
| Burn
|
|
362
371
|
| Transfer
|
|
363
372
|
| Call
|
|
364
|
-
@genType.opaque
|
|
365
373
|
type fuelEventConfig = {
|
|
366
374
|
...eventConfig,
|
|
367
375
|
kind: fuelEventKind,
|
|
@@ -378,36 +386,51 @@ type topicSelection = {
|
|
|
378
386
|
topic3: array<EvmTypes.Hex.t>,
|
|
379
387
|
}
|
|
380
388
|
|
|
381
|
-
|
|
389
|
+
// Per-event, per-invocation arguments passed to a `where` callback. The
|
|
390
|
+
// concrete `chain` shape (which contract key it exposes) is generated per
|
|
391
|
+
// event in user-project codegen — here it's an open record so codegen'd
|
|
392
|
+
// types subtype-coerce into it cleanly.
|
|
393
|
+
type onEventWhereArgs<'chain> = {chain: 'chain}
|
|
382
394
|
|
|
383
395
|
type eventFilters =
|
|
384
396
|
Static(array<topicSelection>) | Dynamic(array<Address.t> => array<topicSelection>)
|
|
385
397
|
|
|
386
|
-
@genType.opaque
|
|
387
398
|
type evmEventConfig = {
|
|
388
399
|
...eventConfig,
|
|
389
400
|
getEventFiltersOrThrow: ChainMap.Chain.t => eventFilters,
|
|
390
401
|
convertHyperSyncEventArgs: HyperSyncClient.Decoder.decodedEvent => eventParams,
|
|
391
402
|
selectedBlockFields: Utils.Set.t<evmBlockField>,
|
|
392
403
|
selectedTransactionFields: Utils.Set.t<evmTransactionField>,
|
|
404
|
+
// Retained so `HandlerLoader.applyRegistrations` can re-run
|
|
405
|
+
// `LogSelection.parseEventFiltersOrThrow` after handler modules register
|
|
406
|
+
// with a `where:` filter. Only indexed params are kept — they're all the
|
|
407
|
+
// filter parser needs for topic-getter construction + key validation.
|
|
408
|
+
sighash: string,
|
|
409
|
+
indexedParams: array<eventParam>,
|
|
393
410
|
}
|
|
411
|
+
|
|
412
|
+
// Shared formula for `eventConfig.dependsOnAddresses`. Kept here so
|
|
413
|
+
// `EventConfigBuilder.build{Evm,Fuel}EventConfig` and
|
|
414
|
+
// `HandlerLoader.applyRegistrations` stay in sync when handler state flips
|
|
415
|
+
// the value. Fuel events always have `filterByAddresses=false`, so callers
|
|
416
|
+
// there simply pass it through as `false`.
|
|
417
|
+
let dependsOnAddresses = (~isWildcard, ~filterByAddresses) => !isWildcard || filterByAddresses
|
|
418
|
+
|
|
394
419
|
type evmContractConfig = {
|
|
395
420
|
name: string,
|
|
396
421
|
abi: EvmTypes.Abi.t,
|
|
397
422
|
events: array<evmEventConfig>,
|
|
398
423
|
}
|
|
399
424
|
|
|
400
|
-
type
|
|
425
|
+
type indexingAddress = {
|
|
401
426
|
address: Address.t,
|
|
402
427
|
contractName: string,
|
|
403
|
-
|
|
404
|
-
//
|
|
405
|
-
|
|
406
|
-
// and shouldn't be rolled back
|
|
407
|
-
registrationBlock: option<int>,
|
|
428
|
+
// Needed for rollback.
|
|
429
|
+
// -1 for config addresses that shouldn't be rolled back.
|
|
430
|
+
registrationBlock: int,
|
|
408
431
|
}
|
|
409
432
|
|
|
410
|
-
type dcs = array<
|
|
433
|
+
type dcs = array<indexingAddress>
|
|
411
434
|
|
|
412
435
|
// Duplicate the type from item
|
|
413
436
|
// to make item properly unboxed
|
|
@@ -473,22 +496,19 @@ external getItemDcs: item => option<dcs> = "dcs"
|
|
|
473
496
|
@set
|
|
474
497
|
external setItemDcs: (item, dcs) => unit = "dcs"
|
|
475
498
|
|
|
476
|
-
|
|
477
|
-
type eventOptions<'eventFilters> = {
|
|
499
|
+
type eventOptions<'where> = {
|
|
478
500
|
wildcard?: bool,
|
|
479
|
-
|
|
501
|
+
where?: 'where,
|
|
480
502
|
}
|
|
481
503
|
|
|
482
|
-
@genType
|
|
483
504
|
type fuelSupplyParams = {
|
|
484
505
|
subId: string,
|
|
485
506
|
amount: bigint,
|
|
486
507
|
}
|
|
487
508
|
let fuelSupplyParamsSchema = S.schema(s => {
|
|
488
509
|
subId: s.matches(S.string),
|
|
489
|
-
amount: s.matches(BigInt.schema),
|
|
510
|
+
amount: s.matches(Utils.BigInt.schema),
|
|
490
511
|
})
|
|
491
|
-
@genType
|
|
492
512
|
type fuelTransferParams = {
|
|
493
513
|
to: Address.t,
|
|
494
514
|
assetId: string,
|
|
@@ -497,7 +517,7 @@ type fuelTransferParams = {
|
|
|
497
517
|
let fuelTransferParamsSchema = S.schema(s => {
|
|
498
518
|
to: s.matches(Address.schema),
|
|
499
519
|
assetId: s.matches(S.string),
|
|
500
|
-
amount: s.matches(BigInt.schema),
|
|
520
|
+
amount: s.matches(Utils.BigInt.schema),
|
|
501
521
|
})
|
|
502
522
|
|
|
503
523
|
type multichain = | @as("ordered") Ordered | @as("unordered") Unordered
|
|
@@ -548,7 +568,7 @@ type effect = {
|
|
|
548
568
|
rateLimit: option<rateLimitState>,
|
|
549
569
|
}
|
|
550
570
|
let cacheTablePrefix = "envio_effect_"
|
|
551
|
-
let cacheOutputSchema = S.json(~validate=false)->(Utils.magic: S.t<
|
|
571
|
+
let cacheOutputSchema = S.json(~validate=false)->(Utils.magic: S.t<JSON.t> => S.t<effectOutput>)
|
|
552
572
|
let effectCacheItemRowsSchema = S.array(
|
|
553
573
|
S.schema(s => {id: s.matches(S.string), output: s.matches(cacheOutputSchema)}),
|
|
554
574
|
)
|
|
@@ -562,8 +582,7 @@ let makeCacheTable = (~effectName) => {
|
|
|
562
582
|
)
|
|
563
583
|
}
|
|
564
584
|
|
|
565
|
-
|
|
566
|
-
type noEventFilters
|
|
585
|
+
type noOnEventWhere
|
|
567
586
|
|
|
568
587
|
type checkpointId = bigint
|
|
569
588
|
|
package/src/Internal.res.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
3
|
import * as Table from "./db/Table.res.mjs";
|
|
4
|
-
import * as
|
|
4
|
+
import * as Utils from "./Utils.res.mjs";
|
|
5
5
|
import * as Address from "./Address.res.mjs";
|
|
6
6
|
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
let allEvmBlockFields = [
|
|
9
9
|
"number",
|
|
10
10
|
"timestamp",
|
|
11
11
|
"hash",
|
|
@@ -35,9 +35,9 @@ var allEvmBlockFields = [
|
|
|
35
35
|
"mixHash"
|
|
36
36
|
];
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
let evmBlockFieldSchema = S$RescriptSchema.$$enum(allEvmBlockFields);
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
let allEvmTransactionFields = [
|
|
41
41
|
"transactionIndex",
|
|
42
42
|
"hash",
|
|
43
43
|
"from",
|
|
@@ -72,46 +72,54 @@ var allEvmTransactionFields = [
|
|
|
72
72
|
"authorizationList"
|
|
73
73
|
];
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
75
|
+
let evmTransactionFieldSchema = S$RescriptSchema.$$enum(allEvmTransactionFields);
|
|
76
|
+
|
|
77
|
+
let evmNullableBlockFields = new Set([
|
|
78
|
+
"nonce",
|
|
79
|
+
"difficulty",
|
|
80
|
+
"totalDifficulty",
|
|
81
|
+
"uncles",
|
|
82
|
+
"baseFeePerGas",
|
|
83
|
+
"blobGasUsed",
|
|
84
|
+
"excessBlobGas",
|
|
85
|
+
"parentBeaconBlockRoot",
|
|
86
|
+
"withdrawalsRoot",
|
|
87
|
+
"l1BlockNumber",
|
|
88
|
+
"sendCount",
|
|
89
|
+
"sendRoot",
|
|
90
|
+
"mixHash"
|
|
91
|
+
]);
|
|
92
|
+
|
|
93
|
+
let evmNullableTransactionFields = new Set([
|
|
94
|
+
"gasPrice",
|
|
95
|
+
"v",
|
|
96
|
+
"r",
|
|
97
|
+
"s",
|
|
98
|
+
"yParity",
|
|
99
|
+
"maxPriorityFeePerGas",
|
|
100
|
+
"maxFeePerGas",
|
|
101
|
+
"maxFeePerBlobGas",
|
|
102
|
+
"blobVersionedHashes",
|
|
103
|
+
"contractAddress",
|
|
104
|
+
"root",
|
|
105
|
+
"status",
|
|
106
|
+
"l1Fee",
|
|
107
|
+
"l1GasPrice",
|
|
108
|
+
"l1GasUsed",
|
|
109
|
+
"l1FeeScalar",
|
|
110
|
+
"gasUsedForL1",
|
|
111
|
+
"from",
|
|
112
|
+
"to",
|
|
113
|
+
"type"
|
|
114
|
+
]);
|
|
115
|
+
|
|
116
|
+
function dependsOnAddresses(isWildcard, filterByAddresses) {
|
|
117
|
+
if (isWildcard) {
|
|
118
|
+
return filterByAddresses;
|
|
119
|
+
} else {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
115
123
|
|
|
116
124
|
function getItemChainId(item) {
|
|
117
125
|
if (item.kind === 0) {
|
|
@@ -121,52 +129,47 @@ function getItemChainId(item) {
|
|
|
121
129
|
}
|
|
122
130
|
}
|
|
123
131
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
};
|
|
129
|
-
});
|
|
132
|
+
let fuelSupplyParamsSchema = S$RescriptSchema.schema(s => ({
|
|
133
|
+
subId: s.m(S$RescriptSchema.string),
|
|
134
|
+
amount: s.m(Utils.$$BigInt.schema)
|
|
135
|
+
}));
|
|
130
136
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
};
|
|
137
|
-
});
|
|
137
|
+
let fuelTransferParamsSchema = S$RescriptSchema.schema(s => ({
|
|
138
|
+
to: s.m(Address.schema),
|
|
139
|
+
assetId: s.m(S$RescriptSchema.string),
|
|
140
|
+
amount: s.m(Utils.$$BigInt.schema)
|
|
141
|
+
}));
|
|
138
142
|
|
|
139
|
-
|
|
143
|
+
let cacheTablePrefix = "envio_effect_";
|
|
140
144
|
|
|
141
|
-
|
|
145
|
+
let cacheOutputSchema = S$RescriptSchema.json(false);
|
|
142
146
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
};
|
|
148
|
-
}));
|
|
147
|
+
let effectCacheItemRowsSchema = S$RescriptSchema.array(S$RescriptSchema.schema(s => ({
|
|
148
|
+
id: s.m(S$RescriptSchema.string),
|
|
149
|
+
output: s.m(cacheOutputSchema)
|
|
150
|
+
})));
|
|
149
151
|
|
|
150
152
|
function makeCacheTable(effectName) {
|
|
151
153
|
return Table.mkTable(cacheTablePrefix + effectName, undefined, [
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
Table.mkField("id", "String", S$RescriptSchema.string, undefined, undefined, undefined, true, undefined, undefined),
|
|
155
|
+
Table.mkField("output", "Json", cacheOutputSchema, undefined, undefined, true, undefined, undefined, undefined)
|
|
156
|
+
]);
|
|
155
157
|
}
|
|
156
158
|
|
|
157
159
|
export {
|
|
158
|
-
allEvmBlockFields
|
|
159
|
-
evmBlockFieldSchema
|
|
160
|
-
allEvmTransactionFields
|
|
161
|
-
evmTransactionFieldSchema
|
|
162
|
-
evmNullableBlockFields
|
|
163
|
-
evmNullableTransactionFields
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
160
|
+
allEvmBlockFields,
|
|
161
|
+
evmBlockFieldSchema,
|
|
162
|
+
allEvmTransactionFields,
|
|
163
|
+
evmTransactionFieldSchema,
|
|
164
|
+
evmNullableBlockFields,
|
|
165
|
+
evmNullableTransactionFields,
|
|
166
|
+
dependsOnAddresses,
|
|
167
|
+
getItemChainId,
|
|
168
|
+
fuelSupplyParamsSchema,
|
|
169
|
+
fuelTransferParamsSchema,
|
|
170
|
+
cacheTablePrefix,
|
|
171
|
+
cacheOutputSchema,
|
|
172
|
+
effectCacheItemRowsSchema,
|
|
173
|
+
makeCacheTable,
|
|
171
174
|
}
|
|
172
175
|
/* evmBlockFieldSchema Not a pure module */
|
package/src/LazyLoader.res.mjs
CHANGED
|
@@ -2,31 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
import * as Utils from "./Utils.res.mjs";
|
|
4
4
|
import * as JsSdsl from "js-sdsl";
|
|
5
|
-
import * as Belt_Option from "rescript/lib/es6/
|
|
6
|
-
import * as
|
|
7
|
-
import * as
|
|
8
|
-
import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
|
|
5
|
+
import * as Belt_Option from "@rescript/runtime/lib/es6/Belt_Option.js";
|
|
6
|
+
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
7
|
+
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
let LoaderTimeout = /* @__PURE__ */Primitive_exceptions.create("LazyLoader.LoaderTimeout");
|
|
11
10
|
|
|
12
11
|
function make(loaderFn, onError, cacheSizeOpt, loaderPoolSizeOpt, retryDelayMillisOpt, timeoutMillisOpt) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
let cacheSize = cacheSizeOpt !== undefined ? cacheSizeOpt : 10000;
|
|
13
|
+
let loaderPoolSize = loaderPoolSizeOpt !== undefined ? loaderPoolSizeOpt : 10;
|
|
14
|
+
let retryDelayMillis = retryDelayMillisOpt !== undefined ? retryDelayMillisOpt : 5000;
|
|
15
|
+
let timeoutMillis = timeoutMillisOpt !== undefined ? timeoutMillisOpt : 300000;
|
|
17
16
|
return {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
_cacheSize: cacheSize,
|
|
18
|
+
_loaderPoolSize: loaderPoolSize,
|
|
19
|
+
_retryDelayMillis: retryDelayMillis,
|
|
20
|
+
_timeoutMillis: timeoutMillis,
|
|
21
|
+
externalPromises: new Map(),
|
|
22
|
+
resolvers: new Map(),
|
|
23
|
+
inProgress: new Set(),
|
|
24
|
+
loaderQueue: new JsSdsl.Queue(),
|
|
25
|
+
loadedKeys: new JsSdsl.Queue(),
|
|
26
|
+
loaderFn: loaderFn,
|
|
27
|
+
onError: onError
|
|
28
|
+
};
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
function deleteKey(_obj, _k) {
|
|
@@ -34,50 +33,45 @@ function deleteKey(_obj, _k) {
|
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
function timeoutAfter(timeoutMillis) {
|
|
37
|
-
return Utils.delay(timeoutMillis).then(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
});
|
|
36
|
+
return Utils.delay(timeoutMillis).then(() => Promise.reject({
|
|
37
|
+
RE_EXN_ID: LoaderTimeout,
|
|
38
|
+
_1: `Query took longer than ` + String(timeoutMillis / 1000 | 0) + ` seconds`
|
|
39
|
+
}));
|
|
43
40
|
}
|
|
44
41
|
|
|
45
42
|
async function loadNext(am, k) {
|
|
46
43
|
am.inProgress.add(k);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
Belt_Option.forEach(am.resolvers.get(k),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
let awaitTaskPromiseAndLoadNextWithTimeout = async () => {
|
|
45
|
+
let val = await Promise.race([
|
|
46
|
+
am.loaderFn(k),
|
|
47
|
+
timeoutAfter(am._timeoutMillis)
|
|
48
|
+
]);
|
|
49
|
+
Belt_Option.forEach(am.resolvers.get(k), r => {
|
|
50
|
+
am.resolvers.delete(k);
|
|
51
|
+
r(val);
|
|
52
|
+
});
|
|
56
53
|
am.inProgress.delete(k);
|
|
57
|
-
|
|
54
|
+
let loadedKeysNumber = am.loadedKeys.push(k);
|
|
58
55
|
if (loadedKeysNumber > am._cacheSize) {
|
|
59
|
-
|
|
56
|
+
let old = am.loadedKeys.pop();
|
|
60
57
|
if (old !== undefined) {
|
|
61
|
-
am.externalPromises.delete(
|
|
58
|
+
am.externalPromises.delete(Primitive_option.valFromOption(old));
|
|
62
59
|
}
|
|
63
|
-
|
|
64
60
|
}
|
|
65
|
-
|
|
61
|
+
let next = am.loaderQueue.pop();
|
|
66
62
|
if (next !== undefined) {
|
|
67
|
-
return await loadNext(am,
|
|
63
|
+
return await loadNext(am, Primitive_option.valFromOption(next));
|
|
68
64
|
}
|
|
69
|
-
|
|
70
65
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
let tmp;
|
|
67
|
+
let exit = 0;
|
|
68
|
+
let val;
|
|
74
69
|
try {
|
|
75
70
|
val = await awaitTaskPromiseAndLoadNextWithTimeout();
|
|
76
71
|
exit = 1;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var onError = am.onError;
|
|
72
|
+
} catch (raw_err) {
|
|
73
|
+
let err = Primitive_exceptions.internalToException(raw_err);
|
|
74
|
+
let onError = am.onError;
|
|
81
75
|
if (onError !== undefined) {
|
|
82
76
|
onError(am, err);
|
|
83
77
|
}
|
|
@@ -91,13 +85,13 @@ async function loadNext(am, k) {
|
|
|
91
85
|
}
|
|
92
86
|
|
|
93
87
|
function get(am, k) {
|
|
94
|
-
|
|
88
|
+
let x = am.externalPromises.get(k);
|
|
95
89
|
if (x !== undefined) {
|
|
96
|
-
return
|
|
90
|
+
return x;
|
|
97
91
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
92
|
+
let promise = new Promise((resolve, param) => {
|
|
93
|
+
am.resolvers.set(k, resolve);
|
|
94
|
+
});
|
|
101
95
|
am.externalPromises.set(k, promise);
|
|
102
96
|
if (am.inProgress.size < am._loaderPoolSize) {
|
|
103
97
|
loadNext(am, k);
|
|
@@ -108,11 +102,11 @@ function get(am, k) {
|
|
|
108
102
|
}
|
|
109
103
|
|
|
110
104
|
export {
|
|
111
|
-
LoaderTimeout
|
|
112
|
-
make
|
|
113
|
-
deleteKey
|
|
114
|
-
timeoutAfter
|
|
115
|
-
loadNext
|
|
116
|
-
get
|
|
105
|
+
LoaderTimeout,
|
|
106
|
+
make,
|
|
107
|
+
deleteKey,
|
|
108
|
+
timeoutAfter,
|
|
109
|
+
loadNext,
|
|
110
|
+
get,
|
|
117
111
|
}
|
|
118
112
|
/* Utils Not a pure module */
|