@unifold/connect-react 0.1.60 → 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
@@ -6220,6 +6220,7 @@ async function createDepositAddress(overrides, publishableKey) {
6220
6220
  recipient_address: overrides?.recipient_address || DEFAULT_CONFIG.recipientAddress || "0x309a4154a2CD4153Da886E780890C9cb5161553C",
6221
6221
  ...overrides?.action_type ? { action_type: overrides.action_type } : {},
6222
6222
  ...overrides?.source_chain_type ? { source_chain_type: overrides.source_chain_type } : {},
6223
+ ...overrides?.contract_calls ? { contract_calls: overrides.contract_calls } : {},
6223
6224
  client_metadata: overrides?.client_metadata || {}
6224
6225
  };
6225
6226
  const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
@@ -7381,7 +7382,7 @@ var React102 = __toESM(require("react"), 1);
7381
7382
  var import_jsx_runtime38 = require("react/jsx-runtime");
7382
7383
  var React112 = __toESM(require("react"), 1);
7383
7384
  var import_jsx_runtime39 = require("react/jsx-runtime");
7384
- var React242 = __toESM(require("react"), 1);
7385
+ var React252 = __toESM(require("react"), 1);
7385
7386
 
7386
7387
  // ../../node_modules/.pnpm/mipd@0.0.7_typescript@5.9.3/node_modules/mipd/dist/esm/utils.js
