@unifold/ui-web 0.1.62 → 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 +428 -162
  2. package/dist/index.mjs +428 -162
  3. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -43130,6 +43130,42 @@ var getDefaultConfig = () => {
43130
43130
  };
43131
43131
  };
43132
43132
  var twMerge = /* @__PURE__ */ createTailwindMerge(getDefaultConfig);
43133
+ function formatStablecoinAmount(baseUnits, decimals) {
43134
+ const raw = Number(baseUnits) / 10 ** decimals;
43135
+ const floored = Math.floor(raw * 100) / 100;
43136
+ const ceiled = raw > floored ? floored + 0.01 : raw;
43137
+ return ceiled.toFixed(2);
43138
+ }
43139
+ function generateKSUID() {
43140
+ const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
43141
+ const KSUID_EPOCH = 14e8;
43142
+ const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
43143
+ const payload = new Uint8Array(20);
43144
+ payload[0] = timestampSeconds >>> 24 & 255;
43145
+ payload[1] = timestampSeconds >>> 16 & 255;
43146
+ payload[2] = timestampSeconds >>> 8 & 255;
43147
+ payload[3] = timestampSeconds & 255;
43148
+ if (typeof crypto !== "undefined" && crypto.getRandomValues) {
43149
+ crypto.getRandomValues(payload.subarray(4));
43150
+ } else {
43151
+ for (let i = 4; i < 20; i++) {
43152
+ payload[i] = Math.floor(Math.random() * 256);
43153
+ }
43154
+ }
43155
+ let value = 0n;
43156
+ for (const byte of payload) {
43157
+ value = value << 8n | BigInt(byte);
43158
+ }
43159
+ let encoded = "";
43160
+ while (value > 0n) {
43161
+ encoded = BASE62[Number(value % 62n)] + encoded;
43162
+ value = value / 62n;
43163
+ }
43164
+ return encoded.padStart(27, "0");
43165
+ }
43166
+ function generatePrefixedKSUID(prefix) {
43167
+ return `${prefix}_${generateKSUID()}`;
43168
+ }
43133
43169
  var API_BASE_URL = (() => {
43134
43170
  try {
43135
43171
  return process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.unifold.io";
@@ -43432,9 +43468,7 @@ function getOnrampSessionStartUrl(request, publishableKey) {
43432
43468
  if (request.subdivision_code) {
43433
43469
  params.append("subdivision_code", request.subdivision_code);
43434
43470
  }
43435
- if (request.external_id) {
43436
- params.append("external_id", request.external_id);
43437
- }
43471
+ params.append("external_id", request.external_id ?? generatePrefixedKSUID("ors"));
43438
43472
  if (request.email) {
43439
43473
  params.append("email", request.email);
43440
43474
  }
@@ -43649,9 +43683,7 @@ function getExchangeSessionStartUrl(request, publishableKey) {
43649
43683
  if (request.source_amount) {
43650
43684
  params.append("source_amount", request.source_amount);
43651
43685
  }
43652
- if (request.external_id) {
43653
- params.append("external_id", request.external_id);
43654
- }
43686
+ params.append("external_id", request.external_id ?? generatePrefixedKSUID("exc"));
43655
43687
  return `${API_BASE_URL}/v1/public/onramps/exchanges/sessions/start?${params.toString()}`;
43656
43688
  }
43657
43689
  async function getIntegrationExchanges(publishableKey) {
@@ -43985,40 +44017,6 @@ async function getCashAppSessionStatus(externalId, publishableKey) {
43985
44017
  }
43986
44018
  return response.json();
43987
44019
  }
43988
- function formatStablecoinAmount(baseUnits, decimals) {
43989
- const raw = Number(baseUnits) / 10 ** decimals;
43990
- const floored = Math.floor(raw * 100) / 100;
43991
- const ceiled = raw > floored ? floored + 0.01 : raw;
43992
- return ceiled.toFixed(2);
43993
- }
43994
- function generatePrefixedKSUID(prefix) {
43995
- const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
43996
- const KSUID_EPOCH = 14e8;
43997
- const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
43998
- const payload = new Uint8Array(20);
43999
- payload[0] = timestampSeconds >>> 24 & 255;
44000
- payload[1] = timestampSeconds >>> 16 & 255;
44001
- payload[2] = timestampSeconds >>> 8 & 255;
44002
- payload[3] = timestampSeconds & 255;
44003
- if (typeof crypto !== "undefined" && crypto.getRandomValues) {
44004
- crypto.getRandomValues(payload.subarray(4));
44005
- } else {
44006
- for (let i = 4; i < 20; i++) {
44007
- payload[i] = Math.floor(Math.random() * 256);
44008
- }
44009
- }
44010
- let value = 0n;
44011
- for (const byte of payload) {
44012
- value = value << 8n | BigInt(byte);
44013
- }
44014
- let encoded = "";
44015
- while (value > 0n) {
44016
- encoded = BASE62[Number(value % 62n)] + encoded;
44017
- value = value / 62n;
44018
- }
44019
- encoded = encoded.padStart(27, "0");
44020
- return `${prefix}_${encoded}`;
44021
- }
44022
44020
  var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
44023
44021
  DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
44024
44022
  return DepositEventType2;
@@ -50118,8 +50116,32 @@ var Separator = SelectSeparator;
50118
50116
  function cn(...inputs) {
50119
50117
  return twMerge(clsx(inputs));
50120
50118
  }
50121
- var WALLET_CHAIN_TYPE_STORAGE_KEY = "unifold_last_wallet_type";
50119
+ var WALLET_STATE_STORAGE_KEY = "unifold_wallet_state";
50120
+ var LEGACY_WALLET_KEYS = [
50121
+ "unifold_last_wallet_type",
50122
+ "unifold_last_connected_wallet"
50123
+ ];
50122
50124
  var WALLET_USER_DISCONNECTED_KEY = "unifold_wallet_user_disconnected";
50125
+ var SOLANA_WALLET_TYPES = /* @__PURE__ */ new Set([
50126
+ "phantom-solana",
50127
+ "solflare",
50128
+ "backpack",
50129
+ "glow"
50130
+ ]);
50131
+ var ETHEREUM_WALLET_TYPES = /* @__PURE__ */ new Set([
50132
+ "metamask",
50133
+ "phantom-ethereum",
50134
+ "coinbase",
50135
+ "trust",
50136
+ "rainbow",
50137
+ "rabby",
50138
+ "okx"
50139
+ ]);
50140
+ function walletTypeToChain(t12) {
50141
+ if (SOLANA_WALLET_TYPES.has(t12)) return "solana";
50142
+ if (ETHEREUM_WALLET_TYPES.has(t12)) return "ethereum";
50143
+ return void 0;
50144
+ }
50123
50145
  function getUserDisconnectedWallet() {
50124
50146
  if (typeof window === "undefined") return false;
50125
50147
  try {
@@ -50139,26 +50161,35 @@ function setUserDisconnectedWallet(disconnected) {
50139
50161
  } catch {
50140
50162
  }
50141
50163
  }
50142
- function getStoredWalletChainType() {
50164
+ function getStoredWalletState() {
50143
50165
  if (typeof window === "undefined") return void 0;
50144
50166
  try {
50145
- const stored = localStorage.getItem(WALLET_CHAIN_TYPE_STORAGE_KEY);
50146
- if (stored === "ethereum" || stored === "solana") return stored;
50167
+ const raw = localStorage.getItem(WALLET_STATE_STORAGE_KEY);
50168
+ if (!raw) return void 0;
50169
+ const chainType = walletTypeToChain(raw);
50170
+ if (!chainType) {
50171
+ localStorage.removeItem(WALLET_STATE_STORAGE_KEY);
50172
+ return void 0;
50173
+ }
50174
+ return { walletType: raw, chainType };
50147
50175
  } catch {
50176
+ return void 0;
50148
50177
  }
50149
- return void 0;
50150
50178
  }
50151
- function setStoredWalletChainType(chainType) {
50179
+ function setStoredWalletState(walletType) {
50152
50180
  if (typeof window === "undefined") return;
50181
+ if (!walletTypeToChain(walletType)) return;
50153
50182
  try {
50154
- localStorage.setItem(WALLET_CHAIN_TYPE_STORAGE_KEY, chainType);
50183
+ localStorage.setItem(WALLET_STATE_STORAGE_KEY, walletType);
50184
+ for (const key of LEGACY_WALLET_KEYS) localStorage.removeItem(key);
50155
50185
  } catch {
50156
50186
  }
50157
50187
  }
50158
- function clearStoredWalletChainType() {
50188
+ function clearStoredWalletState() {
50159
50189
  if (typeof window === "undefined") return;
50160
50190
  try {
50161
- localStorage.removeItem(WALLET_CHAIN_TYPE_STORAGE_KEY);
50191
+ localStorage.removeItem(WALLET_STATE_STORAGE_KEY);
50192
+ for (const key of LEGACY_WALLET_KEYS) localStorage.removeItem(key);
50162
50193
  } catch {
50163
50194
  }
50164
50195
  }
@@ -50721,6 +50752,60 @@ function useDepositAddress(params) {
50721
50752
  // 1s, 2s, 4s (max 10s)
50722
50753
  });
50723
50754
  }
50755
+ var normalize = (value) => value?.toLowerCase();
50756
+ function sourceTokenMatchesDefaultSource(token, defaultSource) {
50757
+ if (!token || !defaultSource.defaultSourceChainType || !defaultSource.defaultSourceChainId) {
50758
+ return false;
50759
+ }
50760
+ if (token.chain_type !== defaultSource.defaultSourceChainType || token.chain_id !== defaultSource.defaultSourceChainId) {
50761
+ return false;
50762
+ }
50763
+ if (defaultSource.defaultSourceTokenAddress && normalize(token.token_address) === normalize(defaultSource.defaultSourceTokenAddress)) {
50764
+ return true;
50765
+ }
50766
+ if (defaultSource.defaultSourceTokenAddress) {
50767
+ return false;
50768
+ }
50769
+ return !!defaultSource.defaultSourceSymbol && normalize(token.symbol) === normalize(defaultSource.defaultSourceSymbol);
50770
+ }
50771
+ function isDefaultSourceBalance(balance, defaultSource) {
50772
+ return isBalanceEligible(balance) && sourceTokenMatchesDefaultSource(getTokenFromBalance(balance), defaultSource);
50773
+ }
50774
+ function compareBalancesWithDefaultSource(a, b, defaultSource) {
50775
+ const aDefault = isDefaultSourceBalance(a, defaultSource);
50776
+ const bDefault = isDefaultSourceBalance(b, defaultSource);
50777
+ if (aDefault && !bDefault) return -1;
50778
+ if (!aDefault && bDefault) return 1;
50779
+ const aEligible = isBalanceEligible(a);
50780
+ const bEligible = isBalanceEligible(b);
50781
+ if (aEligible && !bEligible) return -1;
50782
+ if (!aEligible && bEligible) return 1;
50783
+ return 0;
50784
+ }
50785
+ function resolveDefaultSourceSymbol(supportedTokens, defaultSource) {
50786
+ if (!supportedTokens?.length || !defaultSource.defaultSourceChainType || !defaultSource.defaultSourceChainId) {
50787
+ return null;
50788
+ }
50789
+ if (defaultSource.defaultSourceTokenAddress) {
50790
+ for (const token of supportedTokens) {
50791
+ const matchingChain = token.chains.find(
50792
+ (chain) => chain.chain_type === defaultSource.defaultSourceChainType && chain.chain_id === defaultSource.defaultSourceChainId && normalize(chain.token_address) === normalize(defaultSource.defaultSourceTokenAddress)
50793
+ );
50794
+ if (matchingChain) return token.symbol;
50795
+ }
50796
+ }
50797
+ if (!defaultSource.defaultSourceSymbol) return null;
50798
+ for (const token of supportedTokens) {
50799
+ if (normalize(token.symbol) !== normalize(defaultSource.defaultSourceSymbol)) {
50800
+ continue;
50801
+ }
50802
+ const matchingChain = token.chains.find(
50803
+ (chain) => chain.chain_type === defaultSource.defaultSourceChainType && chain.chain_id === defaultSource.defaultSourceChainId
50804
+ );
50805
+ if (matchingChain) return token.symbol;
50806
+ }
50807
+ return null;
50808
+ }
50724
50809
  function formatUsdFromBalancePercent(maxUsdAmount, percent) {
50725
50810
  if (maxUsdAmount <= 0 || percent < 0) return "";
50726
50811
  const raw = maxUsdAmount * percent / 100;
@@ -55234,70 +55319,106 @@ function identifyEthWallet(provider, hint) {
55234
55319
  }
55235
55320
  return { type: "metamask", name: "Wallet", icon: "metamask" };
55236
55321
  }
55322
+ var EIP6963_ID_TO_WALLET_TYPE = {
55323
+ metamask: "metamask",
55324
+ phantom: "phantom-ethereum",
55325
+ coinbase: "coinbase",
55326
+ trust: "trust",
55327
+ rainbow: "rainbow",
55328
+ rabby: "rabby",
55329
+ okx: "okx"
55330
+ };
55331
+ function inferEthWalletType(provider, walletId) {
55332
+ if (EIP6963_ID_TO_WALLET_TYPE[walletId]) return EIP6963_ID_TO_WALLET_TYPE[walletId];
55333
+ const any = provider;
55334
+ if (provider.isPhantom) return "phantom-ethereum";
55335
+ if (any.isCoinbaseWallet) return "coinbase";
55336
+ if (any.isRabby) return "rabby";
55337
+ if (any.isTrust) return "trust";
55338
+ if (any.isRainbow) return "rainbow";
55339
+ if (any.isOkxWallet) return "okx";
55340
+ if (provider.isMetaMask && !provider.isPhantom) return "metamask";
55341
+ return null;
55342
+ }
55343
+ function solanaCandidate(provider, type, name, icon) {
55344
+ return {
55345
+ walletType: type,
55346
+ detect: async () => {
55347
+ if (!provider) return null;
55348
+ if (provider.isConnected && provider.publicKey) {
55349
+ return { type, name, address: provider.publicKey.toString(), icon };
55350
+ }
55351
+ try {
55352
+ const resp = await provider.connect({ onlyIfTrusted: true });
55353
+ if (resp.publicKey) {
55354
+ return { type, name, address: resp.publicKey.toString(), icon };
55355
+ }
55356
+ } catch {
55357
+ }
55358
+ return null;
55359
+ }
55360
+ };
55361
+ }
55362
+ function ethereumCandidate(provider, walletId) {
55363
+ return {
55364
+ walletType: inferEthWalletType(provider, walletId),
55365
+ detect: async () => {
55366
+ try {
55367
+ const accounts = await provider.request({ method: "eth_accounts" });
55368
+ if (!accounts?.length) return null;
55369
+ const resolved = identifyEthWallet(provider, walletId);
55370
+ return { ...resolved, address: accounts[0] };
55371
+ } catch {
55372
+ return null;
55373
+ }
55374
+ }
55375
+ };
55376
+ }
55377
+ function buildCandidates(win, chainType) {
55378
+ const candidates = [];
55379
+ if (!chainType || chainType === "solana") {
55380
+ candidates.push(
55381
+ solanaCandidate(win.phantom?.solana, "phantom-solana", "Phantom", "phantom"),
55382
+ solanaCandidate(win.solflare, "solflare", "Solflare", "solflare"),
55383
+ solanaCandidate(win.backpack, "backpack", "Backpack", "backpack"),
55384
+ solanaCandidate(win.glow, "glow", "Glow", "glow")
55385
+ );
55386
+ }
55387
+ if (!chainType || chainType === "ethereum") {
55388
+ const seen = /* @__PURE__ */ new Set();
55389
+ const addEth = (provider, walletId) => {
55390
+ if (!provider || seen.has(provider)) return;
55391
+ seen.add(provider);
55392
+ candidates.push(ethereumCandidate(provider, walletId));
55393
+ };
55394
+ for (const { provider, walletId } of getEip6963Providers()) {
55395
+ addEth(
55396
+ provider,
55397
+ walletId === "unknown" ? "default" : walletId
55398
+ );
55399
+ }
55400
+ addEth(win.phantom?.ethereum, "phantom");
55401
+ addEth(win.coinbaseWalletExtension, "coinbase");
55402
+ addEth(win.okxwallet, "okx");
55403
+ addEth(win.trustwallet?.ethereum, "trust");
55404
+ addEth(win.ethereum, "default");
55405
+ }
55406
+ return candidates;
55407
+ }
55237
55408
  async function detectConnectedBrowserWallet(chainType) {
55238
55409
  if (typeof window === "undefined") return null;
55239
55410
  if (getUserDisconnectedWallet()) return null;
55240
55411
  try {
55241
55412
  const win = window;
55242
- if (!chainType || chainType === "solana") {
55243
- const trySilentSolana = async (provider, type, name, icon) => {
55244
- if (!provider) return null;
55245
- if (provider.isConnected && provider.publicKey) {
55246
- return { type, name, address: provider.publicKey.toString(), icon };
55247
- }
55248
- try {
55249
- const resp = await provider.connect({ onlyIfTrusted: true });
55250
- if (resp.publicKey) {
55251
- return { type, name, address: resp.publicKey.toString(), icon };
55252
- }
55253
- } catch {
55254
- }
55255
- return null;
55256
- };
55257
- const solanaCandidates = [
55258
- [win.phantom?.solana, "phantom-solana", "Phantom", "phantom"],
55259
- [win.solflare, "solflare", "Solflare", "solflare"],
55260
- [win.backpack, "backpack", "Backpack", "backpack"],
55261
- [win.glow, "glow", "Glow", "glow"]
55262
- ];
55263
- for (const [provider, type, name, icon] of solanaCandidates) {
55264
- const found = await trySilentSolana(provider, type, name, icon);
55265
- if (found) return found;
55266
- }
55267
- }
55268
- if (!chainType || chainType === "ethereum") {
55269
- const allProviders = [];
55270
- const eip6963 = getEip6963Providers();
55271
- for (const { provider, walletId } of eip6963) {
55272
- allProviders.push({
55273
- provider,
55274
- walletId: walletId === "unknown" ? "default" : walletId
55275
- });
55276
- }
55277
- if (allProviders.length === 0) {
55278
- if (win.phantom?.ethereum) {
55279
- allProviders.push({ provider: win.phantom.ethereum, walletId: "phantom" });
55280
- }
55281
- if (win.okxwallet) {
55282
- allProviders.push({ provider: win.okxwallet, walletId: "okx" });
55283
- }
55284
- if (win.coinbaseWalletExtension) {
55285
- allProviders.push({ provider: win.coinbaseWalletExtension, walletId: "coinbase" });
55286
- }
55287
- if (win.ethereum && !allProviders.some((p) => p.provider === win.ethereum)) {
55288
- allProviders.push({ provider: win.ethereum, walletId: "default" });
55289
- }
55290
- }
55291
- for (const { provider, walletId } of allProviders) {
55292
- if (!provider) continue;
55293
- try {
55294
- const accounts = await provider.request({ method: "eth_accounts" });
55295
- if (!accounts || accounts.length === 0) continue;
55296
- const resolved = identifyEthWallet(provider, walletId);
55297
- return { ...resolved, address: accounts[0] };
55298
- } catch {
55299
- }
55300
- }
55413
+ const candidates = buildCandidates(win, chainType);
55414
+ const preferred = getStoredWalletState();
55415
+ if (preferred && (!chainType || preferred.chainType === chainType)) {
55416
+ const idx = candidates.findIndex((c) => c.walletType === preferred.walletType);
55417
+ if (idx > 0) candidates.unshift(...candidates.splice(idx, 1));
55418
+ }
55419
+ for (const c of candidates) {
55420
+ const found = await c.detect();
55421
+ if (found) return found;
55301
55422
  }
55302
55423
  } catch (error) {
55303
55424
  console.error("[detectConnectedBrowserWallet] detection error:", error);
@@ -57443,6 +57564,7 @@ function BrowserWalletButton({
57443
57564
  if (solanaProvider?.isPhantom) {
57444
57565
  const { publicKey } = await solanaProvider.connect();
57445
57566
  setUserDisconnectedWallet(false);
57567
+ setStoredWalletState("phantom-solana");
57446
57568
  setWallet({
57447
57569
  type: "phantom-solana",
57448
57570
  name: "Phantom",
@@ -57462,8 +57584,10 @@ function BrowserWalletButton({
57462
57584
  if (accounts && accounts.length > 0) {
57463
57585
  setUserDisconnectedWallet(false);
57464
57586
  const isPhantom = ethProvider.isPhantom;
57587
+ const walletType = isPhantom ? "phantom-ethereum" : "metamask";
57588
+ setStoredWalletState(walletType);
57465
57589
  setWallet({
57466
- type: isPhantom ? "phantom-ethereum" : "metamask",
57590
+ type: walletType,
57467
57591
  name: isPhantom ? "Phantom" : "MetaMask",
57468
57592
  address: accounts[0],
57469
57593
  icon: isPhantom ? "phantom" : "metamask"
@@ -57773,7 +57897,11 @@ function CoinbaseConnect({
57773
57897
  onDisconnect,
57774
57898
  skipToHoldings,
57775
57899
  canGoBack = true,
57776
- onExecutionsChange
57900
+ onExecutionsChange,
57901
+ defaultSourceChainType,
57902
+ defaultSourceChainId,
57903
+ defaultSourceTokenAddress,
57904
+ defaultSourceSymbol
57777
57905
  }) {
57778
57906
  const { colors: colors2, fonts, components } = useTheme();
57779
57907
  const { projectConfig } = useProjectConfig({ publishableKey });
@@ -57838,6 +57966,21 @@ function CoinbaseConnect({
57838
57966
  params: defaultTokenParams,
57839
57967
  publishableKey
57840
57968
  });
57969
+ const defaultSourceCurrency = (0, import_react18.useMemo)(
57970
+ () => resolveDefaultSourceSymbol(supportedTokensData?.data, {
57971
+ defaultSourceChainType,
57972
+ defaultSourceChainId,
57973
+ defaultSourceTokenAddress,
57974
+ defaultSourceSymbol
57975
+ })?.toLowerCase() ?? null,
57976
+ [
57977
+ supportedTokensData,
57978
+ defaultSourceChainType,
57979
+ defaultSourceChainId,
57980
+ defaultSourceTokenAddress,
57981
+ defaultSourceSymbol
57982
+ ]
57983
+ );
57841
57984
  const sortedHoldings = (0, import_react18.useMemo)(() => {
57842
57985
  const supported = [];
57843
57986
  const unsupported = [];
@@ -57847,13 +57990,42 @@ function CoinbaseConnect({
57847
57990
  if (isSupported) supported.push(account);
57848
57991
  else unsupported.push(account);
57849
57992
  });
57993
+ if (defaultSourceCurrency) {
57994
+ const defaultIndex = supported.findIndex(
57995
+ (account) => account.currency.toLowerCase() === defaultSourceCurrency
57996
+ );
57997
+ if (defaultIndex > 0) {
57998
+ const [defaultHolding] = supported.splice(defaultIndex, 1);
57999
+ supported.unshift(defaultHolding);
58000
+ }
58001
+ }
57850
58002
  return [...supported, ...unsupported];
57851
- }, [holdings, supportedSymbols, exchangeSupportedCurrencies]);
58003
+ }, [
58004
+ holdings,
58005
+ supportedSymbols,
58006
+ exchangeSupportedCurrencies,
58007
+ defaultSourceCurrency
58008
+ ]);
57852
58009
  const selectedHoldingIsSupported = (0, import_react18.useMemo)(() => {
57853
58010
  if (!selectedHolding) return false;
57854
58011
  const currencyLower = selectedHolding.currency.toLowerCase();
57855
58012
  return (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
57856
58013
  }, [selectedHolding, supportedSymbols, exchangeSupportedCurrencies]);
58014
+ (0, import_react18.useEffect)(() => {
58015
+ if (!defaultSourceCurrency || selectedHolding) return;
58016
+ const defaultHolding = sortedHoldings.find((account) => {
58017
+ const currencyLower = account.currency.toLowerCase();
58018
+ return currencyLower === defaultSourceCurrency && (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
58019
+ });
58020
+ if (!defaultHolding) return;
58021
+ setSelectedHolding(defaultHolding);
58022
+ }, [
58023
+ defaultSourceCurrency,
58024
+ selectedHolding,
58025
+ sortedHoldings,
58026
+ supportedSymbols,
58027
+ exchangeSupportedCurrencies
58028
+ ]);
57857
58029
  const exchangeName = selectedExchange?.service_provider_display_name || "Exchange";
57858
58030
  const {
57859
58031
  executions: depositExecutions,
@@ -63019,6 +63191,19 @@ var WALLET_DEFINITIONS = [
63019
63191
  { id: "backpack", name: "Backpack", networks: ["solana"], installUrl: "https://backpack.app/" },
63020
63192
  { id: "glow", name: "Glow", networks: ["solana"], installUrl: "https://glow.app/" }
63021
63193
  ];
63194
+ function normalizeTokenAddress(address) {
63195
+ const normalized = (address ?? "").toLowerCase();
63196
+ if (normalized === "" || normalized === "native" || normalized === "0x0000000000000000000000000000000000000000") {
63197
+ return "native";
63198
+ }
63199
+ return normalized;
63200
+ }
63201
+ function balancesRepresentSameToken(a, b) {
63202
+ const tokenA = getTokenFromBalance(a);
63203
+ const tokenB = getTokenFromBalance(b);
63204
+ if (!tokenA || !tokenB) return false;
63205
+ return tokenA.chain_type === tokenB.chain_type && tokenA.chain_id === tokenB.chain_id && normalizeTokenAddress(tokenA.token_address) === normalizeTokenAddress(tokenB.token_address);
63206
+ }
63022
63207
  function getSolanaProviders() {
63023
63208
  if (typeof window === "undefined") return {};
63024
63209
  const win = window;
@@ -63161,6 +63346,10 @@ function WalletConnect({
63161
63346
  checkoutRemainingBaseUnits,
63162
63347
  stablecoinParity = false,
63163
63348
  productType,
63349
+ defaultSourceChainType,
63350
+ defaultSourceChainId,
63351
+ defaultSourceTokenAddress,
63352
+ defaultSourceSymbol,
63164
63353
  onBack: parentOnBack,
63165
63354
  onClose,
63166
63355
  canGoBack = true,
@@ -63321,6 +63510,7 @@ function WalletConnect({
63321
63510
  metamask: "metamask"
63322
63511
  };
63323
63512
  const walletType = walletIdToType[wallet.id] || "metamask";
63513
+ setStoredWalletState(walletType);
63324
63514
  connectedInfo = { type: walletType, name: wallet.name, address: accounts[0], icon: wallet.id };
63325
63515
  } else {
63326
63516
  const solProviders = getSolanaProviders();
@@ -63349,6 +63539,7 @@ function WalletConnect({
63349
63539
  const response = await provider.connect();
63350
63540
  setUserDisconnectedWallet(false);
63351
63541
  const walletType = wallet.id === "solflare" ? "solflare" : wallet.id === "backpack" ? "backpack" : wallet.id === "glow" ? "glow" : "phantom-solana";
63542
+ setStoredWalletState(walletType);
63352
63543
  connectedInfo = { type: walletType, name: wallet.name, address: response.publicKey.toString(), icon: wallet.id };
63353
63544
  }
63354
63545
  const walletChainType = network === "solana" ? "solana" : "ethereum";
@@ -63463,18 +63654,33 @@ function WalletConnect({
63463
63654
  getAddressBalances(activeWalletInfo.address, sct, publishableKey).then((response) => {
63464
63655
  if (cancelled) return;
63465
63656
  const nonZero = response.balances.filter((b) => b.amount !== "0");
63466
- const sorted = [...nonZero].sort((a, b) => {
63467
- const ae = isBalanceEligible(a);
63468
- const be = isBalanceEligible(b);
63469
- if (ae && !be) return -1;
63470
- if (!ae && be) return 1;
63471
- return 0;
63472
- });
63657
+ const defaultSource = {
63658
+ defaultSourceChainType,
63659
+ defaultSourceChainId,
63660
+ defaultSourceTokenAddress,
63661
+ defaultSourceSymbol
63662
+ };
63663
+ const sorted = [...nonZero].sort(
63664
+ (a, b) => compareBalancesWithDefaultSource(a, b, defaultSource)
63665
+ );
63473
63666
  setBalances(sorted);
63474
63667
  const totalUsd = nonZero.reduce((sum, b) => b.amount_usd ? sum + parseFloat(b.amount_usd) : sum, 0);
63475
63668
  if (totalUsd > 0) setTotalBalanceUsd(totalUsd.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 }));
63476
63669
  const eligible = sorted.filter(isBalanceEligible);
63477
- if (eligible.length === 1) setSelectedBalance(eligible[0]);
63670
+ const defaultBalance = sorted.find(
63671
+ (balance) => isDefaultSourceBalance(balance, defaultSource)
63672
+ );
63673
+ setSelectedBalance((current) => {
63674
+ if (current) {
63675
+ const currentInNewBalances = sorted.find(
63676
+ (balance) => balancesRepresentSameToken(balance, current)
63677
+ );
63678
+ if (currentInNewBalances) return currentInNewBalances;
63679
+ }
63680
+ if (defaultBalance) return defaultBalance;
63681
+ if (eligible.length === 1) return eligible[0];
63682
+ return null;
63683
+ });
63478
63684
  }).catch((err) => {
63479
63685
  if (!cancelled) {
63480
63686
  console.error("[WalletConnect] Error fetching balances:", err);
@@ -63486,7 +63692,15 @@ function WalletConnect({
63486
63692
  return () => {
63487
63693
  cancelled = true;
63488
63694
  };
63489
- }, [activeWalletInfo?.address, activeDepositWallet?.chain_type, publishableKey]);
63695
+ }, [
63696
+ activeWalletInfo?.address,
63697
+ activeDepositWallet?.chain_type,
63698
+ publishableKey,
63699
+ defaultSourceChainType,
63700
+ defaultSourceChainId,
63701
+ defaultSourceTokenAddress,
63702
+ defaultSourceSymbol
63703
+ ]);
63490
63704
  const usdToTokenRate = React302.useMemo(() => {
63491
63705
  if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
63492
63706
  const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
@@ -63841,16 +64055,17 @@ function DepositModal({
63841
64055
  defaultSourceChainId,
63842
64056
  defaultSourceTokenAddress,
63843
64057
  defaultSourceSymbol,
63844
- hideDepositTracker = false,
64058
+ hideDepositTracker,
63845
64059
  showBalanceHeader = false,
63846
64060
  transferInputVariant = "double_input",
63847
64061
  depositConfirmationMode = "auto_ui",
63848
- enableConnectWallet = false,
64062
+ enableTransferCrypto,
64063
+ enableConnectWallet,
63849
64064
  browserWalletAmountQuickSelect = "percentage",
63850
64065
  enablePayWithExchange,
63851
64066
  enableFiatOnramp,
63852
- enableConnectExchange = false,
63853
- enableCashApp = false,
64067
+ enableConnectExchange,
64068
+ enableCashApp,
63854
64069
  hideDepositFlowInfo = false,
63855
64070
  hideDisplayDescription = false,
63856
64071
  onDepositSuccess,
@@ -63868,12 +64083,13 @@ function DepositModal({
63868
64083
  const { colors: colors2, fonts, components } = useTheme();
63869
64084
  const effectiveInitialScreen = (0, import_react3.useMemo)(() => {
63870
64085
  const s = initialScreen ?? "main";
63871
- if (s === "tracker" && hideDepositTracker) return "main";
63872
- if (s === "cashapp" && !enableCashApp) return "main";
64086
+ if (s === "tracker" && hideDepositTracker === true) return "main";
64087
+ if (s === "cashapp" && enableCashApp === false) return "main";
63873
64088
  if (s === "card" && enableFiatOnramp === false) return "main";
63874
64089
  if (s === "pay_with_exchange") return enablePayWithExchange === false ? "main" : "exchange";
63875
- if (s === "exchange_connect") return enableConnectExchange ? "coinbase_connect" : "main";
63876
- if (s === "wallet_connect") return enableConnectWallet ? "wallet_connect" : "main";
64090
+ if (s === "exchange_connect")
64091
+ return enableConnectExchange === false ? "main" : "coinbase_connect";
64092
+ if (s === "wallet_connect") return enableConnectWallet === false ? "main" : "wallet_connect";
63877
64093
  return s;
63878
64094
  }, [
63879
64095
  initialScreen,
@@ -63902,26 +64118,37 @@ function DepositModal({
63902
64118
  const [browserWalletModalOpen, setBrowserWalletModalOpen] = (0, import_react3.useState)(false);
63903
64119
  const [browserWalletInfo, setBrowserWalletInfo] = (0, import_react3.useState)(null);
63904
64120
  const [walletSelectionModalOpen, setWalletSelectionModalOpen] = (0, import_react3.useState)(false);
63905
- const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react3.useState)(() => getStoredWalletChainType());
64121
+ const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react3.useState)(() => getStoredWalletState()?.chainType);
63906
64122
  const [quotesCount, setQuotesCount] = (0, import_react3.useState)(0);
63907
64123
  const [allExecutions, setAllExecutions] = (0, import_react3.useState)([]);
63908
64124
  const [selectedExecution, setSelectedExecution] = (0, import_react3.useState)(null);
63909
64125
  const [depositExecutions, setDepositExecutions] = (0, import_react3.useState)([]);
63910
64126
  const isMobileView = useIsMobileViewport();
64127
+ const { projectConfig } = useProjectConfig({
64128
+ publishableKey,
64129
+ enabled: open
64130
+ });
64131
+ const showTransferCrypto = enableTransferCrypto ?? projectConfig?.transfer_crypto?.enabled ?? true;
64132
+ const showConnectWallet = enableConnectWallet ?? projectConfig?.connect_wallet?.enabled ?? true;
64133
+ const showPayWithExchange = enablePayWithExchange ?? projectConfig?.pay_with_exchange?.enabled ?? true;
64134
+ const showFiatOnramp = enableFiatOnramp ?? projectConfig?.fiat_onramp?.enabled ?? true;
64135
+ const showConnectExchange = enableConnectExchange ?? projectConfig?.connect_exchange?.enabled ?? true;
64136
+ const showCashApp = enableCashApp ?? projectConfig?.cash_app?.enabled ?? true;
64137
+ const showDepositTracker = hideDepositTracker ? false : projectConfig?.deposit_tracker?.enabled ?? true;
63911
64138
  const [integrationExchanges, setIntegrationExchanges] = (0, import_react3.useState)([]);
63912
64139
  (0, import_react3.useEffect)(() => {
63913
- if (!enableConnectExchange || !open) return;
64140
+ if (!showConnectExchange || !open) return;
63914
64141
  getIntegrationExchanges(publishableKey).then((res) => setIntegrationExchanges(res.data)).catch(() => {
63915
64142
  });
63916
- }, [enableConnectExchange, open, publishableKey]);
64143
+ }, [showConnectExchange, open, publishableKey]);
63917
64144
  const [connectedExchange, setConnectedExchange] = (0, import_react3.useState)(() => {
63918
- if (!enableConnectExchange) return null;
64145
+ if (!showConnectExchange) return null;
63919
64146
  const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
63920
64147
  if (!stored) return null;
63921
64148
  return { name: "Coinbase", iconUrl: void 0, balanceUsd: null, isLoading: true };
63922
64149
  });
63923
64150
  (0, import_react3.useEffect)(() => {
63924
- if (!enableConnectExchange || !open || view !== "main") return;
64151
+ if (!showConnectExchange || !open || view !== "main") return;
63925
64152
  const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
63926
64153
  if (!stored) {
63927
64154
  setConnectedExchange(null);
@@ -63956,7 +64183,7 @@ function DepositModal({
63956
64183
  setConnectedExchange(null);
63957
64184
  }
63958
64185
  });
63959
- }, [enableConnectExchange, open, view, publishableKey]);
64186
+ }, [showConnectExchange, open, view, publishableKey]);
63960
64187
  (0, import_react3.useEffect)(() => {
63961
64188
  if (!connectedExchange || integrationExchanges.length === 0) return;
63962
64189
  const cbExchange = integrationExchanges.find(
@@ -63995,18 +64222,33 @@ function DepositModal({
63995
64222
  setResolvedTheme(theme);
63996
64223
  }
63997
64224
  }, [theme]);
63998
- const { projectConfig } = useProjectConfig({
63999
- publishableKey,
64000
- enabled: open
64001
- });
64002
- const showPayWithExchange = enablePayWithExchange ?? projectConfig?.pay_with_exchange?.enabled ?? true;
64003
- const showFiatOnramp = enableFiatOnramp ?? projectConfig?.fiat_onramp?.enabled ?? true;
64004
64225
  (0, import_react3.useEffect)(() => {
64005
64226
  if (view === "card" && !showFiatOnramp) {
64006
64227
  setView("main");
64007
64228
  setCardView("amount");
64229
+ } else if (view === "transfer" && !showTransferCrypto) {
64230
+ setView("main");
64231
+ } else if (view === "exchange" && !showPayWithExchange) {
64232
+ setView("main");
64233
+ } else if (view === "cashapp" && !showCashApp) {
64234
+ setView("main");
64235
+ } else if (view === "tracker" && !showDepositTracker) {
64236
+ setView("main");
64237
+ } else if (view === "coinbase_connect" && !showConnectExchange) {
64238
+ setView("main");
64239
+ } else if (view === "wallet_connect" && !showConnectWallet) {
64240
+ setView("main");
64008
64241
  }
64009
- }, [view, showFiatOnramp]);
64242
+ }, [
64243
+ view,
64244
+ showFiatOnramp,
64245
+ showTransferCrypto,
64246
+ showPayWithExchange,
64247
+ showCashApp,
64248
+ showDepositTracker,
64249
+ showConnectExchange,
64250
+ showConnectWallet
64251
+ ]);
64010
64252
  (0, import_react3.useEffect)(() => {
64011
64253
  if (view === "exchange" && !showPayWithExchange) {
64012
64254
  setView("main");
@@ -64096,7 +64338,7 @@ function DepositModal({
64096
64338
  depositPrerequisiteBody = standaloneNeedsDepositPrereq ? /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, { variant: "with-icons" }) : /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(import_jsx_runtime74.Fragment, { children: [
64097
64339
  /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, { variant: "with-icons" }),
64098
64340
  /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, { variant: "with-icons" }),
64099
- !hideDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, {})
64341
+ showDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, {})
64100
64342
  ] });
64101
64343
  } else if (countryError) {
64102
64344
  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: [
@@ -64128,7 +64370,7 @@ function DepositModal({
64128
64370
  const themeClass = resolvedTheme === "dark" ? "uf-dark" : "";
64129
64371
  const handleWalletDisconnect = () => {
64130
64372
  setUserDisconnectedWallet(true);
64131
- clearStoredWalletChainType();
64373
+ clearStoredWalletState();
64132
64374
  setBrowserWalletChainType(void 0);
64133
64375
  setBrowserWalletInfo(null);
64134
64376
  setBrowserWalletModalOpen(false);
@@ -64206,7 +64448,7 @@ function DepositModal({
64206
64448
  };
64207
64449
  const handleBrowserWalletClick = (walletInfo) => {
64208
64450
  const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
64209
- setStoredWalletChainType(walletChainType);
64451
+ setStoredWalletState(walletInfo.type);
64210
64452
  setBrowserWalletChainType(walletChainType);
64211
64453
  const matchingDepositWallet = wallets.find(
64212
64454
  (w) => w.chain_type === walletChainType
@@ -64237,7 +64479,7 @@ function DepositModal({
64237
64479
  };
64238
64480
  const handleWalletConnected = (walletInfo) => {
64239
64481
  const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
64240
- setStoredWalletChainType(walletChainType);
64482
+ setStoredWalletState(walletInfo.type);
64241
64483
  setBrowserWalletChainType(walletChainType);
64242
64484
  const matchingDepositWallet = wallets.find(
64243
64485
  (w) => w.chain_type === walletChainType
@@ -64304,7 +64546,7 @@ function DepositModal({
64304
64546
  ),
64305
64547
  /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
64306
64548
  /* @__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: [
64307
- /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64549
+ showTransferCrypto && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64308
64550
  TransferCryptoButton,
64309
64551
  {
64310
64552
  onClick: () => setView("transfer"),
@@ -64313,7 +64555,7 @@ function DepositModal({
64313
64555
  featuredTokens: projectConfig?.transfer_crypto.networks
64314
64556
  }
64315
64557
  ),
64316
- enableConnectWallet && !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64558
+ showConnectWallet && !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64317
64559
  BrowserWalletButton,
64318
64560
  {
64319
64561
  onClick: handleBrowserWalletClick,
@@ -64343,7 +64585,7 @@ function DepositModal({
64343
64585
  loading: exchangesLoading
64344
64586
  }
64345
64587
  ),
64346
- enableConnectExchange && connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64588
+ showConnectExchange && connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64347
64589
  ConnectExchangeButton,
64348
64590
  {
64349
64591
  onClick: () => {
@@ -64357,7 +64599,7 @@ function DepositModal({
64357
64599
  connectedExchange
64358
64600
  }
64359
64601
  ),
64360
- enableConnectExchange && !connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64602
+ showConnectExchange && !connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64361
64603
  ConnectExchangeButton,
64362
64604
  {
64363
64605
  onClick: () => {
@@ -64369,7 +64611,7 @@ function DepositModal({
64369
64611
  exchanges: integrationExchanges
64370
64612
  }
64371
64613
  ),
64372
- enableCashApp && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64614
+ showCashApp && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64373
64615
  CashAppButton,
64374
64616
  {
64375
64617
  onClick: () => setView("cashapp"),
@@ -64378,7 +64620,7 @@ function DepositModal({
64378
64620
  iconUrl: projectConfig?.asset_cdn_url ? `${projectConfig.asset_cdn_url}/api/public/icons/onramps/svg/cashapp.svg` : void 0
64379
64621
  }
64380
64622
  ),
64381
- !hideDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64623
+ showDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
64382
64624
  DepositTrackerButton,
64383
64625
  {
64384
64626
  onClick: () => {
@@ -64583,7 +64825,11 @@ function DepositModal({
64583
64825
  onDisconnect: handleExchangeDisconnect,
64584
64826
  skipToHoldings: coinbaseSkipToHoldings,
64585
64827
  canGoBack: sessionOpenedFromMenu,
64586
- onExecutionsChange: setDepositExecutions
64828
+ onExecutionsChange: setDepositExecutions,
64829
+ defaultSourceChainType,
64830
+ defaultSourceChainId,
64831
+ defaultSourceTokenAddress,
64832
+ defaultSourceSymbol
64587
64833
  }
64588
64834
  ),
64589
64835
  depositPoweredByFooter
@@ -64616,11 +64862,15 @@ function DepositModal({
64616
64862
  onWalletDisconnect: handleWalletDisconnect,
64617
64863
  onWalletConnected: (info, dw) => {
64618
64864
  setBrowserWalletInfo({ ...info, depositWallet: dw });
64619
- setStoredWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
64865
+ setStoredWalletState(info.type);
64620
64866
  setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
64621
64867
  },
64622
64868
  onBack: handleBack,
64623
64869
  onClose: handleClose,
64870
+ defaultSourceChainType,
64871
+ defaultSourceChainId,
64872
+ defaultSourceTokenAddress,
64873
+ defaultSourceSymbol,
64624
64874
  canGoBack: sessionOpenedFromMenu,
64625
64875
  depositWalletsLoading: walletsLoading
64626
64876
  }
@@ -64723,7 +64973,8 @@ function CheckoutModal({
64723
64973
  clientSecret,
64724
64974
  publishableKey,
64725
64975
  modalTitle,
64726
- enableConnectWallet = false,
64976
+ enableTransferCrypto,
64977
+ enableConnectWallet,
64727
64978
  defaultSourceChainType,
64728
64979
  defaultSourceChainId,
64729
64980
  defaultSourceTokenAddress,
@@ -64740,7 +64991,7 @@ function CheckoutModal({
64740
64991
  const [browserWalletModalOpen, setBrowserWalletModalOpen] = (0, import_react29.useState)(false);
64741
64992
  const [browserWalletInfo, setBrowserWalletInfo] = (0, import_react29.useState)(null);
64742
64993
  const [walletSelectionModalOpen, setWalletSelectionModalOpen] = (0, import_react29.useState)(false);
64743
- const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react29.useState)(() => getStoredWalletChainType());
64994
+ const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react29.useState)(() => getStoredWalletState()?.chainType);
64744
64995
  const isMobileView = useIsMobileViewport();
64745
64996
  const [resolvedTheme, setResolvedTheme] = (0, import_react29.useState)(
64746
64997
  theme === "auto" ? "dark" : theme
@@ -64773,6 +65024,15 @@ function CheckoutModal({
64773
65024
  publishableKey,
64774
65025
  enabled: open
64775
65026
  });
65027
+ const showTransferCrypto = enableTransferCrypto ?? projectConfig?.transfer_crypto?.enabled ?? true;
65028
+ const showConnectWallet = enableConnectWallet ?? projectConfig?.connect_wallet?.enabled ?? true;
65029
+ (0, import_react29.useEffect)(() => {
65030
+ if (view === "transfer" && !showTransferCrypto) {
65031
+ setView("main");
65032
+ } else if (view === "wallet_connect" && !showConnectWallet) {
65033
+ setView("main");
65034
+ }
65035
+ }, [showConnectWallet, showTransferCrypto, view]);
64776
65036
  const prevStatusRef = (0, import_react29.useRef)(null);
64777
65037
  (0, import_react29.useEffect)(() => {
64778
65038
  if (!paymentIntent) return;
@@ -64863,7 +65123,7 @@ function CheckoutModal({
64863
65123
  const handleBrowserWalletClick = (0, import_react29.useCallback)(
64864
65124
  (walletInfo) => {
64865
65125
  const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
64866
- setStoredWalletChainType(walletChainType);
65126
+ setStoredWalletState(walletInfo.type);
64867
65127
  setBrowserWalletChainType(walletChainType);
64868
65128
  const matchingDepositWallet = wallets.find(
64869
65129
  (w) => w.chain_type === walletChainType
@@ -64890,7 +65150,7 @@ function CheckoutModal({
64890
65150
  const handleWalletConnected = (0, import_react29.useCallback)(
64891
65151
  (walletInfo) => {
64892
65152
  const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
64893
- setStoredWalletChainType(walletChainType);
65153
+ setStoredWalletState(walletInfo.type);
64894
65154
  setBrowserWalletChainType(walletChainType);
64895
65155
  const matchingDepositWallet = wallets.find(
64896
65156
  (w) => w.chain_type === walletChainType
@@ -64914,7 +65174,7 @@ function CheckoutModal({
64914
65174
  );
64915
65175
  const handleWalletDisconnect = (0, import_react29.useCallback)(() => {
64916
65176
  setUserDisconnectedWallet(true);
64917
- clearStoredWalletChainType();
65177
+ clearStoredWalletState();
64918
65178
  setBrowserWalletChainType(void 0);
64919
65179
  setBrowserWalletInfo(null);
64920
65180
  setBrowserWalletModalOpen(false);
@@ -65149,7 +65409,7 @@ function CheckoutModal({
65149
65409
  ] }) : paymentIntent ? /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "uf-space-y-3", children: [
65150
65410
  progressSection,
65151
65411
  (paymentIntent.status === "requires_payment" || paymentIntent.status === "processing") && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_jsx_runtime75.Fragment, { children: [
65152
- /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
65412
+ showTransferCrypto && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
65153
65413
  TransferCryptoButton,
65154
65414
  {
65155
65415
  onClick: () => setView("transfer"),
@@ -65158,7 +65418,7 @@ function CheckoutModal({
65158
65418
  featuredTokens: projectConfig?.transfer_crypto.networks
65159
65419
  }
65160
65420
  ),
65161
- enableConnectWallet && !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
65421
+ showConnectWallet && !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
65162
65422
  BrowserWalletButton,
65163
65423
  {
65164
65424
  onClick: handleBrowserWalletClick,
@@ -65299,14 +65559,18 @@ function CheckoutModal({
65299
65559
  onWalletDisconnect: handleWalletDisconnect,
65300
65560
  onWalletConnected: (info, dw) => {
65301
65561
  setBrowserWalletInfo({ ...info, depositWallet: dw });
65302
- setStoredWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
65562
+ setStoredWalletState(info.type);
65303
65563
  setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
65304
65564
  },
65305
65565
  onNewDeposit: () => setView("main"),
65306
65566
  onDone: () => setView("main"),
65307
65567
  paymentIntentStatus: paymentIntent.status,
65308
65568
  onBack: handleBack,
65309
- onClose: handleClose
65569
+ onClose: handleClose,
65570
+ defaultSourceChainType,
65571
+ defaultSourceChainId,
65572
+ defaultSourceTokenAddress,
65573
+ defaultSourceSymbol
65310
65574
  }
65311
65575
  ),
65312
65576
  poweredByFooter
@@ -67269,6 +67533,7 @@ function UnifoldProvider2({
67269
67533
  onOpenChange: closeCheckout,
67270
67534
  clientSecret: checkoutConfig.clientSecret,
67271
67535
  publishableKey,
67536
+ enableTransferCrypto: config?.enableTransferCrypto,
67272
67537
  enableConnectWallet: config?.enableConnectWallet,
67273
67538
  defaultSourceChainType: checkoutConfig.defaultSourceChainType,
67274
67539
  defaultSourceChainId: checkoutConfig.defaultSourceChainId,
@@ -67325,6 +67590,7 @@ function UnifoldProvider2({
67325
67590
  hideDepositTracker: config?.hideDepositTracker,
67326
67591
  showBalanceHeader: config?.showBalanceHeader,
67327
67592
  transferInputVariant: config?.transferInputVariant,
67593
+ enableTransferCrypto: config?.enableTransferCrypto,
67328
67594
  enableConnectWallet: config?.enableConnectWallet,
67329
67595
  enablePayWithExchange: config?.enablePayWithExchange,
67330
67596
  enableFiatOnramp: config?.enableFiatOnramp,