@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.cjs CHANGED
@@ -266,8 +266,8 @@ var init_theme = __esm({
266
266
  --tw-accent-foreground: 0 0% 100%;
267
267
  --tw-destructive: 0 84% 60%;
268
268
  --tw-destructive-foreground: 0 0% 100%;
269
- --tw-border: 220 13% 91%;
270
- --tw-input: 220 13% 91%;
269
+ --tw-border: 220 13% 94%;
270
+ --tw-input: 220 13% 94%;
271
271
  --tw-ring: 217 91% 60%;
272
272
  --tw-radius: 1rem;
273
273
 
@@ -585,7 +585,7 @@ var init_constants = __esm({
585
585
  "src/constants.ts"() {
586
586
  "use strict";
587
587
  SDK_NAME = "@trustware/sdk";
588
- SDK_VERSION = "1.1.8-staging.8";
588
+ SDK_VERSION = "1.1.9-staging.1";
589
589
  API_ROOT = "https://bv-staging-api.trustware.io";
590
590
  GTM_ID = "GTM-TZDGNCXB";
591
591
  API_PREFIX = "/api";
@@ -605,16 +605,6 @@ var init_config2 = __esm({
605
605
  });
606
606
 
607
607
  // src/core/http.ts
608
- var http_exports = {};
609
- __export(http_exports, {
610
- RateLimitError: () => RateLimitError,
611
- apiBase: () => apiBase,
612
- assertOK: () => assertOK,
613
- jsonHeaders: () => jsonHeaders,
614
- parseRateLimitHeaders: () => parseRateLimitHeaders,
615
- rateLimitedFetch: () => rateLimitedFetch,
616
- validateSdkAccess: () => validateSdkAccess
617
- });
618
608
  function apiBase() {
619
609
  return `${API_ROOT}${API_PREFIX}`;
620
610
  }
@@ -812,11 +802,6 @@ var init_chains = __esm({
812
802
  });
813
803
 
814
804
  // src/registry.ts
815
- var registry_exports = {};
816
- __export(registry_exports, {
817
- NATIVE: () => NATIVE,
818
- Registry: () => Registry
819
- });
820
805
  function getChainAliases(chain) {
821
806
  const values = [
822
807
  chain.chainId,
@@ -2350,7 +2335,7 @@ async function parseStreamingBalances(response, address, options = {}) {
2350
2335
  }
2351
2336
  return stream();
2352
2337
  }
2353
- async function getBalances(chainRef, address) {
2338
+ async function getBalances(chainRef, address, opts) {
2354
2339
  const reg = await ensureRegistry();
2355
2340
  const chain = reg.chain(chainRef);
2356
2341
  if (!chain) return [];
@@ -2365,8 +2350,10 @@ async function getBalances(chainRef, address) {
2365
2350
  chain.nativeCurrency?.decimals ?? "",
2366
2351
  normalizeChainType(chain) ?? ""
2367
2352
  ].join(":");
2368
- const cached = balanceCache.get(cacheKey);
2369
- if (cached) return cached;
2353
+ if (!opts?.forceRefresh) {
2354
+ const cached = balanceCache.get(cacheKey);
2355
+ if (cached) return cached;
2356
+ }
2370
2357
  const url = `${apiBase()}/v1/data/wallets/${encodeURIComponent(chainKey)}/${trimmedAddress}/balances`;
2371
2358
  const response = await fetch(url, {
2372
2359
  method: "GET",
@@ -2873,7 +2860,6 @@ function useTrustwareConfig() {
2873
2860
  toToken: "",
2874
2861
  toAddress: void 0,
2875
2862
  defaultSlippage: 1,
2876
- routeType: "swap",
2877
2863
  options: {}
2878
2864
  },
2879
2865
  autoDetectProvider: false,
@@ -2986,6 +2972,10 @@ var init_useAmountConstraints = __esm({
2986
2972
  });
2987
2973
 
2988
2974
  // src/core/registryClient.ts
2975
+ var registryClient_exports = {};
2976
+ __export(registryClient_exports, {
2977
+ getSharedRegistry: () => getSharedRegistry
2978
+ });
2989
2979
  function registryCacheKey() {
2990
2980
  const base2 = apiBase();
2991
2981
  const apiKey = TrustwareConfigStore.peek()?.apiKey ?? "__uninitialized__";
@@ -6116,11 +6106,27 @@ function toSolanaWalletInterface(provider) {
6116
6106
  serializedTransactionBase64
6117
6107
  );
6118
6108
  if (provider.signAndSendTransaction) {
6119
- const result = await provider.signAndSendTransaction(transaction, {
6120
- preflightCommitment: "confirmed"
6121
- });
6122
- if (typeof result === "string") return result;
6123
- if (result?.signature) return result.signature;
6109
+ const MAX_INTERNAL_ERROR_ATTEMPTS = 3;
6110
+ const INTERNAL_ERROR_RETRY_DELAY_MS = 500;
6111
+ for (let attempt = 1; attempt <= MAX_INTERNAL_ERROR_ATTEMPTS; attempt++) {
6112
+ try {
6113
+ const result = await provider.signAndSendTransaction(transaction, {
6114
+ skipPreflight: true
6115
+ });
6116
+ if (typeof result === "string") return result;
6117
+ if (result?.signature) return result.signature;
6118
+ break;
6119
+ } catch (err) {
6120
+ const code = err?.code;
6121
+ if (code === -32603 && attempt < MAX_INTERNAL_ERROR_ATTEMPTS) {
6122
+ await new Promise(
6123
+ (resolve) => setTimeout(resolve, INTERNAL_ERROR_RETRY_DELAY_MS * attempt)
6124
+ );
6125
+ continue;
6126
+ }
6127
+ throw err;
6128
+ }
6129
+ }
6124
6130
  }
6125
6131
  if (!provider.signTransaction) {
6126
6132
  throw new Error("Connected Solana wallet cannot sign transactions");
@@ -8595,7 +8601,6 @@ function resolveConfig(input) {
8595
8601
  defaultSlippage: normalizeSlippage(
8596
8602
  input.routes.defaultSlippage ?? DEFAULT_SLIPPAGE
8597
8603
  ),
8598
- routeType: input.routes.routeType ?? "swap",
8599
8604
  options: {
8600
8605
  ...input.routes.options
8601
8606
  }
@@ -8795,10 +8800,9 @@ async function sendRouteTransaction(b, fallbackChainId) {
8795
8800
  if (w.ecosystem !== "solana") {
8796
8801
  throw new Error("A Solana wallet is required for this route");
8797
8802
  }
8798
- const { Registry: Registry2 } = await Promise.resolve().then(() => (init_registry(), registry_exports));
8799
- const { apiBase: apiBase2 } = await Promise.resolve().then(() => (init_http(), http_exports));
8800
- const registry = new Registry2(apiBase2());
8801
- await registry.ensureLoaded();
8803
+ const { getSharedRegistry: getSharedRegistry2 } = await Promise.resolve().then(() => (init_registryClient(), registryClient_exports));
8804
+ const registry = getSharedRegistry2();
8805
+ await registry.ensureChainsLoaded();
8802
8806
  const chain = registry.chain(
8803
8807
  String(fallbackChainId ?? txReq.chainId ?? "")
8804
8808
  );
@@ -8812,9 +8816,8 @@ async function sendRouteTransaction(b, fallbackChainId) {
8812
8816
  async function runTopUp(params) {
8813
8817
  const w = walletManager.wallet;
8814
8818
  if (!w) throw new Error("Trustware.wallet not configured");
8815
- const { Registry: Registry2 } = await Promise.resolve().then(() => (init_registry(), registry_exports));
8816
- const { apiBase: apiBase2 } = await Promise.resolve().then(() => (init_http(), http_exports));
8817
- const reg = new Registry2(apiBase2());
8819
+ const { getSharedRegistry: getSharedRegistry2 } = await Promise.resolve().then(() => (init_registryClient(), registryClient_exports));
8820
+ const reg = getSharedRegistry2();
8818
8821
  await reg.ensureLoaded();
8819
8822
  const fromAddress = await w.getAddress();
8820
8823
  const currentChainRef = w.ecosystem === "evm" ? String(await w.getChainId()) : await w.getChainKey?.() ?? "solana-mainnet-beta";
@@ -8925,6 +8928,39 @@ var init_core = __esm({
8925
8928
  getConfig() {
8926
8929
  return TrustwareConfigStore.get();
8927
8930
  },
8931
+ /**
8932
+ * Read the SDK's currently configured theme mode.
8933
+ *
8934
+ * Returns the raw setting — `"light" | "dark" | "system"` — i.e. whatever
8935
+ * was last passed to `init()` or `setTheme()`. When the mode is `"system"`,
8936
+ * the widget resolves the actual light/dark appearance itself (from the OS
8937
+ * `prefers-color-scheme`, or a saved preference if the user has used the
8938
+ * widget's built-in theme toggle), so this getter still reports `"system"`
8939
+ * rather than the resolved value.
8940
+ */
8941
+ getTheme() {
8942
+ return TrustwareConfigStore.get().theme;
8943
+ },
8944
+ /**
8945
+ * Set the widget's theme at runtime.
8946
+ *
8947
+ * Call this from your own app's theme toggle to keep an embedded
8948
+ * `TrustwareWidget` in sync with your UI — no remount required, any
8949
+ * mounted widget picks up the change immediately.
8950
+ *
8951
+ * Passing `"light"` or `"dark"` pins the widget to that mode. Passing
8952
+ * `"system"` makes it follow the OS preference again — unless the user
8953
+ * previously used the widget's own in-widget theme toggle, in which case
8954
+ * their saved choice takes precedence until they toggle it again.
8955
+ *
8956
+ * @example
8957
+ * // In your app's own dark-mode toggle handler:
8958
+ * Trustware.setTheme(isDark ? "dark" : "light");
8959
+ */
8960
+ setTheme(theme) {
8961
+ TrustwareConfigStore.update({ theme });
8962
+ return Trustware;
8963
+ },
8928
8964
  setDestinationAddress(address) {
8929
8965
  const prev = TrustwareConfigStore.get();
8930
8966
  TrustwareConfigStore.update({
@@ -13630,7 +13666,7 @@ function ChainSelectorPanel({
13630
13666
  paddingTop: spacing[2],
13631
13667
  paddingBottom: spacing[2],
13632
13668
  fontSize: fontSize.sm,
13633
- backgroundColor: colors.muted,
13669
+ backgroundColor: colors.background,
13634
13670
  border: `1px solid ${colors.border}`,
13635
13671
  borderRadius: borderRadius.lg,
13636
13672
  color: colors.foreground,
@@ -13844,7 +13880,7 @@ function TokenSearchInput({
13844
13880
  paddingTop: spacing[2],
13845
13881
  paddingBottom: spacing[2],
13846
13882
  fontSize: fontSize.sm,
13847
- backgroundColor: colors.muted,
13883
+ backgroundColor: colors.background,
13848
13884
  border: `1px solid ${colors.border}`,
13849
13885
  borderRadius: borderRadius.lg,
13850
13886
  color: colors.foreground,
@@ -34207,8 +34243,13 @@ function SwapMode({
34207
34243
  setStage("processing");
34208
34244
  const fromTokenAddress = fromToken?.address ?? fromToken?.address;
34209
34245
  const fromTokenDecimals = fromToken?.decimals ?? void 0;
34246
+ let routeToSend = route.data;
34247
+ if (isSerializedSolanaTxRequest(routeToSend.txReq) && latestFetchParamsRef.current) {
34248
+ const fresh = await route.fetch(latestFetchParamsRef.current);
34249
+ if (fresh) routeToSend = fresh;
34250
+ }
34210
34251
  await execution.execute(
34211
- route.data,
34252
+ routeToSend,
34212
34253
  fromTokenAddress,
34213
34254
  fromTokenDecimals,
34214
34255
  walletAddress ?? void 0,
@@ -34219,7 +34260,7 @@ function SwapMode({
34219
34260
  },
34220
34261
  () => setStage("error")
34221
34262
  );
34222
- }, [route.data, execution, fromToken, walletAddress, maxApproval]);
34263
+ }, [route, execution, fromToken, walletAddress, maxApproval]);
34223
34264
  const handleReset = (0, import_react48.useCallback)(() => {
34224
34265
  execution.reset();
34225
34266
  route.clear();
@@ -37985,6 +38026,7 @@ var init_SwapMode = __esm({
37985
38026
  init_mapError();
37986
38027
  init_components();
37987
38028
  init_registryClient();
38029
+ init_routes();
37988
38030
  init_useThemePreference();
37989
38031
  init_useWalletSessionState();
37990
38032
  init_useWalletTokenState();