@unifold/ui-web 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.
Files changed (3) hide show
  1. package/dist/index.js +372 -359
  2. package/dist/index.mjs +372 -359
  3. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -37153,30 +37153,31 @@ var React102 = __toESM(require_react(), 1);
37153
37153
  var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
37154
37154
  var React112 = __toESM(require_react(), 1);
37155
37155
  var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
37156
- var React242 = __toESM(require_react(), 1);
37156
+ var React252 = __toESM(require_react(), 1);
37157
37157
  var React122 = __toESM(require_react(), 1);
37158
- var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
37159
37158
  var React132 = __toESM(require_react(), 1);
37160
- var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
37159
+ var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
37161
37160
  var React142 = __toESM(require_react(), 1);
37162
- var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
37161
+ var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
37163
37162
  var React152 = __toESM(require_react(), 1);
37164
- var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
37163
+ var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
37165
37164
  var React162 = __toESM(require_react(), 1);
37166
- var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
37165
+ var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
37167
37166
  var React172 = __toESM(require_react(), 1);
37168
- var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
37167
+ var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
37169
37168
  var React182 = __toESM(require_react(), 1);
37170
- var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
37169
+ var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
37171
37170
  var React192 = __toESM(require_react(), 1);
37172
- var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
37171
+ var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
37173
37172
  var React202 = __toESM(require_react(), 1);
37174
- var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
37173
+ var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
37175
37174
  var React212 = __toESM(require_react(), 1);
37176
- var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
37175
+ var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
37177
37176
  var React2222 = __toESM(require_react(), 1);
37178
- var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
37177
+ var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
37179
37178
  var React232 = __toESM(require_react(), 1);
37179
+ var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
37180
+ var React242 = __toESM(require_react(), 1);
37180
37181
  var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
37181
37182
  var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
37182
37183
  var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
@@ -37184,7 +37185,7 @@ var import_react18 = __toESM(require_react(), 1);
37184
37185
  var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
37185
37186
  var import_react19 = __toESM(require_react(), 1);
37186
37187
  var import_react20 = __toESM(require_react(), 1);
37187
- var React262 = __toESM(require_react(), 1);
37188
+ var React272 = __toESM(require_react(), 1);
37188
37189
  var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
37189
37190
  var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
37190
37191
  var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
@@ -37194,7 +37195,7 @@ var import_react22 = __toESM(require_react(), 1);
37194
37195
  var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
37195
37196
  var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
37196
37197
  var import_react23 = __toESM(require_react(), 1);
37197
- var React272 = __toESM(require_react(), 1);
37198
+ var React282 = __toESM(require_react(), 1);
37198
37199
  var React31 = __toESM(require_react(), 1);
37199
37200
  var React29 = __toESM(require_react(), 1);
37200
37201
  var React26 = __toESM(require_react(), 1);
@@ -37211,7 +37212,7 @@ var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
37211
37212
  var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
37212
37213
  var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
37213
37214
  var import_react25 = __toESM(require_react(), 1);
37214
- var React282 = __toESM(require_react(), 1);
37215
+ var React292 = __toESM(require_react(), 1);
37215
37216
  var React35 = __toESM(require_react(), 1);
37216
37217
  var ReactDOM4 = __toESM(require_react_dom(), 1);
37217
37218
  var import_react26 = __toESM(require_react(), 1);
@@ -37224,7 +37225,7 @@ var React34 = __toESM(require_react(), 1);
37224
37225
  var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
37225
37226
  var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
37226
37227
  var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
37227
- var React292 = __toESM(require_react(), 1);
37228
+ var React302 = __toESM(require_react(), 1);
37228
37229
  var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
37229
37230
  var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
37230
37231
  var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
@@ -55195,6 +55196,190 @@ function collectAllEip6963EthProviders() {
55195
55196
  if (!store) return [];
55196
55197
  return store.getProviders().map((d) => d.provider);
55197
55198
  }
