@secondlayer/sdk 6.29.1 → 6.31.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/index.d.ts CHANGED
@@ -1691,6 +1691,73 @@ interface PoxResource {
1691
1691
  get(rewardCycle: number): Promise<PoxCycleEnvelope | null>
1692
1692
  };
1693
1693
  }
1694
+ /** The decoded `pox-5` boot-contract print topics (SIP-045 Bitcoin Staking).
1695
+ * Declared locally rather than imported from the server packages — the SDK is
1696
+ * published and owns its own dependency surface (same as {@link SbtcEventTopic}). */
1697
+ type IndexPox5EventTopic = "set-bond-admin" | "set-pause-admin" | "pause-rewards" | "setup-bond" | "add-to-allowlist" | "register-for-bond" | "update-bond-registration" | "register-signer" | "stake" | "stake-update" | "announce-l1-early-exit" | "unstake-sbtc" | "unstake" | "calculate-rewards" | "bond-distribution" | "claim-rewards" | "claim-staker-rewards-for-signer" | "grant-signer-key" | "revoke-signer-grant";
1698
+ /** A raw decoded PoX-5 print event. Promoted fields cover the hot query paths;
1699
+ * `data` always carries the full decoded tuple, including nested shapes
1700
+ * (`btc-lockup`, `bond-rewards`, `bond-periods`) that have no flat column. */
1701
+ type IndexPox5Event = {
1702
+ cursor: string
1703
+ block_height: number
1704
+ block_time: string | null
1705
+ tx_id: string
1706
+ tx_index: number
1707
+ event_index: number
1708
+ topic: IndexPox5EventTopic
1709
+ staker: string | null
1710
+ signer: string | null
1711
+ signer_manager: string | null
1712
+ bond_index: number | null
1713
+ /** ustx, bigint-safe string. */
1714
+ amount_ustx: string | null
1715
+ /** sats, bigint-safe string. */
1716
+ amount_sats: string | null
1717
+ reward_cycle: number | null
1718
+ first_reward_cycle: number | null
1719
+ unlock_cycle: number | null
1720
+ unlock_burn_height: number | null
1721
+ is_l1_lock: boolean | null
1722
+ signer_key: string | null
1723
+ /** The full decoded print tuple as JSON. */
1724
+ data: unknown
1725
+ };
1726
+ type Pox5EventsEnvelope = {
1727
+ events: IndexPox5Event[]
1728
+ next_cursor: string | null
1729
+ tip: IndexTip
1730
+ reorgs: IndexReorg[]
1731
+ /** Present only when the PoX-5 decoder is disabled, explaining an empty feed. */
1732
+ notes?: string
1733
+ };
1734
+ type Pox5EventsListParams = {
1735
+ cursor?: string | null
1736
+ fromCursor?: string | null
1737
+ limit?: number
1738
+ /** Clamp to the finality boundary — only rows past the reorg margin. */
1739
+ confirmed?: boolean
1740
+ topic?: IndexPox5EventTopic
1741
+ staker?: string
1742
+ signer?: string
1743
+ signerManager?: string
1744
+ bondIndex?: number
1745
+ rewardCycle?: number
1746
+ fromHeight?: number
1747
+ toHeight?: number
1748
+ };
1749
+ type Pox5EventsWalkParams = Omit<Pox5EventsListParams, "limit"> & {
1750
+ batchSize?: number
1751
+ signal?: AbortSignal
1752
+ };
1753
+ /** `index.pox5` — decoded PoX-5 print events, the staking primitive from the
1754
+ * epoch 4.0 hard fork onward (PoX-4's `index.stacking` stream ends there). */
1755
+ interface Pox5Resource {
1756
+ events: {
1757
+ list(params?: Pox5EventsListParams): Promise<Pox5EventsEnvelope>
1758
+ walk(params?: Pox5EventsWalkParams): AsyncIterable<IndexPox5Event>
1759
+ };
1760
+ }
1694
1761
  /**
1695
1762
  * `index.ftTransfers` — callable shorthand for `.list()`, with `.list`/`.walk`
1696
1763
  * still available: `await sl.index.ftTransfers({ contractId })`.
@@ -1805,6 +1872,9 @@ declare class Index extends BaseClient {
1805
1872
  /** PoX reward-cycle aggregates. Distinct from `stacking` (per-call PoX-4
1806
1873
  * actions); `cycles` is the reward-cycle rollup. */
