@secondlayer/sdk 6.26.0 → 6.27.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
@@ -1413,6 +1413,265 @@ type PrintSchemaResponse = {
1413
1413
  }
1414
1414
  tip: IndexTip
1415
1415
  };
1416
+ /** The decoded `sbtc_events` topics. */
1417
+ type SbtcEventTopic = "completed-deposit" | "withdrawal-create" | "withdrawal-accept" | "withdrawal-reject" | "key-rotation" | "update-protocol-contract";
1418
+ type SbtcWithdrawalStatus = "REQUESTED" | "ACCEPTED" | "REJECTED";
1419
+ /** A completed sBTC peg-in, keyed by `bitcoin_txid` (deposits carry no
1420
+ * `request_id`). One terminal `completed-deposit` event per deposit. */
1421
+ type IndexSbtcDeposit = {
1422
+ cursor: string
1423
+ block_height: number
1424
+ block_time?: string | null
1425
+ tx_id: string
1426
+ tx_index: number
1427
+ event_index: number
1428
+ amount: string | null
1429
+ sender: string | null
1430
+ bitcoin_txid: string | null
1431
+ output_index: number | null
1432
+ recipient_btc_version: number | null
1433
+ recipient_btc_hashbytes: string | null
1434
+ };
1435
+ /** A deposit fetched by Bitcoin txid — always terminal, hence `status`. */
1436
+ type IndexSbtcDepositDetail = IndexSbtcDeposit & {
1437
+ status: "COMPLETED"
1438
+ };
1439
+ /** A peg-out collapsed to one row per `request_id`, with lifecycle `status`
1440
+ * derived from the latest accept/reject. */
1441
+ type IndexSbtcWithdrawal = {
1442
+ cursor: string
1443
+ request_id: number
1444
+ status: SbtcWithdrawalStatus
1445
+ amount: string | null
1446
+ sender: string | null
1447
+ recipient_btc_version: number | null
1448
+ recipient_btc_hashbytes: string | null
1449
+ sweep_txid: string | null
1450
+ requested_at?: string | null
1451
+ resolved_at?: string | null
1452
+ };
1453
+ /** One phase of a withdrawal's lifecycle (the on-Stacks event that drove it). */
1454
+ type IndexSbtcWithdrawalPhase = {
1455
+ block_height: number
1456
+ block_time: string | null
1457
+ tx_id: string
1458
+ };
1459
+ /** A single peg-out's full assembled lifecycle, fetched by `request_id`.
1460
+ * `finalized` is true once terminal and past the reorg margin. */
1461
+ type IndexSbtcWithdrawalDetail = {
1462
+ request_id: number
1463
+ status: SbtcWithdrawalStatus
1464
+ amount: string | null
1465
+ sender: string | null
1466
+ recipient_btc_version: number | null
1467
+ recipient_btc_hashbytes: string | null
1468
+ requested: IndexSbtcWithdrawalPhase
1469
+ accepted: (IndexSbtcWithdrawalPhase & {
1470
+ sweep_txid: string | null
1471
+ signer_bitmap: string | null
1472
+ }) | null
1473
+ rejected: IndexSbtcWithdrawalPhase | null
1474
+ settlement: {
1475
+ sweep_txid: string | null
1476
+ btc_confirmations: number | null
1477
+ settlement_confirmed: boolean | null
1478
+ }
1479
+ finalized: boolean
1480
+ };
1481
+ /** A raw decoded sBTC protocol-state event — the full `sbtc_events` row, one
1482
+ * per event across all topics. */
1483
+ type IndexSbtcEvent = {
1484
+ cursor: string
1485
+ block_height: number
1486
+ block_time?: string | null
1487
+ tx_id: string
1488
+ tx_index: number
1489
+ event_index: number
1490
+ topic: SbtcEventTopic
1491
+ request_id: number | null
1492
+ amount: string | null
1493
+ sender: string | null
1494
+ recipient_btc_version: number | null
1495
+ recipient_btc_hashbytes: string | null
1496
+ bitcoin_txid: string | null
1497
+ output_index: number | null
1498
+ sweep_txid: string | null
1499
+ burn_hash: string | null
1500
+ burn_height: number | null
1501
+ signer_bitmap: string | null
1502
+ max_fee: string | null
1503
+ fee: string | null
1504
+ governance_contract_type: number | null
1505
+ governance_new_contract: string | null
1506
+ signer_aggregate_pubkey: string | null
1507
+ signer_threshold: number | null
1508
+ signer_address: string | null
1509
+ signer_keys_count: number | null
1510
+ };
1511
+ /** The peg "scoreboard" — a single all-time canonical aggregate. */
1512
+ type IndexSbtcSummary = {
1513
+ total_deposits: number
1514
+ total_withdrawals_requested: number
1515
+ total_withdrawals_accepted: number
1516
+ total_withdrawals_rejected: number
1517
+ net_peg_flow_sats: string
1518
+ total_locked_sats: string
1519
+ sbtc_supply_sats: string | null
1520
+ };
1521
+ type SbtcDepositsEnvelope = {
1522
+ deposits: IndexSbtcDeposit[]
1523
+ next_cursor: string | null
1524
+ tip: IndexTip
1525
+ reorgs: IndexReorg[]
1526
+ /** Present only when the sBTC decoder is disabled, explaining an empty feed. */
1527
+ notes?: string
1528
+ };
1529
+ type SbtcDepositEnvelope = {
1530
+ deposit: IndexSbtcDepositDetail
1531
+ tip: IndexTip
1532
+ };
1533
+ type SbtcWithdrawalsEnvelope = {
1534
+ withdrawals: IndexSbtcWithdrawal[]
1535
+ next_cursor: string | null
1536
+ tip: IndexTip
1537
+ reorgs: IndexReorg[]
1538
+ notes?: string
1539
+ };
1540
+ type SbtcWithdrawalEnvelope = {
1541
+ withdrawal: IndexSbtcWithdrawalDetail
1542
+ tip: IndexTip
1543
+ };
1544
+ type SbtcEventsEnvelope = {
1545
+ events: IndexSbtcEvent[]
1546
+ next_cursor: string | null
1547
+ tip: IndexTip
1548
+ reorgs: IndexReorg[]
1549
+ notes?: string
1550
+ };
1551
+ type SbtcSummaryEnvelope = {
1552
+ summary: IndexSbtcSummary
1553
+ tip: IndexTip
1554
+ notes?: string
1555
+ };
1556
+ type SbtcDepositsListParams = {
1557
+ cursor?: string | null
1558
+ fromCursor?: string | null
1559
+ limit?: number
1560
+ /** Clamp to the finality boundary — only settled deposits past the reorg margin. */
1561
+ confirmed?: boolean
1562
+ sender?: string
1563
+ bitcoinTxid?: string
1564
+ fromHeight?: number
1565
+ toHeight?: number
1566
+ };
1567
+ type SbtcDepositsWalkParams = Omit<SbtcDepositsListParams, "limit"> & {
1568
+ batchSize?: number
1569
+ signal?: AbortSignal
1570
+ };
1571
+ type SbtcWithdrawalsListParams = {
1572
+ cursor?: string | null
1573
+ fromCursor?: string | null
1574
+ limit?: number
1575
+ confirmed?: boolean
1576
+ status?: SbtcWithdrawalStatus
1577
+ sender?: string
1578
+ requestId?: number
1579
+ fromHeight?: number
1580
+ toHeight?: number
1581
+ };
1582
+ type SbtcWithdrawalsWalkParams = Omit<SbtcWithdrawalsListParams, "limit"> & {
1583
+ batchSize?: number
1584
+ signal?: AbortSignal
1585
+ };
1586
+ type SbtcEventsListParams = {
1587
+ cursor?: string | null
1588
+ fromCursor?: string | null
1589
+ limit?: number
1590
+ confirmed?: boolean
1591
+ topic?: SbtcEventTopic
1592
+ sender?: string
1593
+ requestId?: number
1594
+ bitcoinTxid?: string
1595
+ fromHeight?: number
1596
+ toHeight?: number
1597
+ };
1598
+ type SbtcEventsWalkParams = Omit<SbtcEventsListParams, "limit"> & {
1599
+ batchSize?: number
1600
+ signal?: AbortSignal
1601
+ };
1602
+ /** `index.sbtc` — the decoded sBTC peg surface (deposits, withdrawals, raw
1603
+ * events, scoreboard). The only productized decoded sBTC peg feed on Stacks. */
1604
+ interface SbtcResource {
1605
+ deposits: {
1606
+ list(params?: SbtcDepositsListParams): Promise<SbtcDepositsEnvelope>
1607
+ walk(params?: SbtcDepositsWalkParams): AsyncIterable<IndexSbtcDeposit>
1608
+ /** Fetch a completed deposit by Bitcoin txid; 404 → null. */
1609
+ get(bitcoinTxid: string): Promise<SbtcDepositEnvelope | null>
1610
+ };
1611
+ withdrawals: {
1612
+ list(params?: SbtcWithdrawalsListParams): Promise<SbtcWithdrawalsEnvelope>
1613
+ walk(params?: SbtcWithdrawalsWalkParams): AsyncIterable<IndexSbtcWithdrawal>
1614
+ /** Fetch a withdrawal's full lifecycle by request id; 404 → null. */
1615
+ get(requestId: number): Promise<SbtcWithdrawalEnvelope | null>
1616
+ };
1617
+ events: {
1618
+ list(params?: SbtcEventsListParams): Promise<SbtcEventsEnvelope>
1619
+ walk(params?: SbtcEventsWalkParams): AsyncIterable<IndexSbtcEvent>
1620
+ };
1621
+ /** The peg scoreboard — a single all-time aggregate (no pagination). */
1622
+ summary(): Promise<SbtcSummaryEnvelope>;
1623
+ }
1624
+ /** Per-function action count within a reward cycle. */
1625
+ type IndexPoxFunctionCount = {
1626
+ function_name: string
1627
+ count: number
1628
+ };
1629
+ /** Aggregate stats for one PoX reward cycle — distinct from `index.stacking`
1630
+ * (decoded per-call PoX-4 actions); this is the reward-cycle rollup. */
1631
+ type IndexPoxCycle = {
1632
+ reward_cycle: number
1633
+ /** Total ustx locked across all stack-* calls in this cycle (bigint-safe string). */
1634
+ total_stacked_ustx: string
1635
+ unique_stackers: number
1636
+ unique_delegators: number
1637
+ action_count: number
1638
+ start_block_height: number
1639
+ end_block_height: number
1640
+ /** True when this is the latest reward cycle (still accumulating new actions). */
1641
+ is_current: boolean
1642
+ function_breakdown: IndexPoxFunctionCount[]
1643
+ };
1644
+ type PoxCyclesEnvelope = {
1645
+ cycles: IndexPoxCycle[]
1646
+ /** The next `reward_cycle` to page from (cycles descend), or null at the end. */
1647
+ next_cursor: number | null
1648
+ tip: IndexTip
1649
+ /** Present only when the PoX-4 decoder is disabled, explaining an empty feed. */
1650
+ notes?: string
1651
+ };
1652
+ type PoxCycleEnvelope = {
1653
+ cycle: IndexPoxCycle
1654
+ tip: IndexTip
1655
+ notes?: string
1656
+ };
1657
+ type PoxCyclesListParams = {
1658
+ /** A `reward_cycle` to page from; the page returns cycles below it (descending). */
1659
+ cursor?: number | null
1660
+ limit?: number
1661
+ };
1662
+ type PoxCyclesWalkParams = Omit<PoxCyclesListParams, "limit"> & {
1663
+ batchSize?: number
1664
+ signal?: AbortSignal
1665
+ };
1666
+ /** `index.pox` — PoX reward-cycle aggregates. */
1667
+ interface PoxResource {
1668
+ cycles: {
1669
+ list(params?: PoxCyclesListParams): Promise<PoxCyclesEnvelope>
1670
+ walk(params?: PoxCyclesWalkParams): AsyncIterable<IndexPoxCycle>
1671
+ /** Fetch one reward cycle's aggregate by number; 404 → null. */
1672
+ get(rewardCycle: number): Promise<PoxCycleEnvelope | null>
1673
+ };
1674
+ }
1416
1675
  /**
1417
1676
  * `index.ftTransfers` — callable shorthand for `.list()`, with `.list`/`.walk`
1418
1677
  * still available: `await sl.index.ftTransfers({ contractId })`.
@@ -1521,6 +1780,12 @@ declare class Index extends BaseClient {
1521
1780
  walk: (params?: MempoolWalkParams) => AsyncIterable<IndexMempoolTransaction>
1522
1781
  get: (txId: string) => Promise<MempoolTransactionEnvelope | null>
1523
1782
  };
1783
+ /** Decoded sBTC peg surface — the only productized decoded sBTC peg feed on
1784
+ * Stacks. `deposits`/`withdrawals`/`events` paginate; `summary` is a scalar. */
1785
+ readonly sbtc: SbtcResource;
1786
+ /** PoX reward-cycle aggregates. Distinct from `stacking` (per-call PoX-4
1787
+ * actions); `cycles` is the reward-cycle rollup. */
1788
+ readonly pox: PoxResource;
1524
1789
  private listFtTransfers;
