@secondlayer/sdk 6.51.0 → 6.52.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 CHANGED
@@ -93,10 +93,12 @@ declare class Subgraphs extends BaseClient {
93
93
  openapi(name: string, options?: SubgraphSpecOptions): Promise<Record<string, unknown>>;
94
94
  schema(name: string, options?: SubgraphSpecOptions): Promise<SubgraphAgentSchema>;
95
95
  markdown(name: string, options?: SubgraphSpecOptions): Promise<string>;
96
- reindex(name: string, options?: {
97
- fromBlock?: number;
98
- toBlock?: number;
99
- }): Promise<ReindexResponse>;
96
+ /**
97
+ * Reindex always drops and rebuilds the whole subgraph, so it takes no
98
+ * block range — the API rejects one with `REINDEX_RANGE_NOT_SUPPORTED`.
99
+ * Use {@link backfill} to process a specific range.
100
+ */
101
+ reindex(name: string): Promise<ReindexResponse>;
100
102
  stop(name: string): Promise<{
101
103
  message: string;
102
104
  operationId?: string;
package/dist/index.js CHANGED
@@ -367,8 +367,8 @@ class Subgraphs extends BaseClient {
367
367
  async markdown(name, options) {
368
368
  return this.requestText("GET", `/api/subgraphs/${name}/docs.md${buildSpecQueryString(options)}`);
369
369
  }
370
- async reindex(name, options) {
371
- return this.request("POST", `/api/subgraphs/${name}/reindex`, options);
370
+ async reindex(name) {
371
+ return this.request("POST", `/api/subgraphs/${name}/reindex`);
372
372
  }
373
373
  async stop(name) {
374
374
  return this.request("POST", `/api/subgraphs/${name}/stop`);
@@ -945,6 +945,16 @@ function firstWalkFromHeight(params) {
945
945
  return;
946
946
  return 0;
947
947
  }
948
+ function indexPageQuery(params) {
949
+ return {
950
+ cursor: params.cursor,
951
+ from_cursor: params.fromCursor,
952
+ limit: params.limit,
953
+ from_height: params.fromHeight,
954
+ to_height: params.toHeight,
955
+ fields: params.fields
956
+ };
957
+ }
948
958
 
949
959
  class Index extends BaseClient {
950
960
  constructor(options = {}) {
@@ -1090,30 +1100,20 @@ class Index extends BaseClient {
1090
1100
  };
1091
1101
  async listFtTransfers(params = {}) {
1092
1102
  return this.request("GET", `/v1/index/ft-transfers${buildQuery({
1093
- cursor: params.cursor,
1094
- from_cursor: params.fromCursor,
1095
- limit: params.limit,
1103
+ ...indexPageQuery(params),
1096
1104
  contract_id: params.contractId,
1097
1105
  asset_identifier: params.assetIdentifier,
1098
1106
  sender: params.sender,
1099
- recipient: params.recipient,
1100
- from_height: params.fromHeight,
1101
- to_height: params.toHeight,
1102
- fields: params.fields?.join(",")
1107
+ recipient: params.recipient
1103
1108
  })}`);
1104
1109
  }
1105
1110
  async listNftTransfers(params = {}) {
1106
1111
  return this.request("GET", `/v1/index/nft-transfers${buildQuery({
1107
- cursor: params.cursor,
1108
- from_cursor: params.fromCursor,
1109
- limit: params.limit,
1112
+ ...indexPageQuery(params),
1110
1113
  contract_id: params.contractId,
1111
1114
  asset_identifier: params.assetIdentifier,
1112
1115
  sender: params.sender,
1113
- recipient: params.recipient,
1114
- from_height: params.fromHeight,
1115
- to_height: params.toHeight,
1116
- fields: params.fields?.join(",")
1116
+ recipient: params.recipient
1117
1117
  })}`);
1118
1118
  }
1119
1119
  async* keysetWalk(params, list, itemsOf) {
@@ -1149,19 +1149,14 @@ class Index extends BaseClient {
1149
1149
  }
1150
1150
  async listEvents(params) {
1151
1151
  return this.request("GET", `/v1/index/events${buildQuery({
1152
+ ...indexPageQuery(params),
1152
1153
  event_type: params.eventType,
1153
- cursor: params.cursor,
1154
- from_cursor: params.fromCursor,
1155
- limit: params.limit,
1156
1154
  contract_id: params.contractId,
1157
1155
  asset_identifier: params.assetIdentifier,
1158
1156
  sender: params.sender,
1159
1157
  recipient: params.recipient,
1160
- from_height: params.fromHeight,
1161
- to_height: params.toHeight,
1162
1158
  trait: params.trait,
1163
- tx_context: params.txContext ? "true" : undefined,
1164
- fields: params.fields?.join(",")
1159
+ tx_context: params.txContext ? "true" : undefined
1165
1160
  })}`);
1166
1161
  }
1167
1162
  walkEvents(params) {
@@ -1169,14 +1164,10 @@ class Index extends BaseClient {
1169
1164
  }
1170
1165
  async listContractCalls(params = {}) {
1171
1166
  return this.request("GET", `/v1/index/contract-calls${buildQuery({
1172
- cursor: params.cursor,
1173
- from_cursor: params.fromCursor,
1174
- limit: params.limit,
1167
+ ...indexPageQuery(params),
1175
1168
  contract_id: params.contractId,
1176
1169
  function_name: params.functionName,
1177
1170
  sender: params.sender,
1178
- from_height: params.fromHeight,
1179
- to_height: params.toHeight,
1180
1171
  trait: params.trait
1181
1172
  })}`);
1182
1173
  }
@@ -1184,25 +1175,13 @@ class Index extends BaseClient {
1184
1175
  return this.keysetWalk(params, (page) => this.listContractCalls({ ...params, ...page }), (e) => e.contract_calls);
1185
1176
  }
1186
1177
  async listCanonical(params = {}) {
1187
- return this.request("GET", `/v1/index/canonical${buildQuery({
1188
- cursor: params.cursor,
1189
- from_cursor: params.fromCursor,
1190
- limit: params.limit,
1191
- from_height: params.fromHeight,
1192
- to_height: params.toHeight
1193
- })}`);
1178
+ return this.request("GET", `/v1/index/canonical${buildQuery(indexPageQuery(params))}`);
1194
1179
  }
1195
1180
  walkCanonical(params = {}) {
1196
1181
  return this.keysetWalk(params, (page) => this.listCanonical({ ...params, ...page }), (e) => e.canonical);
1197
1182
  }
1198
1183
  async listBlocks(params = {}) {
1199
- return this.request("GET", `/v1/index/blocks${buildQuery({
1200
- cursor: params.cursor,
1201
- from_cursor: params.fromCursor,
1202
- limit: params.limit,
1203
- from_height: params.fromHeight,
1204
- to_height: params.toHeight
1205
- })}`);
1184
+ return this.request("GET", `/v1/index/blocks${buildQuery(indexPageQuery(params))}`);
1206
1185
  }
1207
1186
  async getBlock(ref) {
1208
1187
  return this.requestOrNull("GET", `/v1/index/blocks/${encodeURIComponent(String(ref))}`);
@@ -1212,15 +1191,10 @@ class Index extends BaseClient {
1212
1191
  }
1213
1192
  async listTransactions(params = {}) {
1214
1193
  return this.request("GET", `/v1/index/transactions${buildQuery({
1215
- cursor: params.cursor,
1216
- from_cursor: params.fromCursor,
1217
- limit: params.limit,
1194
+ ...indexPageQuery(params),
1218
1195
  type: params.type,
1219
1196
  sender: params.sender,
1220
- contract_id: params.contractId,
1221
- from_height: params.fromHeight,
1222
- to_height: params.toHeight,
1223
- fields: params.fields?.join(",")
1197
+ contract_id: params.contractId
1224
1198
  })}`);
1225
1199
  }
1226
1200
  async getTransaction(txId) {
@@ -1234,14 +1208,10 @@ class Index extends BaseClient {
1234
1208
  }
1235
1209
  async listStacking(params = {}) {
1236
1210
  return this.request("GET", `/v1/index/stacking${buildQuery({
1237
- cursor: params.cursor,
1238
- from_cursor: params.fromCursor,
1239
- limit: params.limit,
1211
+ ...indexPageQuery(params),
1240
1212
  function_name: params.functionName,
1241
1213
  stacker: params.stacker,
1242
- caller: params.caller,
1243
- from_height: params.fromHeight,
1244
- to_height: params.toHeight
1214
+ caller: params.caller
1245
1215
  })}`);
1246
1216
  }
1247
1217
  walkStacking(params = {}) {
@@ -1249,9 +1219,7 @@ class Index extends BaseClient {
1249
1219
  }
1250
1220
  async listMempool(params = {}) {
1251
1221
  return this.request("GET", `/v1/index/mempool${buildQuery({
1252
- cursor: params.cursor,
1253
- from_cursor: params.fromCursor,
1254
- limit: params.limit,
1222
+ ...indexPageQuery(params),
1255
1223
  sender: params.sender,
1256
1224
  type: params.type,
1257
1225
  contract_id: params.contractId,
@@ -1266,15 +1234,10 @@ class Index extends BaseClient {
1266
1234
  }
1267
1235
  async listSbtcDeposits(params = {}) {
1268
1236
  return this.request("GET", `/v1/index/sbtc/deposits${buildQuery({
1269
- cursor: params.cursor,
1270
- from_cursor: params.fromCursor,
1271
- limit: params.limit,
1237
+ ...indexPageQuery(params),
1272
1238
  confirmed: params.confirmed,
1273
1239
  sender: params.sender,
1274
- bitcoin_txid: params.bitcoinTxid,
1275
- from_height: params.fromHeight,
1276
- to_height: params.toHeight,
1277
- fields: params.fields?.join(",")
1240
+ bitcoin_txid: params.bitcoinTxid
1278
1241
  })}`);
1279
1242
  }
1280
1243
  walkSbtcDeposits(params = {}) {
@@ -1285,17 +1248,12 @@ class Index extends BaseClient {
1285
1248
  }
1286
1249
  async listSbtcWithdrawals(params = {}) {
1287
1250
  return this.request("GET", `/v1/index/sbtc/withdrawals${buildQuery({
1288
- cursor: params.cursor,
1289
- from_cursor: params.fromCursor,
1290
- limit: params.limit,
1251
+ ...indexPageQuery(params),
1291
1252
  confirmed: params.confirmed,
1292
1253
  status: params.status,
1293
1254
  sender: params.sender,
1294
1255
  request_id: params.requestId,
1295
- settlement_confirmed: params.settlementConfirmed,
1296
- from_height: params.fromHeight,
1297
- to_height: params.toHeight,
1298
- fields: params.fields?.join(",")
1256
+ settlement_confirmed: params.settlementConfirmed
1299
1257
  })}`);
1300
1258
  }
1301
1259
  walkSbtcWithdrawals(params = {}) {
@@ -1306,16 +1264,12 @@ class Index extends BaseClient {
1306
1264
  }
1307
1265
  async listSbtcEvents(params = {}) {
1308
1266
  return this.request("GET", `/v1/index/sbtc/events${buildQuery({
1309
- cursor: params.cursor,
1310
- from_cursor: params.fromCursor,
1311
- limit: params.limit,
1267
+ ...indexPageQuery(params),
1312
1268
  confirmed: params.confirmed,
1313
1269
  topic: params.topic,
1314
1270
  sender: params.sender,
1315
1271
  request_id: params.requestId,
1316
- bitcoin_txid: params.bitcoinTxid,
1317
- from_height: params.fromHeight,
1318
- to_height: params.toHeight
1272
+ bitcoin_txid: params.bitcoinTxid
1319
1273
  })}`);
1320
1274
  }
1321
1275
  walkSbtcEvents(params = {}) {
@@ -1326,19 +1280,14 @@ class Index extends BaseClient {
1326
1280
  }
1327
1281
  async listPox5Events(params = {}) {
1328
1282
  return this.request("GET", `/v1/index/pox5/events${buildQuery({
1329
- cursor: params.cursor,
1330
- from_cursor: params.fromCursor,
1331
- limit: params.limit,
1283
+ ...indexPageQuery(params),
1332
1284
  confirmed: params.confirmed,
1333
1285
  topic: params.topic,
1334
1286
  staker: params.staker,
1335
1287
  signer: params.signer,
1336
1288
  signer_manager: params.signerManager,
1337
1289
  bond_index: params.bondIndex,
1338
- reward_cycle: params.rewardCycle,
1339
- from_height: params.fromHeight,
1340
- to_height: params.toHeight,
1341
- fields: params.fields?.join(",")
1290
+ reward_cycle: params.rewardCycle
1342
1291
  })}`);
1343
1292
  }
1344
1293
  walkPox5Events(params = {}) {
@@ -2930,5 +2879,5 @@ export {
2930
2879
  ApiError
2931
2880
  };
2932
2881
 
2933
- //# debugId=B1BDDF1D7FA0472C64756E2164756E21
2882
+ //# debugId=7A6D4D9CC23446D364756E2164756E21
2934
2883
  //# sourceMappingURL=index.js.map