55199
+ function identifyEthWallet(provider, hint) {
55200
+ switch (hint) {
55201
+ case "metamask":
55202
+ return { type: "metamask", name: "MetaMask", icon: "metamask" };
55203
+ case "phantom":
55204
+ return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
55205
+ case "coinbase":
55206
+ return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
55207
+ case "okx":
55208
+ return { type: "okx", name: "OKX Wallet", icon: "okx" };
55209
+ case "rabby":
55210
+ return { type: "rabby", name: "Rabby", icon: "rabby" };
55211
+ case "trust":
55212
+ return { type: "trust", name: "Trust Wallet", icon: "trust" };
55213
+ case "rainbow":
55214
+ return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
55215
+ }
55216
+ const anyProvider = provider;
55217
+ if (provider.isPhantom) {
55218
+ return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
55219
+ }
55220
+ if (anyProvider.isCoinbaseWallet) {
55221
+ return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
55222
+ }
55223
+ if (anyProvider.isRabby) {
55224
+ return { type: "rabby", name: "Rabby", icon: "rabby" };
55225
+ }
55226
+ if (anyProvider.isTrust) {
55227
+ return { type: "trust", name: "Trust Wallet", icon: "trust" };
55228
+ }
55229
+ if (anyProvider.isRainbow) {
55230
+ return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
55231
+ }
55232
+ if (provider.isMetaMask && !provider.isPhantom) {
55233
+ return { type: "metamask", name: "MetaMask", icon: "metamask" };
55234
+ }
55235
+ return { type: "metamask", name: "Wallet", icon: "metamask" };
55236
+ }
55237
+ async function detectConnectedBrowserWallet(chainType) {
55238
+ if (typeof window === "undefined") return null;
55239
+ if (getUserDisconnectedWallet()) return null;
55240
+ try {
55241
+ const win = window;
55242
+ if (!chainType || chainType === "solana") {
55243
+ const trySilentSolana = async (provider, type, name, icon) => {
55244
+ if (!provider) return null;
55245
+ if (provider.isConnected && provider.publicKey) {
55246
+ return { type, name, address: provider.publicKey.toString(), icon };
55247
+ }
55248
+ try {
55249
+ const resp = await provider.connect({ onlyIfTrusted: true });
55250
+ if (resp.publicKey) {
55251
+ return { type, name, address: resp.publicKey.toString(), icon };
55252
+ }
55253
+ } catch {
55254
+ }
55255
+ return null;
55256
+ };
55257
+ const solanaCandidates = [
55258
+ [win.phantom?.solana, "phantom-solana", "Phantom", "phantom"],
55259
+ [win.solflare, "solflare", "Solflare", "solflare"],
55260
+ [win.backpack, "backpack", "Backpack", "backpack"],
55261
+ [win.glow, "glow", "Glow", "glow"]
55262
+ ];
55263
+ for (const [provider, type, name, icon] of solanaCandidates) {
55264
+ const found = await trySilentSolana(provider, type, name, icon);
55265
+ if (found) return found;
55266
+ }
55267
+ }
55268
+ if (!chainType || chainType === "ethereum") {
55269
+ const allProviders = [];
55270
+ const eip6963 = getEip6963Providers();
55271
+ for (const { provider, walletId } of eip6963) {
55272
+ allProviders.push({
55273
+ provider,
55274
+ walletId: walletId === "unknown" ? "default" : walletId
55275
+ });
55276
+ }
55277
+ if (allProviders.length === 0) {
55278
+ if (win.phantom?.ethereum) {
55279
+ allProviders.push({ provider: win.phantom.ethereum, walletId: "phantom" });
55280
+ }
55281
+ if (win.okxwallet) {
55282
+ allProviders.push({ provider: win.okxwallet, walletId: "okx" });
55283
+ }
55284
+ if (win.coinbaseWalletExtension) {
55285
+ allProviders.push({ provider: win.coinbaseWalletExtension, walletId: "coinbase" });
55286
+ }
55287
+ if (win.ethereum && !allProviders.some((p) => p.provider === win.ethereum)) {
55288
+ allProviders.push({ provider: win.ethereum, walletId: "default" });
55289
+ }
55290
+ }
55291
+ for (const { provider, walletId } of allProviders) {
55292
+ if (!provider) continue;
55293
+ try {
55294
+ const accounts = await provider.request({ method: "eth_accounts" });
55295
+ if (!accounts || accounts.length === 0) continue;
55296
+ const resolved = identifyEthWallet(provider, walletId);
55297
+ return { ...resolved, address: accounts[0] };
55298
+ } catch {
55299
+ }
55300
+ }
55301
+ }
55302
+ } catch (error) {
55303
+ console.error("[detectConnectedBrowserWallet] detection error:", error);
55304
+ }
55305
+ return null;
55306
+ }
55307
+ function useDetectedBrowserWallet(opts = {}) {
55308
+ const { chainType, enabled = true, onDisconnect } = opts;
55309
+ const [wallet, setWallet] = React122.useState(null);
55310
+ const [isLoading, setIsLoading] = React122.useState(enabled);
55311
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React122.useState(0);
55312
+ const onDisconnectRef = React122.useRef(onDisconnect);
55313
+ onDisconnectRef.current = onDisconnect;
55314
+ React122.useEffect(() => {
55315
+ const store = getEip6963Store();
55316
+ if (!store) return;
55317
+ setEip6963ProviderCount(store.getProviders().length);
55318
+ return store.subscribe((providers) => setEip6963ProviderCount(providers.length));
55319
+ }, []);
55320
+ React122.useEffect(() => {
55321
+ if (!enabled) {
55322
+ setWallet(null);
55323
+ setIsLoading(false);
55324
+ return;
55325
+ }
55326
+ let mounted = true;
55327
+ const detect = async () => {
55328
+ if (!mounted) return;
55329
+ setIsLoading(true);
55330
+ const detected = await detectConnectedBrowserWallet(chainType);
55331
+ if (!mounted) return;
55332
+ setWallet(detected);
55333
+ setIsLoading(false);
55334
+ };
55335
+ detect();
55336
+ const onChange = () => detect();
55337
+ const onDisc = () => {
55338
+ onDisconnectRef.current?.();
55339
+ detect();
55340
+ };
55341
+ const onEthAccounts = (accounts) => {
55342
+ if (Array.isArray(accounts) && accounts.length === 0) onDisconnectRef.current?.();
55343
+ detect();
55344
+ };
55345
+ const win = typeof window !== "undefined" ? window : void 0;
55346
+ const solanaProvider = win?.phantom?.solana || win?.solana;
55347
+ if (solanaProvider) {
55348
+ solanaProvider.on("connect", onChange);
55349
+ solanaProvider.on("disconnect", onDisc);
55350
+ solanaProvider.on("accountChanged", onChange);
55351
+ }
55352
+ const ethProviders = [];
55353
+ for (const { provider } of getEip6963Providers()) {
55354
+ const p = provider;
55355
+ if (p && !ethProviders.includes(p)) ethProviders.push(p);
55356
+ }
55357
+ if (win?.ethereum && !ethProviders.includes(win.ethereum)) ethProviders.push(win.ethereum);
55358
+ if (win?.phantom?.ethereum && !ethProviders.includes(win.phantom.ethereum)) {
55359
+ ethProviders.push(win.phantom.ethereum);
55360
+ }
55361
+ for (const p of ethProviders) {
55362
+ p.on("accountsChanged", onEthAccounts);
55363
+ p.on("chainChanged", onChange);
55364
+ }
55365
+ return () => {
55366
+ mounted = false;
55367
+ if (solanaProvider) {
55368
+ solanaProvider.off?.("connect", onChange);
55369
+ solanaProvider.off?.("disconnect", onDisc);
55370
+ solanaProvider.off?.("accountChanged", onChange);
55371
+ }
55372
+ for (const p of ethProviders) {
55373
+ const off = p.off?.bind(p) ?? p.removeListener?.bind(p);
55374
+ if (off) {
55375
+ off("accountsChanged", onEthAccounts);
55376
+ off("chainChanged", onChange);
55377
+ }
55378
+ }
55379
+ };
55380
+ }, [chainType, eip6963ProviderCount, enabled]);
55381
+ return { wallet, isLoading, setWallet };
55382
+ }
55198
55383
  var SOLANA_DISCONNECT_TYPES = [
55199
55384
  "phantom-solana",
55200
55385
  "solflare",
@@ -55282,7 +55467,7 @@ function MetamaskIcon({
55282
55467
  className,
55283
55468
  variant = "color"
55284
55469
  }) {
55285
- const id = React122.useId();
55470
+ const id = React132.useId();
55286
55471
  if (variant === "light" || variant === "dark") {
55287
55472
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
55288
55473
  "svg",
@@ -55407,7 +55592,7 @@ function PhantomIcon({
55407
55592
  className,
55408
55593
  variant = "color"
55409
55594
  }) {
55410
- const id = React132.useId();
55595
+ const id = React142.useId();
55411
55596
  if (variant === "light") {
55412
55597
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
55413
55598
  "svg",
@@ -55478,7 +55663,7 @@ function CoinbaseIcon({
55478
55663
  className,
55479
55664
  variant = "color"
55480
55665
  }) {
55481
- const id = React142.useId();
55666
+ const id = React152.useId();
55482
55667
  if (variant === "light") {
55483
55668
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
55484
55669
  "svg",
@@ -55562,7 +55747,7 @@ function RabbyIcon({
55562
55747
  className,
55563
55748
  variant = "color"
55564
55749
  }) {
55565
- const id = React152.useId();
55750
+ const id = React162.useId();
55566
55751
  if (variant === "light") {
55567
55752
  return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
55568
55753
  "svg",
@@ -55913,7 +56098,7 @@ function RainbowIcon({
55913
56098
  className,
55914
56099
  variant = "color"
55915
56100
  }) {
55916
- const id = React162.useId();
56101
+ const id = React172.useId();
55917
56102
  if (variant === "light") {
55918
56103
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
55919
56104
  "svg",
@@ -56379,7 +56564,7 @@ function TrustIcon({
56379
56564
  className,
56380
56565
  variant = "color"
56381
56566
  }) {
56382
- const id = React172.useId();
56567
+ const id = React182.useId();
56383
56568
  if (variant === "light") {
56384
56569
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
56385
56570
  "svg",
@@ -56472,7 +56657,7 @@ function OkxIcon({
56472
56657
  className,
56473
56658
  variant = "color"
56474
56659
  }) {
56475
- const id = React182.useId();
56660
+ const id = React192.useId();
56476
56661
  if (variant === "light") {
56477
56662
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
56478
56663
  "svg",
@@ -56543,7 +56728,7 @@ function GlowIcon({
56543
56728
  className,
56544
56729
  variant = "color"
56545
56730
  }) {
56546
- const id = React192.useId();
56731
+ const id = React202.useId();
56547
56732
  if (variant === "light") {
56548
56733
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
56549
56734
  "svg",
@@ -56648,7 +56833,7 @@ function BackpackIcon({
56648
56833
  className,
56649
56834
  variant = "color"
56650
56835
  }) {
56651
- const id = React202.useId();
56836
+ const id = React212.useId();
56652
56837
  if (variant === "light") {
56653
56838
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
56654
56839
  "svg",
@@ -56725,7 +56910,7 @@ function SolflareIcon({
56725
56910
  className,
56726
56911
  variant = "color"
56727
56912
  }) {
56728
- const id = React212.useId();
56913
+ const id = React2222.useId();
56729
56914
  if (variant === "light") {
56730
56915
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
56731
56916
  "svg",
@@ -56796,7 +56981,7 @@ function EthereumIcon({
56796
56981
  className,
56797
56982
  variant = "color"
56798
56983
  }) {
56799
- const id = React2222.useId();
56984
+ const id = React232.useId();
56800
56985
  if (variant === "light") {
56801
56986
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
56802
56987
  "svg",
@@ -56930,7 +57115,7 @@ function SolanaIcon({
56930
57115
  className,
56931
57116
  variant = "color"
56932
57117
  }) {
56933
- const id = React232.useId();
57118
+ const id = React242.useId();
56934
57119
  if (variant === "light") {
56935
57120
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
56936
57121
  "svg",
@@ -57179,44 +57364,6 @@ function truncateAddress3(address) {
57179
57364
  if (address.length <= 10) return address;
57180
57365
  return `${address.slice(0, 4)}...${address.slice(-4)}`;
57181
57366
  }
57182
- function identifyEthWallet(provider, _win, hint) {
57183
- switch (hint) {
57184
- case "metamask":
57185
- return { type: "metamask", name: "MetaMask", icon: "metamask" };
57186
- case "phantom":
57187
- return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
57188
- case "coinbase":
57189
- return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
57190
- case "okx":
57191
- return { type: "okx", name: "OKX Wallet", icon: "okx" };
57192
- case "rabby":
57193
- return { type: "rabby", name: "Rabby", icon: "rabby" };
57194
- case "trust":
57195
- return { type: "trust", name: "Trust Wallet", icon: "trust" };
57196
- case "rainbow":
57197
- return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
57198
- }
57199
- const anyProvider = provider;
57200
- if (provider.isPhantom) {
57201
- return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
57202
- }
57203
- if (anyProvider.isCoinbaseWallet) {
57204
- return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
57205
- }
57206
- if (anyProvider.isRabby) {
57207
- return { type: "rabby", name: "Rabby", icon: "rabby" };
57208
- }
57209
- if (anyProvider.isTrust) {
57210
- return { type: "trust", name: "Trust Wallet", icon: "trust" };
57211
- }
57212
- if (anyProvider.isRainbow) {
57213
- return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
57214
- }
57215
- if (provider.isMetaMask && !provider.isPhantom) {
57216
- return { type: "metamask", name: "MetaMask", icon: "metamask" };
57217
- }
57218
- return { type: "metamask", name: "Wallet", icon: "metamask" };
57219
- }
57220
57367
  function BrowserWalletButton({
57221
57368
  onClick,
57222
57369
  onConnectClick,
@@ -57227,30 +57374,19 @@ function BrowserWalletButton({
57227
57374
  subtitle = i18n2.depositModal.browserWallet.subtitle
57228
57375
  }) {
57229
57376
  const { colors: colors2, fonts, components } = useTheme();
57230
- const [isHovered, setIsHovered] = React242.useState(false);
57231
- const [isTouchDevice, setIsTouchDevice] = React242.useState(false);
57232
- const [wallet, setWallet] = React242.useState(null);
57233
- const [isLoading, setIsLoading] = React242.useState(true);
57234
- const [isConnecting, setIsConnecting] = React242.useState(false);
57235
- const [balanceText, setBalanceText] = React242.useState(null);
57236
- const [isLoadingBalance, setIsLoadingBalance] = React242.useState(false);
57237
- const [isDisconnecting, setIsDisconnecting] = React242.useState(false);
57238
- const onDisconnectRef = React242.useRef(onDisconnect);
57377
+ const [isHovered, setIsHovered] = React252.useState(false);
57378
+ const [isTouchDevice, setIsTouchDevice] = React252.useState(false);
57379
+ const { wallet, isLoading, setWallet } = useDetectedBrowserWallet({ chainType, onDisconnect });
57380
+ const [isConnecting, setIsConnecting] = React252.useState(false);
57381
+ const [balanceText, setBalanceText] = React252.useState(null);
57382
+ const [isLoadingBalance, setIsLoadingBalance] = React252.useState(false);
57383
+ const [isDisconnecting, setIsDisconnecting] = React252.useState(false);
57384
+ const onDisconnectRef = React252.useRef(onDisconnect);
57239
57385
  onDisconnectRef.current = onDisconnect;
57240
- React242.useEffect(() => {
57386
+ React252.useEffect(() => {
57241
57387
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
57242
57388
  }, []);
57243
- const [eip6963ProviderCount, setEip6963ProviderCount] = React242.useState(0);
57244
- React242.useEffect(() => {
57245
- const store = getEip6963Store();
57246
- if (!store) return;
57247
- setEip6963ProviderCount(store.getProviders().length);
57248
- const unsubscribe = store.subscribe((providers) => {
57249
- setEip6963ProviderCount(providers.length);
57250
- });
57251
- return unsubscribe;
57252
- }, []);
57253
- React242.useEffect(() => {
57389
+ React252.useEffect(() => {
57254
57390
  if (!wallet || !publishableKey) {
57255
57391
  setBalanceText(null);
57256
57392
  return;
@@ -57291,206 +57427,6 @@ function BrowserWalletButton({
57291
57427
  cancelled = true;
57292
57428
  };
57293
57429
  }, [wallet, publishableKey]);
57294
- React242.useEffect(() => {
57295
- let mounted = true;
57296
- const detectWallet = async () => {
57297
- if (!mounted) return;
57298
- setIsLoading(true);
57299
- try {
57300
- const win = typeof window !== "undefined" ? window : null;
57301
- if (!win) return;
57302
- if (getUserDisconnectedWallet()) {
57303
- if (mounted) {
57304
- setWallet(null);
57305
- setIsLoading(false);
57306
- }
57307
- return;
57308
- }
57309
- if (!chainType || chainType === "solana") {
57310
- const anyWin = win;
57311
- const trySilentSolana = async (provider, type, name, icon) => {
57312
- if (!provider) return false;
57313
- if (provider.isConnected && provider.publicKey) {
57314
- if (mounted) {
57315
- setWallet({
57316
- type,
57317
- name,
57318
- address: provider.publicKey.toString(),
57319
- icon
57320
- });
57321
- setIsLoading(false);
57322
- }
57323
- return true;
57324
- }
57325
- try {
57326
- const resp = await provider.connect({ onlyIfTrusted: true });
57327
- if (mounted && resp.publicKey) {
57328
- setWallet({
57329
- type,
57330
- name,
57331
- address: resp.publicKey.toString(),
57332
- icon
57333
- });
57334
- setIsLoading(false);
57335
- return true;
57336
- }
57337
- } catch {
57338
- }
57339
- return false;
57340
- };
57341
- if (await trySilentSolana(
57342
- win.phantom?.solana,
57343
- "phantom-solana",
57344
- "Phantom",
57345
- "phantom"
57346
- ))
57347
- return;
57348
- if (await trySilentSolana(
57349
- anyWin.solflare,
57350
- "solflare",
57351
- "Solflare",
57352
- "solflare"
57353
- ))
57354
- return;
57355
- if (await trySilentSolana(
57356
- anyWin.backpack,
57357
- "backpack",
57358
- "Backpack",
57359
- "backpack"
57360
- ))
57361
- return;
57362
- if (await trySilentSolana(
57363
- anyWin.glow,
57364
- "glow",
57365
- "Glow",
57366
- "glow"
57367
- ))
57368
- return;
57369
- }
57370
- if (!chainType || chainType === "ethereum") {
57371
- const anyWin = win;
57372
- const allProviders = [];
57373
- const eip6963 = getEip6963Providers();
57374
- for (const { provider, walletId } of eip6963) {
57375
- allProviders.push({
57376
- provider,
57377
- walletId: walletId === "unknown" ? "default" : walletId
57378
- });
57379
- }
57380
- if (allProviders.length === 0) {
57381
- if (win.phantom?.ethereum) {
57382
- allProviders.push({
57383
- provider: win.phantom.ethereum,
57384
- walletId: "phantom"
57385
- });
57386
- }
57387
- if (anyWin.okxwallet) {
57388
- allProviders.push({
57389
- provider: anyWin.okxwallet,
57390
- walletId: "okx"
57391
- });
57392
- }
57393
- if (anyWin.coinbaseWalletExtension) {
57394
- allProviders.push({
57395
- provider: anyWin.coinbaseWalletExtension,
57396
- walletId: "coinbase"
57397
- });
57398
- }
57399
- if (win.ethereum) {
57400
- const isDuplicate = allProviders.some(
57401
- (p) => p.provider === win.ethereum
57402
- );
57403
- if (!isDuplicate) {
57404
- allProviders.push({
57405
- provider: win.ethereum,
57406
- walletId: "default"
57407
- });
57408
- }
57409
- }
57410
- }
57411
- for (const { provider, walletId } of allProviders) {
57412
- if (!provider) continue;
57413
- try {
57414
- const accounts = await provider.request({
57415
- method: "eth_accounts"
57416
- });
57417
- if (!accounts || accounts.length === 0) continue;
57418
- const address = accounts[0];
57419
- const resolved = identifyEthWallet(provider, anyWin, walletId);
57420
- if (mounted) {
57421
- setWallet({ ...resolved, address });
57422
- setIsLoading(false);
57423
- }
57424
- return;
57425
- } catch {
57426
- }
57427
- }
57428
- }
57429
- if (mounted) {
57430
- setWallet(null);
57431
- setIsLoading(false);
57432
- }
57433
- } catch (error) {
57434
- console.error("[BrowserWalletButton] Error detecting wallet:", error);
57435
- if (mounted) {
57436
- setWallet(null);
57437
- setIsLoading(false);
57438
- }
57439
- }
57440
- };
57441
- detectWallet();
57442
- const handleAccountsChanged = () => {
57443
- detectWallet();
57444
- };
57445
- const handleDisconnect = () => {
57446
- onDisconnectRef.current?.();
57447
- detectWallet();
57448
- };
57449
- const handleEthAccountsChanged = (accounts) => {
57450
- if (Array.isArray(accounts) && accounts.length === 0) {
57451
- onDisconnectRef.current?.();
57452
- }
57453
- detectWallet();
57454
- };
57455
- const solanaProvider = window.phantom?.solana || window.solana;
57456
- if (solanaProvider) {
57457
- solanaProvider.on("connect", handleAccountsChanged);
57458
- solanaProvider.on("disconnect", handleDisconnect);
57459
- solanaProvider.on("accountChanged", handleAccountsChanged);
57460
- }
57461
- const ethProviders = [];
57462
- for (const { provider } of getEip6963Providers()) {
57463
- const p = provider;
57464
- if (p && !ethProviders.includes(p)) {
57465
- ethProviders.push(p);
57466
- }
57467
- }
57468
- if (window.ethereum && !ethProviders.includes(window.ethereum)) {
57469
- ethProviders.push(window.ethereum);
57470
- }
57471
- if (window.phantom?.ethereum && !ethProviders.includes(window.phantom.ethereum)) {
57472
- ethProviders.push(window.phantom.ethereum);
57473
- }
57474
- for (const provider of ethProviders) {
57475
- provider.on("accountsChanged", handleEthAccountsChanged);
57476
- provider.on("chainChanged", handleAccountsChanged);
57477
- }
57478
- return () => {
57479
- mounted = false;
57480
- if (solanaProvider) {
57481
- solanaProvider.off("connect", handleAccountsChanged);
57482
- solanaProvider.off("disconnect", handleDisconnect);
57483
- solanaProvider.off("accountChanged", handleAccountsChanged);
57484
- }
57485
- for (const provider of ethProviders) {
57486
- const off = provider.off?.bind(provider) ?? provider.removeListener?.bind(provider);
57487
- if (off) {
57488
- off("accountsChanged", handleEthAccountsChanged);
57489
- off("chainChanged", handleAccountsChanged);
57490
- }
57491
- }
57492
- };
57493
- }, [chainType, eip6963ProviderCount]);
57494
57430
  const handleConnect = async () => {
57495
57431
  if (wallet) {
57496
57432
  onClick(wallet);
@@ -57574,7 +57510,7 @@ function BrowserWalletButton({
57574
57510
  border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
57575
57511
  };
57576
57512
  const sortedWallets = featuredWallets ? [...featuredWallets].sort((a, b) => a.position - b.position) : [];
57577
- const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React242.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
57513
+ const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React252.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
57578
57514
  size: 36,
57579
57515
  className: "uf-rounded-lg",
57580
57516
  variant: "color"
@@ -57836,6 +57772,7 @@ function CoinbaseConnect({
57836
57772
  onBack: parentOnBack,
57837
57773
  onDisconnect,
57838
57774
  skipToHoldings,
57775
+ canGoBack = true,
57839
57776
  onExecutionsChange
57840
57777
  }) {
57841
57778
  const { colors: colors2, fonts, components } = useTheme();
@@ -58223,6 +58160,16 @@ function CoinbaseConnect({
58223
58160
  setIsLoading(false);
58224
58161
  }
58225
58162
  };
58163
+ const handleDisconnect = () => {
58164
+ onDisconnect?.();
58165
+ if (!canGoBack) {
58166
+ setAccessToken(null);
58167
+ setHoldings([]);
58168
+ setSelectedHolding(null);
58169
+ setSelectedAsset(null);
58170
+ transitionTo("select_exchange");
58171
+ }
58172
+ };
58226
58173
  const handleBack = () => {
58227
58174
  switch (view) {
58228
58175
  case "select_exchange":
@@ -58283,7 +58230,7 @@ function CoinbaseConnect({
58283
58230
  DepositHeader,
58284
58231
  {
58285
58232
  title: t12.title,
58286
- showBack: true,
58233
+ showBack: canGoBack,
58287
58234
  onBack: handleBack,
58288
58235
  onClose
58289
58236
  }
@@ -58296,7 +58243,7 @@ function CoinbaseConnect({
58296
58243
  DepositHeader,
58297
58244
  {
58298
58245
  title: t12.title,
58299
- showBack: true,
58246
+ showBack: canGoBack,
58300
58247
  onBack: handleBack,
58301
58248
  onClose
58302
58249
  }
@@ -59008,7 +58955,7 @@ function CoinbaseConnect({
59008
58955
  borderRadius: components.button.borderRadius,
59009
58956
  fontFamily: fonts.medium
59010
58957
  },
59011
- onClick: onDisconnect,
58958
+ onClick: handleDisconnect,
59012
58959
  children: t12.disconnect
59013
58960
  }
59014
58961
  )
@@ -59795,7 +59742,7 @@ function ThemeStyleInjector({
59795
59742
  className
59796
59743
  }) {
59797
59744
  const { colors: colors2, fonts, mode } = useTheme();
59798
- const cssVars = React262.useMemo(() => {
59745
+ const cssVars = React272.useMemo(() => {
59799
59746
  const hexToHSL = (hex) => {
59800
59747
  hex = hex.replace("#", "");
59801
59748
  const r2 = parseInt(hex.slice(0, 2), 16) / 255;
@@ -59855,7 +59802,7 @@ function ThemeStyleInjector({
59855
59802
  ...fonts.regular ? { "--uf-font-family": fonts.regular } : {}
59856
59803
  };
59857
59804
  }, [colors2, fonts.regular]);
59858
- React262.useEffect(() => {
59805
+ React272.useEffect(() => {
59859
59806
  if (typeof document === "undefined") return;
59860
59807
  if (fonts.regular) {
59861
59808
  document.documentElement.style.setProperty(
@@ -60814,14 +60761,14 @@ function useCopyAddress() {
60814
60761
  return { copied, handleCopy };
60815
60762
  }
60816
60763
  var TooltipProvider2 = Provider;
60817
- var TooltipContext = React272.createContext({
60764
+ var TooltipContext = React282.createContext({
60818
60765
  open: false,
60819
60766
  onOpenChange: () => {
60820
60767
  }
60821
60768
  });
60822
- var TooltipTrigger2 = React272.forwardRef(({ onClick, ...props }, ref) => {
60823
- const { open, onOpenChange } = React272.useContext(TooltipContext);
60824
- const handleClick = React272.useCallback(
60769
+ var TooltipTrigger2 = React282.forwardRef(({ onClick, ...props }, ref) => {
60770
+ const { open, onOpenChange } = React282.useContext(TooltipContext);
60771
+ const handleClick = React282.useCallback(
60825
60772
  (e) => {
60826
60773
  onOpenChange(!open);
60827
60774
  onClick?.(e);
@@ -60831,7 +60778,7 @@ var TooltipTrigger2 = React272.forwardRef(({ onClick, ...props }, ref) => {
60831
60778
  return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Trigger, { ref, onClick: handleClick, ...props });
60832
60779
  });
60833
60780
  TooltipTrigger2.displayName = Trigger.displayName;
60834
- var TooltipContent2 = React272.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
60781
+ var TooltipContent2 = React282.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
60835
60782
  const { themeClass, colors: colors2 } = useTheme();
60836
60783
  return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Portal3, { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
60837
60784
  Content22,
@@ -61436,7 +61383,7 @@ function TransferCryptoSingleInput({
61436
61383
  }
61437
61384
  var Select2 = Root23;
61438
61385
  var SelectValue2 = Value;
61439
- var SelectTrigger2 = React282.forwardRef(({ className, style, children, ...props }, ref) => {
61386
+ var SelectTrigger2 = React292.forwardRef(({ className, style, children, ...props }, ref) => {
61440
61387
  const { components } = useTheme();
61441
61388
  return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61442
61389
  Trigger2,
@@ -61460,7 +61407,7 @@ var SelectTrigger2 = React282.forwardRef(({ className, style, children, ...props
61460
61407
  );
61461
61408
  });
61462
61409
  SelectTrigger2.displayName = Trigger2.displayName;
61463
- var SelectScrollUpButton2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61410
+ var SelectScrollUpButton2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61464
61411
  ScrollUpButton,
61465
61412
  {
61466
61413
  ref,
@@ -61473,7 +61420,7 @@ var SelectScrollUpButton2 = React282.forwardRef(({ className, ...props }, ref) =
61473
61420
  }
61474
61421
  ));
61475
61422
  SelectScrollUpButton2.displayName = ScrollUpButton.displayName;
61476
- var SelectScrollDownButton2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61423
+ var SelectScrollDownButton2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61477
61424
  ScrollDownButton,
61478
61425
  {
61479
61426
  ref,
@@ -61486,7 +61433,7 @@ var SelectScrollDownButton2 = React282.forwardRef(({ className, ...props }, ref)
61486
61433
  }
61487
61434
  ));
61488
61435
  SelectScrollDownButton2.displayName = ScrollDownButton.displayName;
61489
- var SelectContent2 = React282.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
61436
+ var SelectContent2 = React292.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
61490
61437
  const { themeClass, colors: colors2, components } = useTheme();
61491
61438
  return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Portal4, { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61492
61439
  Content23,
@@ -61524,7 +61471,7 @@ var SelectContent2 = React282.forwardRef(({ className, style, children, position
61524
61471
  ) });
61525
61472
  });
61526
61473
  SelectContent2.displayName = Content23.displayName;
61527
- var SelectLabel2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61474
+ var SelectLabel2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61528
61475
  Label,
61529
61476
  {
61530
61477
  ref,
@@ -61536,7 +61483,7 @@ var SelectLabel2 = React282.forwardRef(({ className, ...props }, ref) => /* @__P
61536
61483
  }
61537
61484
  ));
61538
61485
  SelectLabel2.displayName = Label.displayName;
61539
- var SelectItem2 = React282.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61486
+ var SelectItem2 = React292.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61540
61487
  Item,
61541
61488
  {
61542
61489
  ref,
@@ -61552,7 +61499,7 @@ var SelectItem2 = React282.forwardRef(({ className, children, ...props }, ref) =
61552
61499
  }
61553
61500
  ));
61554
61501
  SelectItem2.displayName = Item.displayName;
61555
- var SelectSeparator2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61502
+ var SelectSeparator2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61556
61503
  Separator,
61557
61504
  {
61558
61505
  ref,
@@ -63216,22 +63163,27 @@ function WalletConnect({
63216
63163
  productType,
63217
63164
  onBack: parentOnBack,
63218
63165
  onClose,
63166
+ canGoBack = true,
63167
+ depositWalletsLoading = false,
63219
63168
  onExecutionsChange
63220
63169
  }) {
63221
63170
  const { colors: colors2, fonts, components } = useTheme();
63222
- const walletProvidedAtMount = React292.useRef(!!initialWalletInfo && !!initialDepositWallet);
63223
- const [activeWalletInfo, setActiveWalletInfo] = React292.useState(initialWalletInfo ?? null);
63224
- const [activeDepositWallet, setActiveDepositWallet] = React292.useState(initialDepositWallet ?? null);
63171
+ const walletProvidedAtMount = React302.useRef(!!initialWalletInfo && !!initialDepositWallet);
63172
+ const [activeWalletInfo, setActiveWalletInfo] = React302.useState(initialWalletInfo ?? null);
63173
+ const [activeDepositWallet, setActiveDepositWallet] = React302.useState(initialDepositWallet ?? null);
63225
63174
  const initialView = initialWalletInfo && initialDepositWallet ? "select_token" : "select_wallet";
63226
- const [view, setView] = React292.useState(initialView);
63227
- const [isTransitioning, setIsTransitioning] = React292.useState(false);
63228
- const viewRef = React292.useRef(initialView);
63229
- const [selectedWalletDef, setSelectedWalletDef] = React292.useState(null);
63230
- const [connectingNetwork, setConnectingNetwork] = React292.useState(null);
63231
- const [walletError, setWalletError] = React292.useState(null);
63232
- const [isWalletConnecting, setIsWalletConnecting] = React292.useState(false);
63233
- const [eip6963ProviderCount, setEip6963ProviderCount] = React292.useState(0);
63234
- React292.useEffect(() => {
63175
+ const [view, setView] = React302.useState(initialView);
63176
+ const [isTransitioning, setIsTransitioning] = React302.useState(false);
63177
+ const viewRef = React302.useRef(initialView);
63178
+ const standalone = !canGoBack && !walletProvidedAtMount.current;
63179
+ const { wallet: detectedWallet, isLoading: detectingWallet } = useDetectedBrowserWallet({ enabled: standalone });
63180
+ const [autoResolved, setAutoResolved] = React302.useState(false);
63181
+ const [selectedWalletDef, setSelectedWalletDef] = React302.useState(null);
63182
+ const [connectingNetwork, setConnectingNetwork] = React302.useState(null);
63183
+ const [walletError, setWalletError] = React302.useState(null);
63184
+ const [isWalletConnecting, setIsWalletConnecting] = React302.useState(false);
63185
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React302.useState(0);
63186
+ React302.useEffect(() => {
63235
63187
  const store = getEip6963Store();
63236
63188
  if (!store) return;
63237
63189
  setEip6963ProviderCount(store.getProviders().length);
@@ -63239,20 +63191,44 @@ function WalletConnect({
63239
63191
  setEip6963ProviderCount(providers.length);
63240
63192
  });
63241
63193
  }, []);
63242
- const availableWallets = React292.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
63243
- const [balances, setBalances] = React292.useState([]);
63244
- const [isLoading, setIsLoading] = React292.useState(false);
63245
- const [selectedBalance, setSelectedBalance] = React292.useState(null);
63246
- const [totalBalanceUsd, setTotalBalanceUsd] = React292.useState(null);
63247
- const [error, setError] = React292.useState(null);
63248
- const [isDisconnectingWallet, setIsDisconnectingWallet] = React292.useState(false);
63249
- const [amountUsd, setAmountUsd] = React292.useState(prefillAmountUsd ?? "");
63250
- const [isConfirming, setIsConfirming] = React292.useState(false);
63251
- const [hasSignedTransaction, setHasSignedTransaction] = React292.useState(false);
63252
- const [tokenChainDetails, setTokenChainDetails] = React292.useState(null);
63253
- const [loadingTokenDetails, setLoadingTokenDetails] = React292.useState(false);
63254
- const [showTransactionDetails, setShowTransactionDetails] = React292.useState(false);
63255
- const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React292.useState(null);
63194
+ const availableWallets = React302.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
63195
+ React302.useEffect(() => {
63196
+ if (!standalone || autoResolved || detectingWallet) return;
63197
+ if (!detectedWallet) {
63198
+ setAutoResolved(true);
63199
+ return;
63200
+ }
63201
+ const wct = detectedWallet.type === "phantom-solana" || detectedWallet.type === "solflare" || detectedWallet.type === "backpack" || detectedWallet.type === "glow" ? "solana" : "ethereum";
63202
+ const matching = depositWallets?.find((w) => w.chain_type === wct);
63203
+ if (!matching) {
63204
+ if (!depositWalletsLoading) setAutoResolved(true);
63205
+ return;
63206
+ }
63207
+ setActiveWalletInfo(detectedWallet);
63208
+ setActiveDepositWallet(matching);
63209
+ onWalletConnected?.(detectedWallet, matching);
63210
+ setView("select_token");
63211
+ viewRef.current = "select_token";
63212
+ setAutoResolved(true);
63213
+ }, [standalone, autoResolved, detectingWallet, detectedWallet, depositWallets, depositWalletsLoading]);
63214
+ React302.useEffect(() => {
63215
+ if (!standalone || autoResolved) return;
63216
+ const t12 = setTimeout(() => setAutoResolved(true), 5e3);
63217
+ return () => clearTimeout(t12);
63218
+ }, [standalone, autoResolved]);
63219
+ const [balances, setBalances] = React302.useState([]);
63220
+ const [isLoading, setIsLoading] = React302.useState(false);
63221
+ const [selectedBalance, setSelectedBalance] = React302.useState(null);
63222
+ const [totalBalanceUsd, setTotalBalanceUsd] = React302.useState(null);
63223
+ const [error, setError] = React302.useState(null);
63224
+ const [isDisconnectingWallet, setIsDisconnectingWallet] = React302.useState(false);
63225
+ const [amountUsd, setAmountUsd] = React302.useState(prefillAmountUsd ?? "");
63226
+ const [isConfirming, setIsConfirming] = React302.useState(false);
63227
+ const [hasSignedTransaction, setHasSignedTransaction] = React302.useState(false);
63228
+ const [tokenChainDetails, setTokenChainDetails] = React302.useState(null);
63229
+ const [loadingTokenDetails, setLoadingTokenDetails] = React302.useState(false);
63230
+ const [showTransactionDetails, setShowTransactionDetails] = React302.useState(false);
63231
+ const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React302.useState(null);
63256
63232
  const walletInfo = activeWalletInfo;
63257
63233
  const depositWallet = activeDepositWallet;
63258
63234
  const hasWallet = !!activeWalletInfo && !!activeDepositWallet;
@@ -63260,7 +63236,7 @@ function WalletConnect({
63260
63236
  const recipientAddress = activeDepositWallet?.address ?? "";
63261
63237
  const isCheckoutMode = !!checkoutAmountUsd;
63262
63238
  const supportedChainType = chainType === "algorand" || chainType === "xrpl" ? "ethereum" : chainType;
63263
- const transitionTo = React292.useCallback((nextView) => {
63239
+ const transitionTo = React302.useCallback((nextView) => {
63264
63240
  if (nextView === viewRef.current) return;
63265
63241
  setIsTransitioning(true);
63266
63242
  setTimeout(() => {
@@ -63397,7 +63373,7 @@ function WalletConnect({
63397
63373
  }
63398
63374
  };
63399
63375
  const selectedToken = selectedBalance ? getTokenFromBalance(selectedBalance) : null;
63400
- const effectiveDestinationAmount = React292.useMemo(() => {
63376
+ const effectiveDestinationAmount = React302.useMemo(() => {
63401
63377
  if (!checkoutRemainingBaseUnits || checkoutRemainingBaseUnits === "0") return "0";
63402
63378
  if (!checkoutAmountUsd) return checkoutRemainingBaseUnits;
63403
63379
  const remaining = BigInt(checkoutRemainingBaseUnits);
@@ -63425,7 +63401,7 @@ function WalletConnect({
63425
63401
  stablecoinParity,
63426
63402
  enabled: isCheckoutMode && !!selectedToken && !!checkoutDestination && effectiveDestinationAmount !== "0"
63427
63403
  });
63428
- const activeCheckoutQuote = React292.useMemo(() => {
63404
+ const activeCheckoutQuote = React302.useMemo(() => {
63429
63405
  if (!isCheckoutMode) return null;
63430
63406
  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 };
63431
63407
  return checkoutQuote ?? null;
@@ -63439,19 +63415,19 @@ function WalletConnect({
63439
63415
  onDepositSuccess,
63440
63416
  onDepositError
63441
63417
  });
63442
- React292.useEffect(() => {
63418
+ React302.useEffect(() => {
63443
63419
  onExecutionsChange?.(depositExecutions);
63444
63420
  }, [depositExecutions, onExecutionsChange]);
63445
- React292.useEffect(() => {
63421
+ React302.useEffect(() => {
63446
63422
  if (!prefillAmountUsd || !tokenChainDetails || view !== "enter_amount") return;
63447
63423
  const minDeposit = tokenChainDetails.minimum_deposit_amount_usd || 0;
63448
63424
  const currentAmount = parseFloat(amountUsd) || 0;
63449
63425
  if (currentAmount > 0 && currentAmount < minDeposit) setAmountUsd(minDeposit.toFixed(2));
63450
63426
  }, [tokenChainDetails, view, prefillAmountUsd]);
63451
- React292.useEffect(() => {
63427
+ React302.useEffect(() => {
63452
63428
  if (view === "review") setShowTransactionDetails(false);
63453
63429
  }, [view]);
63454
- React292.useEffect(() => {
63430
+ React302.useEffect(() => {
63455
63431
  if (view !== "enter_amount" && view !== "review" || !selectedBalance || !activeDepositWallet) return;
63456
63432
  let cancelled = false;
63457
63433
  const fetchTokenDetails = async () => {
@@ -63478,7 +63454,7 @@ function WalletConnect({
63478
63454
  cancelled = true;
63479
63455
  };
63480
63456
  }, [view, selectedBalance, publishableKey, activeDepositWallet]);
63481
- React292.useEffect(() => {
63457
+ React302.useEffect(() => {
63482
63458
  if (!activeWalletInfo || !activeDepositWallet) return;
63483
63459
  let cancelled = false;
63484
63460
  setIsLoading(true);
@@ -63511,20 +63487,20 @@ function WalletConnect({
63511
63487
  cancelled = true;
63512
63488
  };
63513
63489
  }, [activeWalletInfo?.address, activeDepositWallet?.chain_type, publishableKey]);
63514
- const usdToTokenRate = React292.useMemo(() => {
63490
+ const usdToTokenRate = React302.useMemo(() => {
63515
63491
  if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
63516
63492
  const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
63517
63493
  const balanceUsd = parseFloat(selectedBalance.amount_usd);
63518
63494
  if (balanceAmount === 0 || balanceUsd === 0) return 0;
63519
63495
  return balanceAmount / balanceUsd;
63520
63496
  }, [selectedBalance, selectedToken]);
63521
- const tokenAmount = React292.useMemo(() => {
63497
+ const tokenAmount = React302.useMemo(() => {
63522
63498
  if (isCheckoutMode && activeCheckoutQuote && selectedToken) return Number(activeCheckoutQuote.sourceAmount) / 10 ** activeCheckoutQuote.sourceTokenDecimals;
63523
63499
  const usdNum = parseFloat(amountUsd) || 0;
63524
63500
  if (usdNum === 0 || usdToTokenRate === 0) return 0;
63525
63501
  return usdNum * usdToTokenRate;
63526
63502
  }, [amountUsd, usdToTokenRate, isCheckoutMode, activeCheckoutQuote, selectedToken]);
63527
- React292.useEffect(() => {
63503
+ React302.useEffect(() => {
63528
63504
  if (isCheckoutMode && activeCheckoutQuote?.sourceAmountUsd && view === "enter_amount") setAmountUsd(activeCheckoutQuote.sourceAmountUsd);
63529
63505
  }, [isCheckoutMode, activeCheckoutQuote, view]);
63530
63506
  const maxTokenAmount = selectedBalance && selectedToken ? Number(selectedBalance.amount) / 10 ** selectedToken.decimals : 0;
@@ -63532,7 +63508,7 @@ function WalletConnect({
63532
63508
  const inputUsdNum = parseFloat(amountUsd) || 0;
63533
63509
  const minDepositUsd = tokenChainDetails?.minimum_deposit_amount_usd || 0;
63534
63510
  const isValidAmount = isCheckoutMode && activeCheckoutQuote ? tokenAmount > 0 && tokenAmount <= maxTokenAmount : inputUsdNum > 0 && inputUsdNum <= maxUsdAmount && inputUsdNum >= minDepositUsd;
63535
- const formattedTokenAmount = React292.useMemo(() => {
63511
+ const formattedTokenAmount = React302.useMemo(() => {
63536
63512
  if (tokenAmount === 0 || !selectedToken) return null;
63537
63513
  return `${tokenAmount.toFixed(6)} ${selectedToken.symbol}`.replace(/\.?0+$/, "");
63538
63514
  }, [tokenAmount, selectedToken]);
@@ -63580,16 +63556,25 @@ function WalletConnect({
63580
63556
  } catch (err) {
63581
63557
  console.warn("[WalletConnect] disconnect error:", err);
63582
63558
  } finally {
63583
- setActiveWalletInfo(null);
63584
- setActiveDepositWallet(null);
63585
- setSelectedBalance(null);
63586
- setBalances([]);
63587
- setTotalBalanceUsd(null);
63588
- setAmountUsd(prefillAmountUsd ?? "");
63589
- setError(null);
63590
63559
  setIsDisconnectingWallet(false);
63591
- if (onWalletDisconnect) onWalletDisconnect();
63592
- else parentOnBack?.();
63560
+ const clearWalletState = () => {
63561
+ setActiveWalletInfo(null);
63562
+ setActiveDepositWallet(null);
63563
+ setSelectedBalance(null);
63564
+ setBalances([]);
63565
+ setTotalBalanceUsd(null);
63566
+ setAmountUsd(prefillAmountUsd ?? "");
63567
+ setError(null);
63568
+ };
63569
+ if (standalone) {
63570
+ onWalletDisconnect?.();
63571
+ transitionTo("select_wallet");
63572
+ setTimeout(clearWalletState, 160);
63573
+ } else {
63574
+ clearWalletState();
63575
+ if (onWalletDisconnect) onWalletDisconnect();
63576
+ else parentOnBack?.();
63577
+ }
63593
63578
  }
63594
63579
  };
63595
63580
  const handleReview = () => {
@@ -63715,9 +63700,15 @@ function WalletConnect({
63715
63700
  setIsConfirming(false);
63716
63701
  }
63717
63702
  };
63703
+ if (standalone && !autoResolved) {
63704
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { style: viewTransitionStyle, children: [
63705
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: "Connect Wallet", showBack: canGoBack, onBack: handleBack, onClose }),
63706
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-16", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(LoaderCircle, { className: "uf-w-8 uf-h-8 uf-animate-spin", style: { color: colors2.primary } }) })
63707
+ ] });
63708
+ }
63718
63709
  if (view === "select_wallet") {
63719
63710
  return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { style: viewTransitionStyle, children: [
63720
- /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: "Connect Wallet", showBack: true, onBack: handleBack, onClose }),
63711
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: "Connect Wallet", showBack: canGoBack, onBack: handleBack, onClose }),
63721
63712
  /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-pb-4", children: [
63722
63713
  /* @__PURE__ */ (0, import_jsx_runtime73.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" }),
63723
63714
  /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-space-y-2", style: { maxHeight: 330, overflowY: "auto" }, children: availableWallets.map((wallet) => /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
@@ -63880,8 +63871,19 @@ function DepositModal({
63880
63871
  if (s === "tracker" && hideDepositTracker) return "main";
63881
63872
  if (s === "cashapp" && !enableCashApp) return "main";
63882
63873
  if (s === "card" && enableFiatOnramp === false) return "main";
63874
+ if (s === "pay_with_exchange") return enablePayWithExchange === false ? "main" : "exchange";
63875
+ if (s === "exchange_connect") return enableConnectExchange ? "coinbase_connect" : "main";
63876
+ if (s === "wallet_connect") return enableConnectWallet ? "wallet_connect" : "main";
63883
63877
  return s;
63884
- }, [initialScreen, hideDepositTracker, enableCashApp, enableFiatOnramp]);
63878
+ }, [
63879
+ initialScreen,
63880
+ hideDepositTracker,
63881
+ enableCashApp,
63882
+ enableFiatOnramp,
63883
+ enablePayWithExchange,
63884
+ enableConnectExchange,
63885
+ enableConnectWallet
63886
+ ]);
63885
63887
  const [containerEl, setContainerEl] = (0, import_react3.useState)(null);
63886
63888
  const containerCallbackRef = (0, import_react3.useCallback)((el) => {
63887
63889
  setContainerEl(el);
@@ -64005,6 +64007,12 @@ function DepositModal({
64005
64007
  setCardView("amount");
64006
64008
  }
64007
64009
  }, [view, showFiatOnramp]);
64010
+ (0, import_react3.useEffect)(() => {
64011
+ if (view === "exchange" && !showPayWithExchange) {
64012
+ setView("main");
64013
+ setExchangeView("providers");
64014
+ }
64015
+ }, [view, showPayWithExchange]);
64008
64016
  const { exchanges, isLoading: exchangesLoading } = useExchanges({
64009
64017
  publishableKey,
64010
64018
  enabled: open && showPayWithExchange
@@ -64124,7 +64132,7 @@ function DepositModal({
64124
64132
  setBrowserWalletChainType(void 0);
64125
64133
  setBrowserWalletInfo(null);
64126
64134
  setBrowserWalletModalOpen(false);
64127
- if (view === "wallet_connect") setView("main");
64135
+ if (view === "wallet_connect" && sessionOpenedFromMenu) setView("main");
64128
64136
  };
64129
64137
  const handleExchangeDisconnect = () => {
64130
64138
  const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
@@ -64133,7 +64141,7 @@ function DepositModal({
64133
64141
  }
64134
64142
  clearStoredIntegrationToken(IntegrationProvider.COINBASE);
64135
64143
  setConnectedExchange(null);
64136
- if (view === "coinbase_connect") setView("main");
64144
+ if (view === "coinbase_connect" && sessionOpenedFromMenu) setView("main");
64137
64145
  };
64138
64146
  const handleClose = () => {
64139
64147
  onOpenChange(false);
@@ -64145,6 +64153,7 @@ function DepositModal({
64145
64153
  setCardView("amount");
64146
64154
  setExchangeView("providers");
64147
64155
  setBrowserWalletInfo(null);
64156
+ setCoinbaseSkipToHoldings(false);
64148
64157
  resetViewTimeoutRef.current = null;
64149
64158
  }, 200);
64150
64159
  };
@@ -64159,6 +64168,7 @@ function DepositModal({
64159
64168
  setExchangeView("providers");
64160
64169
  setBrowserWalletInfo(null);
64161
64170
  setSelectedExecution(null);
64171
+ setCoinbaseSkipToHoldings(false);
64162
64172
  }, [open, effectiveInitialScreen]);
64163
64173
  (0, import_react3.useEffect)(
64164
64174
  () => () => {
@@ -64518,7 +64528,7 @@ function DepositModal({
64518
64528
  DepositHeader,
64519
64529
  {
64520
64530
  title: payWithExchangeTitle,
64521
- showBack: true,
64531
+ showBack: exchangeView === "pending" || sessionOpenedFromMenu,
64522
64532
  onBack: handleBack,
64523
64533
  onClose: handleClose
64524
64534
  }
@@ -64572,6 +64582,7 @@ function DepositModal({
64572
64582
  onClose: handleClose,
64573
64583
  onDisconnect: handleExchangeDisconnect,
64574
64584
  skipToHoldings: coinbaseSkipToHoldings,
64585
+ canGoBack: sessionOpenedFromMenu,
64575
64586
  onExecutionsChange: setDepositExecutions
64576
64587
  }
64577
64588
  ),
@@ -64609,7 +64620,9 @@ function DepositModal({
64609
64620
  setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
64610
64621
  },
64611
64622
  onBack: handleBack,
64612
- onClose: handleClose
64623
+ onClose: handleClose,
64624
+ canGoBack: sessionOpenedFromMenu,
64625
+ depositWalletsLoading: walletsLoading
64613
64626
  }
64614
64627
  ),
64615
64628
  depositPoweredByFooter
@@ -64618,7 +64631,7 @@ function DepositModal({
64618
64631
  DepositHeader,
64619
64632
  {
64620
64633
  title: cashAppView !== "amount" && cashAppAmount ? `Pay $${cashAppAmount} via Cash App` : "Pay with Cash App",
64621
- showBack: true,
64634
+ showBack: cashAppView !== "amount" || sessionOpenedFromMenu,
64622
64635
  onBack: handleBack,
64623
64636
  onClose: handleClose
64624
64637
  }