@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.js CHANGED
@@ -37153,30 +37153,31 @@ var React102 = __toESM(require_react(), 1);
37153
37153
  var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
37154
37154
  var React112 = __toESM(require_react(), 1);
37155
37155
  var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
37156
- var React242 = __toESM(require_react(), 1);
37156
+ var React252 = __toESM(require_react(), 1);
37157
37157
  var React122 = __toESM(require_react(), 1);
37158
- var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
37159
37158
  var React132 = __toESM(require_react(), 1);
37160
- var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
37159
+ var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
37161
37160
  var React142 = __toESM(require_react(), 1);
37162
- var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
37161
+ var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
37163
37162
  var React152 = __toESM(require_react(), 1);
37164
- var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
37163
+ var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
37165
37164
  var React162 = __toESM(require_react(), 1);
37166
- var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
37165
+ var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
37167
37166
  var React172 = __toESM(require_react(), 1);
37168
- var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
37167
+ var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
37169
37168
  var React182 = __toESM(require_react(), 1);
37170
- var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
37169
+ var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
37171
37170
  var React192 = __toESM(require_react(), 1);
37172
- var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
37171
+ var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
37173
37172
  var React202 = __toESM(require_react(), 1);
37174
- var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
37173
+ var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
37175
37174
  var React212 = __toESM(require_react(), 1);
37176
- var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
37175
+ var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
37177
37176
  var React2222 = __toESM(require_react(), 1);
37178
- var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
37177
+ var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
37179
37178
  var React232 = __toESM(require_react(), 1);
37179
+ var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
37180
+ var React242 = __toESM(require_react(), 1);
37180
37181
  var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
37181
37182
  var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
37182
37183
  var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
@@ -37184,7 +37185,7 @@ var import_react18 = __toESM(require_react(), 1);
37184
37185
  var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
37185
37186
  var import_react19 = __toESM(require_react(), 1);
37186
37187
  var import_react20 = __toESM(require_react(), 1);
37187
- var React262 = __toESM(require_react(), 1);
37188
+ var React272 = __toESM(require_react(), 1);
37188
37189
  var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
37189
37190
  var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
37190
37191
  var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
@@ -37194,7 +37195,7 @@ var import_react22 = __toESM(require_react(), 1);
37194
37195
  var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
37195
37196
  var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
37196
37197
  var import_react23 = __toESM(require_react(), 1);
37197
- var React272 = __toESM(require_react(), 1);
37198
+ var React282 = __toESM(require_react(), 1);
37198
37199
  var React31 = __toESM(require_react(), 1);
37199
37200
  var React29 = __toESM(require_react(), 1);
37200
37201
  var React26 = __toESM(require_react(), 1);
@@ -37211,7 +37212,7 @@ var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
37211
37212
  var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
37212
37213
  var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
37213
37214
  var import_react25 = __toESM(require_react(), 1);
37214
- var React282 = __toESM(require_react(), 1);
37215
+ var React292 = __toESM(require_react(), 1);
37215
37216
  var React35 = __toESM(require_react(), 1);
37216
37217
  var ReactDOM4 = __toESM(require_react_dom(), 1);
37217
37218
  var import_react26 = __toESM(require_react(), 1);
@@ -37224,7 +37225,7 @@ var React34 = __toESM(require_react(), 1);
37224
37225
  var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
37225
37226
  var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
37226
37227
  var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
37227
- var React292 = __toESM(require_react(), 1);
37228
+ var React302 = __toESM(require_react(), 1);
37228
37229
  var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
37229
37230
  var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
37230
37231
  var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
@@ -43195,6 +43196,7 @@ async function createDepositAddress(overrides, publishableKey) {
43195
43196
  recipient_address: overrides?.recipient_address || DEFAULT_CONFIG.recipientAddress || "0x309a4154a2CD4153Da886E780890C9cb5161553C",
43196
43197
  ...overrides?.action_type ? { action_type: overrides.action_type } : {},
43197
43198
  ...overrides?.source_chain_type ? { source_chain_type: overrides.source_chain_type } : {},
43199
+ ...overrides?.contract_calls ? { contract_calls: overrides.contract_calls } : {},
43198
43200
  client_metadata: overrides?.client_metadata || {}
43199
43201
  };
43200
43202
  const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
@@ -50679,6 +50681,7 @@ function useDepositAddress(params) {
50679
50681
  destinationChainId,
50680
50682
  destinationTokenAddress,
50681
50683
  actionType,
50684
+ contractCalls,
50682
50685
  enabled = true
50683
50686
  } = params;