1807
1874
  readonly pox: PoxResource;
1875
+ /** Decoded PoX-5 print events (SIP-045 Bitcoin Staking) — the raw pox-5
1876
+ * boot-contract log, all 19 topics. Distinct from `stacking` (PoX-4 era). */
1877
+ readonly pox5: Pox5Resource;
1808
1878
  private listFtTransfers;
1809
1879
  private listNftTransfers;
1810
1880
  /** Shared keyset-pagination loop for every `walk*` feed: seed the cursor from
@@ -1846,6 +1916,8 @@ declare class Index extends BaseClient {
1846
1916
  private listSbtcEvents;
1847
1917
  private walkSbtcEvents;
1848
1918
  private getSbtcSummary;
1919
+ private listPox5Events;
1920
+ private walkPox5Events;
1849
1921
  private listPoxCycles;
1850
1922
  private walkPoxCycles;
1851
1923
  private getPoxCycle;
@@ -2603,7 +2675,10 @@ declare class ByoBreakingChangeError extends ApiError {
2603
2675
  readonly details: ByoBreakingChangeDetails;
2604
2676
  constructor(message: string, details: ByoBreakingChangeDetails);
2605
2677
  }
2678
+ import { ChainWebhookDelivery } from "@secondlayer/shared";
2606
2679
  import { StandardWebhooksHeaders } from "@secondlayer/shared/crypto/standard-webhooks";
2680
+ import { StandardWebhooksHeaders as StandardWebhooksHeaders2, verify } from "@secondlayer/shared/crypto/standard-webhooks";
2681
+ import { ChainApplyDeliveryOf, ChainApplyEnvelope, ChainApplyEnvelopeOf, ChainEventEnvelope, ChainFtBurnData, ChainFtMintData, ChainFtTransferData, ChainNftBurnData, ChainNftMintData, ChainNftTransferData, ChainPrintEventData, ChainReorgOrphanedEntry, ChainReorgRollbackDelivery, ChainReorgRollbackEnvelope, ChainStxBurnData, ChainStxLockData, ChainStxMintData, ChainStxTransferData, ChainTestDelivery, ChainTxLevelEvent, ChainWebhookDelivery as ChainWebhookDelivery2, ChainWebhookEnvelope, SbtcDepositEvent, SbtcWithdrawalEvent, SbtcWithdrawalSweptConfirmedEvent } from "@secondlayer/shared";
2607
2682
  type HeaderLookup = (name: string) => string | null | undefined;
2608
2683
  type WebhookHeaderInput = HeaderLookup | StandardWebhooksHeaders | Record<string, string | string[] | undefined> | {
2609
2684
  get: (name: string) => string | null
@@ -2717,6 +2792,45 @@ declare function verifyWebhookSignature(rawBody: string, headers: WebhookHeaderI
2717
2792
  * ```
2718
2793
  */
2719
2794
  declare function verifySecondlayerSignature(rawBody: string, headers: WebhookHeaderInput, publicKeyPem: string): boolean;
