@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.
Files changed (42) hide show
  1. package/README.md +0 -2
  2. package/dist/{blockchain-BONedEsU.d.cts → blockchain-BxAFzp0s.d.cts} +5 -1
  3. package/dist/{blockchain-BONedEsU.d.ts → blockchain-BxAFzp0s.d.ts} +5 -1
  4. package/dist/constants.cjs +1 -1
  5. package/dist/constants.mjs +1 -1
  6. package/dist/{core-BjQwlpoI.d.cts → core-D_jx805U.d.cts} +32 -4
  7. package/dist/{core-BQ0mFnLc.d.ts → core-p_5BLdbE.d.ts} +32 -4
  8. package/dist/core.cjs +69 -32
  9. package/dist/core.cjs.map +1 -1
  10. package/dist/core.d.cts +4 -4
  11. package/dist/core.d.ts +4 -4
  12. package/dist/core.mjs +69 -32
  13. package/dist/core.mjs.map +1 -1
  14. package/dist/{detect-DlbgTrkm.d.cts → detect--pmNlAHv.d.cts} +1 -1
  15. package/dist/{detect-MWKHLhn9.d.ts → detect-qAX6I4JI.d.ts} +1 -1
  16. package/dist/index.cjs +108 -66
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +8 -8
  19. package/dist/index.d.ts +8 -8
  20. package/dist/index.mjs +108 -66
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/{manager-aOd3vkF9.d.ts → manager-DFQkemW0.d.ts} +1 -3
  23. package/dist/{manager-DKVW7zeh.d.cts → manager-aMi4_Ss6.d.cts} +1 -3
  24. package/dist/smart-account.cjs +1 -2
  25. package/dist/smart-account.cjs.map +1 -1
  26. package/dist/smart-account.mjs +1 -2
  27. package/dist/smart-account.mjs.map +1 -1
  28. package/dist/{types-MtdjJgwT.d.ts → types-BJY9r-mz.d.ts} +1 -1
  29. package/dist/{types-B3nKHW6H.d.cts → types-DX3HtFcn.d.cts} +1 -1
  30. package/dist/wallet.cjs +22 -7
  31. package/dist/wallet.cjs.map +1 -1
  32. package/dist/wallet.d.cts +4 -4
  33. package/dist/wallet.d.ts +4 -4
  34. package/dist/wallet.mjs +22 -7
  35. package/dist/wallet.mjs.map +1 -1
  36. package/dist/widget.cjs +81 -39
  37. package/dist/widget.cjs.map +1 -1
  38. package/dist/widget.d.cts +2 -2
  39. package/dist/widget.d.ts +2 -2
  40. package/dist/widget.mjs +81 -39
  41. package/dist/widget.mjs.map +1 -1
  42. package/package.json +1 -1
package/dist/widget.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React__default from 'react';
2
- import { N as NavigationStep } from './types-B3nKHW6H.cjs';
3
- import './blockchain-BONedEsU.cjs';
2
+ import { N as NavigationStep } from './types-DX3HtFcn.cjs';
3
+ import './blockchain-BxAFzp0s.cjs';
4
4
 
5
5
  type Theme = "light" | "dark" | "system";
6
6
 
package/dist/widget.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React__default from 'react';
2
- import { N as NavigationStep } from './types-MtdjJgwT.js';
3
- import './blockchain-BONedEsU.js';
2
+ import { N as NavigationStep } from './types-BJY9r-mz.js';
3
+ import './blockchain-BxAFzp0s.js';
4
4
 
5
5
  type Theme = "light" | "dark" | "system";
6
6
 