50684
50687
  return useQuery({
@@ -50691,6 +50694,7 @@ function useDepositAddress(params) {
50691
50694
  destinationChainId ?? null,
50692
50695
  destinationTokenAddress ?? null,
50693
50696
  actionType ?? null,
50697
+ contractCalls ?? null,
50694
50698
  publishableKey
50695
50699
  ],
50696
50700
  queryFn: () => createDepositAddress(
@@ -50700,7 +50704,8 @@ function useDepositAddress(params) {
50700
50704
  destination_chain_type: destinationChainType,
50701
50705
  destination_chain_id: destinationChainId,
50702
50706
  destination_token_address: destinationTokenAddress,
50703
- action_type: actionType
50707
+ action_type: actionType,
50708
+ contract_calls: contractCalls
50704
50709
  },
50705
50710
  publishableKey
50706
50711
  ),
@@ -55191,6 +55196,190 @@ function collectAllEip6963EthProviders() {
55191
55196
  if (!store) return [];
55192
55197
  return store.getProviders().map((d) => d.provider);
55193
55198
  }
55199
+ function identifyEthWallet(provider, hint) {
55200
+ switch (hint) {
55201
+ case "metamask":
55202
+ return { type: "metamask", name: "MetaMask", icon: "metamask" };
55203
+ case "phantom":
55204
+ return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
55205
+ case "coinbase":
55206
+ return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
55207
+ case "okx":
55208
+ return { type: "okx", name: "OKX Wallet", icon: "okx" };
55209
+ case "rabby":
55210
+ return { type: "rabby", name: "Rabby", icon: "rabby" };
55211
+ case "trust":
55212
+ return { type: "trust", name: "Trust Wallet", icon: "trust" };
55213
+ case "rainbow":
55214
+ return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
55215
+ }
55216
+ const anyProvider = provider;
55217
+ if (provider.isPhantom) {
55218
+ return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
55219
+ }
55220
+ if (anyProvider.isCoinbaseWallet) {
55221
+ return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
55222
+ }
55223
+ if (anyProvider.isRabby) {
55224
+ return { type: "rabby", name: "Rabby", icon: "rabby" };
55225
+ }
55226
+ if (anyProvider.isTrust) {
55227
+ return { type: "trust", name: "Trust Wallet", icon: "trust" };
55228
+ }
55229
+ if (anyProvider.isRainbow) {
55230
+ return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
55231
+ }
55232
+ if (provider.isMetaMask && !provider.isPhantom) {
55233
+ return { type: "metamask", name: "MetaMask", icon: "metamask" };
55234
+ }
55235
+ return { type: "metamask", name: "Wallet", icon: "metamask" };
55236
+ }
55237
+ async function detectConnectedBrowserWallet(chainType) {
55238
+ if (typeof window === "undefined") return null;
55239
+ if (getUserDisconnectedWallet()) return null;
55240
+ try {
55241
+ const win = window;
55242
+ if (!chainType || chainType === "solana") {
55243
+ const trySilentSolana = async (provider, type, name, icon) => {
55244
+ if (!provider) return null;
55245
+ if (provider.isConnected && provider.publicKey) {
55246
+ return { type, name, address: provider.publicKey.toString(), icon };
55247
+ }
55248
+ try {
55249
+ const resp = await provider.connect({ onlyIfTrusted: true });
55250
+ if (resp.publicKey) {
55251
+ return { type, name, address: resp.publicKey.toString(), icon };
55252
+ }
55253
+ } catch {
55254
+ }
55255
+ return null;
55256
+ };
55257
+ const solanaCandidates = [
55258
+ [win.phantom?.solana, "phantom-solana", "Phantom", "phantom"],
55259
+ [win.solflare, "solflare", "Solflare", "solflare"],
55260
+ [win.backpack, "backpack", "Backpack", "backpack"],
55261
+ [win.glow, "glow", "Glow", "glow"]
55262
+ ];
55263
+ for (const [provider, type, name, icon] of solanaCandidates) {
55264
+ const found = await trySilentSolana(provider, type, name, icon);
55265
+ if (found) return found;
55266
+ }
55267
+ }
55268
+ if (!chainType || chainType === "ethereum") {
55269
+ const allProviders = [];
55270
+ const eip6963 = getEip6963Providers();
55271
+ for (const { provider, walletId } of eip6963) {
55272
+ allProviders.push({
55273
+ provider,
55274
+ walletId: walletId === "unknown" ? "default" : walletId
55275
+ });
55276
+ }
55277
+ if (allProviders.length === 0) {
55278
+ if (win.phantom?.ethereum) {
55279
+ allProviders.push({ provider: win.phantom.ethereum, walletId: "phantom" });
55280
+ }
55281
+ if (win.okxwallet) {
55282
+ allProviders.push({ provider: win.okxwallet, walletId: "okx" });
55283
+ }
55284
+ if (win.coinbaseWalletExtension) {
55285
+ allProviders.push({ provider: win.coinbaseWalletExtension, walletId: "coinbase" });
55286
+ }
55287
+ if (win.ethereum && !allProviders.some((p) => p.provider === win.ethereum)) {
55288
+ allProviders.push({ provider: win.ethereum, walletId: "default" });
55289
+ }
55290
+ }
55291
+ for (const { provider, walletId } of allProviders) {
55292
+ if (!provider) continue;
55293
+ try {
55294
+ const accounts = await provider.request({ method: "eth_accounts" });
55295
+ if (!accounts || accounts.length === 0) continue;
55296
+ const resolved = identifyEthWallet(provider, walletId);
55297
+ return { ...resolved, address: accounts[0] };
55298
+ } catch {
55299
+ }
55300
+ }
55301
+ }
55302
+ } catch (error) {
55303
+ console.error("[detectConnectedBrowserWallet] detection error:", error);
55304
+ }
55305
+ return null;
55306
+ }
55307
+ function useDetectedBrowserWallet(opts = {}) {
55308
+ const { chainType, enabled = true, onDisconnect } = opts;
55309
+ const [wallet, setWallet] = React122.useState(null);
55310
+ const [isLoading, setIsLoading] = React122.useState(enabled);
55311
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React122.useState(0);
55312
+ const onDisconnectRef = React122.useRef(onDisconnect);
55313
+ onDisconnectRef.current = onDisconnect;
55314
+ React122.useEffect(() => {
55315
+ const store = getEip6963Store();
55316
+ if (!store) return;
55317
+ setEip6963ProviderCount(store.getProviders().length);
55318
+ return store.subscribe((providers) => setEip6963ProviderCount(providers.length));
55319
+ }, []);
55320
+ React122.useEffect(() => {
55321
+ if (!enabled) {
55322
+ setWallet(null);
55323
+ setIsLoading(false);
55324
+ return;
55325
+ }
55326
+ let mounted = true;
55327
+ const detect = async () => {
55328
+ if (!mounted) return;
55329
+ setIsLoading(true);
55330
+ const detected = await detectConnectedBrowserWallet(chainType);
55331
+ if (!mounted) return;
55332
+ setWallet(detected);
55333
+ setIsLoading(false);
55334
+ };
55335
+ detect();
55336
+ const onChange = () => detect();
55337
+ const onDisc = () => {
55338
+ onDisconnectRef.current?.();
55339
+ detect();
55340
+ };
55341
+ const onEthAccounts = (accounts) => {
55342
+ if (Array.isArray(accounts) && accounts.length === 0) onDisconnectRef.current?.();
55343
+ detect();
55344
+ };
55345
+ const win = typeof window !== "undefined" ? window : void 0;
55346
+ const solanaProvider = win?.phantom?.solana || win?.solana;
55347
+ if (solanaProvider) {
55348
+ solanaProvider.on("connect", onChange);
55349
+ solanaProvider.on("disconnect", onDisc);
55350
+ solanaProvider.on("accountChanged", onChange);
55351
+ }
55352
+ const ethProviders = [];
55353
+ for (const { provider } of getEip6963Providers()) {
55354
+ const p = provider;
55355
+ if (p && !ethProviders.includes(p)) ethProviders.push(p);
55356
+ }
55357
+ if (win?.ethereum && !ethProviders.includes(win.ethereum)) ethProviders.push(win.ethereum);
55358
+ if (win?.phantom?.ethereum && !ethProviders.includes(win.phantom.ethereum)) {
55359
+ ethProviders.push(win.phantom.ethereum);
55360
+ }
55361
+ for (const p of ethProviders) {
55362
+ p.on("accountsChanged", onEthAccounts);
55363
+ p.on("chainChanged", onChange);
55364
+ }
55365
+ return () => {
55366
+ mounted = false;
55367
+ if (solanaProvider) {
55368
+ solanaProvider.off?.("connect", onChange);
55369
+ solanaProvider.off?.("disconnect", onDisc);
55370
+ solanaProvider.off?.("accountChanged", onChange);
55371
+ }
55372
+ for (const p of ethProviders) {
55373
+ const off = p.off?.bind(p) ?? p.removeListener?.bind(p);
55374
+ if (off) {
55375
+ off("accountsChanged", onEthAccounts);
55376
+ off("chainChanged", onChange);
55377
+ }
55378
+ }
55379
+ };
55380
+ }, [chainType, eip6963ProviderCount, enabled]);
55381
+ return { wallet, isLoading, setWallet };
55382
+ }
55194
55383
  var SOLANA_DISCONNECT_TYPES = [
55195
55384
  "phantom-solana",
55196
55385
  "solflare",
@@ -55278,7 +55467,7 @@ function MetamaskIcon({
55278
55467
  className,
55279
55468
  variant = "color"
55280
55469
  }) {
55281
- const id = React122.useId();
55470
+ const id = React132.useId();
55282
55471
  if (variant === "light" || variant === "dark") {
55283
55472
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
55284
55473
  "svg",
@@ -55403,7 +55592,7 @@ function PhantomIcon({
55403
55592
  className,
55404
55593
  variant = "color"
55405
55594
  }) {
55406
- const id = React132.useId();
55595
+ const id = React142.useId();
55407
55596
  if (variant === "light") {
55408
55597
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
55409
55598
  "svg",
@@ -55474,7 +55663,7 @@ function CoinbaseIcon({
55474
55663
  className,
55475
55664
  variant = "color"
55476
55665
  }) {
55477
- const id = React142.useId();
55666
+ const id = React152.useId();
55478
55667
  if (variant === "light") {
55479
55668
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
55480
55669
  "svg",
@@ -55558,7 +55747,7 @@ function RabbyIcon({
55558
55747
  className,
55559
55748
  variant = "color"
55560
55749
  }) {
55561
- const id = React152.useId();
55750
+ const id = React162.useId();
55562
55751
  if (variant === "light") {
55563
55752
  return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
55564
55753
  "svg",
@@ -55909,7 +56098,7 @@ function RainbowIcon({
55909
56098
  className,
55910
56099
  variant = "color"
55911
56100
  }) {
55912
- const id = React162.useId();
56101
+ const id = React172.useId();
55913
56102
  if (variant === "light") {
55914
56103
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
55915
56104
  "svg",
@@ -56375,7 +56564,7 @@ function TrustIcon({
56375
56564
  className,
56376
56565
  variant = "color"
56377
56566
  }) {
56378
- const id = React172.useId();
56567
+ const id = React182.useId();
56379
56568
  if (variant === "light") {
56380
56569
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
56381
56570
  "svg",
@@ -56468,7 +56657,7 @@ function OkxIcon({
56468
56657
  className,
56469
56658
  variant = "color"
56470
56659
  }) {
56471
- const id = React182.useId();
56660
+ const id = React192.useId();
56472
56661
  if (variant === "light") {
56473
56662
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
56474
56663
  "svg",
@@ -56539,7 +56728,7 @@ function GlowIcon({
56539
56728
  className,
56540
56729
  variant = "color"
56541
56730
  }) {
56542
- const id = React192.useId();
56731
+ const id = React202.useId();
56543
56732
  if (variant === "light") {
56544
56733
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
56545
56734
  "svg",
@@ -56644,7 +56833,7 @@ function BackpackIcon({
56644
56833
  className,
56645
56834
  variant = "color"
56646
56835
  }) {
56647
- const id = React202.useId();
56836
+ const id = React212.useId();
56648
56837
  if (variant === "light") {
56649
56838
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
56650
56839
  "svg",
@@ -56721,7 +56910,7 @@ function SolflareIcon({
56721
56910
  className,
56722
56911
  variant = "color"
56723
56912
  }) {
56724
- const id = React212.useId();
56913
+ const id = React2222.useId();
56725
56914
  if (variant === "light") {
56726
56915
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
56727
56916
  "svg",
@@ -56792,7 +56981,7 @@ function EthereumIcon({
56792
56981
  className,
56793
56982
  variant = "color"
56794
56983
  }) {
56795
- const id = React2222.useId();
56984
+ const id = React232.useId();
56796
56985
  if (variant === "light") {
56797
56986
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
56798
56987
  "svg",
@@ -56926,7 +57115,7 @@ function SolanaIcon({
56926
57115
  className,
56927
57116
  variant = "color"
56928
57117
  }) {
56929
- const id = React232.useId();
57118
+ const id = React242.useId();
56930
57119
  if (variant === "light") {
56931
57120
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
56932
57121
  "svg",
@@ -57175,44 +57364,6 @@ function truncateAddress3(address) {
57175
57364
  if (address.length <= 10) return address;
57176
57365
  return `${address.slice(0, 4)}...${address.slice(-4)}`;
57177
57366
  }
57178
- function identifyEthWallet(provider, _win, hint) {
57179
- switch (hint) {
57180
- case "metamask":
57181
- return { type: "metamask", name: "MetaMask", icon: "metamask" };
57182
- case "phantom":
57183
- return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
57184
- case "coinbase":
57185
- return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
57186
- case "okx":
57187
- return { type: "okx", name: "OKX Wallet", icon: "okx" };
57188
- case "rabby":
57189
- return { type: "rabby", name: "Rabby", icon: "rabby" };
57190
- case "trust":
57191
- return { type: "trust", name: "Trust Wallet", icon: "trust" };
57192
- case "rainbow":
57193
- return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
57194
- }
57195
- const anyProvider = provider;
57196
- if (provider.isPhantom) {
57197
- return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
57198
- }
57199
- if (anyProvider.isCoinbaseWallet) {
57200
- return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
57201
- }
57202
- if (anyProvider.isRabby) {
57203
- return { type: "rabby", name: "Rabby", icon: "rabby" };
57204
- }
57205
- if (anyProvider.isTrust) {
57206
- return { type: "trust", name: "Trust Wallet", icon: "trust" };
57207
- }
57208
- if (anyProvider.isRainbow) {
57209
- return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
57210
- }
57211
- if (provider.isMetaMask && !provider.isPhantom) {
57212
- return { type: "metamask", name: "MetaMask", icon: "metamask" };
57213
- }
57214
- return { type: "metamask", name: "Wallet", icon: "metamask" };
57215
- }
57216
57367
  function BrowserWalletButton({
57217
57368
  onClick,
57218
57369
  onConnectClick,
@@ -57223,30 +57374,19 @@ function BrowserWalletButton({
57223
57374
  subtitle = i18n2.depositModal.browserWallet.subtitle
57224
57375
  }) {
57225
57376
  const { colors: colors2, fonts, components } = useTheme();
57226
- const [isHovered, setIsHovered] = React242.useState(false);
57227
- const [isTouchDevice, setIsTouchDevice] = React242.useState(false);
57228
- const [wallet, setWallet] = React242.useState(null);
57229
- const [isLoading, setIsLoading] = React242.useState(true);
57230
- const [isConnecting, setIsConnecting] = React242.useState(false);
57231
- const [balanceText, setBalanceText] = React242.useState(null);
57232
- const [isLoadingBalance, setIsLoadingBalance] = React242.useState(false);
57233
- const [isDisconnecting, setIsDisconnecting] = React242.useState(false);
57234
- const onDisconnectRef = React242.useRef(onDisconnect);
57377
+ const [isHovered, setIsHovered] = React252.useState(false);
57378
+ const [isTouchDevice, setIsTouchDevice] = React252.useState(false);
57379
+ const { wallet, isLoading, setWallet } = useDetectedBrowserWallet({ chainType, onDisconnect });
57380
+ const [isConnecting, setIsConnecting] = React252.useState(false);
57381
+ const [balanceText, setBalanceText] = React252.useState(null);
57382
+ const [isLoadingBalance, setIsLoadingBalance] = React252.useState(false);
57383
+ const [isDisconnecting, setIsDisconnecting] = React252.useState(false);
57384
+ const onDisconnectRef = React252.useRef(onDisconnect);
57235
57385
  onDisconnectRef.current = onDisconnect;
57236
- React242.useEffect(() => {
57386
+ React252.useEffect(() => {
57237
57387
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
57238
57388
  }, []);
57239
- const [eip6963ProviderCount, setEip6963ProviderCount] = React242.useState(0);
57240
- React242.useEffect(() => {
57241
- const store = getEip6963Store();
57242
- if (!store) return;
57243
- setEip6963ProviderCount(store.getProviders().length);
57244
- const unsubscribe = store.subscribe((providers) => {
57245
- setEip6963ProviderCount(providers.length);
57246
- });
57247
- return unsubscribe;
57248
- }, []);
57249
- React242.useEffect(() => {
57389
+ React252.useEffect(() => {
57250
57390
  if (!wallet || !publishableKey) {
57251
57391
  setBalanceText(null);
57252
57392
  return;
@@ -57287,206 +57427,6 @@ function BrowserWalletButton({
57287
57427
  cancelled = true;
57288
57428
  };
57289
57429
  }, [wallet, publishableKey]);
57290
- React242.useEffect(() => {
57291
- let mounted = true;
57292
- const detectWallet = async () => {
57293
- if (!mounted) return;
57294
- setIsLoading(true);
57295
- try {
57296
- const win = typeof window !== "undefined" ? window : null;
57297
- if (!win) return;
57298
- if (getUserDisconnectedWallet()) {
57299
- if (mounted) {
57300
- setWallet(null);
57301
- setIsLoading(false);
57302
- }
57303
- return;
57304
- }
57305
- if (!chainType || chainType === "solana") {
57306
- const anyWin = win;
57307
- const trySilentSolana = async (provider, type, name, icon) => {
57308
- if (!provider) return false;
57309
- if (provider.isConnected && provider.publicKey) {
57310
- if (mounted) {
57311
- setWallet({
57312
- type,
57313
- name,
57314
- address: provider.publicKey.toString(),
57315
- icon
57316
- });
57317
- setIsLoading(false);
57318
- }
57319
- return true;
57320
- }
57321
- try {
57322
- const resp = await provider.connect({ onlyIfTrusted: true });
57323
- if (mounted && resp.publicKey) {
57324
- setWallet({
57325
- type,
57326
- name,
57327
- address: resp.publicKey.toString(),
57328
- icon
57329
- });
57330
- setIsLoading(false);
57331
- return true;
57332
- }
57333
- } catch {
57334
- }
57335
- return false;
57336
- };
57337
- if (await trySilentSolana(
57338
- win.phantom?.solana,
57339
- "phantom-solana",
57340
- "Phantom",
57341
- "phantom"
57342
- ))
57343
- return;
57344
- if (await trySilentSolana(
57345
- anyWin.solflare,
57346
- "solflare",
57347
- "Solflare",
57348
- "solflare"
57349
- ))
57350
- return;
57351
- if (await trySilentSolana(
57352
- anyWin.backpack,
57353
- "backpack",
57354
- "Backpack",
57355
- "backpack"
57356
- ))
57357
- return;
57358
- if (await trySilentSolana(
57359
- anyWin.glow,
57360
- "glow",
57361
- "Glow",
57362
- "glow"
57363
- ))
57364
- return;
57365
- }
57366
- if (!chainType || chainType === "ethereum") {
57367
- const anyWin = win;
57368
- const allProviders = [];
57369
- const eip6963 = getEip6963Providers();
57370
- for (const { provider, walletId } of eip6963) {
57371
- allProviders.push({
57372
- provider,
57373
- walletId: walletId === "unknown" ? "default" : walletId
57374
- });
57375
- }
57376
- if (allProviders.length === 0) {
57377
- if (win.phantom?.ethereum) {
57378
- allProviders.push({
57379
- provider: win.phantom.ethereum,
57380
- walletId: "phantom"
57381
- });
57382
- }
57383
- if (anyWin.okxwallet) {
57384
- allProviders.push({
57385
- provider: anyWin.okxwallet,
57386
- walletId: "okx"
57387
- });
57388
- }
57389
- if (anyWin.coinbaseWalletExtension) {
57390
- allProviders.push({
57391
- provider: anyWin.coinbaseWalletExtension,
57392
- walletId: "coinbase"
57393
- });
57394
- }
57395
- if (win.ethereum) {
57396
- const isDuplicate = allProviders.some(
57397
- (p) => p.provider === win.ethereum
57398
- );
57399
- if (!isDuplicate) {
57400
- allProviders.push({
57401
- provider: win.ethereum,
57402
- walletId: "default"
57403
- });
57404
- }
57405
- }
57406
- }
57407
- for (const { provider, walletId } of allProviders) {
57408
- if (!provider) continue;
57409
- try {
57410
- const accounts = await provider.request({
57411
- method: "eth_accounts"
57412
- });
57413
- if (!accounts || accounts.length === 0) continue;
57414
- const address = accounts[0];
57415
- const resolved = identifyEthWallet(provider, anyWin, walletId);
57416
- if (mounted) {
57417
- setWallet({ ...resolved, address });
57418
- setIsLoading(false);
57419
- }
57420
- return;
57421
- } catch {
57422
- }
57423
- }
57424
- }
57425
- if (mounted) {
57426
- setWallet(null);
57427
- setIsLoading(false);
57428
- }
57429
- } catch (error) {
57430
- console.error("[BrowserWalletButton] Error detecting wallet:", error);
57431
- if (mounted) {
57432
- setWallet(null);
57433
- setIsLoading(false);
57434
- }
57435
- }
57436
- };
57437
- detectWallet();
57438
- const handleAccountsChanged = () => {
57439
- detectWallet();
57440
- };
57441
- const handleDisconnect = () => {
57442
- onDisconnectRef.current?.();
57443
- detectWallet();
57444
- };
57445
- const handleEthAccountsChanged = (accounts) => {
57446
- if (Array.isArray(accounts) && accounts.length === 0) {
57447
- onDisconnectRef.current?.();
57448
- }
57449
- detectWallet();
57450
- };
57451
- const solanaProvider = window.phantom?.solana || window.solana;
57452
- if (solanaProvider) {
57453
- solanaProvider.on("connect", handleAccountsChanged);
57454
- solanaProvider.on("disconnect", handleDisconnect);
57455
- solanaProvider.on("accountChanged", handleAccountsChanged);
57456
- }
57457
- const ethProviders = [];
57458
- for (const { provider } of getEip6963Providers()) {
57459
- const p = provider;
57460
- if (p && !ethProviders.includes(p)) {
57461
- ethProviders.push(p);
57462
- }
57463
- }
57464
- if (window.ethereum && !ethProviders.includes(window.ethereum)) {
57465
- ethProviders.push(window.ethereum);
57466
- }
57467
- if (window.phantom?.ethereum && !ethProviders.includes(window.phantom.ethereum)) {
57468
- ethProviders.push(window.phantom.ethereum);
57469
- }
57470
- for (const provider of ethProviders) {
57471
- provider.on("accountsChanged", handleEthAccountsChanged);
57472
- provider.on("chainChanged", handleAccountsChanged);
57473
- }
57474
- return () => {
57475
- mounted = false;
57476
- if (solanaProvider) {
57477
- solanaProvider.off("connect", handleAccountsChanged);
57478
- solanaProvider.off("disconnect", handleDisconnect);
57479
- solanaProvider.off("accountChanged", handleAccountsChanged);
57480
- }
57481
- for (const provider of ethProviders) {
57482
- const off = provider.off?.bind(provider) ?? provider.removeListener?.bind(provider);
57483
- if (off) {
57484
- off("accountsChanged", handleEthAccountsChanged);
57485
- off("chainChanged", handleAccountsChanged);
57486
- }
57487
- }
57488
- };
57489
- }, [chainType, eip6963ProviderCount]);
57490
57430
  const handleConnect = async () => {
57491
57431
  if (wallet) {
57492
57432
  onClick(wallet);
@@ -57570,7 +57510,7 @@ function BrowserWalletButton({
57570
57510
  border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
57571
57511
  };
57572
57512
  const sortedWallets = featuredWallets ? [...featuredWallets].sort((a, b) => a.position - b.position) : [];
57573
- const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React242.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
57513
+ const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React252.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
57574
57514
  size: 36,
57575
57515
  className: "uf-rounded-lg",
57576
57516
  variant: "color"
@@ -57832,6 +57772,7 @@ function CoinbaseConnect({
57832
57772
  onBack: parentOnBack,
57833
57773
  onDisconnect,
57834
57774
  skipToHoldings,
57775
+ canGoBack = true,
57835
57776
  onExecutionsChange
57836
57777
  }) {
57837
57778
  const { colors: colors2, fonts, components } = useTheme();
@@ -58219,6 +58160,16 @@ function CoinbaseConnect({
58219
58160
  setIsLoading(false);
58220
58161
  }
58221
58162
  };
58163
+ const handleDisconnect = () => {
58164
+ onDisconnect?.();
58165
+ if (!canGoBack) {
58166
+ setAccessToken(null);
58167
+ setHoldings([]);
58168
+ setSelectedHolding(null);
58169
+ setSelectedAsset(null);
58170
+ transitionTo("select_exchange");
58171
+ }
58172
+ };
58222
58173
  const handleBack = () => {
58223
58174
  switch (view) {
58224
58175
  case "select_exchange":
@@ -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
  }
@@ -58292,7 +58243,7 @@ function CoinbaseConnect({
58292
58243
  DepositHeader,
58293
58244
  {
58294
58245
  title: t12.title,
58295
- showBack: true,
58246
+ showBack: canGoBack,
58296
58247
  onBack: handleBack,
58297
58248
  onClose
58298
58249
  }
@@ -59004,7 +58955,7 @@ function CoinbaseConnect({
59004
58955
  borderRadius: components.button.borderRadius,
59005
58956
  fontFamily: fonts.medium
59006
58957
  },
59007
- onClick: onDisconnect,
58958
+ onClick: handleDisconnect,
59008
58959
  children: t12.disconnect
59009
58960
  }
59010
58961
  )
@@ -59791,7 +59742,7 @@ function ThemeStyleInjector({
59791
59742
  className
59792
59743
  }) {
59793
59744
  const { colors: colors2, fonts, mode } = useTheme();
59794
- const cssVars = React262.useMemo(() => {
59745
+ const cssVars = React272.useMemo(() => {
59795
59746
  const hexToHSL = (hex) => {
59796
59747
  hex = hex.replace("#", "");
59797
59748
  const r2 = parseInt(hex.slice(0, 2), 16) / 255;
@@ -59851,7 +59802,7 @@ function ThemeStyleInjector({
59851
59802
  ...fonts.regular ? { "--uf-font-family": fonts.regular } : {}
59852
59803
  };
59853
59804
  }, [colors2, fonts.regular]);
59854
- React262.useEffect(() => {
59805
+ React272.useEffect(() => {
59855
59806
  if (typeof document === "undefined") return;
59856
59807
  if (fonts.regular) {
59857
59808
  document.documentElement.style.setProperty(
@@ -60810,14 +60761,14 @@ function useCopyAddress() {
60810
60761
  return { copied, handleCopy };
60811
60762
  }
60812
60763
  var TooltipProvider2 = Provider;
60813
- var TooltipContext = React272.createContext({
60764
+ var TooltipContext = React282.createContext({
60814
60765
  open: false,
60815
60766
  onOpenChange: () => {
60816
60767
  }
60817
60768
  });
60818
- var TooltipTrigger2 = React272.forwardRef(({ onClick, ...props }, ref) => {
60819
- const { open, onOpenChange } = React272.useContext(TooltipContext);
60820
- const handleClick = React272.useCallback(
60769
+ var TooltipTrigger2 = React282.forwardRef(({ onClick, ...props }, ref) => {
60770
+ const { open, onOpenChange } = React282.useContext(TooltipContext);
60771
+ const handleClick = React282.useCallback(
60821
60772
  (e) => {
60822
60773
  onOpenChange(!open);
60823
60774
  onClick?.(e);
@@ -60827,7 +60778,7 @@ var TooltipTrigger2 = React272.forwardRef(({ onClick, ...props }, ref) => {
60827
60778
  return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Trigger, { ref, onClick: handleClick, ...props });
60828
60779
  });
60829
60780
  TooltipTrigger2.displayName = Trigger.displayName;
60830
- var TooltipContent2 = React272.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
60781
+ var TooltipContent2 = React282.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
60831
60782
  const { themeClass, colors: colors2 } = useTheme();
60832
60783
  return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Portal3, { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
60833
60784
  Content22,
@@ -61432,7 +61383,7 @@ function TransferCryptoSingleInput({
61432
61383
  }
61433
61384
  var Select2 = Root23;
61434
61385
  var SelectValue2 = Value;
61435
- var SelectTrigger2 = React282.forwardRef(({ className, style, children, ...props }, ref) => {
61386
+ var SelectTrigger2 = React292.forwardRef(({ className, style, children, ...props }, ref) => {
61436
61387
  const { components } = useTheme();
61437
61388
  return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61438
61389
  Trigger2,
@@ -61456,7 +61407,7 @@ var SelectTrigger2 = React282.forwardRef(({ className, style, children, ...props
61456
61407
  );
61457
61408
  });
61458
61409
  SelectTrigger2.displayName = Trigger2.displayName;
61459
- var SelectScrollUpButton2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61410
+ var SelectScrollUpButton2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61460
61411
  ScrollUpButton,
61461
61412
  {
61462
61413
  ref,
@@ -61469,7 +61420,7 @@ var SelectScrollUpButton2 = React282.forwardRef(({ className, ...props }, ref) =
61469
61420
  }
61470
61421
  ));
61471
61422
  SelectScrollUpButton2.displayName = ScrollUpButton.displayName;
61472
- var SelectScrollDownButton2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61423
+ var SelectScrollDownButton2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61473
61424
  ScrollDownButton,
61474
61425
  {
61475
61426
  ref,
@@ -61482,7 +61433,7 @@ var SelectScrollDownButton2 = React282.forwardRef(({ className, ...props }, ref)
61482
61433
  }
61483
61434
  ));
61484
61435
  SelectScrollDownButton2.displayName = ScrollDownButton.displayName;
61485
- var SelectContent2 = React282.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
61436
+ var SelectContent2 = React292.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
61486
61437
  const { themeClass, colors: colors2, components } = useTheme();
61487
61438
  return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Portal4, { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61488
61439
  Content23,
@@ -61520,7 +61471,7 @@ var SelectContent2 = React282.forwardRef(({ className, style, children, position
61520
61471
  ) });
61521
61472
  });
61522
61473
  SelectContent2.displayName = Content23.displayName;
61523
- var SelectLabel2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61474
+ var SelectLabel2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61524
61475
  Label,
61525
61476
  {
61526
61477
  ref,
@@ -61532,7 +61483,7 @@ var SelectLabel2 = React282.forwardRef(({ className, ...props }, ref) => /* @__P
61532
61483
  }
61533
61484
  ));
61534
61485
  SelectLabel2.displayName = Label.displayName;
61535
- var SelectItem2 = React282.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61486
+ var SelectItem2 = React292.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61536
61487
  Item,
61537
61488
  {
61538
61489
  ref,
@@ -61548,7 +61499,7 @@ var SelectItem2 = React282.forwardRef(({ className, children, ...props }, ref) =
61548
61499
  }
61549
61500
  ));
61550
61501
  SelectItem2.displayName = Item.displayName;
61551
- var SelectSeparator2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61502
+ var SelectSeparator2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61552
61503
  Separator,
61553
61504
  {
61554
61505
  ref,
@@ -63212,22 +63163,27 @@ function WalletConnect({
63212
63163
  productType,
63213
63164
  onBack: parentOnBack,
63214
63165
  onClose,
63166
+ canGoBack = true,
63167
+ depositWalletsLoading = false,
63215
63168
  onExecutionsChange
63216
63169
  }) {
63217
63170
  const { colors: colors2, fonts, components } = useTheme();
63218
- const walletProvidedAtMount = React292.useRef(!!initialWalletInfo && !!initialDepositWallet);
63219
- const [activeWalletInfo, setActiveWalletInfo] = React292.useState(initialWalletInfo ?? null);
63220
- const [activeDepositWallet, setActiveDepositWallet] = React292.useState(initialDepositWallet ?? null);
63171
+ const walletProvidedAtMount = React302.useRef(!!initialWalletInfo && !!initialDepositWallet);
63172
+ const [activeWalletInfo, setActiveWalletInfo] = React302.useState(initialWalletInfo ?? null);
63173
+ const [activeDepositWallet, setActiveDepositWallet] = React302.useState(initialDepositWallet ?? null);
63221
63174
  const initialView = initialWalletInfo && initialDepositWallet ? "select_token" : "select_wallet";
63222
- const [view, setView] = React292.useState(initialView);
63223
- const [isTransitioning, setIsTransitioning] = React292.useState(false);
63224
- const viewRef = React292.useRef(initialView);
63225
- const [selectedWalletDef, setSelectedWalletDef] = React292.useState(null);
63226
- const [connectingNetwork, setConnectingNetwork] = React292.useState(null);
63227
- const [walletError, setWalletError] = React292.useState(null);
63228
- const [isWalletConnecting, setIsWalletConnecting] = React292.useState(false);
63229
- const [eip6963ProviderCount, setEip6963ProviderCount] = React292.useState(0);
63230
- React292.useEffect(() => {
63175
+ const [view, setView] = React302.useState(initialView);
63176
+ const [isTransitioning, setIsTransitioning] = React302.useState(false);
63177
+ const viewRef = React302.useRef(initialView);
63178
+ const standalone = !canGoBack && !walletProvidedAtMount.current;
63179
+ const { wallet: detectedWallet, isLoading: detectingWallet } = useDetectedBrowserWallet({ enabled: standalone });
63180
+ const [autoResolved, setAutoResolved] = React302.useState(false);
63181
+ const [selectedWalletDef, setSelectedWalletDef] = React302.useState(null);
63182
+ const [connectingNetwork, setConnectingNetwork] = React302.useState(null);
63183
+ const [walletError, setWalletError] = React302.useState(null);
63184
+ const [isWalletConnecting, setIsWalletConnecting] = React302.useState(false);
63185
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React302.useState(0);
63186
+ React302.useEffect(() => {
63231
63187
  const store = getEip6963Store();
63232
63188
  if (!store) return;
63233
63189
  setEip6963ProviderCount(store.getProviders().length);
@@ -63235,20 +63191,44 @@ function WalletConnect({
63235
63191
  setEip6963ProviderCount(providers.length);
63236
63192
  });
63237
63193
  }, []);
63238
- const availableWallets = React292.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
63239
- const [balances, setBalances] = React292.useState([]);
63240
- const [isLoading, setIsLoading] = React292.useState(false);
63241
- const [selectedBalance, setSelectedBalance] = React292.useState(null);
63242
- const [totalBalanceUsd, setTotalBalanceUsd] = React292.useState(null);
63243
- const [error, setError] = React292.useState(null);
63244
- const [isDisconnectingWallet, setIsDisconnectingWallet] = React292.useState(false);
63245
- const [amountUsd, setAmountUsd] = React292.useState(prefillAmountUsd ?? "");
63246
- const [isConfirming, setIsConfirming] = React292.useState(false);
63247
- const [hasSignedTransaction, setHasSignedTransaction] = React292.useState(false);
63248
- const [tokenChainDetails, setTokenChainDetails] = React292.useState(null);
63249
- const [loadingTokenDetails, setLoadingTokenDetails] = React292.useState(false);
63250
- const [showTransactionDetails, setShowTransactionDetails] = React292.useState(false);
63251
- const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React292.useState(null);
63194
+ const availableWallets = React302.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
63195
+ React302.useEffect(() => {
63196
+ if (!standalone || autoResolved || detectingWallet) return;
63197
+ if (!detectedWallet) {
63198
+ setAutoResolved(true);
63199
+ return;
63200
+ }
63201
+ const wct = detectedWallet.type === "phantom-solana" || detectedWallet.type === "solflare" || detectedWallet.type === "backpack" || detectedWallet.type === "glow" ? "solana" : "ethereum";
63202
+ const matching = depositWallets?.find((w) => w.chain_type === wct);
63203
+ if (!matching) {
63204
+ if (!depositWalletsLoading) setAutoResolved(true);
63205
+ return;
63206
+ }
63207
+ setActiveWalletInfo(detectedWallet);
63208
+ setActiveDepositWallet(matching);
63209
+ onWalletConnected?.(detectedWallet, matching);
63210
+ setView("select_token");
63211
+ viewRef.current = "select_token";
63212
+ setAutoResolved(true);
63213
+ }, [standalone, autoResolved, detectingWallet, detectedWallet, depositWallets, depositWalletsLoading]);
63214
+ React302.useEffect(() => {
63215
+ if (!standalone || autoResolved) return;
63216
+ const t12 = setTimeout(() => setAutoResolved(true), 5e3);
63217
+ return () => clearTimeout(t12);
63218
+ }, [standalone, autoResolved]);
63219
+ const [balances, setBalances] = React302.useState([]);
63220
+ const [isLoading, setIsLoading] = React302.useState(false);
63221
+ const [selectedBalance, setSelectedBalance] = React302.useState(null);
63222
+ const [totalBalanceUsd, setTotalBalanceUsd] = React302.useState(null);
63223
+ const [error, setError] = React302.useState(null);
63224
+ const [isDisconnectingWallet, setIsDisconnectingWallet] = React302.useState(false);
63225
+ const [amountUsd, setAmountUsd] = React302.useState(prefillAmountUsd ?? "");
63226
+ const [isConfirming, setIsConfirming] = React302.useState(false);
63227
+ const [hasSignedTransaction, setHasSignedTransaction] = React302.useState(false);
63228
+ const [tokenChainDetails, setTokenChainDetails] = React302.useState(null);
63229
+ const [loadingTokenDetails, setLoadingTokenDetails] = React302.useState(false);
63230
+ const [showTransactionDetails, setShowTransactionDetails] = React302.useState(false);
63231
+ const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React302.useState(null);
63252
63232
  const walletInfo = activeWalletInfo;
63253
63233
  const depositWallet = activeDepositWallet;
63254
63234
  const hasWallet = !!activeWalletInfo && !!activeDepositWallet;
@@ -63256,7 +63236,7 @@ function WalletConnect({
63256
63236
  const recipientAddress = activeDepositWallet?.address ?? "";
63257
63237
  const isCheckoutMode = !!checkoutAmountUsd;
63258
63238
  const supportedChainType = chainType === "algorand" || chainType === "xrpl" ? "ethereum" : chainType;
63259
- const transitionTo = React292.useCallback((nextView) => {
63239
+ const transitionTo = React302.useCallback((nextView) => {
63260
63240
  if (nextView === viewRef.current) return;
63261
63241
  setIsTransitioning(true);
63262
63242
  setTimeout(() => {
@@ -63393,7 +63373,7 @@ function WalletConnect({
63393
63373
  }
63394
63374
  };
63395
63375
  const selectedToken = selectedBalance ? getTokenFromBalance(selectedBalance) : null;
63396
- const effectiveDestinationAmount = React292.useMemo(() => {
63376
+ const effectiveDestinationAmount = React302.useMemo(() => {
63397
63377
  if (!checkoutRemainingBaseUnits || checkoutRemainingBaseUnits === "0") return "0";
63398
63378
  if (!checkoutAmountUsd) return checkoutRemainingBaseUnits;
63399
63379
  const remaining = BigInt(checkoutRemainingBaseUnits);
@@ -63421,7 +63401,7 @@ function WalletConnect({
63421
63401
  stablecoinParity,
63422
63402
  enabled: isCheckoutMode && !!selectedToken && !!checkoutDestination && effectiveDestinationAmount !== "0"
63423
63403
  });
63424
- const activeCheckoutQuote = React292.useMemo(() => {
63404
+ const activeCheckoutQuote = React302.useMemo(() => {
63425
63405
  if (!isCheckoutMode) return null;
63426
63406
  if (walletCheckoutQuote) return { sourceAmount: walletCheckoutQuote.source_amount, sourceTokenDecimals: walletCheckoutQuote.source_token_decimals, sourceTokenSymbol: walletCheckoutQuote.source_token_symbol, sourceAmountUsd: walletCheckoutQuote.source_amount_usd, slippageBufferPercent: walletCheckoutQuote.slippage_buffer_percent ?? null };
63427
63407
  return checkoutQuote ?? null;
@@ -63435,19 +63415,19 @@ function WalletConnect({
63435
63415
  onDepositSuccess,
63436
63416
  onDepositError
63437
63417
  });
63438
- React292.useEffect(() => {
63418
+ React302.useEffect(() => {
63439
63419
  onExecutionsChange?.(depositExecutions);
63440
63420
  }, [depositExecutions, onExecutionsChange]);
63441
- React292.useEffect(() => {
63421
+ React302.useEffect(() => {
63442
63422
  if (!prefillAmountUsd || !tokenChainDetails || view !== "enter_amount") return;
63443
63423
  const minDeposit = tokenChainDetails.minimum_deposit_amount_usd || 0;
63444
63424
  const currentAmount = parseFloat(amountUsd) || 0;
63445
63425
  if (currentAmount > 0 && currentAmount < minDeposit) setAmountUsd(minDeposit.toFixed(2));
63446
63426
  }, [tokenChainDetails, view, prefillAmountUsd]);
63447
- React292.useEffect(() => {
63427
+ React302.useEffect(() => {
63448
63428
  if (view === "review") setShowTransactionDetails(false);
63449
63429
  }, [view]);
63450
- React292.useEffect(() => {
63430
+ React302.useEffect(() => {
63451
63431
  if (view !== "enter_amount" && view !== "review" || !selectedBalance || !activeDepositWallet) return;
63452
63432
  let cancelled = false;
63453
63433
  const fetchTokenDetails = async () => {
@@ -63474,7 +63454,7 @@ function WalletConnect({
63474
63454
  cancelled = true;
63475
63455
  };
63476
63456
  }, [view, selectedBalance, publishableKey, activeDepositWallet]);
63477
- React292.useEffect(() => {
63457
+ React302.useEffect(() => {
63478
63458
  if (!activeWalletInfo || !activeDepositWallet) return;
63479
63459
  let cancelled = false;
63480
63460
  setIsLoading(true);
@@ -63507,20 +63487,20 @@ function WalletConnect({
63507
63487
  cancelled = true;
63508
63488
  };
63509
63489
  }, [activeWalletInfo?.address, activeDepositWallet?.chain_type, publishableKey]);
63510
- const usdToTokenRate = React292.useMemo(() => {
63490
+ const usdToTokenRate = React302.useMemo(() => {
63511
63491
  if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
63512
63492
  const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
63513
63493
  const balanceUsd = parseFloat(selectedBalance.amount_usd);
63514
63494
  if (balanceAmount === 0 || balanceUsd === 0) return 0;
63515
63495
  return balanceAmount / balanceUsd;
63516
63496
  }, [selectedBalance, selectedToken]);
63517
- const tokenAmount = React292.useMemo(() => {
63497
+ const tokenAmount = React302.useMemo(() => {
63518
63498
  if (isCheckoutMode && activeCheckoutQuote && selectedToken) return Number(activeCheckoutQuote.sourceAmount) / 10 ** activeCheckoutQuote.sourceTokenDecimals;
63519
63499
  const usdNum = parseFloat(amountUsd) || 0;
63520
63500
  if (usdNum === 0 || usdToTokenRate === 0) return 0;
63521
63501
  return usdNum * usdToTokenRate;
63522
63502
  }, [amountUsd, usdToTokenRate, isCheckoutMode, activeCheckoutQuote, selectedToken]);
63523
- React292.useEffect(() => {
63503
+ React302.useEffect(() => {
63524
63504
  if (isCheckoutMode && activeCheckoutQuote?.sourceAmountUsd && view === "enter_amount") setAmountUsd(activeCheckoutQuote.sourceAmountUsd);
63525
63505
  }, [isCheckoutMode, activeCheckoutQuote, view]);
63526
63506
  const maxTokenAmount = selectedBalance && selectedToken ? Number(selectedBalance.amount) / 10 ** selectedToken.decimals : 0;
@@ -63528,7 +63508,7 @@ function WalletConnect({
63528
63508
  const inputUsdNum = parseFloat(amountUsd) || 0;
63529
63509
  const minDepositUsd = tokenChainDetails?.minimum_deposit_amount_usd || 0;
63530
63510
  const isValidAmount = isCheckoutMode && activeCheckoutQuote ? tokenAmount > 0 && tokenAmount <= maxTokenAmount : inputUsdNum > 0 && inputUsdNum <= maxUsdAmount && inputUsdNum >= minDepositUsd;
63531
- const formattedTokenAmount = React292.useMemo(() => {
63511
+ const formattedTokenAmount = React302.useMemo(() => {
63532
63512
  if (tokenAmount === 0 || !selectedToken) return null;
63533
63513
  return `${tokenAmount.toFixed(6)} ${selectedToken.symbol}`.replace(/\.?0+$/, "");
63534
63514
  }, [tokenAmount, selectedToken]);
@@ -63576,16 +63556,25 @@ function WalletConnect({
63576
63556
  } catch (err) {
63577
63557
  console.warn("[WalletConnect] disconnect error:", err);
63578
63558
  } finally {
63579
- setActiveWalletInfo(null);
63580
- setActiveDepositWallet(null);
63581
- setSelectedBalance(null);
63582
- setBalances([]);
63583
- setTotalBalanceUsd(null);
63584
- setAmountUsd(prefillAmountUsd ?? "");
63585
- setError(null);
63586
63559
  setIsDisconnectingWallet(false);
63587
- if (onWalletDisconnect) onWalletDisconnect();
63588
- else parentOnBack?.();
63560
+ const clearWalletState = () => {
63561
+ setActiveWalletInfo(null);
63562
+ setActiveDepositWallet(null);
63563
+ setSelectedBalance(null);
63564
+ setBalances([]);
63565
+ setTotalBalanceUsd(null);
63566
+ setAmountUsd(prefillAmountUsd ?? "");
63567
+ setError(null);
63568
+ };
63569
+ if (standalone) {
63570
+ onWalletDisconnect?.();
63571
+ transitionTo("select_wallet");
63572
+ setTimeout(clearWalletState, 160);
63573
+ } else {
63574
+ clearWalletState();
63575
+ if (onWalletDisconnect) onWalletDisconnect();
63576
+ else parentOnBack?.();
63577
+ }
63589
63578
  }
63590
63579
  };
63591
63580
  const handleReview = () => {
@@ -63711,9 +63700,15 @@ function WalletConnect({
63711
63700
  setIsConfirming(false);
63712
63701
  }
63713
63702
  };
63703
+ if (standalone && !autoResolved) {
63704
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { style: viewTransitionStyle, children: [
63705
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: "Connect Wallet", showBack: canGoBack, onBack: handleBack, onClose }),
63706
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-16", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(LoaderCircle, { className: "uf-w-8 uf-h-8 uf-animate-spin", style: { color: colors2.primary } }) })
63707
+ ] });
63708
+ }
63714
63709
  if (view === "select_wallet") {
63715
63710
  return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { style: viewTransitionStyle, children: [
63716
- /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: "Connect Wallet", showBack: true, onBack: handleBack, onClose }),
63711
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: "Connect Wallet", showBack: canGoBack, onBack: handleBack, onClose }),
63717
63712
  /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-pb-4", children: [
63718
63713
  /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("p", { className: "uf-text-sm uf-text-center uf-pb-4", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: "Select a wallet to connect" }),
63719
63714
  /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-space-y-2", style: { maxHeight: 330, overflowY: "auto" }, children: availableWallets.map((wallet) => /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
@@ -63841,6 +63836,7 @@ function DepositModal({
63841
63836
  destinationChainType,
63842
63837
  destinationChainId,
63843
63838
  destinationTokenAddress,
63839
+ contractCalls,
63844
63840
  defaultSourceChainType,
63845
63841
  defaultSourceChainId,
63846
63842
  defaultSourceTokenAddress,
@@ -63875,8 +63871,19 @@ function DepositModal({
63875
63871
  if (s === "tracker" && hideDepositTracker) return "main";
63876
63872
  if (s === "cashapp" && !enableCashApp) return "main";
63877
63873
  if (s === "card" && enableFiatOnramp === false) return "main";
63874
+ if (s === "pay_with_exchange") return enablePayWithExchange === false ? "main" : "exchange";
63875
+ if (s === "exchange_connect") return enableConnectExchange ? "coinbase_connect" : "main";
63876
+ if (s === "wallet_connect") return enableConnectWallet ? "wallet_connect" : "main";
63878
63877
  return s;
63879
- }, [initialScreen, hideDepositTracker, enableCashApp, enableFiatOnramp]);
63878
+ }, [
63879
+ initialScreen,
63880
+ hideDepositTracker,
63881
+ enableCashApp,
63882
+ enableFiatOnramp,
63883
+ enablePayWithExchange,
63884
+ enableConnectExchange,
63885
+ enableConnectWallet
63886
+ ]);
63880
63887
  const [containerEl, setContainerEl] = (0, import_react3.useState)(null);
63881
63888
  const containerCallbackRef = (0, import_react3.useCallback)((el) => {
63882
63889
  setContainerEl(el);
@@ -63967,6 +63974,7 @@ function DepositModal({
63967
63974
  destinationChainType,
63968
63975
  destinationChainId,
63969
63976
  destinationTokenAddress,
63977
+ contractCalls,
63970
63978
  enabled: open
63971
63979
  // Only fetch when modal is open
63972
63980
  });
@@ -63999,6 +64007,12 @@ function DepositModal({
63999
64007
  setCardView("amount");
64000
64008
  }
64001
64009
  }, [view, showFiatOnramp]);
64010
+ (0, import_react3.useEffect)(() => {
64011
+ if (view === "exchange" && !showPayWithExchange) {
64012
+ setView("main");
64013
+ setExchangeView("providers");
64014
+ }
64015
+ }, [view, showPayWithExchange]);
64002
64016
  const { exchanges, isLoading: exchangesLoading } = useExchanges({
64003
64017
  publishableKey,
64004
64018
  enabled: open && showPayWithExchange
@@ -64118,7 +64132,7 @@ function DepositModal({
64118
64132
  setBrowserWalletChainType(void 0);
64119
64133
  setBrowserWalletInfo(null);
64120
64134
  setBrowserWalletModalOpen(false);
64121
- if (view === "wallet_connect") setView("main");
64135
+ if (view === "wallet_connect" && sessionOpenedFromMenu) setView("main");
64122
64136
  };
64123
64137
  const handleExchangeDisconnect = () => {
64124
64138
  const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
@@ -64127,7 +64141,7 @@ function DepositModal({
64127
64141
  }
64128
64142
  clearStoredIntegrationToken(IntegrationProvider.COINBASE);
64129
64143
  setConnectedExchange(null);
64130
- if (view === "coinbase_connect") setView("main");
64144
+ if (view === "coinbase_connect" && sessionOpenedFromMenu) setView("main");
64131
64145
  };
64132
64146
  const handleClose = () => {
64133
64147
  onOpenChange(false);
@@ -64139,6 +64153,7 @@ function DepositModal({
64139
64153
  setCardView("amount");
64140
64154
  setExchangeView("providers");
64141
64155
  setBrowserWalletInfo(null);
64156
+ setCoinbaseSkipToHoldings(false);
64142
64157
  resetViewTimeoutRef.current = null;
64143
64158
  }, 200);
64144
64159
  };
@@ -64153,6 +64168,7 @@ function DepositModal({
64153
64168
  setExchangeView("providers");
64154
64169
  setBrowserWalletInfo(null);
64155
64170
  setSelectedExecution(null);
64171
+ setCoinbaseSkipToHoldings(false);
64156
64172
  }, [open, effectiveInitialScreen]);
64157
64173
  (0, import_react3.useEffect)(
64158
64174
  () => () => {
@@ -64512,7 +64528,7 @@ function DepositModal({
64512
64528
  DepositHeader,
64513
64529
  {
64514
64530
  title: payWithExchangeTitle,
64515
- showBack: true,
64531
+ showBack: exchangeView === "pending" || sessionOpenedFromMenu,
64516
64532
  onBack: handleBack,
64517
64533
  onClose: handleClose
64518
64534
  }
@@ -64566,6 +64582,7 @@ function DepositModal({
64566
64582
  onClose: handleClose,
64567
64583
  onDisconnect: handleExchangeDisconnect,
64568
64584
  skipToHoldings: coinbaseSkipToHoldings,
64585
+ canGoBack: sessionOpenedFromMenu,
64569
64586
  onExecutionsChange: setDepositExecutions
64570
64587
  }
64571
64588
  ),
@@ -64603,7 +64620,9 @@ function DepositModal({
64603
64620
  setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
64604
64621
  },
64605
64622
  onBack: handleBack,
64606
- onClose: handleClose
64623
+ onClose: handleClose,
64624
+ canGoBack: sessionOpenedFromMenu,
64625
+ depositWalletsLoading: walletsLoading
64607
64626
  }
64608
64627
  ),
64609
64628
  depositPoweredByFooter
@@ -64612,7 +64631,7 @@ function DepositModal({
64612
64631
  DepositHeader,
64613
64632
  {
64614
64633
  title: cashAppView !== "amount" && cashAppAmount ? `Pay $${cashAppAmount} via Cash App` : "Pay with Cash App",
64615
- showBack: true,
64634
+ showBack: cashAppView !== "amount" || sessionOpenedFromMenu,
64616
64635
  onBack: handleBack,
64617
64636
  onClose: handleClose
64618
64637
  }
@@ -67297,6 +67316,7 @@ function UnifoldProvider2({
67297
67316
  destinationChainType: depositConfig.destinationChainType,
67298
67317
  destinationChainId: depositConfig.destinationChainId,
67299
67318
  destinationTokenAddress: depositConfig.destinationTokenAddress,
67319
+ contractCalls: depositConfig.contractCalls,
67300
67320
  defaultSourceChainType: depositConfig.defaultSourceChainType,
67301
67321
  defaultSourceChainId: depositConfig.defaultSourceChainId,
67302
67322
  defaultSourceTokenAddress: depositConfig.defaultSourceTokenAddress,