@secondlayer/sdk 6.27.2 → 6.28.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.
@@ -1374,6 +1374,9 @@ type IndexSbtcWithdrawal = {
1374
1374
  recipient_btc_version: number | null
1375
1375
  recipient_btc_hashbytes: string | null
1376
1376
  sweep_txid: string | null
1377
+ /** BTC L1 settlement of the committed sweep: true once confirmed, false while
1378
+ * pending, null when there is no sweep yet (REQUESTED). */
1379
+ settlement_confirmed: boolean | null
1377
1380
  requested_at?: string | null
1378
1381
  resolved_at?: string | null
1379
1382
  };
@@ -1402,6 +1405,10 @@ type IndexSbtcWithdrawalDetail = {
1402
1405
  sweep_txid: string | null
1403
1406
  btc_confirmations: number | null
1404
1407
  settlement_confirmed: boolean | null
1408
+ /** Confirming Bitcoin block height; null until the sweep confirms. */
1409
+ btc_block_height: number | null
1410
+ /** ISO timestamp the sweep first crossed the confirmation threshold. */
1411
+ confirmed_at: string | null
1405
1412
  }
1406
1413
  finalized: boolean
1407
1414
  };
@@ -1503,6 +1510,9 @@ type SbtcWithdrawalsListParams = {
1503
1510
  status?: SbtcWithdrawalStatus
1504
1511
  sender?: string
1505
1512
  requestId?: number
1513
+ /** Filter by BTC L1 settlement: true → only confirmed sweeps; false → not
1514
+ * yet confirmed (pending or no sweep). */
1515
+ settlementConfirmed?: boolean
1506
1516
  fromHeight?: number
1507
1517
  toHeight?: number
1508
1518
  };
