@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.mjs CHANGED
@@ -37140,30 +37140,31 @@ var React102 = __toESM(require_react(), 1);
37140
37140
  var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
37141
37141
  var React112 = __toESM(require_react(), 1);
37142
37142
  var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
37143
- var React242 = __toESM(require_react(), 1);
37143
+ var React252 = __toESM(require_react(), 1);
37144
37144
  var React122 = __toESM(require_react(), 1);
37145
- var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
37146
37145
  var React132 = __toESM(require_react(), 1);
37147
- var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
37146
+ var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
37148
37147
  var React142 = __toESM(require_react(), 1);
37149
- var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
37148
+ var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
37150
37149
  var React152 = __toESM(require_react(), 1);
37151
- var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
37150
+ var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
37152
37151
  var React162 = __toESM(require_react(), 1);
37153
- var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
37152
+ var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
37154
37153
  var React172 = __toESM(require_react(), 1);
37155
- var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
37154
+ var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
37156
37155
  var React182 = __toESM(require_react(), 1);
37157
- var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
37156
+ var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
37158
37157
  var React192 = __toESM(require_react(), 1);
37159
- var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
37158
+ var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
37160
37159
  var React202 = __toESM(require_react(), 1);
37161
- var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
37160
+ var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
37162
37161
  var React212 = __toESM(require_react(), 1);
37163
- var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
37162
+ var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
37164
37163
  var React2222 = __toESM(require_react(), 1);
37165
- var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
37164
+ var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
37166
37165
  var React232 = __toESM(require_react(), 1);
37166
+ var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
37167
+ var React242 = __toESM(require_react(), 1);
37167
37168
  var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
37168
37169
  var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
37169
37170
  var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
@@ -37171,7 +37172,7 @@ var import_react18 = __toESM(require_react(), 1);
37171
37172
  var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
37172
37173
  var import_react19 = __toESM(require_react(), 1);
37173
37174
  var import_react20 = __toESM(require_react(), 1);
37174
- var React262 = __toESM(require_react(), 1);
37175
+ var React272 = __toESM(require_react(), 1);
37175
37176
  var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
37176
37177
  var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
37177
37178
  var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
@@ -37181,7 +37182,7 @@ var import_react22 = __toESM(require_react(), 1);
37181
37182
  var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
37182
37183
  var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
37183
37184
  var import_react23 = __toESM(require_react(), 1);
37184
- var React272 = __toESM(require_react(), 1);
37185
+ var React282 = __toESM(require_react(), 1);
37185
37186
  var React31 = __toESM(require_react(), 1);
37186
37187
  var React29 = __toESM(require_react(), 1);
37187
37188
  var React26 = __toESM(require_react(), 1);
@@ -37198,7 +37199,7 @@ var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
37198
37199
  var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
37199
37200
  var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
37200
37201
  var import_react25 = __toESM(require_react(), 1);
37201
- var React282 = __toESM(require_react(), 1);
37202
+ var React292 = __toESM(require_react(), 1);
37202
37203
  var React35 = __toESM(require_react(), 1);
37203
37204
  var ReactDOM4 = __toESM(require_react_dom(), 1);
37204
37205
  var import_react26 = __toESM(require_react(), 1);
@@ -37211,7 +37212,7 @@ var React34 = __toESM(require_react(), 1);
37211
37212
  var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
37212
37213
  var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
37213
37214
  var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
37214
- var React292 = __toESM(require_react(), 1);
37215
+ var React302 = __toESM(require_react(), 1);
37215
37216
  var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
37216
37217
  var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
37217
37218
  var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
@@ -55182,6 +55183,190 @@ function collectAllEip6963EthProviders() {
55182
55183
  if (!store) return [];
55183
55184
  return store.getProviders().map((d) => d.provider);
55184
55185
  }
