envio 3.7.0 → 3.9.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/README.md +2 -2
- package/index.d.ts +399 -156
- package/package.json +6 -6
- package/src/AddressRows.res +121 -0
- package/src/AddressRows.res.mjs +143 -0
- package/src/Batch.res +2 -0
- package/src/Batch.res.mjs +2 -1
- package/src/ChainState.res +82 -68
- package/src/ChainState.res.mjs +81 -65
- package/src/ChainState.resi +14 -9
- package/src/Config.res +41 -91
- package/src/Config.res.mjs +34 -68
- package/src/ContractMapping.res +66 -0
- package/src/ContractMapping.res.mjs +73 -0
- package/src/Core.res +20 -0
- package/src/Core.res.mjs +4 -0
- package/src/Envio.res +54 -76
- package/src/EventConfigBuilder.res +157 -30
- package/src/EventConfigBuilder.res.mjs +118 -24
- package/src/FetchState.res +59 -67
- package/src/FetchState.res.mjs +34 -44
- package/src/HandlerRegister.res +20 -11
- package/src/HandlerRegister.res.mjs +22 -5
- package/src/Hasura.res +30 -22
- package/src/Hasura.res.mjs +11 -5
- package/src/InMemoryStore.res +18 -36
- package/src/InMemoryStore.res.mjs +12 -26
- package/src/IndexerState.res +21 -1
- package/src/IndexerState.res.mjs +9 -3
- package/src/IndexerState.resi +1 -0
- package/src/Internal.res +33 -13
- package/src/Internal.res.mjs +12 -16
- package/src/Main.res +27 -20
- package/src/Main.res.mjs +19 -14
- package/src/MemoryStorage.res +78 -73
- package/src/MemoryStorage.res.mjs +66 -81
- package/src/Metrics.res +15 -1
- package/src/Metrics.res.mjs +5 -1
- package/src/Persistence.res +34 -18
- package/src/Persistence.res.mjs +8 -5
- package/src/PgStorage.res +189 -66
- package/src/PgStorage.res.mjs +93 -59
- package/src/Rollback.res +14 -10
- package/src/Rollback.res.mjs +4 -2
- package/src/SimulateItems.res +254 -9
- package/src/SimulateItems.res.mjs +214 -47
- package/src/TestIndexer.res +119 -121
- package/src/TestIndexer.res.mjs +95 -100
- package/src/Utils.res +7 -0
- package/src/Utils.res.mjs +9 -2
- package/src/Writing.res +2 -0
- package/src/Writing.res.mjs +2 -1
- package/src/bindings/ClickHouse.res +39 -6
- package/src/bindings/ClickHouse.res.mjs +29 -4
- package/src/bindings/NodeJs.res +9 -0
- package/src/bindings/NodeJs.res.mjs +8 -1
- package/src/bindings/Postgres.res +9 -0
- package/src/bindings/Postgres.res.mjs +3 -0
- package/src/db/EntityHistory.res +12 -18
- package/src/db/EntityHistory.res.mjs +3 -14
- package/src/db/InternalTable.res +182 -65
- package/src/db/InternalTable.res.mjs +183 -73
- package/src/db/Table.res +24 -0
- package/src/db/Table.res.mjs +20 -1
- package/src/sources/AddressSet.res +0 -22
- package/src/sources/AddressStore.res +48 -88
- package/src/sources/AddressStore.res.mjs +11 -22
- package/src/sources/EvmHyperSyncSource.res +3 -2
- package/src/sources/SimulateSource.res +8 -4
- package/src/sources/SimulateSource.res.mjs +7 -3
- package/src/sources/Svm.res +34 -7
- package/src/sources/Svm.res.mjs +32 -4
- package/src/sources/SvmHyperSyncClient.res +24 -30
- package/src/sources/SvmHyperSyncClient.res.mjs +3 -2
- package/src/sources/SvmHyperSyncSource.res +88 -36
- package/src/sources/SvmHyperSyncSource.res.mjs +71 -39
- package/src/sources/TransactionStore.res +38 -0
- package/src/sources/TransactionStore.res.mjs +5 -0
- package/svm.schema.json +37 -82
|
@@ -310,33 +310,47 @@ let internalBlockFields = ["number"]
|
|
|
310
310
|
// selected.
|
|
311
311
|
let rawEventBlockFields = ["hash", "timestamp"]
|
|
312
312
|
|
|
313
|
-
let
|
|
313
|
+
let evmSelectionKinds = ["block", "transaction"]
|
|
314
|
+
let svmSelectionKinds = ["instruction", "transaction", "accountActivity", "block", "log"]
|
|
314
315
|
|
|
315
316
|
// A handler written in plain JS gets no type error for a `blocks`/`transactions`
|
|
316
317
|
// typo, and an unrecognised key would read as an empty selection — silently
|
|
317
318
|
// dropping every field `config.yaml` selected. Rejected here so the option is
|
|
318
319
|
// held to the same shape whether or not the project type-checks it.
|
|
319
|
-
let
|
|
320
|
-
|
|
321
|
-
|
|
320
|
+
let quotedJoin = (names: array<string>) =>
|
|
321
|
+
names->Array.map(name => `"${name}"`)->Array.joinUnsafe(", ")
|
|
322
|
+
|
|
323
|
+
let validateFieldsShapeOrThrow = (
|
|
324
|
+
fields: unknown,
|
|
325
|
+
~registration: string,
|
|
326
|
+
~validKeys: array<string>,
|
|
327
|
+
~shapeNoun: string,
|
|
328
|
+
) => {
|
|
329
|
+
if typeof(fields) !== #object || fields === %raw(`null`) || Array.isArray(fields) {
|
|
322
330
|
JsError.throwWithMessage(
|
|
323
|
-
`The fields option of ${registration} must be an object of
|
|
331
|
+
`The fields option of ${registration} must be an object of ${shapeNoun} field names.`,
|
|
324
332
|
)
|
|
325
333
|
}
|
|
326
|
-
|
|
334
|
+
fields
|
|
327
335
|
->(Utils.magic: unknown => dict<unknown>)
|
|
328
336
|
->Dict.keysToArray
|
|
329
337
|
->Array.forEach(key =>
|
|
330
|
-
if !(
|
|
338
|
+
if !(validKeys->Array.includes(key)) {
|
|
331
339
|
JsError.throwWithMessage(
|
|
332
|
-
`Invalid "${key}" key in the fields option of ${registration}. Valid keys: ${
|
|
333
|
-
|
|
340
|
+
`Invalid "${key}" key in the fields option of ${registration}. Valid keys: ${quotedJoin(
|
|
341
|
+
validKeys,
|
|
334
342
|
)}.`,
|
|
335
343
|
)
|
|
336
344
|
}
|
|
337
345
|
)
|
|
338
346
|
}
|
|
339
347
|
|
|
348
|
+
let selectionList = (fields: unknown, key: string): option<array<string>> =>
|
|
349
|
+
switch (fields->(Utils.magic: unknown => dict<unknown>))->Dict.get(key) {
|
|
350
|
+
| None => None
|
|
351
|
+
| Some(value) => Some(value->(Utils.magic: unknown => array<string>))
|
|
352
|
+
}
|
|
353
|
+
|
|
340
354
|
let validBlockFields = Utils.Set.fromArray(Evm.blockFields)
|
|
341
355
|
let validTransactionFields = Utils.Set.fromArray(Evm.transactionFields)
|
|
342
356
|
|
|
@@ -345,6 +359,7 @@ let parseFieldsOrThrow = (
|
|
|
345
359
|
~valid: Utils.Set.t<string>,
|
|
346
360
|
~kind: string,
|
|
347
361
|
~registration: string,
|
|
362
|
+
~rejectEmpty=false,
|
|
348
363
|
) => {
|
|
349
364
|
let seen = Utils.Set.make()
|
|
350
365
|
let fields = switch fields {
|
|
@@ -358,9 +373,9 @@ let parseFieldsOrThrow = (
|
|
|
358
373
|
fields->Array.forEach(name => {
|
|
359
374
|
if !(valid->Utils.Set.has(name)) {
|
|
360
375
|
JsError.throwWithMessage(
|
|
361
|
-
`Invalid "${name}" field in the fields.${kind} option of ${registration}. Valid ${kind} fields: ${
|
|
362
|
-
->Utils.Set.toArray
|
|
363
|
-
|
|
376
|
+
`Invalid "${name}" field in the fields.${kind} option of ${registration}. Valid ${kind} fields: ${quotedJoin(
|
|
377
|
+
valid->Utils.Set.toArray,
|
|
378
|
+
)}.`,
|
|
364
379
|
)
|
|
365
380
|
}
|
|
366
381
|
if seen->Utils.Set.has(name) {
|
|
@@ -370,6 +385,11 @@ let parseFieldsOrThrow = (
|
|
|
370
385
|
}
|
|
371
386
|
seen->Utils.Set.add(name)->ignore
|
|
372
387
|
})
|
|
388
|
+
if rejectEmpty && fields->Array.length === 0 {
|
|
389
|
+
JsError.throwWithMessage(
|
|
390
|
+
`The fields.${kind} option of ${registration} must list at least one field.`,
|
|
391
|
+
)
|
|
392
|
+
}
|
|
373
393
|
seen
|
|
374
394
|
}
|
|
375
395
|
|
|
@@ -377,21 +397,26 @@ let parseFieldsOrThrow = (
|
|
|
377
397
|
// option itself (the names are for error messages), never on the chain, so one
|
|
378
398
|
// `onEvent` call resolves once and shares the result across every chain.
|
|
379
399
|
let resolveInlineFieldSelection = (
|
|
380
|
-
fields:
|
|
400
|
+
fields: unknown,
|
|
381
401
|
~contractName: string,
|
|
382
402
|
~eventName: string,
|
|
383
403
|
~enableRawEvents: bool,
|
|
384
404
|
): Internal.fieldSelection => {
|
|
385
405
|
let registration = `the "${eventName}" event registration on contract "${contractName}"`
|
|
386
|
-
validateFieldsShapeOrThrow(
|
|
406
|
+
validateFieldsShapeOrThrow(
|
|
407
|
+
fields,
|
|
408
|
+
~registration,
|
|
409
|
+
~validKeys=evmSelectionKinds,
|
|
410
|
+
~shapeNoun="block and transaction",
|
|
411
|
+
)
|
|
387
412
|
let blockFields = parseFieldsOrThrow(
|
|
388
|
-
fields
|
|
413
|
+
selectionList(fields, "block"),
|
|
389
414
|
~valid=validBlockFields,
|
|
390
415
|
~kind="block",
|
|
391
416
|
~registration,
|
|
392
417
|
)
|
|
393
418
|
let transactionFields = parseFieldsOrThrow(
|
|
394
|
-
fields
|
|
419
|
+
selectionList(fields, "transaction"),
|
|
395
420
|
~valid=validTransactionFields,
|
|
396
421
|
~kind="transaction",
|
|
397
422
|
~registration,
|
|
@@ -498,9 +523,115 @@ let buildEvmOnEventRegistration = (
|
|
|
498
523
|
|
|
499
524
|
// ============== Build SVM instruction event config ==============
|
|
500
525
|
|
|
501
|
-
//
|
|
502
|
-
//
|
|
503
|
-
let alwaysIncludedSvmBlockFields
|
|
526
|
+
// `block.slot` is the item's own key, so an inline selection carries it
|
|
527
|
+
// whether or not the handler listed it.
|
|
528
|
+
let alwaysIncludedSvmBlockFields = ["slot"]
|
|
529
|
+
|
|
530
|
+
let validSvmInstructionFields = Utils.Set.fromArray([
|
|
531
|
+
"args",
|
|
532
|
+
"accounts",
|
|
533
|
+
"accountArguments",
|
|
534
|
+
"programId",
|
|
535
|
+
"data",
|
|
536
|
+
"path",
|
|
537
|
+
"isInner",
|
|
538
|
+
])
|
|
539
|
+
let validSvmTransactionFields = Utils.Set.fromArray([
|
|
540
|
+
"transactionIndex",
|
|
541
|
+
"signature",
|
|
542
|
+
"feePayer",
|
|
543
|
+
"success",
|
|
544
|
+
"err",
|
|
545
|
+
"fee",
|
|
546
|
+
"computeUnitsConsumed",
|
|
547
|
+
"accountKeys",
|
|
548
|
+
"recentBlockhash",
|
|
549
|
+
"version",
|
|
550
|
+
"allSignatures",
|
|
551
|
+
])
|
|
552
|
+
let validSvmAccountActivityFields = Utils.Set.fromArray([
|
|
553
|
+
"address",
|
|
554
|
+
"transactionAccountIndex",
|
|
555
|
+
"isSigner",
|
|
556
|
+
"isWritable",
|
|
557
|
+
"lamports.pre",
|
|
558
|
+
"lamports.post",
|
|
559
|
+
"token.mint",
|
|
560
|
+
"token.owner",
|
|
561
|
+
"token.decimals",
|
|
562
|
+
"token.preAmount",
|
|
563
|
+
"token.postAmount",
|
|
564
|
+
])
|
|
565
|
+
let validSvmBlockFields = Utils.Set.fromArray([
|
|
566
|
+
"slot",
|
|
567
|
+
"time",
|
|
568
|
+
"hash",
|
|
569
|
+
"height",
|
|
570
|
+
"parentSlot",
|
|
571
|
+
"parentHash",
|
|
572
|
+
])
|
|
573
|
+
let validSvmLogFields = Utils.Set.fromArray(["kind", "message"])
|
|
574
|
+
|
|
575
|
+
let resolveSvmInlineFieldSelection = (
|
|
576
|
+
fields: unknown,
|
|
577
|
+
~contractName: string,
|
|
578
|
+
~eventName: string,
|
|
579
|
+
): Internal.fieldSelection => {
|
|
580
|
+
let registration = `the "${eventName}" event registration on contract "${contractName}"`
|
|
581
|
+
validateFieldsShapeOrThrow(
|
|
582
|
+
fields,
|
|
583
|
+
~registration,
|
|
584
|
+
~validKeys=svmSelectionKinds,
|
|
585
|
+
~shapeNoun="instruction, transaction, accountActivity, block and log",
|
|
586
|
+
)
|
|
587
|
+
let accountActivity = selectionList(fields, "accountActivity")
|
|
588
|
+
let log = selectionList(fields, "log")
|
|
589
|
+
let instructionFields = parseFieldsOrThrow(
|
|
590
|
+
selectionList(fields, "instruction"),
|
|
591
|
+
~valid=validSvmInstructionFields,
|
|
592
|
+
~kind="instruction",
|
|
593
|
+
~registration,
|
|
594
|
+
)
|
|
595
|
+
let transactionFields = parseFieldsOrThrow(
|
|
596
|
+
selectionList(fields, "transaction"),
|
|
597
|
+
~valid=validSvmTransactionFields,
|
|
598
|
+
~kind="transaction",
|
|
599
|
+
~registration,
|
|
600
|
+
)
|
|
601
|
+
let accountActivityFields = parseFieldsOrThrow(
|
|
602
|
+
accountActivity,
|
|
603
|
+
~valid=validSvmAccountActivityFields,
|
|
604
|
+
~kind="accountActivity",
|
|
605
|
+
~registration,
|
|
606
|
+
~rejectEmpty=accountActivity->Option.isSome,
|
|
607
|
+
)
|
|
608
|
+
let blockFields = parseFieldsOrThrow(
|
|
609
|
+
selectionList(fields, "block"),
|
|
610
|
+
~valid=validSvmBlockFields,
|
|
611
|
+
~kind="block",
|
|
612
|
+
~registration,
|
|
613
|
+
)
|
|
614
|
+
let logFields = parseFieldsOrThrow(
|
|
615
|
+
log,
|
|
616
|
+
~valid=validSvmLogFields,
|
|
617
|
+
~kind="log",
|
|
618
|
+
~registration,
|
|
619
|
+
~rejectEmpty=log->Option.isSome,
|
|
620
|
+
)
|
|
621
|
+
blockFields->Utils.Set.addMany(alwaysIncludedSvmBlockFields)
|
|
622
|
+
if accountActivityFields->Utils.Set.size > 0 {
|
|
623
|
+
transactionFields->Utils.Set.add("accountActivities")->ignore
|
|
624
|
+
}
|
|
625
|
+
Internal.makeFieldSelection(
|
|
626
|
+
~blockFields,
|
|
627
|
+
~transactionFields,
|
|
628
|
+
~instructionFields,
|
|
629
|
+
~accountActivityFields,
|
|
630
|
+
~logFields,
|
|
631
|
+
~blockMaskFn=Svm.eventBlockFieldMask,
|
|
632
|
+
~transactionMaskFn=Svm.eventTransactionFieldMask,
|
|
633
|
+
)
|
|
634
|
+
}
|
|
504
635
|
|
|
505
636
|
let buildSvmInstructionEventConfig = (
|
|
506
637
|
~contractName: string,
|
|
@@ -508,9 +639,6 @@ let buildSvmInstructionEventConfig = (
|
|
|
508
639
|
~programId: SvmTypes.Pubkey.t,
|
|
509
640
|
~discriminator: option<string>,
|
|
510
641
|
~discriminatorByteLen: int,
|
|
511
|
-
~includeLogs: bool,
|
|
512
|
-
~transactionFields: array<Internal.svmTransactionField>=[],
|
|
513
|
-
~blockFields: array<Internal.svmBlockField>=[],
|
|
514
642
|
~accountFilters: array<Internal.svmAccountFilterGroup>,
|
|
515
643
|
~isInner: option<bool>,
|
|
516
644
|
~accounts: array<string>=[],
|
|
@@ -523,12 +651,8 @@ let buildSvmInstructionEventConfig = (
|
|
|
523
651
|
->(Utils.magic: S.t<JSON.t> => S.t<Internal.eventParams>)
|
|
524
652
|
|
|
525
653
|
let fieldSelection = Internal.makeFieldSelection(
|
|
526
|
-
~blockFields=Utils.Set.fromArray(
|
|
527
|
-
|
|
528
|
-
),
|
|
529
|
-
~transactionFields=Utils.Set.fromArray(transactionFields)->(
|
|
530
|
-
Utils.magic: Utils.Set.t<Internal.svmTransactionField> => Utils.Set.t<string>
|
|
531
|
-
),
|
|
654
|
+
~blockFields=Utils.Set.fromArray(alwaysIncludedSvmBlockFields),
|
|
655
|
+
~transactionFields=Utils.Set.make(),
|
|
532
656
|
~blockMaskFn=Svm.eventBlockFieldMask,
|
|
533
657
|
~transactionMaskFn=Svm.eventTransactionFieldMask,
|
|
534
658
|
)
|
|
@@ -544,7 +668,6 @@ let buildSvmInstructionEventConfig = (
|
|
|
544
668
|
programId,
|
|
545
669
|
discriminator,
|
|
546
670
|
discriminatorByteLen,
|
|
547
|
-
includeLogs,
|
|
548
671
|
fieldSelection,
|
|
549
672
|
accountFilters,
|
|
550
673
|
isInner,
|
|
@@ -561,6 +684,7 @@ let buildSvmOnEventRegistration = (
|
|
|
561
684
|
~isWildcard: bool,
|
|
562
685
|
~handler: option<Internal.handler>,
|
|
563
686
|
~contractRegister: option<Internal.contractRegister>,
|
|
687
|
+
~fieldSelection: option<Internal.fieldSelection>=?,
|
|
564
688
|
~startBlock: option<int>=?,
|
|
565
689
|
): Internal.svmOnEventRegistration => {
|
|
566
690
|
index: -1,
|
|
@@ -571,7 +695,10 @@ let buildSvmOnEventRegistration = (
|
|
|
571
695
|
filterByAddresses: false,
|
|
572
696
|
dependsOnAddresses: Internal.dependsOnAddresses(~isWildcard, ~filterByAddresses=false),
|
|
573
697
|
startBlock,
|
|
574
|
-
fieldSelection:
|
|
698
|
+
fieldSelection: switch fieldSelection {
|
|
699
|
+
| Some(fieldSelection) => fieldSelection
|
|
700
|
+
| None => eventConfig.fieldSelection
|
|
701
|
+
},
|
|
575
702
|
}
|
|
576
703
|
|
|
577
704
|
// ============== Build Fuel event config ==============
|
|
@@ -238,7 +238,7 @@ let alwaysIncludedBlockFields = [
|
|
|
238
238
|
function resolveFieldSelection(blockFields, transactionFields, globalBlockFieldsSet, globalTransactionFieldsSet) {
|
|
239
239
|
let selectedBlockFields = blockFields !== undefined ? new Set(alwaysIncludedBlockFields.concat(blockFields)) : globalBlockFieldsSet;
|
|
240
240
|
let selectedTransactionFields = transactionFields !== undefined ? new Set(transactionFields) : globalTransactionFieldsSet;
|
|
241
|
-
return Internal.makeFieldSelection(selectedBlockFields, selectedTransactionFields, Evm.eventBlockFieldMask, Evm.eventTransactionFieldMask);
|
|
241
|
+
return Internal.makeFieldSelection(selectedBlockFields, selectedTransactionFields, undefined, undefined, undefined, Evm.eventBlockFieldMask, Evm.eventTransactionFieldMask);
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
let internalBlockFields = ["number"];
|
|
@@ -248,53 +248,76 @@ let rawEventBlockFields = [
|
|
|
248
248
|
"timestamp"
|
|
249
249
|
];
|
|
250
250
|
|
|
251
|
-
let
|
|
251
|
+
let evmSelectionKinds = [
|
|
252
252
|
"block",
|
|
253
253
|
"transaction"
|
|
254
254
|
];
|
|
255
255
|
|
|
256
|
-
|
|
256
|
+
let svmSelectionKinds = [
|
|
257
|
+
"instruction",
|
|
258
|
+
"transaction",
|
|
259
|
+
"accountActivity",
|
|
260
|
+
"block",
|
|
261
|
+
"log"
|
|
262
|
+
];
|
|
263
|
+
|
|
264
|
+
function quotedJoin(names) {
|
|
265
|
+
return names.map(name => `"` + name + `"`).join(", ");
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function validateFieldsShapeOrThrow(fields, registration, validKeys, shapeNoun) {
|
|
257
269
|
if (typeof fields !== "object" || fields === null || Array.isArray(fields)) {
|
|
258
|
-
Stdlib_JsError.throwWithMessage(`The fields option of ` + registration + ` must be an object of
|
|
270
|
+
Stdlib_JsError.throwWithMessage(`The fields option of ` + registration + ` must be an object of ` + shapeNoun + ` field names.`);
|
|
259
271
|
}
|
|
260
272
|
Object.keys(fields).forEach(key => {
|
|
261
|
-
if (!
|
|
262
|
-
return Stdlib_JsError.throwWithMessage(`Invalid "` + key + `" key in the fields option of ` + registration + `. Valid keys: ` +
|
|
273
|
+
if (!validKeys.includes(key)) {
|
|
274
|
+
return Stdlib_JsError.throwWithMessage(`Invalid "` + key + `" key in the fields option of ` + registration + `. Valid keys: ` + quotedJoin(validKeys) + `.`);
|
|
263
275
|
}
|
|
264
276
|
});
|
|
265
277
|
}
|
|
266
278
|
|
|
279
|
+
function selectionList(fields, key) {
|
|
280
|
+
let value = fields[key];
|
|
281
|
+
if (value !== undefined) {
|
|
282
|
+
return Primitive_option.valFromOption(value);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
267
286
|
let validBlockFields = new Set(Evm.blockFields);
|
|
268
287
|
|
|
269
288
|
let validTransactionFields = new Set(Evm.transactionFields);
|
|
270
289
|
|
|
271
|
-
function parseFieldsOrThrow(fields, valid, kind, registration) {
|
|
290
|
+
function parseFieldsOrThrow(fields, valid, kind, registration, rejectEmptyOpt) {
|
|
291
|
+
let rejectEmpty = rejectEmptyOpt !== undefined ? rejectEmptyOpt : false;
|
|
272
292
|
let seen = new Set();
|
|
273
293
|
let fields$1 = fields !== undefined ? (
|
|
274
294
|
Array.isArray(fields) ? fields : Stdlib_JsError.throwWithMessage(`The fields.` + kind + ` option of ` + registration + ` must be an array of field names.`)
|
|
275
295
|
) : [];
|
|
276
296
|
fields$1.forEach(name => {
|
|
277
297
|
if (!valid.has(name)) {
|
|
278
|
-
Stdlib_JsError.throwWithMessage(`Invalid "` + name + `" field in the fields.` + kind + ` option of ` + registration + `. Valid ` + kind + ` fields: ` + Array.from(valid)
|
|
298
|
+
Stdlib_JsError.throwWithMessage(`Invalid "` + name + `" field in the fields.` + kind + ` option of ` + registration + `. Valid ` + kind + ` fields: ` + quotedJoin(Array.from(valid)) + `.`);
|
|
279
299
|
}
|
|
280
300
|
if (seen.has(name)) {
|
|
281
301
|
Stdlib_JsError.throwWithMessage(`Duplicate "` + name + `" field in the fields.` + kind + ` option of ` + registration + `.`);
|
|
282
302
|
}
|
|
283
303
|
seen.add(name);
|
|
284
304
|
});
|
|
305
|
+
if (rejectEmpty && fields$1.length === 0) {
|
|
306
|
+
Stdlib_JsError.throwWithMessage(`The fields.` + kind + ` option of ` + registration + ` must list at least one field.`);
|
|
307
|
+
}
|
|
285
308
|
return seen;
|
|
286
309
|
}
|
|
287
310
|
|
|
288
311
|
function resolveInlineFieldSelection(fields, contractName, eventName, enableRawEvents) {
|
|
289
312
|
let registration = `the "` + eventName + `" event registration on contract "` + contractName + `"`;
|
|
290
|
-
validateFieldsShapeOrThrow(fields, registration);
|
|
291
|
-
let blockFields = parseFieldsOrThrow(fields
|
|
292
|
-
let transactionFields = parseFieldsOrThrow(fields
|
|
313
|
+
validateFieldsShapeOrThrow(fields, registration, evmSelectionKinds, "block and transaction");
|
|
314
|
+
let blockFields = parseFieldsOrThrow(selectionList(fields, "block"), validBlockFields, "block", registration, undefined);
|
|
315
|
+
let transactionFields = parseFieldsOrThrow(selectionList(fields, "transaction"), validTransactionFields, "transaction", registration, undefined);
|
|
293
316
|
Utils.$$Set.addMany(blockFields, internalBlockFields);
|
|
294
317
|
if (enableRawEvents) {
|
|
295
318
|
Utils.$$Set.addMany(blockFields, rawEventBlockFields);
|
|
296
319
|
}
|
|
297
|
-
return Internal.makeFieldSelection(blockFields, transactionFields, Evm.eventBlockFieldMask, Evm.eventTransactionFieldMask);
|
|
320
|
+
return Internal.makeFieldSelection(blockFields, transactionFields, undefined, undefined, undefined, Evm.eventBlockFieldMask, Evm.eventTransactionFieldMask);
|
|
298
321
|
}
|
|
299
322
|
|
|
300
323
|
function buildEvmEventConfig(contractName, eventName, sighash, params, blockFields, transactionFields, globalBlockFieldsSetOpt, globalTransactionFieldsSetOpt) {
|
|
@@ -342,20 +365,83 @@ function buildEvmOnEventRegistration(eventConfig, isWildcard, handler, contractR
|
|
|
342
365
|
};
|
|
343
366
|
}
|
|
344
367
|
|
|
345
|
-
let alwaysIncludedSvmBlockFields = [
|
|
368
|
+
let alwaysIncludedSvmBlockFields = ["slot"];
|
|
369
|
+
|
|
370
|
+
let validSvmInstructionFields = new Set([
|
|
371
|
+
"args",
|
|
372
|
+
"accounts",
|
|
373
|
+
"accountArguments",
|
|
374
|
+
"programId",
|
|
375
|
+
"data",
|
|
376
|
+
"path",
|
|
377
|
+
"isInner"
|
|
378
|
+
]);
|
|
379
|
+
|
|
380
|
+
let validSvmTransactionFields = new Set([
|
|
381
|
+
"transactionIndex",
|
|
382
|
+
"signature",
|
|
383
|
+
"feePayer",
|
|
384
|
+
"success",
|
|
385
|
+
"err",
|
|
386
|
+
"fee",
|
|
387
|
+
"computeUnitsConsumed",
|
|
388
|
+
"accountKeys",
|
|
389
|
+
"recentBlockhash",
|
|
390
|
+
"version",
|
|
391
|
+
"allSignatures"
|
|
392
|
+
]);
|
|
393
|
+
|
|
394
|
+
let validSvmAccountActivityFields = new Set([
|
|
395
|
+
"address",
|
|
396
|
+
"transactionAccountIndex",
|
|
397
|
+
"isSigner",
|
|
398
|
+
"isWritable",
|
|
399
|
+
"lamports.pre",
|
|
400
|
+
"lamports.post",
|
|
401
|
+
"token.mint",
|
|
402
|
+
"token.owner",
|
|
403
|
+
"token.decimals",
|
|
404
|
+
"token.preAmount",
|
|
405
|
+
"token.postAmount"
|
|
406
|
+
]);
|
|
407
|
+
|
|
408
|
+
let validSvmBlockFields = new Set([
|
|
346
409
|
"slot",
|
|
347
410
|
"time",
|
|
348
|
-
"hash"
|
|
349
|
-
|
|
411
|
+
"hash",
|
|
412
|
+
"height",
|
|
413
|
+
"parentSlot",
|
|
414
|
+
"parentHash"
|
|
415
|
+
]);
|
|
416
|
+
|
|
417
|
+
let validSvmLogFields = new Set([
|
|
418
|
+
"kind",
|
|
419
|
+
"message"
|
|
420
|
+
]);
|
|
350
421
|
|
|
351
|
-
function
|
|
352
|
-
let
|
|
353
|
-
|
|
422
|
+
function resolveSvmInlineFieldSelection(fields, contractName, eventName) {
|
|
423
|
+
let registration = `the "` + eventName + `" event registration on contract "` + contractName + `"`;
|
|
424
|
+
validateFieldsShapeOrThrow(fields, registration, svmSelectionKinds, "instruction, transaction, accountActivity, block and log");
|
|
425
|
+
let accountActivity = selectionList(fields, "accountActivity");
|
|
426
|
+
let log = selectionList(fields, "log");
|
|
427
|
+
let instructionFields = parseFieldsOrThrow(selectionList(fields, "instruction"), validSvmInstructionFields, "instruction", registration, undefined);
|
|
428
|
+
let transactionFields = parseFieldsOrThrow(selectionList(fields, "transaction"), validSvmTransactionFields, "transaction", registration, undefined);
|
|
429
|
+
let accountActivityFields = parseFieldsOrThrow(accountActivity, validSvmAccountActivityFields, "accountActivity", registration, Stdlib_Option.isSome(accountActivity));
|
|
430
|
+
let blockFields = parseFieldsOrThrow(selectionList(fields, "block"), validSvmBlockFields, "block", registration, undefined);
|
|
431
|
+
let logFields = parseFieldsOrThrow(log, validSvmLogFields, "log", registration, Stdlib_Option.isSome(log));
|
|
432
|
+
Utils.$$Set.addMany(blockFields, alwaysIncludedSvmBlockFields);
|
|
433
|
+
if (accountActivityFields.size > 0) {
|
|
434
|
+
transactionFields.add("accountActivities");
|
|
435
|
+
}
|
|
436
|
+
return Internal.makeFieldSelection(blockFields, transactionFields, Primitive_option.some(instructionFields), Primitive_option.some(accountActivityFields), Primitive_option.some(logFields), Svm.eventBlockFieldMask, Svm.eventTransactionFieldMask);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function buildSvmInstructionEventConfig(contractName, instructionName, programId, discriminator, discriminatorByteLen, accountFilters, isInner, accountsOpt, argsOpt, definedTypesOpt) {
|
|
354
440
|
let accounts = accountsOpt !== undefined ? accountsOpt : [];
|
|
355
441
|
let args = argsOpt !== undefined ? argsOpt : null;
|
|
356
442
|
let definedTypes = definedTypesOpt !== undefined ? definedTypesOpt : null;
|
|
357
443
|
let paramsSchema = Utils.Schema.coerceToJsonPgType(S$RescriptSchema.json(false));
|
|
358
|
-
let fieldSelection = Internal.makeFieldSelection(new Set(alwaysIncludedSvmBlockFields
|
|
444
|
+
let fieldSelection = Internal.makeFieldSelection(new Set(alwaysIncludedSvmBlockFields), new Set(), undefined, undefined, undefined, Svm.eventBlockFieldMask, Svm.eventTransactionFieldMask);
|
|
359
445
|
return {
|
|
360
446
|
id: discriminator !== undefined ? discriminator : "none",
|
|
361
447
|
name: instructionName,
|
|
@@ -366,7 +452,6 @@ function buildSvmInstructionEventConfig(contractName, instructionName, programId
|
|
|
366
452
|
programId: programId,
|
|
367
453
|
discriminator: discriminator,
|
|
368
454
|
discriminatorByteLen: discriminatorByteLen,
|
|
369
|
-
includeLogs: includeLogs,
|
|
370
455
|
accountFilters: accountFilters,
|
|
371
456
|
isInner: isInner,
|
|
372
457
|
accounts: accounts,
|
|
@@ -375,7 +460,7 @@ function buildSvmInstructionEventConfig(contractName, instructionName, programId
|
|
|
375
460
|
};
|
|
376
461
|
}
|
|
377
462
|
|
|
378
|
-
function buildSvmOnEventRegistration(eventConfig, isWildcard, handler, contractRegister, startBlock) {
|
|
463
|
+
function buildSvmOnEventRegistration(eventConfig, isWildcard, handler, contractRegister, fieldSelection, startBlock) {
|
|
379
464
|
return {
|
|
380
465
|
index: -1,
|
|
381
466
|
eventConfig: eventConfig,
|
|
@@ -385,7 +470,7 @@ function buildSvmOnEventRegistration(eventConfig, isWildcard, handler, contractR
|
|
|
385
470
|
filterByAddresses: false,
|
|
386
471
|
dependsOnAddresses: Internal.dependsOnAddresses(isWildcard, false),
|
|
387
472
|
startBlock: startBlock,
|
|
388
|
-
fieldSelection: eventConfig.fieldSelection
|
|
473
|
+
fieldSelection: fieldSelection !== undefined ? fieldSelection : eventConfig.fieldSelection
|
|
389
474
|
};
|
|
390
475
|
}
|
|
391
476
|
|
|
@@ -438,7 +523,7 @@ function buildFuelEventConfig(contractName, eventName, kind, sighash, rawAbi) {
|
|
|
438
523
|
contractName: contractName,
|
|
439
524
|
paramsRawEventSchema: paramsSchema,
|
|
440
525
|
simulateParamsSchema: paramsSchema,
|
|
441
|
-
fieldSelection: Internal.makeFieldSelection(new Set(Fuel.blockFields), new Set(Fuel.transactionFields), Fuel.eventBlockFieldMask, Fuel.eventTransactionFieldMask),
|
|
526
|
+
fieldSelection: Internal.makeFieldSelection(new Set(Fuel.blockFields), new Set(Fuel.transactionFields), undefined, undefined, undefined, Fuel.eventBlockFieldMask, Fuel.eventTransactionFieldMask),
|
|
442
527
|
kind: fuelKind
|
|
443
528
|
};
|
|
444
529
|
}
|
|
@@ -474,8 +559,11 @@ export {
|
|
|
474
559
|
resolveFieldSelection,
|
|
475
560
|
internalBlockFields,
|
|
476
561
|
rawEventBlockFields,
|
|
477
|
-
|
|
562
|
+
evmSelectionKinds,
|
|
563
|
+
svmSelectionKinds,
|
|
564
|
+
quotedJoin,
|
|
478
565
|
validateFieldsShapeOrThrow,
|
|
566
|
+
selectionList,
|
|
479
567
|
validBlockFields,
|
|
480
568
|
validTransactionFields,
|
|
481
569
|
parseFieldsOrThrow,
|
|
@@ -483,6 +571,12 @@ export {
|
|
|
483
571
|
buildEvmEventConfig,
|
|
484
572
|
buildEvmOnEventRegistration,
|
|
485
573
|
alwaysIncludedSvmBlockFields,
|
|
574
|
+
validSvmInstructionFields,
|
|
575
|
+
validSvmTransactionFields,
|
|
576
|
+
validSvmAccountActivityFields,
|
|
577
|
+
validSvmBlockFields,
|
|
578
|
+
validSvmLogFields,
|
|
579
|
+
resolveSvmInlineFieldSelection,
|
|
486
580
|
buildSvmInstructionEventConfig,
|
|
487
581
|
buildSvmOnEventRegistration,
|
|
488
582
|
buildFuelEventConfig,
|