@unifold/ui-web 0.1.60 → 0.1.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +380 -360
  2. package/dist/index.mjs +380 -360
  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);
@@ -43182,6 +43183,7 @@ async function createDepositAddress(overrides, publishableKey) {
43182
43183
  recipient_address: overrides?.recipient_address || DEFAULT_CONFIG.recipientAddress || "0x309a4154a2CD4153Da886E780890C9cb5161553C",
43183
43184
  ...overrides?.action_type ? { action_type: overrides.action_type } : {},
43184
43185
  ...overrides?.source_chain_type ? { source_chain_type: overrides.source_chain_type } : {},
43186
+ ...overrides?.contract_calls ? { contract_calls: overrides.contract_calls } : {},
43185
43187
  client_metadata: overrides?.client_metadata || {}
43186
43188
  };
43187
43189
  const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
@@ -50666,6 +50668,7 @@ function useDepositAddress(params) {
50666
50668
  destinationChainId,
50667
50669
  destinationTokenAddress,
50668
50670
  actionType,
50671
+ contractCalls,
50669
50672
  enabled = true
50670
50673
  } = params;
50671
50674
  return useQuery({
@@ -50678,6 +50681,7 @@ function useDepositAddress(params) {
50678
50681
  destinationChainId ?? null,
50679
50682
  destinationTokenAddress ?? null,
50680
50683
  actionType ?? null,
50684
+ contractCalls ?? null,
50681
50685
  publishableKey
50682
50686
  ],
50683
50687
  queryFn: () => createDepositAddress(
@@ -50687,7 +50691,8 @@ function useDepositAddress(params) {
50687
50691
  destination_chain_type: destinationChainType,
50688
50692
  destination_chain_id: destinationChainId,
50689
50693
  destination_token_address: destinationTokenAddress,
50690
- action_type: actionType
50694
+ action_type: actionType,
50695
+ contract_calls: contractCalls
50691
50696
  },
50692
50697
  publishableKey
50693
50698
  ),
@@ -55178,6 +55183,190 @@ function collectAllEip6963EthProviders() {
55178
55183
  if (!store) return [];
55179
55184
  return store.getProviders().map((d) => d.provider);
55180
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
+ }
55181
55370
  var SOLANA_DISCONNECT_TYPES = [
55182
55371
  "phantom-solana",
55183
55372
  "solflare",
@@ -55265,7 +55454,7 @@ function MetamaskIcon({
55265
55454
  className,
55266
55455
  variant = "color"
55267
55456
  }) {
55268
- const id = React122.useId();
55457
+ const id = React132.useId();
55269
55458
  if (variant === "light" || variant === "dark") {
55270
55459
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
55271
55460
  "svg",
@@ -55390,7 +55579,7 @@ function PhantomIcon({
55390
55579
  className,
55391
55580
  variant = "color"
55392
55581
  }) {
55393
- const id = React132.useId();
55582
+ const id = React142.useId();
55394
55583
  if (variant === "light") {
55395
55584
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
55396
55585
  "svg",
@@ -55461,7 +55650,7 @@ function CoinbaseIcon({
55461
55650
  className,
55462
55651
  variant = "color"
55463
55652
  }) {
55464
- const id = React142.useId();
55653
+ const id = React152.useId();
55465
55654
  if (variant === "light") {
55466
55655
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
55467
55656
  "svg",
@@ -55545,7 +55734,7 @@ function RabbyIcon({
55545
55734
  className,
55546
55735
  variant = "color"
55547
55736
  }) {
55548
- const id = React152.useId();
55737
+ const id = React162.useId();
55549
55738
  if (variant === "light") {
55550
55739
  return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
55551
55740
  "svg",
@@ -55896,7 +56085,7 @@ function RainbowIcon({
55896
56085
  className,
55897
56086
  variant = "color"
55898
56087
  }) {
55899
- const id = React162.useId();
56088
+ const id = React172.useId();
55900
56089
  if (variant === "light") {
55901
56090
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
55902
56091
  "svg",
@@ -56362,7 +56551,7 @@ function TrustIcon({
56362
56551
  className,
56363
56552
  variant = "color"
56364
56553
  }) {
56365
- const id = React172.useId();
56554
+ const id = React182.useId();
56366
56555
  if (variant === "light") {
56367
56556
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
56368
56557
  "svg",
@@ -56455,7 +56644,7 @@ function OkxIcon({
56455
56644
  className,
56456
56645
  variant = "color"
56457
56646
  }) {
56458
- const id = React182.useId();
56647
+ const id = React192.useId();
56459
56648
  if (variant === "light") {
56460
56649
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
56461
56650
  "svg",
@@ -56526,7 +56715,7 @@ function GlowIcon({
56526
56715
  className,
56527
56716
  variant = "color"
56528
56717
  }) {
56529
- const id = React192.useId();
56718
+ const id = React202.useId();
56530
56719
  if (variant === "light") {
56531
56720
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
56532
56721
  "svg",
@@ -56631,7 +56820,7 @@ function BackpackIcon({
56631
56820
  className,
56632
56821
  variant = "color"
56633
56822
  }) {
56634
- const id = React202.useId();
56823
+ const id = React212.useId();
56635
56824
  if (variant === "light") {
56636
56825
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
56637
56826
  "svg",
@@ -56708,7 +56897,7 @@ function SolflareIcon({
56708
56897
  className,
56709
56898
  variant = "color"
56710
56899
  }) {
56711
- const id = React212.useId();
56900
+ const id = React2222.useId();
56712
56901
  if (variant === "light") {
56713
56902
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
56714
56903
  "svg",
@@ -56779,7 +56968,7 @@ function EthereumIcon({
56779
56968
  className,
56780
56969
  variant = "color"
56781
56970
  }) {
56782
- const id = React2222.useId();
56971
+ const id = React232.useId();
56783
56972
  if (variant === "light") {
56784
56973
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
56785
56974
  "svg",
@@ -56913,7 +57102,7 @@ function SolanaIcon({
56913
57102
  className,
56914
57103
  variant = "color"
56915
57104
  }) {
56916
- const id = React232.useId();
57105
+ const id = React242.useId();
56917
57106
  if (variant === "light") {
56918
57107
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
56919
57108
  "svg",
@@ -57162,44 +57351,6 @@ function truncateAddress3(address) {
57162
57351
  if (address.length <= 10) return address;
57163
57352
  return `${address.slice(0, 4)}...${address.slice(-4)}`;
57164
57353
  }
57165
- function identifyEthWallet(provider, _win, hint) {
57166
- switch (hint) {
57167
- case "metamask":
57168
- return { type: "metamask", name: "MetaMask", icon: "metamask" };
57169
- case "phantom":
57170
- return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
57171
- case "coinbase":
57172
- return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
57173
- case "okx":
57174
- return { type: "okx", name: "OKX Wallet", icon: "okx" };
57175
- case "rabby":
57176
- return { type: "rabby", name: "Rabby", icon: "rabby" };
57177
- case "trust":
57178
- return { type: "trust", name: "Trust Wallet", icon: "trust" };
57179
- case "rainbow":
57180
- return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
57181
- }
57182
- const anyProvider = provider;
57183
- if (provider.isPhantom) {
57184
- return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
57185
- }
57186
- if (anyProvider.isCoinbaseWallet) {
57187
- return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
57188
- }
57189
- if (anyProvider.isRabby) {
57190
- return { type: "rabby", name: "Rabby", icon: "rabby" };
57191
- }
57192
- if (anyProvider.isTrust) {
57193
- return { type: "trust", name: "Trust Wallet", icon: "trust" };
57194
- }
57195
- if (anyProvider.isRainbow) {
57196
- return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
57197
- }
57198
- if (provider.isMetaMask && !provider.isPhantom) {
57199
- return { type: "metamask", name: "MetaMask", icon: "metamask" };
57200
- }
57201
- return { type: "metamask", name: "Wallet", icon: "metamask" };
57202
- }
57203
57354
  function BrowserWalletButton({
57204
57355
  onClick,
57205
57356
  onConnectClick,
@@ -57210,30 +57361,19 @@ function BrowserWalletButton({
57210
57361
  subtitle = i18n2.depositModal.browserWallet.subtitle
57211
57362
  }) {
57212
57363
  const { colors: colors2, fonts, components } = useTheme();
57213
- const [isHovered, setIsHovered] = React242.useState(false);
57214
- const [isTouchDevice, setIsTouchDevice] = React242.useState(false);
57215
- const [wallet, setWallet] = React242.useState(null);
57216
- const [isLoading, setIsLoading] = React242.useState(true);
57217
- const [isConnecting, setIsConnecting] = React242.useState(false);
57218
- const [balanceText, setBalanceText] = React242.useState(null);
57219
- const [isLoadingBalance, setIsLoadingBalance] = React242.useState(false);
57220
- const [isDisconnecting, setIsDisconnecting] = React242.useState(false);
57221
- 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);
57222
57372
  onDisconnectRef.current = onDisconnect;
57223
- React242.useEffect(() => {
57373
+ React252.useEffect(() => {
57224
57374
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
57225
57375
  }, []);
57226
- const [eip6963ProviderCount, setEip6963ProviderCount] = React242.useState(0);
57227
- React242.useEffect(() => {
57228
- const store = getEip6963Store();
57229
- if (!store) return;
57230
- setEip6963ProviderCount(store.getProviders().length);
57231
- const unsubscribe = store.subscribe((providers) => {
57232
- setEip6963ProviderCount(providers.length);
57233
- });
57234
- return unsubscribe;
57235
- }, []);
57236
- React242.useEffect(() => {
57376
+ React252.useEffect(() => {
57237
57377
  if (!wallet || !publishableKey) {
57238
57378
  setBalanceText(null);
57239
57379
  return;
@@ -57274,206 +57414,6 @@ function BrowserWalletButton({
57274
57414
  cancelled = true;
57275
57415
  };
57276
57416
  }, [wallet, publishableKey]);
57277
- React242.useEffect(() => {
57278
- let mounted = true;
57279
- const detectWallet = async () => {
57280
- if (!mounted) return;
57281
- setIsLoading(true);
57282
- try {
57283
- const win = typeof window !== "undefined" ? window : null;
57284
- if (!win) return;
57285
- if (getUserDisconnectedWallet()) {
57286
- if (mounted) {
57287
- setWallet(null);
57288
- setIsLoading(false);
57289
- }
57290
- return;
57291
- }
57292
- if (!chainType || chainType === "solana") {
57293
- const anyWin = win;
57294
- const trySilentSolana = async (provider, type, name, icon) => {
57295
- if (!provider) return false;
57296
- if (provider.isConnected && provider.publicKey) {
57297
- if (mounted) {
57298
- setWallet({
57299
- type,
57300
- name,
57301
- address: provider.publicKey.toString(),
57302
- icon
57303
- });
57304
- setIsLoading(false);
57305
- }
57306
- return true;
57307
- }
57308
- try {
57309
- const resp = await provider.connect({ onlyIfTrusted: true });
57310
- if (mounted && resp.publicKey) {
57311
- setWallet({
57312
- type,
57313
- name,
57314
- address: resp.publicKey.toString(),
57315
- icon
57316
- });
57317
- setIsLoading(false);
57318
- return true;
57319
- }
57320
- } catch {
57321
- }
57322
- return false;
57323
- };
57324
- if (await trySilentSolana(
57325
- win.phantom?.solana,
57326
- "phantom-solana",
57327
- "Phantom",
57328
- "phantom"
57329
- ))
57330
- return;
57331
- if (await trySilentSolana(
57332
- anyWin.solflare,
57333
- "solflare",
57334
- "Solflare",
57335
- "solflare"
57336
- ))
57337
- return;
57338
- if (await trySilentSolana(
57339
- anyWin.backpack,
57340
- "backpack",
57341
- "Backpack",
57342
- "backpack"
57343
- ))
57344
- return;
57345
- if (await trySilentSolana(
57346
- anyWin.glow,
57347
- "glow",
57348
- "Glow",
57349
- "glow"
57350
- ))
57351
- return;
57352
- }
57353
- if (!chainType || chainType === "ethereum") {
57354
- const anyWin = win;
57355
- const allProviders = [];
57356
- const eip6963 = getEip6963Providers();
57357
- for (const { provider, walletId } of eip6963) {
57358
- allProviders.push({
57359
- provider,
57360
- walletId: walletId === "unknown" ? "default" : walletId
57361
- });
57362
- }
57363
- if (allProviders.length === 0) {
57364
- if (win.phantom?.ethereum) {
57365
- allProviders.push({
57366
- provider: win.phantom.ethereum,
57367
- walletId: "phantom"
57368
- });
57369
- }
57370
- if (anyWin.okxwallet) {
57371
- allProviders.push({
57372
- provider: anyWin.okxwallet,
57373
- walletId: "okx"
57374
- });
57375
- }
57376
- if (anyWin.coinbaseWalletExtension) {
57377
- allProviders.push({
57378
- provider: anyWin.coinbaseWalletExtension,
57379
- walletId: "coinbase"
57380
- });
57381
- }
57382
- if (win.ethereum) {
57383
- const isDuplicate = allProviders.some(
57384
- (p) => p.provider === win.ethereum
57385
- );
57386
- if (!isDuplicate) {
57387
- allProviders.push({
57388
- provider: win.ethereum,
57389
- walletId: "default"
57390
- });
57391
- }
57392
- }
57393
- }
57394
- for (const { provider, walletId } of allProviders) {
57395
- if (!provider) continue;
57396
- try {
57397
- const accounts = await provider.request({
57398
- method: "eth_accounts"
57399
- });
57400
- if (!accounts || accounts.length === 0) continue;
57401
- const address = accounts[0];
57402
- const resolved = identifyEthWallet(provider, anyWin, walletId);
57403
- if (mounted) {
57404
- setWallet({ ...resolved, address });
57405
- setIsLoading(false);
57406
- }
57407
- return;
57408
- } catch {
57409
- }
57410
- }
57411
- }
57412
- if (mounted) {
57413
- setWallet(null);
57414
- setIsLoading(false);
57415
- }
57416
- } catch (error) {
57417
- console.error("[BrowserWalletButton] Error detecting wallet:", error);
57418
- if (mounted) {
57419
- setWallet(null);
57420
- setIsLoading(false);
57421
- }
57422
- }
57423
- };
57424
- detectWallet();
57425
- const handleAccountsChanged = () => {
57426
- detectWallet();
57427
- };
57428
- const handleDisconnect = () => {
57429
- onDisconnectRef.current?.();
57430
- detectWallet();
57431
- };
57432
- const handleEthAccountsChanged = (accounts) => {
57433
- if (Array.isArray(accounts) && accounts.length === 0) {
57434
- onDisconnectRef.current?.();
57435
- }
57436
- detectWallet();
57437
- };
57438
- const solanaProvider = window.phantom?.solana || window.solana;
57439
- if (solanaProvider) {
57440
- solanaProvider.on("connect", handleAccountsChanged);
57441
- solanaProvider.on("disconnect", handleDisconnect);
57442
- solanaProvider.on("accountChanged", handleAccountsChanged);
57443
- }
57444
- const ethProviders = [];
57445
- for (const { provider } of getEip6963Providers()) {
57446
- const p = provider;
57447
- if (p && !ethProviders.includes(p)) {
57448
- ethProviders.push(p);
57449
- }
57450
- }
57451
- if (window.ethereum && !ethProviders.includes(window.ethereum)) {
57452
- ethProviders.push(window.ethereum);
57453
- }
57454
- if (window.phantom?.ethereum && !ethProviders.includes(window.phantom.ethereum)) {
57455
- ethProviders.push(window.phantom.ethereum);
57456
- }
57457
- for (const provider of ethProviders) {
57458
- provider.on("accountsChanged", handleEthAccountsChanged);
57459
- provider.on("chainChanged", handleAccountsChanged);
57460
- }
57461
- return () => {
57462
- mounted = false;
57463
- if (solanaProvider) {
57464
- solanaProvider.off("connect", handleAccountsChanged);
57465
- solanaProvider.off("disconnect", handleDisconnect);
57466
- solanaProvider.off("accountChanged", handleAccountsChanged);
57467
- }
57468
- for (const provider of ethProviders) {
57469
- const off = provider.off?.bind(provider) ?? provider.removeListener?.bind(provider);
57470
- if (off) {
57471
- off("accountsChanged", handleEthAccountsChanged);
57472
- off("chainChanged", handleAccountsChanged);
57473
- }
57474
- }
57475
- };
57476
- }, [chainType, eip6963ProviderCount]);
57477
57417
  const handleConnect = async () => {
57478
57418
  if (wallet) {
57479
57419
  onClick(wallet);
@@ -57557,7 +57497,7 @@ function BrowserWalletButton({
57557
57497
  border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
57558
57498
  };
57559
57499
  const sortedWallets = featuredWallets ? [...featuredWallets].sort((a, b) => a.position - b.position) : [];
57560
- 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], {
57561
57501
  size: 36,
57562
57502
  className: "uf-rounded-lg",
57563
57503
  variant: "color"
@@ -57819,6 +57759,7 @@ function CoinbaseConnect({
57819
57759
  onBack: parentOnBack,
57820
57760
  onDisconnect,
57821
57761
  skipToHoldings,
57762
+ canGoBack = true,
57822
57763
  onExecutionsChange
57823
57764
  }) {
57824
57765
  const { colors: colors2, fonts, components } = useTheme();
@@ -58206,6 +58147,16 @@ function CoinbaseConnect({
58206
58147
  setIsLoading(false);
58207
58148
  }
58208
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
+ };
58209
58160
  const handleBack = () => {
58210
58161
  switch (view) {
58211
58162
  case "select_exchange":
@@ -58266,7 +58217,7 @@ function CoinbaseConnect({
58266
58217
  DepositHeader,
58267
58218
  {
58268
58219
  title: t12.title,
58269
- showBack: true,
58220
+ showBack: canGoBack,
58270
58221
  onBack: handleBack,
58271
58222
  onClose
58272
58223
  }
@@ -58279,7 +58230,7 @@ function CoinbaseConnect({
58279
58230
  DepositHeader,
58280
58231
  {
58281
58232
  title: t12.title,
58282
- showBack: true,
58233
+ showBack: canGoBack,
58283
58234
  onBack: handleBack,
58284
58235
  onClose
58285
58236
  }
@@ -58991,7 +58942,7 @@ function CoinbaseConnect({
58991
58942
  borderRadius: components.button.borderRadius,
58992
58943
  fontFamily: fonts.medium
58993
58944
  },
58994
- onClick: onDisconnect,
58945
+ onClick: handleDisconnect,
58995
58946
  children: t12.disconnect
58996
58947
  }
58997
58948
  )
@@ -59778,7 +59729,7 @@ function ThemeStyleInjector({
59778
59729
  className
59779
59730
  }) {
59780
59731
  const { colors: colors2, fonts, mode } = useTheme();
59781
- const cssVars = React262.useMemo(() => {
59732
+ const cssVars = React272.useMemo(() => {
59782
59733
  const hexToHSL = (hex) => {
59783
59734
  hex = hex.replace("#", "");
59784
59735
  const r2 = parseInt(hex.slice(0, 2), 16) / 255;
@@ -59838,7 +59789,7 @@ function ThemeStyleInjector({
59838
59789
  ...fonts.regular ? { "--uf-font-family": fonts.regular } : {}
59839
59790
  };
59840
59791
  }, [colors2, fonts.regular]);
59841
- React262.useEffect(() => {
59792
+ React272.useEffect(() => {
59842
59793
  if (typeof document === "undefined") return;
59843
59794
  if (fonts.regular) {
59844
59795
  document.documentElement.style.setProperty(
@@ -60797,14 +60748,14 @@ function useCopyAddress() {
60797
60748
  return { copied, handleCopy };
60798
60749
  }
60799
60750
  var TooltipProvider2 = Provider;
60800
- var TooltipContext = React272.createContext({
60751
+ var TooltipContext = React282.createContext({
60801
60752
  open: false,
60802
60753
  onOpenChange: () => {
60803
60754
  }
60804
60755
  });
60805
- var TooltipTrigger2 = React272.forwardRef(({ onClick, ...props }, ref) => {
60806
- const { open, onOpenChange } = React272.useContext(TooltipContext);
60807
- const handleClick = React272.useCallback(
60756
+ var TooltipTrigger2 = React282.forwardRef(({ onClick, ...props }, ref) => {
60757
+ const { open, onOpenChange } = React282.useContext(TooltipContext);
60758
+ const handleClick = React282.useCallback(
60808
60759
  (e) => {
60809
60760
  onOpenChange(!open);
60810
60761
  onClick?.(e);
@@ -60814,7 +60765,7 @@ var TooltipTrigger2 = React272.forwardRef(({ onClick, ...props }, ref) => {
60814
60765
  return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Trigger, { ref, onClick: handleClick, ...props });
60815
60766
  });
60816
60767
  TooltipTrigger2.displayName = Trigger.displayName;
60817
- var TooltipContent2 = React272.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
60768
+ var TooltipContent2 = React282.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
60818
60769
  const { themeClass, colors: colors2 } = useTheme();
60819
60770
  return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Portal3, { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
60820
60771
  Content22,
@@ -61419,7 +61370,7 @@ function TransferCryptoSingleInput({
61419
61370
  }
61420
61371
  var Select2 = Root23;
61421
61372
  var SelectValue2 = Value;
61422
- var SelectTrigger2 = React282.forwardRef(({ className, style, children, ...props }, ref) => {
61373
+ var SelectTrigger2 = React292.forwardRef(({ className, style, children, ...props }, ref) => {
61423
61374
  const { components } = useTheme();
61424
61375
  return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61425
61376
  Trigger2,
@@ -61443,7 +61394,7 @@ var SelectTrigger2 = React282.forwardRef(({ className, style, children, ...props
61443
61394
  );
61444
61395
  });
61445
61396
  SelectTrigger2.displayName = Trigger2.displayName;
61446
- 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)(
61447
61398
  ScrollUpButton,
61448
61399
  {
61449
61400
  ref,
@@ -61456,7 +61407,7 @@ var SelectScrollUpButton2 = React282.forwardRef(({ className, ...props }, ref) =
61456
61407
  }
61457
61408
  ));
61458
61409
  SelectScrollUpButton2.displayName = ScrollUpButton.displayName;
61459
- 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)(
61460
61411
  ScrollDownButton,
61461
61412
  {
61462
61413
  ref,
@@ -61469,7 +61420,7 @@ var SelectScrollDownButton2 = React282.forwardRef(({ className, ...props }, ref)
61469
61420
  }
61470
61421
  ));
61471
61422
  SelectScrollDownButton2.displayName = ScrollDownButton.displayName;
61472
- var SelectContent2 = React282.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
61423
+ var SelectContent2 = React292.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
61473
61424
  const { themeClass, colors: colors2, components } = useTheme();
61474
61425
  return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Portal4, { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61475
61426
  Content23,
@@ -61507,7 +61458,7 @@ var SelectContent2 = React282.forwardRef(({ className, style, children, position
61507
61458
  ) });
61508
61459
  });
61509
61460
  SelectContent2.displayName = Content23.displayName;
61510
- 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)(
61511
61462
  Label,
61512
61463
  {
61513
61464
  ref,
@@ -61519,7 +61470,7 @@ var SelectLabel2 = React282.forwardRef(({ className, ...props }, ref) => /* @__P
61519
61470
  }
61520
61471
  ));
61521
61472
  SelectLabel2.displayName = Label.displayName;
61522
- 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)(
61523
61474
  Item,
61524
61475
  {
61525
61476
  ref,
@@ -61535,7 +61486,7 @@ var SelectItem2 = React282.forwardRef(({ className, children, ...props }, ref) =
61535
61486
  }
61536
61487
  ));
61537
61488
  SelectItem2.displayName = Item.displayName;
61538
- 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)(
61539
61490
  Separator,
61540
61491
  {
61541
61492
  ref,
@@ -63199,22 +63150,27 @@ function WalletConnect({
63199
63150
  productType,
63200
63151
  onBack: parentOnBack,
63201
63152
  onClose,
63153
+ canGoBack = true,
63154
+ depositWalletsLoading = false,
63202
63155
  onExecutionsChange
63203
63156
  }) {
63204
63157
  const { colors: colors2, fonts, components } = useTheme();
63205
- const walletProvidedAtMount = React292.useRef(!!initialWalletInfo && !!initialDepositWallet);
63206
- const [activeWalletInfo, setActiveWalletInfo] = React292.useState(initialWalletInfo ?? null);
63207
- 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);
63208
63161
  const initialView = initialWalletInfo && initialDepositWallet ? "select_token" : "select_wallet";
63209
- const [view, setView] = React292.useState(initialView);
63210
- const [isTransitioning, setIsTransitioning] = React292.useState(false);
63211
- const viewRef = React292.useRef(initialView);
63212
- const [selectedWalletDef, setSelectedWalletDef] = React292.useState(null);
63213
- const [connectingNetwork, setConnectingNetwork] = React292.useState(null);
63214
- const [walletError, setWalletError] = React292.useState(null);
63215
- const [isWalletConnecting, setIsWalletConnecting] = React292.useState(false);
63216
- const [eip6963ProviderCount, setEip6963ProviderCount] = React292.useState(0);
63217
- 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(() => {
63218
63174
  const store = getEip6963Store();
63219
63175
  if (!store) return;
63220
63176
  setEip6963ProviderCount(store.getProviders().length);
@@ -63222,20 +63178,44 @@ function WalletConnect({
63222
63178
  setEip6963ProviderCount(providers.length);
63223
63179
  });
63224
63180
  }, []);
63225
- const availableWallets = React292.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
63226
- const [balances, setBalances] = React292.useState([]);
63227
- const [isLoading, setIsLoading] = React292.useState(false);
63228
- const [selectedBalance, setSelectedBalance] = React292.useState(null);
63229
- const [totalBalanceUsd, setTotalBalanceUsd] = React292.useState(null);
63230
- const [error, setError] = React292.useState(null);
63231
- const [isDisconnectingWallet, setIsDisconnectingWallet] = React292.useState(false);
63232
- const [amountUsd, setAmountUsd] = React292.useState(prefillAmountUsd ?? "");
63233
- const [isConfirming, setIsConfirming] = React292.useState(false);
63234
- const [hasSignedTransaction, setHasSignedTransaction] = React292.useState(false);
63235
- const [tokenChainDetails, setTokenChainDetails] = React292.useState(null);
63236
- const [loadingTokenDetails, setLoadingTokenDetails] = React292.useState(false);
63237
- const [showTransactionDetails, setShowTransactionDetails] = React292.useState(false);
63238
- 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);
63239
63219
  const walletInfo = activeWalletInfo;
63240
63220
  const depositWallet = activeDepositWallet;
63241
63221
  const hasWallet = !!activeWalletInfo && !!activeDepositWallet;
@@ -63243,7 +63223,7 @@ function WalletConnect({
63243
63223
  const recipientAddress = activeDepositWallet?.address ?? "";
63244
63224
  const isCheckoutMode = !!checkoutAmountUsd;
63245
63225
  const supportedChainType = chainType === "algorand" || chainType === "xrpl" ? "ethereum" : chainType;
63246
- const transitionTo = React292.useCallback((nextView) => {
63226
+ const transitionTo = React302.useCallback((nextView) => {
63247
63227
  if (nextView === viewRef.current) return;
63248
63228
  setIsTransitioning(true);
63249
63229
  setTimeout(() => {
@@ -63380,7 +63360,7 @@ function WalletConnect({
63380
63360
  }
63381
63361
  };
63382
63362
  const selectedToken = selectedBalance ? getTokenFromBalance(selectedBalance) : null;
63383
- const effectiveDestinationAmount = React292.useMemo(() => {
63363
+ const effectiveDestinationAmount = React302.useMemo(() => {
63384
63364
  if (!checkoutRemainingBaseUnits || checkoutRemainingBaseUnits === "0") return "0";
63385
63365
  if (!checkoutAmountUsd) return checkoutRemainingBaseUnits;
63386
63366
  const remaining = BigInt(checkoutRemainingBaseUnits);
@@ -63408,7 +63388,7 @@ function WalletConnect({
63408
63388
  stablecoinParity,
63409
63389
  enabled: isCheckoutMode && !!selectedToken && !!checkoutDestination && effectiveDestinationAmount !== "0"
63410
63390
  });
63411
- const activeCheckoutQuote = React292.useMemo(() => {
63391
+ const activeCheckoutQuote = React302.useMemo(() => {
63412
63392
  if (!isCheckoutMode) return null;
63413
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 };
63414
63394
  return checkoutQuote ?? null;
@@ -63422,19 +63402,19 @@ function WalletConnect({
63422
63402
  onDepositSuccess,
63423
63403
  onDepositError
63424
63404
  });
63425
- React292.useEffect(() => {
63405
+ React302.useEffect(() => {
63426
63406
  onExecutionsChange?.(depositExecutions);
63427
63407
  }, [depositExecutions, onExecutionsChange]);
63428
- React292.useEffect(() => {
63408
+ React302.useEffect(() => {
63429
63409
  if (!prefillAmountUsd || !tokenChainDetails || view !== "enter_amount") return;
63430
63410
  const minDeposit = tokenChainDetails.minimum_deposit_amount_usd || 0;
63431
63411
  const currentAmount = parseFloat(amountUsd) || 0;
63432
63412
  if (currentAmount > 0 && currentAmount < minDeposit) setAmountUsd(minDeposit.toFixed(2));
63433
63413
  }, [tokenChainDetails, view, prefillAmountUsd]);
63434
- React292.useEffect(() => {
63414
+ React302.useEffect(() => {
63435
63415
  if (view === "review") setShowTransactionDetails(false);
63436
63416
  }, [view]);
63437
- React292.useEffect(() => {
63417
+ React302.useEffect(() => {
63438
63418
  if (view !== "enter_amount" && view !== "review" || !selectedBalance || !activeDepositWallet) return;
63439
63419
  let cancelled = false;
63440
63420
  const fetchTokenDetails = async () => {
@@ -63461,7 +63441,7 @@ function WalletConnect({
63461
63441
  cancelled = true;
63462
63442
  };
63463
63443
  }, [view, selectedBalance, publishableKey, activeDepositWallet]);
63464
- React292.useEffect(() => {
63444
+ React302.useEffect(() => {
63465
63445
  if (!activeWalletInfo || !activeDepositWallet) return;
63466
63446
  let cancelled = false;
63467
63447
  setIsLoading(true);
@@ -63494,20 +63474,20 @@ function WalletConnect({
63494
63474
  cancelled = true;
63495
63475
  };
63496
63476
  }, [activeWalletInfo?.address, activeDepositWallet?.chain_type, publishableKey]);
63497
- const usdToTokenRate = React292.useMemo(() => {
63477
+ const usdToTokenRate = React302.useMemo(() => {
63498
63478
  if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
63499
63479
  const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
63500
63480
  const balanceUsd = parseFloat(selectedBalance.amount_usd);
63501
63481
  if (balanceAmount === 0 || balanceUsd === 0) return 0;
63502
63482
  return balanceAmount / balanceUsd;
63503
63483
  }, [selectedBalance, selectedToken]);
63504
- const tokenAmount = React292.useMemo(() => {
63484
+ const tokenAmount = React302.useMemo(() => {
63505
63485
  if (isCheckoutMode && activeCheckoutQuote && selectedToken) return Number(activeCheckoutQuote.sourceAmount) / 10 ** activeCheckoutQuote.sourceTokenDecimals;
63506
63486
  const usdNum = parseFloat(amountUsd) || 0;
63507
63487
  if (usdNum === 0 || usdToTokenRate === 0) return 0;
63508
63488
  return usdNum * usdToTokenRate;
63509
63489
  }, [amountUsd, usdToTokenRate, isCheckoutMode, activeCheckoutQuote, selectedToken]);
63510
- React292.useEffect(() => {
63490
+ React302.useEffect(() => {
63511
63491
  if (isCheckoutMode && activeCheckoutQuote?.sourceAmountUsd && view === "enter_amount") setAmountUsd(activeCheckoutQuote.sourceAmountUsd);
63512
63492
  }, [isCheckoutMode, activeCheckoutQuote, view]);
63513
63493
  const maxTokenAmount = selectedBalance && selectedToken ? Number(selectedBalance.amount) / 10 ** selectedToken.decimals : 0;
@@ -63515,7 +63495,7 @@ function WalletConnect({
63515
63495
  const inputUsdNum = parseFloat(amountUsd) || 0;
63516
63496
  const minDepositUsd = tokenChainDetails?.minimum_deposit_amount_usd || 0;
63517
63497
  const isValidAmount = isCheckoutMode && activeCheckoutQuote ? tokenAmount > 0 && tokenAmount <= maxTokenAmount : inputUsdNum > 0 && inputUsdNum <= maxUsdAmount && inputUsdNum >= minDepositUsd;
63518
- const formattedTokenAmount = React292.useMemo(() => {
63498
+ const formattedTokenAmount = React302.useMemo(() => {
63519
63499
  if (tokenAmount === 0 || !selectedToken) return null;
63520
63500
  return `${tokenAmount.toFixed(6)} ${selectedToken.symbol}`.replace(/\.?0+$/, "");
63521
63501
  }, [tokenAmount, selectedToken]);
@@ -63563,16 +63543,25 @@ function WalletConnect({
63563
63543
  } catch (err) {
63564
63544
  console.warn("[WalletConnect] disconnect error:", err);
63565
63545
  } finally {
63566
- setActiveWalletInfo(null);
63567
- setActiveDepositWallet(null);
63568
- setSelectedBalance(null);
63569
- setBalances([]);
63570
- setTotalBalanceUsd(null);
63571
- setAmountUsd(prefillAmountUsd ?? "");
63572
- setError(null);
63573
63546
  setIsDisconnectingWallet(false);
63574
- if (onWalletDisconnect) onWalletDisconnect();
63575
- 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
+ }
63576
63565
  }
63577
63566
  };
63578
63567
  const handleReview = () => {
@@ -63698,9 +63687,15 @@ function WalletConnect({
63698
63687
  setIsConfirming(false);
63699
63688
  }
63700
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
+ }
63701
63696
  if (view === "select_wallet") {
63702
63697
  return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { style: viewTransitionStyle, children: [
63703
- /* @__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 }),
63704
63699
  /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-pb-4", children: [
63705
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" }),
63706
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)(
@@ -63828,6 +63823,7 @@ function DepositModal({
63828
63823
  destinationChainType,
63829
63824
  destinationChainId,
63830
63825
  destinationTokenAddress,
63826
+ contractCalls,
63831
63827
  defaultSourceChainType,
63832
63828
  defaultSourceChainId,
63833
63829
  defaultSourceTokenAddress,
@@ -63862,8 +63858,19 @@ function DepositModal({
63862
63858
  if (s === "tracker" && hideDepositTracker) return "main";
63863
63859
  if (s === "cashapp" && !enableCashApp) return "main";
63864
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";
63865
63864
  return s;
63866
- }, [initialScreen, hideDepositTracker, enableCashApp, enableFiatOnramp]);
63865
+ }, [
63866
+ initialScreen,
63867
+ hideDepositTracker,
63868
+ enableCashApp,
63869
+ enableFiatOnramp,
63870
+ enablePayWithExchange,
63871
+ enableConnectExchange,
63872
+ enableConnectWallet
63873
+ ]);
63867
63874
  const [containerEl, setContainerEl] = (0, import_react3.useState)(null);
63868
63875
  const containerCallbackRef = (0, import_react3.useCallback)((el) => {
63869
63876
  setContainerEl(el);
@@ -63954,6 +63961,7 @@ function DepositModal({
63954
63961
  destinationChainType,
63955
63962
  destinationChainId,
63956
63963
  destinationTokenAddress,
63964
+ contractCalls,
63957
63965
  enabled: open
63958
63966
  // Only fetch when modal is open
63959
63967
  });
@@ -63986,6 +63994,12 @@ function DepositModal({
63986
63994
  setCardView("amount");
63987
63995
  }
63988
63996
  }, [view, showFiatOnramp]);
63997
+ (0, import_react3.useEffect)(() => {
63998
+ if (view === "exchange" && !showPayWithExchange) {
63999
+ setView("main");
64000
+ setExchangeView("providers");
64001
+ }
64002
+ }, [view, showPayWithExchange]);
63989
64003
  const { exchanges, isLoading: exchangesLoading } = useExchanges({
63990
64004
  publishableKey,
63991
64005
  enabled: open && showPayWithExchange
@@ -64105,7 +64119,7 @@ function DepositModal({
64105
64119
  setBrowserWalletChainType(void 0);
64106
64120
  setBrowserWalletInfo(null);
64107
64121
  setBrowserWalletModalOpen(false);
64108
- if (view === "wallet_connect") setView("main");
64122
+ if (view === "wallet_connect" && sessionOpenedFromMenu) setView("main");
64109
64123
  };
64110
64124
  const handleExchangeDisconnect = () => {
64111
64125
  const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
@@ -64114,7 +64128,7 @@ function DepositModal({
64114
64128
  }
64115
64129
  clearStoredIntegrationToken(IntegrationProvider.COINBASE);
64116
64130
  setConnectedExchange(null);
64117
- if (view === "coinbase_connect") setView("main");
64131
+ if (view === "coinbase_connect" && sessionOpenedFromMenu) setView("main");
64118
64132
  };
64119
64133
  const handleClose = () => {
64120
64134
  onOpenChange(false);
@@ -64126,6 +64140,7 @@ function DepositModal({
64126
64140
  setCardView("amount");
64127
64141
  setExchangeView("providers");
64128
64142
  setBrowserWalletInfo(null);
64143
+ setCoinbaseSkipToHoldings(false);
64129
64144
  resetViewTimeoutRef.current = null;
64130
64145
  }, 200);
64131
64146
  };
@@ -64140,6 +64155,7 @@ function DepositModal({
64140
64155
  setExchangeView("providers");
64141
64156
  setBrowserWalletInfo(null);
64142
64157
  setSelectedExecution(null);
64158
+ setCoinbaseSkipToHoldings(false);
64143
64159
  }, [open, effectiveInitialScreen]);
64144
64160
  (0, import_react3.useEffect)(
64145
64161
  () => () => {
@@ -64499,7 +64515,7 @@ function DepositModal({
64499
64515
  DepositHeader,
64500
64516
  {
64501
64517
  title: payWithExchangeTitle,
64502
- showBack: true,
64518
+ showBack: exchangeView === "pending" || sessionOpenedFromMenu,
64503
64519
  onBack: handleBack,
64504
64520
  onClose: handleClose
64505
64521
  }
@@ -64553,6 +64569,7 @@ function DepositModal({
64553
64569
  onClose: handleClose,
64554
64570
  onDisconnect: handleExchangeDisconnect,
64555
64571
  skipToHoldings: coinbaseSkipToHoldings,
64572
+ canGoBack: sessionOpenedFromMenu,
64556
64573
  onExecutionsChange: setDepositExecutions
64557
64574
  }
64558
64575
  ),
@@ -64590,7 +64607,9 @@ function DepositModal({
64590
64607
  setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
64591
64608
  },
64592
64609
  onBack: handleBack,
64593
- onClose: handleClose
64610
+ onClose: handleClose,
64611
+ canGoBack: sessionOpenedFromMenu,
64612
+ depositWalletsLoading: walletsLoading
64594
64613
  }
64595
64614
  ),
64596
64615
  depositPoweredByFooter
@@ -64599,7 +64618,7 @@ function DepositModal({
64599
64618
  DepositHeader,
64600
64619
  {
64601
64620
  title: cashAppView !== "amount" && cashAppAmount ? `Pay $${cashAppAmount} via Cash App` : "Pay with Cash App",
64602
- showBack: true,
64621
+ showBack: cashAppView !== "amount" || sessionOpenedFromMenu,
64603
64622
  onBack: handleBack,
64604
64623
  onClose: handleClose
64605
64624
  }
@@ -67284,6 +67303,7 @@ function UnifoldProvider2({
67284
67303
  destinationChainType: depositConfig.destinationChainType,
67285
67304
  destinationChainId: depositConfig.destinationChainId,
67286
67305
  destinationTokenAddress: depositConfig.destinationTokenAddress,
67306
+ contractCalls: depositConfig.contractCalls,
67287
67307
  defaultSourceChainType: depositConfig.defaultSourceChainType,
67288
67308
  defaultSourceChainId: depositConfig.defaultSourceChainId,
67289
67309
  defaultSourceTokenAddress: depositConfig.defaultSourceTokenAddress,