55186
+ function identifyEthWallet(provider, hint) {
55187
+ switch (hint) {
55188
+ case "metamask":
55189
+ return { type: "metamask", name: "MetaMask", icon: "metamask" };
55190
+ case "phantom":
55191
+ return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
55192
+ case "coinbase":
55193
+ return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
55194
+ case "okx":
55195
+ return { type: "okx", name: "OKX Wallet", icon: "okx" };
55196
+ case "rabby":
55197
+ return { type: "rabby", name: "Rabby", icon: "rabby" };
55198
+ case "trust":
55199
+ return { type: "trust", name: "Trust Wallet", icon: "trust" };
55200
+ case "rainbow":
55201
+ return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
55202
+ }
55203
+ const anyProvider = provider;
55204
+ if (provider.isPhantom) {
55205
+ return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
55206
+ }
55207
+ if (anyProvider.isCoinbaseWallet) {
55208
+ return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
55209
+ }
55210
+ if (anyProvider.isRabby) {
55211
+ return { type: "rabby", name: "Rabby", icon: "rabby" };
55212
+ }
55213
+ if (anyProvider.isTrust) {
55214
+ return { type: "trust", name: "Trust Wallet", icon: "trust" };
55215
+ }
55216
+ if (anyProvider.isRainbow) {
55217
+ return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
55218
+ }
55219
+ if (provider.isMetaMask && !provider.isPhantom) {
55220
+ return { type: "metamask", name: "MetaMask", icon: "metamask" };
55221
+ }
55222
+ return { type: "metamask", name: "Wallet", icon: "metamask" };
55223
+ }
55224
+ async function detectConnectedBrowserWallet(chainType) {
55225
+ if (typeof window === "undefined") return null;
55226
+ if (getUserDisconnectedWallet()) return null;
55227
+ try {
55228
+ const win = window;
55229
+ if (!chainType || chainType === "solana") {
55230
+ const trySilentSolana = async (provider, type, name, icon) => {
55231
+ if (!provider) return null;
55232
+ if (provider.isConnected && provider.publicKey) {
55233
+ return { type, name, address: provider.publicKey.toString(), icon };
55234
+ }
55235
+ try {
55236
+ const resp = await provider.connect({ onlyIfTrusted: true });
55237
+ if (resp.publicKey) {
55238
+ return { type, name, address: resp.publicKey.toString(), icon };
55239
+ }
55240
+ } catch {
55241
+ }
55242
+ return null;
55243
+ };
55244
+ const solanaCandidates = [
55245
+ [win.phantom?.solana, "phantom-solana", "Phantom", "phantom"],
55246
+ [win.solflare, "solflare", "Solflare", "solflare"],
55247
+ [win.backpack, "backpack", "Backpack", "backpack"],
55248
+ [win.glow, "glow", "Glow", "glow"]
55249
+ ];
55250
+ for (const [provider, type, name, icon] of solanaCandidates) {
55251
+ const found = await trySilentSolana(provider, type, name, icon);
55252
+ if (found) return found;
55253
+ }
55254
+ }
55255
+ if (!chainType || chainType === "ethereum") {
55256
+ const allProviders = [];
55257
+ const eip6963 = getEip6963Providers();
55258
+ for (const { provider, walletId } of eip6963) {
55259
+ allProviders.push({
55260
+ provider,
55261
+ walletId: walletId === "unknown" ? "default" : walletId
55262
+ });
55263
+ }
55264
+ if (allProviders.length === 0) {
55265
+ if (win.phantom?.ethereum) {
55266
+ allProviders.push({ provider: win.phantom.ethereum, walletId: "phantom" });
55267
+ }
55268
+ if (win.okxwallet) {
55269
+ allProviders.push({ provider: win.okxwallet, walletId: "okx" });
55270
+ }
55271
+ if (win.coinbaseWalletExtension) {
55272
+ allProviders.push({ provider: win.coinbaseWalletExtension, walletId: "coinbase" });
55273
+ }
55274
+ if (win.ethereum && !allProviders.some((p) => p.provider === win.ethereum)) {
55275
+ allProviders.push({ provider: win.ethereum, walletId: "default" });
55276
+ }
55277
+ }
55278
+ for (const { provider, walletId } of allProviders) {
55279
+ if (!provider) continue;
55280
+ try {
55281
+ const accounts = await provider.request({ method: "eth_accounts" });
55282
+ if (!accounts || accounts.length === 0) continue;
55283
+ const resolved = identifyEthWallet(provider, walletId);
55284
+ return { ...resolved, address: accounts[0] };
55285
+ } catch {
55286
+ }
55287
+ }
55288
+ }
55289
+ } catch (error) {
55290
+ console.error("[detectConnectedBrowserWallet] detection error:", error);
55291
+ }
55292
+ return null;
55293
+ }
55294
+ function useDetectedBrowserWallet(opts = {}) {
55295
+ const { chainType, enabled = true, onDisconnect } = opts;
55296
+ const [wallet, setWallet] = React122.useState(null);
55297
+ const [isLoading, setIsLoading] = React122.useState(enabled);
55298
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React122.useState(0);
55299
+ const onDisconnectRef = React122.useRef(onDisconnect);
55300
+ onDisconnectRef.current = onDisconnect;
55301
+ React122.useEffect(() => {
55302
+ const store = getEip6963Store();
55303
+ if (!store) return;
55304
+ setEip6963ProviderCount(store.getProviders().length);
55305
+ return store.subscribe((providers) => setEip6963ProviderCount(providers.length));
55306
+ }, []);
55307
+ React122.useEffect(() => {
55308
+ if (!enabled) {
55309
+ setWallet(null);
55310
+ setIsLoading(false);
55311
+ return;
55312
+ }
55313
+ let mounted = true;
55314
+ const detect = async () => {
55315
+ if (!mounted) return;
55316
+ setIsLoading(true);
55317
+ const detected = await detectConnectedBrowserWallet(chainType);
55318
+ if (!mounted) return;
55319
+ setWallet(detected);
55320
+ setIsLoading(false);
55321
+ };
55322
+ detect();
55323
+ const onChange = () => detect();
55324
+ const onDisc = () => {
55325
+ onDisconnectRef.current?.();
55326
+ detect();
55327
+ };
55328
+ const onEthAccounts = (accounts) => {
55329
+ if (Array.isArray(accounts) && accounts.length === 0) onDisconnectRef.current?.();
55330
+ detect();
55331
+ };
55332
+ const win = typeof window !== "undefined" ? window : void 0;
55333
+ const solanaProvider = win?.phantom?.solana || win?.solana;
55334
+ if (solanaProvider) {
55335
+ solanaProvider.on("connect", onChange);
55336
+ solanaProvider.on("disconnect", onDisc);
55337
+ solanaProvider.on("accountChanged", onChange);
55338
+ }
55339
+ const ethProviders = [];
55340
+ for (const { provider } of getEip6963Providers()) {
55341
+ const p = provider;
55342
+ if (p && !ethProviders.includes(p)) ethProviders.push(p);
55343
+ }
55344
+ if (win?.ethereum && !ethProviders.includes(win.ethereum)) ethProviders.push(win.ethereum);
55345
+ if (win?.phantom?.ethereum && !ethProviders.includes(win.phantom.ethereum)) {
55346
+ ethProviders.push(win.phantom.ethereum);
55347
+ }
55348
+ for (const p of ethProviders) {
55349
+ p.on("accountsChanged", onEthAccounts);
55350
+ p.on("chainChanged", onChange);
55351
+ }
55352
+ return () => {
55353
+ mounted = false;
55354
+ if (solanaProvider) {
55355
+ solanaProvider.off?.("connect", onChange);
55356
+ solanaProvider.off?.("disconnect", onDisc);
55357
+ solanaProvider.off?.("accountChanged", onChange);
55358
+ }
55359
+ for (const p of ethProviders) {
55360
+ const off = p.off?.bind(p) ?? p.removeListener?.bind(p);
55361
+ if (off) {
55362
+ off("accountsChanged", onEthAccounts);
55363
+ off("chainChanged", onChange);
55364
+ }
55365
+ }
55366
+ };
55367
+ }, [chainType, eip6963ProviderCount, enabled]);
55368
+ return { wallet, isLoading, setWallet };
55369
+ }
55185
55370
  var SOLANA_DISCONNECT_TYPES = [
55186
55371
  "phantom-solana",
55187
55372
  "solflare",
@@ -55269,7 +55454,7 @@ function MetamaskIcon({
55269
55454
  className,
55270
55455
  variant = "color"
55271
55456
  }) {
55272
- const id = React122.useId();
55457
+ const id = React132.useId();
55273
55458
  if (variant === "light" || variant === "dark") {
55274
55459
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
55275
55460
  "svg",
@@ -55394,7 +55579,7 @@ function PhantomIcon({
55394
55579
  className,
55395
55580
  variant = "color"
55396
55581
  }) {
55397
- const id = React132.useId();
55582
+ const id = React142.useId();
55398
55583
  if (variant === "light") {
55399
55584
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
55400
55585
  "svg",
@@ -55465,7 +55650,7 @@ function CoinbaseIcon({
55465
55650
  className,
55466
55651
  variant = "color"
55467
55652
  }) {
55468
- const id = React142.useId();
55653
+ const id = React152.useId();
55469
55654
  if (variant === "light") {
55470
55655
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
55471
55656
  "svg",
@@ -55549,7 +55734,7 @@ function RabbyIcon({
55549
55734
  className,
55550
55735
  variant = "color"
55551
55736
  }) {
55552
- const id = React152.useId();
55737
+ const id = React162.useId();
55553
55738
  if (variant === "light") {
55554
55739
  return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
55555
55740
  "svg",
@@ -55900,7 +56085,7 @@ function RainbowIcon({
55900
56085
  className,
55901
56086
  variant = "color"
55902
56087
  }) {
55903
- const id = React162.useId();
56088
+ const id = React172.useId();
55904
56089
  if (variant === "light") {
55905
56090
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
55906
56091
  "svg",
@@ -56366,7 +56551,7 @@ function TrustIcon({
56366
56551
  className,
56367
56552
  variant = "color"
56368
56553
  }) {
56369
- const id = React172.useId();
56554
+ const id = React182.useId();
56370
56555
  if (variant === "light") {
56371
56556
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
56372
56557
  "svg",
@@ -56459,7 +56644,7 @@ function OkxIcon({
56459
56644
  className,
56460
56645
  variant = "color"
56461
56646
  }) {
56462
- const id = React182.useId();
56647
+ const id = React192.useId();
56463
56648
  if (variant === "light") {
56464
56649
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
56465
56650
  "svg",
@@ -56530,7 +56715,7 @@ function GlowIcon({
56530
56715
  className,
56531
56716
  variant = "color"
56532
56717
  }) {
56533
- const id = React192.useId();
56718
+ const id = React202.useId();
56534
56719
  if (variant === "light") {
56535
56720
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
56536
56721
  "svg",
@@ -56635,7 +56820,7 @@ function BackpackIcon({
56635
56820
  className,
56636
56821
  variant = "color"
56637
56822
  }) {
56638
- const id = React202.useId();
56823
+ const id = React212.useId();
56639
56824
  if (variant === "light") {
56640
56825
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
56641
56826
  "svg",
@@ -56712,7 +56897,7 @@ function SolflareIcon({
56712
56897
  className,
56713
56898
  variant = "color"
56714
56899
  }) {
56715
- const id = React212.useId();
56900
+ const id = React2222.useId();
56716
56901
  if (variant === "light") {
56717
56902
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
56718
56903
  "svg",
@@ -56783,7 +56968,7 @@ function EthereumIcon({
56783
56968
  className,
56784
56969
  variant = "color"
56785
56970
  }) {
56786
- const id = React2222.useId();
56971
+ const id = React232.useId();
56787
56972
  if (variant === "light") {
56788
56973
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
56789
56974
  "svg",
@@ -56917,7 +57102,7 @@ function SolanaIcon({
56917
57102
  className,
56918
57103
  variant = "color"
56919
57104
  }) {
56920
- const id = React232.useId();
57105
+ const id = React242.useId();
56921
57106
  if (variant === "light") {
56922
57107
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
56923
57108
  "svg",
@@ -57166,44 +57351,6 @@ function truncateAddress3(address) {
57166
57351
  if (address.length <= 10) return address;
57167
57352
  return `${address.slice(0, 4)}...${address.slice(-4)}`;
57168
57353
  }
57169
- function identifyEthWallet(provider, _win, hint) {
57170
- switch (hint) {
57171
- case "metamask":
57172
- return { type: "metamask", name: "MetaMask", icon: "metamask" };
57173
- case "phantom":
57174
- return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
57175
- case "coinbase":
57176
- return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
57177
- case "okx":
57178
- return { type: "okx", name: "OKX Wallet", icon: "okx" };
57179
- case "rabby":
57180
- return { type: "rabby", name: "Rabby", icon: "rabby" };
57181
- case "trust":
57182
- return { type: "trust", name: "Trust Wallet", icon: "trust" };
57183
- case "rainbow":
57184
- return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
57185
- }
57186
- const anyProvider = provider;
57187
- if (provider.isPhantom) {
57188
- return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
57189
- }
57190
- if (anyProvider.isCoinbaseWallet) {
57191
- return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
57192
- }
57193
- if (anyProvider.isRabby) {
57194
- return { type: "rabby", name: "Rabby", icon: "rabby" };
57195
- }
57196
- if (anyProvider.isTrust) {
57197
- return { type: "trust", name: "Trust Wallet", icon: "trust" };
57198
- }
57199
- if (anyProvider.isRainbow) {
57200
- return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
57201
- }
57202
- if (provider.isMetaMask && !provider.isPhantom) {
57203
- return { type: "metamask", name: "MetaMask", icon: "metamask" };
57204
- }
57205
- return { type: "metamask", name: "Wallet", icon: "metamask" };
57206
- }
57207
57354
  function BrowserWalletButton({
57208
57355
  onClick,
57209
57356
  onConnectClick,
@@ -57214,30 +57361,19 @@ function BrowserWalletButton({
57214
57361
  subtitle = i18n2.depositModal.browserWallet.subtitle
57215
57362
  }) {
57216
57363
  const { colors: colors2, fonts, components } = useTheme();
57217
- const [isHovered, setIsHovered] = React242.useState(false);
57218
- const [isTouchDevice, setIsTouchDevice] = React242.useState(false);
57219
- const [wallet, setWallet] = React242.useState(null);
57220
- const [isLoading, setIsLoading] = React242.useState(true);
57221
- const [isConnecting, setIsConnecting] = React242.useState(false);
57222
- const [balanceText, setBalanceText] = React242.useState(null);
57223
- const [isLoadingBalance, setIsLoadingBalance] = React242.useState(false);
57224
- const [isDisconnecting, setIsDisconnecting] = React242.useState(false);
57225
- const onDisconnectRef = React242.useRef(onDisconnect);
57364
+ const [isHovered, setIsHovered] = React252.useState(false);
57365
+ const [isTouchDevice, setIsTouchDevice] = React252.useState(false);
57366
+ const { wallet, isLoading, setWallet } = useDetectedBrowserWallet({ chainType, onDisconnect });
57367
+ const [isConnecting, setIsConnecting] = React252.useState(false);
57368
+ const [balanceText, setBalanceText] = React252.useState(null);
57369
+ const [isLoadingBalance, setIsLoadingBalance] = React252.useState(false);
57370
+ const [isDisconnecting, setIsDisconnecting] = React252.useState(false);
57371
+ const onDisconnectRef = React252.useRef(onDisconnect);
57226
57372
  onDisconnectRef.current = onDisconnect;
57227
- React242.useEffect(() => {
57373
+ React252.useEffect(() => {
57228
57374
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
57229
57375
  }, []);
57230
- const [eip6963ProviderCount, setEip6963ProviderCount] = React242.useState(0);
57231
- React242.useEffect(() => {
57232
- const store = getEip6963Store();
57233
- if (!store) return;
57234
- setEip6963ProviderCount(store.getProviders().length);
57235
- const unsubscribe = store.subscribe((providers) => {
57236
- setEip6963ProviderCount(providers.length);
57237
- });
57238
- return unsubscribe;
57239
- }, []);
57240
- React242.useEffect(() => {
57376
+ React252.useEffect(() => {
57241
57377
  if (!wallet || !publishableKey) {
57242
57378
  setBalanceText(null);
57243
57379
  return;
@@ -57278,206 +57414,6 @@ function BrowserWalletButton({
57278
57414
  cancelled = true;
57279
57415
  };
57280
57416
  }, [wallet, publishableKey]);
57281
- React242.useEffect(() => {
57282
- let mounted = true;
57283
- const detectWallet = async () => {
57284
- if (!mounted) return;
57285
- setIsLoading(true);
57286
- try {
57287
- const win = typeof window !== "undefined" ? window : null;
57288
- if (!win) return;
57289
- if (getUserDisconnectedWallet()) {
57290
- if (mounted) {
57291
- setWallet(null);
57292
- setIsLoading(false);
57293
- }
57294
- return;
57295
- }
57296
- if (!chainType || chainType === "solana") {
57297
- const anyWin = win;
57298
- const trySilentSolana = async (provider, type, name, icon) => {
57299
- if (!provider) return false;
57300
- if (provider.isConnected && provider.publicKey) {
57301
- if (mounted) {
57302
- setWallet({
57303
- type,
57304
- name,
57305
- address: provider.publicKey.toString(),
57306
- icon
57307
- });
57308
- setIsLoading(false);
57309
- }
57310
- return true;
57311
- }
57312
- try {
57313
- const resp = await provider.connect({ onlyIfTrusted: true });
57314
- if (mounted && resp.publicKey) {
57315
- setWallet({
57316
- type,
57317
- name,
57318
- address: resp.publicKey.toString(),
57319
- icon
57320
- });
57321
- setIsLoading(false);
57322
- return true;
57323
- }
57324
- } catch {
57325
- }
57326
- return false;
57327
- };
57328
- if (await trySilentSolana(
57329
- win.phantom?.solana,
57330
- "phantom-solana",
57331
- "Phantom",
57332
- "phantom"
57333
- ))
57334
- return;
57335
- if (await trySilentSolana(
57336
- anyWin.solflare,
57337
- "solflare",
57338
- "Solflare",
57339
- "solflare"
57340
- ))
57341
- return;
57342
- if (await trySilentSolana(
57343
- anyWin.backpack,
57344
- "backpack",
57345
- "Backpack",
57346
- "backpack"
57347
- ))
57348
- return;
57349
- if (await trySilentSolana(
57350
- anyWin.glow,
57351
- "glow",
57352
- "Glow",
57353
- "glow"
57354
- ))
57355
- return;
57356
- }
57357
- if (!chainType || chainType === "ethereum") {
57358
- const anyWin = win;
57359
- const allProviders = [];
57360
- const eip6963 = getEip6963Providers();
57361
- for (const { provider, walletId } of eip6963) {
57362
- allProviders.push({
57363
- provider,
57364
- walletId: walletId === "unknown" ? "default" : walletId
57365
- });
57366
- }
57367
- if (allProviders.length === 0) {
57368
- if (win.phantom?.ethereum) {
57369
- allProviders.push({
57370
- provider: win.phantom.ethereum,
57371
- walletId: "phantom"
57372
- });
57373
- }
57374
- if (anyWin.okxwallet) {
57375
- allProviders.push({
57376
- provider: anyWin.okxwallet,
57377
- walletId: "okx"
57378
- });
57379
- }
57380
- if (anyWin.coinbaseWalletExtension) {
57381
- allProviders.push({
57382
- provider: anyWin.coinbaseWalletExtension,
57383
- walletId: "coinbase"
57384
- });
57385
- }
57386
- if (win.ethereum) {
57387
- const isDuplicate = allProviders.some(
57388
- (p) => p.provider === win.ethereum
57389
- );
57390
- if (!isDuplicate) {
57391
- allProviders.push({
57392
- provider: win.ethereum,
57393
- walletId: "default"
57394
- });
57395
- }
57396
- }
57397
- }
57398
- for (const { provider, walletId } of allProviders) {
57399
- if (!provider) continue;
57400
- try {
57401
- const accounts = await provider.request({
57402
- method: "eth_accounts"
57403
- });
57404
- if (!accounts || accounts.length === 0) continue;
57405
- const address = accounts[0];
57406
- const resolved = identifyEthWallet(provider, anyWin, walletId);
57407
- if (mounted) {
57408
- setWallet({ ...resolved, address });
57409
- setIsLoading(false);
57410
- }
57411
- return;
57412
- } catch {
57413
- }
57414
- }
57415
- }
57416
- if (mounted) {
57417
- setWallet(null);
57418
- setIsLoading(false);
57419
- }
57420
- } catch (error) {
57421
- console.error("[BrowserWalletButton] Error detecting wallet:", error);
57422
- if (mounted) {
57423
- setWallet(null);
57424
- setIsLoading(false);
57425
- }
57426
- }
57427
- };
57428
- detectWallet();
57429
- const handleAccountsChanged = () => {
57430
- detectWallet();
57431
- };
57432
- const handleDisconnect = () => {
57433
- onDisconnectRef.current?.();
57434
- detectWallet();
57435
- };
57436
- const handleEthAccountsChanged = (accounts) => {
57437
- if (Array.isArray(accounts) && accounts.length === 0) {
57438
- onDisconnectRef.current?.();
57439
- }
57440
- detectWallet();
57441
- };
57442
- const solanaProvider = window.phantom?.solana || window.solana;
57443
- if (solanaProvider) {
57444
- solanaProvider.on("connect", handleAccountsChanged);
57445
- solanaProvider.on("disconnect", handleDisconnect);
57446
- solanaProvider.on("accountChanged", handleAccountsChanged);
57447
- }
57448
- const ethProviders = [];
57449
- for (const { provider } of getEip6963Providers()) {
57450
- const p = provider;
57451
- if (p && !ethProviders.includes(p)) {
57452
- ethProviders.push(p);
57453
- }
57454
- }
57455
- if (window.ethereum && !ethProviders.includes(window.ethereum)) {
57456
- ethProviders.push(window.ethereum);
57457
- }
57458
- if (window.phantom?.ethereum && !ethProviders.includes(window.phantom.ethereum)) {
57459
- ethProviders.push(window.phantom.ethereum);
57460
- }
57461
- for (const provider of ethProviders) {
57462
- provider.on("accountsChanged", handleEthAccountsChanged);
57463
- provider.on("chainChanged", handleAccountsChanged);
57464
- }
57465
- return () => {
57466
- mounted = false;
57467
- if (solanaProvider) {
57468
- solanaProvider.off("connect", handleAccountsChanged);
57469
- solanaProvider.off("disconnect", handleDisconnect);
57470
- solanaProvider.off("accountChanged", handleAccountsChanged);
57471
- }
57472
- for (const provider of ethProviders) {
57473
- const off = provider.off?.bind(provider) ?? provider.removeListener?.bind(provider);
57474
- if (off) {
57475
- off("accountsChanged", handleEthAccountsChanged);
57476
- off("chainChanged", handleAccountsChanged);
57477
- }
57478
- }
57479
- };
57480
- }, [chainType, eip6963ProviderCount]);
57481
57417
  const handleConnect = async () => {
57482
57418
  if (wallet) {
57483
57419
  onClick(wallet);
@@ -57561,7 +57497,7 @@ function BrowserWalletButton({
57561
57497
  border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
57562
57498
  };
57563
57499
  const sortedWallets = featuredWallets ? [...featuredWallets].sort((a, b) => a.position - b.position) : [];
57564
- const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React242.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
57500
+ const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React252.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
57565
57501
  size: 36,
57566
57502
  className: "uf-rounded-lg",
57567
57503
  variant: "color"
@@ -57823,6 +57759,7 @@ function CoinbaseConnect({
57823
57759
  onBack: parentOnBack,
57824
57760
  onDisconnect,
57825
57761
  skipToHoldings,
57762
+ canGoBack = true,
57826
57763
  onExecutionsChange
57827
57764
  }) {
57828
57765
  const { colors: colors2, fonts, components } = useTheme();
@@ -58210,6 +58147,16 @@ function CoinbaseConnect({
58210
58147
  setIsLoading(false);
58211
58148
  }
58212
58149
  };
58150
+ const handleDisconnect = () => {
58151
+ onDisconnect?.();
58152
+ if (!canGoBack) {
58153
+ setAccessToken(null);
58154
+ setHoldings([]);
58155
+ setSelectedHolding(null);
58156
+ setSelectedAsset(null);
58157
+ transitionTo("select_exchange");
58158
+ }
58159
+ };
58213
58160
  const handleBack = () => {
58214
58161
  switch (view) {
58215
58162
  case "select_exchange":
@@ -58270,7 +58217,7 @@ function CoinbaseConnect({
58270
58217
  DepositHeader,
58271
58218
  {
58272
58219
  title: t12.title,
58273
- showBack: true,
58220
+ showBack: canGoBack,
58274
58221
  onBack: handleBack,
58275
58222
  onClose
58276
58223
  }
@@ -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
  }
@@ -58995,7 +58942,7 @@ function CoinbaseConnect({
58995
58942
  borderRadius: components.button.borderRadius,
58996
58943
  fontFamily: fonts.medium
58997
58944
  },
58998
- onClick: onDisconnect,
58945
+ onClick: handleDisconnect,
58999
58946
  children: t12.disconnect
59000
58947
  }
59001
58948
  )
@@ -59782,7 +59729,7 @@ function ThemeStyleInjector({
59782
59729
  className
59783
59730
  }) {
59784
59731
  const { colors: colors2, fonts, mode } = useTheme();
59785
- const cssVars = React262.useMemo(() => {
59732
+ const cssVars = React272.useMemo(() => {
59786
59733
  const hexToHSL = (hex) => {
59787
59734
  hex = hex.replace("#", "");
59788
59735
  const r2 = parseInt(hex.slice(0, 2), 16) / 255;
@@ -59842,7 +59789,7 @@ function ThemeStyleInjector({
59842
59789
  ...fonts.regular ? { "--uf-font-family": fonts.regular } : {}
59843
59790
  };
59844
59791
  }, [colors2, fonts.regular]);
59845
- React262.useEffect(() => {
59792
+ React272.useEffect(() => {
59846
59793
  if (typeof document === "undefined") return;
59847
59794
  if (fonts.regular) {
59848
59795
  document.documentElement.style.setProperty(
@@ -60801,14 +60748,14 @@ function useCopyAddress() {
60801
60748
  return { copied, handleCopy };
60802
60749
  }
60803
60750
  var TooltipProvider2 = Provider;
60804
- var TooltipContext = React272.createContext({
60751
+ var TooltipContext = React282.createContext({
60805
60752
  open: false,
60806
60753
  onOpenChange: () => {
60807
60754
  }
60808
60755
  });
60809
- var TooltipTrigger2 = React272.forwardRef(({ onClick, ...props }, ref) => {
60810
- const { open, onOpenChange } = React272.useContext(TooltipContext);
60811
- const handleClick = React272.useCallback(
60756
+ var TooltipTrigger2 = React282.forwardRef(({ onClick, ...props }, ref) => {
60757
+ const { open, onOpenChange } = React282.useContext(TooltipContext);
60758
+ const handleClick = React282.useCallback(
60812
60759
  (e) => {
60813
60760
  onOpenChange(!open);
60814
60761
  onClick?.(e);
@@ -60818,7 +60765,7 @@ var TooltipTrigger2 = React272.forwardRef(({ onClick, ...props }, ref) => {
60818
60765
  return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Trigger, { ref, onClick: handleClick, ...props });
60819
60766
  });
60820
60767
  TooltipTrigger2.displayName = Trigger.displayName;
60821
- var TooltipContent2 = React272.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
60768
+ var TooltipContent2 = React282.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
60822
60769
  const { themeClass, colors: colors2 } = useTheme();
60823
60770
  return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Portal3, { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
60824
60771
  Content22,
@@ -61423,7 +61370,7 @@ function TransferCryptoSingleInput({
61423
61370
  }
61424
61371
  var Select2 = Root23;
61425
61372
  var SelectValue2 = Value;
61426
- var SelectTrigger2 = React282.forwardRef(({ className, style, children, ...props }, ref) => {
61373
+ var SelectTrigger2 = React292.forwardRef(({ className, style, children, ...props }, ref) => {
61427
61374
  const { components } = useTheme();
61428
61375
  return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61429
61376
  Trigger2,
@@ -61447,7 +61394,7 @@ var SelectTrigger2 = React282.forwardRef(({ className, style, children, ...props
61447
61394
  );
61448
61395
  });
61449
61396
  SelectTrigger2.displayName = Trigger2.displayName;
61450
- var SelectScrollUpButton2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61397
+ var SelectScrollUpButton2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61451
61398
  ScrollUpButton,
61452
61399
  {
61453
61400
  ref,
@@ -61460,7 +61407,7 @@ var SelectScrollUpButton2 = React282.forwardRef(({ className, ...props }, ref) =
61460
61407
  }
61461
61408
  ));
61462
61409
  SelectScrollUpButton2.displayName = ScrollUpButton.displayName;
61463
- var SelectScrollDownButton2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61410
+ var SelectScrollDownButton2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61464
61411
  ScrollDownButton,
61465
61412
  {
61466
61413
  ref,
@@ -61473,7 +61420,7 @@ var SelectScrollDownButton2 = React282.forwardRef(({ className, ...props }, ref)
61473
61420
  }
61474
61421
  ));
61475
61422
  SelectScrollDownButton2.displayName = ScrollDownButton.displayName;
61476
- var SelectContent2 = React282.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
61423
+ var SelectContent2 = React292.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
61477
61424
  const { themeClass, colors: colors2, components } = useTheme();
61478
61425
  return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Portal4, { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61479
61426
  Content23,
@@ -61511,7 +61458,7 @@ var SelectContent2 = React282.forwardRef(({ className, style, children, position
61511
61458
  ) });
61512
61459
  });
61513
61460
  SelectContent2.displayName = Content23.displayName;
61514
- var SelectLabel2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61461
+ var SelectLabel2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61515
61462
  Label,
61516
61463
  {
61517
61464
  ref,
@@ -61523,7 +61470,7 @@ var SelectLabel2 = React282.forwardRef(({ className, ...props }, ref) => /* @__P
61523
61470
  }
61524
61471
  ));
61525
61472
  SelectLabel2.displayName = Label.displayName;
61526
- var SelectItem2 = React282.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61473
+ var SelectItem2 = React292.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61527
61474
  Item,
61528
61475
  {
61529
61476
  ref,
@@ -61539,7 +61486,7 @@ var SelectItem2 = React282.forwardRef(({ className, children, ...props }, ref) =
61539
61486
  }
61540
61487
  ));
61541
61488
  SelectItem2.displayName = Item.displayName;
61542
- var SelectSeparator2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61489
+ var SelectSeparator2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61543
61490
  Separator,
61544
61491
  {
61545
61492
  ref,
@@ -63203,22 +63150,27 @@ function WalletConnect({
63203
63150
  productType,
63204
63151
  onBack: parentOnBack,
63205
63152
  onClose,
63153
+ canGoBack = true,
63154
+ depositWalletsLoading = false,
63206
63155
  onExecutionsChange
63207
63156
  }) {
63208
63157
  const { colors: colors2, fonts, components } = useTheme();
63209
- const walletProvidedAtMount = React292.useRef(!!initialWalletInfo && !!initialDepositWallet);
63210
- const [activeWalletInfo, setActiveWalletInfo] = React292.useState(initialWalletInfo ?? null);
63211
- const [activeDepositWallet, setActiveDepositWallet] = React292.useState(initialDepositWallet ?? null);
63158
+ const walletProvidedAtMount = React302.useRef(!!initialWalletInfo && !!initialDepositWallet);
63159
+ const [activeWalletInfo, setActiveWalletInfo] = React302.useState(initialWalletInfo ?? null);
63160
+ const [activeDepositWallet, setActiveDepositWallet] = React302.useState(initialDepositWallet ?? null);
63212
63161
  const initialView = initialWalletInfo && initialDepositWallet ? "select_token" : "select_wallet";
63213
- const [view, setView] = React292.useState(initialView);
63214
- const [isTransitioning, setIsTransitioning] = React292.useState(false);
63215
- const viewRef = React292.useRef(initialView);
63216
- const [selectedWalletDef, setSelectedWalletDef] = React292.useState(null);
63217
- const [connectingNetwork, setConnectingNetwork] = React292.useState(null);
63218
- const [walletError, setWalletError] = React292.useState(null);
63219
- const [isWalletConnecting, setIsWalletConnecting] = React292.useState(false);
63220
- const [eip6963ProviderCount, setEip6963ProviderCount] = React292.useState(0);
63221
- React292.useEffect(() => {
63162
+ const [view, setView] = React302.useState(initialView);
63163
+ const [isTransitioning, setIsTransitioning] = React302.useState(false);
63164
+ const viewRef = React302.useRef(initialView);
63165
+ const standalone = !canGoBack && !walletProvidedAtMount.current;
63166
+ const { wallet: detectedWallet, isLoading: detectingWallet } = useDetectedBrowserWallet({ enabled: standalone });
63167
+ const [autoResolved, setAutoResolved] = React302.useState(false);
63168
+ const [selectedWalletDef, setSelectedWalletDef] = React302.useState(null);
63169
+ const [connectingNetwork, setConnectingNetwork] = React302.useState(null);
63170
+ const [walletError, setWalletError] = React302.useState(null);
63171
+ const [isWalletConnecting, setIsWalletConnecting] = React302.useState(false);
63172
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React302.useState(0);
63173
+ React302.useEffect(() => {
63222
63174
  const store = getEip6963Store();
63223
63175
  if (!store) return;
63224
63176
  setEip6963ProviderCount(store.getProviders().length);
@@ -63226,20 +63178,44 @@ function WalletConnect({
63226
63178
  setEip6963ProviderCount(providers.length);
63227
63179
  });
63228
63180
  }, []);
63229
- const availableWallets = React292.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
63230
- const [balances, setBalances] = React292.useState([]);
63231
- const [isLoading, setIsLoading] = React292.useState(false);
63232
- const [selectedBalance, setSelectedBalance] = React292.useState(null);
63233
- const [totalBalanceUsd, setTotalBalanceUsd] = React292.useState(null);
63234
- const [error, setError] = React292.useState(null);
63235
- const [isDisconnectingWallet, setIsDisconnectingWallet] = React292.useState(false);
63236
- const [amountUsd, setAmountUsd] = React292.useState(prefillAmountUsd ?? "");
63237
- const [isConfirming, setIsConfirming] = React292.useState(false);
63238
- const [hasSignedTransaction, setHasSignedTransaction] = React292.useState(false);
63239
- const [tokenChainDetails, setTokenChainDetails] = React292.useState(null);
63240
- const [loadingTokenDetails, setLoadingTokenDetails] = React292.useState(false);
63241
- const [showTransactionDetails, setShowTransactionDetails] = React292.useState(false);
63242
- const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React292.useState(null);
63181
+ const availableWallets = React302.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
63182
+ React302.useEffect(() => {
63183
+ if (!standalone || autoResolved || detectingWallet) return;
63184
+ if (!detectedWallet) {
63185
+ setAutoResolved(true);
63186
+ return;
63187
+ }
63188
+ const wct = detectedWallet.type === "phantom-solana" || detectedWallet.type === "solflare" || detectedWallet.type === "backpack" || detectedWallet.type === "glow" ? "solana" : "ethereum";
63189
+ const matching = depositWallets?.find((w) => w.chain_type === wct);
63190
+ if (!matching) {
63191
+ if (!depositWalletsLoading) setAutoResolved(true);
63192
+ return;
63193
+ }
63194
+ setActiveWalletInfo(detectedWallet);
63195
+ setActiveDepositWallet(matching);
63196
+ onWalletConnected?.(detectedWallet, matching);
63197
+ setView("select_token");
63198
+ viewRef.current = "select_token";
63199
+ setAutoResolved(true);
63200
+ }, [standalone, autoResolved, detectingWallet, detectedWallet, depositWallets, depositWalletsLoading]);
63201
+ React302.useEffect(() => {
63202
+ if (!standalone || autoResolved) return;
63203
+ const t12 = setTimeout(() => setAutoResolved(true), 5e3);
63204
+ return () => clearTimeout(t12);
63205
+ }, [standalone, autoResolved]);
63206
+ const [balances, setBalances] = React302.useState([]);
63207
+ const [isLoading, setIsLoading] = React302.useState(false);
63208
+ const [selectedBalance, setSelectedBalance] = React302.useState(null);
63209
+ const [totalBalanceUsd, setTotalBalanceUsd] = React302.useState(null);
63210
+ const [error, setError] = React302.useState(null);
63211
+ const [isDisconnectingWallet, setIsDisconnectingWallet] = React302.useState(false);
63212
+ const [amountUsd, setAmountUsd] = React302.useState(prefillAmountUsd ?? "");
63213
+ const [isConfirming, setIsConfirming] = React302.useState(false);
63214
+ const [hasSignedTransaction, setHasSignedTransaction] = React302.useState(false);
63215
+ const [tokenChainDetails, setTokenChainDetails] = React302.useState(null);
63216
+ const [loadingTokenDetails, setLoadingTokenDetails] = React302.useState(false);
63217
+ const [showTransactionDetails, setShowTransactionDetails] = React302.useState(false);
63218
+ const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React302.useState(null);
63243
63219
  const walletInfo = activeWalletInfo;
63244
63220
  const depositWallet = activeDepositWallet;
63245
63221
  const hasWallet = !!activeWalletInfo && !!activeDepositWallet;
@@ -63247,7 +63223,7 @@ function WalletConnect({
63247
63223
  const recipientAddress = activeDepositWallet?.address ?? "";
63248
63224
  const isCheckoutMode = !!checkoutAmountUsd;
63249
63225
  const supportedChainType = chainType === "algorand" || chainType === "xrpl" ? "ethereum" : chainType;
63250
- const transitionTo = React292.useCallback((nextView) => {
63226
+ const transitionTo = React302.useCallback((nextView) => {
63251
63227
  if (nextView === viewRef.current) return;
63252
63228
  setIsTransitioning(true);
63253
63229
  setTimeout(() => {
@@ -63384,7 +63360,7 @@ function WalletConnect({
63384
63360
  }
63385
63361
  };
63386
63362
  const selectedToken = selectedBalance ? getTokenFromBalance(selectedBalance) : null;
63387
- const effectiveDestinationAmount = React292.useMemo(() => {
63363
+ const effectiveDestinationAmount = React302.useMemo(() => {
63388
63364
  if (!checkoutRemainingBaseUnits || checkoutRemainingBaseUnits === "0") return "0";
63389
63365
  if (!checkoutAmountUsd) return checkoutRemainingBaseUnits;
63390
63366
  const remaining = BigInt(checkoutRemainingBaseUnits);
@@ -63412,7 +63388,7 @@ function WalletConnect({
63412
63388
  stablecoinParity,
63413
63389
  enabled: isCheckoutMode && !!selectedToken && !!checkoutDestination && effectiveDestinationAmount !== "0"
63414
63390
  });
63415
- const activeCheckoutQuote = React292.useMemo(() => {
63391
+ const activeCheckoutQuote = React302.useMemo(() => {
63416
63392
  if (!isCheckoutMode) return null;
63417
63393
  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 };
63418
63394
  return checkoutQuote ?? null;
@@ -63426,19 +63402,19 @@ function WalletConnect({
63426
63402
  onDepositSuccess,
63427
63403
  onDepositError
63428
63404
  });
63429
- React292.useEffect(() => {
63405
+ React302.useEffect(() => {
63430
63406
  onExecutionsChange?.(depositExecutions);
63431
63407
  }, [depositExecutions, onExecutionsChange]);
63432
- React292.useEffect(() => {
63408
+ React302.useEffect(() => {
63433
63409
  if (!prefillAmountUsd || !tokenChainDetails || view !== "enter_amount") return;
63434
63410
  const minDeposit = tokenChainDetails.minimum_deposit_amount_usd || 0;
63435
63411
  const currentAmount = parseFloat(amountUsd) || 0;
63436
63412
  if (currentAmount > 0 && currentAmount < minDeposit) setAmountUsd(minDeposit.toFixed(2));
63437
63413
  }, [tokenChainDetails, view, prefillAmountUsd]);
63438
- React292.useEffect(() => {
63414
+ React302.useEffect(() => {
63439
63415
  if (view === "review") setShowTransactionDetails(false);
63440
63416
  }, [view]);
63441
- React292.useEffect(() => {
63417
+ React302.useEffect(() => {
63442
63418
  if (view !== "enter_amount" && view !== "review" || !selectedBalance || !activeDepositWallet) return;
63443
63419
  let cancelled = false;
63444
63420
  const fetchTokenDetails = async () => {
@@ -63465,7 +63441,7 @@ function WalletConnect({
63465
63441
  cancelled = true;
63466
63442
  };
63467
63443
  }, [view, selectedBalance, publishableKey, activeDepositWallet]);
63468
- React292.useEffect(() => {
63444
+ React302.useEffect(() => {
63469
63445
  if (!activeWalletInfo || !activeDepositWallet) return;
63470
63446
  let cancelled = false;
63471
63447
  setIsLoading(true);
@@ -63498,20 +63474,20 @@ function WalletConnect({
63498
63474
  cancelled = true;
63499
63475
  };
63500
63476
  }, [activeWalletInfo?.address, activeDepositWallet?.chain_type, publishableKey]);
63501
- const usdToTokenRate = React292.useMemo(() => {
63477
+ const usdToTokenRate = React302.useMemo(() => {
63502
63478
  if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
63503
63479
  const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
63504
63480
  const balanceUsd = parseFloat(selectedBalance.amount_usd);
63505
63481
  if (balanceAmount === 0 || balanceUsd === 0) return 0;
63506
63482
  return balanceAmount / balanceUsd;
63507
63483
  }, [selectedBalance, selectedToken]);
63508
- const tokenAmount = React292.useMemo(() => {
63484
+ const tokenAmount = React302.useMemo(() => {
63509
63485
  if (isCheckoutMode && activeCheckoutQuote && selectedToken) return Number(activeCheckoutQuote.sourceAmount) / 10 ** activeCheckoutQuote.sourceTokenDecimals;
63510
63486
  const usdNum = parseFloat(amountUsd) || 0;
63511
63487
  if (usdNum === 0 || usdToTokenRate === 0) return 0;
63512
63488
  return usdNum * usdToTokenRate;
63513
63489
  }, [amountUsd, usdToTokenRate, isCheckoutMode, activeCheckoutQuote, selectedToken]);
63514
- React292.useEffect(() => {
63490
+ React302.useEffect(() => {
63515
63491
  if (isCheckoutMode && activeCheckoutQuote?.sourceAmountUsd && view === "enter_amount") setAmountUsd(activeCheckoutQuote.sourceAmountUsd);
63516
63492
  }, [isCheckoutMode, activeCheckoutQuote, view]);
63517
63493
  const maxTokenAmount = selectedBalance && selectedToken ? Number(selectedBalance.amount) / 10 ** selectedToken.decimals : 0;
@@ -63519,7 +63495,7 @@ function WalletConnect({
63519
63495
  const inputUsdNum = parseFloat(amountUsd) || 0;
63520
63496
  const minDepositUsd = tokenChainDetails?.minimum_deposit_amount_usd || 0;
63521
63497
  const isValidAmount = isCheckoutMode && activeCheckoutQuote ? tokenAmount > 0 && tokenAmount <= maxTokenAmount : inputUsdNum > 0 && inputUsdNum <= maxUsdAmount && inputUsdNum >= minDepositUsd;
63522
- const formattedTokenAmount = React292.useMemo(() => {
63498
+ const formattedTokenAmount = React302.useMemo(() => {
63523
63499
  if (tokenAmount === 0 || !selectedToken) return null;
63524
63500
  return `${tokenAmount.toFixed(6)} ${selectedToken.symbol}`.replace(/\.?0+$/, "");
63525
63501
  }, [tokenAmount, selectedToken]);
@@ -63567,16 +63543,25 @@ function WalletConnect({
63567
63543
  } catch (err) {
63568
63544
  console.warn("[WalletConnect] disconnect error:", err);
63569
63545
  } finally {
63570
- setActiveWalletInfo(null);
63571
- setActiveDepositWallet(null);
63572
- setSelectedBalance(null);
63573
- setBalances([]);
63574
- setTotalBalanceUsd(null);
63575
- setAmountUsd(prefillAmountUsd ?? "");
63576
- setError(null);
63577
63546
  setIsDisconnectingWallet(false);
63578
- if (onWalletDisconnect) onWalletDisconnect();
63579
- else parentOnBack?.();
63547
+ const clearWalletState = () => {
63548
+ setActiveWalletInfo(null);
63549
+ setActiveDepositWallet(null);
63550
+ setSelectedBalance(null);
63551
+ setBalances([]);
63552
+ setTotalBalanceUsd(null);
63553
+ setAmountUsd(prefillAmountUsd ?? "");
63554
+ setError(null);
63555
+ };
63556
+ if (standalone) {
63557
+ onWalletDisconnect?.();
63558
+ transitionTo("select_wallet");
63559
+ setTimeout(clearWalletState, 160);
63560
+ } else {
63561
+ clearWalletState();
63562
+ if (onWalletDisconnect) onWalletDisconnect();
63563
+ else parentOnBack?.();
63564
+ }
63580
63565
  }
63581
63566
  };
63582
63567
  const handleReview = () => {
@@ -63702,9 +63687,15 @@ function WalletConnect({
63702
63687
  setIsConfirming(false);
63703
63688
  }
63704
63689
  };
63690
+ if (standalone && !autoResolved) {
63691
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { style: viewTransitionStyle, children: [
63692
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: "Connect Wallet", showBack: canGoBack, onBack: handleBack, onClose }),
63693
+ /* @__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 } }) })
63694
+ ] });
63695
+ }
63705
63696
  if (view === "select_wallet") {
63706
63697
  return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { style: viewTransitionStyle, children: [
63707
- /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: "Connect Wallet", showBack: true, onBack: handleBack, onClose }),
63698
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: "Connect Wallet", showBack: canGoBack, onBack: handleBack, onClose }),
63708
63699
  /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-pb-4", children: [
63709
63700
  /* @__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" }),
63710
63701
  /* @__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)(
@@ -63867,8 +63858,19 @@ function DepositModal({
63867
63858
  if (s === "tracker" && hideDepositTracker) return "main";
63868
63859
  if (s === "cashapp" && !enableCashApp) return "main";
63869
63860
  if (s === "card" && enableFiatOnramp === false) return "main";
63861
+ if (s === "pay_with_exchange") return enablePayWithExchange === false ? "main" : "exchange";
63862
+ if (s === "exchange_connect") return enableConnectExchange ? "coinbase_connect" : "main";
63863
+ if (s === "wallet_connect") return enableConnectWallet ? "wallet_connect" : "main";
63870
63864
  return s;
63871
- }, [initialScreen, hideDepositTracker, enableCashApp, enableFiatOnramp]);
63865
+ }, [
63866
+ initialScreen,
63867
+ hideDepositTracker,
63868
+ enableCashApp,
63869
+ enableFiatOnramp,
63870
+ enablePayWithExchange,
63871
+ enableConnectExchange,
63872
+ enableConnectWallet
63873
+ ]);
63872
63874
  const [containerEl, setContainerEl] = (0, import_react3.useState)(null);
63873
63875
  const containerCallbackRef = (0, import_react3.useCallback)((el) => {
63874
63876
  setContainerEl(el);
@@ -63992,6 +63994,12 @@ function DepositModal({
63992
63994
  setCardView("amount");
63993
63995
  }
63994
63996
  }, [view, showFiatOnramp]);
63997
+ (0, import_react3.useEffect)(() => {
63998
+ if (view === "exchange" && !showPayWithExchange) {
63999
+ setView("main");
64000
+ setExchangeView("providers");
64001
+ }
64002
+ }, [view, showPayWithExchange]);
63995
64003
  const { exchanges, isLoading: exchangesLoading } = useExchanges({
63996
64004
  publishableKey,
63997
64005
  enabled: open && showPayWithExchange
@@ -64111,7 +64119,7 @@ function DepositModal({
64111
64119
  setBrowserWalletChainType(void 0);
64112
64120
  setBrowserWalletInfo(null);
64113
64121
  setBrowserWalletModalOpen(false);
64114
- if (view === "wallet_connect") setView("main");
64122
+ if (view === "wallet_connect" && sessionOpenedFromMenu) setView("main");
64115
64123
  };
64116
64124
  const handleExchangeDisconnect = () => {
64117
64125
  const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
@@ -64120,7 +64128,7 @@ function DepositModal({
64120
64128
  }
64121
64129
  clearStoredIntegrationToken(IntegrationProvider.COINBASE);
64122
64130
  setConnectedExchange(null);
64123
- if (view === "coinbase_connect") setView("main");
64131
+ if (view === "coinbase_connect" && sessionOpenedFromMenu) setView("main");
64124
64132
  };
64125
64133
  const handleClose = () => {
64126
64134
  onOpenChange(false);
@@ -64132,6 +64140,7 @@ function DepositModal({
64132
64140
  setCardView("amount");
64133
64141
  setExchangeView("providers");
64134
64142
  setBrowserWalletInfo(null);
64143
+ setCoinbaseSkipToHoldings(false);
64135
64144
  resetViewTimeoutRef.current = null;
64136
64145
  }, 200);
64137
64146
  };
@@ -64146,6 +64155,7 @@ function DepositModal({
64146
64155
  setExchangeView("providers");
64147
64156
  setBrowserWalletInfo(null);
64148
64157
  setSelectedExecution(null);
64158
+ setCoinbaseSkipToHoldings(false);
64149
64159
  }, [open, effectiveInitialScreen]);
64150
64160
  (0, import_react3.useEffect)(
64151
64161
  () => () => {
@@ -64505,7 +64515,7 @@ function DepositModal({
64505
64515
  DepositHeader,
64506
64516
  {
64507
64517
  title: payWithExchangeTitle,
64508
- showBack: true,
64518
+ showBack: exchangeView === "pending" || sessionOpenedFromMenu,
64509
64519
  onBack: handleBack,
64510
64520
  onClose: handleClose
64511
64521
  }
@@ -64559,6 +64569,7 @@ function DepositModal({
64559
64569
  onClose: handleClose,
64560
64570
  onDisconnect: handleExchangeDisconnect,
64561
64571
  skipToHoldings: coinbaseSkipToHoldings,
64572
+ canGoBack: sessionOpenedFromMenu,
64562
64573
  onExecutionsChange: setDepositExecutions
64563
64574
  }
64564
64575
  ),
@@ -64596,7 +64607,9 @@ function DepositModal({
64596
64607
  setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
64597
64608
  },
64598
64609
  onBack: handleBack,
64599
- onClose: handleClose
64610
+ onClose: handleClose,
64611
+ canGoBack: sessionOpenedFromMenu,
64612
+ depositWalletsLoading: walletsLoading
64600
64613
  }
64601
64614
  ),
64602
64615
  depositPoweredByFooter
@@ -64605,7 +64618,7 @@ function DepositModal({
64605
64618
  DepositHeader,
64606
64619
  {
64607
64620
  title: cashAppView !== "amount" && cashAppAmount ? `Pay $${cashAppAmount} via Cash App` : "Pay with Cash App",
64608
- showBack: true,
64621
+ showBack: cashAppView !== "amount" || sessionOpenedFromMenu,
64609
64622
  onBack: handleBack,
64610
64623
  onClose: handleClose
64611
64624
  }