2795
+ /**
2796
+ * Decode + narrow a chain-subscription webhook delivery body into a typed
2797
+ * {@link ChainWebhookDelivery}. Verify the signature first with
2798
+ * {@link verifyWebhookSignature} (or {@link verifySecondlayerSignature}), then
2799
+ * decode the same raw body — this does not check authenticity, only shape.
2800
+ *
2801
+ * Only understands the `format: "standard-webhooks"` envelope (`{ type,
2802
+ * timestamp, data }`) — the subscription default, and the only format
2803
+ * `verifyWebhookSignature` covers. Other formats (`raw`, `cloudevents`, …)
2804
+ * carry the same `data` value under a different envelope; see the "Chain
2805
+ * subscription webhook payloads" doc for how to unwrap those.
2806
+ *
2807
+ * A chain-subscription delivery is NOT a Streams/Index event — do not run this
2808
+ * over a `StreamsEvent` body (`{ event_type, payload }`) or vice versa.
2809
+ *
2810
+ * @param rawBody The raw request body string (same bytes passed to
2811
+ * {@link verifyWebhookSignature}).
2812
+ * @throws {Error} if the body isn't a `chain.*` delivery, or the envelope is
2813
+ * internally inconsistent (e.g. `type` and `data.trigger` disagree —
2814
+ * a sign the wire shape drifted from this decoder).
2815
+ *
2816
+ * @example
2817
+ * ```ts
2818
+ * import { decodeChainWebhook, verifyWebhookSignature } from "@secondlayer/sdk";
2819
+ *
2820
+ * app.post("/webhook", async (c) => {
2821
+ * const raw = await c.req.text();
2822
+ * if (!verifyWebhookSignature(raw, c.req.raw.headers, process.env.SIGNING_SECRET!)) {
2823
+ * return c.text("Invalid signature", 401);
2824
+ * }
2825
+ * const delivery = decodeChainWebhook(raw);
2826
+ * if (delivery.data.action === "apply" && delivery.data.trigger === "stx_transfer") {
2827
+ * delivery.data.event.data.amount; // typed
2828
+ * }
2829
+ * return c.body(null, 204);
2830
+ * });
2831
+ * ```
2832
+ */
2833
+ declare function decodeChainWebhook(rawBody: string): ChainWebhookDelivery;
2720
2834
  import { RewardSet as RewardSet2 } from "@secondlayer/shared/node/consensus";
2721
2835
  /** Make a cvToValue result JSON-serializable: Clarity (u)ints decode to bigint,
2722
2836
  * which JSON.stringify can't handle — convert recursively to strings. */
@@ -2724,4 +2838,4 @@ declare function toJsonSafe(value: unknown): unknown;
2724
2838
  /** Decode a hex-encoded Clarity value to JSON-safe JS (uints as strings,
2725
2839
  * buffers as `0x…` hex, tuples as objects). Returns the input hex on failure. */
2726
2840
  declare function decodeClarityValue(hex: string): unknown;
