@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as DetectedWallet, W as WagmiBridge, P as WalletInterFaceAPI, E as EIP1193, L as WalletId, f as EIP6963ProviderDetail } from './manager-
|
|
1
|
+
import { e as DetectedWallet, W as WagmiBridge, P as WalletInterFaceAPI, E as EIP1193, L as WalletId, f as EIP6963ProviderDetail } from './manager-aMi4_Ss6.cjs';
|
|
2
2
|
|
|
3
3
|
/** Try wagmi bridge first (if provided), otherwise return EIP-1193 adapter. */
|
|
4
4
|
declare function connectDetectedWallet(dw: DetectedWallet, opts?: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as DetectedWallet, W as WagmiBridge, P as WalletInterFaceAPI, E as EIP1193, L as WalletId, f as EIP6963ProviderDetail } from './manager-
|
|
1
|
+
import { e as DetectedWallet, W as WagmiBridge, P as WalletInterFaceAPI, E as EIP1193, L as WalletId, f as EIP6963ProviderDetail } from './manager-DFQkemW0.js';
|
|
2
2
|
|
|
3
3
|
/** Try wagmi bridge first (if provided), otherwise return EIP-1193 adapter. */
|
|
4
4
|
declare function connectDetectedWallet(dw: DetectedWallet, opts?: {
|
package/dist/index.cjs
CHANGED
|
@@ -129,7 +129,6 @@ function resolveConfig(input) {
|
|
|
129
129
|
defaultSlippage: normalizeSlippage(
|
|
130
130
|
input.routes.defaultSlippage ?? DEFAULT_SLIPPAGE
|
|
131
131
|
),
|
|
132
|
-
routeType: input.routes.routeType ?? "swap",
|
|
133
132
|
options: {
|
|
134
133
|
...input.routes.options
|
|
135
134
|
}
|
|
@@ -431,7 +430,7 @@ var init_constants = __esm({
|
|
|
431
430
|
"src/constants.ts"() {
|
|
432
431
|
"use strict";
|
|
433
432
|
SDK_NAME = "@trustware/sdk";
|
|
434
|
-
SDK_VERSION = "1.1.
|
|
433
|
+
SDK_VERSION = "1.1.9-staging.1";
|
|
435
434
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
436
435
|
GTM_ID = "GTM-TZDGNCXB";
|
|
437
436
|
API_PREFIX = "/api";
|
|
@@ -451,16 +450,6 @@ var init_config2 = __esm({
|
|
|
451
450
|
});
|
|
452
451
|
|
|
453
452
|
// src/core/http.ts
|
|
454
|
-
var http_exports = {};
|
|
455
|
-
__export(http_exports, {
|
|
456
|
-
RateLimitError: () => RateLimitError,
|
|
457
|
-
apiBase: () => apiBase,
|
|
458
|
-
assertOK: () => assertOK,
|
|
459
|
-
jsonHeaders: () => jsonHeaders,
|
|
460
|
-
parseRateLimitHeaders: () => parseRateLimitHeaders,
|
|
461
|
-
rateLimitedFetch: () => rateLimitedFetch,
|
|
462
|
-
validateSdkAccess: () => validateSdkAccess
|
|
463
|
-
});
|
|
464
453
|
function apiBase() {
|
|
465
454
|
return `${API_ROOT}${API_PREFIX}`;
|
|
466
455
|
}
|
|
@@ -912,11 +901,27 @@ function toSolanaWalletInterface(provider) {
|
|
|
912
901
|
serializedTransactionBase64
|
|
913
902
|
);
|
|
914
903
|
if (provider.signAndSendTransaction) {
|
|
915
|
-
const
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
904
|
+
const MAX_INTERNAL_ERROR_ATTEMPTS = 3;
|
|
905
|
+
const INTERNAL_ERROR_RETRY_DELAY_MS = 500;
|
|
906
|
+
for (let attempt = 1; attempt <= MAX_INTERNAL_ERROR_ATTEMPTS; attempt++) {
|
|
907
|
+
try {
|
|
908
|
+
const result = await provider.signAndSendTransaction(transaction, {
|
|
909
|
+
skipPreflight: true
|
|
910
|
+
});
|
|
911
|
+
if (typeof result === "string") return result;
|
|
912
|
+
if (result?.signature) return result.signature;
|
|
913
|
+
break;
|
|
914
|
+
} catch (err) {
|
|
915
|
+
const code = err?.code;
|
|
916
|
+
if (code === -32603 && attempt < MAX_INTERNAL_ERROR_ATTEMPTS) {
|
|
917
|
+
await new Promise(
|
|
918
|
+
(resolve) => setTimeout(resolve, INTERNAL_ERROR_RETRY_DELAY_MS * attempt)
|
|
919
|
+
);
|
|
920
|
+
continue;
|
|
921
|
+
}
|
|
922
|
+
throw err;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
920
925
|
}
|
|
921
926
|
if (!provider.signTransaction) {
|
|
922
927
|
throw new Error("Connected Solana wallet cannot sign transactions");
|
|
@@ -4195,11 +4200,6 @@ var init_routes = __esm({
|
|
|
4195
4200
|
});
|
|
4196
4201
|
|
|
4197
4202
|
// src/registry.ts
|
|
4198
|
-
var registry_exports = {};
|
|
4199
|
-
__export(registry_exports, {
|
|
4200
|
-
NATIVE: () => NATIVE,
|
|
4201
|
-
Registry: () => Registry
|
|
4202
|
-
});
|
|
4203
4203
|
function getChainAliases(chain) {
|
|
4204
4204
|
const values = [
|
|
4205
4205
|
chain.chainId,
|
|
@@ -4724,7 +4724,7 @@ async function parseStreamingBalances(response, address, options = {}) {
|
|
|
4724
4724
|
}
|
|
4725
4725
|
return stream();
|
|
4726
4726
|
}
|
|
4727
|
-
async function getBalances(chainRef, address) {
|
|
4727
|
+
async function getBalances(chainRef, address, opts) {
|
|
4728
4728
|
const reg = await ensureRegistry();
|
|
4729
4729
|
const chain = reg.chain(chainRef);
|
|
4730
4730
|
if (!chain) return [];
|
|
@@ -4739,8 +4739,10 @@ async function getBalances(chainRef, address) {
|
|
|
4739
4739
|
chain.nativeCurrency?.decimals ?? "",
|
|
4740
4740
|
normalizeChainType(chain) ?? ""
|
|
4741
4741
|
].join(":");
|
|
4742
|
-
|
|
4743
|
-
|
|
4742
|
+
if (!opts?.forceRefresh) {
|
|
4743
|
+
const cached = balanceCache.get(cacheKey);
|
|
4744
|
+
if (cached) return cached;
|
|
4745
|
+
}
|
|
4744
4746
|
const url = `${apiBase()}/v1/data/wallets/${encodeURIComponent(chainKey)}/${trimmedAddress}/balances`;
|
|
4745
4747
|
const response = await fetch(url, {
|
|
4746
4748
|
method: "GET",
|
|
@@ -4826,6 +4828,37 @@ var init_balances = __esm({
|
|
|
4826
4828
|
}
|
|
4827
4829
|
});
|
|
4828
4830
|
|
|
4831
|
+
// src/core/registryClient.ts
|
|
4832
|
+
var registryClient_exports = {};
|
|
4833
|
+
__export(registryClient_exports, {
|
|
4834
|
+
getSharedRegistry: () => getSharedRegistry
|
|
4835
|
+
});
|
|
4836
|
+
function registryCacheKey() {
|
|
4837
|
+
const base2 = apiBase();
|
|
4838
|
+
const apiKey = TrustwareConfigStore.peek()?.apiKey ?? "__uninitialized__";
|
|
4839
|
+
return `${base2}::${apiKey}`;
|
|
4840
|
+
}
|
|
4841
|
+
function getSharedRegistry() {
|
|
4842
|
+
const key = registryCacheKey();
|
|
4843
|
+
const existing = registryCache.get(key);
|
|
4844
|
+
if (existing) {
|
|
4845
|
+
return existing;
|
|
4846
|
+
}
|
|
4847
|
+
const registry = new Registry(apiBase());
|
|
4848
|
+
registryCache.set(key, registry);
|
|
4849
|
+
return registry;
|
|
4850
|
+
}
|
|
4851
|
+
var registryCache;
|
|
4852
|
+
var init_registryClient = __esm({
|
|
4853
|
+
"src/core/registryClient.ts"() {
|
|
4854
|
+
"use strict";
|
|
4855
|
+
init_config2();
|
|
4856
|
+
init_registry();
|
|
4857
|
+
init_http();
|
|
4858
|
+
registryCache = /* @__PURE__ */ new Map();
|
|
4859
|
+
}
|
|
4860
|
+
});
|
|
4861
|
+
|
|
4829
4862
|
// src/core/tx.ts
|
|
4830
4863
|
function backendChainId(chain, fallback) {
|
|
4831
4864
|
const preferred = chain?.networkIdentifier ?? chain?.chainId ?? chain?.id;
|
|
@@ -4897,10 +4930,9 @@ async function sendRouteTransaction(b, fallbackChainId) {
|
|
|
4897
4930
|
if (w.ecosystem !== "solana") {
|
|
4898
4931
|
throw new Error("A Solana wallet is required for this route");
|
|
4899
4932
|
}
|
|
4900
|
-
const {
|
|
4901
|
-
const
|
|
4902
|
-
|
|
4903
|
-
await registry.ensureLoaded();
|
|
4933
|
+
const { getSharedRegistry: getSharedRegistry2 } = await Promise.resolve().then(() => (init_registryClient(), registryClient_exports));
|
|
4934
|
+
const registry = getSharedRegistry2();
|
|
4935
|
+
await registry.ensureChainsLoaded();
|
|
4904
4936
|
const chain = registry.chain(
|
|
4905
4937
|
String(fallbackChainId ?? txReq.chainId ?? "")
|
|
4906
4938
|
);
|
|
@@ -4914,9 +4946,8 @@ async function sendRouteTransaction(b, fallbackChainId) {
|
|
|
4914
4946
|
async function runTopUp(params) {
|
|
4915
4947
|
const w = walletManager.wallet;
|
|
4916
4948
|
if (!w) throw new Error("Trustware.wallet not configured");
|
|
4917
|
-
const {
|
|
4918
|
-
const
|
|
4919
|
-
const reg = new Registry2(apiBase2());
|
|
4949
|
+
const { getSharedRegistry: getSharedRegistry2 } = await Promise.resolve().then(() => (init_registryClient(), registryClient_exports));
|
|
4950
|
+
const reg = getSharedRegistry2();
|
|
4920
4951
|
await reg.ensureLoaded();
|
|
4921
4952
|
const fromAddress = await w.getAddress();
|
|
4922
4953
|
const currentChainRef = w.ecosystem === "evm" ? String(await w.getChainId()) : await w.getChainKey?.() ?? "solana-mainnet-beta";
|
|
@@ -4972,33 +5003,6 @@ var init_tx = __esm({
|
|
|
4972
5003
|
}
|
|
4973
5004
|
});
|
|
4974
5005
|
|
|
4975
|
-
// src/core/registryClient.ts
|
|
4976
|
-
function registryCacheKey() {
|
|
4977
|
-
const base2 = apiBase();
|
|
4978
|
-
const apiKey = TrustwareConfigStore.peek()?.apiKey ?? "__uninitialized__";
|
|
4979
|
-
return `${base2}::${apiKey}`;
|
|
4980
|
-
}
|
|
4981
|
-
function getSharedRegistry() {
|
|
4982
|
-
const key = registryCacheKey();
|
|
4983
|
-
const existing = registryCache.get(key);
|
|
4984
|
-
if (existing) {
|
|
4985
|
-
return existing;
|
|
4986
|
-
}
|
|
4987
|
-
const registry = new Registry(apiBase());
|
|
4988
|
-
registryCache.set(key, registry);
|
|
4989
|
-
return registry;
|
|
4990
|
-
}
|
|
4991
|
-
var registryCache;
|
|
4992
|
-
var init_registryClient = __esm({
|
|
4993
|
-
"src/core/registryClient.ts"() {
|
|
4994
|
-
"use strict";
|
|
4995
|
-
init_config2();
|
|
4996
|
-
init_registry();
|
|
4997
|
-
init_http();
|
|
4998
|
-
registryCache = /* @__PURE__ */ new Map();
|
|
4999
|
-
}
|
|
5000
|
-
});
|
|
5001
|
-
|
|
5002
5006
|
// src/widget/helpers/chainHelpers.ts
|
|
5003
5007
|
function normalizeChainKey2(id) {
|
|
5004
5008
|
if (id === void 0 || id === null) return "";
|
|
@@ -7203,6 +7207,39 @@ var init_core = __esm({
|
|
|
7203
7207
|
getConfig() {
|
|
7204
7208
|
return TrustwareConfigStore.get();
|
|
7205
7209
|
},
|
|
7210
|
+
/**
|
|
7211
|
+
* Read the SDK's currently configured theme mode.
|
|
7212
|
+
*
|
|
7213
|
+
* Returns the raw setting — `"light" | "dark" | "system"` — i.e. whatever
|
|
7214
|
+
* was last passed to `init()` or `setTheme()`. When the mode is `"system"`,
|
|
7215
|
+
* the widget resolves the actual light/dark appearance itself (from the OS
|
|
7216
|
+
* `prefers-color-scheme`, or a saved preference if the user has used the
|
|
7217
|
+
* widget's built-in theme toggle), so this getter still reports `"system"`
|
|
7218
|
+
* rather than the resolved value.
|
|
7219
|
+
*/
|
|
7220
|
+
getTheme() {
|
|
7221
|
+
return TrustwareConfigStore.get().theme;
|
|
7222
|
+
},
|
|
7223
|
+
/**
|
|
7224
|
+
* Set the widget's theme at runtime.
|
|
7225
|
+
*
|
|
7226
|
+
* Call this from your own app's theme toggle to keep an embedded
|
|
7227
|
+
* `TrustwareWidget` in sync with your UI — no remount required, any
|
|
7228
|
+
* mounted widget picks up the change immediately.
|
|
7229
|
+
*
|
|
7230
|
+
* Passing `"light"` or `"dark"` pins the widget to that mode. Passing
|
|
7231
|
+
* `"system"` makes it follow the OS preference again — unless the user
|
|
7232
|
+
* previously used the widget's own in-widget theme toggle, in which case
|
|
7233
|
+
* their saved choice takes precedence until they toggle it again.
|
|
7234
|
+
*
|
|
7235
|
+
* @example
|
|
7236
|
+
* // In your app's own dark-mode toggle handler:
|
|
7237
|
+
* Trustware.setTheme(isDark ? "dark" : "light");
|
|
7238
|
+
*/
|
|
7239
|
+
setTheme(theme) {
|
|
7240
|
+
TrustwareConfigStore.update({ theme });
|
|
7241
|
+
return Trustware;
|
|
7242
|
+
},
|
|
7206
7243
|
setDestinationAddress(address) {
|
|
7207
7244
|
const prev = TrustwareConfigStore.get();
|
|
7208
7245
|
TrustwareConfigStore.update({
|
|
@@ -7631,7 +7668,6 @@ function useTrustwareConfig() {
|
|
|
7631
7668
|
toToken: "",
|
|
7632
7669
|
toAddress: void 0,
|
|
7633
7670
|
defaultSlippage: 1,
|
|
7634
|
-
routeType: "swap",
|
|
7635
7671
|
options: {}
|
|
7636
7672
|
},
|
|
7637
7673
|
autoDetectProvider: false,
|
|
@@ -9323,8 +9359,8 @@ var init_theme = __esm({
|
|
|
9323
9359
|
--tw-accent-foreground: 0 0% 100%;
|
|
9324
9360
|
--tw-destructive: 0 84% 60%;
|
|
9325
9361
|
--tw-destructive-foreground: 0 0% 100%;
|
|
9326
|
-
--tw-border: 220 13%
|
|
9327
|
-
--tw-input: 220 13%
|
|
9362
|
+
--tw-border: 220 13% 94%;
|
|
9363
|
+
--tw-input: 220 13% 94%;
|
|
9328
9364
|
--tw-ring: 217 91% 60%;
|
|
9329
9365
|
--tw-radius: 1rem;
|
|
9330
9366
|
|
|
@@ -13759,7 +13795,7 @@ function ChainSelectorPanel({
|
|
|
13759
13795
|
paddingTop: spacing[2],
|
|
13760
13796
|
paddingBottom: spacing[2],
|
|
13761
13797
|
fontSize: fontSize.sm,
|
|
13762
|
-
backgroundColor: colors.
|
|
13798
|
+
backgroundColor: colors.background,
|
|
13763
13799
|
border: `1px solid ${colors.border}`,
|
|
13764
13800
|
borderRadius: borderRadius.lg,
|
|
13765
13801
|
color: colors.foreground,
|
|
@@ -13973,7 +14009,7 @@ function TokenSearchInput({
|
|
|
13973
14009
|
paddingTop: spacing[2],
|
|
13974
14010
|
paddingBottom: spacing[2],
|
|
13975
14011
|
fontSize: fontSize.sm,
|
|
13976
|
-
backgroundColor: colors.
|
|
14012
|
+
backgroundColor: colors.background,
|
|
13977
14013
|
border: `1px solid ${colors.border}`,
|
|
13978
14014
|
borderRadius: borderRadius.lg,
|
|
13979
14015
|
color: colors.foreground,
|
|
@@ -34336,8 +34372,13 @@ function SwapMode({
|
|
|
34336
34372
|
setStage("processing");
|
|
34337
34373
|
const fromTokenAddress = fromToken?.address ?? fromToken?.address;
|
|
34338
34374
|
const fromTokenDecimals = fromToken?.decimals ?? void 0;
|
|
34375
|
+
let routeToSend = route.data;
|
|
34376
|
+
if (isSerializedSolanaTxRequest(routeToSend.txReq) && latestFetchParamsRef.current) {
|
|
34377
|
+
const fresh = await route.fetch(latestFetchParamsRef.current);
|
|
34378
|
+
if (fresh) routeToSend = fresh;
|
|
34379
|
+
}
|
|
34339
34380
|
await execution.execute(
|
|
34340
|
-
|
|
34381
|
+
routeToSend,
|
|
34341
34382
|
fromTokenAddress,
|
|
34342
34383
|
fromTokenDecimals,
|
|
34343
34384
|
walletAddress ?? void 0,
|
|
@@ -34348,7 +34389,7 @@ function SwapMode({
|
|
|
34348
34389
|
},
|
|
34349
34390
|
() => setStage("error")
|
|
34350
34391
|
);
|
|
34351
|
-
}, [route
|
|
34392
|
+
}, [route, execution, fromToken, walletAddress, maxApproval]);
|
|
34352
34393
|
const handleReset = (0, import_react48.useCallback)(() => {
|
|
34353
34394
|
execution.reset();
|
|
34354
34395
|
route.clear();
|
|
@@ -38114,6 +38155,7 @@ var init_SwapMode = __esm({
|
|
|
38114
38155
|
init_mapError();
|
|
38115
38156
|
init_components();
|
|
38116
38157
|
init_registryClient();
|
|
38158
|
+
init_routes();
|
|
38117
38159
|
init_useThemePreference();
|
|
38118
38160
|
init_useWalletSessionState();
|
|
38119
38161
|
init_useWalletTokenState();
|