@secondlayer/sdk 6.26.1 → 6.27.1
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 +281 -1
- package/dist/index.js +190 -44
- package/dist/index.js.map +5 -5
- package/dist/streams/index.js +10 -1
- package/dist/streams/index.js.map +3 -3
- package/dist/subgraphs/index.d.ts +280 -0
- package/dist/subgraphs/index.js +190 -44
- package/dist/subgraphs/index.js.map +5 -5
- package/package.json +2 -4
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,9 @@ declare abstract class BaseClient {
|
|
|
24
24
|
constructor(options?: Partial<SecondLayerOptions>);
|
|
25
25
|
static authHeaders(apiKey?: string): Record<string, string>;
|
|
26
26
|
protected request<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
27
|
+
/** Like `request`, but maps a 404 to `null` instead of throwing — the one
|
|
28
|
+
* place that owns the "absent resource" rule for `get*` accessors. */
|
|
29
|
+
protected requestOrNull<T>(method: string, path: string, body?: unknown): Promise<T | null>;
|
|
27
30
|
protected requestText(method: string, path: string, body?: unknown): Promise<string>;
|
|
28
31
|
private fetchResponse;
|
|
29
32
|
}
|
|
@@ -1413,6 +1416,265 @@ type PrintSchemaResponse = {
|
|
|
1413
1416
|
}
|
|
1414
1417
|
tip: IndexTip
|
|
1415
1418
|
};
|
|
1419
|
+
/** The decoded `sbtc_events` topics. */
|
|
1420
|
+
type SbtcEventTopic = "completed-deposit" | "withdrawal-create" | "withdrawal-accept" | "withdrawal-reject" | "key-rotation" | "update-protocol-contract";
|
|
1421
|
+
type SbtcWithdrawalStatus = "REQUESTED" | "ACCEPTED" | "REJECTED";
|
|
1422
|
+
/** A completed sBTC peg-in, keyed by `bitcoin_txid` (deposits carry no
|
|
1423
|
+
* `request_id`). One terminal `completed-deposit` event per deposit. */
|
|
1424
|
+
type IndexSbtcDeposit = {
|
|
1425
|
+
cursor: string
|
|
1426
|
+
block_height: number
|
|
1427
|
+
block_time?: string | null
|
|
1428
|
+
tx_id: string
|
|
1429
|
+
tx_index: number
|
|
1430
|
+
event_index: number
|
|
1431
|
+
amount: string | null
|
|
1432
|
+
sender: string | null
|
|
1433
|
+
bitcoin_txid: string | null
|
|
1434
|
+
output_index: number | null
|
|
1435
|
+
recipient_btc_version: number | null
|
|
1436
|
+
recipient_btc_hashbytes: string | null
|
|
1437
|
+
};
|
|
1438
|
+
/** A deposit fetched by Bitcoin txid — always terminal, hence `status`. */
|
|
1439
|
+
type IndexSbtcDepositDetail = IndexSbtcDeposit & {
|
|
1440
|
+
status: "COMPLETED"
|
|
1441
|
+
};
|
|
1442
|
+
/** A peg-out collapsed to one row per `request_id`, with lifecycle `status`
|
|
1443
|
+
* derived from the latest accept/reject. */
|
|
1444
|
+
type IndexSbtcWithdrawal = {
|
|
1445
|
+
cursor: string
|
|
1446
|
+
request_id: number
|
|
1447
|
+
status: SbtcWithdrawalStatus
|
|
1448
|
+
amount: string | null
|
|
1449
|
+
sender: string | null
|
|
1450
|
+
recipient_btc_version: number | null
|
|
1451
|
+
recipient_btc_hashbytes: string | null
|
|
1452
|
+
sweep_txid: string | null
|
|
1453
|
+
requested_at?: string | null
|
|
1454
|
+
resolved_at?: string | null
|
|
1455
|
+
};
|
|
1456
|
+
/** One phase of a withdrawal's lifecycle (the on-Stacks event that drove it). */
|
|
1457
|
+
type IndexSbtcWithdrawalPhase = {
|
|
1458
|
+
block_height: number
|
|
1459
|
+
block_time: string | null
|
|
1460
|
+
tx_id: string
|
|
1461
|
+
};
|
|
1462
|
+
/** A single peg-out's full assembled lifecycle, fetched by `request_id`.
|
|
1463
|
+
* `finalized` is true once terminal and past the reorg margin. */
|
|
1464
|
+
type IndexSbtcWithdrawalDetail = {
|
|
1465
|
+
request_id: number
|
|
1466
|
+
status: SbtcWithdrawalStatus
|
|
1467
|
+
amount: string | null
|
|
1468
|
+
sender: string | null
|
|
1469
|
+
recipient_btc_version: number | null
|
|
1470
|
+
recipient_btc_hashbytes: string | null
|
|
1471
|
+
requested: IndexSbtcWithdrawalPhase
|
|
1472
|
+
accepted: (IndexSbtcWithdrawalPhase & {
|
|
1473
|
+
sweep_txid: string | null
|
|
1474
|
+
signer_bitmap: string | null
|
|
1475
|
+
}) | null
|
|
1476
|
+
rejected: IndexSbtcWithdrawalPhase | null
|
|
1477
|
+
settlement: {
|
|
1478
|
+
sweep_txid: string | null
|
|
1479
|
+
btc_confirmations: number | null
|
|
1480
|
+
settlement_confirmed: boolean | null
|
|
1481
|
+
}
|
|
1482
|
+
finalized: boolean
|
|
1483
|
+
};
|
|
1484
|
+
/** A raw decoded sBTC protocol-state event — the full `sbtc_events` row, one
|
|
1485
|
+
* per event across all topics. */
|
|
1486
|
+
type IndexSbtcEvent = {
|
|
1487
|
+
cursor: string
|
|
1488
|
+
block_height: number
|
|
1489
|
+
block_time?: string | null
|
|
1490
|
+
tx_id: string
|
|
1491
|
+
tx_index: number
|
|
1492
|
+
event_index: number
|
|
1493
|
+
topic: SbtcEventTopic
|
|
1494
|
+
request_id: number | null
|
|
1495
|
+
amount: string | null
|
|
1496
|
+
sender: string | null
|
|
1497
|
+
recipient_btc_version: number | null
|
|
1498
|
+
recipient_btc_hashbytes: string | null
|
|
1499
|
+
bitcoin_txid: string | null
|
|
1500
|
+
output_index: number | null
|
|
1501
|
+
sweep_txid: string | null
|
|
1502
|
+
burn_hash: string | null
|
|
1503
|
+
burn_height: number | null
|
|
1504
|
+
signer_bitmap: string | null
|
|
1505
|
+
max_fee: string | null
|
|
1506
|
+
fee: string | null
|
|
1507
|
+
governance_contract_type: number | null
|
|
1508
|
+
governance_new_contract: string | null
|
|
1509
|
+
signer_aggregate_pubkey: string | null
|
|
1510
|
+
signer_threshold: number | null
|
|
1511
|
+
signer_address: string | null
|
|
1512
|
+
signer_keys_count: number | null
|
|
1513
|
+
};
|
|
1514
|
+
/** The peg "scoreboard" — a single all-time canonical aggregate. */
|
|
1515
|
+
type IndexSbtcSummary = {
|
|
1516
|
+
total_deposits: number
|
|
1517
|
+
total_withdrawals_requested: number
|
|
1518
|
+
total_withdrawals_accepted: number
|
|
1519
|
+
total_withdrawals_rejected: number
|
|
1520
|
+
net_peg_flow_sats: string
|
|
1521
|
+
total_locked_sats: string
|
|
1522
|
+
sbtc_supply_sats: string | null
|
|
1523
|
+
};
|
|
1524
|
+
type SbtcDepositsEnvelope = {
|
|
1525
|
+
deposits: IndexSbtcDeposit[]
|
|
1526
|
+
next_cursor: string | null
|
|
1527
|
+
tip: IndexTip
|
|
1528
|
+
reorgs: IndexReorg[]
|
|
1529
|
+
/** Present only when the sBTC decoder is disabled, explaining an empty feed. */
|
|
1530
|
+
notes?: string
|
|
1531
|
+
};
|
|
1532
|
+
type SbtcDepositEnvelope = {
|
|
1533
|
+
deposit: IndexSbtcDepositDetail
|
|
1534
|
+
tip: IndexTip
|
|
1535
|
+
};
|
|
1536
|
+
type SbtcWithdrawalsEnvelope = {
|
|
1537
|
+
withdrawals: IndexSbtcWithdrawal[]
|
|
1538
|
+
next_cursor: string | null
|
|
1539
|
+
tip: IndexTip
|
|
1540
|
+
reorgs: IndexReorg[]
|
|
1541
|
+
notes?: string
|
|
1542
|
+
};
|
|
1543
|
+
type SbtcWithdrawalEnvelope = {
|
|
1544
|
+
withdrawal: IndexSbtcWithdrawalDetail
|
|
1545
|
+
tip: IndexTip
|
|
1546
|
+
};
|
|
1547
|
+
type SbtcEventsEnvelope = {
|
|
1548
|
+
events: IndexSbtcEvent[]
|
|
1549
|
+
next_cursor: string | null
|
|
1550
|
+
tip: IndexTip
|
|
1551
|
+
reorgs: IndexReorg[]
|
|
1552
|
+
notes?: string
|
|
1553
|
+
};
|
|
1554
|
+
type SbtcSummaryEnvelope = {
|
|
1555
|
+
summary: IndexSbtcSummary
|
|
1556
|
+
tip: IndexTip
|
|
1557
|
+
notes?: string
|
|
1558
|
+
};
|
|
1559
|
+
type SbtcDepositsListParams = {
|
|
1560
|
+
cursor?: string | null
|
|
1561
|
+
fromCursor?: string | null
|
|
1562
|
+
limit?: number
|
|
1563
|
+
/** Clamp to the finality boundary — only settled deposits past the reorg margin. */
|
|
1564
|
+
confirmed?: boolean
|
|
1565
|
+
sender?: string
|
|
1566
|
+
bitcoinTxid?: string
|
|
1567
|
+
fromHeight?: number
|
|
1568
|
+
toHeight?: number
|
|
1569
|
+
};
|
|
1570
|
+
type SbtcDepositsWalkParams = Omit<SbtcDepositsListParams, "limit"> & {
|
|
1571
|
+
batchSize?: number
|
|
1572
|
+
signal?: AbortSignal
|
|
1573
|
+
};
|
|
1574
|
+
type SbtcWithdrawalsListParams = {
|
|
1575
|
+
cursor?: string | null
|
|
1576
|
+
fromCursor?: string | null
|
|
1577
|
+
limit?: number
|
|
1578
|
+
confirmed?: boolean
|
|
1579
|
+
status?: SbtcWithdrawalStatus
|
|
1580
|
+
sender?: string
|
|
1581
|
+
requestId?: number
|
|
1582
|
+
fromHeight?: number
|
|
1583
|
+
toHeight?: number
|
|
1584
|
+
};
|
|
1585
|
+
type SbtcWithdrawalsWalkParams = Omit<SbtcWithdrawalsListParams, "limit"> & {
|
|
1586
|
+
batchSize?: number
|
|
1587
|
+
signal?: AbortSignal
|
|
1588
|
+
};
|
|
1589
|
+
type SbtcEventsListParams = {
|
|
1590
|
+
cursor?: string | null
|
|
1591
|
+
fromCursor?: string | null
|
|
1592
|
+
limit?: number
|
|
1593
|
+
confirmed?: boolean
|
|
1594
|
+
topic?: SbtcEventTopic
|
|
1595
|
+
sender?: string
|
|
1596
|
+
requestId?: number
|
|
1597
|
+
bitcoinTxid?: string
|
|
1598
|
+
fromHeight?: number
|
|
1599
|
+
toHeight?: number
|
|
1600
|
+
};
|
|
1601
|
+
type SbtcEventsWalkParams = Omit<SbtcEventsListParams, "limit"> & {
|
|
1602
|
+
batchSize?: number
|
|
1603
|
+
signal?: AbortSignal
|
|
1604
|
+
};
|
|
1605
|
+
/** `index.sbtc` — the decoded sBTC peg surface (deposits, withdrawals, raw
|
|
1606
|
+
* events, scoreboard). The only productized decoded sBTC peg feed on Stacks. */
|
|
1607
|
+
interface SbtcResource {
|
|
1608
|
+
deposits: {
|
|
1609
|
+
list(params?: SbtcDepositsListParams): Promise<SbtcDepositsEnvelope>
|
|
1610
|
+
walk(params?: SbtcDepositsWalkParams): AsyncIterable<IndexSbtcDeposit>
|
|
1611
|
+
/** Fetch a completed deposit by Bitcoin txid; 404 → null. */
|
|
1612
|
+
get(bitcoinTxid: string): Promise<SbtcDepositEnvelope | null>
|
|
1613
|
+
};
|
|
1614
|
+
withdrawals: {
|
|
1615
|
+
list(params?: SbtcWithdrawalsListParams): Promise<SbtcWithdrawalsEnvelope>
|
|
1616
|
+
walk(params?: SbtcWithdrawalsWalkParams): AsyncIterable<IndexSbtcWithdrawal>
|
|
1617
|
+
/** Fetch a withdrawal's full lifecycle by request id; 404 → null. */
|
|
1618
|
+
get(requestId: number): Promise<SbtcWithdrawalEnvelope | null>
|
|
1619
|
+
};
|
|
1620
|
+
events: {
|
|
1621
|
+
list(params?: SbtcEventsListParams): Promise<SbtcEventsEnvelope>
|
|
1622
|
+
walk(params?: SbtcEventsWalkParams): AsyncIterable<IndexSbtcEvent>
|
|
1623
|
+
};
|
|
1624
|
+
/** The peg scoreboard — a single all-time aggregate (no pagination). */
|
|
1625
|
+
summary(): Promise<SbtcSummaryEnvelope>;
|
|
1626
|
+
}
|
|
1627
|
+
/** Per-function action count within a reward cycle. */
|
|
1628
|
+
type IndexPoxFunctionCount = {
|
|
1629
|
+
function_name: string
|
|
1630
|
+
count: number
|
|
1631
|
+
};
|
|
1632
|
+
/** Aggregate stats for one PoX reward cycle — distinct from `index.stacking`
|
|
1633
|
+
* (decoded per-call PoX-4 actions); this is the reward-cycle rollup. */
|
|
1634
|
+
type IndexPoxCycle = {
|
|
1635
|
+
reward_cycle: number
|
|
1636
|
+
/** Total ustx locked across all stack-* calls in this cycle (bigint-safe string). */
|
|
1637
|
+
total_stacked_ustx: string
|
|
1638
|
+
unique_stackers: number
|
|
1639
|
+
unique_delegators: number
|
|
1640
|
+
action_count: number
|
|
1641
|
+
start_block_height: number
|
|
1642
|
+
end_block_height: number
|
|
1643
|
+
/** True when this is the latest reward cycle (still accumulating new actions). */
|
|
1644
|
+
is_current: boolean
|
|
1645
|
+
function_breakdown: IndexPoxFunctionCount[]
|
|
1646
|
+
};
|
|
1647
|
+
type PoxCyclesEnvelope = {
|
|
1648
|
+
cycles: IndexPoxCycle[]
|
|
1649
|
+
/** The next `reward_cycle` to page from (cycles descend), or null at the end. */
|
|
1650
|
+
next_cursor: number | null
|
|
1651
|
+
tip: IndexTip
|
|
1652
|
+
/** Present only when the PoX-4 decoder is disabled, explaining an empty feed. */
|
|
1653
|
+
notes?: string
|
|
1654
|
+
};
|
|
1655
|
+
type PoxCycleEnvelope = {
|
|
1656
|
+
cycle: IndexPoxCycle
|
|
1657
|
+
tip: IndexTip
|
|
1658
|
+
notes?: string
|
|
1659
|
+
};
|
|
1660
|
+
type PoxCyclesListParams = {
|
|
1661
|
+
/** A `reward_cycle` to page from; the page returns cycles below it (descending). */
|
|
1662
|
+
cursor?: number | null
|
|
1663
|
+
limit?: number
|
|
1664
|
+
};
|
|
1665
|
+
type PoxCyclesWalkParams = Omit<PoxCyclesListParams, "limit"> & {
|
|
1666
|
+
batchSize?: number
|
|
1667
|
+
signal?: AbortSignal
|
|
1668
|
+
};
|
|
1669
|
+
/** `index.pox` — PoX reward-cycle aggregates. */
|
|
1670
|
+
interface PoxResource {
|
|
1671
|
+
cycles: {
|
|
1672
|
+
list(params?: PoxCyclesListParams): Promise<PoxCyclesEnvelope>
|
|
1673
|
+
walk(params?: PoxCyclesWalkParams): AsyncIterable<IndexPoxCycle>
|
|
1674
|
+
/** Fetch one reward cycle's aggregate by number; 404 → null. */
|
|
1675
|
+
get(rewardCycle: number): Promise<PoxCycleEnvelope | null>
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1416
1678
|
/**
|
|
1417
1679
|
* `index.ftTransfers` — callable shorthand for `.list()`, with `.list`/`.walk`
|
|
1418
1680
|
* still available: `await sl.index.ftTransfers({ contractId })`.
|
|
@@ -1521,6 +1783,12 @@ declare class Index extends BaseClient {
|
|
|
1521
1783
|
walk: (params?: MempoolWalkParams) => AsyncIterable<IndexMempoolTransaction>
|
|
1522
1784
|
get: (txId: string) => Promise<MempoolTransactionEnvelope | null>
|
|
1523
1785
|
};
|
|
1786
|
+
/** Decoded sBTC peg surface — the only productized decoded sBTC peg feed on
|
|
1787
|
+
* Stacks. `deposits`/`withdrawals`/`events` paginate; `summary` is a scalar. */
|
|
1788
|
+
readonly sbtc: SbtcResource;
|
|
1789
|
+
/** PoX reward-cycle aggregates. Distinct from `stacking` (per-call PoX-4
|
|
1790
|
+
* actions); `cycles` is the reward-cycle rollup. */
|
|
1791
|
+
readonly pox: PoxResource;
|
|
1524
1792
|
private listFtTransfers;
|
|
1525
1793
|
private listNftTransfers;
|
|
1526
1794
|
private walkFtTransfers;
|
|
@@ -1547,6 +1815,18 @@ declare class Index extends BaseClient {
|
|
|
1547
1815
|
private listMempool;
|
|
1548
1816
|
private getMempoolTx;
|
|
1549
1817
|
private walkMempool;
|
|
1818
|
+
private listSbtcDeposits;
|
|
1819
|
+
private walkSbtcDeposits;
|
|
1820
|
+
private getSbtcDeposit;
|
|
1821
|
+
private listSbtcWithdrawals;
|
|
1822
|
+
private walkSbtcWithdrawals;
|
|
1823
|
+
private getSbtcWithdrawal;
|
|
1824
|
+
private listSbtcEvents;
|
|
1825
|
+
private walkSbtcEvents;
|
|
1826
|
+
private getSbtcSummary;
|
|
1827
|
+
private listPoxCycles;
|
|
1828
|
+
private walkPoxCycles;
|
|
1829
|
+
private getPoxCycle;
|
|
1550
1830
|
}
|
|
1551
1831
|
/**
|
|
1552
1832
|
* Typed client for project management (`/api/projects/*`).
|
|
@@ -2422,4 +2702,4 @@ declare function toJsonSafe(value: unknown): unknown;
|
|
|
2422
2702
|
/** Decode a hex-encoded Clarity value to JSON-safe JS (uints as strings,
|
|
2423
2703
|
* buffers as `0x…` hex, tuples as objects). Returns the input hex on failure. */
|
|
2424
2704
|
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 };
|
|
2705
|
+
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
|
@@ -80,6 +80,15 @@ class BaseClient {
|
|
|
80
80
|
}
|
|
81
81
|
return response.json();
|
|
82
82
|
}
|
|
83
|
+
async requestOrNull(method, path, body) {
|
|
84
|
+
try {
|
|
85
|
+
return await this.request(method, path, body);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
if (err instanceof ApiError && err.status === 404)
|
|
88
|
+
return null;
|
|
89
|
+
throw err;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
83
92
|
async requestText(method, path, body) {
|
|
84
93
|
const response = await this.fetchResponse(method, path, body);
|
|
85
94
|
return response.text();
|
|
@@ -424,14 +433,8 @@ class Contracts extends BaseClient {
|
|
|
424
433
|
})}`);
|
|
425
434
|
}
|
|
426
435
|
async get(contractId, opts = {}) {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
return contract;
|
|
430
|
-
} catch (err) {
|
|
431
|
-
if (err instanceof ApiError && err.status === 404)
|
|
432
|
-
return null;
|
|
433
|
-
throw err;
|
|
434
|
-
}
|
|
436
|
+
const result = await this.requestOrNull("GET", `/v1/contracts/${encodeURIComponent(contractId)}${opts.includeAbi ? "?include=abi" : ""}`);
|
|
437
|
+
return result?.contract ?? null;
|
|
435
438
|
}
|
|
436
439
|
}
|
|
437
440
|
|
|
@@ -732,13 +735,7 @@ class Index extends BaseClient {
|
|
|
732
735
|
return this.request("GET", "/v1/index");
|
|
733
736
|
}
|
|
734
737
|
async printSchema(contractId) {
|
|
735
|
-
|
|
736
|
-
return await this.request("GET", `/v1/index/contracts/${encodeURIComponent(contractId)}/print-schema`);
|
|
737
|
-
} catch (err) {
|
|
738
|
-
if (err instanceof ApiError && err.status === 404)
|
|
739
|
-
return null;
|
|
740
|
-
throw err;
|
|
741
|
-
}
|
|
738
|
+
return this.requestOrNull("GET", `/v1/index/contracts/${encodeURIComponent(contractId)}/print-schema`);
|
|
742
739
|
}
|
|
743
740
|
ftTransfers = Object.assign((params = {}) => this.listFtTransfers(params), {
|
|
744
741
|
list: (params = {}) => this.listFtTransfers(params),
|
|
@@ -811,6 +808,30 @@ class Index extends BaseClient {
|
|
|
811
808
|
walk: (params = {}) => this.walkMempool(params),
|
|
812
809
|
get: (txId) => this.getMempoolTx(txId)
|
|
813
810
|
};
|
|
811
|
+
sbtc = {
|
|
812
|
+
deposits: {
|
|
813
|
+
list: (params = {}) => this.listSbtcDeposits(params),
|
|
814
|
+
walk: (params = {}) => this.walkSbtcDeposits(params),
|
|
815
|
+
get: (bitcoinTxid) => this.getSbtcDeposit(bitcoinTxid)
|
|
816
|
+
},
|
|
817
|
+
withdrawals: {
|
|
818
|
+
list: (params = {}) => this.listSbtcWithdrawals(params),
|
|
819
|
+
walk: (params = {}) => this.walkSbtcWithdrawals(params),
|
|
820
|
+
get: (requestId) => this.getSbtcWithdrawal(requestId)
|
|
821
|
+
},
|
|
822
|
+
events: {
|
|
823
|
+
list: (params = {}) => this.listSbtcEvents(params),
|
|
824
|
+
walk: (params = {}) => this.walkSbtcEvents(params)
|
|
825
|
+
},
|
|
826
|
+
summary: () => this.getSbtcSummary()
|
|
827
|
+
};
|
|
828
|
+
pox = {
|
|
829
|
+
cycles: {
|
|
830
|
+
list: (params = {}) => this.listPoxCycles(params),
|
|
831
|
+
walk: (params = {}) => this.walkPoxCycles(params),
|
|
832
|
+
get: (rewardCycle) => this.getPoxCycle(rewardCycle)
|
|
833
|
+
}
|
|
834
|
+
};
|
|
814
835
|
async listFtTransfers(params = {}) {
|
|
815
836
|
return this.request("GET", `/v1/index/ft-transfers${buildQuery({
|
|
816
837
|
cursor: params.cursor,
|
|
@@ -1009,13 +1030,7 @@ class Index extends BaseClient {
|
|
|
1009
1030
|
})}`);
|
|
1010
1031
|
}
|
|
1011
1032
|
async getBlock(ref) {
|
|
1012
|
-
|
|
1013
|
-
return await this.request("GET", `/v1/index/blocks/${encodeURIComponent(String(ref))}`);
|
|
1014
|
-
} catch (err) {
|
|
1015
|
-
if (err instanceof ApiError && err.status === 404)
|
|
1016
|
-
return null;
|
|
1017
|
-
throw err;
|
|
1018
|
-
}
|
|
1033
|
+
return this.requestOrNull("GET", `/v1/index/blocks/${encodeURIComponent(String(ref))}`);
|
|
1019
1034
|
}
|
|
1020
1035
|
async* walkBlocks(params = {}) {
|
|
1021
1036
|
const batchSize = params.batchSize ?? 200;
|
|
@@ -1055,22 +1070,10 @@ class Index extends BaseClient {
|
|
|
1055
1070
|
})}`);
|
|
1056
1071
|
}
|
|
1057
1072
|
async getTransaction(txId) {
|
|
1058
|
-
|
|
1059
|
-
return await this.request("GET", `/v1/index/transactions/${encodeURIComponent(txId)}`);
|
|
1060
|
-
} catch (err) {
|
|
1061
|
-
if (err instanceof ApiError && err.status === 404)
|
|
1062
|
-
return null;
|
|
1063
|
-
throw err;
|
|
1064
|
-
}
|
|
1073
|
+
return this.requestOrNull("GET", `/v1/index/transactions/${encodeURIComponent(txId)}`);
|
|
1065
1074
|
}
|
|
1066
1075
|
async getTransactionProof(txId) {
|
|
1067
|
-
|
|
1068
|
-
return await this.request("GET", `/v1/index/transactions/${encodeURIComponent(txId)}/proof`);
|
|
1069
|
-
} catch (err) {
|
|
1070
|
-
if (err instanceof ApiError && err.status === 404)
|
|
1071
|
-
return null;
|
|
1072
|
-
throw err;
|
|
1073
|
-
}
|
|
1076
|
+
return this.requestOrNull("GET", `/v1/index/transactions/${encodeURIComponent(txId)}/proof`);
|
|
1074
1077
|
}
|
|
1075
1078
|
async* walkTransactions(params = {}) {
|
|
1076
1079
|
const batchSize = params.batchSize ?? 200;
|
|
@@ -1145,13 +1148,7 @@ class Index extends BaseClient {
|
|
|
1145
1148
|
})}`);
|
|
1146
1149
|
}
|
|
1147
1150
|
async getMempoolTx(txId) {
|
|
1148
|
-
|
|
1149
|
-
return await this.request("GET", `/v1/index/mempool/${encodeURIComponent(txId)}`);
|
|
1150
|
-
} catch (err) {
|
|
1151
|
-
if (err instanceof ApiError && err.status === 404)
|
|
1152
|
-
return null;
|
|
1153
|
-
throw err;
|
|
1154
|
-
}
|
|
1151
|
+
return this.requestOrNull("GET", `/v1/index/mempool/${encodeURIComponent(txId)}`);
|
|
1155
1152
|
}
|
|
1156
1153
|
async* walkMempool(params = {}) {
|
|
1157
1154
|
const batchSize = params.batchSize ?? 200;
|
|
@@ -1177,6 +1174,155 @@ class Index extends BaseClient {
|
|
|
1177
1174
|
firstPage = false;
|
|
1178
1175
|
}
|
|
1179
1176
|
}
|
|
1177
|
+
async listSbtcDeposits(params = {}) {
|
|
1178
|
+
return this.request("GET", `/v1/index/sbtc/deposits${buildQuery({
|
|
1179
|
+
cursor: params.cursor,
|
|
1180
|
+
from_cursor: params.fromCursor,
|
|
1181
|
+
limit: params.limit,
|
|
1182
|
+
confirmed: params.confirmed,
|
|
1183
|
+
sender: params.sender,
|
|
1184
|
+
bitcoin_txid: params.bitcoinTxid,
|
|
1185
|
+
from_height: params.fromHeight,
|
|
1186
|
+
to_height: params.toHeight
|
|
1187
|
+
})}`);
|
|
1188
|
+
}
|
|
1189
|
+
async* walkSbtcDeposits(params = {}) {
|
|
1190
|
+
const batchSize = params.batchSize ?? 200;
|
|
1191
|
+
let cursor = params.cursor ?? params.fromCursor ?? null;
|
|
1192
|
+
let firstPage = true;
|
|
1193
|
+
while (!params.signal?.aborted) {
|
|
1194
|
+
const envelope = await this.listSbtcDeposits({
|
|
1195
|
+
...params,
|
|
1196
|
+
limit: batchSize,
|
|
1197
|
+
cursor: firstPage ? params.cursor : cursor,
|
|
1198
|
+
fromCursor: firstPage ? params.fromCursor : undefined,
|
|
1199
|
+
fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
|
|
1200
|
+
});
|
|
1201
|
+
for (const deposit of envelope.deposits) {
|
|
1202
|
+
if (params.signal?.aborted)
|
|
1203
|
+
return;
|
|
1204
|
+
yield deposit;
|
|
1205
|
+
}
|
|
1206
|
+
const nextCursor = envelope.next_cursor;
|
|
1207
|
+
if (!nextCursor || nextCursor === cursor || envelope.deposits.length < batchSize) {
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
cursor = nextCursor;
|
|
1211
|
+
firstPage = false;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
async getSbtcDeposit(bitcoinTxid) {
|
|
1215
|
+
return this.requestOrNull("GET", `/v1/index/sbtc/deposits/${encodeURIComponent(bitcoinTxid)}`);
|
|
1216
|
+
}
|
|
1217
|
+
async listSbtcWithdrawals(params = {}) {
|
|
1218
|
+
return this.request("GET", `/v1/index/sbtc/withdrawals${buildQuery({
|
|
1219
|
+
cursor: params.cursor,
|
|
1220
|
+
from_cursor: params.fromCursor,
|
|
1221
|
+
limit: params.limit,
|
|
1222
|
+
confirmed: params.confirmed,
|
|
1223
|
+
status: params.status,
|
|
1224
|
+
sender: params.sender,
|
|
1225
|
+
request_id: params.requestId,
|
|
1226
|
+
from_height: params.fromHeight,
|
|
1227
|
+
to_height: params.toHeight
|
|
1228
|
+
})}`);
|
|
1229
|
+
}
|
|
1230
|
+
async* walkSbtcWithdrawals(params = {}) {
|
|
1231
|
+
const batchSize = params.batchSize ?? 200;
|
|
1232
|
+
let cursor = params.cursor ?? params.fromCursor ?? null;
|
|
1233
|
+
let firstPage = true;
|
|
1234
|
+
while (!params.signal?.aborted) {
|
|
1235
|
+
const envelope = await this.listSbtcWithdrawals({
|
|
1236
|
+
...params,
|
|
1237
|
+
limit: batchSize,
|
|
1238
|
+
cursor: firstPage ? params.cursor : cursor,
|
|
1239
|
+
fromCursor: firstPage ? params.fromCursor : undefined,
|
|
1240
|
+
fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
|
|
1241
|
+
});
|
|
1242
|
+
for (const withdrawal of envelope.withdrawals) {
|
|
1243
|
+
if (params.signal?.aborted)
|
|
1244
|
+
return;
|
|
1245
|
+
yield withdrawal;
|
|
1246
|
+
}
|
|
1247
|
+
const nextCursor = envelope.next_cursor;
|
|
1248
|
+
if (!nextCursor || nextCursor === cursor || envelope.withdrawals.length < batchSize) {
|
|
1249
|
+
return;
|
|
1250
|
+
}
|
|
1251
|
+
cursor = nextCursor;
|
|
1252
|
+
firstPage = false;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
async getSbtcWithdrawal(requestId) {
|
|
1256
|
+
return this.requestOrNull("GET", `/v1/index/sbtc/withdrawals/${requestId}`);
|
|
1257
|
+
}
|
|
1258
|
+
async listSbtcEvents(params = {}) {
|
|
1259
|
+
return this.request("GET", `/v1/index/sbtc/events${buildQuery({
|
|
1260
|
+
cursor: params.cursor,
|
|
1261
|
+
from_cursor: params.fromCursor,
|
|
1262
|
+
limit: params.limit,
|
|
1263
|
+
confirmed: params.confirmed,
|
|
1264
|
+
topic: params.topic,
|
|
1265
|
+
sender: params.sender,
|
|
1266
|
+
request_id: params.requestId,
|
|
1267
|
+
bitcoin_txid: params.bitcoinTxid,
|
|
1268
|
+
from_height: params.fromHeight,
|
|
1269
|
+
to_height: params.toHeight
|
|
1270
|
+
})}`);
|
|
1271
|
+
}
|
|
1272
|
+
async* walkSbtcEvents(params = {}) {
|
|
1273
|
+
const batchSize = params.batchSize ?? 200;
|
|
1274
|
+
let cursor = params.cursor ?? params.fromCursor ?? null;
|
|
1275
|
+
let firstPage = true;
|
|
1276
|
+
while (!params.signal?.aborted) {
|
|
1277
|
+
const envelope = await this.listSbtcEvents({
|
|
1278
|
+
...params,
|
|
1279
|
+
limit: batchSize,
|
|
1280
|
+
cursor: firstPage ? params.cursor : cursor,
|
|
1281
|
+
fromCursor: firstPage ? params.fromCursor : undefined,
|
|
1282
|
+
fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
|
|
1283
|
+
});
|
|
1284
|
+
for (const event of envelope.events) {
|
|
1285
|
+
if (params.signal?.aborted)
|
|
1286
|
+
return;
|
|
1287
|
+
yield event;
|
|
1288
|
+
}
|
|
1289
|
+
const nextCursor = envelope.next_cursor;
|
|
1290
|
+
if (!nextCursor || nextCursor === cursor || envelope.events.length < batchSize) {
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
cursor = nextCursor;
|
|
1294
|
+
firstPage = false;
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
async getSbtcSummary() {
|
|
1298
|
+
return this.request("GET", "/v1/index/sbtc/summary");
|
|
1299
|
+
}
|
|
1300
|
+
async listPoxCycles(params = {}) {
|
|
1301
|
+
return this.request("GET", `/v1/index/pox/cycles${buildQuery({
|
|
1302
|
+
cursor: params.cursor,
|
|
1303
|
+
limit: params.limit
|
|
1304
|
+
})}`);
|
|
1305
|
+
}
|
|
1306
|
+
async* walkPoxCycles(params = {}) {
|
|
1307
|
+
const batchSize = params.batchSize ?? 100;
|
|
1308
|
+
let cursor = params.cursor ?? null;
|
|
1309
|
+
while (!params.signal?.aborted) {
|
|
1310
|
+
const envelope = await this.listPoxCycles({ cursor, limit: batchSize });
|
|
1311
|
+
for (const cycle of envelope.cycles) {
|
|
1312
|
+
if (params.signal?.aborted)
|
|
1313
|
+
return;
|
|
1314
|
+
yield cycle;
|
|
1315
|
+
}
|
|
1316
|
+
const nextCursor = envelope.next_cursor;
|
|
1317
|
+
if (nextCursor === null || nextCursor === cursor || envelope.cycles.length < batchSize) {
|
|
1318
|
+
return;
|
|
1319
|
+
}
|
|
1320
|
+
cursor = nextCursor;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
async getPoxCycle(rewardCycle) {
|
|
1324
|
+
return this.requestOrNull("GET", `/v1/index/pox/cycles/${rewardCycle}`);
|
|
1325
|
+
}
|
|
1180
1326
|
}
|
|
1181
1327
|
|
|
1182
1328
|
// src/projects/client.ts
|
|
@@ -2510,5 +2656,5 @@ export {
|
|
|
2510
2656
|
ApiError
|
|
2511
2657
|
};
|
|
2512
2658
|
|
|
2513
|
-
//# debugId=
|
|
2659
|
+
//# debugId=C1FDCE89B0E4893864756E2164756E21
|
|
2514
2660
|
//# sourceMappingURL=index.js.map
|