2727
- export { withX402, verifyWebhookSignature, verifyTransactionProof, verifySecondlayerSignature, trigger, toJsonSafe, selectOffer, resolveAccountNonce, readX402Receipt, readX402Challenge, payAndRetry, isStxTransfer, isStxMint, isStxLock, isStxBurn, isPrint, isNftTransfer, isNftMint, isNftBurn, isFtTransfer, isFtMint, isFtBurn, getSubgraph, fetchRewardSet, decodeStxTransfer, decodeStxMint, decodeStxLock, decodeStxBurn, decodePrint, decodeNftTransfer, decodeNftMint, decodeNftBurn, decodeFtTransfer, decodeFtMint, decodeFtBurn, decodeClarityValue, createX402Client, createStreamsClient, consumeIndexFeed, buildSignedX402Payment, X402SpendGuardError, X402Result, X402Receipt, X402Fetch, X402ClientOptions, X402Client, X402Challenge, X402Accept, WithX402Options, VersionConflictError, ValidationError, UpdateSubscriptionRequest2 as UpdateSubscriptionRequest, UpdateProjectParams, TransactionsWalkParams, TransactionsListParams, TransactionsEnvelope, TransactionProofVerifyResult, TransactionProof, TransactionEnvelope, Subscriptions, SubscriptionSummary2 as SubscriptionSummary, SubscriptionStatus, SubscriptionRuntime, SubscriptionKind, SubscriptionFormat, SubscriptionDetail2 as SubscriptionDetail, Subgraphs, SubgraphSpecOptions3 as SubgraphSpecOptions, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphOperationStatus, SubgraphAgentSchema3 as SubgraphAgentSchema, StreamsUsage, StreamsTip, StreamsSignatureError, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorgContext, StreamsReorg, StreamsEventsSubscribeParams, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsDumpsManifest, StreamsDumps, StreamsDumpFile, StreamsConsumeParams, StreamsClient, StreamsCanonicalBlock, StreamsBatchContext, StreamsBatch, StackingWalkParams, StackingListParams, StackingEnvelope, SelectOfferOptions, SecondLayerOptions, SecondLayer, ScopedKeyProduct, SbtcWithdrawalsWalkParams, SbtcWithdrawalsListParams, SbtcWithdrawalsEnvelope, SbtcWithdrawalStatus, SbtcWithdrawalEnvelope, SbtcSummaryEnvelope, SbtcResource, SbtcEventsWalkParams, SbtcEventsListParams, SbtcEventsEnvelope, SbtcEventTopic, SbtcDepositsWalkParams, SbtcDepositsListParams, SbtcDepositsEnvelope, SbtcDepositEnvelope, RotateSecretResponse2 as RotateSecretResponse, RewardSet2 as RewardSet, ReplayResult2 as ReplayResult, RateLimitError, Projects, ProjectTeamMember, ProjectTeam, ProjectInvitation, Project, PrintSchemaResponse, PoxResource, PoxCyclesWalkParams, PoxCyclesListParams, PoxCyclesEnvelope, PoxCycleEnvelope, PayAndRetryOptions, NftTransfersWalkParams, NftTransfersResource, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload, NftTransferEvent, NftTransfer, MempoolWalkParams, MempoolTransactionEnvelope, MempoolListParams, MempoolEnvelope, IndexUsage, IndexTransaction, IndexTip, IndexStackingAction, IndexSbtcWithdrawalPhase, IndexSbtcWithdrawalDetail, IndexSbtcWithdrawal, IndexSbtcSummary, IndexSbtcEvent, IndexSbtcDepositDetail, IndexSbtcDeposit, IndexReorg, IndexPoxFunctionCount, IndexPoxCycle, IndexPostCondition, IndexMempoolTransaction, IndexEventsResource, IndexEventTypeFilters, IndexEventType, IndexEvent, IndexDiscovery, IndexContractCall, IndexConsumeOptions, IndexCanonicalBlock, IndexBlock, Index, FtTransfersWalkParams, FtTransfersResource, FtTransfersListParams, FtTransfersEnvelope, FtTransferPayload, FtTransferEvent, FtTransfer, FetchLike2 as FetchLike, EventsWalkParams, EventsListParams, EventsEnvelope, EventsConsumeParams, DeliveryRow2 as DeliveryRow, DecodedStxTransferPayload, DecodedStxTransfer, DecodedStxMintPayload, DecodedStxMint, DecodedStxLockPayload, DecodedStxLock, DecodedStxBurnPayload, DecodedStxBurn, DecodedPrintValue, DecodedPrintPayload, DecodedPrint, DecodedNftTransferPayload, DecodedNftTransfer, DecodedNftMintPayload, DecodedNftMint, DecodedNftBurnPayload, DecodedNftBurn, DecodedFtTransferPayload, DecodedFtTransfer, DecodedFtMintPayload, DecodedFtMint, DecodedFtBurnPayload, DecodedFtBurn, DecodedEventRow, DecodedEventColumns, DeadRow2 as DeadRow, DEFAULT_PREFER_ASSETS, Cursor, CreateSubscriptionResponse2 as CreateSubscriptionResponse, CreateSubscriptionRequest2 as CreateSubscriptionRequest, CreateProjectParams, CreateApiKeyResponse, CreateApiKeyParams, ContractsListParams, ContractsEnvelope, Contracts, ContractSummary, ContractConformance, ContractCallsWalkParams, ContractCallsListParams, ContractCallsEnvelope, ContractCallsConsumeParams, ContextSnapshot, ContextProject, ContextApiKey, ContextAccount, ChainTriggerType, ChainTrigger, CanonicalWalkParams, CanonicalListParams, CanonicalEnvelope, ByoBreakingChangeError, ByoBreakingChangeDetails, BuildSignedX402PaymentOptions, BlocksWalkParams, BlocksListParams, BlocksEnvelope, BlockEnvelope, AuthError, ApiKeys, ApiKeySummary, ApiError, ActiveSubgraphOperation };
2841
+ export { withX402, verifyWebhookSignature, verifyTransactionProof, verify as verifyStandardWebhooksHeaders, verifySecondlayerSignature, trigger, toJsonSafe, selectOffer, resolveAccountNonce, readX402Receipt, readX402Challenge, payAndRetry, isStxTransfer, isStxMint, isStxLock, isStxBurn, isPrint, isNftTransfer, isNftMint, isNftBurn, isFtTransfer, isFtMint, isFtBurn, getSubgraph, fetchRewardSet, decodeStxTransfer, decodeStxMint, decodeStxLock, decodeStxBurn, decodePrint, decodeNftTransfer, decodeNftMint, decodeNftBurn, decodeFtTransfer, decodeFtMint, decodeFtBurn, decodeClarityValue, decodeChainWebhook, createX402Client, createStreamsClient, consumeIndexFeed, buildSignedX402Payment, X402SpendGuardError, X402Result, X402Receipt, X402Fetch, X402ClientOptions, X402Client, X402Challenge, X402Accept, WithX402Options, WebhookHeaderInput, VersionConflictError, ValidationError, UpdateSubscriptionRequest2 as UpdateSubscriptionRequest, UpdateProjectParams, TransactionsWalkParams, TransactionsListParams, TransactionsEnvelope, TransactionProofVerifyResult, TransactionProof, TransactionEnvelope, Subscriptions, SubscriptionSummary2 as SubscriptionSummary, SubscriptionStatus, SubscriptionRuntime, SubscriptionKind, SubscriptionFormat, SubscriptionDetail2 as SubscriptionDetail, Subgraphs, SubgraphSpecOptions3 as SubgraphSpecOptions, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphOperationStatus, SubgraphAgentSchema3 as SubgraphAgentSchema, StreamsUsage, StreamsTip, StreamsSignatureError, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorgContext, StreamsReorg, StreamsEventsSubscribeParams, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsDumpsManifest, StreamsDumps, StreamsDumpFile, StreamsConsumeParams, StreamsClient, StreamsCanonicalBlock, StreamsBatchContext, StreamsBatch, StandardWebhooksHeaders2 as StandardWebhooksHeaders, StackingWalkParams, StackingListParams, StackingEnvelope, SelectOfferOptions, SecondLayerOptions, SecondLayer, ScopedKeyProduct, SbtcWithdrawalsWalkParams, SbtcWithdrawalsListParams, SbtcWithdrawalsEnvelope, SbtcWithdrawalSweptConfirmedEvent, SbtcWithdrawalStatus, SbtcWithdrawalEvent, SbtcWithdrawalEnvelope, SbtcSummaryEnvelope, SbtcResource, SbtcEventsWalkParams, SbtcEventsListParams, SbtcEventsEnvelope, SbtcEventTopic, SbtcDepositsWalkParams, SbtcDepositsListParams, SbtcDepositsEnvelope, SbtcDepositEvent, SbtcDepositEnvelope, RotateSecretResponse2 as RotateSecretResponse, RewardSet2 as RewardSet, ReplayResult2 as ReplayResult, RateLimitError, Projects, ProjectTeamMember, ProjectTeam, ProjectInvitation, Project, PrintSchemaResponse, PoxResource, PoxCyclesWalkParams, PoxCyclesListParams, PoxCyclesEnvelope, PoxCycleEnvelope, Pox5Resource, Pox5EventsWalkParams, Pox5EventsListParams, Pox5EventsEnvelope, PayAndRetryOptions, NftTransfersWalkParams, NftTransfersResource, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload, NftTransferEvent, NftTransfer, MempoolWalkParams, MempoolTransactionEnvelope, MempoolListParams, MempoolEnvelope, IndexUsage, IndexTransaction, IndexTip, IndexStackingAction, IndexSbtcWithdrawalPhase, IndexSbtcWithdrawalDetail, IndexSbtcWithdrawal, IndexSbtcSummary, IndexSbtcEvent, IndexSbtcDepositDetail, IndexSbtcDeposit, IndexReorg, IndexPoxFunctionCount, IndexPoxCycle, IndexPox5EventTopic, IndexPox5Event, IndexPostCondition, IndexMempoolTransaction, IndexEventsResource, IndexEventTypeFilters, IndexEventType, IndexEvent, IndexDiscovery, IndexContractCall, IndexConsumeOptions, IndexCanonicalBlock, IndexBlock, Index, FtTransfersWalkParams, FtTransfersResource, FtTransfersListParams, FtTransfersEnvelope, FtTransferPayload, FtTransferEvent, FtTransfer, FetchLike2 as FetchLike, EventsWalkParams, EventsListParams, EventsEnvelope, EventsConsumeParams, DeliveryRow2 as DeliveryRow, DecodedStxTransferPayload, DecodedStxTransfer, DecodedStxMintPayload, DecodedStxMint, DecodedStxLockPayload, DecodedStxLock, DecodedStxBurnPayload, DecodedStxBurn, DecodedPrintValue, DecodedPrintPayload, DecodedPrint, DecodedNftTransferPayload, DecodedNftTransfer, DecodedNftMintPayload, DecodedNftMint, DecodedNftBurnPayload, DecodedNftBurn, DecodedFtTransferPayload, DecodedFtTransfer, DecodedFtMintPayload, DecodedFtMint, DecodedFtBurnPayload, DecodedFtBurn, DecodedEventRow, DecodedEventColumns, DeadRow2 as DeadRow, DEFAULT_PREFER_ASSETS, Cursor, CreateSubscriptionResponse2 as CreateSubscriptionResponse, CreateSubscriptionRequest2 as CreateSubscriptionRequest, CreateProjectParams, CreateApiKeyResponse, CreateApiKeyParams, ContractsListParams, ContractsEnvelope, Contracts, ContractSummary, ContractConformance, ContractCallsWalkParams, ContractCallsListParams, ContractCallsEnvelope, ContractCallsConsumeParams, ContextSnapshot, ContextProject, ContextApiKey, ContextAccount, ChainWebhookEnvelope, ChainWebhookDelivery2 as ChainWebhookDelivery, ChainTxLevelEvent, ChainTriggerType, ChainTrigger, ChainTestDelivery, ChainStxTransferData, ChainStxMintData, ChainStxLockData, ChainStxBurnData, ChainReorgRollbackEnvelope, ChainReorgRollbackDelivery, ChainReorgOrphanedEntry, ChainPrintEventData, ChainNftTransferData, ChainNftMintData, ChainNftBurnData, ChainFtTransferData, ChainFtMintData, ChainFtBurnData, ChainEventEnvelope, ChainApplyEnvelopeOf, ChainApplyEnvelope, ChainApplyDeliveryOf, CanonicalWalkParams, CanonicalListParams, CanonicalEnvelope, ByoBreakingChangeError, ByoBreakingChangeDetails, BuildSignedX402PaymentOptions, BlocksWalkParams, BlocksListParams, BlocksEnvelope, BlockEnvelope, AuthError, ApiKeys, ApiKeySummary, ApiError, ActiveSubgraphOperation };
package/dist/index.js CHANGED
@@ -810,6 +810,12 @@ class Index extends BaseClient {
810
810
  get: (rewardCycle) => this.getPoxCycle(rewardCycle)
811
811
  }
