envio 3.5.0-alpha.1 → 3.5.0-alpha.2
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 +10 -6
- package/package.json +6 -6
- package/src/BatchProcessing.res +13 -0
- package/src/BatchProcessing.res.mjs +4 -0
- package/src/ChainFetching.res +5 -5
- package/src/ChainFetching.res.mjs +3 -4
- package/src/ChainState.res +38 -21
- package/src/ChainState.res.mjs +17 -24
- package/src/ChainState.resi +1 -5
- package/src/Change.res +3 -3
- package/src/Config.res +0 -4
- package/src/Config.res.mjs +0 -10
- package/src/Core.res +3 -0
- package/src/EntityId.res +15 -0
- package/src/EntityId.res.mjs +9 -0
- package/src/EventConfigBuilder.res +1 -58
- package/src/EventConfigBuilder.res.mjs +1 -33
- package/src/FetchState.res +345 -459
- package/src/FetchState.res.mjs +269 -430
- package/src/HandlerRegister.res +45 -0
- package/src/HandlerRegister.res.mjs +43 -0
- package/src/InMemoryStore.res +11 -4
- package/src/InMemoryTable.res +12 -10
- package/src/InMemoryTable.res.mjs +6 -5
- package/src/IndexerState.res +59 -2
- package/src/IndexerState.res.mjs +48 -3
- package/src/IndexerState.resi +2 -0
- package/src/Internal.res +17 -8
- package/src/LogSelection.res +2 -1
- package/src/Metrics.res +37 -6
- package/src/Metrics.res.mjs +5 -1
- package/src/Persistence.res +1 -1
- package/src/PgStorage.res +55 -22
- package/src/PgStorage.res.mjs +25 -17
- package/src/SimulateItems.res +2 -2
- package/src/TestIndexer.res +6 -5
- package/src/TestIndexer.res.mjs +3 -2
- package/src/UserContext.res +3 -3
- package/src/Writing.res +12 -2
- package/src/Writing.res.mjs +13 -2
- package/src/bindings/ClickHouse.res +5 -3
- package/src/bindings/ClickHouse.res.mjs +2 -5
- package/src/bindings/Vitest.res +22 -1
- package/src/bindings/Vitest.res.mjs +15 -0
- package/src/db/EntityHistory.res +16 -7
- package/src/db/EntityHistory.res.mjs +7 -6
- package/src/db/Table.res +40 -9
- package/src/db/Table.res.mjs +44 -6
- package/src/sources/AddressSet.res +48 -0
- package/src/sources/AddressSet.res.mjs +11 -0
- package/src/sources/AddressStore.res +152 -0
- package/src/sources/AddressStore.res.mjs +97 -0
- package/src/sources/EvmChain.res +3 -0
- package/src/sources/EvmChain.res.mjs +4 -2
- package/src/sources/EvmHyperSyncSource.res +6 -3
- package/src/sources/EvmHyperSyncSource.res.mjs +3 -3
- package/src/sources/EvmRpcClient.res +6 -3
- package/src/sources/EvmRpcClient.res.mjs +3 -3
- package/src/sources/FuelHyperSync.res +4 -3
- package/src/sources/FuelHyperSync.res.mjs +3 -3
- package/src/sources/FuelHyperSync.resi +2 -1
- package/src/sources/FuelHyperSyncClient.res +12 -6
- package/src/sources/FuelHyperSyncClient.res.mjs +2 -2
- package/src/sources/FuelHyperSyncSource.res +7 -4
- package/src/sources/FuelHyperSyncSource.res.mjs +3 -3
- package/src/sources/HyperSync.res +6 -4
- package/src/sources/HyperSync.res.mjs +2 -3
- package/src/sources/HyperSync.resi +1 -1
- package/src/sources/HyperSyncClient.res +18 -9
- package/src/sources/HyperSyncClient.res.mjs +4 -4
- package/src/sources/RpcSource.res +15 -10
- package/src/sources/RpcSource.res.mjs +3 -4
- package/src/sources/SimulateSource.res +26 -11
- package/src/sources/SimulateSource.res.mjs +13 -5
- package/src/sources/Source.res +4 -2
- package/src/sources/SourceManager.res +2 -3
- package/src/sources/SourceManager.res.mjs +2 -3
- package/src/sources/Svm.res +1 -2
- package/src/sources/Svm.res.mjs +1 -1
- package/src/sources/SvmHyperSyncClient.res +12 -3
- package/src/sources/SvmHyperSyncClient.res.mjs +2 -2
- package/src/sources/SvmHyperSyncSource.res +10 -5
- package/src/sources/SvmHyperSyncSource.res.mjs +5 -4
- package/src/IndexingAddresses.res +0 -151
- package/src/IndexingAddresses.res.mjs +0 -130
- package/src/IndexingAddresses.resi +0 -39
|
@@ -292,61 +292,6 @@ let resolveFieldSelection = (
|
|
|
292
292
|
)
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
-
// ============== Client-side address filter ==============
|
|
296
|
-
|
|
297
|
-
let compileAddressFilter: string => (
|
|
298
|
-
Internal.eventPayload,
|
|
299
|
-
int,
|
|
300
|
-
dict<Internal.indexingContract>,
|
|
301
|
-
) => bool = %raw(`function (body) {
|
|
302
|
-
return new Function("event", "blockNumber", "indexingAddresses", body);
|
|
303
|
-
}`)
|
|
304
|
-
|
|
305
|
-
// Body of the client-side address filter. Two analogous registered-at-or-before
|
|
306
|
-
// checks, ANDed: (1) for non-wildcard events, the log's srcAddress must itself be
|
|
307
|
-
// registered (ownership is resolved structurally by partition, but the temporal
|
|
308
|
-
// `effectiveStartBlock` gate lives here now); (2) a DNF of address-filtered param
|
|
309
|
-
// names (OR of AND-groups) for events that filter an indexed address param. The
|
|
310
|
-
// DNF is fixed here, so it's unrolled into one boolean expression — no per-event
|
|
311
|
-
// closure, loop, or array. `None` only for wildcard events without a param
|
|
312
|
-
// filter. Exposed for snapshotting.
|
|
313
|
-
// `srcAddressExpr` is the JS expression for the event's owning address: EVM and
|
|
314
|
-
// Fuel events expose `event.srcAddress`; SVM instructions expose `event.programId`.
|
|
315
|
-
let buildAddressFilterBody = (
|
|
316
|
-
groups: array<array<string>>,
|
|
317
|
-
~isWildcard: bool,
|
|
318
|
-
~srcAddressExpr: string="event.srcAddress",
|
|
319
|
-
): option<string> => {
|
|
320
|
-
let paramLeaf = name =>
|
|
321
|
-
`(ic = indexingAddresses[p[${JSON.stringify(
|
|
322
|
-
JSON.String(name),
|
|
323
|
-
)}]]) !== undefined && ic.effectiveStartBlock <= blockNumber`
|
|
324
|
-
let paramDnf = switch groups {
|
|
325
|
-
| [] => None
|
|
326
|
-
| _ =>
|
|
327
|
-
Some(
|
|
328
|
-
groups
|
|
329
|
-
->Array.map(group => "(" ++ group->Array.map(paramLeaf)->Array.join(" && ") ++ ")")
|
|
330
|
-
->Array.join(" || "),
|
|
331
|
-
)
|
|
332
|
-
}
|
|
333
|
-
let srcLeaf = `(ic = indexingAddresses[${srcAddressExpr}]) !== undefined && ic.effectiveStartBlock <= blockNumber`
|
|
334
|
-
switch (isWildcard, paramDnf) {
|
|
335
|
-
| (true, None) => None
|
|
336
|
-
| (true, Some(dnf)) => Some("var p = event.params, ic; return " ++ dnf ++ ";")
|
|
337
|
-
| (false, None) => Some("var ic; return " ++ srcLeaf ++ ";")
|
|
338
|
-
| (false, Some(dnf)) =>
|
|
339
|
-
Some("var p = event.params, ic; return " ++ srcLeaf ++ " && (" ++ dnf ++ ");")
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
let buildAddressFilter = (
|
|
344
|
-
groups: array<array<string>>,
|
|
345
|
-
~isWildcard: bool,
|
|
346
|
-
~srcAddressExpr: string="event.srcAddress",
|
|
347
|
-
): option<(Internal.eventPayload, int, dict<Internal.indexingContract>) => bool> =>
|
|
348
|
-
buildAddressFilterBody(groups, ~isWildcard, ~srcAddressExpr)->Option.map(compileAddressFilter)
|
|
349
|
-
|
|
350
295
|
// ============== Build complete EVM event config ==============
|
|
351
296
|
|
|
352
297
|
let buildEvmEventConfig = (
|
|
@@ -431,7 +376,7 @@ let buildEvmOnEventRegistration = (
|
|
|
431
376
|
contractRegister,
|
|
432
377
|
resolvedWhere,
|
|
433
378
|
filterByAddresses,
|
|
434
|
-
|
|
379
|
+
addressFilterParamGroups,
|
|
435
380
|
dependsOnAddresses: Internal.dependsOnAddresses(~isWildcard, ~filterByAddresses),
|
|
436
381
|
startBlock: resolvedStartBlock,
|
|
437
382
|
}
|
|
@@ -516,7 +461,6 @@ let buildSvmOnEventRegistration = (
|
|
|
516
461
|
isWildcard,
|
|
517
462
|
filterByAddresses: false,
|
|
518
463
|
dependsOnAddresses: Internal.dependsOnAddresses(~isWildcard, ~filterByAddresses=false),
|
|
519
|
-
clientAddressFilter: ?buildAddressFilter([], ~isWildcard, ~srcAddressExpr="event.programId"),
|
|
520
464
|
startBlock,
|
|
521
465
|
}
|
|
522
466
|
|
|
@@ -594,6 +538,5 @@ let buildFuelOnEventRegistration = (
|
|
|
594
538
|
isWildcard,
|
|
595
539
|
filterByAddresses: false,
|
|
596
540
|
dependsOnAddresses: Internal.dependsOnAddresses(~isWildcard, ~filterByAddresses=false),
|
|
597
|
-
clientAddressFilter: ?buildAddressFilter([], ~isWildcard),
|
|
598
541
|
startBlock,
|
|
599
542
|
}
|
|
@@ -243,33 +243,6 @@ function resolveFieldSelection(blockFields, transactionFields, globalBlockFields
|
|
|
243
243
|
];
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
let compileAddressFilter = (function (body) {
|
|
247
|
-
return new Function("event", "blockNumber", "indexingAddresses", body);
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
function buildAddressFilterBody(groups, isWildcard, srcAddressExprOpt) {
|
|
251
|
-
let srcAddressExpr = srcAddressExprOpt !== undefined ? srcAddressExprOpt : "event.srcAddress";
|
|
252
|
-
let paramLeaf = name => `(ic = indexingAddresses[p[` + JSON.stringify(name) + `]]) !== undefined && ic.effectiveStartBlock <= blockNumber`;
|
|
253
|
-
let paramDnf = groups.length !== 0 ? groups.map(group => "(" + group.map(paramLeaf).join(" && ") + ")").join(" || ") : undefined;
|
|
254
|
-
let srcLeaf = `(ic = indexingAddresses[` + srcAddressExpr + `]) !== undefined && ic.effectiveStartBlock <= blockNumber`;
|
|
255
|
-
if (isWildcard) {
|
|
256
|
-
if (paramDnf !== undefined) {
|
|
257
|
-
return "var p = event.params, ic; return " + paramDnf + ";";
|
|
258
|
-
} else {
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
} else if (paramDnf !== undefined) {
|
|
262
|
-
return "var p = event.params, ic; return " + srcLeaf + " && (" + paramDnf + ");";
|
|
263
|
-
} else {
|
|
264
|
-
return "var ic; return " + srcLeaf + ";";
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function buildAddressFilter(groups, isWildcard, srcAddressExprOpt) {
|
|
269
|
-
let srcAddressExpr = srcAddressExprOpt !== undefined ? srcAddressExprOpt : "event.srcAddress";
|
|
270
|
-
return Stdlib_Option.map(buildAddressFilterBody(groups, isWildcard, srcAddressExpr), compileAddressFilter);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
246
|
function buildEvmEventConfig(contractName, eventName, sighash, params, blockFields, transactionFields, globalBlockFieldsSetOpt, globalTransactionFieldsSetOpt) {
|
|
274
247
|
let globalBlockFieldsSet = globalBlockFieldsSetOpt !== undefined ? Primitive_option.valFromOption(globalBlockFieldsSetOpt) : new Set();
|
|
275
248
|
let globalTransactionFieldsSet = globalTransactionFieldsSetOpt !== undefined ? Primitive_option.valFromOption(globalTransactionFieldsSetOpt) : new Set();
|
|
@@ -314,7 +287,7 @@ function buildEvmOnEventRegistration(eventConfig, isWildcard, handler, contractR
|
|
|
314
287
|
isWildcard: isWildcard,
|
|
315
288
|
filterByAddresses: filterByAddresses,
|
|
316
289
|
dependsOnAddresses: Internal.dependsOnAddresses(isWildcard, filterByAddresses),
|
|
317
|
-
|
|
290
|
+
addressFilterParamGroups: match.addressFilterParamGroups,
|
|
318
291
|
startBlock: resolvedStartBlock,
|
|
319
292
|
resolvedWhere: resolvedWhere
|
|
320
293
|
};
|
|
@@ -367,7 +340,6 @@ function buildSvmOnEventRegistration(eventConfig, isWildcard, handler, contractR
|
|
|
367
340
|
isWildcard: isWildcard,
|
|
368
341
|
filterByAddresses: false,
|
|
369
342
|
dependsOnAddresses: Internal.dependsOnAddresses(isWildcard, false),
|
|
370
|
-
clientAddressFilter: buildAddressFilter([], isWildcard, "event.programId"),
|
|
371
343
|
startBlock: startBlock
|
|
372
344
|
};
|
|
373
345
|
}
|
|
@@ -437,7 +409,6 @@ function buildFuelOnEventRegistration(eventConfig, isWildcard, handler, contract
|
|
|
437
409
|
isWildcard: isWildcard,
|
|
438
410
|
filterByAddresses: false,
|
|
439
411
|
dependsOnAddresses: Internal.dependsOnAddresses(isWildcard, false),
|
|
440
|
-
clientAddressFilter: buildAddressFilter([], isWildcard, undefined),
|
|
441
412
|
startBlock: startBlock
|
|
442
413
|
};
|
|
443
414
|
}
|
|
@@ -457,9 +428,6 @@ export {
|
|
|
457
428
|
buildTopicGetter,
|
|
458
429
|
alwaysIncludedBlockFields,
|
|
459
430
|
resolveFieldSelection,
|
|
460
|
-
compileAddressFilter,
|
|
461
|
-
buildAddressFilterBody,
|
|
462
|
-
buildAddressFilter,
|
|
463
431
|
buildEvmEventConfig,
|
|
464
432
|
buildEvmOnEventRegistration,
|
|
465
433
|
alwaysIncludedSvmBlockFields,
|