@secondlayer/sdk 6.52.0 → 6.53.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 +1 -1
- package/dist/index.js +56 -151
- package/dist/index.js.map +4 -4
- package/dist/streams/index.js +16 -45
- package/dist/streams/index.js.map +3 -3
- package/dist/subgraphs/index.d.ts +1 -1
- package/dist/subgraphs/index.js +56 -151
- package/dist/subgraphs/index.js.map +4 -4
- package/package.json +2 -2
package/dist/subgraphs/index.js
CHANGED
|
@@ -938,6 +938,10 @@ async function consumeIndexFeed(opts) {
|
|
|
938
938
|
}
|
|
939
939
|
|
|
940
940
|
// src/index-api/client.ts
|
|
941
|
+
function feedFilters(params) {
|
|
942
|
+
const { fromCursor: _checkpoint, ...filters } = params;
|
|
943
|
+
return filters;
|
|
944
|
+
}
|
|
941
945
|
function firstWalkFromHeight(params) {
|
|
942
946
|
if (params.fromHeight !== undefined)
|
|
943
947
|
return params.fromHeight;
|
|
@@ -945,6 +949,16 @@ function firstWalkFromHeight(params) {
|
|
|
945
949
|
return;
|
|
946
950
|
return 0;
|
|
947
951
|
}
|
|
952
|
+
function indexPageQuery(params) {
|
|
953
|
+
return {
|
|
954
|
+
cursor: params.cursor,
|
|
955
|
+
from_cursor: params.fromCursor,
|
|
956
|
+
limit: params.limit,
|
|
957
|
+
from_height: params.fromHeight,
|
|
958
|
+
to_height: params.toHeight,
|
|
959
|
+
fields: params.fields
|
|
960
|
+
};
|
|
961
|
+
}
|
|
948
962
|
|
|
949
963
|
class Index extends BaseClient {
|
|
950
964
|
constructor(options = {}) {
|
|
@@ -973,14 +987,7 @@ class Index extends BaseClient {
|
|
|
973
987
|
consume: (params) => consumeIndexFeed({
|
|
974
988
|
...params,
|
|
975
989
|
fetchPage: ({ cursor, fromHeight, limit }) => this.listEvents({
|
|
976
|
-
|
|
977
|
-
contractId: params.contractId,
|
|
978
|
-
assetIdentifier: params.assetIdentifier,
|
|
979
|
-
sender: params.sender,
|
|
980
|
-
recipient: params.recipient,
|
|
981
|
-
trait: params.trait,
|
|
982
|
-
toHeight: params.toHeight,
|
|
983
|
-
txContext: params.txContext,
|
|
990
|
+
...feedFilters(params),
|
|
984
991
|
cursor,
|
|
985
992
|
fromHeight,
|
|
986
993
|
limit
|
|
@@ -994,11 +1001,7 @@ class Index extends BaseClient {
|
|
|
994
1001
|
consume: (params) => consumeIndexFeed({
|
|
995
1002
|
...params,
|
|
996
1003
|
fetchPage: ({ cursor, fromHeight, limit }) => this.listContractCalls({
|
|
997
|
-
|
|
998
|
-
functionName: params.functionName,
|
|
999
|
-
sender: params.sender,
|
|
1000
|
-
trait: params.trait,
|
|
1001
|
-
toHeight: params.toHeight,
|
|
1004
|
+
...feedFilters(params),
|
|
1002
1005
|
cursor,
|
|
1003
1006
|
fromHeight,
|
|
1004
1007
|
limit
|
|
@@ -1037,10 +1040,7 @@ class Index extends BaseClient {
|
|
|
1037
1040
|
consume: (params) => consumeIndexFeed({
|
|
1038
1041
|
...params,
|
|
1039
1042
|
fetchPage: ({ cursor, fromHeight, limit }) => this.listSbtcDeposits({
|
|
1040
|
-
|
|
1041
|
-
sender: params.sender,
|
|
1042
|
-
bitcoinTxid: params.bitcoinTxid,
|
|
1043
|
-
toHeight: params.toHeight,
|
|
1043
|
+
...feedFilters(params),
|
|
1044
1044
|
cursor,
|
|
1045
1045
|
fromHeight,
|
|
1046
1046
|
limit
|
|
@@ -1060,12 +1060,7 @@ class Index extends BaseClient {
|
|
|
1060
1060
|
consume: (params) => consumeIndexFeed({
|
|
1061
1061
|
...params,
|
|
1062
1062
|
fetchPage: ({ cursor, fromHeight, limit }) => this.listSbtcEvents({
|
|
1063
|
-
|
|
1064
|
-
topic: params.topic,
|
|
1065
|
-
sender: params.sender,
|
|
1066
|
-
requestId: params.requestId,
|
|
1067
|
-
bitcoinTxid: params.bitcoinTxid,
|
|
1068
|
-
toHeight: params.toHeight,
|
|
1063
|
+
...feedFilters(params),
|
|
1069
1064
|
cursor,
|
|
1070
1065
|
fromHeight,
|
|
1071
1066
|
limit
|
|
@@ -1090,30 +1085,20 @@ class Index extends BaseClient {
|
|
|
1090
1085
|
};
|
|
1091
1086
|
async listFtTransfers(params = {}) {
|
|
1092
1087
|
return this.request("GET", `/v1/index/ft-transfers${buildQuery({
|
|
1093
|
-
|
|
1094
|
-
from_cursor: params.fromCursor,
|
|
1095
|
-
limit: params.limit,
|
|
1088
|
+
...indexPageQuery(params),
|
|
1096
1089
|
contract_id: params.contractId,
|
|
1097
1090
|
asset_identifier: params.assetIdentifier,
|
|
1098
1091
|
sender: params.sender,
|
|
1099
|
-
recipient: params.recipient
|
|
1100
|
-
from_height: params.fromHeight,
|
|
1101
|
-
to_height: params.toHeight,
|
|
1102
|
-
fields: params.fields?.join(",")
|
|
1092
|
+
recipient: params.recipient
|
|
1103
1093
|
})}`);
|
|
1104
1094
|
}
|
|
1105
1095
|
async listNftTransfers(params = {}) {
|
|
1106
1096
|
return this.request("GET", `/v1/index/nft-transfers${buildQuery({
|
|
1107
|
-
|
|
1108
|
-
from_cursor: params.fromCursor,
|
|
1109
|
-
limit: params.limit,
|
|
1097
|
+
...indexPageQuery(params),
|
|
1110
1098
|
contract_id: params.contractId,
|
|
1111
1099
|
asset_identifier: params.assetIdentifier,
|
|
1112
1100
|
sender: params.sender,
|
|
1113
|
-
recipient: params.recipient
|
|
1114
|
-
from_height: params.fromHeight,
|
|
1115
|
-
to_height: params.toHeight,
|
|
1116
|
-
fields: params.fields?.join(",")
|
|
1101
|
+
recipient: params.recipient
|
|
1117
1102
|
})}`);
|
|
1118
1103
|
}
|
|
1119
1104
|
async* keysetWalk(params, list, itemsOf) {
|
|
@@ -1149,19 +1134,14 @@ class Index extends BaseClient {
|
|
|
1149
1134
|
}
|
|
1150
1135
|
async listEvents(params) {
|
|
1151
1136
|
return this.request("GET", `/v1/index/events${buildQuery({
|
|
1137
|
+
...indexPageQuery(params),
|
|
1152
1138
|
event_type: params.eventType,
|
|
1153
|
-
cursor: params.cursor,
|
|
1154
|
-
from_cursor: params.fromCursor,
|
|
1155
|
-
limit: params.limit,
|
|
1156
1139
|
contract_id: params.contractId,
|
|
1157
1140
|
asset_identifier: params.assetIdentifier,
|
|
1158
1141
|
sender: params.sender,
|
|
1159
1142
|
recipient: params.recipient,
|
|
1160
|
-
from_height: params.fromHeight,
|
|
1161
|
-
to_height: params.toHeight,
|
|
1162
1143
|
trait: params.trait,
|
|
1163
|
-
tx_context: params.txContext ? "true" : undefined
|
|
1164
|
-
fields: params.fields?.join(",")
|
|
1144
|
+
tx_context: params.txContext ? "true" : undefined
|
|
1165
1145
|
})}`);
|
|
1166
1146
|
}
|
|
1167
1147
|
walkEvents(params) {
|
|
@@ -1169,14 +1149,10 @@ class Index extends BaseClient {
|
|
|
1169
1149
|
}
|
|
1170
1150
|
async listContractCalls(params = {}) {
|
|
1171
1151
|
return this.request("GET", `/v1/index/contract-calls${buildQuery({
|
|
1172
|
-
|
|
1173
|
-
from_cursor: params.fromCursor,
|
|
1174
|
-
limit: params.limit,
|
|
1152
|
+
...indexPageQuery(params),
|
|
1175
1153
|
contract_id: params.contractId,
|
|
1176
1154
|
function_name: params.functionName,
|
|
1177
1155
|
sender: params.sender,
|
|
1178
|
-
from_height: params.fromHeight,
|
|
1179
|
-
to_height: params.toHeight,
|
|
1180
1156
|
trait: params.trait
|
|
1181
1157
|
})}`);
|
|
1182
1158
|
}
|
|
@@ -1184,25 +1160,13 @@ class Index extends BaseClient {
|
|
|
1184
1160
|
return this.keysetWalk(params, (page) => this.listContractCalls({ ...params, ...page }), (e) => e.contract_calls);
|
|
1185
1161
|
}
|
|
1186
1162
|
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
|
-
})}`);
|
|
1163
|
+
return this.request("GET", `/v1/index/canonical${buildQuery(indexPageQuery(params))}`);
|
|
1194
1164
|
}
|
|
1195
1165
|
walkCanonical(params = {}) {
|
|
1196
1166
|
return this.keysetWalk(params, (page) => this.listCanonical({ ...params, ...page }), (e) => e.canonical);
|
|
1197
1167
|
}
|
|
1198
1168
|
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
|
-
})}`);
|
|
1169
|
+
return this.request("GET", `/v1/index/blocks${buildQuery(indexPageQuery(params))}`);
|
|
1206
1170
|
}
|
|
1207
1171
|
async getBlock(ref) {
|
|
1208
1172
|
return this.requestOrNull("GET", `/v1/index/blocks/${encodeURIComponent(String(ref))}`);
|
|
@@ -1212,15 +1176,10 @@ class Index extends BaseClient {
|
|
|
1212
1176
|
}
|
|
1213
1177
|
async listTransactions(params = {}) {
|
|
1214
1178
|
return this.request("GET", `/v1/index/transactions${buildQuery({
|
|
1215
|
-
|
|
1216
|
-
from_cursor: params.fromCursor,
|
|
1217
|
-
limit: params.limit,
|
|
1179
|
+
...indexPageQuery(params),
|
|
1218
1180
|
type: params.type,
|
|
1219
1181
|
sender: params.sender,
|
|
1220
|
-
contract_id: params.contractId
|
|
1221
|
-
from_height: params.fromHeight,
|
|
1222
|
-
to_height: params.toHeight,
|
|
1223
|
-
fields: params.fields?.join(",")
|
|
1182
|
+
contract_id: params.contractId
|
|
1224
1183
|
})}`);
|
|
1225
1184
|
}
|
|
1226
1185
|
async getTransaction(txId) {
|
|
@@ -1234,14 +1193,10 @@ class Index extends BaseClient {
|
|
|
1234
1193
|
}
|
|
1235
1194
|
async listStacking(params = {}) {
|
|
1236
1195
|
return this.request("GET", `/v1/index/stacking${buildQuery({
|
|
1237
|
-
|
|
1238
|
-
from_cursor: params.fromCursor,
|
|
1239
|
-
limit: params.limit,
|
|
1196
|
+
...indexPageQuery(params),
|
|
1240
1197
|
function_name: params.functionName,
|
|
1241
1198
|
stacker: params.stacker,
|
|
1242
|
-
caller: params.caller
|
|
1243
|
-
from_height: params.fromHeight,
|
|
1244
|
-
to_height: params.toHeight
|
|
1199
|
+
caller: params.caller
|
|
1245
1200
|
})}`);
|
|
1246
1201
|
}
|
|
1247
1202
|
walkStacking(params = {}) {
|
|
@@ -1249,9 +1204,7 @@ class Index extends BaseClient {
|
|
|
1249
1204
|
}
|
|
1250
1205
|
async listMempool(params = {}) {
|
|
1251
1206
|
return this.request("GET", `/v1/index/mempool${buildQuery({
|
|
1252
|
-
|
|
1253
|
-
from_cursor: params.fromCursor,
|
|
1254
|
-
limit: params.limit,
|
|
1207
|
+
...indexPageQuery(params),
|
|
1255
1208
|
sender: params.sender,
|
|
1256
1209
|
type: params.type,
|
|
1257
1210
|
contract_id: params.contractId,
|
|
@@ -1266,15 +1219,10 @@ class Index extends BaseClient {
|
|
|
1266
1219
|
}
|
|
1267
1220
|
async listSbtcDeposits(params = {}) {
|
|
1268
1221
|
return this.request("GET", `/v1/index/sbtc/deposits${buildQuery({
|
|
1269
|
-
|
|
1270
|
-
from_cursor: params.fromCursor,
|
|
1271
|
-
limit: params.limit,
|
|
1222
|
+
...indexPageQuery(params),
|
|
1272
1223
|
confirmed: params.confirmed,
|
|
1273
1224
|
sender: params.sender,
|
|
1274
|
-
bitcoin_txid: params.bitcoinTxid
|
|
1275
|
-
from_height: params.fromHeight,
|
|
1276
|
-
to_height: params.toHeight,
|
|
1277
|
-
fields: params.fields?.join(",")
|
|
1225
|
+
bitcoin_txid: params.bitcoinTxid
|
|
1278
1226
|
})}`);
|
|
1279
1227
|
}
|
|
1280
1228
|
walkSbtcDeposits(params = {}) {
|
|
@@ -1285,17 +1233,12 @@ class Index extends BaseClient {
|
|
|
1285
1233
|
}
|
|
1286
1234
|
async listSbtcWithdrawals(params = {}) {
|
|
1287
1235
|
return this.request("GET", `/v1/index/sbtc/withdrawals${buildQuery({
|
|
1288
|
-
|
|
1289
|
-
from_cursor: params.fromCursor,
|
|
1290
|
-
limit: params.limit,
|
|
1236
|
+
...indexPageQuery(params),
|
|
1291
1237
|
confirmed: params.confirmed,
|
|
1292
1238
|
status: params.status,
|
|
1293
1239
|
sender: params.sender,
|
|
1294
1240
|
request_id: params.requestId,
|
|
1295
|
-
settlement_confirmed: params.settlementConfirmed
|
|
1296
|
-
from_height: params.fromHeight,
|
|
1297
|
-
to_height: params.toHeight,
|
|
1298
|
-
fields: params.fields?.join(",")
|
|
1241
|
+
settlement_confirmed: params.settlementConfirmed
|
|
1299
1242
|
})}`);
|
|
1300
1243
|
}
|
|
1301
1244
|
walkSbtcWithdrawals(params = {}) {
|
|
@@ -1306,16 +1249,12 @@ class Index extends BaseClient {
|
|
|
1306
1249
|
}
|
|
1307
1250
|
async listSbtcEvents(params = {}) {
|
|
1308
1251
|
return this.request("GET", `/v1/index/sbtc/events${buildQuery({
|
|
1309
|
-
|
|
1310
|
-
from_cursor: params.fromCursor,
|
|
1311
|
-
limit: params.limit,
|
|
1252
|
+
...indexPageQuery(params),
|
|
1312
1253
|
confirmed: params.confirmed,
|
|
1313
1254
|
topic: params.topic,
|
|
1314
1255
|
sender: params.sender,
|
|
1315
1256
|
request_id: params.requestId,
|
|
1316
|
-
bitcoin_txid: params.bitcoinTxid
|
|
1317
|
-
from_height: params.fromHeight,
|
|
1318
|
-
to_height: params.toHeight
|
|
1257
|
+
bitcoin_txid: params.bitcoinTxid
|
|
1319
1258
|
})}`);
|
|
1320
1259
|
}
|
|
1321
1260
|
walkSbtcEvents(params = {}) {
|
|
@@ -1326,19 +1265,14 @@ class Index extends BaseClient {
|
|
|
1326
1265
|
}
|
|
1327
1266
|
async listPox5Events(params = {}) {
|
|
1328
1267
|
return this.request("GET", `/v1/index/pox5/events${buildQuery({
|
|
1329
|
-
|
|
1330
|
-
from_cursor: params.fromCursor,
|
|
1331
|
-
limit: params.limit,
|
|
1268
|
+
...indexPageQuery(params),
|
|
1332
1269
|
confirmed: params.confirmed,
|
|
1333
1270
|
topic: params.topic,
|
|
1334
1271
|
staker: params.staker,
|
|
1335
1272
|
signer: params.signer,
|
|
1336
1273
|
signer_manager: params.signerManager,
|
|
1337
1274
|
bond_index: params.bondIndex,
|
|
1338
|
-
reward_cycle: params.rewardCycle
|
|
1339
|
-
from_height: params.fromHeight,
|
|
1340
|
-
to_height: params.toHeight,
|
|
1341
|
-
fields: params.fields?.join(",")
|
|
1275
|
+
reward_cycle: params.rewardCycle
|
|
1342
1276
|
})}`);
|
|
1343
1277
|
}
|
|
1344
1278
|
walkPox5Events(params = {}) {
|
|
@@ -1776,6 +1710,17 @@ function maxCursor(a, b) {
|
|
|
1776
1710
|
const [bh, bi] = cursorTuple(b);
|
|
1777
1711
|
return ah > bh || ah === bh && ai >= bi ? a : b;
|
|
1778
1712
|
}
|
|
1713
|
+
function streamsFilters(params) {
|
|
1714
|
+
return {
|
|
1715
|
+
types: params.types,
|
|
1716
|
+
notTypes: params.notTypes,
|
|
1717
|
+
contractId: params.contractId,
|
|
1718
|
+
sender: params.sender,
|
|
1719
|
+
recipient: params.recipient,
|
|
1720
|
+
assetIdentifier: params.assetIdentifier,
|
|
1721
|
+
filters: params.filters
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1779
1724
|
var DEFAULT_STREAMS_BASE_URL = "https://api.secondlayer.tools";
|
|
1780
1725
|
function normalizeBaseUrl(baseUrl) {
|
|
1781
1726
|
return baseUrl.replace(/\/+$/, "");
|
|
@@ -1887,29 +1832,7 @@ function createStreamsClient(options) {
|
|
|
1887
1832
|
}
|
|
1888
1833
|
return JSON.parse(text);
|
|
1889
1834
|
}
|
|
1890
|
-
const fetchEvents =
|
|
1891
|
-
cursor,
|
|
1892
|
-
limit,
|
|
1893
|
-
types,
|
|
1894
|
-
notTypes,
|
|
1895
|
-
contractId,
|
|
1896
|
-
sender,
|
|
1897
|
-
recipient,
|
|
1898
|
-
assetIdentifier,
|
|
1899
|
-
filters
|
|
1900
|
-
}) => {
|
|
1901
|
-
return listEvents({
|
|
1902
|
-
cursor,
|
|
1903
|
-
limit,
|
|
1904
|
-
types,
|
|
1905
|
-
notTypes,
|
|
1906
|
-
contractId,
|
|
1907
|
-
sender,
|
|
1908
|
-
recipient,
|
|
1909
|
-
assetIdentifier,
|
|
1910
|
-
filters
|
|
1911
|
-
});
|
|
1912
|
-
};
|
|
1835
|
+
const fetchEvents = listEvents;
|
|
1913
1836
|
function encodeFilters(filters) {
|
|
1914
1837
|
return filters ? JSON.stringify(filters) : undefined;
|
|
1915
1838
|
}
|
|
@@ -1954,13 +1877,7 @@ function createStreamsClient(options) {
|
|
|
1954
1877
|
onProgress: params.onProgress,
|
|
1955
1878
|
mode: params.mode,
|
|
1956
1879
|
finalizedOnly: params.finalizedOnly,
|
|
1957
|
-
|
|
1958
|
-
notTypes: params.notTypes,
|
|
1959
|
-
contractId: params.contractId,
|
|
1960
|
-
sender: params.sender,
|
|
1961
|
-
recipient: params.recipient,
|
|
1962
|
-
assetIdentifier: params.assetIdentifier,
|
|
1963
|
-
filters: params.filters,
|
|
1880
|
+
...streamsFilters(params),
|
|
1964
1881
|
batchSize: params.batchSize ?? 100,
|
|
1965
1882
|
fetchEvents,
|
|
1966
1883
|
onBatch,
|
|
@@ -1980,13 +1897,7 @@ function createStreamsClient(options) {
|
|
|
1980
1897
|
fromCursor: params.cursor,
|
|
1981
1898
|
batchSize: params.batchSize ?? 100,
|
|
1982
1899
|
intervalMs: params.intervalMs ?? 2000,
|
|
1983
|
-
|
|
1984
|
-
notTypes: params.notTypes,
|
|
1985
|
-
contractId: params.contractId,
|
|
1986
|
-
sender: params.sender,
|
|
1987
|
-
recipient: params.recipient,
|
|
1988
|
-
assetIdentifier: params.assetIdentifier,
|
|
1989
|
-
filters: params.filters,
|
|
1900
|
+
...streamsFilters(params),
|
|
1990
1901
|
signal: params.signal,
|
|
1991
1902
|
fetchEvents
|
|
1992
1903
|
});
|
|
@@ -2000,13 +1911,7 @@ function createStreamsClient(options) {
|
|
|
2000
1911
|
stream(params = {}) {
|
|
2001
1912
|
return streamStreamsEvents({
|
|
2002
1913
|
fromCursor: params.fromCursor,
|
|
2003
|
-
|
|
2004
|
-
notTypes: params.notTypes,
|
|
2005
|
-
contractId: params.contractId,
|
|
2006
|
-
sender: params.sender,
|
|
2007
|
-
recipient: params.recipient,
|
|
2008
|
-
assetIdentifier: params.assetIdentifier,
|
|
2009
|
-
filters: params.filters,
|
|
1914
|
+
...streamsFilters(params),
|
|
2010
1915
|
batchSize: params.batchSize ?? 100,
|
|
2011
1916
|
emptyBackoffMs: params.emptyBackoffMs,
|
|
2012
1917
|
maxPages: params.maxPages,
|
|
@@ -2233,5 +2138,5 @@ export {
|
|
|
2233
2138
|
Subgraphs
|
|
2234
2139
|
};
|
|
2235
2140
|
|
|
2236
|
-
//# debugId=
|
|
2141
|
+
//# debugId=15400962101264EB64756E2164756E21
|
|
2237
2142
|
//# sourceMappingURL=index.js.map
|