@unifold/ui-web 0.1.61 → 0.1.63

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 +739 -460
  2. package/dist/index.mjs +739 -460
  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);
@@ -43116,6 +43117,42 @@ var getDefaultConfig = () => {
43116
43117
  };
43117
43118
  };
43118
43119
  var twMerge = /* @__PURE__ */ createTailwindMerge(getDefaultConfig);
43120
+ function formatStablecoinAmount(baseUnits, decimals) {
43121
+ const raw = Number(baseUnits) / 10 ** decimals;
43122
+ const floored = Math.floor(raw * 100) / 100;
43123
+ const ceiled = raw > floored ? floored + 0.01 : raw;
43124
+ return ceiled.toFixed(2);
43125
+ }
43126
+ function generateKSUID() {
43127
+ const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
43128
+ const KSUID_EPOCH = 14e8;
43129
+ const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
43130
+ const payload = new Uint8Array(20);
43131
+ payload[0] = timestampSeconds >>> 24 & 255;
43132
+ payload[1] = timestampSeconds >>> 16 & 255;
43133
+ payload[2] = timestampSeconds >>> 8 & 255;
43134
+ payload[3] = timestampSeconds & 255;
43135
+ if (typeof crypto !== "undefined" && crypto.getRandomValues) {
43136
+ crypto.getRandomValues(payload.subarray(4));
43137
+ } else {
43138
+ for (let i = 4; i < 20; i++) {
43139
+ payload[i] = Math.floor(Math.random() * 256);
43140
+ }
43141
+ }
43142
+ let value = 0n;
43143
+ for (const byte of payload) {
43144
+ value = value << 8n | BigInt(byte);
43145
+ }
43146
+ let encoded = "";
43147
+ while (value > 0n) {
43148
+ encoded = BASE62[Number(value % 62n)] + encoded;
43149
+ value = value / 62n;
43150
+ }
43151
+ return encoded.padStart(27, "0");
43152
+ }
43153
+ function generatePrefixedKSUID(prefix) {
43154
+ return `${prefix}_${generateKSUID()}`;
43155
+ }
43119
43156
  var API_BASE_URL = (() => {
43120
43157
  try {
43121
43158
  return process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.unifold.io";
@@ -43418,9 +43455,7 @@ function getOnrampSessionStartUrl(request, publishableKey) {
43418
43455
  if (request.subdivision_code) {
43419
43456
  params.append("subdivision_code", request.subdivision_code);
43420
43457
  }
43421
- if (request.external_id) {
43422
- params.append("external_id", request.external_id);
43423
- }
43458
+ params.append("external_id", request.external_id ?? generatePrefixedKSUID("ors"));
43424
43459
  if (request.email) {
43425
43460
  params.append("email", request.email);
43426
43461
  }
@@ -43635,9 +43670,7 @@ function getExchangeSessionStartUrl(request, publishableKey) {
43635
43670
  if (request.source_amount) {
43636
43671
  params.append("source_amount", request.source_amount);
43637
43672
  }
43638
- if (request.external_id) {
43639
- params.append("external_id", request.external_id);
43640
- }
43673
+ params.append("external_id", request.external_id ?? generatePrefixedKSUID("exc"));
43641
43674
  return `${API_BASE_URL}/v1/public/onramps/exchanges/sessions/start?${params.toString()}`;
43642
43675
  }
43643
43676
  async function getIntegrationExchanges(publishableKey) {
@@ -43971,40 +44004,6 @@ async function getCashAppSessionStatus(externalId, publishableKey) {
43971
44004
  }
43972
44005
  return response.json();
43973
44006
  }
43974
- function formatStablecoinAmount(baseUnits, decimals) {
43975
- const raw = Number(baseUnits) / 10 ** decimals;
43976
- const floored = Math.floor(raw * 100) / 100;
43977
- const ceiled = raw > floored ? floored + 0.01 : raw;
43978
- return ceiled.toFixed(2);
43979
- }
43980
- function generatePrefixedKSUID(prefix) {
43981
- const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
43982
- const KSUID_EPOCH = 14e8;
43983
- const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
43984
- const payload = new Uint8Array(20);
43985
- payload[0] = timestampSeconds >>> 24 & 255;
43986
- payload[1] = timestampSeconds >>> 16 & 255;
43987
- payload[2] = timestampSeconds >>> 8 & 255;
43988
- payload[3] = timestampSeconds & 255;
43989
- if (typeof crypto !== "undefined" && crypto.getRandomValues) {
43990
- crypto.getRandomValues(payload.subarray(4));
43991
- } else {
43992
- for (let i = 4; i < 20; i++) {
43993
- payload[i] = Math.floor(Math.random() * 256);
43994
- }
43995
- }
43996
- let value = 0n;
43997
- for (const byte of payload) {
43998
- value = value << 8n | BigInt(byte);
43999
- }
44000
- let encoded = "";
44001
- while (value > 0n) {
44002
- encoded = BASE62[Number(value % 62n)] + encoded;
44003
- value = value / 62n;
44004
- }
44005
- encoded = encoded.padStart(27, "0");
44006
- return `${prefix}_${encoded}`;
44007
- }
44008
44007
  var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
44009
44008
  DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
44010
44009
  return DepositEventType2;
@@ -50104,8 +50103,32 @@ var Separator = SelectSeparator;
50104
50103
  function cn(...inputs) {
50105
50104
  return twMerge(clsx(inputs));
50106
50105
  }
50107
- var WALLET_CHAIN_TYPE_STORAGE_KEY = "unifold_last_wallet_type";
50106
+ var WALLET_STATE_STORAGE_KEY = "unifold_wallet_state";
50107
+ var LEGACY_WALLET_KEYS = [
50108
+ "unifold_last_wallet_type",
50109
+ "unifold_last_connected_wallet"
50110
+ ];
50108
50111
  var WALLET_USER_DISCONNECTED_KEY = "unifold_wallet_user_disconnected";
50112
+ var SOLANA_WALLET_TYPES = /* @__PURE__ */ new Set([
50113
+ "phantom-solana",
50114
+ "solflare",
50115
+ "backpack",
50116
+ "glow"
50117
+ ]);
50118
+ var ETHEREUM_WALLET_TYPES = /* @__PURE__ */ new Set([
50119
+ "metamask",
50120
+ "phantom-ethereum",
50121
+ "coinbase",
50122
+ "trust",
50123
+ "rainbow",
50124
+ "rabby",
50125
+ "okx"
50126
+ ]);
50127
+ function walletTypeToChain(t12) {
50128
+ if (SOLANA_WALLET_TYPES.has(t12)) return "solana";
50129
+ if (ETHEREUM_WALLET_TYPES.has(t12)) return "ethereum";
50130
+ return void 0;
50131
+ }
50109
50132
  function getUserDisconnectedWallet() {
50110
50133
  if (typeof window === "undefined") return false;
50111
50134
  try {
@@ -50125,26 +50148,35 @@ function setUserDisconnectedWallet(disconnected) {
50125
50148
  } catch {
50126
50149
  }
50127
50150
  }
50128
- function getStoredWalletChainType() {
50151
+ function getStoredWalletState() {
50129
50152
  if (typeof window === "undefined") return void 0;
50130
50153
  try {
50131
- const stored = localStorage.getItem(WALLET_CHAIN_TYPE_STORAGE_KEY);
50132
- if (stored === "ethereum" || stored === "solana") return stored;
50154
+ const raw = localStorage.getItem(WALLET_STATE_STORAGE_KEY);
50155
+ if (!raw) return void 0;
50156
+ const chainType = walletTypeToChain(raw);
50157
+ if (!chainType) {
50158
+ localStorage.removeItem(WALLET_STATE_STORAGE_KEY);
50159
+ return void 0;
50160
+ }
50161
+ return { walletType: raw, chainType };
50133
50162
  } catch {
50163
+ return void 0;
50134
50164
  }
50135
- return void 0;
50136
50165
  }
50137
- function setStoredWalletChainType(chainType) {
50166
+ function setStoredWalletState(walletType) {
50138
50167
  if (typeof window === "undefined") return;
50168
+ if (!walletTypeToChain(walletType)) return;
50139
50169
  try {
50140
- localStorage.setItem(WALLET_CHAIN_TYPE_STORAGE_KEY, chainType);
50170
+ localStorage.setItem(WALLET_STATE_STORAGE_KEY, walletType);
50171
+ for (const key of LEGACY_WALLET_KEYS) localStorage.removeItem(key);
50141
50172
  } catch {
50142
50173
  }
50143
50174
  }
50144
- function clearStoredWalletChainType() {
50175
+ function clearStoredWalletState() {
50145
50176
  if (typeof window === "undefined") return;
50146
50177
  try {
50147
- localStorage.removeItem(WALLET_CHAIN_TYPE_STORAGE_KEY);
50178
+ localStorage.removeItem(WALLET_STATE_STORAGE_KEY);
50179
+ for (const key of LEGACY_WALLET_KEYS) localStorage.removeItem(key);
50148
50180
  } catch {
50149
50181
  }
50150
50182
  }
@@ -50707,6 +50739,60 @@ function useDepositAddress(params) {
50707
50739
  // 1s, 2s, 4s (max 10s)
50708
50740
  });
50709
50741
  }
50742
+ var normalize = (value) => value?.toLowerCase();
50743
+ function sourceTokenMatchesDefaultSource(token, defaultSource) {
50744
+ if (!token || !defaultSource.defaultSourceChainType || !defaultSource.defaultSourceChainId) {
50745
+ return false;
50746
+ }
50747
+ if (token.chain_type !== defaultSource.defaultSourceChainType || token.chain_id !== defaultSource.defaultSourceChainId) {
50748
+ return false;
50749
+ }
50750
+ if (defaultSource.defaultSourceTokenAddress && normalize(token.token_address) === normalize(defaultSource.defaultSourceTokenAddress)) {
50751
+ return true;
50752
+ }
50753
+ if (defaultSource.defaultSourceTokenAddress) {
50754
+ return false;
50755
+ }
50756
+ return !!defaultSource.defaultSourceSymbol && normalize(token.symbol) === normalize(defaultSource.defaultSourceSymbol);
50757
+ }
50758
+ function isDefaultSourceBalance(balance, defaultSource) {
50759
+ return isBalanceEligible(balance) && sourceTokenMatchesDefaultSource(getTokenFromBalance(balance), defaultSource);
50760
+ }
50761
+ function compareBalancesWithDefaultSource(a, b, defaultSource) {
50762
+ const aDefault = isDefaultSourceBalance(a, defaultSource);
50763
+ const bDefault = isDefaultSourceBalance(b, defaultSource);
50764
+ if (aDefault && !bDefault) return -1;
50765
+ if (!aDefault && bDefault) return 1;
50766
+ const aEligible = isBalanceEligible(a);
50767
+ const bEligible = isBalanceEligible(b);
50768
+ if (aEligible && !bEligible) return -1;
50769
+ if (!aEligible && bEligible) return 1;
50770
+ return 0;
50771
+ }
50772
+ function resolveDefaultSourceSymbol(supportedTokens, defaultSource) {
50773
+ if (!supportedTokens?.length || !defaultSource.defaultSourceChainType || !defaultSource.defaultSourceChainId) {
50774
+ return null;
50775
+ }
50776
+ if (defaultSource.defaultSourceTokenAddress) {
50777
+ for (const token of supportedTokens) {
50778
+ const matchingChain = token.chains.find(
50779
+ (chain) => chain.chain_type === defaultSource.defaultSourceChainType && chain.chain_id === defaultSource.defaultSourceChainId && normalize(chain.token_address) === normalize(defaultSource.defaultSourceTokenAddress)
50780
+ );
50781
+ if (matchingChain) return token.symbol;
50782
+ }
50783
+ }
50784
+ if (!defaultSource.defaultSourceSymbol) return null;
50785
+ for (const token of supportedTokens) {
50786
+ if (normalize(token.symbol) !== normalize(defaultSource.defaultSourceSymbol)) {
50787
+ continue;
50788
+ }
50789
+ const matchingChain = token.chains.find(
50790
+ (chain) => chain.chain_type === defaultSource.defaultSourceChainType && chain.chain_id === defaultSource.defaultSourceChainId
50791
+ );
50792
+ if (matchingChain) return token.symbol;
50793
+ }
50794
+ return null;
50795
+ }
50710
50796
  function formatUsdFromBalancePercent(maxUsdAmount, percent) {
50711
50797
  if (maxUsdAmount <= 0 || percent < 0) return "";
50712
50798
  const raw = maxUsdAmount * percent / 100;
@@ -55182,6 +55268,226 @@ function collectAllEip6963EthProviders() {
55182
55268
  if (!store) return [];
55183
55269
  return store.getProviders().map((d) => d.provider);
55184
55270
  }
55271
+ function identifyEthWallet(provider, hint) {
55272
+ switch (hint) {
55273
+ case "metamask":
55274
+ return { type: "metamask", name: "MetaMask", icon: "metamask" };
55275
+ case "phantom":
55276
+ return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
55277
+ case "coinbase":
55278
+ return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
55279
+ case "okx":
55280
+ return { type: "okx", name: "OKX Wallet", icon: "okx" };
55281
+ case "rabby":
55282
+ return { type: "rabby", name: "Rabby", icon: "rabby" };
55283
+ case "trust":
55284
+ return { type: "trust", name: "Trust Wallet", icon: "trust" };
55285
+ case "rainbow":
55286
+ return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
55287
+ }
55288
+ const anyProvider = provider;
55289
+ if (provider.isPhantom) {
55290
+ return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
55291
+ }
55292
+ if (anyProvider.isCoinbaseWallet) {
55293
+ return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
55294
+ }
55295
+ if (anyProvider.isRabby) {
55296
+ return { type: "rabby", name: "Rabby", icon: "rabby" };
55297
+ }
55298
+ if (anyProvider.isTrust) {
55299
+ return { type: "trust", name: "Trust Wallet", icon: "trust" };
55300
+ }
55301
+ if (anyProvider.isRainbow) {
55302
+ return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
55303
+ }
55304
+ if (provider.isMetaMask && !provider.isPhantom) {
55305
+ return { type: "metamask", name: "MetaMask", icon: "metamask" };
55306
+ }
55307
+ return { type: "metamask", name: "Wallet", icon: "metamask" };
55308
+ }
55309
+ var EIP6963_ID_TO_WALLET_TYPE = {
55310
+ metamask: "metamask",
55311
+ phantom: "phantom-ethereum",
55312
+ coinbase: "coinbase",
55313
+ trust: "trust",
55314
+ rainbow: "rainbow",
55315
+ rabby: "rabby",
55316
+ okx: "okx"
55317
+ };
55318
+ function inferEthWalletType(provider, walletId) {
55319
+ if (EIP6963_ID_TO_WALLET_TYPE[walletId]) return EIP6963_ID_TO_WALLET_TYPE[walletId];
55320
+ const any = provider;
55321
+ if (provider.isPhantom) return "phantom-ethereum";
55322
+ if (any.isCoinbaseWallet) return "coinbase";
55323
+ if (any.isRabby) return "rabby";
55324
+ if (any.isTrust) return "trust";
55325
+ if (any.isRainbow) return "rainbow";
55326
+ if (any.isOkxWallet) return "okx";
55327
+ if (provider.isMetaMask && !provider.isPhantom) return "metamask";
55328
+ return null;
55329
+ }
55330
+ function solanaCandidate(provider, type, name, icon) {
55331
+ return {
55332
+ walletType: type,
55333
+ detect: async () => {
55334
+ if (!provider) return null;
55335
+ if (provider.isConnected && provider.publicKey) {
55336
+ return { type, name, address: provider.publicKey.toString(), icon };
55337
+ }
55338
+ try {
55339
+ const resp = await provider.connect({ onlyIfTrusted: true });
55340
+ if (resp.publicKey) {
55341
+ return { type, name, address: resp.publicKey.toString(), icon };
55342
+ }
55343
+ } catch {
55344
+ }
55345
+ return null;
55346
+ }
55347
+ };
55348
+ }
55349
+ function ethereumCandidate(provider, walletId) {
55350
+ return {
55351
+ walletType: inferEthWalletType(provider, walletId),
55352
+ detect: async () => {
55353
+ try {
55354
+ const accounts = await provider.request({ method: "eth_accounts" });
55355
+ if (!accounts?.length) return null;
55356
+ const resolved = identifyEthWallet(provider, walletId);
55357
+ return { ...resolved, address: accounts[0] };
55358
+ } catch {
55359
+ return null;
55360
+ }
55361
+ }
55362
+ };
55363
+ }
55364
+ function buildCandidates(win, chainType) {
55365
+ const candidates = [];
55366
+ if (!chainType || chainType === "solana") {
55367
+ candidates.push(
55368
+ solanaCandidate(win.phantom?.solana, "phantom-solana", "Phantom", "phantom"),
55369
+ solanaCandidate(win.solflare, "solflare", "Solflare", "solflare"),
55370
+ solanaCandidate(win.backpack, "backpack", "Backpack", "backpack"),
55371
+ solanaCandidate(win.glow, "glow", "Glow", "glow")
55372
+ );
55373
+ }
55374
+ if (!chainType || chainType === "ethereum") {
55375
+ const seen = /* @__PURE__ */ new Set();
55376
+ const addEth = (provider, walletId) => {
55377
+ if (!provider || seen.has(provider)) return;
55378
+ seen.add(provider);
55379
+ candidates.push(ethereumCandidate(provider, walletId));
55380
+ };
55381
+ for (const { provider, walletId } of getEip6963Providers()) {
55382
+ addEth(
55383
+ provider,
55384
+ walletId === "unknown" ? "default" : walletId
55385
+ );
55386
+ }
55387
+ addEth(win.phantom?.ethereum, "phantom");
55388
+ addEth(win.coinbaseWalletExtension, "coinbase");
55389
+ addEth(win.okxwallet, "okx");
55390
+ addEth(win.trustwallet?.ethereum, "trust");
55391
+ addEth(win.ethereum, "default");
55392
+ }
55393
+ return candidates;
55394
+ }
55395
+ async function detectConnectedBrowserWallet(chainType) {
55396
+ if (typeof window === "undefined") return null;
55397
+ if (getUserDisconnectedWallet()) return null;
55398
+ try {
55399
+ const win = window;
55400
+ const candidates = buildCandidates(win, chainType);
55401
+ const preferred = getStoredWalletState();
55402
+ if (preferred && (!chainType || preferred.chainType === chainType)) {
55403
+ const idx = candidates.findIndex((c) => c.walletType === preferred.walletType);
55404
+ if (idx > 0) candidates.unshift(...candidates.splice(idx, 1));
55405
+ }
55406
+ for (const c of candidates) {
55407
+ const found = await c.detect();
55408
+ if (found) return found;
55409
+ }
55410
+ } catch (error) {
55411
+ console.error("[detectConnectedBrowserWallet] detection error:", error);
55412
+ }
55413
+ return null;
55414
+ }
55415
+ function useDetectedBrowserWallet(opts = {}) {
55416
+ const { chainType, enabled = true, onDisconnect } = opts;
55417
+ const [wallet, setWallet] = React122.useState(null);
55418
+ const [isLoading, setIsLoading] = React122.useState(enabled);
55419
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React122.useState(0);
55420
+ const onDisconnectRef = React122.useRef(onDisconnect);
55421
+ onDisconnectRef.current = onDisconnect;
55422
+ React122.useEffect(() => {
55423
+ const store = getEip6963Store();
55424
+ if (!store) return;
55425
+ setEip6963ProviderCount(store.getProviders().length);
55426
+ return store.subscribe((providers) => setEip6963ProviderCount(providers.length));
55427
+ }, []);
55428
+ React122.useEffect(() => {
55429
+ if (!enabled) {
55430
+ setWallet(null);
55431
+ setIsLoading(false);
55432
+ return;
55433
+ }
55434
+ let mounted = true;
55435
+ const detect = async () => {
55436
+ if (!mounted) return;
55437
+ setIsLoading(true);
55438
+ const detected = await detectConnectedBrowserWallet(chainType);
55439
+ if (!mounted) return;
55440
+ setWallet(detected);
55441
+ setIsLoading(false);
55442
+ };
55443
+ detect();
55444
+ const onChange = () => detect();
55445
+ const onDisc = () => {
55446
+ onDisconnectRef.current?.();
55447
+ detect();
55448
+ };
55449
+ const onEthAccounts = (accounts) => {
55450
+ if (Array.isArray(accounts) && accounts.length === 0) onDisconnectRef.current?.();
55451
+ detect();
55452
+ };
55453
+ const win = typeof window !== "undefined" ? window : void 0;
55454
+ const solanaProvider = win?.phantom?.solana || win?.solana;
55455
+ if (solanaProvider) {
55456
+ solanaProvider.on("connect", onChange);
55457
+ solanaProvider.on("disconnect", onDisc);
55458
+ solanaProvider.on("accountChanged", onChange);
55459
+ }
55460
+ const ethProviders = [];
55461
+ for (const { provider } of getEip6963Providers()) {
55462
+ const p = provider;
55463
+ if (p && !ethProviders.includes(p)) ethProviders.push(p);
55464
+ }
55465
+ if (win?.ethereum && !ethProviders.includes(win.ethereum)) ethProviders.push(win.ethereum);
55466
+ if (win?.phantom?.ethereum && !ethProviders.includes(win.phantom.ethereum)) {
55467
+ ethProviders.push(win.phantom.ethereum);
55468
+ }
55469
+ for (const p of ethProviders) {
55470
+ p.on("accountsChanged", onEthAccounts);
55471
+ p.on("chainChanged", onChange);
55472
+ }
55473
+ return () => {
55474
+ mounted = false;
55475
+ if (solanaProvider) {
55476
+ solanaProvider.off?.("connect", onChange);
55477
+ solanaProvider.off?.("disconnect", onDisc);
55478
+ solanaProvider.off?.("accountChanged", onChange);
55479
+ }
55480
+ for (const p of ethProviders) {
55481
+ const off = p.off?.bind(p) ?? p.removeListener?.bind(p);
55482
+ if (off) {
55483
+ off("accountsChanged", onEthAccounts);
55484
+ off("chainChanged", onChange);
55485
+ }
55486
+ }
55487
+ };
55488
+ }, [chainType, eip6963ProviderCount, enabled]);
55489
+ return { wallet, isLoading, setWallet };
55490
+ }
55185
55491
  var SOLANA_DISCONNECT_TYPES = [
55186
55492
  "phantom-solana",
55187
55493
  "solflare",
@@ -55269,7 +55575,7 @@ function MetamaskIcon({
55269
55575
  className,
55270
55576
  variant = "color"
55271
55577
  }) {
55272
- const id = React122.useId();
55578
+ const id = React132.useId();
55273
55579
  if (variant === "light" || variant === "dark") {
55274
55580
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
55275
55581
  "svg",
@@ -55394,7 +55700,7 @@ function PhantomIcon({
55394
55700
  className,
55395
55701
  variant = "color"
55396
55702
  }) {
55397
- const id = React132.useId();
55703
+ const id = React142.useId();
55398
55704
  if (variant === "light") {
55399
55705
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
55400
55706
  "svg",
@@ -55465,7 +55771,7 @@ function CoinbaseIcon({
55465
55771
  className,
55466
55772
  variant = "color"
55467
55773
  }) {
55468
- const id = React142.useId();
55774
+ const id = React152.useId();
55469
55775
  if (variant === "light") {
55470
55776
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
55471
55777
  "svg",
@@ -55549,7 +55855,7 @@ function RabbyIcon({
55549
55855
  className,
55550
55856
  variant = "color"
55551
55857
  }) {
55552
- const id = React152.useId();
55858
+ const id = React162.useId();
55553
55859
  if (variant === "light") {
55554
55860
  return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
55555
55861
  "svg",
@@ -55900,7 +56206,7 @@ function RainbowIcon({
55900
56206
  className,
55901
56207
  variant = "color"
55902
56208
  }) {
55903
- const id = React162.useId();
56209
+ const id = React172.useId();
55904
56210
  if (variant === "light") {
55905
56211
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
55906
56212
  "svg",
@@ -56366,7 +56672,7 @@ function TrustIcon({
56366
56672
  className,
56367
56673
  variant = "color"
56368
56674
  }) {
56369
- const id = React172.useId();
56675
+ const id = React182.useId();
56370
56676
  if (variant === "light") {
56371
56677
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
56372
56678
  "svg",
@@ -56459,7 +56765,7 @@ function OkxIcon({
56459
56765
  className,
56460
56766
  variant = "color"
56461
56767
  }) {
56462
- const id = React182.useId();
56768
+ const id = React192.useId();
56463
56769
  if (variant === "light") {
56464
56770
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
56465
56771
  "svg",
@@ -56530,7 +56836,7 @@ function GlowIcon({
56530
56836
  className,
56531
56837
  variant = "color"
56532
56838
  }) {
56533
- const id = React192.useId();
56839
+ const id = React202.useId();
56534
56840
  if (variant === "light") {
56535
56841
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
56536
56842
  "svg",
@@ -56635,7 +56941,7 @@ function BackpackIcon({
56635
56941
  className,
56636
56942
  variant = "color"
56637
56943
  }) {
56638
- const id = React202.useId();
56944
+ const id = React212.useId();
56639
56945
  if (variant === "light") {
56640
56946
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
56641
56947
  "svg",
@@ -56712,7 +57018,7 @@ function SolflareIcon({
56712
57018
  className,
56713
57019
  variant = "color"
56714
57020
  }) {
56715
- const id = React212.useId();
57021
+ const id = React2222.useId();
56716
57022
  if (variant === "light") {
56717
57023
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
56718
57024
  "svg",
@@ -56783,7 +57089,7 @@ function EthereumIcon({
56783
57089
  className,
56784
57090
  variant = "color"
56785
57091
  }) {
56786
- const id = React2222.useId();
57092
+ const id = React232.useId();
56787
57093
  if (variant === "light") {
56788
57094
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
56789
57095
  "svg",
@@ -56917,7 +57223,7 @@ function SolanaIcon({
56917
57223
  className,
56918
57224
  variant = "color"
56919
57225
  }) {
56920
- const id = React232.useId();
57226
+ const id = React242.useId();
56921
57227
  if (variant === "light") {
56922
57228
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
56923
57229
  "svg",
@@ -57166,44 +57472,6 @@ function truncateAddress3(address) {
57166
57472
  if (address.length <= 10) return address;
57167
57473
  return `${address.slice(0, 4)}...${address.slice(-4)}`;
57168
57474
  }
57169
- function identifyEthWallet(provider, _win, hint) {
57170
- switch (hint) {
57171
- case "metamask":
57172
- return { type: "metamask", name: "MetaMask", icon: "metamask" };
57173
- case "phantom":
57174
- return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
57175
- case "coinbase":
57176
- return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
57177
- case "okx":
57178
- return { type: "okx", name: "OKX Wallet", icon: "okx" };
57179
- case "rabby":
57180
- return { type: "rabby", name: "Rabby", icon: "rabby" };
57181
- case "trust":
57182
- return { type: "trust", name: "Trust Wallet", icon: "trust" };
57183
- case "rainbow":
57184
- return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
57185
- }
57186
- const anyProvider = provider;
57187
- if (provider.isPhantom) {
57188
- return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
57189
- }
57190
- if (anyProvider.isCoinbaseWallet) {
57191
- return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
57192
- }
57193
- if (anyProvider.isRabby) {
57194
- return { type: "rabby", name: "Rabby", icon: "rabby" };
57195
- }
57196
- if (anyProvider.isTrust) {
57197
- return { type: "trust", name: "Trust Wallet", icon: "trust" };
57198
- }
57199
- if (anyProvider.isRainbow) {
57200
- return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
57201
- }
57202
- if (provider.isMetaMask && !provider.isPhantom) {
57203
- return { type: "metamask", name: "MetaMask", icon: "metamask" };
57204
- }
57205
- return { type: "metamask", name: "Wallet", icon: "metamask" };
57206
- }
57207
57475
  function BrowserWalletButton({
57208
57476
  onClick,
57209
57477
  onConnectClick,
@@ -57214,30 +57482,19 @@ function BrowserWalletButton({
57214
57482
  subtitle = i18n2.depositModal.browserWallet.subtitle
57215
57483
  }) {
57216
57484
  const { colors: colors2, fonts, components } = useTheme();
57217
- const [isHovered, setIsHovered] = React242.useState(false);
57218
- const [isTouchDevice, setIsTouchDevice] = React242.useState(false);
57219
- const [wallet, setWallet] = React242.useState(null);
57220
- const [isLoading, setIsLoading] = React242.useState(true);
57221
- const [isConnecting, setIsConnecting] = React242.useState(false);
57222
- const [balanceText, setBalanceText] = React242.useState(null);
57223
- const [isLoadingBalance, setIsLoadingBalance] = React242.useState(false);
57224
- const [isDisconnecting, setIsDisconnecting] = React242.useState(false);
57225
- const onDisconnectRef = React242.useRef(onDisconnect);
57485
+ const [isHovered, setIsHovered] = React252.useState(false);
57486
+ const [isTouchDevice, setIsTouchDevice] = React252.useState(false);
57487
+ const { wallet, isLoading, setWallet } = useDetectedBrowserWallet({ chainType, onDisconnect });
57488
+ const [isConnecting, setIsConnecting] = React252.useState(false);
57489
+ const [balanceText, setBalanceText] = React252.useState(null);
57490
+ const [isLoadingBalance, setIsLoadingBalance] = React252.useState(false);
57491
+ const [isDisconnecting, setIsDisconnecting] = React252.useState(false);
57492
+ const onDisconnectRef = React252.useRef(onDisconnect);
57226
57493
  onDisconnectRef.current = onDisconnect;
57227
- React242.useEffect(() => {
57494
+ React252.useEffect(() => {
57228
57495
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
57229
57496
  }, []);
57230
- const [eip6963ProviderCount, setEip6963ProviderCount] = React242.useState(0);
57231
- React242.useEffect(() => {
57232
- const store = getEip6963Store();
57233
- if (!store) return;
57234
- setEip6963ProviderCount(store.getProviders().length);
57235
- const unsubscribe = store.subscribe((providers) => {
57236
- setEip6963ProviderCount(providers.length);
57237
- });
57238
- return unsubscribe;
57239
- }, []);
57240
- React242.useEffect(() => {
57497
+ React252.useEffect(() => {
57241
57498
  if (!wallet || !publishableKey) {
57242
57499
  setBalanceText(null);
57243
57500
  return;
@@ -57278,206 +57535,6 @@ function BrowserWalletButton({
57278
57535
  cancelled = true;
57279
57536
  };
57280
57537
  }, [wallet, publishableKey]);
57281
- React242.useEffect(() => {
57282
- let mounted = true;
57283
- const detectWallet = async () => {
57284
- if (!mounted) return;
57285
- setIsLoading(true);
57286
- try {
57287
- const win = typeof window !== "undefined" ? window : null;
57288
- if (!win) return;
57289
- if (getUserDisconnectedWallet()) {
57290
- if (mounted) {
57291
- setWallet(null);
57292
- setIsLoading(false);
57293
- }
57294
- return;
57295
- }
57296
- if (!chainType || chainType === "solana") {
57297
- const anyWin = win;
57298
- const trySilentSolana = async (provider, type, name, icon) => {
57299
- if (!provider) return false;
57300
- if (provider.isConnected && provider.publicKey) {
57301
- if (mounted) {
57302
- setWallet({
57303
- type,
57304
- name,
57305
- address: provider.publicKey.toString(),
57306
- icon
57307
- });
57308
- setIsLoading(false);
57309
- }
57310
- return true;
57311
- }
57312
- try {
57313
- const resp = await provider.connect({ onlyIfTrusted: true });
57314
- if (mounted && resp.publicKey) {
57315
- setWallet({
57316
- type,
57317
- name,
57318
- address: resp.publicKey.toString(),
57319
- icon
57320
- });
57321
- setIsLoading(false);
57322
- return true;
57323
- }
57324
- } catch {
57325
- }
57326
- return false;
57327
- };
57328
- if (await trySilentSolana(
57329
- win.phantom?.solana,
57330
- "phantom-solana",
57331
- "Phantom",
57332
- "phantom"
57333
- ))
57334
- return;
57335
- if (await trySilentSolana(
57336
- anyWin.solflare,
57337
- "solflare",
57338
- "Solflare",
57339
- "solflare"
57340
- ))
57341
- return;
57342
- if (await trySilentSolana(
57343
- anyWin.backpack,
57344
- "backpack",
57345
- "Backpack",
57346
- "backpack"
57347
- ))
57348
- return;
57349
- if (await trySilentSolana(
57350
- anyWin.glow,
57351
- "glow",
57352
- "Glow",
57353
- "glow"
57354
- ))
57355
- return;
57356
- }
57357
- if (!chainType || chainType === "ethereum") {
57358
- const anyWin = win;
57359
- const allProviders = [];
57360
- const eip6963 = getEip6963Providers();
57361
- for (const { provider, walletId } of eip6963) {
57362
- allProviders.push({
57363
- provider,
57364
- walletId: walletId === "unknown" ? "default" : walletId
57365
- });
57366
- }
57367
- if (allProviders.length === 0) {
57368
- if (win.phantom?.ethereum) {
57369
- allProviders.push({
57370
- provider: win.phantom.ethereum,
57371
- walletId: "phantom"
57372
- });
57373
- }
57374
- if (anyWin.okxwallet) {
57375
- allProviders.push({
57376
- provider: anyWin.okxwallet,
57377
- walletId: "okx"
57378
- });
57379
- }
57380
- if (anyWin.coinbaseWalletExtension) {
57381
- allProviders.push({
57382
- provider: anyWin.coinbaseWalletExtension,
57383
- walletId: "coinbase"
57384
- });
57385
- }
57386
- if (win.ethereum) {
57387
- const isDuplicate = allProviders.some(
57388
- (p) => p.provider === win.ethereum
57389
- );
57390
- if (!isDuplicate) {
57391
- allProviders.push({
57392
- provider: win.ethereum,
57393
- walletId: "default"
57394
- });
57395
- }
57396
- }
57397
- }
57398
- for (const { provider, walletId } of allProviders) {
57399
- if (!provider) continue;
57400
- try {
57401
- const accounts = await provider.request({
57402
- method: "eth_accounts"
57403
- });
57404
- if (!accounts || accounts.length === 0) continue;
57405
- const address = accounts[0];
57406
- const resolved = identifyEthWallet(provider, anyWin, walletId);
57407
- if (mounted) {
57408
- setWallet({ ...resolved, address });
57409
- setIsLoading(false);
57410
- }
57411
- return;
57412
- } catch {
57413
- }
57414
- }
57415
- }
57416
- if (mounted) {
57417
- setWallet(null);
57418
- setIsLoading(false);
57419
- }
57420
- } catch (error) {
57421
- console.error("[BrowserWalletButton] Error detecting wallet:", error);
57422
- if (mounted) {
57423
- setWallet(null);
57424
- setIsLoading(false);
57425
- }
57426
- }
57427
- };
57428
- detectWallet();
57429
- const handleAccountsChanged = () => {
57430
- detectWallet();
57431
- };
57432
- const handleDisconnect = () => {
57433
- onDisconnectRef.current?.();
57434
- detectWallet();
57435
- };
57436
- const handleEthAccountsChanged = (accounts) => {
57437
- if (Array.isArray(accounts) && accounts.length === 0) {
57438
- onDisconnectRef.current?.();
57439
- }
57440
- detectWallet();
57441
- };
57442
- const solanaProvider = window.phantom?.solana || window.solana;
57443
- if (solanaProvider) {
57444
- solanaProvider.on("connect", handleAccountsChanged);
57445
- solanaProvider.on("disconnect", handleDisconnect);
57446
- solanaProvider.on("accountChanged", handleAccountsChanged);
57447
- }
57448
- const ethProviders = [];
57449
- for (const { provider } of getEip6963Providers()) {
57450
- const p = provider;
57451
- if (p && !ethProviders.includes(p)) {
57452
- ethProviders.push(p);
57453
- }
57454
- }
57455
- if (window.ethereum && !ethProviders.includes(window.ethereum)) {
57456
- ethProviders.push(window.ethereum);
57457
- }
57458
- if (window.phantom?.ethereum && !ethProviders.includes(window.phantom.ethereum)) {
57459
- ethProviders.push(window.phantom.ethereum);
57460
- }
57461
- for (const provider of ethProviders) {
57462
- provider.on("accountsChanged", handleEthAccountsChanged);
57463
- provider.on("chainChanged", handleAccountsChanged);
57464
- }
57465
- return () => {
57466
- mounted = false;
57467
- if (solanaProvider) {
57468
- solanaProvider.off("connect", handleAccountsChanged);
57469
- solanaProvider.off("disconnect", handleDisconnect);
57470
- solanaProvider.off("accountChanged", handleAccountsChanged);
57471
- }
57472
- for (const provider of ethProviders) {
57473
- const off = provider.off?.bind(provider) ?? provider.removeListener?.bind(provider);
57474
- if (off) {
57475
- off("accountsChanged", handleEthAccountsChanged);
57476
- off("chainChanged", handleAccountsChanged);
57477
- }
57478
- }
57479
- };
57480
- }, [chainType, eip6963ProviderCount]);
57481
57538
  const handleConnect = async () => {
57482
57539
  if (wallet) {
57483
57540
  onClick(wallet);
@@ -57494,6 +57551,7 @@ function BrowserWalletButton({
57494
57551
  if (solanaProvider?.isPhantom) {
57495
57552
  const { publicKey } = await solanaProvider.connect();
57496
57553
  setUserDisconnectedWallet(false);
57554
+ setStoredWalletState("phantom-solana");
57497
57555
  setWallet({
57498
57556
  type: "phantom-solana",
57499
57557
  name: "Phantom",
@@ -57513,8 +57571,10 @@ function BrowserWalletButton({
57513
57571
  if (accounts && accounts.length > 0) {
57514
57572
  setUserDisconnectedWallet(false);
57515
57573
  const isPhantom = ethProvider.isPhantom;
57574
+ const walletType = isPhantom ? "phantom-ethereum" : "metamask";
57575
+ setStoredWalletState(walletType);
57516
57576
  setWallet({
57517
- type: isPhantom ? "phantom-ethereum" : "metamask",
57577
+ type: walletType,
57518
57578
  name: isPhantom ? "Phantom" : "MetaMask",
57519
57579
  address: accounts[0],
57520
57580
  icon: isPhantom ? "phantom" : "metamask"
@@ -57561,7 +57621,7 @@ function BrowserWalletButton({
57561
57621
  border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
57562
57622
  };
57563
57623
  const sortedWallets = featuredWallets ? [...featuredWallets].sort((a, b) => a.position - b.position) : [];
57564
- const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React242.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
57624
+ const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React252.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
57565
57625
  size: 36,
57566
57626
  className: "uf-rounded-lg",
57567
57627
  variant: "color"
@@ -57823,7 +57883,12 @@ function CoinbaseConnect({
57823
57883
  onBack: parentOnBack,
57824
57884
  onDisconnect,
57825
57885
  skipToHoldings,
57826
- onExecutionsChange
57886
+ canGoBack = true,
57887
+ onExecutionsChange,
57888
+ defaultSourceChainType,
57889
+ defaultSourceChainId,
57890
+ defaultSourceTokenAddress,
57891
+ defaultSourceSymbol
57827
57892
  }) {
57828
57893
  const { colors: colors2, fonts, components } = useTheme();
57829
57894
  const { projectConfig } = useProjectConfig({ publishableKey });
@@ -57888,6 +57953,21 @@ function CoinbaseConnect({
57888
57953
  params: defaultTokenParams,
57889
57954
  publishableKey
57890
57955
  });
57956
+ const defaultSourceCurrency = (0, import_react18.useMemo)(
57957
+ () => resolveDefaultSourceSymbol(supportedTokensData?.data, {
57958
+ defaultSourceChainType,
57959
+ defaultSourceChainId,
57960
+ defaultSourceTokenAddress,
57961
+ defaultSourceSymbol
57962
+ })?.toLowerCase() ?? null,
57963
+ [
57964
+ supportedTokensData,
57965
+ defaultSourceChainType,
57966
+ defaultSourceChainId,
57967
+ defaultSourceTokenAddress,
57968
+ defaultSourceSymbol
57969
+ ]
57970
+ );
57891
57971
  const sortedHoldings = (0, import_react18.useMemo)(() => {
57892
57972
  const supported = [];
57893
57973
  const unsupported = [];
@@ -57897,13 +57977,42 @@ function CoinbaseConnect({
57897
57977
  if (isSupported) supported.push(account);
57898
57978
  else unsupported.push(account);
57899
57979
  });
57980
+ if (defaultSourceCurrency) {
57981
+ const defaultIndex = supported.findIndex(
57982
+ (account) => account.currency.toLowerCase() === defaultSourceCurrency
57983
+ );
57984
+ if (defaultIndex > 0) {
57985
+ const [defaultHolding] = supported.splice(defaultIndex, 1);
57986
+ supported.unshift(defaultHolding);
57987
+ }
57988
+ }
57900
57989
  return [...supported, ...unsupported];
57901
- }, [holdings, supportedSymbols, exchangeSupportedCurrencies]);
57990
+ }, [
57991
+ holdings,
57992
+ supportedSymbols,
57993
+ exchangeSupportedCurrencies,
57994
+ defaultSourceCurrency
57995
+ ]);
57902
57996
  const selectedHoldingIsSupported = (0, import_react18.useMemo)(() => {
57903
57997
  if (!selectedHolding) return false;
57904
57998
  const currencyLower = selectedHolding.currency.toLowerCase();
57905
57999
  return (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
57906
58000
  }, [selectedHolding, supportedSymbols, exchangeSupportedCurrencies]);
58001
+ (0, import_react18.useEffect)(() => {
58002
+ if (!defaultSourceCurrency || selectedHolding) return;
58003
+ const defaultHolding = sortedHoldings.find((account) => {
58004
+ const currencyLower = account.currency.toLowerCase();
58005
+ return currencyLower === defaultSourceCurrency && (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
58006
+ });
58007
+ if (!defaultHolding) return;
58008
+ setSelectedHolding(defaultHolding);
58009
+ }, [
58010
+ defaultSourceCurrency,
58011
+ selectedHolding,
58012
+ sortedHoldings,
58013
+ supportedSymbols,
58014
+ exchangeSupportedCurrencies
58015
+ ]);
57907
58016
  const exchangeName = selectedExchange?.service_provider_display_name || "Exchange";
57908
58017
  const {
57909
58018
  executions: depositExecutions,
@@ -58210,6 +58319,16 @@ function CoinbaseConnect({
58210
58319
  setIsLoading(false);
58211
58320
  }
58212
58321
  };
58322
+ const handleDisconnect = () => {
58323
+ onDisconnect?.();
58324
+ if (!canGoBack) {
58325
+ setAccessToken(null);
58326
+ setHoldings([]);
58327
+ setSelectedHolding(null);
58328
+ setSelectedAsset(null);
58329
+ transitionTo("select_exchange");
58330
+ }
58331
+ };
58213
58332
  const handleBack = () => {
58214
58333
  switch (view) {
58215
58334
  case "select_exchange":
@@ -58270,7 +58389,7 @@ function CoinbaseConnect({
58270
58389
  DepositHeader,
58271
58390
  {
58272
58391
  title: t12.title,
58273
- showBack: true,
58392
+ showBack: canGoBack,
58274
58393
  onBack: handleBack,
58275
58394
  onClose
58276
58395
  }
@@ -58283,7 +58402,7 @@ function CoinbaseConnect({
58283
58402
  DepositHeader,
58284
58403
  {
58285
58404
  title: t12.title,
58286
- showBack: true,
58405
+ showBack: canGoBack,
58287
58406
  onBack: handleBack,
58288
58407
  onClose
58289
58408
  }
@@ -58995,7 +59114,7 @@ function CoinbaseConnect({
58995
59114
  borderRadius: components.button.borderRadius,
58996
59115
  fontFamily: fonts.medium
58997
59116
  },
58998
- onClick: onDisconnect,
59117
+ onClick: handleDisconnect,
58999
59118
  children: t12.disconnect
59000
59119
  }
59001
59120
  )
@@ -59782,7 +59901,7 @@ function ThemeStyleInjector({
59782
59901
  className
59783
59902
  }) {
59784
59903
  const { colors: colors2, fonts, mode } = useTheme();
59785
- const cssVars = React262.useMemo(() => {
59904
+ const cssVars = React272.useMemo(() => {
59786
59905
  const hexToHSL = (hex) => {
59787
59906
  hex = hex.replace("#", "");
59788
59907
  const r2 = parseInt(hex.slice(0, 2), 16) / 255;
@@ -59842,7 +59961,7 @@ function ThemeStyleInjector({
59842
59961
  ...fonts.regular ? { "--uf-font-family": fonts.regular } : {}
59843
59962
  };
59844
59963
  }, [colors2, fonts.regular]);
59845
- React262.useEffect(() => {
59964
+ React272.useEffect(() => {
59846
59965
  if (typeof document === "undefined") return;
59847
59966
  if (fonts.regular) {
59848
59967
  document.documentElement.style.setProperty(
@@ -60801,14 +60920,14 @@ function useCopyAddress() {
60801
60920
  return { copied, handleCopy };
60802
60921
  }
60803
60922
  var TooltipProvider2 = Provider;
60804
- var TooltipContext = React272.createContext({
60923
+ var TooltipContext = React282.createContext({
60805
60924
  open: false,
60806
60925
  onOpenChange: () => {
60807
60926
  }
60808
60927
  });
60809
- var TooltipTrigger2 = React272.forwardRef(({ onClick, ...props }, ref) => {
60810
- const { open, onOpenChange } = React272.useContext(TooltipContext);
60811
- const handleClick = React272.useCallback(
60928
+ var TooltipTrigger2 = React282.forwardRef(({ onClick, ...props }, ref) => {
60929
+ const { open, onOpenChange } = React282.useContext(TooltipContext);
60930
+ const handleClick = React282.useCallback(
60812
60931
  (e) => {
60813
60932
  onOpenChange(!open);
60814
60933
  onClick?.(e);
@@ -60818,7 +60937,7 @@ var TooltipTrigger2 = React272.forwardRef(({ onClick, ...props }, ref) => {
60818
60937
  return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Trigger, { ref, onClick: handleClick, ...props });
60819
60938
  });
60820
60939
  TooltipTrigger2.displayName = Trigger.displayName;
60821
- var TooltipContent2 = React272.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
60940
+ var TooltipContent2 = React282.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
60822
60941
  const { themeClass, colors: colors2 } = useTheme();
60823
60942
  return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Portal3, { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
60824
60943
  Content22,
@@ -61423,7 +61542,7 @@ function TransferCryptoSingleInput({
61423
61542
  }
61424
61543
  var Select2 = Root23;
61425
61544
  var SelectValue2 = Value;
61426
- var SelectTrigger2 = React282.forwardRef(({ className, style, children, ...props }, ref) => {
61545
+ var SelectTrigger2 = React292.forwardRef(({ className, style, children, ...props }, ref) => {
61427
61546
  const { components } = useTheme();
61428
61547
  return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61429
61548
  Trigger2,
@@ -61447,7 +61566,7 @@ var SelectTrigger2 = React282.forwardRef(({ className, style, children, ...props
61447
61566
  );
61448
61567
  });
61449
61568
  SelectTrigger2.displayName = Trigger2.displayName;
61450
- var SelectScrollUpButton2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61569
+ var SelectScrollUpButton2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61451
61570
  ScrollUpButton,
61452
61571
  {
61453
61572
  ref,
@@ -61460,7 +61579,7 @@ var SelectScrollUpButton2 = React282.forwardRef(({ className, ...props }, ref) =
61460
61579
  }
61461
61580
  ));
61462
61581
  SelectScrollUpButton2.displayName = ScrollUpButton.displayName;
61463
- var SelectScrollDownButton2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61582
+ var SelectScrollDownButton2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61464
61583
  ScrollDownButton,
61465
61584
  {
61466
61585
  ref,
@@ -61473,7 +61592,7 @@ var SelectScrollDownButton2 = React282.forwardRef(({ className, ...props }, ref)
61473
61592
  }
61474
61593
  ));
61475
61594
  SelectScrollDownButton2.displayName = ScrollDownButton.displayName;
61476
- var SelectContent2 = React282.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
61595
+ var SelectContent2 = React292.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
61477
61596
  const { themeClass, colors: colors2, components } = useTheme();
61478
61597
  return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Portal4, { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61479
61598
  Content23,
@@ -61511,7 +61630,7 @@ var SelectContent2 = React282.forwardRef(({ className, style, children, position
61511
61630
  ) });
61512
61631
  });
61513
61632
  SelectContent2.displayName = Content23.displayName;
61514
- var SelectLabel2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61633
+ var SelectLabel2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61515
61634
  Label,
61516
61635
  {
61517
61636
  ref,
@@ -61523,7 +61642,7 @@ var SelectLabel2 = React282.forwardRef(({ className, ...props }, ref) => /* @__P
61523
61642
  }
61524
61643
  ));
61525
61644
  SelectLabel2.displayName = Label.displayName;
61526
- var SelectItem2 = React282.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61645
+ var SelectItem2 = React292.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
61527
61646
  Item,
61528
61647
  {
61529
61648
  ref,
@@ -61539,7 +61658,7 @@ var SelectItem2 = React282.forwardRef(({ className, children, ...props }, ref) =
61539
61658
  }
61540
61659
  ));
61541
61660
  SelectItem2.displayName = Item.displayName;
61542
- var SelectSeparator2 = React282.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61661
+ var SelectSeparator2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
61543
61662
  Separator,
61544
61663
  {
61545
61664
  ref,
@@ -63059,6 +63178,19 @@ var WALLET_DEFINITIONS = [
63059
63178
  { id: "backpack", name: "Backpack", networks: ["solana"], installUrl: "https://backpack.app/" },
63060
63179
  { id: "glow", name: "Glow", networks: ["solana"], installUrl: "https://glow.app/" }
63061
63180
  ];
63181
+ function normalizeTokenAddress(address) {
63182
+ const normalized = (address ?? "").toLowerCase();
63183
+ if (normalized === "" || normalized === "native" || normalized === "0x0000000000000000000000000000000000000000") {
63184
+ return "native";
63185
+ }
63186
+ return normalized;
63187
+ }
63188
+ function balancesRepresentSameToken(a, b) {
63189
+ const tokenA = getTokenFromBalance(a);
63190
+ const tokenB = getTokenFromBalance(b);
63191
+ if (!tokenA || !tokenB) return false;
63192
+ return tokenA.chain_type === tokenB.chain_type && tokenA.chain_id === tokenB.chain_id && normalizeTokenAddress(tokenA.token_address) === normalizeTokenAddress(tokenB.token_address);
63193
+ }
63062
63194
  function getSolanaProviders() {
63063
63195
  if (typeof window === "undefined") return {};
63064
63196
  const win = window;
@@ -63201,24 +63333,33 @@ function WalletConnect({
63201
63333
  checkoutRemainingBaseUnits,
63202
63334
  stablecoinParity = false,
63203
63335
  productType,
63336
+ defaultSourceChainType,
63337
+ defaultSourceChainId,
63338
+ defaultSourceTokenAddress,
63339
+ defaultSourceSymbol,
63204
63340
  onBack: parentOnBack,
63205
63341
  onClose,
63342
+ canGoBack = true,
63343
+ depositWalletsLoading = false,
63206
63344
  onExecutionsChange
63207
63345
  }) {
63208
63346
  const { colors: colors2, fonts, components } = useTheme();
63209
- const walletProvidedAtMount = React292.useRef(!!initialWalletInfo && !!initialDepositWallet);
63210
- const [activeWalletInfo, setActiveWalletInfo] = React292.useState(initialWalletInfo ?? null);
63211
- const [activeDepositWallet, setActiveDepositWallet] = React292.useState(initialDepositWallet ?? null);
63347
+ const walletProvidedAtMount = React302.useRef(!!initialWalletInfo && !!initialDepositWallet);
63348
+ const [activeWalletInfo, setActiveWalletInfo] = React302.useState(initialWalletInfo ?? null);
63349
+ const [activeDepositWallet, setActiveDepositWallet] = React302.useState(initialDepositWallet ?? null);
63212
63350
  const initialView = initialWalletInfo && initialDepositWallet ? "select_token" : "select_wallet";
63213
- const [view, setView] = React292.useState(initialView);
63214
- const [isTransitioning, setIsTransitioning] = React292.useState(false);
63215
- const viewRef = React292.useRef(initialView);
63216
- const [selectedWalletDef, setSelectedWalletDef] = React292.useState(null);
63217
- const [connectingNetwork, setConnectingNetwork] = React292.useState(null);
63218
- const [walletError, setWalletError] = React292.useState(null);
63219
- const [isWalletConnecting, setIsWalletConnecting] = React292.useState(false);
63220
- const [eip6963ProviderCount, setEip6963ProviderCount] = React292.useState(0);
63221
- React292.useEffect(() => {
63351
+ const [view, setView] = React302.useState(initialView);
63352
+ const [isTransitioning, setIsTransitioning] = React302.useState(false);
63353
+ const viewRef = React302.useRef(initialView);
63354
+ const standalone = !canGoBack && !walletProvidedAtMount.current;
63355
+ const { wallet: detectedWallet, isLoading: detectingWallet } = useDetectedBrowserWallet({ enabled: standalone });
63356
+ const [autoResolved, setAutoResolved] = React302.useState(false);
63357
+ const [selectedWalletDef, setSelectedWalletDef] = React302.useState(null);
63358
+ const [connectingNetwork, setConnectingNetwork] = React302.useState(null);
63359
+ const [walletError, setWalletError] = React302.useState(null);
63360
+ const [isWalletConnecting, setIsWalletConnecting] = React302.useState(false);
63361
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React302.useState(0);
63362
+ React302.useEffect(() => {
63222
63363
  const store = getEip6963Store();
63223
63364
  if (!store) return;
63224
63365
  setEip6963ProviderCount(store.getProviders().length);
@@ -63226,20 +63367,44 @@ function WalletConnect({
63226
63367
  setEip6963ProviderCount(providers.length);
63227
63368
  });
63228
63369
  }, []);
63229
- const availableWallets = React292.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
63230
- const [balances, setBalances] = React292.useState([]);
63231
- const [isLoading, setIsLoading] = React292.useState(false);
63232
- const [selectedBalance, setSelectedBalance] = React292.useState(null);
63233
- const [totalBalanceUsd, setTotalBalanceUsd] = React292.useState(null);
63234
- const [error, setError] = React292.useState(null);
63235
- const [isDisconnectingWallet, setIsDisconnectingWallet] = React292.useState(false);
63236
- const [amountUsd, setAmountUsd] = React292.useState(prefillAmountUsd ?? "");
63237
- const [isConfirming, setIsConfirming] = React292.useState(false);
63238
- const [hasSignedTransaction, setHasSignedTransaction] = React292.useState(false);
63239
- const [tokenChainDetails, setTokenChainDetails] = React292.useState(null);
63240
- const [loadingTokenDetails, setLoadingTokenDetails] = React292.useState(false);
63241
- const [showTransactionDetails, setShowTransactionDetails] = React292.useState(false);
63242
- const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React292.useState(null);
63370
+ const availableWallets = React302.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
63371
+ React302.useEffect(() => {
63372
+ if (!standalone || autoResolved || detectingWallet) return;
63373
+ if (!detectedWallet) {
63374
+ setAutoResolved(true);
63375
+ return;
63376
+ }
63377
+ const wct = detectedWallet.type === "phantom-solana" || detectedWallet.type === "solflare" || detectedWallet.type === "backpack" || detectedWallet.type === "glow" ? "solana" : "ethereum";
63378
+ const matching = depositWallets?.find((w) => w.chain_type === wct);
63379
+ if (!matching) {
63380
+ if (!depositWalletsLoading) setAutoResolved(true);
63381
+ return;
63382
+ }
63383
+ setActiveWalletInfo(detectedWallet);
63384
+ setActiveDepositWallet(matching);
63385
+ onWalletConnected?.(detectedWallet, matching);
63386
+ setView("select_token");
63387
+ viewRef.current = "select_token";
63388
+ setAutoResolved(true);
63389
+ }, [standalone, autoResolved, detectingWallet, detectedWallet, depositWallets, depositWalletsLoading]);
63390
+ React302.useEffect(() => {
63391
+ if (!standalone || autoResolved) return;
63392
+ const t12 = setTimeout(() => setAutoResolved(true), 5e3);
63393
+ return () => clearTimeout(t12);
63394
+ }, [standalone, autoResolved]);
63395
+ const [balances, setBalances] = React302.useState([]);
63396
+ const [isLoading, setIsLoading] = React302.useState(false);
63397
+ const [selectedBalance, setSelectedBalance] = React302.useState(null);
63398
+ const [totalBalanceUsd, setTotalBalanceUsd] = React302.useState(null);
63399
+ const [error, setError] = React302.useState(null);
63400
+ const [isDisconnectingWallet, setIsDisconnectingWallet] = React302.useState(false);
63401
+ const [amountUsd, setAmountUsd] = React302.useState(prefillAmountUsd ?? "");
63402
+ const [isConfirming, setIsConfirming] = React302.useState(false);
63403
+ const [hasSignedTransaction, setHasSignedTransaction] = React302.useState(false);
63404
+ const [tokenChainDetails, setTokenChainDetails] = React302.useState(null);
63405
+ const [loadingTokenDetails, setLoadingTokenDetails] = React302.useState(false);
63406
+ const [showTransactionDetails, setShowTransactionDetails] = React302.useState(false);
63407
+ const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React302.useState(null);
63243
63408
  const walletInfo = activeWalletInfo;
63244
63409
  const depositWallet = activeDepositWallet;
63245
63410
  const hasWallet = !!activeWalletInfo && !!activeDepositWallet;
@@ -63247,7 +63412,7 @@ function WalletConnect({
63247
63412
  const recipientAddress = activeDepositWallet?.address ?? "";
63248
63413
  const isCheckoutMode = !!checkoutAmountUsd;
63249
63414
  const supportedChainType = chainType === "algorand" || chainType === "xrpl" ? "ethereum" : chainType;
63250
- const transitionTo = React292.useCallback((nextView) => {
63415
+ const transitionTo = React302.useCallback((nextView) => {
63251
63416
  if (nextView === viewRef.current) return;
63252
63417
  setIsTransitioning(true);
63253
63418
  setTimeout(() => {
@@ -63332,6 +63497,7 @@ function WalletConnect({
63332
63497
  metamask: "metamask"
63333
63498
  };
63334
63499
  const walletType = walletIdToType[wallet.id] || "metamask";
63500
+ setStoredWalletState(walletType);
63335
63501
  connectedInfo = { type: walletType, name: wallet.name, address: accounts[0], icon: wallet.id };
63336
63502
  } else {
63337
63503
  const solProviders = getSolanaProviders();
@@ -63360,6 +63526,7 @@ function WalletConnect({
63360
63526
  const response = await provider.connect();
63361
63527
  setUserDisconnectedWallet(false);
63362
63528
  const walletType = wallet.id === "solflare" ? "solflare" : wallet.id === "backpack" ? "backpack" : wallet.id === "glow" ? "glow" : "phantom-solana";
63529
+ setStoredWalletState(walletType);
63363
63530
  connectedInfo = { type: walletType, name: wallet.name, address: response.publicKey.toString(), icon: wallet.id };
63364
63531
  }
63365
63532
  const walletChainType = network === "solana" ? "solana" : "ethereum";
@@ -63384,7 +63551,7 @@ function WalletConnect({
63384
63551
  }
63385
63552
  };
63386
63553
  const selectedToken = selectedBalance ? getTokenFromBalance(selectedBalance) : null;
63387
- const effectiveDestinationAmount = React292.useMemo(() => {
63554
+ const effectiveDestinationAmount = React302.useMemo(() => {
63388
63555
  if (!checkoutRemainingBaseUnits || checkoutRemainingBaseUnits === "0") return "0";
63389
63556
  if (!checkoutAmountUsd) return checkoutRemainingBaseUnits;
63390
63557
  const remaining = BigInt(checkoutRemainingBaseUnits);
@@ -63412,7 +63579,7 @@ function WalletConnect({
63412
63579
  stablecoinParity,
63413
63580
  enabled: isCheckoutMode && !!selectedToken && !!checkoutDestination && effectiveDestinationAmount !== "0"
63414
63581
  });
63415
- const activeCheckoutQuote = React292.useMemo(() => {
63582
+ const activeCheckoutQuote = React302.useMemo(() => {
63416
63583
  if (!isCheckoutMode) return null;
63417
63584
  if (walletCheckoutQuote) return { sourceAmount: walletCheckoutQuote.source_amount, sourceTokenDecimals: walletCheckoutQuote.source_token_decimals, sourceTokenSymbol: walletCheckoutQuote.source_token_symbol, sourceAmountUsd: walletCheckoutQuote.source_amount_usd, slippageBufferPercent: walletCheckoutQuote.slippage_buffer_percent ?? null };
63418
63585
  return checkoutQuote ?? null;
@@ -63426,19 +63593,19 @@ function WalletConnect({
63426
63593
  onDepositSuccess,
63427
63594
  onDepositError
63428
63595
  });
63429
- React292.useEffect(() => {
63596
+ React302.useEffect(() => {
63430
63597
  onExecutionsChange?.(depositExecutions);
63431
63598
  }, [depositExecutions, onExecutionsChange]);
63432
- React292.useEffect(() => {
63599
+ React302.useEffect(() => {
63433
63600
  if (!prefillAmountUsd || !tokenChainDetails || view !== "enter_amount") return;
63434
63601
  const minDeposit = tokenChainDetails.minimum_deposit_amount_usd || 0;
63435
63602
  const currentAmount = parseFloat(amountUsd) || 0;
63436
63603
  if (currentAmount > 0 && currentAmount < minDeposit) setAmountUsd(minDeposit.toFixed(2));
63437
63604
  }, [tokenChainDetails, view, prefillAmountUsd]);
63438
- React292.useEffect(() => {
63605
+ React302.useEffect(() => {
63439
63606
  if (view === "review") setShowTransactionDetails(false);
63440
63607
  }, [view]);
63441
- React292.useEffect(() => {
63608
+ React302.useEffect(() => {
63442
63609
  if (view !== "enter_amount" && view !== "review" || !selectedBalance || !activeDepositWallet) return;
63443
63610
  let cancelled = false;
63444
63611
  const fetchTokenDetails = async () => {
@@ -63465,7 +63632,7 @@ function WalletConnect({
63465
63632
  cancelled = true;
63466
63633
  };
63467
63634
  }, [view, selectedBalance, publishableKey, activeDepositWallet]);
63468
- React292.useEffect(() => {
63635
+ React302.useEffect(() => {
63469
63636
  if (!activeWalletInfo || !activeDepositWallet) return;
63470
63637
  let cancelled = false;
63471
63638
  setIsLoading(true);
@@ -63474,18 +63641,33 @@ function WalletConnect({
63474
63641
  getAddressBalances(activeWalletInfo.address, sct, publishableKey).then((response) => {
63475
63642
  if (cancelled) return;
63476
63643
  const nonZero = response.balances.filter((b) => b.amount !== "0");
63477
- const sorted = [...nonZero].sort((a, b) => {
63478
- const ae = isBalanceEligible(a);
63479
- const be = isBalanceEligible(b);
63480
- if (ae && !be) return -1;
63481
- if (!ae && be) return 1;
63482
- return 0;
63483
- });
63644
+ const defaultSource = {
63645
+ defaultSourceChainType,
63646
+ defaultSourceChainId,
63647
+ defaultSourceTokenAddress,
63648
+ defaultSourceSymbol
63649
+ };
63650
+ const sorted = [...nonZero].sort(
63651
+ (a, b) => compareBalancesWithDefaultSource(a, b, defaultSource)
63652
+ );
63484
63653
  setBalances(sorted);
63485
63654
  const totalUsd = nonZero.reduce((sum, b) => b.amount_usd ? sum + parseFloat(b.amount_usd) : sum, 0);
63486
63655
  if (totalUsd > 0) setTotalBalanceUsd(totalUsd.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 }));
63487
63656
  const eligible = sorted.filter(isBalanceEligible);
63488
- if (eligible.length === 1) setSelectedBalance(eligible[0]);
63657
+ const defaultBalance = sorted.find(
63658
+ (balance) => isDefaultSourceBalance(balance, defaultSource)
63659
+ );
63660
+ setSelectedBalance((current) => {
63661
+ if (current) {
63662
+ const currentInNewBalances = sorted.find(
63663
+ (balance) => balancesRepresentSameToken(balance, current)
63664
+ );
63665
+ if (currentInNewBalances) return currentInNewBalances;
63666
+ }
63667
+ if (defaultBalance) return defaultBalance;
63668
+ if (eligible.length === 1) return eligible[0];
63669
+ return null;
63670
+ });
63489
63671
  }).catch((err) => {
63490
63672
  if (!cancelled) {
63491
63673
  console.error("[WalletConnect] Error fetching balances:", err);
@@ -63497,21 +63679,29 @@ function WalletConnect({
63497
63679
  return () => {
63498
63680
  cancelled = true;
63499
63681
  };
63500
- }, [activeWalletInfo?.address, activeDepositWallet?.chain_type, publishableKey]);
63501
- const usdToTokenRate = React292.useMemo(() => {
63682
+ }, [
63683
+ activeWalletInfo?.address,
63684
+ activeDepositWallet?.chain_type,
63685
+ publishableKey,
63686
+ defaultSourceChainType,
63687
+ defaultSourceChainId,
63688
+ defaultSourceTokenAddress,
63689
+ defaultSourceSymbol
63690
+ ]);
63691
+ const usdToTokenRate = React302.useMemo(() => {
63502
63692
  if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
63503
63693
  const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
63504
63694
  const balanceUsd = parseFloat(selectedBalance.amount_usd);
63505
63695
  if (balanceAmount === 0 || balanceUsd === 0) return 0;
63506
63696
  return balanceAmount / balanceUsd;
63507
63697
  }, [selectedBalance, selectedToken]);
63508
- const tokenAmount = React292.useMemo(() => {
63698
+ const tokenAmount = React302.useMemo(() => {
63509
63699
  if (isCheckoutMode && activeCheckoutQuote && selectedToken) return Number(activeCheckoutQuote.sourceAmount) / 10 ** activeCheckoutQuote.sourceTokenDecimals;
63510
63700
  const usdNum = parseFloat(amountUsd) || 0;
63511
63701
  if (usdNum === 0 || usdToTokenRate === 0) return 0;
63512
63702
  return usdNum * usdToTokenRate;
63513
63703
  }, [amountUsd, usdToTokenRate, isCheckoutMode, activeCheckoutQuote, selectedToken]);
63514
- React292.useEffect(() => {
63704
+ React302.useEffect(() => {
63515
63705
  if (isCheckoutMode && activeCheckoutQuote?.sourceAmountUsd && view === "enter_amount") setAmountUsd(activeCheckoutQuote.sourceAmountUsd);
63516
63706
  }, [isCheckoutMode, activeCheckoutQuote, view]);
63517
63707
  const maxTokenAmount = selectedBalance && selectedToken ? Number(selectedBalance.amount) / 10 ** selectedToken.decimals : 0;
@@ -63519,7 +63709,7 @@ function WalletConnect({
63519
63709
  const inputUsdNum = parseFloat(amountUsd) || 0;
63520
63710
  const minDepositUsd = tokenChainDetails?.minimum_deposit_amount_usd || 0;
63521
63711
  const isValidAmount = isCheckoutMode && activeCheckoutQuote ? tokenAmount > 0 && tokenAmount <= maxTokenAmount : inputUsdNum > 0 && inputUsdNum <= maxUsdAmount && inputUsdNum >= minDepositUsd;
63522
- const formattedTokenAmount = React292.useMemo(() => {
63712
+ const formattedTokenAmount = React302.useMemo(() => {
63523
63713
  if (tokenAmount === 0 || !selectedToken) return null;
63524
63714
  return `${tokenAmount.toFixed(6)} ${selectedToken.symbol}`.replace(/\.?0+$/, "");
63525
63715
  }, [tokenAmount, selectedToken]);
@@ -63567,16 +63757,25 @@ function WalletConnect({
63567
63757
  } catch (err) {
63568
63758
  console.warn("[WalletConnect] disconnect error:", err);
63569
63759
  } finally {
63570
- setActiveWalletInfo(null);
63571
- setActiveDepositWallet(null);
63572
- setSelectedBalance(null);
63573
- setBalances([]);
63574
- setTotalBalanceUsd(null);
63575
- setAmountUsd(prefillAmountUsd ?? "");
63576
- setError(null);
63577
63760
  setIsDisconnectingWallet(false);
63578
- if (onWalletDisconnect) onWalletDisconnect();
63579
- else parentOnBack?.();
63761
+ const clearWalletState = () => {
63762
+ setActiveWalletInfo(null);
63763
+ setActiveDepositWallet(null);
63764
+ setSelectedBalance(null);
63765
+ setBalances([]);
63766
+ setTotalBalanceUsd(null);
63767
+ setAmountUsd(prefillAmountUsd ?? "");
63768
+ setError(null);
63769
+ };
63770
+ if (standalone) {
63771
+ onWalletDisconnect?.();
63772
+ transitionTo("select_wallet");
63773
+ setTimeout(clearWalletState, 160);
63774
+ } else {
63775
+ clearWalletState();
63776
+ if (onWalletDisconnect) onWalletDisconnect();
63777
+ else parentOnBack?.();
63778
+ }
63580
63779
  }
63581
63780
  };
63582
63781
  const handleReview = () => {
@@ -63702,9 +63901,15 @@ function WalletConnect({
63702
63901
  setIsConfirming(false);
63703
63902
  }
63704
63903
  };
63904
+ if (standalone && !autoResolved) {
63905
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { style: viewTransitionStyle, children: [
63906
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: "Connect Wallet", showBack: canGoBack, onBack: handleBack, onClose }),
63907
+ /* @__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 } }) })
63908
+ ] });
63909
+ }
63705
63910
  if (view === "select_wallet") {
63706
63911
  return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { style: viewTransitionStyle, children: [
63707
- /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: "Connect Wallet", showBack: true, onBack: handleBack, onClose }),
63912
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: "Connect Wallet", showBack: canGoBack, onBack: handleBack, onClose }),
63708
63913
  /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-pb-4", children: [
63709
63914
  /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("p", { className: "uf-text-sm uf-text-center uf-pb-4", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: "Select a wallet to connect" }),
63710
63915
  /* @__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)(
@@ -63837,16 +64042,17 @@ function DepositModal({
63837
64042
  defaultSourceChainId,
63838
64043
  defaultSourceTokenAddress,
63839
64044
  defaultSourceSymbol,
63840
- hideDepositTracker = false,
64045
+ hideDepositTracker,
63841
64046
  showBalanceHeader = false,
63842
64047
  transferInputVariant = "double_input",
63843
64048
  depositConfirmationMode = "auto_ui",
63844
- enableConnectWallet = false,
64049
+ enableTransferCrypto,
64050
+ enableConnectWallet,
63845
64051
  browserWalletAmountQuickSelect = "percentage",
63846
64052
  enablePayWithExchange,
63847
64053
  enableFiatOnramp,
63848
- enableConnectExchange = false,
63849
- enableCashApp = false,
64054
+ enableConnectExchange,
64055
+ enableCashApp,
63850
64056
  hideDepositFlowInfo = false,
63851
64057
  hideDisplayDescription = false,
63852
64058
  onDepositSuccess,
@@ -63864,11 +64070,23 @@ function DepositModal({
63864
64070
  const { colors: colors2, fonts, components } = useTheme();
63865
64071
  const effectiveInitialScreen = (0, import_react3.useMemo)(() => {
63866
64072
  const s = initialScreen ?? "main";
63867
- if (s === "tracker" && hideDepositTracker) return "main";
63868
- if (s === "cashapp" && !enableCashApp) return "main";
64073
+ if (s === "tracker" && hideDepositTracker === true) return "main";
64074
+ if (s === "cashapp" && enableCashApp === false) return "main";
63869
64075
  if (s === "card" && enableFiatOnramp === false) return "main";
64076
+ if (s === "pay_with_exchange") return enablePayWithExchange === false ? "main" : "exchange";
64077
+ if (s === "exchange_connect")
64078
+ return enableConnectExchange === false ? "main" : "coinbase_connect";
64079
+ if (s === "wallet_connect") return enableConnectWallet === false ? "main" : "wallet_connect";
63870
64080
  return s;
63871
- }, [initialScreen, hideDepositTracker, enableCashApp, enableFiatOnramp]);
64081
+ }, [
64082
+ initialScreen,
64083
+ hideDepositTracker,
64084
+ enableCashApp,
64085
+ enableFiatOnramp,
64086
+ enablePayWithExchange,
64087
+ enableConnectExchange,
64088
+ enableConnectWallet
64089
+ ]);
63872
64090
  const [containerEl, setContainerEl] = (0, import_react3.useState)(null);
63873
64091
  const containerCallbackRef = (0, import_react3.useCallback)((el) => {
63874
64092
  setContainerEl(el);
@@ -63887,26 +64105,37 @@ function DepositModal({
63887
64105
  const [browserWalletModalOpen, setBrowserWalletModalOpen] = (0, import_react3.useState)(false);
63888
64106
  const [browserWalletInfo, setBrowserWalletInfo] = (0, import_react3.useState)(null);
63889
64107
  const [walletSelectionModalOpen, setWalletSelectionModalOpen] = (0, import_react3.useState)(false);
63890
- const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react3.useState)(() => getStoredWalletChainType());
64108
+ const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react3.useState)(() => getStoredWalletState()?.chainType);
63891
64109
  const [quotesCount, setQuotesCount] = (0, import_react3.useState)(0);
63892
64110
  const [allExecutions, setAllExecutions] = (0, import_react3.useState)([]);
63893
64111
  const [selectedExecution, setSelectedExecution] = (0, import_react3.useState)(null);
63894
64112
  const [depositExecutions, setDepositExecutions] = (0, import_react3.useState)([]);
63895
64113
  const isMobileView = useIsMobileViewport();
64114
+ const { projectConfig } = useProjectConfig({
64115
+ publishableKey,
64116
+ enabled: open
64117
+ });
64118
+ const showTransferCrypto = enableTransferCrypto ?? projectConfig?.transfer_crypto?.enabled ?? true;
64119
+ const showConnectWallet = enableConnectWallet ?? projectConfig?.connect_wallet?.enabled ?? true;
64120
+ const showPayWithExchange = enablePayWithExchange ?? projectConfig?.pay_with_exchange?.enabled ?? true;
64121
+ const showFiatOnramp = enableFiatOnramp ?? projectConfig?.fiat_onramp?.enabled ?? true;
64122
+ const showConnectExchange = enableConnectExchange ?? projectConfig?.connect_exchange?.enabled ?? true;
64123
+ const showCashApp = enableCashApp ?? projectConfig?.cash_app?.enabled ?? true;
64124
+ const showDepositTracker = hideDepositTracker ? false : projectConfig?.deposit_tracker?.enabled ?? true;
63896
64125
  const [integrationExchanges, setIntegrationExchanges] = (0, import_react3.useState)([]);
63897
64126
  (0, import_react3.useEffect)(() => {
63898
- if (!enableConnectExchange || !open) return;
64127
+ if (!showConnectExchange || !open) return;
63899
64128
  getIntegrationExchanges(publishableKey).then((res) => setIntegrationExchanges(res.data)).catch(() => {
63900
64129
  });
63901
- }, [enableConnectExchange, open, publishableKey]);
64130
+ }, [showConnectExchange, open, publishableKey]);
63902
64131
  const [connectedExchange, setConnectedExchange] = (0, import_react3.useState)(() => {
63903
- if (!enableConnectExchange) return null;
64132
+ if (!showConnectExchange) return null;
63904
64133
  const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
63905
64134
  if (!stored) return null;
63906
64135
  return { name: "Coinbase", iconUrl: void 0, balanceUsd: null, isLoading: true };
63907
64136
  });
63908
64137
  (0, import_react3.useEffect)(() => {
63909
- if (!enableConnectExchange || !open || view !== "main") return;
64138
+ if (!showConnectExchange || !open || view !== "main") return;
63910
64139
  const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
63911
64140
  if (!stored) {
63912
64141
  setConnectedExchange(null);
@@ -63941,7 +64170,7 @@ function DepositModal({
63941
64170
  setConnectedExchange(null);
63942
64171
  }
63943
64172
  });
63944
- }, [enableConnectExchange, open, view, publishableKey]);
64173
+ }, [showConnectExchange, open, view, publishableKey]);
63945
64174
  (0, import_react3.useEffect)(() => {
63946
64175
  if (!connectedExchange || integrationExchanges.length === 0) return;
63947
64176
  const cbExchange = integrationExchanges.find(
@@ -63980,18 +64209,39 @@ function DepositModal({
63980
64209
  setResolvedTheme(theme);
63981
64210
  }
63982
64211
  }, [theme]);
63983
- const { projectConfig } = useProjectConfig({
63984
- publishableKey,
63985
- enabled: open
63986
- });
63987
- const showPayWithExchange = enablePayWithExchange ?? projectConfig?.pay_with_exchange?.enabled ?? true;
63988
- const showFiatOnramp = enableFiatOnramp ?? projectConfig?.fiat_onramp?.enabled ?? true;
63989
64212
  (0, import_react3.useEffect)(() => {
63990
64213
  if (view === "card" && !showFiatOnramp) {
63991
64214
  setView("main");
63992
64215
  setCardView("amount");
64216
+ } else if (view === "transfer" && !showTransferCrypto) {
64217
+ setView("main");
64218
+ } else if (view === "exchange" && !showPayWithExchange) {
64219
+ setView("main");
64220
+ } else if (view === "cashapp" && !showCashApp) {
64221
+ setView("main");
64222
+ } else if (view === "tracker" && !showDepositTracker) {
64223
+ setView("main");
64224
+ } else if (view === "coinbase_connect" && !showConnectExchange) {
64225
+ setView("main");
64226
+ } else if (view === "wallet_connect" && !showConnectWallet) {
64227
+ setView("main");
64228
+ }
64229
+ }, [
64230
+ view,
64231
+ showFiatOnramp,
64232
+ showTransferCrypto,
64233
+ showPayWithExchange,
64234
+ showCashApp,
64235
+ showDepositTracker,
64236
+ showConnectExchange,
64237
+ showConnectWallet
64238
+ ]);
64239
+ (0, import_react3.useEffect)(() => {
64240
+ if (view === "exchange" && !showPayWithExchange) {
64241
+ setView("main");
64242
+ setExchangeView("providers");
63993
64243
  }
63994
- }, [view, showFiatOnramp]);
64244
+ }, [view, showPayWithExchange]);
63995
64245
  const { exchanges, isLoading: exchangesLoading } = useExchanges({
63996
64246
  publishableKey,
63997
64247
  enabled: open && showPayWithExchange
@@ -64075,7 +64325,7 @@ function DepositModal({
64075
64325
  depositPrerequisiteBody = standaloneNeedsDepositPrereq ? /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, { variant: "with-icons" }) : /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(import_jsx_runtime74.Fragment, { children: [
64076
64326
  /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, { variant: "with-icons" }),
64077
64327
  /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, { variant: "with-icons" }),
64078
- !hideDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, {})
64328
+ showDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, {})
64079
64329
  ] });
64080
64330
  } else if (countryError) {
64081
64331
  depositPrerequisiteBody = /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-8 uf-px-4 uf-text-center", children: [
@@ -64107,11 +64357,11 @@ function DepositModal({
64107
64357
  const themeClass = resolvedTheme === "dark" ? "uf-dark" : "";
64108
64358
  const handleWalletDisconnect = () => {
64109
64359
  setUserDisconnectedWallet(true);
64110
- clearStoredWalletChainType();
64360
+ clearStoredWalletState();
64111
64361
  setBrowserWalletChainType(void 0);
64112
64362
  setBrowserWalletInfo(null);
64113
64363
  setBrowserWalletModalOpen(false);
64114
- if (view === "wallet_connect") setView("main");
64364
+ if (view === "wallet_connect" && sessionOpenedFromMenu) setView("main");
64115
64365
  };
64116
64366
  const handleExchangeDisconnect = () => {
64117
64367
  const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
@@ -64120,7 +64370,7 @@ function DepositModal({
64120
64370
  }
64121
64371
  clearStoredIntegrationToken(IntegrationProvider.COINBASE);
64122
64372
  setConnectedExchange(null);
64123
- if (view === "coinbase_connect") setView("main");
64373
+ if (view === "coinbase_connect" && sessionOpenedFromMenu) setView("main");
64124
64374
  };
64125
64375
  const handleClose = () => {
64126
64376
  onOpenChange(false);
@@ -64132,6 +64382,7 @@ function DepositModal({
64132
64382
  setCardView("amount");
64133
64383
  setExchangeView("providers");
64134
64384
  setBrowserWalletInfo(null);
64385
+ setCoinbaseSkipToHoldings(false);
64135
64386
  resetViewTimeoutRef.current = null;
64136
64387
  }, 200);
64137
64388
  };
@@ -64146,6 +64397,7 @@ function DepositModal({
64146
64397
  setExchangeView("providers");
64147
64398
  setBrowserWalletInfo(null);
64148
64399
  setSelectedExecution(null);
64400
+ setCoinbaseSkipToHoldings(false);
64149
64401
  }, [open, effectiveInitialScreen]);
64150
64402
  (0, import_react3.useEffect)(
64151
64403
  () => () => {
@@ -64183,7 +64435,7 @@ function DepositModal({
64183
64435
  };
64184
64436
  const handleBrowserWalletClick = (walletInfo) => {
64185
64437
  const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
64186
- setStoredWalletChainType(walletChainType);
64438
+ setStoredWalletState(walletInfo.type);
64187
64439
  setBrowserWalletChainType(walletChainType);
64188
64440
  const matchingDepositWallet = wallets.find(
64189
64441
  (w) => w.chain_type === walletChainType
@@ -64214,7 +64466,7 @@ function DepositModal({
64214
64466
  };
64215
64467
  const handleWalletConnected = (walletInfo) => {
64216
64468
  const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
64217
- setStoredWalletChainType(walletChainType);
64469
+ setStoredWalletState(walletInfo.type);
64218
64470
  setBrowserWalletChainType(walletChainType);
64219
64471
  const matchingDepositWallet = wallets.find(
64220
64472
  (w) => w.chain_type === walletChainType
@@ -64281,7 +64533,7 @@ function DepositModal({
64281
64533
  ),
64282
64534
  /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
64283
64535
  /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("div", { className: "uf-space-y-3", children: depositPrerequisiteBody ?? /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(import_jsx_runtime74.Fragment, { children: [
64284
- /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64536
+ showTransferCrypto && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64285
64537
  TransferCryptoButton,
64286
64538
  {
64287
64539
  onClick: () => setView("transfer"),
@@ -64290,7 +64542,7 @@ function DepositModal({
64290
64542
  featuredTokens: projectConfig?.transfer_crypto.networks
64291
64543
  }
64292
64544
  ),
64293
- enableConnectWallet && !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64545
+ showConnectWallet && !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64294
64546
  BrowserWalletButton,
64295
64547
  {
64296
64548
  onClick: handleBrowserWalletClick,
@@ -64320,7 +64572,7 @@ function DepositModal({
64320
64572
  loading: exchangesLoading
64321
64573
  }
64322
64574
  ),
64323
- enableConnectExchange && connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64575
+ showConnectExchange && connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64324
64576
  ConnectExchangeButton,
64325
64577
  {
64326
64578
  onClick: () => {
@@ -64334,7 +64586,7 @@ function DepositModal({
64334
64586
  connectedExchange
64335
64587
  }
64336
64588
  ),
64337
- enableConnectExchange && !connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64589
+ showConnectExchange && !connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64338
64590
  ConnectExchangeButton,
64339
64591
  {
64340
64592
  onClick: () => {
@@ -64346,7 +64598,7 @@ function DepositModal({
64346
64598
  exchanges: integrationExchanges
64347
64599
  }
64348
64600
  ),
64349
- enableCashApp && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64601
+ showCashApp && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64350
64602
  CashAppButton,
64351
64603
  {
64352
64604
  onClick: () => setView("cashapp"),
@@ -64355,7 +64607,7 @@ function DepositModal({
64355
64607
  iconUrl: projectConfig?.asset_cdn_url ? `${projectConfig.asset_cdn_url}/api/public/icons/onramps/svg/cashapp.svg` : void 0
64356
64608
  }
64357
64609
  ),
64358
- !hideDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64610
+ showDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64359
64611
  DepositTrackerButton,
64360
64612
  {
64361
64613
  onClick: () => {
@@ -64505,7 +64757,7 @@ function DepositModal({
64505
64757
  DepositHeader,
64506
64758
  {
64507
64759
  title: payWithExchangeTitle,
64508
- showBack: true,
64760
+ showBack: exchangeView === "pending" || sessionOpenedFromMenu,
64509
64761
  onBack: handleBack,
64510
64762
  onClose: handleClose
64511
64763
  }
@@ -64559,7 +64811,12 @@ function DepositModal({
64559
64811
  onClose: handleClose,
64560
64812
  onDisconnect: handleExchangeDisconnect,
64561
64813
  skipToHoldings: coinbaseSkipToHoldings,
64562
- onExecutionsChange: setDepositExecutions
64814
+ canGoBack: sessionOpenedFromMenu,
64815
+ onExecutionsChange: setDepositExecutions,
64816
+ defaultSourceChainType,
64817
+ defaultSourceChainId,
64818
+ defaultSourceTokenAddress,
64819
+ defaultSourceSymbol
64563
64820
  }
64564
64821
  ),
64565
64822
  depositPoweredByFooter
@@ -64592,11 +64849,17 @@ function DepositModal({
64592
64849
  onWalletDisconnect: handleWalletDisconnect,
64593
64850
  onWalletConnected: (info, dw) => {
64594
64851
  setBrowserWalletInfo({ ...info, depositWallet: dw });
64595
- setStoredWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
64852
+ setStoredWalletState(info.type);
64596
64853
  setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
64597
64854
  },
64598
64855
  onBack: handleBack,
64599
- onClose: handleClose
64856
+ onClose: handleClose,
64857
+ defaultSourceChainType,
64858
+ defaultSourceChainId,
64859
+ defaultSourceTokenAddress,
64860
+ defaultSourceSymbol,
64861
+ canGoBack: sessionOpenedFromMenu,
64862
+ depositWalletsLoading: walletsLoading
64600
64863
  }
64601
64864
  ),
64602
64865
  depositPoweredByFooter
@@ -64605,7 +64868,7 @@ function DepositModal({
64605
64868
  DepositHeader,
64606
64869
  {
64607
64870
  title: cashAppView !== "amount" && cashAppAmount ? `Pay $${cashAppAmount} via Cash App` : "Pay with Cash App",
64608
- showBack: true,
64871
+ showBack: cashAppView !== "amount" || sessionOpenedFromMenu,
64609
64872
  onBack: handleBack,
64610
64873
  onClose: handleClose
64611
64874
  }
@@ -64697,7 +64960,8 @@ function CheckoutModal({
64697
64960
  clientSecret,
64698
64961
  publishableKey,
64699
64962
  modalTitle,
64700
- enableConnectWallet = false,
64963
+ enableTransferCrypto,
64964
+ enableConnectWallet,
64701
64965
  defaultSourceChainType,
64702
64966
  defaultSourceChainId,
64703
64967
  defaultSourceTokenAddress,
@@ -64714,7 +64978,7 @@ function CheckoutModal({
64714
64978
  const [browserWalletModalOpen, setBrowserWalletModalOpen] = (0, import_react29.useState)(false);
64715
64979
  const [browserWalletInfo, setBrowserWalletInfo] = (0, import_react29.useState)(null);
64716
64980
  const [walletSelectionModalOpen, setWalletSelectionModalOpen] = (0, import_react29.useState)(false);
64717
- const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react29.useState)(() => getStoredWalletChainType());
64981
+ const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react29.useState)(() => getStoredWalletState()?.chainType);
64718
64982
  const isMobileView = useIsMobileViewport();
64719
64983
  const [resolvedTheme, setResolvedTheme] = (0, import_react29.useState)(
64720
64984
  theme === "auto" ? "dark" : theme
@@ -64747,6 +65011,15 @@ function CheckoutModal({
64747
65011
  publishableKey,
64748
65012
  enabled: open
64749
65013
  });
65014
+ const showTransferCrypto = enableTransferCrypto ?? projectConfig?.transfer_crypto?.enabled ?? true;
65015
+ const showConnectWallet = enableConnectWallet ?? projectConfig?.connect_wallet?.enabled ?? true;
65016
+ (0, import_react29.useEffect)(() => {
65017
+ if (view === "transfer" && !showTransferCrypto) {
65018
+ setView("main");
65019
+ } else if (view === "wallet_connect" && !showConnectWallet) {
65020
+ setView("main");
65021
+ }
65022
+ }, [showConnectWallet, showTransferCrypto, view]);
64750
65023
  const prevStatusRef = (0, import_react29.useRef)(null);
64751
65024
  (0, import_react29.useEffect)(() => {
64752
65025
  if (!paymentIntent) return;
@@ -64837,7 +65110,7 @@ function CheckoutModal({
64837
65110
  const handleBrowserWalletClick = (0, import_react29.useCallback)(
64838
65111
  (walletInfo) => {
64839
65112
  const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
64840
- setStoredWalletChainType(walletChainType);
65113
+ setStoredWalletState(walletInfo.type);
64841
65114
  setBrowserWalletChainType(walletChainType);
64842
65115
  const matchingDepositWallet = wallets.find(
64843
65116
  (w) => w.chain_type === walletChainType
@@ -64864,7 +65137,7 @@ function CheckoutModal({
64864
65137
  const handleWalletConnected = (0, import_react29.useCallback)(
64865
65138
  (walletInfo) => {
64866
65139
  const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
64867
- setStoredWalletChainType(walletChainType);
65140
+ setStoredWalletState(walletInfo.type);
64868
65141
  setBrowserWalletChainType(walletChainType);
64869
65142
  const matchingDepositWallet = wallets.find(
64870
65143
  (w) => w.chain_type === walletChainType
@@ -64888,7 +65161,7 @@ function CheckoutModal({
64888
65161
  );
64889
65162
  const handleWalletDisconnect = (0, import_react29.useCallback)(() => {
64890
65163
  setUserDisconnectedWallet(true);
64891
- clearStoredWalletChainType();
65164
+ clearStoredWalletState();
64892
65165
  setBrowserWalletChainType(void 0);
64893
65166
  setBrowserWalletInfo(null);
64894
65167
  setBrowserWalletModalOpen(false);
@@ -65123,7 +65396,7 @@ function CheckoutModal({
65123
65396
  ] }) : paymentIntent ? /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "uf-space-y-3", children: [
65124
65397
  progressSection,
65125
65398
  (paymentIntent.status === "requires_payment" || paymentIntent.status === "processing") && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_jsx_runtime75.Fragment, { children: [
65126
- /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
65399
+ showTransferCrypto && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
65127
65400
  TransferCryptoButton,
65128
65401
  {
65129
65402
  onClick: () => setView("transfer"),
@@ -65132,7 +65405,7 @@ function CheckoutModal({
65132
65405
  featuredTokens: projectConfig?.transfer_crypto.networks
65133
65406
  }
65134
65407
  ),
65135
- enableConnectWallet && !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
65408
+ showConnectWallet && !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
65136
65409
  BrowserWalletButton,
65137
65410
  {
65138
65411
  onClick: handleBrowserWalletClick,
@@ -65273,14 +65546,18 @@ function CheckoutModal({
65273
65546
  onWalletDisconnect: handleWalletDisconnect,
65274
65547
  onWalletConnected: (info, dw) => {
65275
65548
  setBrowserWalletInfo({ ...info, depositWallet: dw });
65276
- setStoredWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
65549
+ setStoredWalletState(info.type);
65277
65550
  setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
65278
65551
  },
65279
65552
  onNewDeposit: () => setView("main"),
65280
65553
  onDone: () => setView("main"),
65281
65554
  paymentIntentStatus: paymentIntent.status,
65282
65555
  onBack: handleBack,
65283
- onClose: handleClose
65556
+ onClose: handleClose,
65557
+ defaultSourceChainType,
65558
+ defaultSourceChainId,
65559
+ defaultSourceTokenAddress,
65560
+ defaultSourceSymbol
65284
65561
  }
65285
65562
  ),
65286
65563
  poweredByFooter
@@ -67243,6 +67520,7 @@ function UnifoldProvider2({
67243
67520
  onOpenChange: closeCheckout,
67244
67521
  clientSecret: checkoutConfig.clientSecret,
67245
67522
  publishableKey,
67523
+ enableTransferCrypto: config?.enableTransferCrypto,
67246
67524
  enableConnectWallet: config?.enableConnectWallet,
67247
67525
  defaultSourceChainType: checkoutConfig.defaultSourceChainType,
67248
67526
  defaultSourceChainId: checkoutConfig.defaultSourceChainId,
@@ -67299,6 +67577,7 @@ function UnifoldProvider2({
67299
67577
  hideDepositTracker: config?.hideDepositTracker,
67300
67578
  showBalanceHeader: config?.showBalanceHeader,
67301
67579
  transferInputVariant: config?.transferInputVariant,
67580
+ enableTransferCrypto: config?.enableTransferCrypto,
67302
67581
  enableConnectWallet: config?.enableConnectWallet,
67303
67582
  enablePayWithExchange: config?.enablePayWithExchange,
67304
67583
  enableFiatOnramp: config?.enableFiatOnramp,