1525
1790
  private listNftTransfers;
1526
1791
  private walkFtTransfers;
@@ -1547,6 +1812,18 @@ declare class Index extends BaseClient {
1547
1812
  private listMempool;
1548
1813
  private getMempoolTx;
1549
1814
  private walkMempool;
1815
+ private listSbtcDeposits;
1816
+ private walkSbtcDeposits;
1817
+ private getSbtcDeposit;
1818
+ private listSbtcWithdrawals;
1819
+ private walkSbtcWithdrawals;
1820
+ private getSbtcWithdrawal;
1821
+ private listSbtcEvents;
1822
+ private walkSbtcEvents;
1823
+ private getSbtcSummary;
1824
+ private listPoxCycles;
1825
+ private walkPoxCycles;
1826
+ private getPoxCycle;
1550
1827
  }
1551
1828
  /**
1552
1829
  * Typed client for project management (`/api/projects/*`).
@@ -2422,4 +2699,4 @@ declare function toJsonSafe(value: unknown): unknown;
2422
2699
  /** Decode a hex-encoded Clarity value to JSON-safe JS (uints as strings,
2423
2700
  * buffers as `0x…` hex, tuples as objects). Returns the input hex on failure. */
2424
2701
  declare function decodeClarityValue(hex: string): unknown;
