@secondlayer/sdk 6.52.1 → 6.54.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 +5 -2
- package/dist/index.js +39 -72
- package/dist/index.js.map +5 -5
- package/dist/streams/index.js +29 -49
- package/dist/streams/index.js.map +4 -4
- package/dist/subgraphs/index.d.ts +1 -1
- package/dist/subgraphs/index.js +37 -72
- package/dist/subgraphs/index.js.map +5 -5
- package/package.json +3 -3
|
@@ -1994,7 +1994,7 @@ type SbtcEventsWalkParams = Omit<SbtcEventsListParams, "limit"> & {
|
|
|
1994
1994
|
signal?: AbortSignal;
|
|
1995
1995
|
};
|
|
1996
1996
|
type SbtcEventsConsumeParams<TTx = never> = Omit<SbtcEventsListParams, "cursor" | "fromCursor" | "limit"> & IndexConsumeOptions<IndexSbtcEvent, SbtcEventsEnvelope, TTx>;
|
|
1997
|
-
type SbtcDepositsConsumeParams<TTx = never> = Omit<SbtcDepositsListParams, "cursor" | "fromCursor" | "limit"> & IndexConsumeOptions<IndexSbtcDeposit, SbtcDepositsEnvelope, TTx>;
|
|
1997
|
+
type SbtcDepositsConsumeParams<TTx = never> = Omit<SbtcDepositsListParams, "cursor" | "fromCursor" | "limit" | "fields"> & IndexConsumeOptions<IndexSbtcDeposit, SbtcDepositsEnvelope, TTx>;
|
|
1998
1998
|
/** `index.sbtc` — the decoded sBTC peg surface (deposits, withdrawals, raw
|
|
1999
1999
|
* events, scoreboard). The only productized decoded sBTC peg feed on Stacks. */
|
|
2000
2000
|
interface SbtcResource {
|
package/dist/subgraphs/index.js
CHANGED
|
@@ -156,7 +156,17 @@ function isByoBreakingDetails(x) {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
// src/base.ts
|
|
159
|
-
var
|
|
159
|
+
var LOCAL_API_URL = "http://127.0.0.1:3800";
|
|
160
|
+
function resolveBaseUrl(explicit) {
|
|
161
|
+
if (explicit && explicit.length > 0)
|
|
162
|
+
return explicit.replace(/\/+$/, "");
|
|
163
|
+
if (typeof process !== "undefined") {
|
|
164
|
+
const fromEnv = process.env?.SL_API_URL || process.env?.SECONDLAYER_API_URL;
|
|
165
|
+
if (fromEnv)
|
|
166
|
+
return fromEnv.replace(/\/+$/, "");
|
|
167
|
+
}
|
|
168
|
+
return LOCAL_API_URL;
|
|
169
|
+
}
|
|
160
170
|
function resolveApiKey(apiKey) {
|
|
161
171
|
if (apiKey !== undefined)
|
|
162
172
|
return apiKey;
|
|
@@ -184,7 +194,7 @@ class BaseClient {
|
|
|
184
194
|
origin;
|
|
185
195
|
fetchImpl;
|
|
186
196
|
constructor(options = {}) {
|
|
187
|
-
this.baseUrl = (options.baseUrl
|
|
197
|
+
this.baseUrl = resolveBaseUrl(options.baseUrl);
|
|
188
198
|
this.apiKey = resolveApiKey(options.apiKey);
|
|
189
199
|
this.origin = options.origin ?? "cli";
|
|
190
200
|
this.fetchImpl = options.fetchImpl ?? ((...args) => fetch(...args));
|
|
@@ -938,6 +948,10 @@ async function consumeIndexFeed(opts) {
|
|
|
938
948
|
}
|
|
939
949
|
|
|
940
950
|
// src/index-api/client.ts
|
|
951
|
+
function feedFilters(params) {
|
|
952
|
+
const { fromCursor: _checkpoint, ...filters } = params;
|
|
953
|
+
return filters;
|
|
954
|
+
}
|
|
941
955
|
function firstWalkFromHeight(params) {
|
|
942
956
|
if (params.fromHeight !== undefined)
|
|
943
957
|
return params.fromHeight;
|
|
@@ -983,14 +997,7 @@ class Index extends BaseClient {
|
|
|
983
997
|
consume: (params) => consumeIndexFeed({
|
|
984
998
|
...params,
|
|
985
999
|
fetchPage: ({ cursor, fromHeight, limit }) => this.listEvents({
|
|
986
|
-
|
|
987
|
-
contractId: params.contractId,
|
|
988
|
-
assetIdentifier: params.assetIdentifier,
|
|
989
|
-
sender: params.sender,
|
|
990
|
-
recipient: params.recipient,
|
|
991
|
-
trait: params.trait,
|
|
992
|
-
toHeight: params.toHeight,
|
|
993
|
-
txContext: params.txContext,
|
|
1000
|
+
...feedFilters(params),
|
|
994
1001
|
cursor,
|
|
995
1002
|
fromHeight,
|
|
996
1003
|
limit
|
|
@@ -1004,11 +1011,7 @@ class Index extends BaseClient {
|
|
|
1004
1011
|
consume: (params) => consumeIndexFeed({
|
|
1005
1012
|
...params,
|
|
1006
1013
|
fetchPage: ({ cursor, fromHeight, limit }) => this.listContractCalls({
|
|
1007
|
-
|
|
1008
|
-
functionName: params.functionName,
|
|
1009
|
-
sender: params.sender,
|
|
1010
|
-
trait: params.trait,
|
|
1011
|
-
toHeight: params.toHeight,
|
|
1014
|
+
...feedFilters(params),
|
|
1012
1015
|
cursor,
|
|
1013
1016
|
fromHeight,
|
|
1014
1017
|
limit
|
|
@@ -1047,10 +1050,7 @@ class Index extends BaseClient {
|
|
|
1047
1050
|
consume: (params) => consumeIndexFeed({
|
|
1048
1051
|
...params,
|
|
1049
1052
|
fetchPage: ({ cursor, fromHeight, limit }) => this.listSbtcDeposits({
|
|
1050
|
-
|
|
1051
|
-
sender: params.sender,
|
|
1052
|
-
bitcoinTxid: params.bitcoinTxid,
|
|
1053
|
-
toHeight: params.toHeight,
|
|
1053
|
+
...feedFilters(params),
|
|
1054
1054
|
cursor,
|
|
1055
1055
|
fromHeight,
|
|
1056
1056
|
limit
|
|
@@ -1070,12 +1070,7 @@ class Index extends BaseClient {
|
|
|
1070
1070
|
consume: (params) => consumeIndexFeed({
|
|
1071
1071
|
...params,
|
|
1072
1072
|
fetchPage: ({ cursor, fromHeight, limit }) => this.listSbtcEvents({
|
|
1073
|
-
|
|
1074
|
-
topic: params.topic,
|
|
1075
|
-
sender: params.sender,
|
|
1076
|
-
requestId: params.requestId,
|
|
1077
|
-
bitcoinTxid: params.bitcoinTxid,
|
|
1078
|
-
toHeight: params.toHeight,
|
|
1073
|
+
...feedFilters(params),
|
|
1079
1074
|
cursor,
|
|
1080
1075
|
fromHeight,
|
|
1081
1076
|
limit
|
|
@@ -1725,7 +1720,17 @@ function maxCursor(a, b) {
|
|
|
1725
1720
|
const [bh, bi] = cursorTuple(b);
|
|
1726
1721
|
return ah > bh || ah === bh && ai >= bi ? a : b;
|
|
1727
1722
|
}
|
|
1728
|
-
|
|
1723
|
+
function streamsFilters(params) {
|
|
1724
|
+
return {
|
|
1725
|
+
types: params.types,
|
|
1726
|
+
notTypes: params.notTypes,
|
|
1727
|
+
contractId: params.contractId,
|
|
1728
|
+
sender: params.sender,
|
|
1729
|
+
recipient: params.recipient,
|
|
1730
|
+
assetIdentifier: params.assetIdentifier,
|
|
1731
|
+
filters: params.filters
|
|
1732
|
+
};
|
|
1733
|
+
}
|
|
1729
1734
|
function normalizeBaseUrl(baseUrl) {
|
|
1730
1735
|
return baseUrl.replace(/\/+$/, "");
|
|
1731
1736
|
}
|
|
@@ -1765,7 +1770,7 @@ async function mapStreamsError(response) {
|
|
|
1765
1770
|
throw new ValidationError(errorMessage(body, `Streams request returned ${response.status}.`), response.status, body);
|
|
1766
1771
|
}
|
|
1767
1772
|
function createStreamsClient(options) {
|
|
1768
|
-
const baseUrl = normalizeBaseUrl(options.baseUrl
|
|
1773
|
+
const baseUrl = normalizeBaseUrl(resolveBaseUrl(options.baseUrl));
|
|
1769
1774
|
const fetchImpl = options.fetchImpl ?? ((input, init) => fetch(input, init));
|
|
1770
1775
|
const verify = options.verify;
|
|
1771
1776
|
const verifyMode = verify === false ? "off" : verify === undefined ? "lenient" : "strict";
|
|
@@ -1836,29 +1841,7 @@ function createStreamsClient(options) {
|
|
|
1836
1841
|
}
|
|
1837
1842
|
return JSON.parse(text);
|
|
1838
1843
|
}
|
|
1839
|
-
const fetchEvents =
|
|
1840
|
-
cursor,
|
|
1841
|
-
limit,
|
|
1842
|
-
types,
|
|
1843
|
-
notTypes,
|
|
1844
|
-
contractId,
|
|
1845
|
-
sender,
|
|
1846
|
-
recipient,
|
|
1847
|
-
assetIdentifier,
|
|
1848
|
-
filters
|
|
1849
|
-
}) => {
|
|
1850
|
-
return listEvents({
|
|
1851
|
-
cursor,
|
|
1852
|
-
limit,
|
|
1853
|
-
types,
|
|
1854
|
-
notTypes,
|
|
1855
|
-
contractId,
|
|
1856
|
-
sender,
|
|
1857
|
-
recipient,
|
|
1858
|
-
assetIdentifier,
|
|
1859
|
-
filters
|
|
1860
|
-
});
|
|
1861
|
-
};
|
|
1844
|
+
const fetchEvents = listEvents;
|
|
1862
1845
|
function encodeFilters(filters) {
|
|
1863
1846
|
return filters ? JSON.stringify(filters) : undefined;
|
|
1864
1847
|
}
|
|
@@ -1903,13 +1886,7 @@ function createStreamsClient(options) {
|
|
|
1903
1886
|
onProgress: params.onProgress,
|
|
1904
1887
|
mode: params.mode,
|
|
1905
1888
|
finalizedOnly: params.finalizedOnly,
|
|
1906
|
-
|
|
1907
|
-
notTypes: params.notTypes,
|
|
1908
|
-
contractId: params.contractId,
|
|
1909
|
-
sender: params.sender,
|
|
1910
|
-
recipient: params.recipient,
|
|
1911
|
-
assetIdentifier: params.assetIdentifier,
|
|
1912
|
-
filters: params.filters,
|
|
1889
|
+
...streamsFilters(params),
|
|
1913
1890
|
batchSize: params.batchSize ?? 100,
|
|
1914
1891
|
fetchEvents,
|
|
1915
1892
|
onBatch,
|
|
@@ -1929,13 +1906,7 @@ function createStreamsClient(options) {
|
|
|
1929
1906
|
fromCursor: params.cursor,
|
|
1930
1907
|
batchSize: params.batchSize ?? 100,
|
|
1931
1908
|
intervalMs: params.intervalMs ?? 2000,
|
|
1932
|
-
|
|
1933
|
-
notTypes: params.notTypes,
|
|
1934
|
-
contractId: params.contractId,
|
|
1935
|
-
sender: params.sender,
|
|
1936
|
-
recipient: params.recipient,
|
|
1937
|
-
assetIdentifier: params.assetIdentifier,
|
|
1938
|
-
filters: params.filters,
|
|
1909
|
+
...streamsFilters(params),
|
|
1939
1910
|
signal: params.signal,
|
|
1940
1911
|
fetchEvents
|
|
1941
1912
|
});
|
|
@@ -1949,13 +1920,7 @@ function createStreamsClient(options) {
|
|
|
1949
1920
|
stream(params = {}) {
|
|
1950
1921
|
return streamStreamsEvents({
|
|
1951
1922
|
fromCursor: params.fromCursor,
|
|
1952
|
-
|
|
1953
|
-
notTypes: params.notTypes,
|
|
1954
|
-
contractId: params.contractId,
|
|
1955
|
-
sender: params.sender,
|
|
1956
|
-
recipient: params.recipient,
|
|
1957
|
-
assetIdentifier: params.assetIdentifier,
|
|
1958
|
-
filters: params.filters,
|
|
1923
|
+
...streamsFilters(params),
|
|
1959
1924
|
batchSize: params.batchSize ?? 100,
|
|
1960
1925
|
emptyBackoffMs: params.emptyBackoffMs,
|
|
1961
1926
|
maxPages: params.maxPages,
|
|
@@ -2182,5 +2147,5 @@ export {
|
|
|
2182
2147
|
Subgraphs
|
|
2183
2148
|
};
|
|
2184
2149
|
|
|
2185
|
-
//# debugId=
|
|
2150
|
+
//# debugId=D5DB35E1FBF2DF3E64756E2164756E21
|
|
2186
2151
|
//# sourceMappingURL=index.js.map
|