package/dist/widget.mjs CHANGED
@@ -244,8 +244,8 @@ var init_theme = __esm({
244
244
  --tw-accent-foreground: 0 0% 100%;
245
245
  --tw-destructive: 0 84% 60%;
246
246
  --tw-destructive-foreground: 0 0% 100%;
247
- --tw-border: 220 13% 91%;
248
- --tw-input: 220 13% 91%;
247
+ --tw-border: 220 13% 94%;
248
+ --tw-input: 220 13% 94%;
249
249
  --tw-ring: 217 91% 60%;
250
250
  --tw-radius: 1rem;
251
251
 
@@ -563,7 +563,7 @@ var init_constants = __esm({
563
563
  "src/constants.ts"() {
564
564
  "use strict";
565
565
  SDK_NAME = "@trustware/sdk";
566
- SDK_VERSION = "1.1.8-staging.8";
566
+ SDK_VERSION = "1.1.9-staging.1";
567
567
  API_ROOT = "https://bv-staging-api.trustware.io";
568
568
  GTM_ID = "GTM-TZDGNCXB";
569
569
  API_PREFIX = "/api";
@@ -583,16 +583,6 @@ var init_config2 = __esm({
583
583
  });
584
584
 
585
585
  // src/core/http.ts
586
- var http_exports = {};
587
- __export(http_exports, {
588
- RateLimitError: () => RateLimitError,
589
- apiBase: () => apiBase,
590
- assertOK: () => assertOK,
591
- jsonHeaders: () => jsonHeaders,
592
- parseRateLimitHeaders: () => parseRateLimitHeaders,
593
- rateLimitedFetch: () => rateLimitedFetch,
594
- validateSdkAccess: () => validateSdkAccess
595
- });
596
586
  function apiBase() {
597
587
  return `${API_ROOT}${API_PREFIX}`;
598
588
  }
@@ -790,11 +780,6 @@ var init_chains = __esm({
790
780
  });
791
781
 
792
782
  // src/registry.ts
793
- var registry_exports = {};
794
- __export(registry_exports, {
795
- NATIVE: () => NATIVE,
796
- Registry: () => Registry
797
- });
798
783
  function getChainAliases(chain) {
799
784
  const values = [
800
785
  chain.chainId,
@@ -2328,7 +2313,7 @@ async function parseStreamingBalances(response, address, options = {}) {
2328
2313
  }
2329
2314
  return stream();
2330
2315
  }
2331
- async function getBalances(chainRef, address) {
2316
+ async function getBalances(chainRef, address, opts) {
2332
2317
  const reg = await ensureRegistry();
2333
2318
  const chain = reg.chain(chainRef);
2334
2319
  if (!chain) return [];
@@ -2343,8 +2328,10 @@ async function getBalances(chainRef, address) {
2343
2328
  chain.nativeCurrency?.decimals ?? "",
2344
2329
  normalizeChainType(chain) ?? ""
2345
2330
  ].join(":");
2346
- const cached = balanceCache.get(cacheKey);
2347
- if (cached) return cached;
2331
+ if (!opts?.forceRefresh) {
2332
+ const cached = balanceCache.get(cacheKey);
2333
+ if (cached) return cached;
2334
+ }
2348
2335
  const url = `${apiBase()}/v1/data/wallets/${encodeURIComponent(chainKey)}/${trimmedAddress}/balances`;
2349
2336
  const response = await fetch(url, {
2350
2337
  method: "GET",
@@ -2851,7 +2838,6 @@ function useTrustwareConfig() {
2851
2838
  toToken: "",
2852
2839
  toAddress: void 0,
2853
2840
  defaultSlippage: 1,
2854
- routeType: "swap",
2855
2841
  options: {}
2856
2842
  },
2857
2843
  autoDetectProvider: false,
@@ -2961,6 +2947,10 @@ var init_useAmountConstraints = __esm({
2961
2947
  });
2962
2948
 
2963
2949
  // src/core/registryClient.ts
2950
+ var registryClient_exports = {};
2951
+ __export(registryClient_exports, {
2952
+ getSharedRegistry: () => getSharedRegistry
2953
+ });
2964
2954
  function registryCacheKey() {
2965
2955
  const base2 = apiBase();
2966
2956
  const apiKey = TrustwareConfigStore.peek()?.apiKey ?? "__uninitialized__";
@@ -6089,11 +6079,27 @@ function toSolanaWalletInterface(provider) {
6089
6079
  serializedTransactionBase64
6090
6080
  );
6091
6081
  if (provider.signAndSendTransaction) {
6092
- const result = await provider.signAndSendTransaction(transaction, {
6093
- preflightCommitment: "confirmed"
6094
- });
6095
- if (typeof result === "string") return result;
6096
- if (result?.signature) return result.signature;
6082
+ const MAX_INTERNAL_ERROR_ATTEMPTS = 3;
6083
+ const INTERNAL_ERROR_RETRY_DELAY_MS = 500;
6084
+ for (let attempt = 1; attempt <= MAX_INTERNAL_ERROR_ATTEMPTS; attempt++) {
6085
+ try {
6086
+ const result = await provider.signAndSendTransaction(transaction, {
6087
+ skipPreflight: true
6088
+ });
6089
+ if (typeof result === "string") return result;
6090
+ if (result?.signature) return result.signature;
6091
+ break;
6092
+ } catch (err) {
6093
+ const code = err?.code;
6094
+ if (code === -32603 && attempt < MAX_INTERNAL_ERROR_ATTEMPTS) {
6095
+ await new Promise(
6096
+ (resolve) => setTimeout(resolve, INTERNAL_ERROR_RETRY_DELAY_MS * attempt)
6097
+ );
6098
+ continue;
6099
+ }
6100
+ throw err;
6101
+ }
6102
+ }
6097
6103
  }
6098
6104
  if (!provider.signTransaction) {
6099
6105
  throw new Error("Connected Solana wallet cannot sign transactions");
@@ -8567,7 +8573,6 @@ function resolveConfig(input) {
8567
8573
  defaultSlippage: normalizeSlippage(
8568
8574
  input.routes.defaultSlippage ?? DEFAULT_SLIPPAGE
8569
8575
  ),
8570
- routeType: input.routes.routeType ?? "swap",
8571
8576
  options: {
8572
8577
  ...input.routes.options
8573
8578
  }
@@ -8768,10 +8773,9 @@ async function sendRouteTransaction(b, fallbackChainId) {
8768
8773
  if (w.ecosystem !== "solana") {
8769
8774
  throw new Error("A Solana wallet is required for this route");
8770
8775
  }
8771
- const { Registry: Registry2 } = await Promise.resolve().then(() => (init_registry(), registry_exports));
8772
- const { apiBase: apiBase2 } = await Promise.resolve().then(() => (init_http(), http_exports));
8773
- const registry = new Registry2(apiBase2());
8774
- await registry.ensureLoaded();
8776
+ const { getSharedRegistry: getSharedRegistry2 } = await Promise.resolve().then(() => (init_registryClient(), registryClient_exports));
8777
+ const registry = getSharedRegistry2();
8778
+ await registry.ensureChainsLoaded();
8775
8779
  const chain = registry.chain(
8776
8780
  String(fallbackChainId ?? txReq.chainId ?? "")
8777
8781
  );
@@ -8785,9 +8789,8 @@ async function sendRouteTransaction(b, fallbackChainId) {
8785
8789
  async function runTopUp(params) {
8786
8790
  const w = walletManager.wallet;
8787
8791
  if (!w) throw new Error("Trustware.wallet not configured");
8788
- const { Registry: Registry2 } = await Promise.resolve().then(() => (init_registry(), registry_exports));
8789
- const { apiBase: apiBase2 } = await Promise.resolve().then(() => (init_http(), http_exports));
8790
- const reg = new Registry2(apiBase2());
8792
+ const { getSharedRegistry: getSharedRegistry2 } = await Promise.resolve().then(() => (init_registryClient(), registryClient_exports));
8793
+ const reg = getSharedRegistry2();
8791
8794
  await reg.ensureLoaded();
8792
8795
  const fromAddress = await w.getAddress();
8793
8796
  const currentChainRef = w.ecosystem === "evm" ? String(await w.getChainId()) : await w.getChainKey?.() ?? "solana-mainnet-beta";
@@ -8896,6 +8899,39 @@ var init_core = __esm({
8896
8899
  getConfig() {
8897
8900
  return TrustwareConfigStore.get();
8898
8901
  },
8902
+ /**
8903
+ * Read the SDK's currently configured theme mode.
8904
+ *
8905
+ * Returns the raw setting — `"light" | "dark" | "system"` — i.e. whatever
8906
+ * was last passed to `init()` or `setTheme()`. When the mode is `"system"`,
8907
+ * the widget resolves the actual light/dark appearance itself (from the OS
8908
+ * `prefers-color-scheme`, or a saved preference if the user has used the
8909
+ * widget's built-in theme toggle), so this getter still reports `"system"`
8910
+ * rather than the resolved value.
8911
+ */
8912
+ getTheme() {
8913
+ return TrustwareConfigStore.get().theme;
8914
+ },
8915
+ /**
8916
+ * Set the widget's theme at runtime.
8917
+ *
8918
+ * Call this from your own app's theme toggle to keep an embedded
8919
+ * `TrustwareWidget` in sync with your UI — no remount required, any
8920
+ * mounted widget picks up the change immediately.
8921
+ *
8922
+ * Passing `"light"` or `"dark"` pins the widget to that mode. Passing
8923
+ * `"system"` makes it follow the OS preference again — unless the user
8924
+ * previously used the widget's own in-widget theme toggle, in which case
8925
+ * their saved choice takes precedence until they toggle it again.
8926
+ *
8927
+ * @example
8928
+ * // In your app's own dark-mode toggle handler:
8929
+ * Trustware.setTheme(isDark ? "dark" : "light");
8930
+ */
8931
+ setTheme(theme) {
8932
+ TrustwareConfigStore.update({ theme });
8933
+ return Trustware;
8934
+ },
8899
8935
  setDestinationAddress(address) {
8900
8936
  const prev = TrustwareConfigStore.get();
8901
8937
  TrustwareConfigStore.update({
@@ -13602,7 +13638,7 @@ function ChainSelectorPanel({
13602
13638
  paddingTop: spacing[2],
13603
13639
  paddingBottom: spacing[2],
13604
13640
  fontSize: fontSize.sm,
13605
- backgroundColor: colors.muted,
13641
+ backgroundColor: colors.background,
13606
13642
  border: `1px solid ${colors.border}`,
13607
13643
  borderRadius: borderRadius.lg,
13608
13644
  color: colors.foreground,
@@ -13814,7 +13850,7 @@ function TokenSearchInput({
13814
13850
  paddingTop: spacing[2],
13815
13851
  paddingBottom: spacing[2],
13816
13852
  fontSize: fontSize.sm,
13817
- backgroundColor: colors.muted,
13853
+ backgroundColor: colors.background,
13818
13854
  border: `1px solid ${colors.border}`,
13819
13855
  borderRadius: borderRadius.lg,
13820
13856
  color: colors.foreground,
@@ -34153,8 +34189,13 @@ function SwapMode({
34153
34189
  setStage("processing");
34154
34190
  const fromTokenAddress = fromToken?.address ?? fromToken?.address;
34155
34191
  const fromTokenDecimals = fromToken?.decimals ?? void 0;
34192
+ let routeToSend = route.data;
34193
+ if (isSerializedSolanaTxRequest(routeToSend.txReq) && latestFetchParamsRef.current) {
34194
+ const fresh = await route.fetch(latestFetchParamsRef.current);
34195
+ if (fresh) routeToSend = fresh;
34196
+ }
34156
34197
  await execution.execute(
34157
- route.data,
34198
+ routeToSend,
34158
34199
  fromTokenAddress,
34159
34200
  fromTokenDecimals,
34160
34201
  walletAddress ?? void 0,
@@ -34165,7 +34206,7 @@ function SwapMode({
34165
34206
  },
34166
34207
  () => setStage("error")
34167
34208
  );
34168
- }, [route.data, execution, fromToken, walletAddress, maxApproval]);
34209
+ }, [route, execution, fromToken, walletAddress, maxApproval]);
34169
34210
  const handleReset = useCallback22(() => {
34170
34211
  execution.reset();
34171
34212
  route.clear();
@@ -37929,6 +37970,7 @@ var init_SwapMode = __esm({
37929
37970
  init_mapError();
37930
37971
  init_components();
37931
37972
  init_registryClient();
37973
+ init_routes();
37932
37974
  init_useThemePreference();
37933
37975
  init_useWalletSessionState();
37934
37976
  init_useWalletTokenState();