812
812
  };
813
+ pox5 = {
814
+ events: {
815
+ list: (params = {}) => this.listPox5Events(params),
816
+ walk: (params = {}) => this.walkPox5Events(params)
817
+ }
818
+ };
813
819
  async listFtTransfers(params = {}) {
814
820
  return this.request("GET", `/v1/index/ft-transfers${buildQuery({
815
821
  cursor: params.cursor,
@@ -1038,6 +1044,25 @@ class Index extends BaseClient {
1038
1044
  async getSbtcSummary() {
1039
1045
  return this.request("GET", "/v1/index/sbtc/summary");
1040
1046
  }
1047
+ async listPox5Events(params = {}) {
1048
+ return this.request("GET", `/v1/index/pox5/events${buildQuery({
1049
+ cursor: params.cursor,
1050
+ from_cursor: params.fromCursor,
1051
+ limit: params.limit,
1052
+ confirmed: params.confirmed,
1053
+ topic: params.topic,
1054
+ staker: params.staker,
1055
+ signer: params.signer,
1056
+ signer_manager: params.signerManager,
1057
+ bond_index: params.bondIndex,
1058
+ reward_cycle: params.rewardCycle,
1059
+ from_height: params.fromHeight,
1060
+ to_height: params.toHeight
1061
+ })}`);
1062
+ }
1063
+ walkPox5Events(params = {}) {
1064
+ return this.keysetWalk(params, (page) => this.listPox5Events({ ...params, ...page }), (e) => e.events);
1065
+ }
1041
1066
  async listPoxCycles(params = {}) {
1042
1067
  return this.request("GET", `/v1/index/pox/cycles${buildQuery({
1043
1068
  cursor: params.cursor,
@@ -2260,6 +2285,33 @@ function verifySecondlayerSignature(rawBody, headers, publicKeyPem) {
2260
2285
  const signature = pickHeader(headers, "x-secondlayer-signature");
2261
2286
  return verifySecondlayerSignatureValues(rawBody, id, signature, publicKeyPem);
2262
2287
  }
2288
+ function decodeChainWebhook(rawBody) {
2289
+ const parsed = JSON.parse(rawBody);
2290
+ if (typeof parsed.type !== "string" || typeof parsed.timestamp !== "string" || typeof parsed.data !== "object" || parsed.data === null) {
2291
+ throw new Error("decodeChainWebhook: not a chain-subscription delivery — expected { type, timestamp, data }");
2292
+ }
2293
+ if (!parsed.type.startsWith("chain.")) {
2294
+ throw new Error(`decodeChainWebhook: not a chain-subscription delivery (type "${parsed.type}")`);
2295
+ }
2296
+ const data = parsed.data;
2297
+ if (parsed.type === "chain.test.apply") {
2298
+ if (data.test !== true) {
2299
+ throw new Error('decodeChainWebhook: "chain.test.apply" body missing `data.test: true`');
2300
+ }
2301
+ } else if (parsed.type === "chain.reorg.rollback") {
2302
+ if (data.action !== "rollback" || !Array.isArray(data.orphaned)) {
2303
+ throw new Error('decodeChainWebhook: "chain.reorg.rollback" body missing `data.action`/`data.orphaned`');
2304
+ }
2305
+ } else {
2306
+ if (data.action !== "apply" || typeof data.trigger !== "string") {
2307
+ throw new Error("decodeChainWebhook: apply delivery missing `data.action`/`data.trigger`");
2308
+ }
2309
+ if (parsed.type !== `chain.${data.trigger}.apply`) {
2310
+ throw new Error(`decodeChainWebhook: type "${parsed.type}" doesn't match data.trigger "${data.trigger}"`);
2311
+ }
2312
+ }
2313
+ return parsed;
2314
+ }
2263
2315
  // src/proofs.ts
2264
2316
  import {
2265
2317
  verifySignerSignatures
@@ -2339,6 +2391,7 @@ export {
2339
2391
  withX402,
2340
2392
  verifyWebhookSignature,
2341
2393
  verifyTransactionProof,
2394
+ verify2 as verifyStandardWebhooksHeaders,
2342
2395
  verifySecondlayerSignature,
2343
2396
  trigger,
2344
2397
  toJsonSafe,
@@ -2372,6 +2425,7 @@ export {
2372
2425
  decodeFtMint,
2373
2426
  decodeFtBurn,
2374
2427
  decodeClarityValue,
2428
+ decodeChainWebhook,
2375
2429
  createX402Client,
2376
2430
  createStreamsClient,
2377
2431
  consumeIndexFeed,
@@ -2396,5 +2450,5 @@ export {
2396
2450
  ApiError
2397
2451
  };
2398
2452
 
2399
- //# debugId=5E9E0D97F72D6DEB64756E2164756E21
2453
+ //# debugId=A3035E23B178A62A64756E2164756E21
2400
2454
  //# sourceMappingURL=index.js.map