7387
7388
  function requestProviders(listener) {
@@ -7439,28 +7440,29 @@ function createStore() {
7439
7440
 
7440
7441
  // ../ui-react/dist/index.mjs
7441
7442
  var React122 = __toESM(require("react"), 1);
7442
- var import_jsx_runtime40 = require("react/jsx-runtime");
7443
7443
  var React132 = __toESM(require("react"), 1);
7444
- var import_jsx_runtime41 = require("react/jsx-runtime");
7444
+ var import_jsx_runtime40 = require("react/jsx-runtime");
7445
7445
  var React142 = __toESM(require("react"), 1);
7446
- var import_jsx_runtime42 = require("react/jsx-runtime");
7446
+ var import_jsx_runtime41 = require("react/jsx-runtime");
7447
7447
  var React152 = __toESM(require("react"), 1);
7448
- var import_jsx_runtime43 = require("react/jsx-runtime");
7448
+ var import_jsx_runtime42 = require("react/jsx-runtime");
7449
7449
  var React162 = __toESM(require("react"), 1);
7450
- var import_jsx_runtime44 = require("react/jsx-runtime");
7450
+ var import_jsx_runtime43 = require("react/jsx-runtime");
7451
7451
  var React172 = __toESM(require("react"), 1);
7452
- var import_jsx_runtime45 = require("react/jsx-runtime");
7452
+ var import_jsx_runtime44 = require("react/jsx-runtime");
7453
7453
  var React182 = __toESM(require("react"), 1);
7454
- var import_jsx_runtime46 = require("react/jsx-runtime");
7454
+ var import_jsx_runtime45 = require("react/jsx-runtime");
7455
7455
  var React192 = __toESM(require("react"), 1);
7456
- var import_jsx_runtime47 = require("react/jsx-runtime");
7456
+ var import_jsx_runtime46 = require("react/jsx-runtime");
7457
7457
  var React202 = __toESM(require("react"), 1);
7458
- var import_jsx_runtime48 = require("react/jsx-runtime");
7458
+ var import_jsx_runtime47 = require("react/jsx-runtime");
7459
7459
  var React212 = __toESM(require("react"), 1);
7460
- var import_jsx_runtime49 = require("react/jsx-runtime");
7460
+ var import_jsx_runtime48 = require("react/jsx-runtime");
7461
7461
  var React222 = __toESM(require("react"), 1);
7462
- var import_jsx_runtime50 = require("react/jsx-runtime");
7462
+ var import_jsx_runtime49 = require("react/jsx-runtime");
7463
7463
  var React232 = __toESM(require("react"), 1);
7464
+ var import_jsx_runtime50 = require("react/jsx-runtime");
7465
+ var React242 = __toESM(require("react"), 1);
7464
7466
  var import_jsx_runtime51 = require("react/jsx-runtime");
7465
7467
  var import_jsx_runtime52 = require("react/jsx-runtime");
7466
7468
  var import_jsx_runtime53 = require("react/jsx-runtime");
@@ -7475,7 +7477,7 @@ var import_react_query11 = require("@tanstack/react-query");
7475
7477
  var import_react_query12 = require("@tanstack/react-query");
7476
7478
  var import_react21 = require("react");
7477
7479
  var import_react22 = require("react");
7478
- var React262 = __toESM(require("react"), 1);
7480
+ var React272 = __toESM(require("react"), 1);
7479
7481
  var import_jsx_runtime55 = require("react/jsx-runtime");
7480
7482
  var import_jsx_runtime56 = require("react/jsx-runtime");
7481
7483
  var import_jsx_runtime57 = require("react/jsx-runtime");
@@ -9485,7 +9487,7 @@ var import_react24 = require("react");
9485
9487
  var import_jsx_runtime59 = require("react/jsx-runtime");
9486
9488
  var import_jsx_runtime60 = require("react/jsx-runtime");
9487
9489
  var import_react25 = require("react");
9488
- var React272 = __toESM(require("react"), 1);
9490
+ var React282 = __toESM(require("react"), 1);
9489
9491
 
9490
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
9491
9493
  var React31 = __toESM(require("react"), 1);
@@ -12227,7 +12229,7 @@ var import_react_query13 = require("@tanstack/react-query");
12227
12229
  var import_jsx_runtime62 = require("react/jsx-runtime");
12228
12230
  var import_jsx_runtime63 = require("react/jsx-runtime");
12229
12231
  var import_react26 = require("react");
12230
- var React282 = __toESM(require("react"), 1);
12232
+ var React292 = __toESM(require("react"), 1);
12231
12233
 
12232
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
12233
12235
  var React35 = __toESM(require("react"), 1);
@@ -13464,7 +13466,7 @@ var Separator = SelectSeparator;
13464
13466
  // ../ui-react/dist/index.mjs
13465
13467
  var import_jsx_runtime64 = require("react/jsx-runtime");
13466
13468
  var import_jsx_runtime65 = require("react/jsx-runtime");
13467
- var React292 = __toESM(require("react"), 1);
13469
+ var React302 = __toESM(require("react"), 1);
13468
13470
  var import_react_query14 = require("@tanstack/react-query");
13469
13471
  var import_jsx_runtime66 = require("react/jsx-runtime");
13470
13472
  var import_jsx_runtime67 = require("react/jsx-runtime");
@@ -14061,6 +14063,7 @@ function useDepositAddress(params) {
14061
14063
  destinationChainId,
14062
14064
  destinationTokenAddress,
14063
14065
  actionType,
14066
+ contractCalls,
14064
14067
  enabled = true
14065
14068
  } = params;
14066
14069
  return (0, import_react_query3.useQuery)({
@@ -14073,6 +14076,7 @@ function useDepositAddress(params) {
14073
14076
  destinationChainId ?? null,
14074
14077
  destinationTokenAddress ?? null,
14075
14078
  actionType ?? null,
14079
+ contractCalls ?? null,
14076
14080
  publishableKey
14077
14081
  ],
14078
14082
  queryFn: () => createDepositAddress(
@@ -14082,7 +14086,8 @@ function useDepositAddress(params) {
14082
14086
  destination_chain_type: destinationChainType,
14083
14087
  destination_chain_id: destinationChainId,
14084
14088
  destination_token_address: destinationTokenAddress,
14085
- action_type: actionType
14089
+ action_type: actionType,
14090
+ contract_calls: contractCalls
14086
14091
  },
14087
14092
  publishableKey
14088
14093
  ),
@@ -18573,6 +18578,190 @@ function collectAllEip6963EthProviders() {
18573
18578
  if (!store) return [];
18574
18579
  return store.getProviders().map((d) => d.provider);
18575
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
+ }
18576
18765
  var SOLANA_DISCONNECT_TYPES = [
18577
18766
  "phantom-solana",
18578
18767
  "solflare",
@@ -18660,7 +18849,7 @@ function MetamaskIcon({
18660
18849
  className,
18661
18850
  variant = "color"
18662
18851
  }) {
18663
- const id = React122.useId();
18852
+ const id = React132.useId();
18664
18853
  if (variant === "light" || variant === "dark") {
18665
18854
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
18666
18855
  "svg",
@@ -18785,7 +18974,7 @@ function PhantomIcon({
18785
18974
  className,
18786
18975
  variant = "color"
18787
18976
  }) {
18788
- const id = React132.useId();
18977
+ const id = React142.useId();
18789
18978
  if (variant === "light") {
18790
18979
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
18791
18980
  "svg",
@@ -18856,7 +19045,7 @@ function CoinbaseIcon({
18856
19045
  className,
18857
19046
  variant = "color"
18858
19047
  }) {
18859
- const id = React142.useId();
19048
+ const id = React152.useId();
18860
19049
  if (variant === "light") {
18861
19050
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
18862
19051
  "svg",
@@ -18940,7 +19129,7 @@ function RabbyIcon({
18940
19129
  className,
18941
19130
  variant = "color"
18942
19131
  }) {
18943
- const id = React152.useId();
19132
+ const id = React162.useId();
18944
19133
  if (variant === "light") {
18945
19134
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
18946
19135
  "svg",
@@ -19291,7 +19480,7 @@ function RainbowIcon({
19291
19480
  className,
19292
19481
  variant = "color"
19293
19482
  }) {
19294
- const id = React162.useId();
19483
+ const id = React172.useId();
19295
19484
  if (variant === "light") {
19296
19485
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
19297
19486
  "svg",
@@ -19757,7 +19946,7 @@ function TrustIcon({
19757
19946
  className,
19758
19947
  variant = "color"
19759
19948
  }) {
19760
- const id = React172.useId();
19949
+ const id = React182.useId();
19761
19950
  if (variant === "light") {
19762
19951
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
19763
19952
  "svg",
@@ -19850,7 +20039,7 @@ function OkxIcon({
19850
20039
  className,
19851
20040
  variant = "color"
19852
20041
  }) {
19853
- const id = React182.useId();
20042
+ const id = React192.useId();
19854
20043
  if (variant === "light") {
19855
20044
  return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
19856
20045
  "svg",
@@ -19921,7 +20110,7 @@ function GlowIcon({
19921
20110
  className,
19922
20111
  variant = "color"
19923
20112
  }) {
19924
- const id = React192.useId();
20113
+ const id = React202.useId();
19925
20114
  if (variant === "light") {
19926
20115
  return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
19927
20116
  "svg",
@@ -20026,7 +20215,7 @@ function BackpackIcon({
20026
20215
  className,
20027
20216
  variant = "color"
20028
20217
  }) {
20029
- const id = React202.useId();
20218
+ const id = React212.useId();
20030
20219
  if (variant === "light") {
20031
20220
  return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
20032
20221
  "svg",
@@ -20103,7 +20292,7 @@ function SolflareIcon({
20103
20292
  className,
20104
20293
  variant = "color"
20105
20294
  }) {
20106
- const id = React212.useId();
20295
+ const id = React222.useId();
20107
20296
  if (variant === "light") {
20108
20297
  return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
20109
20298
  "svg",
@@ -20174,7 +20363,7 @@ function EthereumIcon({
20174
20363
  className,
20175
20364
  variant = "color"
20176
20365
  }) {
20177
- const id = React222.useId();
20366
+ const id = React232.useId();
20178
20367
  if (variant === "light") {
20179
20368
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
20180
20369
  "svg",
@@ -20308,7 +20497,7 @@ function SolanaIcon({
20308
20497
  className,
20309
20498
  variant = "color"
20310
20499
  }) {
20311
- const id = React232.useId();
20500
+ const id = React242.useId();
20312
20501
  if (variant === "light") {
20313
20502
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
20314
20503
  "svg",
@@ -20557,44 +20746,6 @@ function truncateAddress3(address) {
20557
20746
  if (address.length <= 10) return address;
20558
20747
  return `${address.slice(0, 4)}...${address.slice(-4)}`;
20559
20748
  }
20560
- function identifyEthWallet(provider, _win, hint) {
20561
- switch (hint) {
20562
- case "metamask":
20563
- return { type: "metamask", name: "MetaMask", icon: "metamask" };
20564
- case "phantom":
20565
- return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
20566
- case "coinbase":
20567
- return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
20568
- case "okx":
20569
- return { type: "okx", name: "OKX Wallet", icon: "okx" };
20570
- case "rabby":
20571
- return { type: "rabby", name: "Rabby", icon: "rabby" };
20572
- case "trust":
20573
- return { type: "trust", name: "Trust Wallet", icon: "trust" };
20574
- case "rainbow":
20575
- return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
20576
- }
20577
- const anyProvider = provider;
20578
- if (provider.isPhantom) {
20579
- return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
20580
- }
20581
- if (anyProvider.isCoinbaseWallet) {
20582
- return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
20583
- }
20584
- if (anyProvider.isRabby) {
20585
- return { type: "rabby", name: "Rabby", icon: "rabby" };
20586
- }
20587
- if (anyProvider.isTrust) {
20588
- return { type: "trust", name: "Trust Wallet", icon: "trust" };
20589
- }
20590
- if (anyProvider.isRainbow) {
20591
- return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
20592
- }
20593
- if (provider.isMetaMask && !provider.isPhantom) {
20594
- return { type: "metamask", name: "MetaMask", icon: "metamask" };
20595
- }
20596
- return { type: "metamask", name: "Wallet", icon: "metamask" };
20597
- }
20598
20749
  function BrowserWalletButton({
20599
20750
  onClick,
20600
20751
  onConnectClick,
@@ -20605,30 +20756,19 @@ function BrowserWalletButton({
20605
20756
  subtitle = i18n2.depositModal.browserWallet.subtitle
20606
20757
  }) {
20607
20758
  const { colors: colors2, fonts, components } = useTheme();
20608
- const [isHovered, setIsHovered] = React242.useState(false);
20609
- const [isTouchDevice, setIsTouchDevice] = React242.useState(false);
20610
- const [wallet, setWallet] = React242.useState(null);
20611
- const [isLoading, setIsLoading] = React242.useState(true);
20612
- const [isConnecting, setIsConnecting] = React242.useState(false);
20613
- const [balanceText, setBalanceText] = React242.useState(null);
20614
- const [isLoadingBalance, setIsLoadingBalance] = React242.useState(false);
20615
- const [isDisconnecting, setIsDisconnecting] = React242.useState(false);
20616
- 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);
20617
20767
  onDisconnectRef.current = onDisconnect;
20618
- React242.useEffect(() => {
20768
+ React252.useEffect(() => {
20619
20769
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
20620
20770
  }, []);
20621
- const [eip6963ProviderCount, setEip6963ProviderCount] = React242.useState(0);
20622
- React242.useEffect(() => {
20623
- const store = getEip6963Store();
20624
- if (!store) return;
20625
- setEip6963ProviderCount(store.getProviders().length);
20626
- const unsubscribe = store.subscribe((providers) => {
20627
- setEip6963ProviderCount(providers.length);
20628
- });
20629
- return unsubscribe;
20630
- }, []);
20631
- React242.useEffect(() => {
20771
+ React252.useEffect(() => {
20632
20772
  if (!wallet || !publishableKey) {
20633
20773
  setBalanceText(null);
20634
20774
  return;
@@ -20669,206 +20809,6 @@ function BrowserWalletButton({
20669
20809
  cancelled = true;
20670
20810
  };
20671
20811
  }, [wallet, publishableKey]);
20672
- React242.useEffect(() => {
20673
- let mounted = true;
20674
- const detectWallet = async () => {
20675
- if (!mounted) return;
20676
- setIsLoading(true);
20677
- try {
20678
- const win = typeof window !== "undefined" ? window : null;
20679
- if (!win) return;
20680
- if (getUserDisconnectedWallet()) {
20681
- if (mounted) {
20682
- setWallet(null);
20683
- setIsLoading(false);
20684
- }
20685
- return;
20686
- }
20687
- if (!chainType || chainType === "solana") {
20688
- const anyWin = win;
20689
- const trySilentSolana = async (provider, type, name, icon) => {
20690
- if (!provider) return false;
20691
- if (provider.isConnected && provider.publicKey) {
20692
- if (mounted) {
20693
- setWallet({
20694
- type,
20695
- name,
20696
- address: provider.publicKey.toString(),
20697
- icon
20698
- });
20699
- setIsLoading(false);
20700
- }
20701
- return true;
20702
- }
20703
- try {
20704
- const resp = await provider.connect({ onlyIfTrusted: true });
20705
- if (mounted && resp.publicKey) {
20706
- setWallet({
20707
- type,
20708
- name,
20709
- address: resp.publicKey.toString(),
20710
- icon
20711
- });
20712
- setIsLoading(false);
20713
- return true;
20714
- }
20715
- } catch {
20716
- }
20717
- return false;
20718
- };
20719
- if (await trySilentSolana(
20720
- win.phantom?.solana,
20721
- "phantom-solana",
20722
- "Phantom",
20723
- "phantom"
20724
- ))
20725
- return;
20726
- if (await trySilentSolana(
20727
- anyWin.solflare,
20728
- "solflare",
20729
- "Solflare",
20730
- "solflare"
20731
- ))
20732
- return;
20733
- if (await trySilentSolana(
20734
- anyWin.backpack,
20735
- "backpack",
20736
- "Backpack",
20737
- "backpack"
20738
- ))
20739
- return;
20740
- if (await trySilentSolana(
20741
- anyWin.glow,
20742
- "glow",
20743
- "Glow",
20744
- "glow"
20745
- ))
20746
- return;
20747
- }
20748
- if (!chainType || chainType === "ethereum") {
20749
- const anyWin = win;
20750
- const allProviders = [];
20751
- const eip6963 = getEip6963Providers();
20752
- for (const { provider, walletId } of eip6963) {
20753
- allProviders.push({
20754
- provider,
20755
- walletId: walletId === "unknown" ? "default" : walletId
20756
- });
20757
- }
20758
- if (allProviders.length === 0) {
20759
- if (win.phantom?.ethereum) {
20760
- allProviders.push({
20761
- provider: win.phantom.ethereum,
20762
- walletId: "phantom"
20763
- });
20764
- }
20765
- if (anyWin.okxwallet) {
20766
- allProviders.push({
20767
- provider: anyWin.okxwallet,
20768
- walletId: "okx"
20769
- });
20770
- }
20771
- if (anyWin.coinbaseWalletExtension) {
20772
- allProviders.push({
20773
- provider: anyWin.coinbaseWalletExtension,
20774
- walletId: "coinbase"
20775
- });
20776
- }
20777
- if (win.ethereum) {
20778
- const isDuplicate = allProviders.some(
20779
- (p) => p.provider === win.ethereum
20780
- );
20781
- if (!isDuplicate) {
20782
- allProviders.push({
20783
- provider: win.ethereum,
20784
- walletId: "default"
20785
- });
20786
- }
20787
- }
20788
- }
20789
- for (const { provider, walletId } of allProviders) {
20790
- if (!provider) continue;
20791
- try {
20792
- const accounts = await provider.request({
20793
- method: "eth_accounts"
20794
- });
20795
- if (!accounts || accounts.length === 0) continue;
20796
- const address = accounts[0];
20797
- const resolved = identifyEthWallet(provider, anyWin, walletId);
20798
- if (mounted) {
20799
- setWallet({ ...resolved, address });
20800
- setIsLoading(false);
20801
- }
20802
- return;
20803
- } catch {
20804
- }
20805
- }
20806
- }
20807
- if (mounted) {
20808
- setWallet(null);
20809
- setIsLoading(false);
20810
- }
20811
- } catch (error) {
20812
- console.error("[BrowserWalletButton] Error detecting wallet:", error);
20813
- if (mounted) {
20814
- setWallet(null);
20815
- setIsLoading(false);
20816
- }
20817
- }
20818
- };
20819
- detectWallet();
20820
- const handleAccountsChanged = () => {
20821
- detectWallet();
20822
- };
20823
- const handleDisconnect = () => {
20824
- onDisconnectRef.current?.();
20825
- detectWallet();
20826
- };
20827
- const handleEthAccountsChanged = (accounts) => {
20828
- if (Array.isArray(accounts) && accounts.length === 0) {
20829
- onDisconnectRef.current?.();
20830
- }
20831
- detectWallet();
20832
- };
20833
- const solanaProvider = window.phantom?.solana || window.solana;
20834
- if (solanaProvider) {
20835
- solanaProvider.on("connect", handleAccountsChanged);
20836
- solanaProvider.on("disconnect", handleDisconnect);
20837
- solanaProvider.on("accountChanged", handleAccountsChanged);
20838
- }
20839
- const ethProviders = [];
20840
- for (const { provider } of getEip6963Providers()) {
20841
- const p = provider;
20842
- if (p && !ethProviders.includes(p)) {
20843
- ethProviders.push(p);
20844
- }
20845
- }
20846
- if (window.ethereum && !ethProviders.includes(window.ethereum)) {
20847
- ethProviders.push(window.ethereum);
20848
- }
20849
- if (window.phantom?.ethereum && !ethProviders.includes(window.phantom.ethereum)) {
20850
- ethProviders.push(window.phantom.ethereum);
20851
- }
20852
- for (const provider of ethProviders) {
20853
- provider.on("accountsChanged", handleEthAccountsChanged);
20854
- provider.on("chainChanged", handleAccountsChanged);
20855
- }
20856
- return () => {
20857
- mounted = false;
20858
- if (solanaProvider) {
20859
- solanaProvider.off("connect", handleAccountsChanged);
20860
- solanaProvider.off("disconnect", handleDisconnect);
20861
- solanaProvider.off("accountChanged", handleAccountsChanged);
20862
- }
20863
- for (const provider of ethProviders) {
20864
- const off = provider.off?.bind(provider) ?? provider.removeListener?.bind(provider);
20865
- if (off) {
20866
- off("accountsChanged", handleEthAccountsChanged);
20867
- off("chainChanged", handleAccountsChanged);
20868
- }
20869
- }
20870
- };
20871
- }, [chainType, eip6963ProviderCount]);
20872
20812
  const handleConnect = async () => {
20873
20813
  if (wallet) {
20874
20814
  onClick(wallet);
@@ -20952,7 +20892,7 @@ function BrowserWalletButton({
20952
20892
  border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
20953
20893
  };
20954
20894
  const sortedWallets = featuredWallets ? [...featuredWallets].sort((a, b) => a.position - b.position) : [];
20955
- 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], {
20956
20896
  size: 36,
20957
20897
  className: "uf-rounded-lg",
20958
20898
  variant: "color"
@@ -21214,6 +21154,7 @@ function CoinbaseConnect({
21214
21154
  onBack: parentOnBack,
21215
21155
  onDisconnect,
21216
21156
  skipToHoldings,
21157
+ canGoBack = true,
21217
21158
  onExecutionsChange
21218
21159
  }) {
21219
21160
  const { colors: colors2, fonts, components } = useTheme();
@@ -21601,6 +21542,16 @@ function CoinbaseConnect({
21601
21542
  setIsLoading(false);
21602
21543
  }
21603
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
+ };
21604
21555
  const handleBack = () => {
21605
21556
  switch (view) {
21606
21557
  case "select_exchange":
@@ -21661,7 +21612,7 @@ function CoinbaseConnect({
21661
21612
  DepositHeader,
21662
21613
  {
21663
21614
  title: t12.title,
21664
- showBack: true,
21615
+ showBack: canGoBack,
21665
21616
  onBack: handleBack,
21666
21617
  onClose
21667
21618
  }
@@ -21674,7 +21625,7 @@ function CoinbaseConnect({
21674
21625
  DepositHeader,
21675
21626
  {
21676
21627
  title: t12.title,
21677
- showBack: true,
21628
+ showBack: canGoBack,
21678
21629
  onBack: handleBack,
21679
21630
  onClose
21680
21631
  }
@@ -22386,7 +22337,7 @@ function CoinbaseConnect({
22386
22337
  borderRadius: components.button.borderRadius,
22387
22338
  fontFamily: fonts.medium
22388
22339
  },
22389
- onClick: onDisconnect,
22340
+ onClick: handleDisconnect,
22390
22341
  children: t12.disconnect
22391
22342
  }
22392
22343
  )
@@ -23173,7 +23124,7 @@ function ThemeStyleInjector({
23173
23124
  className
23174
23125
  }) {
23175
23126
  const { colors: colors2, fonts, mode } = useTheme();
23176
- const cssVars = React262.useMemo(() => {
23127
+ const cssVars = React272.useMemo(() => {
23177
23128
  const hexToHSL = (hex) => {
23178
23129
  hex = hex.replace("#", "");
23179
23130
  const r2 = parseInt(hex.slice(0, 2), 16) / 255;
@@ -23233,7 +23184,7 @@ function ThemeStyleInjector({
23233
23184
  ...fonts.regular ? { "--uf-font-family": fonts.regular } : {}
23234
23185
  };
23235
23186
  }, [colors2, fonts.regular]);
23236
- React262.useEffect(() => {
23187
+ React272.useEffect(() => {
23237
23188
  if (typeof document === "undefined") return;
23238
23189
  if (fonts.regular) {
23239
23190
  document.documentElement.style.setProperty(
@@ -24192,14 +24143,14 @@ function useCopyAddress() {
24192
24143
  return { copied, handleCopy };
24193
24144
  }
24194
24145
  var TooltipProvider2 = Provider;
24195
- var TooltipContext = React272.createContext({
24146
+ var TooltipContext = React282.createContext({
24196
24147
  open: false,
24197
24148
  onOpenChange: () => {
24198
24149
  }
24199
24150
  });
24200
- var TooltipTrigger2 = React272.forwardRef(({ onClick, ...props }, ref) => {
24201
- const { open, onOpenChange } = React272.useContext(TooltipContext);
24202
- const handleClick = React272.useCallback(
24151
+ var TooltipTrigger2 = React282.forwardRef(({ onClick, ...props }, ref) => {
24152
+ const { open, onOpenChange } = React282.useContext(TooltipContext);
24153
+ const handleClick = React282.useCallback(
24203
24154
  (e) => {
24204
24155
  onOpenChange(!open);
24205
24156
  onClick?.(e);
@@ -24209,7 +24160,7 @@ var TooltipTrigger2 = React272.forwardRef(({ onClick, ...props }, ref) => {
24209
24160
  return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Trigger, { ref, onClick: handleClick, ...props });
24210
24161
  });
24211
24162
  TooltipTrigger2.displayName = Trigger.displayName;
24212
- var TooltipContent2 = React272.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
24163
+ var TooltipContent2 = React282.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
24213
24164
  const { themeClass, colors: colors2 } = useTheme();
24214
24165
  return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Portal3, { children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
24215
24166
  Content22,
@@ -24814,7 +24765,7 @@ function TransferCryptoSingleInput({
24814
24765
  }
24815
24766
  var Select2 = Root23;
24816
24767
  var SelectValue2 = Value;
24817
- var SelectTrigger2 = React282.forwardRef(({ className, style, children, ...props }, ref) => {
24768
+ var SelectTrigger2 = React292.forwardRef(({ className, style, children, ...props }, ref) => {
24818
24769
  const { components } = useTheme();
24819
24770
  return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
24820
24771
  Trigger2,
@@ -24838,7 +24789,7 @@ var SelectTrigger2 = React282.forwardRef(({ className, style, children, ...props
24838
24789
  );
24839
24790
  });
24840
24791
  SelectTrigger2.displayName = Trigger2.displayName;
24841
- 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)(
24842
24793
  ScrollUpButton,
24843
24794
  {
24844
24795
  ref,
@@ -24851,7 +24802,7 @@ var SelectScrollUpButton2 = React282.forwardRef(({ className, ...props }, ref) =
24851
24802
  }
24852
24803
  ));
24853
24804
  SelectScrollUpButton2.displayName = ScrollUpButton.displayName;
24854
- 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)(
24855
24806
  ScrollDownButton,
24856
24807
  {
24857
24808
  ref,
@@ -24864,7 +24815,7 @@ var SelectScrollDownButton2 = React282.forwardRef(({ className, ...props }, ref)
24864
24815
  }
24865
24816
  ));
24866
24817
  SelectScrollDownButton2.displayName = ScrollDownButton.displayName;
24867
- var SelectContent2 = React282.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
24818
+ var SelectContent2 = React292.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
24868
24819
  const { themeClass, colors: colors2, components } = useTheme();
24869
24820
  return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Portal4, { children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
24870
24821
  Content23,
@@ -24902,7 +24853,7 @@ var SelectContent2 = React282.forwardRef(({ className, style, children, position
24902
24853
  ) });
24903
24854
  });
24904
24855
  SelectContent2.displayName = Content23.displayName;
24905
- 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)(
24906
24857
  Label,
24907
24858
  {
24908
24859
  ref,
@@ -24914,7 +24865,7 @@ var SelectLabel2 = React282.forwardRef(({ className, ...props }, ref) => /* @__P
24914
24865
  }
24915
24866
  ));
24916
24867
  SelectLabel2.displayName = Label.displayName;
24917
- 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)(
24918
24869
  Item,
24919
24870
  {
24920
24871
  ref,
@@ -24930,7 +24881,7 @@ var SelectItem2 = React282.forwardRef(({ className, children, ...props }, ref) =
24930
24881
  }
24931
24882
  ));
24932
24883
  SelectItem2.displayName = Item.displayName;
24933
- 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)(
24934
24885
  Separator,
24935
24886
  {
24936
24887
  ref,
@@ -26594,22 +26545,27 @@ function WalletConnect({
26594
26545
  productType,
26595
26546
  onBack: parentOnBack,
26596
26547
  onClose,
26548
+ canGoBack = true,
26549
+ depositWalletsLoading = false,
26597
26550
  onExecutionsChange
26598
26551
  }) {
26599
26552
  const { colors: colors2, fonts, components } = useTheme();
26600
- const walletProvidedAtMount = React292.useRef(!!initialWalletInfo && !!initialDepositWallet);
26601
- const [activeWalletInfo, setActiveWalletInfo] = React292.useState(initialWalletInfo ?? null);
26602
- 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);
26603
26556
  const initialView = initialWalletInfo && initialDepositWallet ? "select_token" : "select_wallet";
26604
- const [view, setView] = React292.useState(initialView);
26605
- const [isTransitioning, setIsTransitioning] = React292.useState(false);
26606
- const viewRef = React292.useRef(initialView);
26607
- const [selectedWalletDef, setSelectedWalletDef] = React292.useState(null);
26608
- const [connectingNetwork, setConnectingNetwork] = React292.useState(null);
26609
- const [walletError, setWalletError] = React292.useState(null);
26610
- const [isWalletConnecting, setIsWalletConnecting] = React292.useState(false);
26611
- const [eip6963ProviderCount, setEip6963ProviderCount] = React292.useState(0);
26612
- 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(() => {
26613
26569
  const store = getEip6963Store();
26614
26570
  if (!store) return;
26615
26571
  setEip6963ProviderCount(store.getProviders().length);
@@ -26617,20 +26573,44 @@ function WalletConnect({
26617
26573
  setEip6963ProviderCount(providers.length);
26618
26574
  });
26619
26575
  }, []);
26620
- const availableWallets = React292.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
26621
- const [balances, setBalances] = React292.useState([]);
26622
- const [isLoading, setIsLoading] = React292.useState(false);
26623
- const [selectedBalance, setSelectedBalance] = React292.useState(null);
26624
- const [totalBalanceUsd, setTotalBalanceUsd] = React292.useState(null);
26625
- const [error, setError] = React292.useState(null);
26626
- const [isDisconnectingWallet, setIsDisconnectingWallet] = React292.useState(false);
26627
- const [amountUsd, setAmountUsd] = React292.useState(prefillAmountUsd ?? "");
26628
- const [isConfirming, setIsConfirming] = React292.useState(false);
26629
- const [hasSignedTransaction, setHasSignedTransaction] = React292.useState(false);
26630
- const [tokenChainDetails, setTokenChainDetails] = React292.useState(null);
26631
- const [loadingTokenDetails, setLoadingTokenDetails] = React292.useState(false);
26632
- const [showTransactionDetails, setShowTransactionDetails] = React292.useState(false);
26633
- 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);
26634
26614
  const walletInfo = activeWalletInfo;
26635
26615
  const depositWallet = activeDepositWallet;
26636
26616
  const hasWallet = !!activeWalletInfo && !!activeDepositWallet;
@@ -26638,7 +26618,7 @@ function WalletConnect({
26638
26618
  const recipientAddress = activeDepositWallet?.address ?? "";
26639
26619
  const isCheckoutMode = !!checkoutAmountUsd;
26640
26620
  const supportedChainType = chainType === "algorand" || chainType === "xrpl" ? "ethereum" : chainType;
26641
- const transitionTo = React292.useCallback((nextView) => {
26621
+ const transitionTo = React302.useCallback((nextView) => {
26642
26622
  if (nextView === viewRef.current) return;
26643
26623
  setIsTransitioning(true);
26644
26624
  setTimeout(() => {
@@ -26775,7 +26755,7 @@ function WalletConnect({
26775
26755
  }
26776
26756
  };
26777
26757
  const selectedToken = selectedBalance ? getTokenFromBalance(selectedBalance) : null;
26778
- const effectiveDestinationAmount = React292.useMemo(() => {
26758
+ const effectiveDestinationAmount = React302.useMemo(() => {
26779
26759
  if (!checkoutRemainingBaseUnits || checkoutRemainingBaseUnits === "0") return "0";
26780
26760
  if (!checkoutAmountUsd) return checkoutRemainingBaseUnits;
26781
26761
  const remaining = BigInt(checkoutRemainingBaseUnits);
@@ -26803,7 +26783,7 @@ function WalletConnect({
26803
26783
  stablecoinParity,
26804
26784
  enabled: isCheckoutMode && !!selectedToken && !!checkoutDestination && effectiveDestinationAmount !== "0"
26805
26785
  });
26806
- const activeCheckoutQuote = React292.useMemo(() => {
26786
+ const activeCheckoutQuote = React302.useMemo(() => {
26807
26787
  if (!isCheckoutMode) return null;
26808
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 };
26809
26789
  return checkoutQuote ?? null;
@@ -26817,19 +26797,19 @@ function WalletConnect({
26817
26797
  onDepositSuccess,
26818
26798
  onDepositError
26819
26799
  });
26820
- React292.useEffect(() => {
26800
+ React302.useEffect(() => {
26821
26801
  onExecutionsChange?.(depositExecutions);
26822
26802
  }, [depositExecutions, onExecutionsChange]);
26823
- React292.useEffect(() => {
26803
+ React302.useEffect(() => {
26824
26804
  if (!prefillAmountUsd || !tokenChainDetails || view !== "enter_amount") return;
26825
26805
  const minDeposit = tokenChainDetails.minimum_deposit_amount_usd || 0;
26826
26806
  const currentAmount = parseFloat(amountUsd) || 0;
26827
26807
  if (currentAmount > 0 && currentAmount < minDeposit) setAmountUsd(minDeposit.toFixed(2));
26828
26808
  }, [tokenChainDetails, view, prefillAmountUsd]);
26829
- React292.useEffect(() => {
26809
+ React302.useEffect(() => {
26830
26810
  if (view === "review") setShowTransactionDetails(false);
26831
26811
  }, [view]);
26832
- React292.useEffect(() => {
26812
+ React302.useEffect(() => {
26833
26813
  if (view !== "enter_amount" && view !== "review" || !selectedBalance || !activeDepositWallet) return;
26834
26814
  let cancelled = false;
26835
26815
  const fetchTokenDetails = async () => {
@@ -26856,7 +26836,7 @@ function WalletConnect({
26856
26836
  cancelled = true;
26857
26837
  };
26858
26838
  }, [view, selectedBalance, publishableKey, activeDepositWallet]);
26859
- React292.useEffect(() => {
26839
+ React302.useEffect(() => {
26860
26840
  if (!activeWalletInfo || !activeDepositWallet) return;
26861
26841
  let cancelled = false;
26862
26842
  setIsLoading(true);
@@ -26889,20 +26869,20 @@ function WalletConnect({
26889
26869
  cancelled = true;
26890
26870
  };
26891
26871
  }, [activeWalletInfo?.address, activeDepositWallet?.chain_type, publishableKey]);
26892
- const usdToTokenRate = React292.useMemo(() => {
26872
+ const usdToTokenRate = React302.useMemo(() => {
26893
26873
  if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
26894
26874
  const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
26895
26875
  const balanceUsd = parseFloat(selectedBalance.amount_usd);
26896
26876
  if (balanceAmount === 0 || balanceUsd === 0) return 0;
26897
26877
  return balanceAmount / balanceUsd;
26898
26878
  }, [selectedBalance, selectedToken]);
26899
- const tokenAmount = React292.useMemo(() => {
26879
+ const tokenAmount = React302.useMemo(() => {
26900
26880
  if (isCheckoutMode && activeCheckoutQuote && selectedToken) return Number(activeCheckoutQuote.sourceAmount) / 10 ** activeCheckoutQuote.sourceTokenDecimals;
26901
26881
  const usdNum = parseFloat(amountUsd) || 0;
26902
26882
  if (usdNum === 0 || usdToTokenRate === 0) return 0;
26903
26883
  return usdNum * usdToTokenRate;
26904
26884
  }, [amountUsd, usdToTokenRate, isCheckoutMode, activeCheckoutQuote, selectedToken]);
26905
- React292.useEffect(() => {
26885
+ React302.useEffect(() => {
26906
26886
  if (isCheckoutMode && activeCheckoutQuote?.sourceAmountUsd && view === "enter_amount") setAmountUsd(activeCheckoutQuote.sourceAmountUsd);
26907
26887
  }, [isCheckoutMode, activeCheckoutQuote, view]);
26908
26888
  const maxTokenAmount = selectedBalance && selectedToken ? Number(selectedBalance.amount) / 10 ** selectedToken.decimals : 0;
@@ -26910,7 +26890,7 @@ function WalletConnect({
26910
26890
  const inputUsdNum = parseFloat(amountUsd) || 0;
26911
26891
  const minDepositUsd = tokenChainDetails?.minimum_deposit_amount_usd || 0;
26912
26892
  const isValidAmount = isCheckoutMode && activeCheckoutQuote ? tokenAmount > 0 && tokenAmount <= maxTokenAmount : inputUsdNum > 0 && inputUsdNum <= maxUsdAmount && inputUsdNum >= minDepositUsd;
26913
- const formattedTokenAmount = React292.useMemo(() => {
26893
+ const formattedTokenAmount = React302.useMemo(() => {
26914
26894
  if (tokenAmount === 0 || !selectedToken) return null;
26915
26895
  return `${tokenAmount.toFixed(6)} ${selectedToken.symbol}`.replace(/\.?0+$/, "");
26916
26896
  }, [tokenAmount, selectedToken]);
@@ -26958,16 +26938,25 @@ function WalletConnect({
26958
26938
  } catch (err) {
26959
26939
  console.warn("[WalletConnect] disconnect error:", err);
26960
26940
  } finally {
26961
- setActiveWalletInfo(null);
26962
- setActiveDepositWallet(null);
26963
- setSelectedBalance(null);
26964
- setBalances([]);
26965
- setTotalBalanceUsd(null);
26966
- setAmountUsd(prefillAmountUsd ?? "");
26967
- setError(null);
26968
26941
  setIsDisconnectingWallet(false);
26969
- if (onWalletDisconnect) onWalletDisconnect();
26970
- 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
+ }
26971
26960
  }
26972
26961
  };
26973
26962
  const handleReview = () => {
@@ -27093,9 +27082,15 @@ function WalletConnect({
27093
27082
  setIsConfirming(false);
27094
27083
  }
27095
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
+ }
27096
27091
  if (view === "select_wallet") {
27097
27092
  return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { style: viewTransitionStyle, children: [
27098
- /* @__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 }),
27099
27094
  /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "uf-pb-4", children: [
27100
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" }),
27101
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)(
@@ -27223,6 +27218,7 @@ function DepositModal({
27223
27218
  destinationChainType,
27224
27219
  destinationChainId,
27225
27220
  destinationTokenAddress,
27221
+ contractCalls,
27226
27222
  defaultSourceChainType,
27227
27223
  defaultSourceChainId,
27228
27224
  defaultSourceTokenAddress,
@@ -27257,8 +27253,19 @@ function DepositModal({
27257
27253
  if (s === "tracker" && hideDepositTracker) return "main";
27258
27254
  if (s === "cashapp" && !enableCashApp) return "main";
27259
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";
27260
27259
  return s;
27261
- }, [initialScreen, hideDepositTracker, enableCashApp, enableFiatOnramp]);
27260
+ }, [
27261
+ initialScreen,
27262
+ hideDepositTracker,
27263
+ enableCashApp,
27264
+ enableFiatOnramp,
27265
+ enablePayWithExchange,
27266
+ enableConnectExchange,
27267
+ enableConnectWallet
27268
+ ]);
27262
27269
  const [containerEl, setContainerEl] = (0, import_react8.useState)(null);
27263
27270
  const containerCallbackRef = (0, import_react8.useCallback)((el) => {
27264
27271
  setContainerEl(el);
@@ -27349,6 +27356,7 @@ function DepositModal({
27349
27356
  destinationChainType,
27350
27357
  destinationChainId,
27351
27358
  destinationTokenAddress,
27359
+ contractCalls,
27352
27360
  enabled: open
27353
27361
  // Only fetch when modal is open
27354
27362
  });
@@ -27381,6 +27389,12 @@ function DepositModal({
27381
27389
  setCardView("amount");
27382
27390
  }
27383
27391
  }, [view, showFiatOnramp]);
27392
+ (0, import_react8.useEffect)(() => {
27393
+ if (view === "exchange" && !showPayWithExchange) {
27394
+ setView("main");
27395
+ setExchangeView("providers");
27396
+ }
27397
+ }, [view, showPayWithExchange]);
27384
27398
  const { exchanges, isLoading: exchangesLoading } = useExchanges({
27385
27399
  publishableKey,
27386
27400
  enabled: open && showPayWithExchange
@@ -27500,7 +27514,7 @@ function DepositModal({
27500
27514
  setBrowserWalletChainType(void 0);
27501
27515
  setBrowserWalletInfo(null);
27502
27516
  setBrowserWalletModalOpen(false);
27503
- if (view === "wallet_connect") setView("main");
27517
+ if (view === "wallet_connect" && sessionOpenedFromMenu) setView("main");
27504
27518
  };
27505
27519
  const handleExchangeDisconnect = () => {
27506
27520
  const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
@@ -27509,7 +27523,7 @@ function DepositModal({
27509
27523
  }
27510
27524
  clearStoredIntegrationToken(IntegrationProvider.COINBASE);
27511
27525
  setConnectedExchange(null);
27512
- if (view === "coinbase_connect") setView("main");
27526
+ if (view === "coinbase_connect" && sessionOpenedFromMenu) setView("main");
27513
27527
  };
27514
27528
  const handleClose = () => {
27515
27529
  onOpenChange(false);
@@ -27521,6 +27535,7 @@ function DepositModal({
27521
27535
  setCardView("amount");
27522
27536
  setExchangeView("providers");
27523
27537
  setBrowserWalletInfo(null);
27538
+ setCoinbaseSkipToHoldings(false);
27524
27539
  resetViewTimeoutRef.current = null;
27525
27540
  }, 200);
27526
27541
  };
@@ -27535,6 +27550,7 @@ function DepositModal({
27535
27550
  setExchangeView("providers");
27536
27551
  setBrowserWalletInfo(null);
27537
27552
  setSelectedExecution(null);
27553
+ setCoinbaseSkipToHoldings(false);
27538
27554
  }, [open, effectiveInitialScreen]);
27539
27555
  (0, import_react8.useEffect)(
27540
27556
  () => () => {
@@ -27894,7 +27910,7 @@ function DepositModal({
27894
27910
  DepositHeader,
27895
27911
  {
27896
27912
  title: payWithExchangeTitle,
27897
- showBack: true,
27913
+ showBack: exchangeView === "pending" || sessionOpenedFromMenu,
27898
27914
  onBack: handleBack,
27899
27915
  onClose: handleClose
27900
27916
  }
@@ -27948,6 +27964,7 @@ function DepositModal({
27948
27964
  onClose: handleClose,
27949
27965
  onDisconnect: handleExchangeDisconnect,
27950
27966
  skipToHoldings: coinbaseSkipToHoldings,
27967
+ canGoBack: sessionOpenedFromMenu,
27951
27968
  onExecutionsChange: setDepositExecutions
27952
27969
  }
27953
27970
  ),
@@ -27985,7 +28002,9 @@ function DepositModal({
27985
28002
  setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
27986
28003
  },
27987
28004
  onBack: handleBack,
27988
- onClose: handleClose
28005
+ onClose: handleClose,
28006
+ canGoBack: sessionOpenedFromMenu,
28007
+ depositWalletsLoading: walletsLoading
27989
28008
  }
27990
28009
  ),
27991
28010
  depositPoweredByFooter
@@ -27994,7 +28013,7 @@ function DepositModal({
27994
28013
  DepositHeader,
27995
28014
  {
27996
28015
  title: cashAppView !== "amount" && cashAppAmount ? `Pay $${cashAppAmount} via Cash App` : "Pay with Cash App",
27997
- showBack: true,
28016
+ showBack: cashAppView !== "amount" || sessionOpenedFromMenu,
27998
28017
  onBack: handleBack,
27999
28018
  onClose: handleClose
28000
28019
  }
@@ -30682,6 +30701,7 @@ function UnifoldProvider2({
30682
30701
  destinationChainType: depositConfig.destinationChainType,
30683
30702
  destinationChainId: depositConfig.destinationChainId,
30684
30703
  destinationTokenAddress: depositConfig.destinationTokenAddress,
30704
+ contractCalls: depositConfig.contractCalls,
30685
30705
  defaultSourceChainType: depositConfig.defaultSourceChainType,
30686
30706
  defaultSourceChainId: depositConfig.defaultSourceChainId,
30687
30707
  defaultSourceTokenAddress: depositConfig.defaultSourceTokenAddress,