@secondlayer/shared 6.37.1 → 6.39.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/dist/src/db/index.d.ts +29 -1
- package/dist/src/db/index.js +2 -1
- package/dist/src/db/index.js.map +3 -3
- package/dist/src/db/queries/chain-reorgs.d.ts +27 -0
- package/dist/src/db/queries/chain-reorgs.js +2 -1
- package/dist/src/db/queries/chain-reorgs.js.map +3 -3
- package/dist/src/db/queries/contracts.d.ts +27 -0
- package/dist/src/db/queries/integrity.d.ts +27 -0
- package/dist/src/db/queries/subgraph-gaps.d.ts +27 -0
- package/dist/src/db/queries/subgraph-operations.d.ts +27 -0
- package/dist/src/db/queries/subgraphs.d.ts +27 -0
- package/dist/src/db/queries/subgraphs.js +2 -1
- package/dist/src/db/queries/subgraphs.js.map +3 -3
- package/dist/src/db/queries/subscriptions.d.ts +27 -0
- package/dist/src/db/schema.d.ts +28 -1
- package/dist/src/index.d.ts +233 -5
- package/dist/src/index.js +13 -2
- package/dist/src/index.js.map +4 -4
- package/dist/src/node/local-client.d.ts +27 -0
- package/dist/src/schemas/index.d.ts +5 -1
- package/dist/src/schemas/index.js +12 -2
- package/dist/src/schemas/index.js.map +3 -3
- package/dist/src/schemas/subscriptions.d.ts +6 -1
- package/dist/src/schemas/subscriptions.js +12 -2
- package/dist/src/schemas/subscriptions.js.map +3 -3
- package/migrations/0104_sbtc_settlements.ts +57 -0
- package/migrations/0105_settlement_scan_cursor.ts +31 -0
- package/package.json +1 -1
package/dist/src/db/schema.d.ts
CHANGED
|
@@ -518,6 +518,29 @@ interface SbtcTokenEventsTable {
|
|
|
518
518
|
source_cursor: string;
|
|
519
519
|
created_at: Generated<Date>;
|
|
520
520
|
}
|
|
521
|
+
/**
|
|
522
|
+
* BTC L1 settlement status for sBTC withdrawal sweeps. Filled by the indexer's
|
|
523
|
+
* settlement-confirmer worker, which polls our own bitcoind for confirmations of
|
|
524
|
+
* each `withdrawal-accept`'s `sweep_txid` and surfaces real settlement on the
|
|
525
|
+
* withdrawal lifecycle (the API's `settlement.{btc_confirmations,
|
|
526
|
+
* settlement_confirmed}` placeholder). Keyed on `sweep_txid` (not `request_id`):
|
|
527
|
+
* a request can produce more than one sweep over its life (RBF/rebroadcast), so
|
|
528
|
+
* each broadcast keeps its own confirmation history.
|
|
529
|
+
*/
|
|
530
|
+
interface SbtcSettlementsTable {
|
|
531
|
+
sweep_txid: string;
|
|
532
|
+
request_id: number;
|
|
533
|
+
btc_confirmations: Generated<number>;
|
|
534
|
+
settlement_confirmed: Generated<boolean>;
|
|
535
|
+
/** Confirming Bitcoin block — null while the sweep is unconfirmed. */
|
|
536
|
+
block_hash: string | null;
|
|
537
|
+
block_height: number | null;
|
|
538
|
+
first_seen_at: Generated<Date>;
|
|
539
|
+
last_checked_at: Generated<Date>;
|
|
540
|
+
/** Set once, when `settlement_confirmed` first flips true. */
|
|
541
|
+
confirmed_at: Date | null;
|
|
542
|
+
updated_at: Generated<Date>;
|
|
543
|
+
}
|
|
521
544
|
interface SbtcSupplySnapshotsTable {
|
|
522
545
|
date: string;
|
|
523
546
|
total_supply: Generated<string>;
|
|
@@ -665,6 +688,7 @@ interface Database {
|
|
|
665
688
|
burn_block_reward_slots: BurnBlockRewardSlotsTable;
|
|
666
689
|
sbtc_events: SbtcEventsTable;
|
|
667
690
|
sbtc_token_events: SbtcTokenEventsTable;
|
|
691
|
+
sbtc_settlements: SbtcSettlementsTable;
|
|
668
692
|
sbtc_supply_snapshots: SbtcSupplySnapshotsTable;
|
|
669
693
|
bns_name_events: BnsNameEventsTable;
|
|
670
694
|
bns_namespace_events: BnsNamespaceEventsTable;
|
|
@@ -955,7 +979,10 @@ type InsertSubscriptionDelivery = Insertable<SubscriptionDeliveriesTable>;
|
|
|
955
979
|
interface TriggerEvaluatorStateTable {
|
|
956
980
|
id: Generated<boolean>;
|
|
957
981
|
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
982
|
+
/** Watermark for the async sBTC settlement-confirmed webhook scan; null until
|
|
983
|
+
* the evaluator fast-forwards it on first run. */
|
|
984
|
+
last_settlement_scan_at: ColumnType<Date | null, Date | null | undefined, Date | null>;
|
|
958
985
|
updated_at: Generated<Date>;
|
|
959
986
|
}
|
|
960
987
|
type TriggerEvaluatorState = Selectable<TriggerEvaluatorStateTable>;
|
|
961
|
-
export { X402PaymentsTable, X402BalancesTable, UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateTransaction, UpdateTenantUsageMonthly, UpdateTenantComputeAddon, UpdateTenant, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraphOperation, UpdateSubgraph, UpdateProject, UpdateIndexProgress, UpdateEvent, UpdateContract, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, UpdateAccountCredits, TriggerEvaluatorStateTable, TriggerEvaluatorState, TransactionsTable, TransactionsArchiveTable, Transaction, TenantsTable, TenantUsageMonthlyTable, TenantUsageMonthly, TenantStatus, TenantComputeAddonsTable, TenantComputeAddon, Tenant, TeamMembersTable, TeamMember, TeamInvitationsTable, TeamInvitation, SubscriptionsTable, SubscriptionStatus, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionKind, SubscriptionFormat, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphUsageDailyTable, SubgraphUsageDaily, SubgraphTableSnapshotsTable, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGap, Subgraph, SessionsTable, Session, ServiceHeartbeatsTable, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcEventsTable, SbtcEventTopic, ProvisioningAuditStatus, ProvisioningAuditLogTable, ProvisioningAuditLog, ProvisioningAuditEvent, ProjectsTable, Project, ProcessedStripeEventsTable, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, OutboxStatus, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, InsertTransaction, InsertTenantUsageMonthly, InsertTenantComputeAddon, InsertTenant, InsertTeamMember, InsertTeamInvitation, InsertSubscriptionOutbox, InsertSubscriptionDelivery, InsertSubscription, InsertSubgraphUsageDaily, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertProvisioningAuditLog, InsertProject, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertEvent, InsertContract, InsertClaimToken, InsertBlock, InsertApiKey, InsertAccountSpendCap, InsertAccountInsight, InsertAccountCredits, InsertAccountAgentRun, InsertAccount, IndexProgressTable, IndexProgress, EventsTable, EventsArchiveTable, Event, DecoderCheckpointsTable, DecodedEventsTable, DeadLetterEventsTable, Database, ContractsTable, Contract, ClaimTokensTable, ClaimToken, ChainReorgsTable, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountInsightsTable, AccountInsight, AccountCreditsTable, AccountCredits, AccountAgentRunsTable, AccountAgentRun, Account };
|
|
988
|
+
export { X402PaymentsTable, X402BalancesTable, UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateTransaction, UpdateTenantUsageMonthly, UpdateTenantComputeAddon, UpdateTenant, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraphOperation, UpdateSubgraph, UpdateProject, UpdateIndexProgress, UpdateEvent, UpdateContract, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, UpdateAccountCredits, TriggerEvaluatorStateTable, TriggerEvaluatorState, TransactionsTable, TransactionsArchiveTable, Transaction, TenantsTable, TenantUsageMonthlyTable, TenantUsageMonthly, TenantStatus, TenantComputeAddonsTable, TenantComputeAddon, Tenant, TeamMembersTable, TeamMember, TeamInvitationsTable, TeamInvitation, SubscriptionsTable, SubscriptionStatus, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionKind, SubscriptionFormat, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphUsageDailyTable, SubgraphUsageDaily, SubgraphTableSnapshotsTable, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGap, Subgraph, SessionsTable, Session, ServiceHeartbeatsTable, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcSettlementsTable, SbtcEventsTable, SbtcEventTopic, ProvisioningAuditStatus, ProvisioningAuditLogTable, ProvisioningAuditLog, ProvisioningAuditEvent, ProjectsTable, Project, ProcessedStripeEventsTable, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, OutboxStatus, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, InsertTransaction, InsertTenantUsageMonthly, InsertTenantComputeAddon, InsertTenant, InsertTeamMember, InsertTeamInvitation, InsertSubscriptionOutbox, InsertSubscriptionDelivery, InsertSubscription, InsertSubgraphUsageDaily, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertProvisioningAuditLog, InsertProject, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertEvent, InsertContract, InsertClaimToken, InsertBlock, InsertApiKey, InsertAccountSpendCap, InsertAccountInsight, InsertAccountCredits, InsertAccountAgentRun, InsertAccount, IndexProgressTable, IndexProgress, EventsTable, EventsArchiveTable, Event, DecoderCheckpointsTable, DecodedEventsTable, DeadLetterEventsTable, Database, ContractsTable, Contract, ClaimTokensTable, ClaimToken, ChainReorgsTable, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountInsightsTable, AccountInsight, AccountCreditsTable, AccountCredits, AccountAgentRunsTable, AccountAgentRun, Account };
|
package/dist/src/index.d.ts
CHANGED
|
@@ -518,6 +518,29 @@ interface SbtcTokenEventsTable {
|
|
|
518
518
|
source_cursor: string;
|
|
519
519
|
created_at: Generated<Date>;
|
|
520
520
|
}
|
|
521
|
+
/**
|
|
522
|
+
* BTC L1 settlement status for sBTC withdrawal sweeps. Filled by the indexer's
|
|
523
|
+
* settlement-confirmer worker, which polls our own bitcoind for confirmations of
|
|
524
|
+
* each `withdrawal-accept`'s `sweep_txid` and surfaces real settlement on the
|
|
525
|
+
* withdrawal lifecycle (the API's `settlement.{btc_confirmations,
|
|
526
|
+
* settlement_confirmed}` placeholder). Keyed on `sweep_txid` (not `request_id`):
|
|
527
|
+
* a request can produce more than one sweep over its life (RBF/rebroadcast), so
|
|
528
|
+
* each broadcast keeps its own confirmation history.
|
|
529
|
+
*/
|
|
530
|
+
interface SbtcSettlementsTable {
|
|
531
|
+
sweep_txid: string;
|
|
532
|
+
request_id: number;
|
|
533
|
+
btc_confirmations: Generated<number>;
|
|
534
|
+
settlement_confirmed: Generated<boolean>;
|
|
535
|
+
/** Confirming Bitcoin block — null while the sweep is unconfirmed. */
|
|
536
|
+
block_hash: string | null;
|
|
537
|
+
block_height: number | null;
|
|
538
|
+
first_seen_at: Generated<Date>;
|
|
539
|
+
last_checked_at: Generated<Date>;
|
|
540
|
+
/** Set once, when `settlement_confirmed` first flips true. */
|
|
541
|
+
confirmed_at: Date | null;
|
|
542
|
+
updated_at: Generated<Date>;
|
|
543
|
+
}
|
|
521
544
|
interface SbtcSupplySnapshotsTable {
|
|
522
545
|
date: string;
|
|
523
546
|
total_supply: Generated<string>;
|
|
@@ -665,6 +688,7 @@ interface Database {
|
|
|
665
688
|
burn_block_reward_slots: BurnBlockRewardSlotsTable;
|
|
666
689
|
sbtc_events: SbtcEventsTable;
|
|
667
690
|
sbtc_token_events: SbtcTokenEventsTable;
|
|
691
|
+
sbtc_settlements: SbtcSettlementsTable;
|
|
668
692
|
sbtc_supply_snapshots: SbtcSupplySnapshotsTable;
|
|
669
693
|
bns_name_events: BnsNameEventsTable;
|
|
670
694
|
bns_namespace_events: BnsNamespaceEventsTable;
|
|
@@ -955,6 +979,9 @@ type InsertSubscriptionDelivery = Insertable<SubscriptionDeliveriesTable>;
|
|
|
955
979
|
interface TriggerEvaluatorStateTable {
|
|
956
980
|
id: Generated<boolean>;
|
|
957
981
|
last_processed_block: ColumnType<bigint, bigint | number | undefined, bigint | number>;
|
|
982
|
+
/** Watermark for the async sBTC settlement-confirmed webhook scan; null until
|
|
983
|
+
* the evaluator fast-forwards it on first run. */
|
|
984
|
+
last_settlement_scan_at: ColumnType<Date | null, Date | null | undefined, Date | null>;
|
|
958
985
|
updated_at: Generated<Date>;
|
|
959
986
|
}
|
|
960
987
|
type TriggerEvaluatorState = Selectable<TriggerEvaluatorStateTable>;
|
|
@@ -1832,6 +1859,7 @@ declare const TABLE_TO_DB: {
|
|
|
1832
1859
|
burn_block_reward_slots: string
|
|
1833
1860
|
sbtc_events: string
|
|
1834
1861
|
sbtc_token_events: string
|
|
1862
|
+
sbtc_settlements: string
|
|
1835
1863
|
sbtc_supply_snapshots: string
|
|
1836
1864
|
bns_name_events: string
|
|
1837
1865
|
bns_namespace_events: string
|
|
@@ -2379,7 +2407,7 @@ declare const SubscriptionFilterPrimitiveSchema: z4.ZodType<SubscriptionFilterPr
|
|
|
2379
2407
|
declare const SubscriptionFilterOperatorSchema: z4.ZodType<SubscriptionFilterOperator>;
|
|
2380
2408
|
declare const SubscriptionFilterClauseSchema: z4.ZodType<SubscriptionFilterClause>;
|
|
2381
2409
|
declare const SubscriptionFilterSchema: z4.ZodType<SubscriptionFilter>;
|
|
2382
|
-
declare const CHAIN_TRIGGER_TYPES: readonly ["stx_transfer", "stx_mint", "stx_burn", "stx_lock", "ft_transfer", "ft_mint", "ft_burn", "nft_transfer", "nft_mint", "nft_burn", "contract_call", "contract_deploy", "print_event", "sbtc_deposit", "sbtc_withdrawal_create", "sbtc_withdrawal_accept", "sbtc_withdrawal_reject"];
|
|
2410
|
+
declare const CHAIN_TRIGGER_TYPES: readonly ["stx_transfer", "stx_mint", "stx_burn", "stx_lock", "ft_transfer", "ft_mint", "ft_burn", "nft_transfer", "nft_mint", "nft_burn", "contract_call", "contract_deploy", "print_event", "sbtc_deposit", "sbtc_withdrawal_create", "sbtc_withdrawal_accept", "sbtc_withdrawal_reject", "sbtc_withdrawal_swept_confirmed"];
|
|
2383
2411
|
/**
|
|
2384
2412
|
* Per-type accepted filter fields for chain triggers, DERIVED from
|
|
2385
2413
|
* {@link ChainTriggerSchema} so the agent-facing reference can never drift behind
|
|
@@ -2498,6 +2526,10 @@ type ChainTrigger = {
|
|
|
2498
2526
|
} | {
|
|
2499
2527
|
type: "sbtc_withdrawal_reject"
|
|
2500
2528
|
requestId?: number
|
|
2529
|
+
} | {
|
|
2530
|
+
type: "sbtc_withdrawal_swept_confirmed"
|
|
2531
|
+
requestId?: number
|
|
2532
|
+
sweepTxid?: string
|
|
2501
2533
|
};
|
|
2502
2534
|
interface CreateSubscriptionRequest {
|
|
2503
2535
|
name: string;
|
|
@@ -2776,18 +2808,33 @@ interface SbtcDepositEvent {
|
|
|
2776
2808
|
block_height: number;
|
|
2777
2809
|
tx_id: string;
|
|
2778
2810
|
}
|
|
2779
|
-
/** Payload for `sbtc_withdrawal_create`, `sbtc_withdrawal_accept`, `sbtc_withdrawal_reject
|
|
2811
|
+
/** Payload for `sbtc_withdrawal_create`, `sbtc_withdrawal_accept`, `sbtc_withdrawal_reject` —
|
|
2812
|
+
* the on-Stacks lifecycle events. `settlement_confirmed` is always false here; the
|
|
2813
|
+
* BTC L1 confirmation is delivered separately as `SbtcWithdrawalSweptConfirmedEvent`. */
|
|
2780
2814
|
interface SbtcWithdrawalEvent {
|
|
2781
2815
|
topic: "withdrawal-create" | "withdrawal-accept" | "withdrawal-reject";
|
|
2782
2816
|
request_id: number;
|
|
2783
2817
|
sender: string | null;
|
|
2784
2818
|
amount: string | null;
|
|
2785
2819
|
sweep_txid: string | null;
|
|
2786
|
-
/** Always false until the BTC L1 confirmer ships. */
|
|
2787
2820
|
settlement_confirmed: false;
|
|
2788
2821
|
block_height: number;
|
|
2789
2822
|
tx_id: string;
|
|
2790
2823
|
}
|
|
2824
|
+
/** Payload for `sbtc_withdrawal_swept_confirmed` — fired once when a peg-out's
|
|
2825
|
+
* committed BTC sweep crosses the confirmation threshold on Bitcoin. Anchored to
|
|
2826
|
+
* the Stacks `withdrawal-accept` event (block_height/tx_id in the envelope); the
|
|
2827
|
+
* Bitcoin-side specifics live here. */
|
|
2828
|
+
interface SbtcWithdrawalSweptConfirmedEvent {
|
|
2829
|
+
topic: "withdrawal-swept-confirmed";
|
|
2830
|
+
request_id: number;
|
|
2831
|
+
sweep_txid: string;
|
|
2832
|
+
btc_confirmations: number;
|
|
2833
|
+
btc_block_height: number | null;
|
|
2834
|
+
confirmed_at: string | null;
|
|
2835
|
+
amount: string | null;
|
|
2836
|
+
sender: string | null;
|
|
2837
|
+
}
|
|
2791
2838
|
/**
|
|
2792
2839
|
* Delivered when a matched chain event lands in a canonical block
|
|
2793
2840
|
* (`event_type: "chain.<trigger>.apply"`). Tx-level triggers (contract_call /
|
|
@@ -2803,7 +2850,7 @@ interface ChainApplyEnvelope {
|
|
|
2803
2850
|
canonical: true;
|
|
2804
2851
|
/** The chain-trigger type that matched. */
|
|
2805
2852
|
trigger: ChainTrigger["type"];
|
|
2806
|
-
event: SbtcDepositEvent | SbtcWithdrawalEvent | Record<string, unknown>;
|
|
2853
|
+
event: SbtcDepositEvent | SbtcWithdrawalEvent | SbtcWithdrawalSweptConfirmedEvent | Record<string, unknown>;
|
|
2807
2854
|
}
|
|
2808
2855
|
/** One orphaned delivery recalled by a reorg rollback. */
|
|
2809
2856
|
interface ChainReorgOrphanedEntry {
|
|
@@ -2825,4 +2872,185 @@ interface ChainReorgRollbackEnvelope {
|
|
|
2825
2872
|
}
|
|
2826
2873
|
/** Any chain-subscription webhook body. Discriminate on `action`. */
|
|
2827
2874
|
type ChainWebhookEnvelope = ChainApplyEnvelope | ChainReorgRollbackEnvelope;
|
|
2828
|
-
|
|
2875
|
+
/** `event.data` for a `stx_transfer` delivery. */
|
|
2876
|
+
interface ChainStxTransferData {
|
|
2877
|
+
sender?: string;
|
|
2878
|
+
recipient?: string;
|
|
2879
|
+
amount: string;
|
|
2880
|
+
/** Always present; `""` when the transfer carried no memo. */
|
|
2881
|
+
memo: string;
|
|
2882
|
+
}
|
|
2883
|
+
/** `event.data` for a `stx_mint` delivery. */
|
|
2884
|
+
interface ChainStxMintData {
|
|
2885
|
+
recipient?: string;
|
|
2886
|
+
amount: string;
|
|
2887
|
+
}
|
|
2888
|
+
/** `event.data` for a `stx_burn` delivery. */
|
|
2889
|
+
interface ChainStxBurnData {
|
|
2890
|
+
sender?: string;
|
|
2891
|
+
amount: string;
|
|
2892
|
+
}
|
|
2893
|
+
/** `event.data` for a `stx_lock` delivery. */
|
|
2894
|
+
interface ChainStxLockData {
|
|
2895
|
+
locked_address: string;
|
|
2896
|
+
locked_amount: string;
|
|
2897
|
+
unlock_height: string | null;
|
|
2898
|
+
}
|
|
2899
|
+
/** `event.data` for an `ft_transfer` delivery. */
|
|
2900
|
+
interface ChainFtTransferData {
|
|
2901
|
+
asset_identifier: string;
|
|
2902
|
+
sender?: string;
|
|
2903
|
+
recipient?: string;
|
|
2904
|
+
amount: string;
|
|
2905
|
+
}
|
|
2906
|
+
/** `event.data` for an `ft_mint` delivery. */
|
|
2907
|
+
interface ChainFtMintData {
|
|
2908
|
+
asset_identifier: string;
|
|
2909
|
+
recipient?: string;
|
|
2910
|
+
amount: string;
|
|
2911
|
+
}
|
|
2912
|
+
/** `event.data` for an `ft_burn` delivery. */
|
|
2913
|
+
interface ChainFtBurnData {
|
|
2914
|
+
asset_identifier: string;
|
|
2915
|
+
sender?: string;
|
|
2916
|
+
amount: string;
|
|
2917
|
+
}
|
|
2918
|
+
/**
|
|
2919
|
+
* `event.data` for an `nft_transfer` delivery. Unlike Streams' `NftTransferPayload`,
|
|
2920
|
+
* there is no decoded `value` field — only the canonical hex of the token-id
|
|
2921
|
+
* Clarity value (`raw_value`).
|
|
2922
|
+
*/
|
|
2923
|
+
interface ChainNftTransferData {
|
|
2924
|
+
asset_identifier: string;
|
|
2925
|
+
sender?: string;
|
|
2926
|
+
recipient?: string;
|
|
2927
|
+
raw_value: string;
|
|
2928
|
+
}
|
|
2929
|
+
/** `event.data` for an `nft_mint` delivery. See {@link ChainNftTransferData}. */
|
|
2930
|
+
interface ChainNftMintData {
|
|
2931
|
+
asset_identifier: string;
|
|
2932
|
+
recipient?: string;
|
|
2933
|
+
raw_value: string;
|
|
2934
|
+
}
|
|
2935
|
+
/** `event.data` for an `nft_burn` delivery. See {@link ChainNftTransferData}. */
|
|
2936
|
+
interface ChainNftBurnData {
|
|
2937
|
+
asset_identifier: string;
|
|
2938
|
+
sender?: string;
|
|
2939
|
+
raw_value: string;
|
|
2940
|
+
}
|
|
2941
|
+
/**
|
|
2942
|
+
* `event.data` for a `print_event` delivery. Note the field is
|
|
2943
|
+
* `contract_identifier` — Streams' `PrintPayload` uses `contract_id` for the
|
|
2944
|
+
* same contract, which is NOT the field name delivered here.
|
|
2945
|
+
*/
|
|
2946
|
+
interface ChainPrintEventData {
|
|
2947
|
+
topic: string | null;
|
|
2948
|
+
contract_identifier: string;
|
|
2949
|
+
value: unknown;
|
|
2950
|
+
raw_value: string | null;
|
|
2951
|
+
}
|
|
2952
|
+
/**
|
|
2953
|
+
* Wrapper around an event-level trigger's matched event. `type` is the node's
|
|
2954
|
+
* suffixed event-kind (`"stx_transfer_event"`, `"ft_mint_event"`, …) — EXCEPT
|
|
2955
|
+
* `print_event` triggers, whose `event.type` is `"contract_event"` (the node's
|
|
2956
|
+
* raw name for a print event), not `"print_event_event"`.
|
|
2957
|
+
*/
|
|
2958
|
+
interface ChainEventEnvelope<
|
|
2959
|
+
TType extends string,
|
|
2960
|
+
TData
|
|
2961
|
+
> {
|
|
2962
|
+
tx_id: string;
|
|
2963
|
+
type: TType;
|
|
2964
|
+
event_index: number;
|
|
2965
|
+
data: TData;
|
|
2966
|
+
}
|
|
2967
|
+
/**
|
|
2968
|
+
* A tx-level trigger's matched event (`contract_call` / `contract_deploy`) —
|
|
2969
|
+
* flat, no nested `data` key. `function_args` are RAW (undecoded) Clarity-value
|
|
2970
|
+
* hex strings in call order, not decoded values.
|
|
2971
|
+
*/
|
|
2972
|
+
interface ChainTxLevelEvent {
|
|
2973
|
+
tx_id: string;
|
|
2974
|
+
/** Stacks tx type, e.g. `"contract_call"` for a `contract_call` trigger or
|
|
2975
|
+
* `"smart_contract"` for a `contract_deploy` trigger — NOT `"contract_deploy"`. */
|
|
2976
|
+
type: string;
|
|
2977
|
+
sender: string;
|
|
2978
|
+
status: string;
|
|
2979
|
+
contract_id: string | null;
|
|
2980
|
+
function_name: string | null;
|
|
2981
|
+
/** Raw (undecoded) Clarity-value hex strings, in call order. */
|
|
2982
|
+
function_args: string[] | null;
|
|
2983
|
+
/** Raw hex of the tx's Clarity return value. */
|
|
2984
|
+
result_hex: string | null;
|
|
2985
|
+
}
|
|
2986
|
+
/** One `apply` envelope, generic over its trigger literal + matched-event shape. */
|
|
2987
|
+
interface ChainApplyEnvelopeOf<
|
|
2988
|
+
TTrigger extends ChainTrigger["type"],
|
|
2989
|
+
TEvent
|
|
2990
|
+
> {
|
|
2991
|
+
action: "apply";
|
|
2992
|
+
block_hash: string;
|
|
2993
|
+
block_height: number;
|
|
2994
|
+
tx_id: string;
|
|
2995
|
+
canonical: true;
|
|
2996
|
+
trigger: TTrigger;
|
|
2997
|
+
event: TEvent;
|
|
2998
|
+
}
|
|
2999
|
+
type ChainApplyDeliveryOf<
|
|
3000
|
+
TTrigger extends ChainTrigger["type"],
|
|
3001
|
+
TEvent
|
|
3002
|
+
> = {
|
|
3003
|
+
type: `chain.${TTrigger}.apply`
|
|
3004
|
+
timestamp: string
|
|
3005
|
+
data: ChainApplyEnvelopeOf<TTrigger, TEvent>
|
|
3006
|
+
};
|
|
3007
|
+
/** Delivered once per affected subscription on a reorg (`type: "chain.reorg.rollback"`). */
|
|
3008
|
+
interface ChainReorgRollbackDelivery {
|
|
3009
|
+
type: "chain.reorg.rollback";
|
|
3010
|
+
timestamp: string;
|
|
3011
|
+
data: ChainReorgRollbackEnvelope;
|
|
3012
|
+
}
|
|
3013
|
+
/** The `POST /subscriptions/:id/test` ping (`type: "chain.test.apply"`) — not a real chain event. */
|
|
3014
|
+
interface ChainTestDelivery {
|
|
3015
|
+
type: "chain.test.apply";
|
|
3016
|
+
timestamp: string;
|
|
3017
|
+
data: {
|
|
3018
|
+
test: true
|
|
3019
|
+
message: string
|
|
3020
|
+
subscription_id: string
|
|
3021
|
+
sent_at: string
|
|
3022
|
+
};
|
|
3023
|
+
}
|
|
3024
|
+
/**
|
|
3025
|
+
* The full wire body of a chain-subscription webhook delivery, as sent to a
|
|
3026
|
+
* `format: "standard-webhooks"` subscription (the default) — `{ type,
|
|
3027
|
+
* timestamp, data }`. Discriminate on `data.trigger` (or the top-level `type`)
|
|
3028
|
+
* to narrow `data.event`:
|
|
3029
|
+
*
|
|
3030
|
+
* ```ts
|
|
3031
|
+
* const delivery = decodeChainWebhook(rawBody);
|
|
3032
|
+
* if (delivery.data.action === "apply") {
|
|
3033
|
+
* switch (delivery.data.trigger) {
|
|
3034
|
+
* case "stx_transfer":
|
|
3035
|
+
* delivery.data.event.data.amount; // typed
|
|
3036
|
+
* break;
|
|
3037
|
+
* case "contract_call":
|
|
3038
|
+
* delivery.data.event.function_name; // typed, flat (no nested `.data`)
|
|
3039
|
+
* break;
|
|
3040
|
+
* }
|
|
3041
|
+
* }
|
|
3042
|
+
* ```
|
|
3043
|
+
*
|
|
3044
|
+
* NOTE: this is the DELIVERED webhook body, not a Streams/Index event — those
|
|
3045
|
+
* have an unrelated `{ event_type, payload }` shape (see `StreamsEvent` in
|
|
3046
|
+
* `@secondlayer/sdk`). Do not parse a chain-subscription delivery as a Streams
|
|
3047
|
+
* event or vice versa — mixing them up is the exact bug this type exists to
|
|
3048
|
+
* prevent.
|
|
3049
|
+
*
|
|
3050
|
+
* Other subscription `format`s (`raw`, `cloudevents`, `inngest`, `trigger`,
|
|
3051
|
+
* `cloudflare`) carry the same `data` value (a `ChainApplyEnvelope` /
|
|
3052
|
+
* `ChainReorgRollbackEnvelope`) under a different outer envelope — see the
|
|
3053
|
+
* "Chain subscription webhook payloads" doc.
|
|
3054
|
+
*/
|
|
3055
|
+
type ChainWebhookDelivery = ChainApplyDeliveryOf<"stx_transfer", ChainEventEnvelope<"stx_transfer_event", ChainStxTransferData>> | ChainApplyDeliveryOf<"stx_mint", ChainEventEnvelope<"stx_mint_event", ChainStxMintData>> | ChainApplyDeliveryOf<"stx_burn", ChainEventEnvelope<"stx_burn_event", ChainStxBurnData>> | ChainApplyDeliveryOf<"stx_lock", ChainEventEnvelope<"stx_lock_event", ChainStxLockData>> | ChainApplyDeliveryOf<"ft_transfer", ChainEventEnvelope<"ft_transfer_event", ChainFtTransferData>> | ChainApplyDeliveryOf<"ft_mint", ChainEventEnvelope<"ft_mint_event", ChainFtMintData>> | ChainApplyDeliveryOf<"ft_burn", ChainEventEnvelope<"ft_burn_event", ChainFtBurnData>> | ChainApplyDeliveryOf<"nft_transfer", ChainEventEnvelope<"nft_transfer_event", ChainNftTransferData>> | ChainApplyDeliveryOf<"nft_mint", ChainEventEnvelope<"nft_mint_event", ChainNftMintData>> | ChainApplyDeliveryOf<"nft_burn", ChainEventEnvelope<"nft_burn_event", ChainNftBurnData>> | ChainApplyDeliveryOf<"print_event", ChainEventEnvelope<"contract_event", ChainPrintEventData>> | ChainApplyDeliveryOf<"contract_call", ChainTxLevelEvent> | ChainApplyDeliveryOf<"contract_deploy", ChainTxLevelEvent> | ChainApplyDeliveryOf<"sbtc_deposit", SbtcDepositEvent> | ChainApplyDeliveryOf<"sbtc_withdrawal_create", SbtcWithdrawalEvent> | ChainApplyDeliveryOf<"sbtc_withdrawal_accept", SbtcWithdrawalEvent> | ChainApplyDeliveryOf<"sbtc_withdrawal_reject", SbtcWithdrawalEvent> | ChainApplyDeliveryOf<"sbtc_withdrawal_swept_confirmed", SbtcWithdrawalSweptConfirmedEvent> | ChainReorgRollbackDelivery | ChainTestDelivery;
|
|
3056
|
+
export { validateSubscriptionFilterForTable, sql, setMigrationRole, parseJsonb, onControlPlane, onChainPlane, logger, jsonb, isPox4DecoderEnabled, getTargetDb, getSourceDb, getRawClientFor, getRawClient, getMigrationRole, getErrorMessage, getEnv, getDbSplitStatus, getDb, generateSubgraphSpec, generateSubgraphOpenApi, generateSubgraphMarkdown, generateSubgraphAgentSchema, formatSubscriptionSchemaErrors, finalizedBurnHeight, encodeStreamsCursor, exports_ed25519 as ed25519, decodeStreamsCursor, exports_hmac as crypto, closeDb, assertDbSplit, X402PaymentsTable, X402BalancesTable, VersionConflictError, ValidationError, UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateTransaction, UpdateTenantUsageMonthly, UpdateTenantComputeAddon, UpdateTenant, UpdateSubscriptionRequestSchema, UpdateSubscriptionRequest, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraphOperation, UpdateSubgraph, UpdateProject, UpdateIndexProgress, UpdateEvent, UpdateContract, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, UpdateAccountCredits, TriggerEvaluatorStateTable, TriggerEvaluatorState, TransactionsTable, TransactionsArchiveTable, Transaction, TenantsTable, TenantUsageMonthlyTable, TenantUsageMonthly, TenantSuspendedError, TenantStatus, TenantComputeAddonsTable, TenantComputeAddon, Tenant, TeamMembersTable, TeamMember, TeamInvitationsTable, TeamInvitation, TABLE_TO_DB, SubscriptionsTable, SubscriptionSummary, SubscriptionStatusSchema, SubscriptionStatus, SubscriptionSchemaTables, SubscriptionSchemaTable, SubscriptionSchemaColumn, SubscriptionRuntimeSchema, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionKind, SubscriptionFormatSchema, SubscriptionFormat, SubscriptionFilterSchema, SubscriptionFilterPrimitiveSchema, SubscriptionFilterPrimitive, SubscriptionFilterOperatorSchema, SubscriptionFilterOperator, SubscriptionFilterClauseSchema, SubscriptionFilterClause, SubscriptionFilter, SubscriptionDetail, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphUsageDailyTable, SubgraphUsageDaily, SubgraphTableSnapshotsTable, SubgraphSyncInfo, SubgraphSummary, SubgraphSpecOptions, SubgraphSpecFormat, SubgraphResourceWarning, SubgraphQueryParams, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGapsResponse, SubgraphGapRange, SubgraphGapEntry, SubgraphGap, SubgraphDetail, SubgraphAggregateResponse, SubgraphAggregateParams, SubgraphAgentSchema, Subgraph, StxTransferFilterSchema, StxTransferFilter, StxMintFilterSchema, StxMintFilter, StxLockFilterSchema, StxLockFilter, StxBurnFilterSchema, StxBurnFilter, StreamsEventType, StreamsDbEventType, StreamsCursor, SessionsTable, Session, ServiceHeartbeatsTable, SecondLayerError, SbtcWithdrawalSweptConfirmedEvent, SbtcWithdrawalEvent, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcSettlementsTable, SbtcEventsTable, SbtcEventTopic, SbtcDepositEvent, SUBSCRIPTION_STATUSES, SUBSCRIPTION_RUNTIMES, SUBSCRIPTION_FORMATS, SUBSCRIPTION_FILTER_OPERATORS, STREAMS_TO_DB_EVENT_TYPES, STREAMS_EVENT_TYPES, STREAMS_DB_EVENT_TYPES, SOURCE_READ_TYPES, SOURCE_READ_PKS, SOURCE_READ_COLUMNS, RotateSecretResponse, ReplaySubscriptionRequestSchema, ReplaySubscriptionRequest, ReplayResult, ReindexResponse, RateLimitError, ProvisioningAuditStatus, ProvisioningAuditLogTable, ProvisioningAuditLog, ProvisioningAuditEvent, ProjectsTable, Project, ProcessedStripeEventsTable, PrintEventFilterSchema, PrintEventFilter, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, PaymentRequiredError, ParsedUpdateSubscriptionRequest, ParsedReplaySubscriptionRequest, ParsedCreateSubscriptionRequest, OutboxStatus, NumericAsText, NotFoundError, NftTransferFilterSchema, NftTransferFilter, NftMintFilterSchema, NftMintFilter, NftBurnFilterSchema, NftBurnFilter, MigrationRole, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, KeyRotatedError, InsertTransaction, InsertTenantUsageMonthly, InsertTenantComputeAddon, InsertTenant, InsertTeamMember, InsertTeamInvitation, InsertSubscriptionOutbox, InsertSubscriptionDelivery, InsertSubscription, InsertSubgraphUsageDaily, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertProvisioningAuditLog, InsertProject, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertEvent, InsertContract, InsertClaimToken, InsertBlock, InsertApiKey, InsertAccountSpendCap, InsertAccountInsight, InsertAccountCredits, InsertAccountAgentRun, InsertAccount, IndexProgressTable, IndexProgress, IndexPrimaryKey, IndexColumnType, IndexColumn, FtTransferFilterSchema, FtTransferFilter, FtMintFilterSchema, FtMintFilter, FtBurnFilterSchema, FtBurnFilter, ForbiddenError, EventsTable, EventsArchiveTable, EventFilterSchema, EventFilter, Event, ErrorCodes, ErrorCode, Env, EMPTY_RANGE_EVENT_INDEX_SENTINEL, DeploySubgraphResponse, DeploySubgraphRequestSchema, DeploySubgraphRequest, DeliveryRow, DecoderCheckpointsTable, DecodedEventsTable, DecodedEventType, DeadRow, DeadLetterEventsTable, DbSplitStatus, DbReadRow, DbPlane, DatabaseError, Database, DEFAULT_BTC_CONFIRMATIONS, DECODED_EVENT_TYPES, DB_TO_STREAMS_EVENT_TYPE, CreateSubscriptionResponse, CreateSubscriptionRequestSchema, CreateSubscriptionRequest, ContractsTable, ContractDeployFilterSchema, ContractDeployFilter, ContractCallFilterSchema, ContractCallFilter, Contract, ClaimTokensTable, ClaimToken, ChainWebhookEnvelope, ChainWebhookDelivery, ChainTxLevelEvent, ChainTestDelivery, ChainStxTransferData, ChainStxMintData, ChainStxLockData, ChainStxBurnData, ChainReorgsTable, ChainReorgRollbackEnvelope, ChainReorgRollbackDelivery, ChainReorgOrphanedEntry, ChainPrintEventData, ChainNftTransferData, ChainNftMintData, ChainNftBurnData, ChainFtTransferData, ChainFtMintData, ChainFtBurnData, ChainEventEnvelope, ChainApplyEnvelopeOf, ChainApplyEnvelope, CODE_TO_STATUS, CHAIN_TRIGGER_TYPES, CHAIN_TRIGGER_FIELDS, ByoBreakingChangeDetails, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, AuthorizationError, AuthenticationError, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountInsightsTable, AccountInsight, AccountCreditsTable, AccountCredits, AccountAgentRunsTable, AccountAgentRun, Account };
|
package/dist/src/index.js
CHANGED
|
@@ -665,6 +665,7 @@ var TABLE_TO_DB = {
|
|
|
665
665
|
burn_block_reward_slots: "source",
|
|
666
666
|
sbtc_events: "source",
|
|
667
667
|
sbtc_token_events: "source",
|
|
668
|
+
sbtc_settlements: "source",
|
|
668
669
|
sbtc_supply_snapshots: "source",
|
|
669
670
|
bns_name_events: "source",
|
|
670
671
|
bns_namespace_events: "source",
|
|
@@ -1180,7 +1181,8 @@ var CHAIN_TRIGGER_TYPES = [
|
|
|
1180
1181
|
"sbtc_deposit",
|
|
1181
1182
|
"sbtc_withdrawal_create",
|
|
1182
1183
|
"sbtc_withdrawal_accept",
|
|
1183
|
-
"sbtc_withdrawal_reject"
|
|
1184
|
+
"sbtc_withdrawal_reject",
|
|
1185
|
+
"sbtc_withdrawal_swept_confirmed"
|
|
1184
1186
|
];
|
|
1185
1187
|
var triggerAmount = z4.union([
|
|
1186
1188
|
z4.string().trim().regex(/^\d+$/, "must be a non-negative integer string"),
|
|
@@ -1293,6 +1295,11 @@ var ChainTriggerSchema = z4.discriminatedUnion("type", [
|
|
|
1293
1295
|
z4.object({
|
|
1294
1296
|
type: z4.literal("sbtc_withdrawal_reject"),
|
|
1295
1297
|
requestId: z4.number().int().nonnegative().optional()
|
|
1298
|
+
}).strict(),
|
|
1299
|
+
z4.object({
|
|
1300
|
+
type: z4.literal("sbtc_withdrawal_swept_confirmed"),
|
|
1301
|
+
requestId: z4.number().int().nonnegative().optional(),
|
|
1302
|
+
sweepTxid: triggerPattern.optional()
|
|
1296
1303
|
}).strict()
|
|
1297
1304
|
]);
|
|
1298
1305
|
var ChainTriggersSchema = z4.array(ChainTriggerSchema).min(1).max(50);
|
|
@@ -1417,6 +1424,10 @@ var trigger = {
|
|
|
1417
1424
|
sbtcWithdrawalReject: (f = {}) => ({
|
|
1418
1425
|
type: "sbtc_withdrawal_reject",
|
|
1419
1426
|
...f
|
|
1427
|
+
}),
|
|
1428
|
+
sbtcWithdrawalSweptConfirmed: (f = {}) => ({
|
|
1429
|
+
type: "sbtc_withdrawal_swept_confirmed",
|
|
1430
|
+
...f
|
|
1420
1431
|
})
|
|
1421
1432
|
};
|
|
1422
1433
|
var SCALAR_COLUMN_TYPES = new Set([
|
|
@@ -2143,5 +2154,5 @@ export {
|
|
|
2143
2154
|
AuthenticationError
|
|
2144
2155
|
};
|
|
2145
2156
|
|
|
2146
|
-
//# debugId=
|
|
2157
|
+
//# debugId=39B8FB62F71153DE64756E2164756E21
|
|
2147
2158
|
//# sourceMappingURL=index.js.map
|