@trustware/sdk-staging 1.1.11-staging.2 → 1.1.12-staging.2
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/{blockchain-BxAFzp0s.d.cts → blockchain-DmCPxnxr.d.cts} +25 -1
- package/dist/{blockchain-BxAFzp0s.d.ts → blockchain-DmCPxnxr.d.ts} +25 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/{core-B1WCJfDI.d.ts → core-B4YDGtJT.d.ts} +3 -3
- package/dist/{core-CeNTuqPz.d.cts → core-Ck7dinYj.d.cts} +3 -3
- package/dist/core.cjs +57 -10
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +4 -4
- package/dist/core.d.ts +4 -4
- package/dist/core.mjs +57 -10
- package/dist/core.mjs.map +1 -1
- package/dist/index.cjs +124 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.mjs +124 -29
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-DNGk1YkR.d.cts → manager-BZ8gyHGT.d.cts} +1 -1
- package/dist/{manager-Bw8b1wSD.d.ts → manager-D8nQsod2.d.ts} +1 -1
- package/dist/{metadata-Dk4R8_-T.d.cts → metadata-B23D0oO9.d.cts} +1 -1
- package/dist/{metadata-C__KMeuz.d.ts → metadata-BOjEF7oo.d.ts} +1 -1
- package/dist/smart-account.cjs +26 -5
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.d.cts +1 -0
- package/dist/smart-account.d.ts +1 -0
- package/dist/smart-account.mjs +26 -5
- package/dist/smart-account.mjs.map +1 -1
- package/dist/{types-BJY9r-mz.d.ts → types-CMmx0S4U.d.ts} +1 -1
- package/dist/{types-DX3HtFcn.d.cts → types-DEUb5IZA.d.cts} +1 -1
- package/dist/wallet.cjs +12 -2
- package/dist/wallet.cjs.map +1 -1
- package/dist/wallet.d.cts +4 -4
- package/dist/wallet.d.ts +4 -4
- package/dist/wallet.mjs +12 -2
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +124 -29
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.d.cts +2 -2
- package/dist/widget.d.ts +2 -2
- package/dist/widget.mjs +124 -29
- package/dist/widget.mjs.map +1 -1
- package/package.json +2 -1
package/dist/core.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { T as Trustware, a as TrustwareCore } from './core-
|
|
2
|
-
export { B as BuildRouteBody, m as BuildRouteResponse, a5 as assertValidPostHook } from './manager-
|
|
3
|
-
import './blockchain-
|
|
4
|
-
import './types-
|
|
1
|
+
export { T as Trustware, a as TrustwareCore } from './core-Ck7dinYj.cjs';
|
|
2
|
+
export { B as BuildRouteBody, m as BuildRouteResponse, a5 as assertValidPostHook } from './manager-BZ8gyHGT.cjs';
|
|
3
|
+
import './blockchain-DmCPxnxr.cjs';
|
|
4
|
+
import './types-DEUb5IZA.cjs';
|
package/dist/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { T as Trustware, a as TrustwareCore } from './core-
|
|
2
|
-
export { B as BuildRouteBody, m as BuildRouteResponse, a5 as assertValidPostHook } from './manager-
|
|
3
|
-
import './blockchain-
|
|
4
|
-
import './types-
|
|
1
|
+
export { T as Trustware, a as TrustwareCore } from './core-B4YDGtJT.js';
|
|
2
|
+
export { B as BuildRouteBody, m as BuildRouteResponse, a5 as assertValidPostHook } from './manager-D8nQsod2.js';
|
|
3
|
+
import './blockchain-DmCPxnxr.js';
|
|
4
|
+
import './types-CMmx0S4U.js';
|
package/dist/core.mjs
CHANGED
|
@@ -35,7 +35,17 @@ var init_config = __esm({
|
|
|
35
35
|
RATE_LIMIT_WAIT_BUDGET_MS = 1e4;
|
|
36
36
|
DEFAULT_FEATURE_FLAGS = {
|
|
37
37
|
tokensPagination: true,
|
|
38
|
-
|
|
38
|
+
// On by default: an address scan covers every configured chain and takes
|
|
39
|
+
// seconds end to end, so streaming turns one long wait into a wallet that
|
|
40
|
+
// fills in as results land — first chunk in ~200ms against a ~2.3s buffered
|
|
41
|
+
// response, measured on a live backend.
|
|
42
|
+
//
|
|
43
|
+
// Safe to default because the path degrades on its own: a backend with
|
|
44
|
+
// BALANCE_STREAM_ENABLED off refuses the stream, and the SDK falls back to
|
|
45
|
+
// the buffered endpoint (emitting balance_stream_fallback), as does any
|
|
46
|
+
// runtime whose fetch has no readable body — React Native, most notably.
|
|
47
|
+
// The cost of defaulting ahead of a backend is one refused request per scan.
|
|
48
|
+
balanceStreaming: true,
|
|
39
49
|
shouldAllowGA4: true,
|
|
40
50
|
swapMode: false,
|
|
41
51
|
swapDefaultDestToken: null,
|
|
@@ -51,7 +61,7 @@ var init_constants = __esm({
|
|
|
51
61
|
"src/constants.ts"() {
|
|
52
62
|
"use strict";
|
|
53
63
|
SDK_NAME = "@trustware/sdk";
|
|
54
|
-
SDK_VERSION = "1.1.
|
|
64
|
+
SDK_VERSION = "1.1.12-staging.2";
|
|
55
65
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
56
66
|
API_PREFIX = "/api";
|
|
57
67
|
WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
|
|
@@ -94,7 +104,7 @@ async function assertOK(r) {
|
|
|
94
104
|
throw new Error(`HTTP ${r.status}: ${msg}`);
|
|
95
105
|
}
|
|
96
106
|
async function validateSdkAccess() {
|
|
97
|
-
const r = await fetch(`${apiBase()}/sdk/validate`, {
|
|
107
|
+
const r = await fetch(`${apiBase()}/v1/sdk/validate`, {
|
|
98
108
|
method: "GET",
|
|
99
109
|
headers: jsonHeaders()
|
|
100
110
|
});
|
|
@@ -1777,6 +1787,16 @@ function mergeBalanceWrappers(current, incoming) {
|
|
|
1777
1787
|
}
|
|
1778
1788
|
return Array.from(merged.values());
|
|
1779
1789
|
}
|
|
1790
|
+
function toSummary(frame, address) {
|
|
1791
|
+
const total = toNumberOrUndefined(frame.total) ?? 0;
|
|
1792
|
+
return {
|
|
1793
|
+
address: toStringOrUndefined(frame.address) ?? address,
|
|
1794
|
+
partial: Boolean(frame.partial),
|
|
1795
|
+
completed: toNumberOrUndefined(frame.completed) ?? 0,
|
|
1796
|
+
total,
|
|
1797
|
+
elapsedMs: toNumberOrUndefined(frame.elapsed)
|
|
1798
|
+
};
|
|
1799
|
+
}
|
|
1780
1800
|
async function parseStreamingBalances(response, address, options = {}) {
|
|
1781
1801
|
if (!response.body) {
|
|
1782
1802
|
throw new Error("balances stream: empty response body");
|
|
@@ -1797,7 +1817,12 @@ async function parseStreamingBalances(response, address, options = {}) {
|
|
|
1797
1817
|
if (!trimmed) continue;
|
|
1798
1818
|
try {
|
|
1799
1819
|
const parsed = JSON.parse(trimmed);
|
|
1800
|
-
if (!parsed.chain_id)
|
|
1820
|
+
if (!parsed.chain_id) {
|
|
1821
|
+
if (parsed.type === "summary") {
|
|
1822
|
+
options.onSummary?.(toSummary(parsed, address));
|
|
1823
|
+
}
|
|
1824
|
+
continue;
|
|
1825
|
+
}
|
|
1801
1826
|
const chunk = normalizeStreamChunk(parsed);
|
|
1802
1827
|
emitBalanceStreamChunk(address, chunk.length);
|
|
1803
1828
|
yield chunk;
|
|
@@ -1816,6 +1841,8 @@ async function parseStreamingBalances(response, address, options = {}) {
|
|
|
1816
1841
|
const chunk = normalizeStreamChunk(parsed);
|
|
1817
1842
|
emitBalanceStreamChunk(address, chunk.length);
|
|
1818
1843
|
yield chunk;
|
|
1844
|
+
} else if (parsed.type === "summary") {
|
|
1845
|
+
options.onSummary?.(toSummary(parsed, address));
|
|
1819
1846
|
}
|
|
1820
1847
|
} catch (error) {
|
|
1821
1848
|
if (options.strict) {
|
|
@@ -1870,7 +1897,7 @@ async function getBalancesByAddress(address, opts) {
|
|
|
1870
1897
|
}
|
|
1871
1898
|
return merged;
|
|
1872
1899
|
}
|
|
1873
|
-
const url = `${apiBase()}/data/balances/${address}`;
|
|
1900
|
+
const url = `${apiBase()}/v1/data/balances/${address}`;
|
|
1874
1901
|
const r = await rateLimitedFetch(url, {
|
|
1875
1902
|
method: "GET",
|
|
1876
1903
|
credentials: "omit",
|
|
@@ -1878,14 +1905,27 @@ async function getBalancesByAddress(address, opts) {
|
|
|
1878
1905
|
});
|
|
1879
1906
|
if (!r.ok) throw new Error(`balances: HTTP ${r.status}`);
|
|
1880
1907
|
const j = await r.json();
|
|
1881
|
-
|
|
1908
|
+
const results = Array.isArray(j) ? j : j.results ?? [];
|
|
1909
|
+
if (opts?.onSummary) {
|
|
1910
|
+
const completed = results.length;
|
|
1911
|
+
opts.onSummary({
|
|
1912
|
+
address,
|
|
1913
|
+
partial: Array.isArray(j) ? false : Boolean(j.partial),
|
|
1914
|
+
completed,
|
|
1915
|
+
total: completed
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
return results;
|
|
1919
|
+
}
|
|
1920
|
+
function bufferedOptions(opts) {
|
|
1921
|
+
return { ...opts, stream: false };
|
|
1882
1922
|
}
|
|
1883
1923
|
async function* getBalancesByAddressStream(address, opts = {}) {
|
|
1884
1924
|
if (!TrustwareConfigStore.get().features.balanceStreaming) {
|
|
1885
|
-
yield await getBalancesByAddress(address);
|
|
1925
|
+
yield await getBalancesByAddress(address, bufferedOptions(opts));
|
|
1886
1926
|
return;
|
|
1887
1927
|
}
|
|
1888
|
-
const url = `${apiBase()}/data/balances/${address}?stream=1`;
|
|
1928
|
+
const url = `${apiBase()}/v1/data/balances/${address}?stream=1`;
|
|
1889
1929
|
try {
|
|
1890
1930
|
const response = await rateLimitedFetch(url, {
|
|
1891
1931
|
method: "GET",
|
|
@@ -1901,7 +1941,14 @@ async function* getBalancesByAddressStream(address, opts = {}) {
|
|
|
1901
1941
|
const contentType = response.headers.get("content-type") ?? "";
|
|
1902
1942
|
if (contentType.includes("application/json")) {
|
|
1903
1943
|
const payload = await response.json();
|
|
1904
|
-
|
|
1944
|
+
const results = Array.isArray(payload) ? payload : payload.results ?? [];
|
|
1945
|
+
opts.onSummary?.({
|
|
1946
|
+
address,
|
|
1947
|
+
partial: Array.isArray(payload) ? false : Boolean(payload.partial),
|
|
1948
|
+
completed: results.length,
|
|
1949
|
+
total: results.length
|
|
1950
|
+
});
|
|
1951
|
+
yield results;
|
|
1905
1952
|
return;
|
|
1906
1953
|
}
|
|
1907
1954
|
const stream = await parseStreamingBalances(response, address, opts);
|
|
@@ -1910,7 +1957,7 @@ async function* getBalancesByAddressStream(address, opts = {}) {
|
|
|
1910
1957
|
}
|
|
1911
1958
|
} catch (error) {
|
|
1912
1959
|
emitBalanceStreamFallback(address, error);
|
|
1913
|
-
yield await getBalancesByAddress(address);
|
|
1960
|
+
yield await getBalancesByAddress(address, bufferedOptions(opts));
|
|
1914
1961
|
}
|
|
1915
1962
|
}
|
|
1916
1963
|
async function ensureRegistry() {
|