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/LazyLoader.res.mjs
CHANGED
|
@@ -39,6 +39,17 @@ function timeoutAfter(timeoutMillis) {
|
|
|
39
39
|
}));
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
function rememberLoaded(am, k) {
|
|
43
|
+
if (am.loadedKeys.push(k) <= am._cacheSize) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
let old = am.loadedKeys.pop();
|
|
47
|
+
if (old !== undefined) {
|
|
48
|
+
am.externalPromises.delete(Primitive_option.valFromOption(old));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
42
53
|
async function loadNext(am, k) {
|
|
43
54
|
am.inProgress.add(k);
|
|
44
55
|
let awaitTaskPromiseAndLoadNextWithTimeout = async () => {
|
|
@@ -51,13 +62,7 @@ async function loadNext(am, k) {
|
|
|
51
62
|
r(val);
|
|
52
63
|
});
|
|
53
64
|
am.inProgress.delete(k);
|
|
54
|
-
|
|
55
|
-
if (loadedKeysNumber > am._cacheSize) {
|
|
56
|
-
let old = am.loadedKeys.pop();
|
|
57
|
-
if (old !== undefined) {
|
|
58
|
-
am.externalPromises.delete(Primitive_option.valFromOption(old));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
65
|
+
rememberLoaded(am, k);
|
|
61
66
|
let next = am.loaderQueue.pop();
|
|
62
67
|
if (next !== undefined) {
|
|
63
68
|
return await loadNext(am, Primitive_option.valFromOption(next));
|
|
@@ -106,6 +111,7 @@ export {
|
|
|
106
111
|
make,
|
|
107
112
|
deleteKey,
|
|
108
113
|
timeoutAfter,
|
|
114
|
+
rememberLoaded,
|
|
109
115
|
loadNext,
|
|
110
116
|
get,
|
|
111
117
|
}
|
package/src/Main.res
CHANGED
|
@@ -229,8 +229,8 @@ let buildChainsObject = (~config: Config.t) => {
|
|
|
229
229
|
let getGlobalIndexer = (): 'indexer => {
|
|
230
230
|
// Parse eventIdentity config to extract contractName, eventName, and options.
|
|
231
231
|
// Supports two runtime formats:
|
|
232
|
-
// - From TypeScript: { contract: "X", event: "Y", wildcard?, where? }
|
|
233
|
-
// - From ReScript GADT: { event: { contract: "X", _0: "Y" }, wildcard?, where? }
|
|
232
|
+
// - From TypeScript: { contract: "X", event: "Y", wildcard?, where?, fields? }
|
|
233
|
+
// - From ReScript GADT: { event: { contract: "X", _0: "Y" }, wildcard?, where?, fields? }
|
|
234
234
|
let parseIdentityConfig = (identityConfig: 'a) => {
|
|
235
235
|
let raw =
|
|
236
236
|
identityConfig->(
|
|
@@ -239,6 +239,7 @@ let getGlobalIndexer = (): 'indexer => {
|
|
|
239
239
|
"event": unknown,
|
|
240
240
|
"wildcard": option<bool>,
|
|
241
241
|
"where": option<JSON.t>,
|
|
242
|
+
"fields": option<Internal.evmFieldsSelection>,
|
|
242
243
|
}
|
|
243
244
|
)
|
|
244
245
|
// Detect format: if "contract" is a string, it's the TS format
|
|
@@ -255,12 +256,14 @@ let getGlobalIndexer = (): 'indexer => {
|
|
|
255
256
|
}
|
|
256
257
|
let wildcard = raw["wildcard"]
|
|
257
258
|
let where = raw["where"]
|
|
258
|
-
let
|
|
259
|
-
|
|
260
|
-
| (
|
|
259
|
+
let fields = raw["fields"]
|
|
260
|
+
let eventOptions: option<Internal.eventOptions<_>> = switch (wildcard, where, fields) {
|
|
261
|
+
| (None, None, None) => None
|
|
262
|
+
| (wildcard, where, fields) =>
|
|
261
263
|
Some({
|
|
262
264
|
?wildcard,
|
|
263
265
|
where: ?(where->(Utils.magic: option<JSON.t> => option<_>)),
|
|
266
|
+
?fields,
|
|
264
267
|
})
|
|
265
268
|
}
|
|
266
269
|
(contractName, eventName, eventOptions)
|
|
@@ -288,7 +291,12 @@ let getGlobalIndexer = (): 'indexer => {
|
|
|
288
291
|
let parseSvmIdentityConfig = (identityConfig: 'a) => {
|
|
289
292
|
let raw =
|
|
290
293
|
identityConfig->(
|
|
291
|
-
Utils.magic: 'a => {
|
|
294
|
+
Utils.magic: 'a => {
|
|
295
|
+
"program": unknown,
|
|
296
|
+
"instruction": unknown,
|
|
297
|
+
"where": option<JSON.t>,
|
|
298
|
+
"fields": option<Internal.evmFieldsSelection>,
|
|
299
|
+
}
|
|
292
300
|
)
|
|
293
301
|
let (programName, instructionName) = if typeof(raw["program"]) === #string {
|
|
294
302
|
(
|
|
@@ -300,11 +308,16 @@ let getGlobalIndexer = (): 'indexer => {
|
|
|
300
308
|
(inst["contract"], inst["_0"])
|
|
301
309
|
}
|
|
302
310
|
let where = raw["where"]
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
311
|
+
// SVM takes its selection from the config, so `fields` is carried through
|
|
312
|
+
// only to be rejected by the registration — dropping it here would leave a
|
|
313
|
+
// plain-JS caller with a silently ignored option.
|
|
314
|
+
let fields = raw["fields"]
|
|
315
|
+
let eventOptions: option<Internal.eventOptions<_>> = switch (where, fields) {
|
|
316
|
+
| (None, None) => None
|
|
317
|
+
| (where, fields) =>
|
|
306
318
|
Some({
|
|
307
319
|
where: ?(where->(Utils.magic: option<JSON.t> => option<_>)),
|
|
320
|
+
?fields,
|
|
308
321
|
})
|
|
309
322
|
}
|
|
310
323
|
(programName, instructionName, eventOptions)
|
package/src/Main.res.mjs
CHANGED
|
@@ -232,10 +232,21 @@ function getGlobalIndexer() {
|
|
|
232
232
|
}
|
|
233
233
|
let wildcard = identityConfig.wildcard;
|
|
234
234
|
let where = identityConfig.where;
|
|
235
|
-
let
|
|
235
|
+
let fields = identityConfig.fields;
|
|
236
|
+
let eventOptions;
|
|
237
|
+
let exit = 0;
|
|
238
|
+
if (wildcard !== undefined || where !== undefined || fields !== undefined) {
|
|
239
|
+
exit = 1;
|
|
240
|
+
} else {
|
|
241
|
+
eventOptions = undefined;
|
|
242
|
+
}
|
|
243
|
+
if (exit === 1) {
|
|
244
|
+
eventOptions = {
|
|
236
245
|
wildcard: wildcard,
|
|
237
|
-
where: where
|
|
238
|
-
|
|
246
|
+
where: where,
|
|
247
|
+
fields: fields
|
|
248
|
+
};
|
|
249
|
+
}
|
|
239
250
|
return [
|
|
240
251
|
match[0],
|
|
241
252
|
match[1],
|
|
@@ -262,8 +273,10 @@ function getGlobalIndexer() {
|
|
|
262
273
|
];
|
|
263
274
|
}
|
|
264
275
|
let where = identityConfig.where;
|
|
265
|
-
let
|
|
266
|
-
|
|
276
|
+
let fields = identityConfig.fields;
|
|
277
|
+
let eventOptions = where !== undefined || fields !== undefined ? ({
|
|
278
|
+
where: where,
|
|
279
|
+
fields: fields
|
|
267
280
|
}) : undefined;
|
|
268
281
|
return [
|
|
269
282
|
match[0],
|