@trustware/sdk-staging 1.1.8-staging.8 → 1.1.9-staging.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/README.md +0 -2
- package/dist/{blockchain-BONedEsU.d.cts → blockchain-BxAFzp0s.d.cts} +5 -1
- package/dist/{blockchain-BONedEsU.d.ts → blockchain-BxAFzp0s.d.ts} +5 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/{core-BjQwlpoI.d.cts → core-D_jx805U.d.cts} +32 -4
- package/dist/{core-BQ0mFnLc.d.ts → core-p_5BLdbE.d.ts} +32 -4
- package/dist/core.cjs +69 -32
- 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 +69 -32
- package/dist/core.mjs.map +1 -1
- package/dist/{detect-DlbgTrkm.d.cts → detect--pmNlAHv.d.cts} +1 -1
- package/dist/{detect-MWKHLhn9.d.ts → detect-qAX6I4JI.d.ts} +1 -1
- package/dist/index.cjs +108 -66
- 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 +108 -66
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-aOd3vkF9.d.ts → manager-DFQkemW0.d.ts} +1 -3
- package/dist/{manager-DKVW7zeh.d.cts → manager-aMi4_Ss6.d.cts} +1 -3
- package/dist/smart-account.cjs +1 -2
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.mjs +1 -2
- package/dist/smart-account.mjs.map +1 -1
- package/dist/{types-MtdjJgwT.d.ts → types-BJY9r-mz.d.ts} +1 -1
- package/dist/{types-B3nKHW6H.d.cts → types-DX3HtFcn.d.cts} +1 -1
- package/dist/wallet.cjs +22 -7
- 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 +22 -7
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +81 -39
- 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 +81 -39
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/core.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { T as Trustware, a as TrustwareCore } from './core-
|
|
2
|
-
import './manager-
|
|
3
|
-
import './blockchain-
|
|
4
|
-
import './types-
|
|
1
|
+
export { T as Trustware, a as TrustwareCore } from './core-D_jx805U.cjs';
|
|
2
|
+
import './manager-aMi4_Ss6.cjs';
|
|
3
|
+
import './blockchain-BxAFzp0s.cjs';
|
|
4
|
+
import './types-DX3HtFcn.cjs';
|
package/dist/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { T as Trustware, a as TrustwareCore } from './core-
|
|
2
|
-
import './manager-
|
|
3
|
-
import './blockchain-
|
|
4
|
-
import './types-
|
|
1
|
+
export { T as Trustware, a as TrustwareCore } from './core-p_5BLdbE.js';
|
|
2
|
+
import './manager-DFQkemW0.js';
|
|
3
|
+
import './blockchain-BxAFzp0s.js';
|
|
4
|
+
import './types-BJY9r-mz.js';
|
package/dist/core.mjs
CHANGED
|
@@ -53,7 +53,7 @@ var init_constants = __esm({
|
|
|
53
53
|
"src/constants.ts"() {
|
|
54
54
|
"use strict";
|
|
55
55
|
SDK_NAME = "@trustware/sdk";
|
|
56
|
-
SDK_VERSION = "1.1.
|
|
56
|
+
SDK_VERSION = "1.1.9-staging.1";
|
|
57
57
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
58
58
|
API_PREFIX = "/api";
|
|
59
59
|
WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
|
|
@@ -71,16 +71,6 @@ var init_config2 = __esm({
|
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
// src/core/http.ts
|
|
74
|
-
var http_exports = {};
|
|
75
|
-
__export(http_exports, {
|
|
76
|
-
RateLimitError: () => RateLimitError,
|
|
77
|
-
apiBase: () => apiBase,
|
|
78
|
-
assertOK: () => assertOK,
|
|
79
|
-
jsonHeaders: () => jsonHeaders,
|
|
80
|
-
parseRateLimitHeaders: () => parseRateLimitHeaders,
|
|
81
|
-
rateLimitedFetch: () => rateLimitedFetch,
|
|
82
|
-
validateSdkAccess: () => validateSdkAccess
|
|
83
|
-
});
|
|
84
74
|
function apiBase() {
|
|
85
75
|
return `${API_ROOT}${API_PREFIX}`;
|
|
86
76
|
}
|
|
@@ -278,11 +268,6 @@ var init_chains = __esm({
|
|
|
278
268
|
});
|
|
279
269
|
|
|
280
270
|
// src/registry.ts
|
|
281
|
-
var registry_exports = {};
|
|
282
|
-
__export(registry_exports, {
|
|
283
|
-
NATIVE: () => NATIVE,
|
|
284
|
-
Registry: () => Registry
|
|
285
|
-
});
|
|
286
271
|
function getChainAliases(chain) {
|
|
287
272
|
const values = [
|
|
288
273
|
chain.chainId,
|
|
@@ -1816,7 +1801,7 @@ async function parseStreamingBalances(response, address, options = {}) {
|
|
|
1816
1801
|
}
|
|
1817
1802
|
return stream();
|
|
1818
1803
|
}
|
|
1819
|
-
async function getBalances(chainRef, address) {
|
|
1804
|
+
async function getBalances(chainRef, address, opts) {
|
|
1820
1805
|
const reg = await ensureRegistry();
|
|
1821
1806
|
const chain = reg.chain(chainRef);
|
|
1822
1807
|
if (!chain) return [];
|
|
@@ -1831,8 +1816,10 @@ async function getBalances(chainRef, address) {
|
|
|
1831
1816
|
chain.nativeCurrency?.decimals ?? "",
|
|
1832
1817
|
normalizeChainType(chain) ?? ""
|
|
1833
1818
|
].join(":");
|
|
1834
|
-
|
|
1835
|
-
|
|
1819
|
+
if (!opts?.forceRefresh) {
|
|
1820
|
+
const cached = balanceCache.get(cacheKey);
|
|
1821
|
+
if (cached) return cached;
|
|
1822
|
+
}
|
|
1836
1823
|
const url = `${apiBase()}/v1/data/wallets/${encodeURIComponent(chainKey)}/${trimmedAddress}/balances`;
|
|
1837
1824
|
const response = await fetch(url, {
|
|
1838
1825
|
method: "GET",
|
|
@@ -2145,11 +2132,27 @@ function toSolanaWalletInterface(provider) {
|
|
|
2145
2132
|
serializedTransactionBase64
|
|
2146
2133
|
);
|
|
2147
2134
|
if (provider.signAndSendTransaction) {
|
|
2148
|
-
const
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2135
|
+
const MAX_INTERNAL_ERROR_ATTEMPTS = 3;
|
|
2136
|
+
const INTERNAL_ERROR_RETRY_DELAY_MS = 500;
|
|
2137
|
+
for (let attempt = 1; attempt <= MAX_INTERNAL_ERROR_ATTEMPTS; attempt++) {
|
|
2138
|
+
try {
|
|
2139
|
+
const result = await provider.signAndSendTransaction(transaction, {
|
|
2140
|
+
skipPreflight: true
|
|
2141
|
+
});
|
|
2142
|
+
if (typeof result === "string") return result;
|
|
2143
|
+
if (result?.signature) return result.signature;
|
|
2144
|
+
break;
|
|
2145
|
+
} catch (err) {
|
|
2146
|
+
const code = err?.code;
|
|
2147
|
+
if (code === -32603 && attempt < MAX_INTERNAL_ERROR_ATTEMPTS) {
|
|
2148
|
+
await new Promise(
|
|
2149
|
+
(resolve) => setTimeout(resolve, INTERNAL_ERROR_RETRY_DELAY_MS * attempt)
|
|
2150
|
+
);
|
|
2151
|
+
continue;
|
|
2152
|
+
}
|
|
2153
|
+
throw err;
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2153
2156
|
}
|
|
2154
2157
|
if (!provider.signTransaction) {
|
|
2155
2158
|
throw new Error("Connected Solana wallet cannot sign transactions");
|
|
@@ -3879,6 +3882,10 @@ var init_routes = __esm({
|
|
|
3879
3882
|
});
|
|
3880
3883
|
|
|
3881
3884
|
// src/core/registryClient.ts
|
|
3885
|
+
var registryClient_exports = {};
|
|
3886
|
+
__export(registryClient_exports, {
|
|
3887
|
+
getSharedRegistry: () => getSharedRegistry
|
|
3888
|
+
});
|
|
3882
3889
|
function registryCacheKey() {
|
|
3883
3890
|
const base = apiBase();
|
|
3884
3891
|
const apiKey = TrustwareConfigStore.peek()?.apiKey ?? "__uninitialized__";
|
|
@@ -6046,7 +6053,6 @@ function resolveConfig(input) {
|
|
|
6046
6053
|
defaultSlippage: normalizeSlippage(
|
|
6047
6054
|
input.routes.defaultSlippage ?? DEFAULT_SLIPPAGE
|
|
6048
6055
|
),
|
|
6049
|
-
routeType: input.routes.routeType ?? "swap",
|
|
6050
6056
|
options: {
|
|
6051
6057
|
...input.routes.options
|
|
6052
6058
|
}
|
|
@@ -6247,10 +6253,9 @@ async function sendRouteTransaction(b, fallbackChainId) {
|
|
|
6247
6253
|
if (w.ecosystem !== "solana") {
|
|
6248
6254
|
throw new Error("A Solana wallet is required for this route");
|
|
6249
6255
|
}
|
|
6250
|
-
const {
|
|
6251
|
-
const
|
|
6252
|
-
|
|
6253
|
-
await registry.ensureLoaded();
|
|
6256
|
+
const { getSharedRegistry: getSharedRegistry2 } = await Promise.resolve().then(() => (init_registryClient(), registryClient_exports));
|
|
6257
|
+
const registry = getSharedRegistry2();
|
|
6258
|
+
await registry.ensureChainsLoaded();
|
|
6254
6259
|
const chain = registry.chain(
|
|
6255
6260
|
String(fallbackChainId ?? txReq.chainId ?? "")
|
|
6256
6261
|
);
|
|
@@ -6264,9 +6269,8 @@ async function sendRouteTransaction(b, fallbackChainId) {
|
|
|
6264
6269
|
async function runTopUp(params) {
|
|
6265
6270
|
const w = walletManager.wallet;
|
|
6266
6271
|
if (!w) throw new Error("Trustware.wallet not configured");
|
|
6267
|
-
const {
|
|
6268
|
-
const
|
|
6269
|
-
const reg = new Registry2(apiBase2());
|
|
6272
|
+
const { getSharedRegistry: getSharedRegistry2 } = await Promise.resolve().then(() => (init_registryClient(), registryClient_exports));
|
|
6273
|
+
const reg = getSharedRegistry2();
|
|
6270
6274
|
await reg.ensureLoaded();
|
|
6271
6275
|
const fromAddress = await w.getAddress();
|
|
6272
6276
|
const currentChainRef = w.ecosystem === "evm" ? String(await w.getChainId()) : await w.getChainKey?.() ?? "solana-mainnet-beta";
|
|
@@ -6375,6 +6379,39 @@ var init_core = __esm({
|
|
|
6375
6379
|
getConfig() {
|
|
6376
6380
|
return TrustwareConfigStore.get();
|
|
6377
6381
|
},
|
|
6382
|
+
/**
|
|
6383
|
+
* Read the SDK's currently configured theme mode.
|
|
6384
|
+
*
|
|
6385
|
+
* Returns the raw setting — `"light" | "dark" | "system"` — i.e. whatever
|
|
6386
|
+
* was last passed to `init()` or `setTheme()`. When the mode is `"system"`,
|
|
6387
|
+
* the widget resolves the actual light/dark appearance itself (from the OS
|
|
6388
|
+
* `prefers-color-scheme`, or a saved preference if the user has used the
|
|
6389
|
+
* widget's built-in theme toggle), so this getter still reports `"system"`
|
|
6390
|
+
* rather than the resolved value.
|
|
6391
|
+
*/
|
|
6392
|
+
getTheme() {
|
|
6393
|
+
return TrustwareConfigStore.get().theme;
|
|
6394
|
+
},
|
|
6395
|
+
/**
|
|
6396
|
+
* Set the widget's theme at runtime.
|
|
6397
|
+
*
|
|
6398
|
+
* Call this from your own app's theme toggle to keep an embedded
|
|
6399
|
+
* `TrustwareWidget` in sync with your UI — no remount required, any
|
|
6400
|
+
* mounted widget picks up the change immediately.
|
|
6401
|
+
*
|
|
6402
|
+
* Passing `"light"` or `"dark"` pins the widget to that mode. Passing
|
|
6403
|
+
* `"system"` makes it follow the OS preference again — unless the user
|
|
6404
|
+
* previously used the widget's own in-widget theme toggle, in which case
|
|
6405
|
+
* their saved choice takes precedence until they toggle it again.
|
|
6406
|
+
*
|
|
6407
|
+
* @example
|
|
6408
|
+
* // In your app's own dark-mode toggle handler:
|
|
6409
|
+
* Trustware.setTheme(isDark ? "dark" : "light");
|
|
6410
|
+
*/
|
|
6411
|
+
setTheme(theme) {
|
|
6412
|
+
TrustwareConfigStore.update({ theme });
|
|
6413
|
+
return Trustware;
|
|
6414
|
+
},
|
|
6378
6415
|
setDestinationAddress(address) {
|
|
6379
6416
|
const prev = TrustwareConfigStore.get();
|
|
6380
6417
|
TrustwareConfigStore.update({
|