2425
- 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, RotateSecretResponse2 as RotateSecretResponse, RewardSet2 as RewardSet, ReplayResult2 as ReplayResult, RateLimitError, Projects, ProjectTeamMember, ProjectTeam, ProjectInvitation, Project, PrintSchemaResponse, PayAndRetryOptions, NftTransfersWalkParams, NftTransfersResource, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload, NftTransferEvent, NftTransfer, MempoolWalkParams, MempoolTransactionEnvelope, MempoolListParams, MempoolEnvelope, IndexUsage, IndexTransaction, IndexTip, IndexStackingAction, IndexReorg, 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 };
2702
+ 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 };
package/dist/index.js CHANGED
@@ -234,11 +234,7 @@ function buildAggregateQueryString(params) {
234
234
  return str ? `?${str}` : "";
235
235
  }
236
236
  function buildSpecQueryString(options) {
237
- const qs = new URLSearchParams;
238
- if (options?.serverUrl)
239
- qs.set("server", options.serverUrl);
240
- const str = qs.toString();
241
- return str ? `?${str}` : "";
237
+ return buildQuery({ server: options?.serverUrl });
242
238
  }
243
239
 
244
240
  class Subgraphs extends BaseClient {
@@ -267,18 +263,15 @@ class Subgraphs extends BaseClient {
267
263
  return this.request("POST", `/api/subgraphs/${name}/backfill`, options);
268
264
  }
269
265
  async gaps(name, opts) {
270
- const qs = new URLSearchParams;
271
- if (opts?.limit !== undefined)
272
- qs.set("_limit", String(opts.limit));
273
- if (opts?.offset !== undefined)
274
- qs.set("_offset", String(opts.offset));
275
- if (opts?.resolved !== undefined)
276
- qs.set("resolved", String(opts.resolved));
277
- const query = qs.toString();
278
- return this.request("GET", `/api/subgraphs/${name}/gaps${query ? `?${query}` : ""}`);
266
+ const qs = buildQuery({
267
+ _limit: opts?.limit,
268
+ _offset: opts?.offset,
269
+ resolved: opts?.resolved
270
+ });
271
+ return this.request("GET", `/api/subgraphs/${name}/gaps${qs}`);
279
272
  }
280
273
  async delete(name, options) {
281
- const qs = options?.force ? "?force=true" : "";
274
+ const qs = buildQuery({ force: options?.force ? true : undefined });
282
275
  return this.request("DELETE", `/api/subgraphs/${name}${qs}`);
283
276
  }
284
277
  async publish(name) {
@@ -818,6 +811,30 @@ class Index extends BaseClient {
818
811
  walk: (params = {}) => this.walkMempool(params),
819
812
  get: (txId) => this.getMempoolTx(txId)
820
813
  };
814
+ sbtc = {
815
+ deposits: {
816
+ list: (params = {}) => this.listSbtcDeposits(params),
817
+ walk: (params = {}) => this.walkSbtcDeposits(params),
818
+ get: (bitcoinTxid) => this.getSbtcDeposit(bitcoinTxid)
819
+ },
820
+ withdrawals: {
821
+ list: (params = {}) => this.listSbtcWithdrawals(params),
822
+ walk: (params = {}) => this.walkSbtcWithdrawals(params),
823
+ get: (requestId) => this.getSbtcWithdrawal(requestId)
824
+ },
825
+ events: {
826
+ list: (params = {}) => this.listSbtcEvents(params),
827
+ walk: (params = {}) => this.walkSbtcEvents(params)
828
+ },
829
+ summary: () => this.getSbtcSummary()
830
+ };
831
+ pox = {
832
+ cycles: {
833
+ list: (params = {}) => this.listPoxCycles(params),
834
+ walk: (params = {}) => this.walkPoxCycles(params),
835
+ get: (rewardCycle) => this.getPoxCycle(rewardCycle)
836
+ }
837
+ };
821
838
  async listFtTransfers(params = {}) {
822
839
  return this.request("GET", `/v1/index/ft-transfers${buildQuery({
823
840
  cursor: params.cursor,
@@ -1184,6 +1201,173 @@ class Index extends BaseClient {
1184
1201
  firstPage = false;
1185
1202
  }
1186
1203
  }
1204
+ async listSbtcDeposits(params = {}) {
1205
+ return this.request("GET", `/v1/index/sbtc/deposits${buildQuery({
1206
+ cursor: params.cursor,
1207
+ from_cursor: params.fromCursor,
1208
+ limit: params.limit,
1209
+ confirmed: params.confirmed,
1210
+ sender: params.sender,
1211
+ bitcoin_txid: params.bitcoinTxid,
1212
+ from_height: params.fromHeight,
1213
+ to_height: params.toHeight
1214
+ })}`);
1215
+ }
1216
+ async* walkSbtcDeposits(params = {}) {
1217
+ const batchSize = params.batchSize ?? 200;
1218
+ let cursor = params.cursor ?? params.fromCursor ?? null;
1219
+ let firstPage = true;
1220
+ while (!params.signal?.aborted) {
1221
+ const envelope = await this.listSbtcDeposits({
1222
+ ...params,
1223
+ limit: batchSize,
1224
+ cursor: firstPage ? params.cursor : cursor,
1225
+ fromCursor: firstPage ? params.fromCursor : undefined,
1226
+ fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
1227
+ });
1228
+ for (const deposit of envelope.deposits) {
1229
+ if (params.signal?.aborted)
1230
+ return;
1231
+ yield deposit;
1232
+ }
1233
+ const nextCursor = envelope.next_cursor;
1234
+ if (!nextCursor || nextCursor === cursor || envelope.deposits.length < batchSize) {
1235
+ return;
1236
+ }
1237
+ cursor = nextCursor;
1238
+ firstPage = false;
1239
+ }
1240
+ }
1241
+ async getSbtcDeposit(bitcoinTxid) {
1242
+ try {
1243
+ return await this.request("GET", `/v1/index/sbtc/deposits/${encodeURIComponent(bitcoinTxid)}`);
1244
+ } catch (err) {
1245
+ if (err instanceof ApiError && err.status === 404)
1246
+ return null;
1247
+ throw err;
1248
+ }
1249
+ }
1250
+ async listSbtcWithdrawals(params = {}) {
1251
+ return this.request("GET", `/v1/index/sbtc/withdrawals${buildQuery({
1252
+ cursor: params.cursor,
1253
+ from_cursor: params.fromCursor,
1254
+ limit: params.limit,
1255
+ confirmed: params.confirmed,
1256
+ status: params.status,
1257
+ sender: params.sender,
1258
+ request_id: params.requestId,
1259
+ from_height: params.fromHeight,
1260
+ to_height: params.toHeight
1261
+ })}`);
1262
+ }
1263
+ async* walkSbtcWithdrawals(params = {}) {
1264
+ const batchSize = params.batchSize ?? 200;
1265
+ let cursor = params.cursor ?? params.fromCursor ?? null;
1266
+ let firstPage = true;
1267
+ while (!params.signal?.aborted) {
1268
+ const envelope = await this.listSbtcWithdrawals({
1269
+ ...params,
1270
+ limit: batchSize,
1271
+ cursor: firstPage ? params.cursor : cursor,
1272
+ fromCursor: firstPage ? params.fromCursor : undefined,
1273
+ fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
1274
+ });
1275
+ for (const withdrawal of envelope.withdrawals) {
1276
+ if (params.signal?.aborted)
1277
+ return;
1278
+ yield withdrawal;
1279
+ }
1280
+ const nextCursor = envelope.next_cursor;
1281
+ if (!nextCursor || nextCursor === cursor || envelope.withdrawals.length < batchSize) {
1282
+ return;
1283
+ }
1284
+ cursor = nextCursor;
1285
+ firstPage = false;
1286
+ }
1287
+ }
1288
+ async getSbtcWithdrawal(requestId) {
1289
+ try {
1290
+ return await this.request("GET", `/v1/index/sbtc/withdrawals/${requestId}`);
1291
+ } catch (err) {
1292
+ if (err instanceof ApiError && err.status === 404)
1293
+ return null;
1294
+ throw err;
1295
+ }
1296
+ }
1297
+ async listSbtcEvents(params = {}) {
1298
+ return this.request("GET", `/v1/index/sbtc/events${buildQuery({
1299
+ cursor: params.cursor,
1300
+ from_cursor: params.fromCursor,
1301
+ limit: params.limit,
1302
+ confirmed: params.confirmed,
1303
+ topic: params.topic,
1304
+ sender: params.sender,
1305
+ request_id: params.requestId,
1306
+ bitcoin_txid: params.bitcoinTxid,
1307
+ from_height: params.fromHeight,
1308
+ to_height: params.toHeight
1309
+ })}`);
1310
+ }
1311
+ async* walkSbtcEvents(params = {}) {
1312
+ const batchSize = params.batchSize ?? 200;
1313
+ let cursor = params.cursor ?? params.fromCursor ?? null;
1314
+ let firstPage = true;
1315
+ while (!params.signal?.aborted) {
1316
+ const envelope = await this.listSbtcEvents({
1317
+ ...params,
1318
+ limit: batchSize,
1319
+ cursor: firstPage ? params.cursor : cursor,
1320
+ fromCursor: firstPage ? params.fromCursor : undefined,
1321
+ fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
1322
+ });
1323
+ for (const event of envelope.events) {
1324
+ if (params.signal?.aborted)
1325
+ return;
1326
+ yield event;
1327
+ }
1328
+ const nextCursor = envelope.next_cursor;
1329
+ if (!nextCursor || nextCursor === cursor || envelope.events.length < batchSize) {
1330
+ return;
1331
+ }
1332
+ cursor = nextCursor;
1333
+ firstPage = false;
1334
+ }
1335
+ }
1336
+ async getSbtcSummary() {
1337
+ return this.request("GET", "/v1/index/sbtc/summary");
1338
+ }
1339
+ async listPoxCycles(params = {}) {
1340
+ return this.request("GET", `/v1/index/pox/cycles${buildQuery({
1341
+ cursor: params.cursor,
1342
+ limit: params.limit
1343
+ })}`);
1344
+ }
1345
+ async* walkPoxCycles(params = {}) {
1346
+ const batchSize = params.batchSize ?? 100;
1347
+ let cursor = params.cursor ?? null;
1348
+ while (!params.signal?.aborted) {
1349
+ const envelope = await this.listPoxCycles({ cursor, limit: batchSize });
1350
+ for (const cycle of envelope.cycles) {
1351
+ if (params.signal?.aborted)
1352
+ return;
1353
+ yield cycle;
1354
+ }
1355
+ const nextCursor = envelope.next_cursor;
1356
+ if (nextCursor === null || nextCursor === cursor || envelope.cycles.length < batchSize) {
1357
+ return;
1358
+ }
1359
+ cursor = nextCursor;
1360
+ }
1361
+ }
1362
+ async getPoxCycle(rewardCycle) {
1363
+ try {
1364
+ return await this.request("GET", `/v1/index/pox/cycles/${rewardCycle}`);
1365
+ } catch (err) {
1366
+ if (err instanceof ApiError && err.status === 404)
1367
+ return null;
1368
+ throw err;
1369
+ }
1370
+ }
1187
1371
  }
1188
1372
 
1189
1373
  // src/projects/client.ts
@@ -2517,5 +2701,5 @@ export {
2517
2701
  ApiError
2518
2702
  };
2519
2703
 
2520
- //# debugId=997EE849532E462E64756E2164756E21
2704
+ //# debugId=FEC0971346A0193B64756E2164756E21
2521
2705
  //# sourceMappingURL=index.js.map