@secondlayer/stacks 6.2.0 → 6.2.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/dist/shared/stacks-esm-b54n1jdx.js.map +4 -4
- package/dist/src/filters/index.cjs.map +4 -4
- package/dist/src/filters/index.d.cts +175 -32
- package/dist/src/filters/index.d.ts +175 -32
- package/dist/src/index.cjs.map +4 -4
- package/dist/src/index.d.cts +147 -15
- package/dist/src/index.d.ts +147 -15
- package/package.json +2 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** The decoded event types. Index and Streams expose the same set. */
|
|
1
2
|
declare const DECODED_EVENT_TYPES: readonly ["stx_transfer", "stx_mint", "stx_burn", "stx_lock", "ft_transfer", "ft_mint", "ft_burn", "nft_transfer", "nft_mint", "nft_burn", "print"];
|
|
2
3
|
type DecodedEventType = (typeof DECODED_EVENT_TYPES)[number];
|
|
3
4
|
/** Opt-in node vm_events, stored names. Parallel to DECODED_EVENT_TYPES — not
|
|
@@ -125,21 +126,22 @@ type Principal = string & {
|
|
|
125
126
|
readonly __principal: unique symbol
|
|
126
127
|
};
|
|
127
128
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
129
|
+
* A fungible or non-fungible asset identifier: `<contract>::<asset-name>`.
|
|
130
|
+
*
|
|
131
|
+
* This is the shape an asset filter takes, expressed so the compiler can check it.
|
|
130
132
|
*
|
|
131
133
|
* The most common mistake in this API is passing a CONTRACT ID
|
|
132
134
|
* (`SP….sbtc-token`) where an asset identifier (`SP….sbtc-token::sbtc-token`)
|
|
133
135
|
* belongs, and the failure mode is a query that quietly returns zero rows. The
|
|
134
136
|
* two differ structurally by `::`, so a template-literal type catches it at the
|
|
135
|
-
* call site
|
|
137
|
+
* call site. No brand, no cast, literals just work.
|
|
136
138
|
*
|
|
137
139
|
* A value that is only known at runtime (config, env) is not narrow enough on
|
|
138
140
|
* purpose; run it through {@link assetId} once, which validates and narrows.
|
|
139
141
|
*
|
|
140
|
-
* Wildcard patterns (Webhooks/Subgraphs-only) are admitted by the second arm
|
|
141
|
-
* are legitimately not full identifiers (`SPB.*`), and the runtime
|
|
142
|
-
* short-circuits on them for the same reason.
|
|
142
|
+
* Wildcard patterns (Webhooks/Subgraphs-only) are admitted by the second arm.
|
|
143
|
+
* They are legitimately not full identifiers (`SPB.*`), and the runtime
|
|
144
|
+
* validator short-circuits on them for the same reason.
|
|
143
145
|
*/
|
|
144
146
|
type AssetIdentifier = `${string}::${string}` | `${string}*${string}`;
|
|
145
147
|
/**
|
|
@@ -153,9 +155,12 @@ declare function assetId(value: string): AssetIdentifier;
|
|
|
153
155
|
* Shares {@link parsePrincipal} with the ABI guards so the two surfaces can't
|
|
154
156
|
* disagree about what a principal is. */
|
|
155
157
|
declare function isPrincipal(value: string): value is Principal;
|
|
156
|
-
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
158
|
+
/**
|
|
159
|
+
* Tells whether a value contains a `*` wildcard.
|
|
160
|
+
*
|
|
161
|
+
* Webhooks and Subgraph sources match `*` wildcards in principal and
|
|
162
|
+
* identifier patterns; every other surface treats the value literally.
|
|
163
|
+
*/
|
|
159
164
|
declare function hasWildcard(value: string): boolean;
|
|
160
165
|
/** Throw unless `value` is a principal or a wildcard pattern. The factories
|
|
161
166
|
* call this so a swapped argument (asset id where a sender belongs, typo'd
|
|
@@ -340,14 +345,18 @@ interface SbtcWithdrawalSweptConfirmedSpec {
|
|
|
340
345
|
sweepTxid?: string;
|
|
341
346
|
}
|
|
342
347
|
type ChainEventFilterSpec = StxTransferSpec | StxMintSpec | StxBurnSpec | StxLockSpec | FtTransferSpec | FtMintSpec | FtBurnSpec | NftTransferSpec | NftMintSpec | NftBurnSpec | ContractCallSpec | ContractDeploySpec | NestedContractCallSpec | VarSetSpec | MapSetSpec | MapInsertSpec | MapDeleteSpec | PrintEventSpec | SbtcDepositSpec | SbtcWithdrawalCreateSpec | SbtcWithdrawalAcceptSpec | SbtcWithdrawalRejectSpec | SbtcWithdrawalSweptConfirmedSpec;
|
|
348
|
+
/** The filter spec for one chain event type. */
|
|
343
349
|
type SpecFor<T extends ChainEventFilterType> = Extract<ChainEventFilterSpec, {
|
|
344
350
|
type: T
|
|
345
351
|
}>;
|
|
346
|
-
/**
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
352
|
+
/**
|
|
353
|
+
* The members you can use as subgraph sources.
|
|
354
|
+
*
|
|
355
|
+
* Everything but the Webhooks-only sBTC lifecycle types. Instantiating
|
|
356
|
+
* `ChainEventFilter<SubgraphMemberType>` keeps `toSubgraphSource` present: the
|
|
357
|
+
* conditional in `ProjectionsFor` evaluates over this whole union
|
|
358
|
+
* (non-distributive at an instantiated site), and every member qualifies.
|
|
359
|
+
*/
|
|
351
360
|
type SubgraphMemberType = Exclude<ChainEventFilterType, `sbtc_${string}`>;
|
|
352
361
|
/** A subgraph-source-shaped filter object (the `toSubgraphSource()` output /
|
|
353
362
|
* `fromSubgraphSource()` input). */
|
|
@@ -428,10 +437,11 @@ type ProjectionsFor<
|
|
|
428
437
|
toSubgraphSource(): S
|
|
429
438
|
} : {});
|
|
430
439
|
/**
|
|
431
|
-
* A
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
* (`
|
|
440
|
+
* A chain-event filter: the spec fields plus its member's projections.
|
|
441
|
+
*
|
|
442
|
+
* Write the filter once; project it to a query (`toIndexParams`), a stream
|
|
443
|
+
* (`toStreamsParams`), a webhook trigger (`toChainTrigger`), or a subgraph
|
|
444
|
+
* source (`toSubgraphSource`).
|
|
435
445
|
*/
|
|
436
446
|
type ChainEventFilter<
|
|
437
447
|
T extends ChainEventFilterType = ChainEventFilterType,
|
|
@@ -439,11 +449,15 @@ type ChainEventFilter<
|
|
|
439
449
|
type: T
|
|
440
450
|
} = SpecFor<T>
|
|
441
451
|
> = S & ProjectionsFor<T, S>;
|
|
442
|
-
/**
|
|
443
|
-
*
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
*
|
|
452
|
+
/**
|
|
453
|
+
* Builds a canonical filter from a member type and its fields.
|
|
454
|
+
*
|
|
455
|
+
* It validates the spec and attaches the projections its member supports.
|
|
456
|
+
* Methods are attached per member at runtime, matching the type-level gating
|
|
457
|
+
* exactly. `const F` preserves field literals, so a `prints` or `abi`
|
|
458
|
+
* declaration keeps its exact type through `toSubgraphSource()`, which is what
|
|
459
|
+
* feeds `defineSubgraph` narrowing.
|
|
460
|
+
*/
|
|
447
461
|
declare function makeChainEventFilter<
|
|
448
462
|
T extends ChainEventFilterType,
|
|
449
463
|
const F extends Omit<SpecFor<T>, "type">
|
|
@@ -451,29 +465,87 @@ declare function makeChainEventFilter<
|
|
|
451
465
|
type: T
|
|
452
466
|
} & F>;
|
|
453
467
|
/**
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
* `f`
|
|
468
|
+
* Rebuilds a canonical filter from a subgraph source object.
|
|
469
|
+
*
|
|
470
|
+
* It is the inverse of `toSubgraphSource`. It powers migration and the
|
|
471
|
+
* round-trip property gate: `toSubgraphSource(fromSubgraphSource(f))` must
|
|
472
|
+
* deep-equal `f` for every production subgraph source.
|
|
458
473
|
*/
|
|
459
474
|
declare function fromSubgraphSource(source: SubgraphSourceSpec): ChainEventFilter<SubgraphMemberType>;
|
|
475
|
+
/** The fields a filter factory takes for one event type, without `type`. */
|
|
460
476
|
type Fields<T extends ChainEventFilterType> = Omit<SpecFor<T>, "type">;
|
|
461
477
|
/** The `on.*` namespace, annotated explicitly — bunup's dts emitter needs an
|
|
462
478
|
* annotation on exported values (an inferred object of generic factories
|
|
463
479
|
* collapses to `{}` in the emitted declarations). */
|
|
464
480
|
interface OnNamespace {
|
|
481
|
+
/**
|
|
482
|
+
* Matches STX transfers.
|
|
483
|
+
*
|
|
484
|
+
* @param fields The members of {@link StxTransferSpec}, without `type`.
|
|
485
|
+
*/
|
|
465
486
|
stxTransfer(fields?: Fields<"stx_transfer">): ChainEventFilter<"stx_transfer">;
|
|
487
|
+
/**
|
|
488
|
+
* Matches STX mints.
|
|
489
|
+
*
|
|
490
|
+
* @param fields The members of {@link StxMintSpec}, without `type`.
|
|
491
|
+
*/
|
|
466
492
|
stxMint(fields?: Fields<"stx_mint">): ChainEventFilter<"stx_mint">;
|
|
493
|
+
/**
|
|
494
|
+
* Matches STX burns.
|
|
495
|
+
*
|
|
496
|
+
* @param fields The members of {@link StxBurnSpec}, without `type`.
|
|
497
|
+
*/
|
|
467
498
|
stxBurn(fields?: Fields<"stx_burn">): ChainEventFilter<"stx_burn">;
|
|
499
|
+
/**
|
|
500
|
+
* Matches STX lock events.
|
|
501
|
+
*
|
|
502
|
+
* @param fields The members of {@link StxLockSpec}, without `type`.
|
|
503
|
+
*/
|
|
468
504
|
stxLock(fields?: Fields<"stx_lock">): ChainEventFilter<"stx_lock">;
|
|
505
|
+
/**
|
|
506
|
+
* Matches fungible token transfers.
|
|
507
|
+
*
|
|
508
|
+
* @param fields The members of {@link FtTransferSpec}, without `type`.
|
|
509
|
+
*/
|
|
469
510
|
ftTransfer(fields?: Fields<"ft_transfer">): ChainEventFilter<"ft_transfer">;
|
|
511
|
+
/**
|
|
512
|
+
* Matches fungible token mints.
|
|
513
|
+
*
|
|
514
|
+
* @param fields The members of {@link FtMintSpec}, without `type`.
|
|
515
|
+
*/
|
|
470
516
|
ftMint(fields?: Fields<"ft_mint">): ChainEventFilter<"ft_mint">;
|
|
517
|
+
/**
|
|
518
|
+
* Matches fungible token burns.
|
|
519
|
+
*
|
|
520
|
+
* @param fields The members of {@link FtBurnSpec}, without `type`.
|
|
521
|
+
*/
|
|
471
522
|
ftBurn(fields?: Fields<"ft_burn">): ChainEventFilter<"ft_burn">;
|
|
523
|
+
/**
|
|
524
|
+
* Matches NFT transfers.
|
|
525
|
+
*
|
|
526
|
+
* @param fields The members of {@link NftTransferSpec}, without `type`.
|
|
527
|
+
*/
|
|
472
528
|
nftTransfer(fields?: Fields<"nft_transfer">): ChainEventFilter<"nft_transfer">;
|
|
529
|
+
/**
|
|
530
|
+
* Matches NFT mints.
|
|
531
|
+
*
|
|
532
|
+
* @param fields The members of {@link NftMintSpec}, without `type`.
|
|
533
|
+
*/
|
|
473
534
|
nftMint(fields?: Fields<"nft_mint">): ChainEventFilter<"nft_mint">;
|
|
535
|
+
/**
|
|
536
|
+
* Matches NFT burns.
|
|
537
|
+
*
|
|
538
|
+
* @param fields The members of {@link NftBurnSpec}, without `type`.
|
|
539
|
+
*/
|
|
474
540
|
nftBurn(fields?: Fields<"nft_burn">): ChainEventFilter<"nft_burn">;
|
|
475
|
-
/**
|
|
476
|
-
*
|
|
541
|
+
/**
|
|
542
|
+
* Matches contract calls.
|
|
543
|
+
*
|
|
544
|
+
* `abi` literals are preserved (`const A`), so `toSubgraphSource()` keeps
|
|
545
|
+
* typing `event.input` inside `defineSubgraph`.
|
|
546
|
+
*
|
|
547
|
+
* @param fields The members of {@link ContractCallSpec}, without `type`.
|
|
548
|
+
*/
|
|
477
549
|
contractCall<const A extends AbiContract | undefined = undefined>(fields?: Omit<SpecFor<"contract_call">, "type" | "abi"> & {
|
|
478
550
|
abi?: A
|
|
479
551
|
}): ChainEventFilter<"contract_call", {
|
|
@@ -481,10 +553,21 @@ interface OnNamespace {
|
|
|
481
553
|
} & Omit<SpecFor<"contract_call">, "type" | "abi"> & {
|
|
482
554
|
abi?: A
|
|
483
555
|
}>;
|
|
556
|
+
/**
|
|
557
|
+
* Matches contract deployments.
|
|
558
|
+
*
|
|
559
|
+
* @param fields The members of {@link ContractDeploySpec}, without `type`.
|
|
560
|
+
*/
|
|
484
561
|
contractDeploy(fields?: Fields<"contract_deploy">): ChainEventFilter<"contract_deploy">;
|
|
485
|
-
/**
|
|
486
|
-
*
|
|
487
|
-
*
|
|
562
|
+
/**
|
|
563
|
+
* Matches `print` events.
|
|
564
|
+
*
|
|
565
|
+
* The canonical member is `print_event`, as Subgraphs and Webhooks spell it;
|
|
566
|
+
* `toIndexParams` and `toStreamsParams` project to `print`. `prints` literals
|
|
567
|
+
* are preserved (`const P`), so `event.data` narrows per topic.
|
|
568
|
+
*
|
|
569
|
+
* @param fields The members of {@link PrintEventSpec}, without `type`.
|
|
570
|
+
*/
|
|
488
571
|
print<const P extends Record<string, Record<string, PrintFieldType>> | undefined = undefined>(fields?: Omit<SpecFor<"print_event">, "type" | "prints"> & {
|
|
489
572
|
prints?: P
|
|
490
573
|
}): ChainEventFilter<"print_event", {
|
|
@@ -492,15 +575,75 @@ interface OnNamespace {
|
|
|
492
575
|
} & Omit<SpecFor<"print_event">, "type" | "prints"> & {
|
|
493
576
|
prints?: P
|
|
494
577
|
}>;
|
|
578
|
+
/**
|
|
579
|
+
* Matches contract calls made from inside another contract.
|
|
580
|
+
*
|
|
581
|
+
* @param fields The members of {@link NestedContractCallSpec}, without `type`.
|
|
582
|
+
*/
|
|
495
583
|
nestedCall(fields?: Fields<"nested_contract_call">): ChainEventFilter<"nested_contract_call">;
|
|
584
|
+
/**
|
|
585
|
+
* Matches data variable writes.
|
|
586
|
+
*
|
|
587
|
+
* @param fields The members of {@link VarSetSpec}, without `type`.
|
|
588
|
+
*/
|
|
496
589
|
varSet(fields?: Fields<"var_set">): ChainEventFilter<"var_set">;
|
|
590
|
+
/**
|
|
591
|
+
* Matches `map-set` writes.
|
|
592
|
+
*
|
|
593
|
+
* @param fields The members of {@link MapSetSpec}, without `type`.
|
|
594
|
+
*/
|
|
497
595
|
mapSet(fields?: Fields<"map_set">): ChainEventFilter<"map_set">;
|
|
596
|
+
/**
|
|
597
|
+
* Matches `map-insert` writes.
|
|
598
|
+
*
|
|
599
|
+
* @param fields The members of {@link MapInsertSpec}, without `type`.
|
|
600
|
+
*/
|
|
498
601
|
mapInsert(fields?: Fields<"map_insert">): ChainEventFilter<"map_insert">;
|
|
602
|
+
/**
|
|
603
|
+
* Matches `map-delete` writes.
|
|
604
|
+
*
|
|
605
|
+
* @param fields The members of {@link MapDeleteSpec}, without `type`.
|
|
606
|
+
*/
|
|
499
607
|
mapDelete(fields?: Fields<"map_delete">): ChainEventFilter<"map_delete">;
|
|
608
|
+
/**
|
|
609
|
+
* Matches sBTC deposits.
|
|
610
|
+
*
|
|
611
|
+
* Webhooks only: it has no Index, Streams or subgraph projection.
|
|
612
|
+
*
|
|
613
|
+
* @param fields The members of {@link SbtcDepositSpec}, without `type`.
|
|
614
|
+
*/
|
|
500
615
|
sbtcDeposit(fields?: Fields<"sbtc_deposit">): ChainEventFilter<"sbtc_deposit">;
|
|
616
|
+
/**
|
|
617
|
+
* Matches sBTC withdrawal requests.
|
|
618
|
+
*
|
|
619
|
+
* Webhooks only: it has no Index, Streams or subgraph projection.
|
|
620
|
+
*
|
|
621
|
+
* @param fields The members of {@link SbtcWithdrawalCreateSpec}, without `type`.
|
|
622
|
+
*/
|
|
501
623
|
sbtcWithdrawalCreate(fields?: Fields<"sbtc_withdrawal_create">): ChainEventFilter<"sbtc_withdrawal_create">;
|
|
624
|
+
/**
|
|
625
|
+
* Matches accepted sBTC withdrawals.
|
|
626
|
+
*
|
|
627
|
+
* Webhooks only: it has no Index, Streams or subgraph projection.
|
|
628
|
+
*
|
|
629
|
+
* @param fields The members of {@link SbtcWithdrawalAcceptSpec}, without `type`.
|
|
630
|
+
*/
|
|
502
631
|
sbtcWithdrawalAccept(fields?: Fields<"sbtc_withdrawal_accept">): ChainEventFilter<"sbtc_withdrawal_accept">;
|
|
632
|
+
/**
|
|
633
|
+
* Matches rejected sBTC withdrawals.
|
|
634
|
+
*
|
|
635
|
+
* Webhooks only: it has no Index, Streams or subgraph projection.
|
|
636
|
+
*
|
|
637
|
+
* @param fields The members of {@link SbtcWithdrawalRejectSpec}, without `type`.
|
|
638
|
+
*/
|
|
503
639
|
sbtcWithdrawalReject(fields?: Fields<"sbtc_withdrawal_reject">): ChainEventFilter<"sbtc_withdrawal_reject">;
|
|
640
|
+
/**
|
|
641
|
+
* Matches sBTC withdrawals whose sweep has confirmed.
|
|
642
|
+
*
|
|
643
|
+
* Webhooks only: it has no Index, Streams or subgraph projection.
|
|
644
|
+
*
|
|
645
|
+
* @param fields The members of {@link SbtcWithdrawalSweptConfirmedSpec}, without `type`.
|
|
646
|
+
*/
|
|
504
647
|
sbtcWithdrawalSweptConfirmed(fields?: Fields<"sbtc_withdrawal_swept_confirmed">): ChainEventFilter<"sbtc_withdrawal_swept_confirmed">;
|
|
505
648
|
}
|
|
506
649
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** The decoded event types. Index and Streams expose the same set. */
|
|
1
2
|
declare const DECODED_EVENT_TYPES: readonly ["stx_transfer", "stx_mint", "stx_burn", "stx_lock", "ft_transfer", "ft_mint", "ft_burn", "nft_transfer", "nft_mint", "nft_burn", "print"];
|
|
2
3
|
type DecodedEventType = (typeof DECODED_EVENT_TYPES)[number];
|
|
3
4
|
/** Opt-in node vm_events, stored names. Parallel to DECODED_EVENT_TYPES — not
|
|
@@ -125,21 +126,22 @@ type Principal = string & {
|
|
|
125
126
|
readonly __principal: unique symbol
|
|
126
127
|
};
|
|
127
128
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
129
|
+
* A fungible or non-fungible asset identifier: `<contract>::<asset-name>`.
|
|
130
|
+
*
|
|
131
|
+
* This is the shape an asset filter takes, expressed so the compiler can check it.
|
|
130
132
|
*
|
|
131
133
|
* The most common mistake in this API is passing a CONTRACT ID
|
|
132
134
|
* (`SP….sbtc-token`) where an asset identifier (`SP….sbtc-token::sbtc-token`)
|
|
133
135
|
* belongs, and the failure mode is a query that quietly returns zero rows. The
|
|
134
136
|
* two differ structurally by `::`, so a template-literal type catches it at the
|
|
135
|
-
* call site
|
|
137
|
+
* call site. No brand, no cast, literals just work.
|
|
136
138
|
*
|
|
137
139
|
* A value that is only known at runtime (config, env) is not narrow enough on
|
|
138
140
|
* purpose; run it through {@link assetId} once, which validates and narrows.
|
|
139
141
|
*
|
|
140
|
-
* Wildcard patterns (Webhooks/Subgraphs-only) are admitted by the second arm
|
|
141
|
-
* are legitimately not full identifiers (`SPB.*`), and the runtime
|
|
142
|
-
* short-circuits on them for the same reason.
|
|
142
|
+
* Wildcard patterns (Webhooks/Subgraphs-only) are admitted by the second arm.
|
|
143
|
+
* They are legitimately not full identifiers (`SPB.*`), and the runtime
|
|
144
|
+
* validator short-circuits on them for the same reason.
|
|
143
145
|
*/
|
|
144
146
|
type AssetIdentifier = `${string}::${string}` | `${string}*${string}`;
|
|
145
147
|
/**
|
|
@@ -153,9 +155,12 @@ declare function assetId(value: string): AssetIdentifier;
|
|
|
153
155
|
* Shares {@link parsePrincipal} with the ABI guards so the two surfaces can't
|
|
154
156
|
* disagree about what a principal is. */
|
|
155
157
|
declare function isPrincipal(value: string): value is Principal;
|
|
156
|
-
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
158
|
+
/**
|
|
159
|
+
* Tells whether a value contains a `*` wildcard.
|
|
160
|
+
*
|
|
161
|
+
* Webhooks and Subgraph sources match `*` wildcards in principal and
|
|
162
|
+
* identifier patterns; every other surface treats the value literally.
|
|
163
|
+
*/
|
|
159
164
|
declare function hasWildcard(value: string): boolean;
|
|
160
165
|
/** Throw unless `value` is a principal or a wildcard pattern. The factories
|
|
161
166
|
* call this so a swapped argument (asset id where a sender belongs, typo'd
|
|
@@ -340,14 +345,18 @@ interface SbtcWithdrawalSweptConfirmedSpec {
|
|
|
340
345
|
sweepTxid?: string;
|
|
341
346
|
}
|
|
342
347
|
type ChainEventFilterSpec = StxTransferSpec | StxMintSpec | StxBurnSpec | StxLockSpec | FtTransferSpec | FtMintSpec | FtBurnSpec | NftTransferSpec | NftMintSpec | NftBurnSpec | ContractCallSpec | ContractDeploySpec | NestedContractCallSpec | VarSetSpec | MapSetSpec | MapInsertSpec | MapDeleteSpec | PrintEventSpec | SbtcDepositSpec | SbtcWithdrawalCreateSpec | SbtcWithdrawalAcceptSpec | SbtcWithdrawalRejectSpec | SbtcWithdrawalSweptConfirmedSpec;
|
|
348
|
+
/** The filter spec for one chain event type. */
|
|
343
349
|
type SpecFor<T extends ChainEventFilterType> = Extract<ChainEventFilterSpec, {
|
|
344
350
|
type: T
|
|
345
351
|
}>;
|
|
346
|
-
/**
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
352
|
+
/**
|
|
353
|
+
* The members you can use as subgraph sources.
|
|
354
|
+
*
|
|
355
|
+
* Everything but the Webhooks-only sBTC lifecycle types. Instantiating
|
|
356
|
+
* `ChainEventFilter<SubgraphMemberType>` keeps `toSubgraphSource` present: the
|
|
357
|
+
* conditional in `ProjectionsFor` evaluates over this whole union
|
|
358
|
+
* (non-distributive at an instantiated site), and every member qualifies.
|
|
359
|
+
*/
|
|
351
360
|
type SubgraphMemberType = Exclude<ChainEventFilterType, `sbtc_${string}`>;
|
|
352
361
|
/** A subgraph-source-shaped filter object (the `toSubgraphSource()` output /
|
|
353
362
|
* `fromSubgraphSource()` input). */
|
|
@@ -428,10 +437,11 @@ type ProjectionsFor<
|
|
|
428
437
|
toSubgraphSource(): S
|
|
429
438
|
} : {});
|
|
430
439
|
/**
|
|
431
|
-
* A
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
* (`
|
|
440
|
+
* A chain-event filter: the spec fields plus its member's projections.
|
|
441
|
+
*
|
|
442
|
+
* Write the filter once; project it to a query (`toIndexParams`), a stream
|
|
443
|
+
* (`toStreamsParams`), a webhook trigger (`toChainTrigger`), or a subgraph
|
|
444
|
+
* source (`toSubgraphSource`).
|
|
435
445
|
*/
|
|
436
446
|
type ChainEventFilter<
|
|
437
447
|
T extends ChainEventFilterType = ChainEventFilterType,
|
|
@@ -439,11 +449,15 @@ type ChainEventFilter<
|
|
|
439
449
|
type: T
|
|
440
450
|
} = SpecFor<T>
|
|
441
451
|
> = S & ProjectionsFor<T, S>;
|
|
442
|
-
/**
|
|
443
|
-
*
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
*
|
|
452
|
+
/**
|
|
453
|
+
* Builds a canonical filter from a member type and its fields.
|
|
454
|
+
*
|
|
455
|
+
* It validates the spec and attaches the projections its member supports.
|
|
456
|
+
* Methods are attached per member at runtime, matching the type-level gating
|
|
457
|
+
* exactly. `const F` preserves field literals, so a `prints` or `abi`
|
|
458
|
+
* declaration keeps its exact type through `toSubgraphSource()`, which is what
|
|
459
|
+
* feeds `defineSubgraph` narrowing.
|
|
460
|
+
*/
|
|
447
461
|
declare function makeChainEventFilter<
|
|
448
462
|
T extends ChainEventFilterType,
|
|
449
463
|
const F extends Omit<SpecFor<T>, "type">
|
|
@@ -451,29 +465,87 @@ declare function makeChainEventFilter<
|
|
|
451
465
|
type: T
|
|
452
466
|
} & F>;
|
|
453
467
|
/**
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
* `f`
|
|
468
|
+
* Rebuilds a canonical filter from a subgraph source object.
|
|
469
|
+
*
|
|
470
|
+
* It is the inverse of `toSubgraphSource`. It powers migration and the
|
|
471
|
+
* round-trip property gate: `toSubgraphSource(fromSubgraphSource(f))` must
|
|
472
|
+
* deep-equal `f` for every production subgraph source.
|
|
458
473
|
*/
|
|
459
474
|
declare function fromSubgraphSource(source: SubgraphSourceSpec): ChainEventFilter<SubgraphMemberType>;
|
|
475
|
+
/** The fields a filter factory takes for one event type, without `type`. */
|
|
460
476
|
type Fields<T extends ChainEventFilterType> = Omit<SpecFor<T>, "type">;
|
|
461
477
|
/** The `on.*` namespace, annotated explicitly — bunup's dts emitter needs an
|
|
462
478
|
* annotation on exported values (an inferred object of generic factories
|
|
463
479
|
* collapses to `{}` in the emitted declarations). */
|
|
464
480
|
interface OnNamespace {
|
|
481
|
+
/**
|
|
482
|
+
* Matches STX transfers.
|
|
483
|
+
*
|
|
484
|
+
* @param fields The members of {@link StxTransferSpec}, without `type`.
|
|
485
|
+
*/
|
|
465
486
|
stxTransfer(fields?: Fields<"stx_transfer">): ChainEventFilter<"stx_transfer">;
|
|
487
|
+
/**
|
|
488
|
+
* Matches STX mints.
|
|
489
|
+
*
|
|
490
|
+
* @param fields The members of {@link StxMintSpec}, without `type`.
|
|
491
|
+
*/
|
|
466
492
|
stxMint(fields?: Fields<"stx_mint">): ChainEventFilter<"stx_mint">;
|
|
493
|
+
/**
|
|
494
|
+
* Matches STX burns.
|
|
495
|
+
*
|
|
496
|
+
* @param fields The members of {@link StxBurnSpec}, without `type`.
|
|
497
|
+
*/
|
|
467
498
|
stxBurn(fields?: Fields<"stx_burn">): ChainEventFilter<"stx_burn">;
|
|
499
|
+
/**
|
|
500
|
+
* Matches STX lock events.
|
|
501
|
+
*
|
|
502
|
+
* @param fields The members of {@link StxLockSpec}, without `type`.
|
|
503
|
+
*/
|
|
468
504
|
stxLock(fields?: Fields<"stx_lock">): ChainEventFilter<"stx_lock">;
|
|
505
|
+
/**
|
|
506
|
+
* Matches fungible token transfers.
|
|
507
|
+
*
|
|
508
|
+
* @param fields The members of {@link FtTransferSpec}, without `type`.
|
|
509
|
+
*/
|
|
469
510
|
ftTransfer(fields?: Fields<"ft_transfer">): ChainEventFilter<"ft_transfer">;
|
|
511
|
+
/**
|
|
512
|
+
* Matches fungible token mints.
|
|
513
|
+
*
|
|
514
|
+
* @param fields The members of {@link FtMintSpec}, without `type`.
|
|
515
|
+
*/
|
|
470
516
|
ftMint(fields?: Fields<"ft_mint">): ChainEventFilter<"ft_mint">;
|
|
517
|
+
/**
|
|
518
|
+
* Matches fungible token burns.
|
|
519
|
+
*
|
|
520
|
+
* @param fields The members of {@link FtBurnSpec}, without `type`.
|
|
521
|
+
*/
|
|
471
522
|
ftBurn(fields?: Fields<"ft_burn">): ChainEventFilter<"ft_burn">;
|
|
523
|
+
/**
|
|
524
|
+
* Matches NFT transfers.
|
|
525
|
+
*
|
|
526
|
+
* @param fields The members of {@link NftTransferSpec}, without `type`.
|
|
527
|
+
*/
|
|
472
528
|
nftTransfer(fields?: Fields<"nft_transfer">): ChainEventFilter<"nft_transfer">;
|
|
529
|
+
/**
|
|
530
|
+
* Matches NFT mints.
|
|
531
|
+
*
|
|
532
|
+
* @param fields The members of {@link NftMintSpec}, without `type`.
|
|
533
|
+
*/
|
|
473
534
|
nftMint(fields?: Fields<"nft_mint">): ChainEventFilter<"nft_mint">;
|
|
535
|
+
/**
|
|
536
|
+
* Matches NFT burns.
|
|
537
|
+
*
|
|
538
|
+
* @param fields The members of {@link NftBurnSpec}, without `type`.
|
|
539
|
+
*/
|
|
474
540
|
nftBurn(fields?: Fields<"nft_burn">): ChainEventFilter<"nft_burn">;
|
|
475
|
-
/**
|
|
476
|
-
*
|
|
541
|
+
/**
|
|
542
|
+
* Matches contract calls.
|
|
543
|
+
*
|
|
544
|
+
* `abi` literals are preserved (`const A`), so `toSubgraphSource()` keeps
|
|
545
|
+
* typing `event.input` inside `defineSubgraph`.
|
|
546
|
+
*
|
|
547
|
+
* @param fields The members of {@link ContractCallSpec}, without `type`.
|
|
548
|
+
*/
|
|
477
549
|
contractCall<const A extends AbiContract | undefined = undefined>(fields?: Omit<SpecFor<"contract_call">, "type" | "abi"> & {
|
|
478
550
|
abi?: A
|
|
479
551
|
}): ChainEventFilter<"contract_call", {
|
|
@@ -481,10 +553,21 @@ interface OnNamespace {
|
|
|
481
553
|
} & Omit<SpecFor<"contract_call">, "type" | "abi"> & {
|
|
482
554
|
abi?: A
|
|
483
555
|
}>;
|
|
556
|
+
/**
|
|
557
|
+
* Matches contract deployments.
|
|
558
|
+
*
|
|
559
|
+
* @param fields The members of {@link ContractDeploySpec}, without `type`.
|
|
560
|
+
*/
|
|
484
561
|
contractDeploy(fields?: Fields<"contract_deploy">): ChainEventFilter<"contract_deploy">;
|
|
485
|
-
/**
|
|
486
|
-
*
|
|
487
|
-
*
|
|
562
|
+
/**
|
|
563
|
+
* Matches `print` events.
|
|
564
|
+
*
|
|
565
|
+
* The canonical member is `print_event`, as Subgraphs and Webhooks spell it;
|
|
566
|
+
* `toIndexParams` and `toStreamsParams` project to `print`. `prints` literals
|
|
567
|
+
* are preserved (`const P`), so `event.data` narrows per topic.
|
|
568
|
+
*
|
|
569
|
+
* @param fields The members of {@link PrintEventSpec}, without `type`.
|
|
570
|
+
*/
|
|
488
571
|
print<const P extends Record<string, Record<string, PrintFieldType>> | undefined = undefined>(fields?: Omit<SpecFor<"print_event">, "type" | "prints"> & {
|
|
489
572
|
prints?: P
|
|
490
573
|
}): ChainEventFilter<"print_event", {
|
|
@@ -492,15 +575,75 @@ interface OnNamespace {
|
|
|
492
575
|
} & Omit<SpecFor<"print_event">, "type" | "prints"> & {
|
|
493
576
|
prints?: P
|
|
494
577
|
}>;
|
|
578
|
+
/**
|
|
579
|
+
* Matches contract calls made from inside another contract.
|
|
580
|
+
*
|
|
581
|
+
* @param fields The members of {@link NestedContractCallSpec}, without `type`.
|
|
582
|
+
*/
|
|
495
583
|
nestedCall(fields?: Fields<"nested_contract_call">): ChainEventFilter<"nested_contract_call">;
|
|
584
|
+
/**
|
|
585
|
+
* Matches data variable writes.
|
|
586
|
+
*
|
|
587
|
+
* @param fields The members of {@link VarSetSpec}, without `type`.
|
|
588
|
+
*/
|
|
496
589
|
varSet(fields?: Fields<"var_set">): ChainEventFilter<"var_set">;
|
|
590
|
+
/**
|
|
591
|
+
* Matches `map-set` writes.
|
|
592
|
+
*
|
|
593
|
+
* @param fields The members of {@link MapSetSpec}, without `type`.
|
|
594
|
+
*/
|
|
497
595
|
mapSet(fields?: Fields<"map_set">): ChainEventFilter<"map_set">;
|
|
596
|
+
/**
|
|
597
|
+
* Matches `map-insert` writes.
|
|
598
|
+
*
|
|
599
|
+
* @param fields The members of {@link MapInsertSpec}, without `type`.
|
|
600
|
+
*/
|
|
498
601
|
mapInsert(fields?: Fields<"map_insert">): ChainEventFilter<"map_insert">;
|
|
602
|
+
/**
|
|
603
|
+
* Matches `map-delete` writes.
|
|
604
|
+
*
|
|
605
|
+
* @param fields The members of {@link MapDeleteSpec}, without `type`.
|
|
606
|
+
*/
|
|
499
607
|
mapDelete(fields?: Fields<"map_delete">): ChainEventFilter<"map_delete">;
|
|
608
|
+
/**
|
|
609
|
+
* Matches sBTC deposits.
|
|
610
|
+
*
|
|
611
|
+
* Webhooks only: it has no Index, Streams or subgraph projection.
|
|
612
|
+
*
|
|
613
|
+
* @param fields The members of {@link SbtcDepositSpec}, without `type`.
|
|
614
|
+
*/
|
|
500
615
|
sbtcDeposit(fields?: Fields<"sbtc_deposit">): ChainEventFilter<"sbtc_deposit">;
|
|
616
|
+
/**
|
|
617
|
+
* Matches sBTC withdrawal requests.
|
|
618
|
+
*
|
|
619
|
+
* Webhooks only: it has no Index, Streams or subgraph projection.
|
|
620
|
+
*
|
|
621
|
+
* @param fields The members of {@link SbtcWithdrawalCreateSpec}, without `type`.
|
|
622
|
+
*/
|
|
501
623
|
sbtcWithdrawalCreate(fields?: Fields<"sbtc_withdrawal_create">): ChainEventFilter<"sbtc_withdrawal_create">;
|
|
624
|
+
/**
|
|
625
|
+
* Matches accepted sBTC withdrawals.
|
|
626
|
+
*
|
|
627
|
+
* Webhooks only: it has no Index, Streams or subgraph projection.
|
|
628
|
+
*
|
|
629
|
+
* @param fields The members of {@link SbtcWithdrawalAcceptSpec}, without `type`.
|
|
630
|
+
*/
|
|
502
631
|
sbtcWithdrawalAccept(fields?: Fields<"sbtc_withdrawal_accept">): ChainEventFilter<"sbtc_withdrawal_accept">;
|
|
632
|
+
/**
|
|
633
|
+
* Matches rejected sBTC withdrawals.
|
|
634
|
+
*
|
|
635
|
+
* Webhooks only: it has no Index, Streams or subgraph projection.
|
|
636
|
+
*
|
|
637
|
+
* @param fields The members of {@link SbtcWithdrawalRejectSpec}, without `type`.
|
|
638
|
+
*/
|
|
503
639
|
sbtcWithdrawalReject(fields?: Fields<"sbtc_withdrawal_reject">): ChainEventFilter<"sbtc_withdrawal_reject">;
|
|
640
|
+
/**
|
|
641
|
+
* Matches sBTC withdrawals whose sweep has confirmed.
|
|
642
|
+
*
|
|
643
|
+
* Webhooks only: it has no Index, Streams or subgraph projection.
|
|
644
|
+
*
|
|
645
|
+
* @param fields The members of {@link SbtcWithdrawalSweptConfirmedSpec}, without `type`.
|
|
646
|
+
*/
|
|
504
647
|
sbtcWithdrawalSweptConfirmed(fields?: Fields<"sbtc_withdrawal_swept_confirmed">): ChainEventFilter<"sbtc_withdrawal_swept_confirmed">;
|
|
505
648
|
}
|
|
506
649
|
/**
|