@@ -1715,6 +1725,12 @@ declare class Index extends BaseClient {
1715
1725
  readonly pox: PoxResource;
1716
1726
  private listFtTransfers;
1717
1727
  private listNftTransfers;
1728
+ /** Shared keyset-pagination loop for every `walk*` feed: seed the cursor from
1729
+ * `cursor`/`fromCursor` (and `fromHeight` 0 on the first page), then page until
1730
+ * the cursor stops advancing or a short page signals the tail. `list` merges the
1731
+ * resource's filter params; `itemsOf` selects the envelope's item array. PoX
1732
+ * cycles use a numeric cursor and are walked separately. */
1733
+ private keysetWalk;
1718
1734
  private walkFtTransfers;
1719
1735
  private walkNftTransfers;
1720
1736
  private listEvents;
@@ -835,55 +835,36 @@ class Index extends BaseClient {
835
835
  to_height: params.toHeight
836
836
  })}`);
837
837
  }
838
- async* walkFtTransfers(params = {}) {
838
+ async* keysetWalk(params, list, itemsOf) {
839
839
  const batchSize = params.batchSize ?? 200;
840
840
  let cursor = params.cursor ?? params.fromCursor ?? null;
841
841
  let firstPage = true;
842
842
  while (!params.signal?.aborted) {
843
- const envelope = await this.listFtTransfers({
844
- ...params,
843
+ const envelope = await list({
845
844
  limit: batchSize,
846
845
  cursor: firstPage ? params.cursor : cursor,
847
846
  fromCursor: firstPage ? params.fromCursor : undefined,
848
847
  fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
849
848
  });
850
- for (const event of envelope.events) {
849
+ const items = itemsOf(envelope);
850
+ for (const item of items) {
851
851
  if (params.signal?.aborted)
852
852
  return;
853
- yield event;
853
+ yield item;
854
854
  }
855
855
  const nextCursor = envelope.next_cursor;
856
- if (!nextCursor || nextCursor === cursor || envelope.events.length < batchSize) {
856
+ if (!nextCursor || nextCursor === cursor || items.length < batchSize) {
857
857
  return;
858
858
  }
859
859
  cursor = nextCursor;
860
860
  firstPage = false;
861
861
  }
862
862
  }
863
- async* walkNftTransfers(params = {}) {
864
- const batchSize = params.batchSize ?? 200;
865
- let cursor = params.cursor ?? params.fromCursor ?? null;
866
- let firstPage = true;
867
- while (!params.signal?.aborted) {
868
- const envelope = await this.listNftTransfers({
869
- ...params,
870
- limit: batchSize,
871
- cursor: firstPage ? params.cursor : cursor,
872
- fromCursor: firstPage ? params.fromCursor : undefined,
873
- fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
874
- });
875
- for (const event of envelope.events) {
876
- if (params.signal?.aborted)
877
- return;
878
- yield event;
879
- }
880
- const nextCursor = envelope.next_cursor;
881
- if (!nextCursor || nextCursor === cursor || envelope.events.length < batchSize) {
882
- return;
883
- }
884
- cursor = nextCursor;
885
- firstPage = false;
886
- }
863
+ walkFtTransfers(params = {}) {
864
+ return this.keysetWalk(params, (page) => this.listFtTransfers({ ...params, ...page }), (e) => e.events);
865
+ }
866
+ walkNftTransfers(params = {}) {
867
+ return this.keysetWalk(params, (page) => this.listNftTransfers({ ...params, ...page }), (e) => e.events);
887
868
  }
888
869
  async listEvents(params) {
889
870
  return this.request("GET", `/v1/index/events${buildQuery({
@@ -901,30 +882,8 @@ class Index extends BaseClient {
901
882
  tx_context: params.txContext ? "true" : undefined
902
883
  })}`);
903
884
  }
904
- async* walkEvents(params) {
905
- const batchSize = params.batchSize ?? 200;
906
- let cursor = params.cursor ?? params.fromCursor ?? null;
907
- let firstPage = true;
908
- while (!params.signal?.aborted) {
909
- const envelope = await this.listEvents({
910
- ...params,
911
- limit: batchSize,
912
- cursor: firstPage ? params.cursor : cursor,
913
- fromCursor: firstPage ? params.fromCursor : undefined,
914
- fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
915
- });
916
- for (const event of envelope.events) {
917
- if (params.signal?.aborted)
918
- return;
919
- yield event;
920
- }
921
- const nextCursor = envelope.next_cursor;
922
- if (!nextCursor || nextCursor === cursor || envelope.events.length < batchSize) {
923
- return;
924
- }
925
- cursor = nextCursor;
926
- firstPage = false;
927
- }
885
+ walkEvents(params) {
886
+ return this.keysetWalk(params, (page) => this.listEvents({ ...params, ...page }), (e) => e.events);
928
887
  }
929
888
  async listContractCalls(params = {}) {
930
889
  return this.request("GET", `/v1/index/contract-calls${buildQuery({
@@ -939,30 +898,8 @@ class Index extends BaseClient {
939
898
  trait: params.trait
940
899
  })}`);
941
900
  }
942
- async* walkContractCalls(params = {}) {
943
- const batchSize = params.batchSize ?? 200;
944
- let cursor = params.cursor ?? params.fromCursor ?? null;
945
- let firstPage = true;
946
- while (!params.signal?.aborted) {
947
- const envelope = await this.listContractCalls({
948
- ...params,
949
- limit: batchSize,
950
- cursor: firstPage ? params.cursor : cursor,
951
- fromCursor: firstPage ? params.fromCursor : undefined,
952
- fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
953
- });
954
- for (const call of envelope.contract_calls) {
955
- if (params.signal?.aborted)
956
- return;
957
- yield call;
958
- }
959
- const nextCursor = envelope.next_cursor;
960
- if (!nextCursor || nextCursor === cursor || envelope.contract_calls.length < batchSize) {
961
- return;
962
- }
963
- cursor = nextCursor;
964
- firstPage = false;
965
- }
901
+ walkContractCalls(params = {}) {
902
+ return this.keysetWalk(params, (page) => this.listContractCalls({ ...params, ...page }), (e) => e.contract_calls);
966
903
  }
967
904
  async listCanonical(params = {}) {
968
905
  return this.request("GET", `/v1/index/canonical${buildQuery({
@@ -973,30 +910,8 @@ class Index extends BaseClient {
973
910
  to_height: params.toHeight
974
911
  })}`);
975
912
  }
976
- async* walkCanonical(params = {}) {
977
- const batchSize = params.batchSize ?? 200;
978
- let cursor = params.cursor ?? params.fromCursor ?? null;
979
- let firstPage = true;
980
- while (!params.signal?.aborted) {
981
- const envelope = await this.listCanonical({
982
- ...params,
983
- limit: batchSize,
984
- cursor: firstPage ? params.cursor : cursor,
985
- fromCursor: firstPage ? params.fromCursor : undefined,
986
- fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
987
- });
988
- for (const block of envelope.canonical) {
989
- if (params.signal?.aborted)
990
- return;
991
- yield block;
992
- }
993
- const nextCursor = envelope.next_cursor;
994
- if (!nextCursor || nextCursor === cursor || envelope.canonical.length < batchSize) {
995
- return;
996
- }
997
- cursor = nextCursor;
998
- firstPage = false;
999
- }
913
+ walkCanonical(params = {}) {
914
+ return this.keysetWalk(params, (page) => this.listCanonical({ ...params, ...page }), (e) => e.canonical);
1000
915
  }
1001
916
  async listBlocks(params = {}) {
1002
917
  return this.request("GET", `/v1/index/blocks${buildQuery({
@@ -1010,30 +925,8 @@ class Index extends BaseClient {
1010
925
  async getBlock(ref) {
1011
926
  return this.requestOrNull("GET", `/v1/index/blocks/${encodeURIComponent(String(ref))}`);
1012
927
  }
1013
- async* walkBlocks(params = {}) {
1014
- const batchSize = params.batchSize ?? 200;
1015
- let cursor = params.cursor ?? params.fromCursor ?? null;
1016
- let firstPage = true;
1017
- while (!params.signal?.aborted) {
1018
- const envelope = await this.listBlocks({
1019
- ...params,
1020
- limit: batchSize,
1021
- cursor: firstPage ? params.cursor : cursor,
1022
- fromCursor: firstPage ? params.fromCursor : undefined,
1023
- fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
1024
- });
1025
- for (const block of envelope.blocks) {
1026
- if (params.signal?.aborted)
1027
- return;
1028
- yield block;
1029
- }
1030
- const nextCursor = envelope.next_cursor;
1031
- if (!nextCursor || nextCursor === cursor || envelope.blocks.length < batchSize) {
1032
- return;
1033
- }
1034
- cursor = nextCursor;
1035
- firstPage = false;
1036
- }
928
+ walkBlocks(params = {}) {
929
+ return this.keysetWalk(params, (page) => this.listBlocks({ ...params, ...page }), (e) => e.blocks);
1037
930
  }
1038
931
  async listTransactions(params = {}) {
1039
932
  return this.request("GET", `/v1/index/transactions${buildQuery({
@@ -1053,30 +946,8 @@ class Index extends BaseClient {
1053
946
  async getTransactionProof(txId) {
1054
947
  return this.requestOrNull("GET", `/v1/index/transactions/${encodeURIComponent(txId)}/proof`);
1055
948
  }
1056
- async* walkTransactions(params = {}) {
1057
- const batchSize = params.batchSize ?? 200;
1058
- let cursor = params.cursor ?? params.fromCursor ?? null;
1059
- let firstPage = true;
1060
- while (!params.signal?.aborted) {
1061
- const envelope = await this.listTransactions({
1062
- ...params,
1063
- limit: batchSize,
1064
- cursor: firstPage ? params.cursor : cursor,
1065
- fromCursor: firstPage ? params.fromCursor : undefined,
1066
- fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
1067
- });
1068
- for (const tx of envelope.transactions) {
1069
- if (params.signal?.aborted)
1070
- return;
1071
- yield tx;
1072
- }
1073
- const nextCursor = envelope.next_cursor;
1074
- if (!nextCursor || nextCursor === cursor || envelope.transactions.length < batchSize) {
1075
- return;
1076
- }
1077
- cursor = nextCursor;
1078
- firstPage = false;
1079
- }
949
+ walkTransactions(params = {}) {
950
+ return this.keysetWalk(params, (page) => this.listTransactions({ ...params, ...page }), (e) => e.transactions);
1080
951
  }
1081
952
  async listStacking(params = {}) {
1082
953
  return this.request("GET", `/v1/index/stacking${buildQuery({
@@ -1090,30 +961,8 @@ class Index extends BaseClient {
1090
961
  to_height: params.toHeight
1091
962
  })}`);
1092
963
  }
1093
- async* walkStacking(params = {}) {
1094
- const batchSize = params.batchSize ?? 200;
1095
- let cursor = params.cursor ?? params.fromCursor ?? null;
1096
- let firstPage = true;
1097
- while (!params.signal?.aborted) {
1098
- const envelope = await this.listStacking({
1099
- ...params,
1100
- limit: batchSize,
1101
- cursor: firstPage ? params.cursor : cursor,
1102
- fromCursor: firstPage ? params.fromCursor : undefined,
1103
- fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
1104
- });
1105
- for (const action of envelope.stacking) {
1106
- if (params.signal?.aborted)
1107
- return;
1108
- yield action;
1109
- }
1110
- const nextCursor = envelope.next_cursor;
1111
- if (!nextCursor || nextCursor === cursor || envelope.stacking.length < batchSize) {
1112
- return;
1113
- }
1114
- cursor = nextCursor;
1115
- firstPage = false;
1116
- }
964
+ walkStacking(params = {}) {
965
+ return this.keysetWalk(params, (page) => this.listStacking({ ...params, ...page }), (e) => e.stacking);
1117
966
  }
1118
967
  async listMempool(params = {}) {
1119
968
  return this.request("GET", `/v1/index/mempool${buildQuery({
@@ -1128,29 +977,8 @@ class Index extends BaseClient {
1128
977
  async getMempoolTx(txId) {
1129
978
  return this.requestOrNull("GET", `/v1/index/mempool/${encodeURIComponent(txId)}`);
1130
979
  }
1131
- async* walkMempool(params = {}) {
1132
- const batchSize = params.batchSize ?? 200;
1133
- let cursor = params.cursor ?? params.fromCursor ?? null;
1134
- let firstPage = true;
1135
- while (!params.signal?.aborted) {
1136
- const envelope = await this.listMempool({
1137
- ...params,
1138
- limit: batchSize,
1139
- cursor: firstPage ? params.cursor : cursor,
1140
- fromCursor: firstPage ? params.fromCursor : undefined
1141
- });
1142
- for (const tx of envelope.mempool) {
1143
- if (params.signal?.aborted)
1144
- return;
1145
- yield tx;
1146
- }
1147
- const nextCursor = envelope.next_cursor;
1148
- if (!nextCursor || nextCursor === cursor || envelope.mempool.length < batchSize) {
1149
- return;
1150
- }
1151
- cursor = nextCursor;
1152
- firstPage = false;
1153
- }
980
+ walkMempool(params = {}) {
981
+ return this.keysetWalk(params, (page) => this.listMempool({ ...params, ...page }), (e) => e.mempool);
1154
982
  }
1155
983
  async listSbtcDeposits(params = {}) {
1156
984
  return this.request("GET", `/v1/index/sbtc/deposits${buildQuery({
@@ -1164,30 +992,8 @@ class Index extends BaseClient {
1164
992
  to_height: params.toHeight
1165
993
  })}`);
1166
994
  }
1167
- async* walkSbtcDeposits(params = {}) {
1168
- const batchSize = params.batchSize ?? 200;
1169
- let cursor = params.cursor ?? params.fromCursor ?? null;
1170
- let firstPage = true;
1171
- while (!params.signal?.aborted) {
1172
- const envelope = await this.listSbtcDeposits({
1173
- ...params,
1174
- limit: batchSize,
1175
- cursor: firstPage ? params.cursor : cursor,
1176
- fromCursor: firstPage ? params.fromCursor : undefined,
1177
- fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
1178
- });
1179
- for (const deposit of envelope.deposits) {
1180
- if (params.signal?.aborted)
1181
- return;
1182
- yield deposit;
1183
- }
1184
- const nextCursor = envelope.next_cursor;
1185
- if (!nextCursor || nextCursor === cursor || envelope.deposits.length < batchSize) {
1186
- return;
1187
- }
1188
- cursor = nextCursor;
1189
- firstPage = false;
1190
- }
995
+ walkSbtcDeposits(params = {}) {
996
+ return this.keysetWalk(params, (page) => this.listSbtcDeposits({ ...params, ...page }), (e) => e.deposits);
1191
997
  }
1192
998
  async getSbtcDeposit(bitcoinTxid) {
1193
999
  return this.requestOrNull("GET", `/v1/index/sbtc/deposits/${encodeURIComponent(bitcoinTxid)}`);
@@ -1201,34 +1007,13 @@ class Index extends BaseClient {
1201
1007
  status: params.status,
1202
1008
  sender: params.sender,
1203
1009
  request_id: params.requestId,
1010
+ settlement_confirmed: params.settlementConfirmed,
1204
1011
  from_height: params.fromHeight,
1205
1012
  to_height: params.toHeight
1206
1013
  })}`);
1207
1014
  }
1208
- async* walkSbtcWithdrawals(params = {}) {
1209
- const batchSize = params.batchSize ?? 200;
1210
- let cursor = params.cursor ?? params.fromCursor ?? null;
1211
- let firstPage = true;
1212
- while (!params.signal?.aborted) {
1213
- const envelope = await this.listSbtcWithdrawals({
1214
- ...params,
1215
- limit: batchSize,
1216
- cursor: firstPage ? params.cursor : cursor,
1217
- fromCursor: firstPage ? params.fromCursor : undefined,
1218
- fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
1219
- });
1220
- for (const withdrawal of envelope.withdrawals) {
1221
- if (params.signal?.aborted)
1222
- return;
1223
- yield withdrawal;
1224
- }
1225
- const nextCursor = envelope.next_cursor;
1226
- if (!nextCursor || nextCursor === cursor || envelope.withdrawals.length < batchSize) {
1227
- return;
1228
- }
1229
- cursor = nextCursor;
1230
- firstPage = false;
1231
- }
1015
+ walkSbtcWithdrawals(params = {}) {
1016
+ return this.keysetWalk(params, (page) => this.listSbtcWithdrawals({ ...params, ...page }), (e) => e.withdrawals);
1232
1017
  }
1233
1018
  async getSbtcWithdrawal(requestId) {
1234
1019
  return this.requestOrNull("GET", `/v1/index/sbtc/withdrawals/${requestId}`);
@@ -1247,30 +1032,8 @@ class Index extends BaseClient {
1247
1032
  to_height: params.toHeight
1248
1033
  })}`);
1249
1034
  }
1250
- async* walkSbtcEvents(params = {}) {
1251
- const batchSize = params.batchSize ?? 200;
1252
- let cursor = params.cursor ?? params.fromCursor ?? null;
1253
- let firstPage = true;
1254
- while (!params.signal?.aborted) {
1255
- const envelope = await this.listSbtcEvents({
1256
- ...params,
1257
- limit: batchSize,
1258
- cursor: firstPage ? params.cursor : cursor,
1259
- fromCursor: firstPage ? params.fromCursor : undefined,
1260
- fromHeight: firstPage ? firstWalkFromHeight(params) : undefined
1261
- });
1262
- for (const event of envelope.events) {
1263
- if (params.signal?.aborted)
1264
- return;
1265
- yield event;
1266
- }
1267
- const nextCursor = envelope.next_cursor;
1268
- if (!nextCursor || nextCursor === cursor || envelope.events.length < batchSize) {
1269
- return;
1270
- }
1271
- cursor = nextCursor;
1272
- firstPage = false;
1273
- }
1035
+ walkSbtcEvents(params = {}) {
1036
+ return this.keysetWalk(params, (page) => this.listSbtcEvents({ ...params, ...page }), (e) => e.events);
1274
1037
  }
1275
1038
  async getSbtcSummary() {
1276
1039
  return this.request("GET", "/v1/index/sbtc/summary");
@@ -1957,5 +1720,5 @@ export {
1957
1720
  Subgraphs
1958
1721
  };
1959
1722
 
1960
- //# debugId=330E248B8FA1515864756E2164756E21
1723
+ //# debugId=D9521B9F6768A30F64756E2164756E21
1961
1724
  //# sourceMappingURL=index.js.map