@secondlayer/sdk 6.26.1 → 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 +278 -1
- package/dist/index.js +192 -1
- package/dist/index.js.map +3 -3
- package/dist/subgraphs/index.d.ts +277 -0
- package/dist/subgraphs/index.js +192 -1
- package/dist/subgraphs/index.js.map +3 -3
- package/package.json +2 -4
|
@@ -1337,6 +1337,265 @@ type PrintSchemaResponse = {
|
|
|
1337
1337
|
}
|
|
1338
1338
|
tip: IndexTip
|
|
1339
1339
|
};
|
|
1340
|
+
/** The decoded `sbtc_events` topics. */
|
|
1341
|
+
type SbtcEventTopic = "completed-deposit" | "withdrawal-create" | "withdrawal-accept" | "withdrawal-reject" | "key-rotation" | "update-protocol-contract";
|
|
1342
|
+
type SbtcWithdrawalStatus = "REQUESTED" | "ACCEPTED" | "REJECTED";
|
|
1343
|
+
/** A completed sBTC peg-in, keyed by `bitcoin_txid` (deposits carry no
|
|
1344
|
+
* `request_id`). One terminal `completed-deposit` event per deposit. */
|
|
1345
|
+
type IndexSbtcDeposit = {
|
|
1346
|
+
cursor: string
|
|
1347
|
+
block_height: number
|
|
1348
|
+
block_time?: string | null
|
|
1349
|
+
tx_id: string
|
|
1350
|
+
tx_index: number
|
|
1351
|
+
event_index: number
|
|
1352
|
+
amount: string | null
|
|
1353
|
+
sender: string | null
|
|
1354
|
+
bitcoin_txid: string | null
|
|
1355
|
+
output_index: number | null
|
|
1356
|
+
recipient_btc_version: number | null
|
|
1357
|
+
recipient_btc_hashbytes: string | null
|
|
1358
|
+
};
|
|
1359
|
+
/** A deposit fetched by Bitcoin txid — always terminal, hence `status`. */
|
|
1360
|
+
type IndexSbtcDepositDetail = IndexSbtcDeposit & {
|
|
1361
|
+
status: "COMPLETED"
|
|
1362
|
+
};
|
|
1363
|
+
/** A peg-out collapsed to one row per `request_id`, with lifecycle `status`
|
|
1364
|
+
* derived from the latest accept/reject. */
|
|
1365
|
+
type IndexSbtcWithdrawal = {
|
|
1366
|
+
cursor: string
|
|
1367
|
+
request_id: number
|
|
1368
|
+
status: SbtcWithdrawalStatus
|
|
1369
|
+
amount: string | null
|
|
1370
|
+
sender: string | null
|
|
1371
|
+
recipient_btc_version: number | null
|
|
1372
|
+
recipient_btc_hashbytes: string | null
|
|
1373
|
+
sweep_txid: string | null
|
|
1374
|
+
requested_at?: string | null
|
|
1375
|
+
resolved_at?: string | null
|
|
1376
|
+
};
|
|
1377
|
+
/** One phase of a withdrawal's lifecycle (the on-Stacks event that drove it). */
|
|
1378
|
+
type IndexSbtcWithdrawalPhase = {
|
|
1379
|
+
block_height: number
|
|
1380
|
+
block_time: string | null
|
|
1381
|
+
tx_id: string
|
|
1382
|
+
};
|
|
1383
|
+
/** A single peg-out's full assembled lifecycle, fetched by `request_id`.
|
|
1384
|
+
* `finalized` is true once terminal and past the reorg margin. */
|
|
1385
|
+
type IndexSbtcWithdrawalDetail = {
|
|
1386
|
+
request_id: number
|
|
1387
|
+
status: SbtcWithdrawalStatus
|
|
1388
|
+
amount: string | null
|
|
1389
|
+
sender: string | null
|
|
1390
|
+
recipient_btc_version: number | null
|
|
1391
|
+
recipient_btc_hashbytes: string | null
|
|
1392
|
+
requested: IndexSbtcWithdrawalPhase
|
|
1393
|
+
accepted: (IndexSbtcWithdrawalPhase & {
|
|
1394
|
+
sweep_txid: string | null
|
|
1395
|
+
signer_bitmap: string | null
|
|
1396
|
+
}) | null
|
|
1397
|
+
rejected: IndexSbtcWithdrawalPhase | null
|
|
1398
|
+
settlement: {
|
|
1399
|
+
sweep_txid: string | null
|
|
1400
|
+
btc_confirmations: number | null
|
|
1401
|
+
settlement_confirmed: boolean | null
|
|
1402
|
+
}
|
|
1403
|
+
finalized: boolean
|
|
1404
|
+
};
|
|
1405
|
+
/** A raw decoded sBTC protocol-state event — the full `sbtc_events` row, one
|
|
1406
|
+
* per event across all topics. */
|
|
1407
|
+
type IndexSbtcEvent = {
|
|
1408
|
+
cursor: string
|
|
1409
|
+
block_height: number
|
|
1410
|
+
block_time?: string | null
|
|
1411
|
+
tx_id: string
|
|
1412
|
+
tx_index: number
|
|
1413
|
+
event_index: number
|
|
1414
|
+
topic: SbtcEventTopic
|
|
1415
|
+
request_id: number | null
|
|
1416
|
+
amount: string | null
|
|
1417
|
+
sender: string | null
|
|
1418
|
+
recipient_btc_version: number | null
|
|
1419
|
+
recipient_btc_hashbytes: string | null
|
|
1420
|
+
bitcoin_txid: string | null
|
|
1421
|
+
output_index: number | null
|
|
1422
|
+
sweep_txid: string | null
|
|
1423
|
+
burn_hash: string | null
|
|
1424
|
+
burn_height: number | null
|
|
1425
|
+
signer_bitmap: string | null
|
|
1426
|
+
max_fee: string | null
|
|
1427
|
+
fee: string | null
|
|
1428
|
+
governance_contract_type: number | null
|
|
1429
|
+
governance_new_contract: string | null
|
|
1430
|
+
signer_aggregate_pubkey: string | null
|
|
1431
|
+
signer_threshold: number | null
|
|
1432
|
+
signer_address: string | null
|
|
1433
|
+
signer_keys_count: number | null
|
|
1434
|
+
};
|
|
1435
|
+
/** The peg "scoreboard" — a single all-time canonical aggregate. */
|
|
1436
|
+
type IndexSbtcSummary = {
|
|
1437
|
+
total_deposits: number
|
|
1438
|
+
total_withdrawals_requested: number
|
|
1439
|
+
total_withdrawals_accepted: number
|
|
1440
|
+
total_withdrawals_rejected: number
|
|
1441
|
+
net_peg_flow_sats: string
|
|
1442
|
+
total_locked_sats: string
|
|
1443
|
+
sbtc_supply_sats: string | null
|
|
1444
|
+
};
|
|
1445
|
+
type SbtcDepositsEnvelope = {
|
|
1446
|
+
deposits: IndexSbtcDeposit[]
|
|
1447
|
+
next_cursor: string | null
|
|
1448
|
+
tip: IndexTip
|
|
1449
|
+
reorgs: IndexReorg[]
|
|
1450
|
+
/** Present only when the sBTC decoder is disabled, explaining an empty feed. */
|
|
1451
|
+
notes?: string
|
|
1452
|
+
};
|
|
1453
|
+
type SbtcDepositEnvelope = {
|
|
1454
|
+
deposit: IndexSbtcDepositDetail
|
|
1455
|
+
tip: IndexTip
|
|
1456
|
+
};
|
|
1457
|
+
type SbtcWithdrawalsEnvelope = {
|
|
1458
|
+
withdrawals: IndexSbtcWithdrawal[]
|
|
1459
|
+
next_cursor: string | null
|
|
1460
|
+
tip: IndexTip
|
|
1461
|
+
reorgs: IndexReorg[]
|
|
1462
|
+
notes?: string
|
|
1463
|
+
};
|
|
1464
|
+
type SbtcWithdrawalEnvelope = {
|
|
1465
|
+
withdrawal: IndexSbtcWithdrawalDetail
|
|
1466
|
+
tip: IndexTip
|
|
1467
|
+
};
|
|
1468
|
+
type SbtcEventsEnvelope = {
|
|
1469
|
+
events: IndexSbtcEvent[]
|
|
1470
|
+
next_cursor: string | null
|
|
1471
|
+
tip: IndexTip
|
|
1472
|
+
reorgs: IndexReorg[]
|
|
1473
|
+
notes?: string
|
|
1474
|
+
};
|
|
1475
|
+
type SbtcSummaryEnvelope = {
|
|
1476
|
+
summary: IndexSbtcSummary
|
|
1477
|
+
tip: IndexTip
|
|
1478
|
+
notes?: string
|
|
1479
|
+
};
|
|
1480
|
+
type SbtcDepositsListParams = {
|
|
1481
|
+
cursor?: string | null
|
|
1482
|
+
fromCursor?: string | null
|
|
1483
|
+
limit?: number
|
|
1484
|
+
/** Clamp to the finality boundary — only settled deposits past the reorg margin. */
|
|
1485
|
+
confirmed?: boolean
|
|
1486
|
+
sender?: string
|
|
1487
|
+
bitcoinTxid?: string
|
|
1488
|
+
fromHeight?: number
|
|
1489
|
+
toHeight?: number
|
|
1490
|
+
};
|
|
1491
|
+
type SbtcDepositsWalkParams = Omit<SbtcDepositsListParams, "limit"> & {
|
|
1492
|
+
batchSize?: number
|
|
1493
|
+
signal?: AbortSignal
|
|
1494
|
+
};
|
|
1495
|
+
type SbtcWithdrawalsListParams = {
|
|
1496
|
+
cursor?: string | null
|
|
1497
|
+
fromCursor?: string | null
|
|
1498
|
+
limit?: number
|
|
1499
|
+
confirmed?: boolean
|
|
1500
|
+
status?: SbtcWithdrawalStatus
|
|
1501
|
+
sender?: string
|
|
1502
|
+
requestId?: number
|
|
1503
|
+
fromHeight?: number
|
|
1504
|
+
toHeight?: number
|
|
1505
|
+
};
|
|
1506
|
+
type SbtcWithdrawalsWalkParams = Omit<SbtcWithdrawalsListParams, "limit"> & {
|
|
1507
|
+
batchSize?: number
|
|
1508
|
+
signal?: AbortSignal
|
|
1509
|
+
};
|
|
1510
|
+
type SbtcEventsListParams = {
|
|
1511
|
+
cursor?: string | null
|
|
1512
|
+
fromCursor?: string | null
|
|
1513
|
+
limit?: number
|
|
1514
|
+
confirmed?: boolean
|
|
1515
|
+
topic?: SbtcEventTopic
|
|
1516
|
+
sender?: string
|
|
1517
|
+
requestId?: number
|
|
1518
|
+
bitcoinTxid?: string
|
|
1519
|
+
fromHeight?: number
|
|
1520
|
+
toHeight?: number
|
|
1521
|
+
};
|
|
1522
|
+
type SbtcEventsWalkParams = Omit<SbtcEventsListParams, "limit"> & {
|
|
1523
|
+
batchSize?: number
|
|
1524
|
+
signal?: AbortSignal
|
|
1525
|
+
};
|
|
1526
|
+
/** `index.sbtc` — the decoded sBTC peg surface (deposits, withdrawals, raw
|
|
1527
|
+
* events, scoreboard). The only productized decoded sBTC peg feed on Stacks. */
|
|
1528
|
+
interface SbtcResource {
|
|
1529
|
+
deposits: {
|
|
1530
|
+
list(params?: SbtcDepositsListParams): Promise<SbtcDepositsEnvelope>
|
|
1531
|
+
walk(params?: SbtcDepositsWalkParams): AsyncIterable<IndexSbtcDeposit>
|
|
1532
|
+
/** Fetch a completed deposit by Bitcoin txid; 404 → null. */
|
|
1533
|
+
get(bitcoinTxid: string): Promise<SbtcDepositEnvelope | null>
|
|
1534
|
+
};
|
|
1535
|
+
withdrawals: {
|
|
1536
|
+
list(params?: SbtcWithdrawalsListParams): Promise<SbtcWithdrawalsEnvelope>
|
|
1537
|
+
walk(params?: SbtcWithdrawalsWalkParams): AsyncIterable<IndexSbtcWithdrawal>
|
|
1538
|
+
/** Fetch a withdrawal's full lifecycle by request id; 404 → null. */
|
|
1539
|
+
get(requestId: number): Promise<SbtcWithdrawalEnvelope | null>
|
|
1540
|
+
};
|
|
1541
|
+
events: {
|
|
1542
|
+
list(params?: SbtcEventsListParams): Promise<SbtcEventsEnvelope>
|
|
1543
|
+
walk(params?: SbtcEventsWalkParams): AsyncIterable<IndexSbtcEvent>
|
|
1544
|
+
};
|
|
1545
|
+
/** The peg scoreboard — a single all-time aggregate (no pagination). */
|
|
1546
|
+
summary(): Promise<SbtcSummaryEnvelope>;
|
|
1547
|
+
}
|
|
1548
|
+
/** Per-function action count within a reward cycle. */
|
|
1549
|
+
type IndexPoxFunctionCount = {
|
|
1550
|
+
function_name: string
|
|
1551
|
+
count: number
|
|
1552
|
+
};
|
|
1553
|
+
/** Aggregate stats for one PoX reward cycle — distinct from `index.stacking`
|
|
1554
|
+
* (decoded per-call PoX-4 actions); this is the reward-cycle rollup. */
|
|
1555
|
+
type IndexPoxCycle = {
|
|
1556
|
+
reward_cycle: number
|
|
1557
|
+
/** Total ustx locked across all stack-* calls in this cycle (bigint-safe string). */
|
|
1558
|
+
total_stacked_ustx: string
|
|
1559
|
+
unique_stackers: number
|
|
1560
|
+
unique_delegators: number
|
|
1561
|
+
action_count: number
|
|
1562
|
+
start_block_height: number
|
|
1563
|
+
end_block_height: number
|
|
1564
|
+
/** True when this is the latest reward cycle (still accumulating new actions). */
|
|
1565
|
+
is_current: boolean
|
|
1566
|
+
function_breakdown: IndexPoxFunctionCount[]
|
|
1567
|
+
};
|
|
1568
|
+
type PoxCyclesEnvelope = {
|
|
1569
|
+
cycles: IndexPoxCycle[]
|
|
1570
|
+
/** The next `reward_cycle` to page from (cycles descend), or null at the end. */
|
|
1571
|
+
next_cursor: number | null
|
|
1572
|
+
tip: IndexTip
|
|
1573
|
+
/** Present only when the PoX-4 decoder is disabled, explaining an empty feed. */
|
|
1574
|
+
notes?: string
|
|
1575
|
+
};
|
|
1576
|
+
type PoxCycleEnvelope = {
|
|
1577
|
+
cycle: IndexPoxCycle
|
|
1578
|
+
tip: IndexTip
|
|
1579
|
+
notes?: string
|
|
1580
|
+
};
|
|
1581
|
+
type PoxCyclesListParams = {
|
|
1582
|
+
/** A `reward_cycle` to page from; the page returns cycles below it (descending). */
|
|
1583
|
+
cursor?: number | null
|
|
1584
|
+
limit?: number
|
|
1585
|
+
};
|
|
1586
|
+
type PoxCyclesWalkParams = Omit<PoxCyclesListParams, "limit"> & {
|
|
1587
|
+
batchSize?: number
|
|
1588
|
+
signal?: AbortSignal
|
|
1589
|
+
};
|
|
1590
|
+
/** `index.pox` — PoX reward-cycle aggregates. */
|
|
1591
|
+
interface PoxResource {
|
|
1592
|
+
cycles: {
|
|
1593
|
+
list(params?: PoxCyclesListParams): Promise<PoxCyclesEnvelope>
|
|
1594
|
+
walk(params?: PoxCyclesWalkParams): AsyncIterable<IndexPoxCycle>
|
|
1595
|
+
/** Fetch one reward cycle's aggregate by number; 404 → null. */
|
|
1596
|
+
get(rewardCycle: number): Promise<PoxCycleEnvelope | null>
|
|
1597
|
+
};
|
|
1598
|
+
}
|
|
1340
1599
|
/**
|
|
1341
1600
|
* `index.ftTransfers` — callable shorthand for `.list()`, with `.list`/`.walk`
|
|
1342
1601
|
* still available: `await sl.index.ftTransfers({ contractId })`.
|
|
@@ -1445,6 +1704,12 @@ declare class Index extends BaseClient {
|
|
|
1445
1704
|
walk: (params?: MempoolWalkParams) => AsyncIterable<IndexMempoolTransaction>
|
|
1446
1705
|
get: (txId: string) => Promise<MempoolTransactionEnvelope | null>
|
|
1447
1706
|
};
|
|
1707
|
+
/** Decoded sBTC peg surface — the only productized decoded sBTC peg feed on
|
|
1708
|
+
* Stacks. `deposits`/`withdrawals`/`events` paginate; `summary` is a scalar. */
|
|
1709
|
+
readonly sbtc: SbtcResource;
|
|
1710
|
+
/** PoX reward-cycle aggregates. Distinct from `stacking` (per-call PoX-4
|
|
1711
|
+
* actions); `cycles` is the reward-cycle rollup. */
|
|
1712
|
+
readonly pox: PoxResource;
|
|
1448
1713
|
private listFtTransfers;
|
|
1449
1714
|
private listNftTransfers;
|
|
1450
1715
|
private walkFtTransfers;
|
|
@@ -1471,6 +1736,18 @@ declare class Index extends BaseClient {
|
|
|
1471
1736
|
private listMempool;
|
|
1472
1737
|
private getMempoolTx;
|
|
1473
1738
|
private walkMempool;
|
|
1739
|
+
private listSbtcDeposits;
|
|
1740
|
+
private walkSbtcDeposits;
|
|
1741
|
+
private getSbtcDeposit;
|
|
1742
|
+
private listSbtcWithdrawals;
|
|
1743
|
+
private walkSbtcWithdrawals;
|
|
1744
|
+
private getSbtcWithdrawal;
|
|
1745
|
+
private listSbtcEvents;
|
|
1746
|
+
private walkSbtcEvents;
|
|
1747
|
+
private getSbtcSummary;
|
|
1748
|
+
private listPoxCycles;
|
|
1749
|
+
private walkPoxCycles;
|
|
1750
|
+
private getPoxCycle;
|
|
1474
1751
|
}
|
|
1475
1752
|
/**
|
|
1476
1753
|
* Typed client for project management (`/api/projects/*`).
|
package/dist/subgraphs/index.js
CHANGED
|
@@ -811,6 +811,30 @@ class Index extends BaseClient {
|
|
|
811
811
|
walk: (params = {}) => this.walkMempool(params),
|
|
812
812
|
get: (txId) => this.getMempoolTx(txId)
|
|
813
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
|
+
};
|
|
814
838
|
async listFtTransfers(params = {}) {
|
|
815
839
|
return this.request("GET", `/v1/index/ft-transfers${buildQuery({
|
|
816
840
|
cursor: params.cursor,
|
|
@@ -1177,6 +1201,173 @@ class Index extends BaseClient {
|
|
|
1177
1201
|
firstPage = false;
|
|
1178
1202
|
}
|
|
1179
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
|
+
}
|
|
1180
1371
|
}
|
|
1181
1372
|
|
|
1182
1373
|
// src/projects/client.ts
|
|
@@ -1833,5 +2024,5 @@ export {
|
|
|
1833
2024
|
Subgraphs
|
|
1834
2025
|
};
|
|
1835
2026
|
|
|
1836
|
-
//# debugId=
|
|
2027
|
+
//# debugId=AF49D51938E916C064756E2164756E21
|
|
1837
2028
|
//# sourceMappingURL=index.js.map
|