@unifold/connect-react 0.1.61 → 0.1.62

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/index.js CHANGED
@@ -7382,7 +7382,7 @@ var React102 = __toESM(require("react"), 1);
7382
7382
  var import_jsx_runtime38 = require("react/jsx-runtime");
7383
7383
  var React112 = __toESM(require("react"), 1);
7384
7384
  var import_jsx_runtime39 = require("react/jsx-runtime");
7385
- var React242 = __toESM(require("react"), 1);
7385
+ var React252 = __toESM(require("react"), 1);
7386
7386
 
7387
7387
  // ../../node_modules/.pnpm/mipd@0.0.7_typescript@5.9.3/node_modules/mipd/dist/esm/utils.js
7388
7388
  function requestProviders(listener) {
@@ -7440,28 +7440,29 @@ function createStore() {
7440
7440
 
7441
7441
  // ../ui-react/dist/index.mjs
7442
7442
  var React122 = __toESM(require("react"), 1);
7443
- var import_jsx_runtime40 = require("react/jsx-runtime");
7444
7443
  var React132 = __toESM(require("react"), 1);
7445
- var import_jsx_runtime41 = require("react/jsx-runtime");
7444
+ var import_jsx_runtime40 = require("react/jsx-runtime");
7446
7445
  var React142 = __toESM(require("react"), 1);
7447
- var import_jsx_runtime42 = require("react/jsx-runtime");
7446
+ var import_jsx_runtime41 = require("react/jsx-runtime");
7448
7447
  var React152 = __toESM(require("react"), 1);
7449
- var import_jsx_runtime43 = require("react/jsx-runtime");
7448
+ var import_jsx_runtime42 = require("react/jsx-runtime");
7450
7449
  var React162 = __toESM(require("react"), 1);
7451
- var import_jsx_runtime44 = require("react/jsx-runtime");
7450
+ var import_jsx_runtime43 = require("react/jsx-runtime");
7452
7451
  var React172 = __toESM(require("react"), 1);
7453
- var import_jsx_runtime45 = require("react/jsx-runtime");
7452
+ var import_jsx_runtime44 = require("react/jsx-runtime");
7454
7453
  var React182 = __toESM(require("react"), 1);
7455
- var import_jsx_runtime46 = require("react/jsx-runtime");
7454
+ var import_jsx_runtime45 = require("react/jsx-runtime");
7456
7455
  var React192 = __toESM(require("react"), 1);
7457
- var import_jsx_runtime47 = require("react/jsx-runtime");
7456
+ var import_jsx_runtime46 = require("react/jsx-runtime");
7458
7457
  var React202 = __toESM(require("react"), 1);
7459
- var import_jsx_runtime48 = require("react/jsx-runtime");
7458
+ var import_jsx_runtime47 = require("react/jsx-runtime");
7460
7459
  var React212 = __toESM(require("react"), 1);
7461
- var import_jsx_runtime49 = require("react/jsx-runtime");
7460
+ var import_jsx_runtime48 = require("react/jsx-runtime");
7462
7461
  var React222 = __toESM(require("react"), 1);
7463
- var import_jsx_runtime50 = require("react/jsx-runtime");
7462
+ var import_jsx_runtime49 = require("react/jsx-runtime");
7464
7463
  var React232 = __toESM(require("react"), 1);
7464
+ var import_jsx_runtime50 = require("react/jsx-runtime");
7465
+ var React242 = __toESM(require("react"), 1);
7465
7466
  var import_jsx_runtime51 = require("react/jsx-runtime");
7466
7467
  var import_jsx_runtime52 = require("react/jsx-runtime");
7467
7468
  var import_jsx_runtime53 = require("react/jsx-runtime");
@@ -7476,7 +7477,7 @@ var import_react_query11 = require("@tanstack/react-query");
7476
7477
  var import_react_query12 = require("@tanstack/react-query");
7477
7478
  var import_react21 = require("react");
7478
7479
  var import_react22 = require("react");
7479
- var React262 = __toESM(require("react"), 1);
7480
+ var React272 = __toESM(require("react"), 1);
7480
7481
  var import_jsx_runtime55 = require("react/jsx-runtime");
7481
7482
  var import_jsx_runtime56 = require("react/jsx-runtime");
7482
7483
  var import_jsx_runtime57 = require("react/jsx-runtime");
@@ -9486,7 +9487,7 @@ var import_react24 = require("react");
9486
9487
  var import_jsx_runtime59 = require("react/jsx-runtime");
9487
9488
  var import_jsx_runtime60 = require("react/jsx-runtime");
9488
9489
  var import_react25 = require("react");
9489
- var React272 = __toESM(require("react"), 1);
9490
+ var React282 = __toESM(require("react"), 1);
9490
9491
 
9491
9492
  // ../../node_modules/.pnpm/@radix-ui+react-tooltip@1.2.8_@types+react-dom@19.2.3_@types+react@19.2.9__@types+react@19.2._udyjcec5g7ve3mpsxbgla63vgi/node_modules/@radix-ui/react-tooltip/dist/index.mjs
9492
9493
  var React31 = __toESM(require("react"), 1);
@@ -12228,7 +12229,7 @@ var import_react_query13 = require("@tanstack/react-query");
12228
12229
  var import_jsx_runtime62 = require("react/jsx-runtime");
12229
12230
  var import_jsx_runtime63 = require("react/jsx-runtime");
12230
12231
  var import_react26 = require("react");
12231
- var React282 = __toESM(require("react"), 1);
12232
+ var React292 = __toESM(require("react"), 1);
12232
12233
 
12233
12234
  // ../../node_modules/.pnpm/@radix-ui+react-select@2.2.6_@types+react-dom@19.2.3_@types+react@19.2.9__@types+react@19.2.9_cot3leusltbsophitaz3dgdqdm/node_modules/@radix-ui/react-select/dist/index.mjs
12234
12235
  var React35 = __toESM(require("react"), 1);
@@ -13465,7 +13466,7 @@ var Separator = SelectSeparator;
13465
13466
  // ../ui-react/dist/index.mjs
13466
13467
  var import_jsx_runtime64 = require("react/jsx-runtime");
13467
13468
  var import_jsx_runtime65 = require("react/jsx-runtime");
13468
- var React292 = __toESM(require("react"), 1);
13469
+ var React302 = __toESM(require("react"), 1);
13469
13470
  var import_react_query14 = require("@tanstack/react-query");
13470
13471
  var import_jsx_runtime66 = require("react/jsx-runtime");
13471
13472
  var import_jsx_runtime67 = require("react/jsx-runtime");
@@ -18577,6 +18578,190 @@ function collectAllEip6963EthProviders() {
18577
18578
  if (!store) return [];
18578
18579
  return store.getProviders().map((d) => d.provider);
18579
18580
  }
18581
+ function identifyEthWallet(provider, hint) {
18582
+ switch (hint) {
18583
+ case "metamask":
18584
+ return { type: "metamask", name: "MetaMask", icon: "metamask" };
18585
+ case "phantom":
18586
+ return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
18587
+ case "coinbase":
18588
+ return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
18589
+ case "okx":
18590
+ return { type: "okx", name: "OKX Wallet", icon: "okx" };
18591
+ case "rabby":
18592
+ return { type: "rabby", name: "Rabby", icon: "rabby" };
18593
+ case "trust":
18594
+ return { type: "trust", name: "Trust Wallet", icon: "trust" };
18595
+ case "rainbow":
18596
+ return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
18597
+ }
18598
+ const anyProvider = provider;
18599
+ if (provider.isPhantom) {
18600
+ return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
18601
+ }
18602
+ if (anyProvider.isCoinbaseWallet) {
18603
+ return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
18604
+ }
18605
+ if (anyProvider.isRabby) {
18606
+ return { type: "rabby", name: "Rabby", icon: "rabby" };
18607
+ }
18608
+ if (anyProvider.isTrust) {
18609
+ return { type: "trust", name: "Trust Wallet", icon: "trust" };
18610
+ }
18611
+ if (anyProvider.isRainbow) {
18612
+ return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
18613
+ }
18614
+ if (provider.isMetaMask && !provider.isPhantom) {
18615
+ return { type: "metamask", name: "MetaMask", icon: "metamask" };
18616
+ }
18617
+ return { type: "metamask", name: "Wallet", icon: "metamask" };
18618
+ }
18619
+ async function detectConnectedBrowserWallet(chainType) {
18620
+ if (typeof window === "undefined") return null;
18621
+ if (getUserDisconnectedWallet()) return null;
18622
+ try {
18623
+ const win = window;
18624
+ if (!chainType || chainType === "solana") {
18625
+ const trySilentSolana = async (provider, type, name, icon) => {
18626
+ if (!provider) return null;
18627
+ if (provider.isConnected && provider.publicKey) {
18628
+ return { type, name, address: provider.publicKey.toString(), icon };
18629
+ }
18630
+ try {
18631
+ const resp = await provider.connect({ onlyIfTrusted: true });
18632
+ if (resp.publicKey) {
18633
+ return { type, name, address: resp.publicKey.toString(), icon };
18634
+ }
18635
+ } catch {
18636
+ }
18637
+ return null;
18638
+ };
18639
+ const solanaCandidates = [
18640
+ [win.phantom?.solana, "phantom-solana", "Phantom", "phantom"],
18641
+ [win.solflare, "solflare", "Solflare", "solflare"],
18642
+ [win.backpack, "backpack", "Backpack", "backpack"],
18643
+ [win.glow, "glow", "Glow", "glow"]
18644
+ ];
18645
+ for (const [provider, type, name, icon] of solanaCandidates) {
18646
+ const found = await trySilentSolana(provider, type, name, icon);
18647
+ if (found) return found;
18648
+ }
18649
+ }
18650
+ if (!chainType || chainType === "ethereum") {
18651
+ const allProviders = [];
18652
+ const eip6963 = getEip6963Providers();
18653
+ for (const { provider, walletId } of eip6963) {
18654
+ allProviders.push({
18655
+ provider,
18656
+ walletId: walletId === "unknown" ? "default" : walletId
18657
+ });
18658
+ }
18659
+ if (allProviders.length === 0) {
18660
+ if (win.phantom?.ethereum) {
18661
+ allProviders.push({ provider: win.phantom.ethereum, walletId: "phantom" });
18662
+ }
18663
+ if (win.okxwallet) {
18664
+ allProviders.push({ provider: win.okxwallet, walletId: "okx" });
18665
+ }
18666
+ if (win.coinbaseWalletExtension) {
18667
+ allProviders.push({ provider: win.coinbaseWalletExtension, walletId: "coinbase" });
18668
+ }
18669
+ if (win.ethereum && !allProviders.some((p) => p.provider === win.ethereum)) {
18670
+ allProviders.push({ provider: win.ethereum, walletId: "default" });
18671
+ }
18672
+ }
18673
+ for (const { provider, walletId } of allProviders) {
18674
+ if (!provider) continue;
18675
+ try {
18676
+ const accounts = await provider.request({ method: "eth_accounts" });
18677
+ if (!accounts || accounts.length === 0) continue;
18678
+ const resolved = identifyEthWallet(provider, walletId);
18679
+ return { ...resolved, address: accounts[0] };
18680
+ } catch {
18681
+ }
18682
+ }
18683
+ }
18684
+ } catch (error) {
18685
+ console.error("[detectConnectedBrowserWallet] detection error:", error);
18686
+ }
18687
+ return null;
18688
+ }
18689
+ function useDetectedBrowserWallet(opts = {}) {
18690
+ const { chainType, enabled = true, onDisconnect } = opts;
18691
+ const [wallet, setWallet] = React122.useState(null);
18692
+ const [isLoading, setIsLoading] = React122.useState(enabled);
18693
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React122.useState(0);
18694
+ const onDisconnectRef = React122.useRef(onDisconnect);
18695
+ onDisconnectRef.current = onDisconnect;
18696
+ React122.useEffect(() => {
18697
+ const store = getEip6963Store();
18698
+ if (!store) return;
18699
+ setEip6963ProviderCount(store.getProviders().length);
18700
+ return store.subscribe((providers) => setEip6963ProviderCount(providers.length));
18701
+ }, []);
18702
+ React122.useEffect(() => {
18703
+ if (!enabled) {
18704
+ setWallet(null);
18705
+ setIsLoading(false);
18706
+ return;
18707
+ }
18708
+ let mounted = true;
18709
+ const detect = async () => {
18710
+ if (!mounted) return;
18711
+ setIsLoading(true);
18712
+ const detected = await detectConnectedBrowserWallet(chainType);
18713
+ if (!mounted) return;
18714
+ setWallet(detected);
18715
+ setIsLoading(false);
18716
+ };
18717
+ detect();
18718
+ const onChange = () => detect();
18719
+ const onDisc = () => {
18720
+ onDisconnectRef.current?.();
18721
+ detect();
18722
+ };
18723
+ const onEthAccounts = (accounts) => {
18724
+ if (Array.isArray(accounts) && accounts.length === 0) onDisconnectRef.current?.();
18725
+ detect();
18726
+ };
18727
+ const win = typeof window !== "undefined" ? window : void 0;
18728
+ const solanaProvider = win?.phantom?.solana || win?.solana;
18729
+ if (solanaProvider) {
18730
+ solanaProvider.on("connect", onChange);
18731
+ solanaProvider.on("disconnect", onDisc);
18732
+ solanaProvider.on("accountChanged", onChange);
18733
+ }
18734
+ const ethProviders = [];
18735
+ for (const { provider } of getEip6963Providers()) {
18736
+ const p = provider;
18737
+ if (p && !ethProviders.includes(p)) ethProviders.push(p);
18738
+ }
18739
+ if (win?.ethereum && !ethProviders.includes(win.ethereum)) ethProviders.push(win.ethereum);
18740
+ if (win?.phantom?.ethereum && !ethProviders.includes(win.phantom.ethereum)) {
18741
+ ethProviders.push(win.phantom.ethereum);
18742
+ }
18743
+ for (const p of ethProviders) {
18744
+ p.on("accountsChanged", onEthAccounts);
18745
+ p.on("chainChanged", onChange);
18746
+ }
18747
+ return () => {
18748
+ mounted = false;
18749
+ if (solanaProvider) {
18750
+ solanaProvider.off?.("connect", onChange);
18751
+ solanaProvider.off?.("disconnect", onDisc);
18752
+ solanaProvider.off?.("accountChanged", onChange);
18753
+ }
18754
+ for (const p of ethProviders) {
18755
+ const off = p.off?.bind(p) ?? p.removeListener?.bind(p);
18756
+ if (off) {
18757
+ off("accountsChanged", onEthAccounts);
18758
+ off("chainChanged", onChange);
18759
+ }
18760
+ }
18761
+ };
18762
+ }, [chainType, eip6963ProviderCount, enabled]);
18763
+ return { wallet, isLoading, setWallet };
18764
+ }
18580
18765
  var SOLANA_DISCONNECT_TYPES = [
18581
18766
  "phantom-solana",
18582
18767
  "solflare",
@@ -18664,7 +18849,7 @@ function MetamaskIcon({
18664
18849
  className,
18665
18850
  variant = "color"
18666
18851
  }) {
18667
- const id = React122.useId();
18852
+ const id = React132.useId();
18668
18853
  if (variant === "light" || variant === "dark") {
18669
18854
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
18670
18855
  "svg",
@@ -18789,7 +18974,7 @@ function PhantomIcon({
18789
18974
  className,
18790
18975
  variant = "color"
18791
18976
  }) {
18792
- const id = React132.useId();
18977
+ const id = React142.useId();
18793
18978
  if (variant === "light") {
18794
18979
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
18795
18980
  "svg",
@@ -18860,7 +19045,7 @@ function CoinbaseIcon({
18860
19045
  className,
18861
19046
  variant = "color"
18862
19047
  }) {
18863
- const id = React142.useId();
19048
+ const id = React152.useId();
18864
19049
  if (variant === "light") {
18865
19050
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
18866
19051
  "svg",
@@ -18944,7 +19129,7 @@ function RabbyIcon({
18944
19129
  className,
18945
19130
  variant = "color"
18946
19131
  }) {
18947
- const id = React152.useId();
19132
+ const id = React162.useId();
18948
19133
  if (variant === "light") {
18949
19134
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
18950
19135
  "svg",
@@ -19295,7 +19480,7 @@ function RainbowIcon({
19295
19480
  className,
19296
19481
  variant = "color"
19297
19482
  }) {
19298
- const id = React162.useId();
19483
+ const id = React172.useId();
19299
19484
  if (variant === "light") {
19300
19485
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
19301
19486
  "svg",
@@ -19761,7 +19946,7 @@ function TrustIcon({
19761
19946
  className,
19762
19947
  variant = "color"
19763
19948
  }) {
19764
- const id = React172.useId();
19949
+ const id = React182.useId();
19765
19950
  if (variant === "light") {
19766
19951
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
19767
19952
  "svg",
@@ -19854,7 +20039,7 @@ function OkxIcon({
19854
20039
  className,
19855
20040
  variant = "color"
19856
20041
  }) {
19857
- const id = React182.useId();
20042
+ const id = React192.useId();
19858
20043
  if (variant === "light") {
19859
20044
  return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
19860
20045
  "svg",
@@ -19925,7 +20110,7 @@ function GlowIcon({
19925
20110
  className,
19926
20111
  variant = "color"
19927
20112
  }) {
19928
- const id = React192.useId();
20113
+ const id = React202.useId();
19929
20114
  if (variant === "light") {
19930
20115
  return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
19931
20116
  "svg",
@@ -20030,7 +20215,7 @@ function BackpackIcon({
20030
20215
  className,
20031
20216
  variant = "color"
20032
20217
  }) {
20033
- const id = React202.useId();
20218
+ const id = React212.useId();
20034
20219
  if (variant === "light") {
20035
20220
  return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
20036
20221
  "svg",
@@ -20107,7 +20292,7 @@ function SolflareIcon({
20107
20292
  className,
20108
20293
  variant = "color"
20109
20294
  }) {
20110
- const id = React212.useId();
20295
+ const id = React222.useId();
20111
20296
  if (variant === "light") {
20112
20297
  return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
20113
20298
  "svg",
@@ -20178,7 +20363,7 @@ function EthereumIcon({
20178
20363
  className,
20179
20364
  variant = "color"
20180
20365
  }) {
20181
- const id = React222.useId();
20366
+ const id = React232.useId();
20182
20367
  if (variant === "light") {
20183
20368
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
20184
20369
  "svg",
@@ -20312,7 +20497,7 @@ function SolanaIcon({
20312
20497
  className,
20313
20498
  variant = "color"
20314
20499
  }) {
20315
- const id = React232.useId();
20500
+ const id = React242.useId();
20316
20501
  if (variant === "light") {
20317
20502
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
20318
20503
  "svg",
@@ -20561,44 +20746,6 @@ function truncateAddress3(address) {
20561
20746
  if (address.length <= 10) return address;
20562
20747
  return `${address.slice(0, 4)}...${address.slice(-4)}`;
20563
20748
  }
20564
- function identifyEthWallet(provider, _win, hint) {
20565
- switch (hint) {
20566
- case "metamask":
20567
- return { type: "metamask", name: "MetaMask", icon: "metamask" };
20568
- case "phantom":
20569
- return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
20570
- case "coinbase":
20571
- return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
20572
- case "okx":
20573
- return { type: "okx", name: "OKX Wallet", icon: "okx" };
20574
- case "rabby":
20575
- return { type: "rabby", name: "Rabby", icon: "rabby" };
20576
- case "trust":
20577
- return { type: "trust", name: "Trust Wallet", icon: "trust" };
20578
- case "rainbow":
20579
- return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
20580
- }
20581
- const anyProvider = provider;
20582
- if (provider.isPhantom) {
20583
- return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
20584
- }
20585
- if (anyProvider.isCoinbaseWallet) {
20586
- return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
20587
- }
20588
- if (anyProvider.isRabby) {
20589
- return { type: "rabby", name: "Rabby", icon: "rabby" };
20590
- }
20591
- if (anyProvider.isTrust) {
20592
- return { type: "trust", name: "Trust Wallet", icon: "trust" };
20593
- }
20594
- if (anyProvider.isRainbow) {
20595
- return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
20596
- }
20597
- if (provider.isMetaMask && !provider.isPhantom) {
20598
- return { type: "metamask", name: "MetaMask", icon: "metamask" };
20599
- }
20600
- return { type: "metamask", name: "Wallet", icon: "metamask" };
20601
- }
20602
20749
  function BrowserWalletButton({
20603
20750
  onClick,
20604
20751
  onConnectClick,
@@ -20609,30 +20756,19 @@ function BrowserWalletButton({
20609
20756
  subtitle = i18n2.depositModal.browserWallet.subtitle
20610
20757
  }) {
20611
20758
  const { colors: colors2, fonts, components } = useTheme();
20612
- const [isHovered, setIsHovered] = React242.useState(false);
20613
- const [isTouchDevice, setIsTouchDevice] = React242.useState(false);
20614
- const [wallet, setWallet] = React242.useState(null);
20615
- const [isLoading, setIsLoading] = React242.useState(true);
20616
- const [isConnecting, setIsConnecting] = React242.useState(false);
20617
- const [balanceText, setBalanceText] = React242.useState(null);
20618
- const [isLoadingBalance, setIsLoadingBalance] = React242.useState(false);
20619
- const [isDisconnecting, setIsDisconnecting] = React242.useState(false);
20620
- const onDisconnectRef = React242.useRef(onDisconnect);
20759
+ const [isHovered, setIsHovered] = React252.useState(false);
20760
+ const [isTouchDevice, setIsTouchDevice] = React252.useState(false);
20761
+ const { wallet, isLoading, setWallet } = useDetectedBrowserWallet({ chainType, onDisconnect });
20762
+ const [isConnecting, setIsConnecting] = React252.useState(false);
20763
+ const [balanceText, setBalanceText] = React252.useState(null);
20764
+ const [isLoadingBalance, setIsLoadingBalance] = React252.useState(false);
20765
+ const [isDisconnecting, setIsDisconnecting] = React252.useState(false);
20766
+ const onDisconnectRef = React252.useRef(onDisconnect);
20621
20767
  onDisconnectRef.current = onDisconnect;
20622
- React242.useEffect(() => {
20768
+ React252.useEffect(() => {
20623
20769
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
20624
20770
  }, []);
20625
- const [eip6963ProviderCount, setEip6963ProviderCount] = React242.useState(0);
20626
- React242.useEffect(() => {
20627
- const store = getEip6963Store();
20628
- if (!store) return;
20629
- setEip6963ProviderCount(store.getProviders().length);
20630
- const unsubscribe = store.subscribe((providers) => {
20631
- setEip6963ProviderCount(providers.length);
20632
- });
20633
- return unsubscribe;
20634
- }, []);
20635
- React242.useEffect(() => {
20771
+ React252.useEffect(() => {
20636
20772
  if (!wallet || !publishableKey) {
20637
20773
  setBalanceText(null);
20638
20774
  return;
@@ -20673,206 +20809,6 @@ function BrowserWalletButton({
20673
20809
  cancelled = true;
20674
20810
  };
20675
20811
  }, [wallet, publishableKey]);
20676
- React242.useEffect(() => {
20677
- let mounted = true;
20678
- const detectWallet = async () => {
20679
- if (!mounted) return;
20680
- setIsLoading(true);
20681
- try {
20682
- const win = typeof window !== "undefined" ? window : null;
20683
- if (!win) return;
20684
- if (getUserDisconnectedWallet()) {
20685
- if (mounted) {
20686
- setWallet(null);
20687
- setIsLoading(false);
20688
- }
20689
- return;
20690
- }
20691
- if (!chainType || chainType === "solana") {
20692
- const anyWin = win;
20693
- const trySilentSolana = async (provider, type, name, icon) => {
20694
- if (!provider) return false;
20695
- if (provider.isConnected && provider.publicKey) {
20696
- if (mounted) {
20697
- setWallet({
20698
- type,
20699
- name,
20700
- address: provider.publicKey.toString(),
20701
- icon
20702
- });
20703
- setIsLoading(false);
20704
- }
20705
- return true;
20706
- }
20707
- try {
20708
- const resp = await provider.connect({ onlyIfTrusted: true });
20709
- if (mounted && resp.publicKey) {
20710
- setWallet({
20711
- type,
20712
- name,
20713
- address: resp.publicKey.toString(),
20714
- icon
20715
- });
20716
- setIsLoading(false);
20717
- return true;
20718
- }
20719
- } catch {
20720
- }
20721
- return false;
20722
- };
20723
- if (await trySilentSolana(
20724
- win.phantom?.solana,
20725
- "phantom-solana",
20726
- "Phantom",
20727
- "phantom"
20728
- ))
20729
- return;
20730
- if (await trySilentSolana(
20731
- anyWin.solflare,
20732
- "solflare",
20733
- "Solflare",
20734
- "solflare"
20735
- ))
20736
- return;
20737
- if (await trySilentSolana(
20738
- anyWin.backpack,
20739
- "backpack",
20740
- "Backpack",
20741
- "backpack"
20742
- ))
20743
- return;
20744
- if (await trySilentSolana(
20745
- anyWin.glow,
20746
- "glow",
20747
- "Glow",
20748
- "glow"
20749
- ))
20750
- return;
20751
- }
20752
- if (!chainType || chainType === "ethereum") {
20753
- const anyWin = win;
20754
- const allProviders = [];
20755
- const eip6963 = getEip6963Providers();
20756
- for (const { provider, walletId } of eip6963) {
20757
- allProviders.push({
20758
- provider,
20759
- walletId: walletId === "unknown" ? "default" : walletId
20760
- });
20761
- }
20762
- if (allProviders.length === 0) {
20763
- if (win.phantom?.ethereum) {
20764
- allProviders.push({
20765
- provider: win.phantom.ethereum,
20766
- walletId: "phantom"
20767
- });
20768
- }
20769
- if (anyWin.okxwallet) {
20770
- allProviders.push({
20771
- provider: anyWin.okxwallet,
20772
- walletId: "okx"
20773
- });
20774
- }
20775
- if (anyWin.coinbaseWalletExtension) {
20776
- allProviders.push({
20777
- provider: anyWin.coinbaseWalletExtension,
20778
- walletId: "coinbase"
20779
- });
20780
- }
20781
- if (win.ethereum) {
20782
- const isDuplicate = allProviders.some(
20783
- (p) => p.provider === win.ethereum
20784
- );
20785
- if (!isDuplicate) {
20786
- allProviders.push({
20787
- provider: win.ethereum,
20788
- walletId: "default"
20789
- });
20790
- }
20791
- }
20792
- }
20793
- for (const { provider, walletId } of allProviders) {
20794
- if (!provider) continue;
20795
- try {
20796
- const accounts = await provider.request({
20797
- method: "eth_accounts"
20798
- });
20799
- if (!accounts || accounts.length === 0) continue;
20800
- const address = accounts[0];
20801
- const resolved = identifyEthWallet(provider, anyWin, walletId);
20802
- if (mounted) {
20803
- setWallet({ ...resolved, address });
20804
- setIsLoading(false);
20805
- }
20806
- return;
20807
- } catch {
20808
- }
20809
- }
20810
- }
20811
- if (mounted) {
20812
- setWallet(null);
20813
- setIsLoading(false);
20814
- }
20815
- } catch (error) {
20816
- console.error("[BrowserWalletButton] Error detecting wallet:", error);
20817
- if (mounted) {
20818
- setWallet(null);
20819
- setIsLoading(false);
20820
- }
20821
- }
20822
- };
20823
- detectWallet();
20824
- const handleAccountsChanged = () => {
20825
- detectWallet();
20826
- };
20827
- const handleDisconnect = () => {
20828
- onDisconnectRef.current?.();
20829
- detectWallet();
20830
- };
20831
- const handleEthAccountsChanged = (accounts) => {
20832
- if (Array.isArray(accounts) && accounts.length === 0) {
20833
- onDisconnectRef.current?.();
20834
- }
20835
- detectWallet();
20836
- };
20837
- const solanaProvider = window.phantom?.solana || window.solana;
20838
- if (solanaProvider) {
20839
- solanaProvider.on("connect", handleAccountsChanged);
20840
- solanaProvider.on("disconnect", handleDisconnect);
20841
- solanaProvider.on("accountChanged", handleAccountsChanged);
20842
- }
20843
- const ethProviders = [];
20844
- for (const { provider } of getEip6963Providers()) {
20845
- const p = provider;
20846
- if (p && !ethProviders.includes(p)) {
20847
- ethProviders.push(p);
20848
- }
20849
- }
20850
- if (window.ethereum && !ethProviders.includes(window.ethereum)) {
20851
- ethProviders.push(window.ethereum);
20852
- }
20853
- if (window.phantom?.ethereum && !ethProviders.includes(window.phantom.ethereum)) {
20854
- ethProviders.push(window.phantom.ethereum);
20855
- }
20856
- for (const provider of ethProviders) {
20857
- provider.on("accountsChanged", handleEthAccountsChanged);
20858
- provider.on("chainChanged", handleAccountsChanged);
20859
- }
20860
- return () => {
20861
- mounted = false;
20862
- if (solanaProvider) {
20863
- solanaProvider.off("connect", handleAccountsChanged);
20864
- solanaProvider.off("disconnect", handleDisconnect);
20865
- solanaProvider.off("accountChanged", handleAccountsChanged);
20866
- }
20867
- for (const provider of ethProviders) {
20868
- const off = provider.off?.bind(provider) ?? provider.removeListener?.bind(provider);
20869
- if (off) {
20870
- off("accountsChanged", handleEthAccountsChanged);
20871
- off("chainChanged", handleAccountsChanged);
20872
- }
20873
- }
20874
- };
20875
- }, [chainType, eip6963ProviderCount]);
20876
20812
  const handleConnect = async () => {
20877
20813
  if (wallet) {
20878
20814
  onClick(wallet);
@@ -20956,7 +20892,7 @@ function BrowserWalletButton({
20956
20892
  border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
20957
20893
  };
20958
20894
  const sortedWallets = featuredWallets ? [...featuredWallets].sort((a, b) => a.position - b.position) : [];
20959
- const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React242.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
20895
+ const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React252.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
20960
20896
  size: 36,
20961
20897
  className: "uf-rounded-lg",
20962
20898
  variant: "color"
@@ -21218,6 +21154,7 @@ function CoinbaseConnect({
21218
21154
  onBack: parentOnBack,
21219
21155
  onDisconnect,
21220
21156
  skipToHoldings,
21157
+ canGoBack = true,
21221
21158
  onExecutionsChange
21222
21159
  }) {
21223
21160
  const { colors: colors2, fonts, components } = useTheme();
@@ -21605,6 +21542,16 @@ function CoinbaseConnect({
21605
21542
  setIsLoading(false);
21606
21543
  }
21607
21544
  };
21545
+ const handleDisconnect = () => {
21546
+ onDisconnect?.();
21547
+ if (!canGoBack) {
21548
+ setAccessToken(null);
21549
+ setHoldings([]);
21550
+ setSelectedHolding(null);
21551
+ setSelectedAsset(null);
21552
+ transitionTo("select_exchange");
21553
+ }
21554
+ };
21608
21555
  const handleBack = () => {
21609
21556
  switch (view) {
21610
21557
  case "select_exchange":
@@ -21665,7 +21612,7 @@ function CoinbaseConnect({
21665
21612
  DepositHeader,
21666
21613
  {
21667
21614
  title: t12.title,
21668
- showBack: true,
21615
+ showBack: canGoBack,
21669
21616
  onBack: handleBack,
21670
21617
  onClose
21671
21618
  }
@@ -21678,7 +21625,7 @@ function CoinbaseConnect({
21678
21625
  DepositHeader,
21679
21626
  {
21680
21627
  title: t12.title,
21681
- showBack: true,
21628
+ showBack: canGoBack,
21682
21629
  onBack: handleBack,
21683
21630
  onClose
21684
21631
  }
@@ -22390,7 +22337,7 @@ function CoinbaseConnect({
22390
22337
  borderRadius: components.button.borderRadius,
22391
22338
  fontFamily: fonts.medium
22392
22339
  },
22393
- onClick: onDisconnect,
22340
+ onClick: handleDisconnect,
22394
22341
  children: t12.disconnect
22395
22342
  }
22396
22343
  )
@@ -23177,7 +23124,7 @@ function ThemeStyleInjector({
23177
23124
  className
23178
23125
  }) {
23179
23126
  const { colors: colors2, fonts, mode } = useTheme();
23180
- const cssVars = React262.useMemo(() => {
23127
+ const cssVars = React272.useMemo(() => {
23181
23128
  const hexToHSL = (hex) => {
23182
23129
  hex = hex.replace("#", "");
23183
23130
  const r2 = parseInt(hex.slice(0, 2), 16) / 255;
@@ -23237,7 +23184,7 @@ function ThemeStyleInjector({
23237
23184
  ...fonts.regular ? { "--uf-font-family": fonts.regular } : {}
23238
23185
  };
23239
23186
  }, [colors2, fonts.regular]);
23240
- React262.useEffect(() => {
23187
+ React272.useEffect(() => {
23241
23188
  if (typeof document === "undefined") return;
23242
23189
  if (fonts.regular) {
23243
23190
  document.documentElement.style.setProperty(
@@ -24196,14 +24143,14 @@ function useCopyAddress() {
24196
24143
  return { copied, handleCopy };
24197
24144
  }
24198
24145
  var TooltipProvider2 = Provider;
24199
- var TooltipContext = React272.createContext({
24146
+ var TooltipContext = React282.createContext({
24200
24147
  open: false,
24201
24148
  onOpenChange: () => {
24202
24149
  }
24203
24150
  });
24204
- var TooltipTrigger2 = React272.forwardRef(({ onClick, ...props }, ref) => {
24205
- const { open, onOpenChange } = React272.useContext(TooltipContext);
24206
- const handleClick = React272.useCallback(
24151
+ var TooltipTrigger2 = React282.forwardRef(({ onClick, ...props }, ref) => {
24152
+ const { open, onOpenChange } = React282.useContext(TooltipContext);
24153
+ const handleClick = React282.useCallback(
24207
24154
  (e) => {
24208
24155
  onOpenChange(!open);
24209
24156
  onClick?.(e);
@@ -24213,7 +24160,7 @@ var TooltipTrigger2 = React272.forwardRef(({ onClick, ...props }, ref) => {
24213
24160
  return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Trigger, { ref, onClick: handleClick, ...props });
24214
24161
  });
24215
24162
  TooltipTrigger2.displayName = Trigger.displayName;
24216
- var TooltipContent2 = React272.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
24163
+ var TooltipContent2 = React282.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
24217
24164
  const { themeClass, colors: colors2 } = useTheme();
24218
24165
  return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Portal3, { children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
24219
24166
  Content22,
@@ -24818,7 +24765,7 @@ function TransferCryptoSingleInput({
24818
24765
  }
24819
24766
  var Select2 = Root23;
24820
24767
  var SelectValue2 = Value;
24821
- var SelectTrigger2 = React282.forwardRef(({ className, style, children, ...props }, ref) => {
24768
+ var SelectTrigger2 = React292.forwardRef(({ className, style, children, ...props }, ref) => {
24822
24769
  const { components } = useTheme();
24823
24770
  return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
24824
24771
  Trigger2,
@@ -24842,7 +24789,7 @@ var SelectTrigger2 = React282.forwardRef(({ className, style, children, ...props
24842
24789
  );
24843
24790
  });
24844
24791
  SelectTrigger2.displayName = Trigger2.displayName;
24845
- var SelectScrollUpButton2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
24792
+ var SelectScrollUpButton2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
24846
24793
  ScrollUpButton,
24847
24794
  {
24848
24795
  ref,
@@ -24855,7 +24802,7 @@ var SelectScrollUpButton2 = React282.forwardRef(({ className, ...props }, ref) =
24855
24802
  }
24856
24803
  ));
24857
24804
  SelectScrollUpButton2.displayName = ScrollUpButton.displayName;
24858
- var SelectScrollDownButton2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
24805
+ var SelectScrollDownButton2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
24859
24806
  ScrollDownButton,
24860
24807
  {
24861
24808
  ref,
@@ -24868,7 +24815,7 @@ var SelectScrollDownButton2 = React282.forwardRef(({ className, ...props }, ref)
24868
24815
  }
24869
24816
  ));
24870
24817
  SelectScrollDownButton2.displayName = ScrollDownButton.displayName;
24871
- var SelectContent2 = React282.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
24818
+ var SelectContent2 = React292.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
24872
24819
  const { themeClass, colors: colors2, components } = useTheme();
24873
24820
  return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Portal4, { children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
24874
24821
  Content23,
@@ -24906,7 +24853,7 @@ var SelectContent2 = React282.forwardRef(({ className, style, children, position
24906
24853
  ) });
24907
24854
  });
24908
24855
  SelectContent2.displayName = Content23.displayName;
24909
- var SelectLabel2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
24856
+ var SelectLabel2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
24910
24857
  Label,
24911
24858
  {
24912
24859
  ref,
@@ -24918,7 +24865,7 @@ var SelectLabel2 = React282.forwardRef(({ className, ...props }, ref) => /* @__P
24918
24865
  }
24919
24866
  ));
24920
24867
  SelectLabel2.displayName = Label.displayName;
24921
- var SelectItem2 = React282.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
24868
+ var SelectItem2 = React292.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
24922
24869
  Item,
24923
24870
  {
24924
24871
  ref,
@@ -24934,7 +24881,7 @@ var SelectItem2 = React282.forwardRef(({ className, children, ...props }, ref) =
24934
24881
  }
24935
24882
  ));
24936
24883
  SelectItem2.displayName = Item.displayName;
24937
- var SelectSeparator2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
24884
+ var SelectSeparator2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
24938
24885
  Separator,
24939
24886
  {
24940
24887
  ref,
@@ -26598,22 +26545,27 @@ function WalletConnect({
26598
26545
  productType,
26599
26546
  onBack: parentOnBack,
26600
26547
  onClose,
26548
+ canGoBack = true,
26549
+ depositWalletsLoading = false,
26601
26550
  onExecutionsChange
26602
26551
  }) {
26603
26552
  const { colors: colors2, fonts, components } = useTheme();
26604
- const walletProvidedAtMount = React292.useRef(!!initialWalletInfo && !!initialDepositWallet);
26605
- const [activeWalletInfo, setActiveWalletInfo] = React292.useState(initialWalletInfo ?? null);
26606
- const [activeDepositWallet, setActiveDepositWallet] = React292.useState(initialDepositWallet ?? null);
26553
+ const walletProvidedAtMount = React302.useRef(!!initialWalletInfo && !!initialDepositWallet);
26554
+ const [activeWalletInfo, setActiveWalletInfo] = React302.useState(initialWalletInfo ?? null);
26555
+ const [activeDepositWallet, setActiveDepositWallet] = React302.useState(initialDepositWallet ?? null);
26607
26556
  const initialView = initialWalletInfo && initialDepositWallet ? "select_token" : "select_wallet";
26608
- const [view, setView] = React292.useState(initialView);
26609
- const [isTransitioning, setIsTransitioning] = React292.useState(false);
26610
- const viewRef = React292.useRef(initialView);
26611
- const [selectedWalletDef, setSelectedWalletDef] = React292.useState(null);
26612
- const [connectingNetwork, setConnectingNetwork] = React292.useState(null);
26613
- const [walletError, setWalletError] = React292.useState(null);
26614
- const [isWalletConnecting, setIsWalletConnecting] = React292.useState(false);
26615
- const [eip6963ProviderCount, setEip6963ProviderCount] = React292.useState(0);
26616
- React292.useEffect(() => {
26557
+ const [view, setView] = React302.useState(initialView);
26558
+ const [isTransitioning, setIsTransitioning] = React302.useState(false);
26559
+ const viewRef = React302.useRef(initialView);
26560
+ const standalone = !canGoBack && !walletProvidedAtMount.current;
26561
+ const { wallet: detectedWallet, isLoading: detectingWallet } = useDetectedBrowserWallet({ enabled: standalone });
26562
+ const [autoResolved, setAutoResolved] = React302.useState(false);
26563
+ const [selectedWalletDef, setSelectedWalletDef] = React302.useState(null);
26564
+ const [connectingNetwork, setConnectingNetwork] = React302.useState(null);
26565
+ const [walletError, setWalletError] = React302.useState(null);
26566
+ const [isWalletConnecting, setIsWalletConnecting] = React302.useState(false);
26567
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React302.useState(0);
26568
+ React302.useEffect(() => {
26617
26569
  const store = getEip6963Store();
26618
26570
  if (!store) return;
26619
26571
  setEip6963ProviderCount(store.getProviders().length);
@@ -26621,20 +26573,44 @@ function WalletConnect({
26621
26573
  setEip6963ProviderCount(providers.length);
26622
26574
  });
26623
26575
  }, []);
26624
- const availableWallets = React292.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
26625
- const [balances, setBalances] = React292.useState([]);
26626
- const [isLoading, setIsLoading] = React292.useState(false);
26627
- const [selectedBalance, setSelectedBalance] = React292.useState(null);
26628
- const [totalBalanceUsd, setTotalBalanceUsd] = React292.useState(null);
26629
- const [error, setError] = React292.useState(null);
26630
- const [isDisconnectingWallet, setIsDisconnectingWallet] = React292.useState(false);
26631
- const [amountUsd, setAmountUsd] = React292.useState(prefillAmountUsd ?? "");
26632
- const [isConfirming, setIsConfirming] = React292.useState(false);
26633
- const [hasSignedTransaction, setHasSignedTransaction] = React292.useState(false);
26634
- const [tokenChainDetails, setTokenChainDetails] = React292.useState(null);
26635
- const [loadingTokenDetails, setLoadingTokenDetails] = React292.useState(false);
26636
- const [showTransactionDetails, setShowTransactionDetails] = React292.useState(false);
26637
- const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React292.useState(null);
26576
+ const availableWallets = React302.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
26577
+ React302.useEffect(() => {
26578
+ if (!standalone || autoResolved || detectingWallet) return;
26579
+ if (!detectedWallet) {
26580
+ setAutoResolved(true);
26581
+ return;
26582
+ }
26583
+ const wct = detectedWallet.type === "phantom-solana" || detectedWallet.type === "solflare" || detectedWallet.type === "backpack" || detectedWallet.type === "glow" ? "solana" : "ethereum";
26584
+ const matching = depositWallets?.find((w) => w.chain_type === wct);
26585
+ if (!matching) {
26586
+ if (!depositWalletsLoading) setAutoResolved(true);
26587
+ return;
26588
+ }
26589
+ setActiveWalletInfo(detectedWallet);
26590
+ setActiveDepositWallet(matching);
26591
+ onWalletConnected?.(detectedWallet, matching);
26592
+ setView("select_token");
26593
+ viewRef.current = "select_token";
26594
+ setAutoResolved(true);
26595
+ }, [standalone, autoResolved, detectingWallet, detectedWallet, depositWallets, depositWalletsLoading]);
26596
+ React302.useEffect(() => {
26597
+ if (!standalone || autoResolved) return;
26598
+ const t12 = setTimeout(() => setAutoResolved(true), 5e3);
26599
+ return () => clearTimeout(t12);
26600
+ }, [standalone, autoResolved]);
26601
+ const [balances, setBalances] = React302.useState([]);
26602
+ const [isLoading, setIsLoading] = React302.useState(false);
26603
+ const [selectedBalance, setSelectedBalance] = React302.useState(null);
26604
+ const [totalBalanceUsd, setTotalBalanceUsd] = React302.useState(null);
26605
+ const [error, setError] = React302.useState(null);
26606
+ const [isDisconnectingWallet, setIsDisconnectingWallet] = React302.useState(false);
26607
+ const [amountUsd, setAmountUsd] = React302.useState(prefillAmountUsd ?? "");
26608
+ const [isConfirming, setIsConfirming] = React302.useState(false);
26609
+ const [hasSignedTransaction, setHasSignedTransaction] = React302.useState(false);
26610
+ const [tokenChainDetails, setTokenChainDetails] = React302.useState(null);
26611
+ const [loadingTokenDetails, setLoadingTokenDetails] = React302.useState(false);
26612
+ const [showTransactionDetails, setShowTransactionDetails] = React302.useState(false);
26613
+ const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React302.useState(null);
26638
26614
  const walletInfo = activeWalletInfo;
26639
26615
  const depositWallet = activeDepositWallet;
26640
26616
  const hasWallet = !!activeWalletInfo && !!activeDepositWallet;
@@ -26642,7 +26618,7 @@ function WalletConnect({
26642
26618
  const recipientAddress = activeDepositWallet?.address ?? "";
26643
26619
  const isCheckoutMode = !!checkoutAmountUsd;
26644
26620
  const supportedChainType = chainType === "algorand" || chainType === "xrpl" ? "ethereum" : chainType;
26645
- const transitionTo = React292.useCallback((nextView) => {
26621
+ const transitionTo = React302.useCallback((nextView) => {
26646
26622
  if (nextView === viewRef.current) return;
26647
26623
  setIsTransitioning(true);
26648
26624
  setTimeout(() => {
@@ -26779,7 +26755,7 @@ function WalletConnect({
26779
26755
  }
26780
26756
  };
26781
26757
  const selectedToken = selectedBalance ? getTokenFromBalance(selectedBalance) : null;
26782
- const effectiveDestinationAmount = React292.useMemo(() => {
26758
+ const effectiveDestinationAmount = React302.useMemo(() => {
26783
26759
  if (!checkoutRemainingBaseUnits || checkoutRemainingBaseUnits === "0") return "0";
26784
26760
  if (!checkoutAmountUsd) return checkoutRemainingBaseUnits;
26785
26761
  const remaining = BigInt(checkoutRemainingBaseUnits);
@@ -26807,7 +26783,7 @@ function WalletConnect({
26807
26783
  stablecoinParity,
26808
26784
  enabled: isCheckoutMode && !!selectedToken && !!checkoutDestination && effectiveDestinationAmount !== "0"
26809
26785
  });
26810
- const activeCheckoutQuote = React292.useMemo(() => {
26786
+ const activeCheckoutQuote = React302.useMemo(() => {
26811
26787
  if (!isCheckoutMode) return null;
26812
26788
  if (walletCheckoutQuote) return { sourceAmount: walletCheckoutQuote.source_amount, sourceTokenDecimals: walletCheckoutQuote.source_token_decimals, sourceTokenSymbol: walletCheckoutQuote.source_token_symbol, sourceAmountUsd: walletCheckoutQuote.source_amount_usd, slippageBufferPercent: walletCheckoutQuote.slippage_buffer_percent ?? null };
26813
26789
  return checkoutQuote ?? null;
@@ -26821,19 +26797,19 @@ function WalletConnect({
26821
26797
  onDepositSuccess,
26822
26798
  onDepositError
26823
26799
  });
26824
- React292.useEffect(() => {
26800
+ React302.useEffect(() => {
26825
26801
  onExecutionsChange?.(depositExecutions);
26826
26802
  }, [depositExecutions, onExecutionsChange]);
26827
- React292.useEffect(() => {
26803
+ React302.useEffect(() => {
26828
26804
  if (!prefillAmountUsd || !tokenChainDetails || view !== "enter_amount") return;
26829
26805
  const minDeposit = tokenChainDetails.minimum_deposit_amount_usd || 0;
26830
26806
  const currentAmount = parseFloat(amountUsd) || 0;
26831
26807
  if (currentAmount > 0 && currentAmount < minDeposit) setAmountUsd(minDeposit.toFixed(2));
26832
26808
  }, [tokenChainDetails, view, prefillAmountUsd]);
26833
- React292.useEffect(() => {
26809
+ React302.useEffect(() => {
26834
26810
  if (view === "review") setShowTransactionDetails(false);
26835
26811
  }, [view]);
26836
- React292.useEffect(() => {
26812
+ React302.useEffect(() => {
26837
26813
  if (view !== "enter_amount" && view !== "review" || !selectedBalance || !activeDepositWallet) return;
26838
26814
  let cancelled = false;
26839
26815
  const fetchTokenDetails = async () => {
@@ -26860,7 +26836,7 @@ function WalletConnect({
26860
26836
  cancelled = true;
26861
26837
  };
26862
26838
  }, [view, selectedBalance, publishableKey, activeDepositWallet]);
26863
- React292.useEffect(() => {
26839
+ React302.useEffect(() => {
26864
26840
  if (!activeWalletInfo || !activeDepositWallet) return;
26865
26841
  let cancelled = false;
26866
26842
  setIsLoading(true);
@@ -26893,20 +26869,20 @@ function WalletConnect({
26893
26869
  cancelled = true;
26894
26870
  };
26895
26871
  }, [activeWalletInfo?.address, activeDepositWallet?.chain_type, publishableKey]);
26896
- const usdToTokenRate = React292.useMemo(() => {
26872
+ const usdToTokenRate = React302.useMemo(() => {
26897
26873
  if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
26898
26874
  const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
26899
26875
  const balanceUsd = parseFloat(selectedBalance.amount_usd);
26900
26876
  if (balanceAmount === 0 || balanceUsd === 0) return 0;
26901
26877
  return balanceAmount / balanceUsd;
26902
26878
  }, [selectedBalance, selectedToken]);
26903
- const tokenAmount = React292.useMemo(() => {
26879
+ const tokenAmount = React302.useMemo(() => {
26904
26880
  if (isCheckoutMode && activeCheckoutQuote && selectedToken) return Number(activeCheckoutQuote.sourceAmount) / 10 ** activeCheckoutQuote.sourceTokenDecimals;
26905
26881
  const usdNum = parseFloat(amountUsd) || 0;
26906
26882
  if (usdNum === 0 || usdToTokenRate === 0) return 0;
26907
26883
  return usdNum * usdToTokenRate;
26908
26884
  }, [amountUsd, usdToTokenRate, isCheckoutMode, activeCheckoutQuote, selectedToken]);
26909
- React292.useEffect(() => {
26885
+ React302.useEffect(() => {
26910
26886
  if (isCheckoutMode && activeCheckoutQuote?.sourceAmountUsd && view === "enter_amount") setAmountUsd(activeCheckoutQuote.sourceAmountUsd);
26911
26887
  }, [isCheckoutMode, activeCheckoutQuote, view]);
26912
26888
  const maxTokenAmount = selectedBalance && selectedToken ? Number(selectedBalance.amount) / 10 ** selectedToken.decimals : 0;
@@ -26914,7 +26890,7 @@ function WalletConnect({
26914
26890
  const inputUsdNum = parseFloat(amountUsd) || 0;
26915
26891
  const minDepositUsd = tokenChainDetails?.minimum_deposit_amount_usd || 0;
26916
26892
  const isValidAmount = isCheckoutMode && activeCheckoutQuote ? tokenAmount > 0 && tokenAmount <= maxTokenAmount : inputUsdNum > 0 && inputUsdNum <= maxUsdAmount && inputUsdNum >= minDepositUsd;
26917
- const formattedTokenAmount = React292.useMemo(() => {
26893
+ const formattedTokenAmount = React302.useMemo(() => {
26918
26894
  if (tokenAmount === 0 || !selectedToken) return null;
26919
26895
  return `${tokenAmount.toFixed(6)} ${selectedToken.symbol}`.replace(/\.?0+$/, "");
26920
26896
  }, [tokenAmount, selectedToken]);
@@ -26962,16 +26938,25 @@ function WalletConnect({
26962
26938
  } catch (err) {
26963
26939
  console.warn("[WalletConnect] disconnect error:", err);
26964
26940
  } finally {
26965
- setActiveWalletInfo(null);
26966
- setActiveDepositWallet(null);
26967
- setSelectedBalance(null);
26968
- setBalances([]);
26969
- setTotalBalanceUsd(null);
26970
- setAmountUsd(prefillAmountUsd ?? "");
26971
- setError(null);
26972
26941
  setIsDisconnectingWallet(false);
26973
- if (onWalletDisconnect) onWalletDisconnect();
26974
- else parentOnBack?.();
26942
+ const clearWalletState = () => {
26943
+ setActiveWalletInfo(null);
26944
+ setActiveDepositWallet(null);
26945
+ setSelectedBalance(null);
26946
+ setBalances([]);
26947
+ setTotalBalanceUsd(null);
26948
+ setAmountUsd(prefillAmountUsd ?? "");
26949
+ setError(null);
26950
+ };
26951
+ if (standalone) {
26952
+ onWalletDisconnect?.();
26953
+ transitionTo("select_wallet");
26954
+ setTimeout(clearWalletState, 160);
26955
+ } else {
26956
+ clearWalletState();
26957
+ if (onWalletDisconnect) onWalletDisconnect();
26958
+ else parentOnBack?.();
26959
+ }
26975
26960
  }
26976
26961
  };
26977
26962
  const handleReview = () => {
@@ -27097,9 +27082,15 @@ function WalletConnect({
27097
27082
  setIsConfirming(false);
27098
27083
  }
27099
27084
  };
27085
+ if (standalone && !autoResolved) {
27086
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { style: viewTransitionStyle, children: [
27087
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(DepositHeader, { title: "Connect Wallet", showBack: canGoBack, onBack: handleBack, onClose }),
27088
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-16", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(LoaderCircle, { className: "uf-w-8 uf-h-8 uf-animate-spin", style: { color: colors2.primary } }) })
27089
+ ] });
27090
+ }
27100
27091
  if (view === "select_wallet") {
27101
27092
  return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { style: viewTransitionStyle, children: [
27102
- /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(DepositHeader, { title: "Connect Wallet", showBack: true, onBack: handleBack, onClose }),
27093
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(DepositHeader, { title: "Connect Wallet", showBack: canGoBack, onBack: handleBack, onClose }),
27103
27094
  /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "uf-pb-4", children: [
27104
27095
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { className: "uf-text-sm uf-text-center uf-pb-4", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: "Select a wallet to connect" }),
27105
27096
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "uf-space-y-2", style: { maxHeight: 330, overflowY: "auto" }, children: availableWallets.map((wallet) => /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
@@ -27262,8 +27253,19 @@ function DepositModal({
27262
27253
  if (s === "tracker" && hideDepositTracker) return "main";
27263
27254
  if (s === "cashapp" && !enableCashApp) return "main";
27264
27255
  if (s === "card" && enableFiatOnramp === false) return "main";
27256
+ if (s === "pay_with_exchange") return enablePayWithExchange === false ? "main" : "exchange";
27257
+ if (s === "exchange_connect") return enableConnectExchange ? "coinbase_connect" : "main";
27258
+ if (s === "wallet_connect") return enableConnectWallet ? "wallet_connect" : "main";
27265
27259
  return s;
27266
- }, [initialScreen, hideDepositTracker, enableCashApp, enableFiatOnramp]);
27260
+ }, [
27261
+ initialScreen,
27262
+ hideDepositTracker,
27263
+ enableCashApp,
27264
+ enableFiatOnramp,
27265
+ enablePayWithExchange,
27266
+ enableConnectExchange,
27267
+ enableConnectWallet
27268
+ ]);
27267
27269
  const [containerEl, setContainerEl] = (0, import_react8.useState)(null);
27268
27270
  const containerCallbackRef = (0, import_react8.useCallback)((el) => {
27269
27271
  setContainerEl(el);
@@ -27387,6 +27389,12 @@ function DepositModal({
27387
27389
  setCardView("amount");
27388
27390
  }
27389
27391
  }, [view, showFiatOnramp]);
27392
+ (0, import_react8.useEffect)(() => {
27393
+ if (view === "exchange" && !showPayWithExchange) {
27394
+ setView("main");
27395
+ setExchangeView("providers");
27396
+ }
27397
+ }, [view, showPayWithExchange]);
27390
27398
  const { exchanges, isLoading: exchangesLoading } = useExchanges({
27391
27399
  publishableKey,
27392
27400
  enabled: open && showPayWithExchange
@@ -27506,7 +27514,7 @@ function DepositModal({
27506
27514
  setBrowserWalletChainType(void 0);
27507
27515
  setBrowserWalletInfo(null);
27508
27516
  setBrowserWalletModalOpen(false);
27509
- if (view === "wallet_connect") setView("main");
27517
+ if (view === "wallet_connect" && sessionOpenedFromMenu) setView("main");
27510
27518
  };
27511
27519
  const handleExchangeDisconnect = () => {
27512
27520
  const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
@@ -27515,7 +27523,7 @@ function DepositModal({
27515
27523
  }
27516
27524
  clearStoredIntegrationToken(IntegrationProvider.COINBASE);
27517
27525
  setConnectedExchange(null);
27518
- if (view === "coinbase_connect") setView("main");
27526
+ if (view === "coinbase_connect" && sessionOpenedFromMenu) setView("main");
27519
27527
  };
27520
27528
  const handleClose = () => {
27521
27529
  onOpenChange(false);
@@ -27527,6 +27535,7 @@ function DepositModal({
27527
27535
  setCardView("amount");
27528
27536
  setExchangeView("providers");
27529
27537
  setBrowserWalletInfo(null);
27538
+ setCoinbaseSkipToHoldings(false);
27530
27539
  resetViewTimeoutRef.current = null;
27531
27540
  }, 200);
27532
27541
  };
@@ -27541,6 +27550,7 @@ function DepositModal({
27541
27550
  setExchangeView("providers");
27542
27551
  setBrowserWalletInfo(null);
27543
27552
  setSelectedExecution(null);
27553
+ setCoinbaseSkipToHoldings(false);
27544
27554
  }, [open, effectiveInitialScreen]);
27545
27555
  (0, import_react8.useEffect)(
27546
27556
  () => () => {
@@ -27900,7 +27910,7 @@ function DepositModal({
27900
27910
  DepositHeader,
27901
27911
  {
27902
27912
  title: payWithExchangeTitle,
27903
- showBack: true,
27913
+ showBack: exchangeView === "pending" || sessionOpenedFromMenu,
27904
27914
  onBack: handleBack,
27905
27915
  onClose: handleClose
27906
27916
  }
@@ -27954,6 +27964,7 @@ function DepositModal({
27954
27964
  onClose: handleClose,
27955
27965
  onDisconnect: handleExchangeDisconnect,
27956
27966
  skipToHoldings: coinbaseSkipToHoldings,
27967
+ canGoBack: sessionOpenedFromMenu,
27957
27968
  onExecutionsChange: setDepositExecutions
27958
27969
  }
27959
27970
  ),
@@ -27991,7 +28002,9 @@ function DepositModal({
27991
28002
  setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
27992
28003
  },
27993
28004
  onBack: handleBack,
27994
- onClose: handleClose
28005
+ onClose: handleClose,
28006
+ canGoBack: sessionOpenedFromMenu,
28007
+ depositWalletsLoading: walletsLoading
27995
28008
  }
27996
28009
  ),
27997
28010
  depositPoweredByFooter
@@ -28000,7 +28013,7 @@ function DepositModal({
28000
28013
  DepositHeader,
28001
28014
  {
28002
28015
  title: cashAppView !== "amount" && cashAppAmount ? `Pay $${cashAppAmount} via Cash App` : "Pay with Cash App",
28003
- showBack: true,
28016
+ showBack: cashAppView !== "amount" || sessionOpenedFromMenu,
28004
28017
  onBack: handleBack,
28005
28018
  onClose: handleClose
28006
28019
  }