@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.
- package/dist/index.js +428 -162
- package/dist/index.mjs +428 -162
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -43117,6 +43117,42 @@ var getDefaultConfig = () => {
|
|
|
43117
43117
|
};
|
|
43118
43118
|
};
|
|
43119
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
|
+
}
|
|
43120
43156
|
var API_BASE_URL = (() => {
|
|
43121
43157
|
try {
|
|
43122
43158
|
return process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.unifold.io";
|
|
@@ -43419,9 +43455,7 @@ function getOnrampSessionStartUrl(request, publishableKey) {
|
|
|
43419
43455
|
if (request.subdivision_code) {
|
|
43420
43456
|
params.append("subdivision_code", request.subdivision_code);
|
|
43421
43457
|
}
|
|
43422
|
-
|
|
43423
|
-
params.append("external_id", request.external_id);
|
|
43424
|
-
}
|
|
43458
|
+
params.append("external_id", request.external_id ?? generatePrefixedKSUID("ors"));
|
|
43425
43459
|
if (request.email) {
|
|
43426
43460
|
params.append("email", request.email);
|
|
43427
43461
|
}
|
|
@@ -43636,9 +43670,7 @@ function getExchangeSessionStartUrl(request, publishableKey) {
|
|
|
43636
43670
|
if (request.source_amount) {
|
|
43637
43671
|
params.append("source_amount", request.source_amount);
|
|
43638
43672
|
}
|
|
43639
|
-
|
|
43640
|
-
params.append("external_id", request.external_id);
|
|
43641
|
-
}
|
|
43673
|
+
params.append("external_id", request.external_id ?? generatePrefixedKSUID("exc"));
|
|
43642
43674
|
return `${API_BASE_URL}/v1/public/onramps/exchanges/sessions/start?${params.toString()}`;
|
|
43643
43675
|
}
|
|
43644
43676
|
async function getIntegrationExchanges(publishableKey) {
|
|
@@ -43972,40 +44004,6 @@ async function getCashAppSessionStatus(externalId, publishableKey) {
|
|
|
43972
44004
|
}
|
|
43973
44005
|
return response.json();
|
|
43974
44006
|
}
|
|
43975
|
-
function formatStablecoinAmount(baseUnits, decimals) {
|
|
43976
|
-
const raw = Number(baseUnits) / 10 ** decimals;
|
|
43977
|
-
const floored = Math.floor(raw * 100) / 100;
|
|
43978
|
-
const ceiled = raw > floored ? floored + 0.01 : raw;
|
|
43979
|
-
return ceiled.toFixed(2);
|
|
43980
|
-
}
|
|
43981
|
-
function generatePrefixedKSUID(prefix) {
|
|
43982
|
-
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
43983
|
-
const KSUID_EPOCH = 14e8;
|
|
43984
|
-
const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
|
|
43985
|
-
const payload = new Uint8Array(20);
|
|
43986
|
-
payload[0] = timestampSeconds >>> 24 & 255;
|
|
43987
|
-
payload[1] = timestampSeconds >>> 16 & 255;
|
|
43988
|
-
payload[2] = timestampSeconds >>> 8 & 255;
|
|
43989
|
-
payload[3] = timestampSeconds & 255;
|
|
43990
|
-
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
43991
|
-
crypto.getRandomValues(payload.subarray(4));
|
|
43992
|
-
} else {
|
|
43993
|
-
for (let i = 4; i < 20; i++) {
|
|
43994
|
-
payload[i] = Math.floor(Math.random() * 256);
|
|
43995
|
-
}
|
|
43996
|
-
}
|
|
43997
|
-
let value = 0n;
|
|
43998
|
-
for (const byte of payload) {
|
|
43999
|
-
value = value << 8n | BigInt(byte);
|
|
44000
|
-
}
|
|
44001
|
-
let encoded = "";
|
|
44002
|
-
while (value > 0n) {
|
|
44003
|
-
encoded = BASE62[Number(value % 62n)] + encoded;
|
|
44004
|
-
value = value / 62n;
|
|
44005
|
-
}
|
|
44006
|
-
encoded = encoded.padStart(27, "0");
|
|
44007
|
-
return `${prefix}_${encoded}`;
|
|
44008
|
-
}
|
|
44009
44007
|
var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
|
|
44010
44008
|
DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
|
|
44011
44009
|
return DepositEventType2;
|
|
@@ -50105,8 +50103,32 @@ var Separator = SelectSeparator;
|
|
|
50105
50103
|
function cn(...inputs) {
|
|
50106
50104
|
return twMerge(clsx(inputs));
|
|
50107
50105
|
}
|
|
50108
|
-
var
|
|
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
|
+
];
|
|
50109
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
|
+
}
|
|
50110
50132
|
function getUserDisconnectedWallet() {
|
|
50111
50133
|
if (typeof window === "undefined") return false;
|
|
50112
50134
|
try {
|
|
@@ -50126,26 +50148,35 @@ function setUserDisconnectedWallet(disconnected) {
|
|
|
50126
50148
|
} catch {
|
|
50127
50149
|
}
|
|
50128
50150
|
}
|
|
50129
|
-
function
|
|
50151
|
+
function getStoredWalletState() {
|
|
50130
50152
|
if (typeof window === "undefined") return void 0;
|
|
50131
50153
|
try {
|
|
50132
|
-
const
|
|
50133
|
-
if (
|
|
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 };
|
|
50134
50162
|
} catch {
|
|
50163
|
+
return void 0;
|
|
50135
50164
|
}
|
|
50136
|
-
return void 0;
|
|
50137
50165
|
}
|
|
50138
|
-
function
|
|
50166
|
+
function setStoredWalletState(walletType) {
|
|
50139
50167
|
if (typeof window === "undefined") return;
|
|
50168
|
+
if (!walletTypeToChain(walletType)) return;
|
|
50140
50169
|
try {
|
|
50141
|
-
localStorage.setItem(
|
|
50170
|
+
localStorage.setItem(WALLET_STATE_STORAGE_KEY, walletType);
|
|
50171
|
+
for (const key of LEGACY_WALLET_KEYS) localStorage.removeItem(key);
|
|
50142
50172
|
} catch {
|
|
50143
50173
|
}
|
|
50144
50174
|
}
|
|
50145
|
-
function
|
|
50175
|
+
function clearStoredWalletState() {
|
|
50146
50176
|
if (typeof window === "undefined") return;
|
|
50147
50177
|
try {
|
|
50148
|
-
localStorage.removeItem(
|
|
50178
|
+
localStorage.removeItem(WALLET_STATE_STORAGE_KEY);
|
|
50179
|
+
for (const key of LEGACY_WALLET_KEYS) localStorage.removeItem(key);
|
|
50149
50180
|
} catch {
|
|
50150
50181
|
}
|
|
50151
50182
|
}
|
|
@@ -50708,6 +50739,60 @@ function useDepositAddress(params) {
|
|
|
50708
50739
|
// 1s, 2s, 4s (max 10s)
|
|
50709
50740
|
});
|
|
50710
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
|
+
}
|
|
50711
50796
|
function formatUsdFromBalancePercent(maxUsdAmount, percent) {
|
|
50712
50797
|
if (maxUsdAmount <= 0 || percent < 0) return "";
|
|
50713
50798
|
const raw = maxUsdAmount * percent / 100;
|
|
@@ -55221,70 +55306,106 @@ function identifyEthWallet(provider, hint) {
|
|
|
55221
55306
|
}
|
|
55222
55307
|
return { type: "metamask", name: "Wallet", icon: "metamask" };
|
|
55223
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
|
+
}
|
|
55224
55395
|
async function detectConnectedBrowserWallet(chainType) {
|
|
55225
55396
|
if (typeof window === "undefined") return null;
|
|
55226
55397
|
if (getUserDisconnectedWallet()) return null;
|
|
55227
55398
|
try {
|
|
55228
55399
|
const win = window;
|
|
55229
|
-
|
|
55230
|
-
|
|
55231
|
-
|
|
55232
|
-
|
|
55233
|
-
|
|
55234
|
-
|
|
55235
|
-
|
|
55236
|
-
|
|
55237
|
-
|
|
55238
|
-
return { type, name, address: resp.publicKey.toString(), icon };
|
|
55239
|
-
}
|
|
55240
|
-
} catch {
|
|
55241
|
-
}
|
|
55242
|
-
return null;
|
|
55243
|
-
};
|
|
55244
|
-
const solanaCandidates = [
|
|
55245
|
-
[win.phantom?.solana, "phantom-solana", "Phantom", "phantom"],
|
|
55246
|
-
[win.solflare, "solflare", "Solflare", "solflare"],
|
|
55247
|
-
[win.backpack, "backpack", "Backpack", "backpack"],
|
|
55248
|
-
[win.glow, "glow", "Glow", "glow"]
|
|
55249
|
-
];
|
|
55250
|
-
for (const [provider, type, name, icon] of solanaCandidates) {
|
|
55251
|
-
const found = await trySilentSolana(provider, type, name, icon);
|
|
55252
|
-
if (found) return found;
|
|
55253
|
-
}
|
|
55254
|
-
}
|
|
55255
|
-
if (!chainType || chainType === "ethereum") {
|
|
55256
|
-
const allProviders = [];
|
|
55257
|
-
const eip6963 = getEip6963Providers();
|
|
55258
|
-
for (const { provider, walletId } of eip6963) {
|
|
55259
|
-
allProviders.push({
|
|
55260
|
-
provider,
|
|
55261
|
-
walletId: walletId === "unknown" ? "default" : walletId
|
|
55262
|
-
});
|
|
55263
|
-
}
|
|
55264
|
-
if (allProviders.length === 0) {
|
|
55265
|
-
if (win.phantom?.ethereum) {
|
|
55266
|
-
allProviders.push({ provider: win.phantom.ethereum, walletId: "phantom" });
|
|
55267
|
-
}
|
|
55268
|
-
if (win.okxwallet) {
|
|
55269
|
-
allProviders.push({ provider: win.okxwallet, walletId: "okx" });
|
|
55270
|
-
}
|
|
55271
|
-
if (win.coinbaseWalletExtension) {
|
|
55272
|
-
allProviders.push({ provider: win.coinbaseWalletExtension, walletId: "coinbase" });
|
|
55273
|
-
}
|
|
55274
|
-
if (win.ethereum && !allProviders.some((p) => p.provider === win.ethereum)) {
|
|
55275
|
-
allProviders.push({ provider: win.ethereum, walletId: "default" });
|
|
55276
|
-
}
|
|
55277
|
-
}
|
|
55278
|
-
for (const { provider, walletId } of allProviders) {
|
|
55279
|
-
if (!provider) continue;
|
|
55280
|
-
try {
|
|
55281
|
-
const accounts = await provider.request({ method: "eth_accounts" });
|
|
55282
|
-
if (!accounts || accounts.length === 0) continue;
|
|
55283
|
-
const resolved = identifyEthWallet(provider, walletId);
|
|
55284
|
-
return { ...resolved, address: accounts[0] };
|
|
55285
|
-
} catch {
|
|
55286
|
-
}
|
|
55287
|
-
}
|
|
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;
|
|
55288
55409
|
}
|
|
55289
55410
|
} catch (error) {
|
|
55290
55411
|
console.error("[detectConnectedBrowserWallet] detection error:", error);
|
|
@@ -57430,6 +57551,7 @@ function BrowserWalletButton({
|
|
|
57430
57551
|
if (solanaProvider?.isPhantom) {
|
|
57431
57552
|
const { publicKey } = await solanaProvider.connect();
|
|
57432
57553
|
setUserDisconnectedWallet(false);
|
|
57554
|
+
setStoredWalletState("phantom-solana");
|
|
57433
57555
|
setWallet({
|
|
57434
57556
|
type: "phantom-solana",
|
|
57435
57557
|
name: "Phantom",
|
|
@@ -57449,8 +57571,10 @@ function BrowserWalletButton({
|
|
|
57449
57571
|
if (accounts && accounts.length > 0) {
|
|
57450
57572
|
setUserDisconnectedWallet(false);
|
|
57451
57573
|
const isPhantom = ethProvider.isPhantom;
|
|
57574
|
+
const walletType = isPhantom ? "phantom-ethereum" : "metamask";
|
|
57575
|
+
setStoredWalletState(walletType);
|
|
57452
57576
|
setWallet({
|
|
57453
|
-
type:
|
|
57577
|
+
type: walletType,
|
|
57454
57578
|
name: isPhantom ? "Phantom" : "MetaMask",
|
|
57455
57579
|
address: accounts[0],
|
|
57456
57580
|
icon: isPhantom ? "phantom" : "metamask"
|
|
@@ -57760,7 +57884,11 @@ function CoinbaseConnect({
|
|
|
57760
57884
|
onDisconnect,
|
|
57761
57885
|
skipToHoldings,
|
|
57762
57886
|
canGoBack = true,
|
|
57763
|
-
onExecutionsChange
|
|
57887
|
+
onExecutionsChange,
|
|
57888
|
+
defaultSourceChainType,
|
|
57889
|
+
defaultSourceChainId,
|
|
57890
|
+
defaultSourceTokenAddress,
|
|
57891
|
+
defaultSourceSymbol
|
|
57764
57892
|
}) {
|
|
57765
57893
|
const { colors: colors2, fonts, components } = useTheme();
|
|
57766
57894
|
const { projectConfig } = useProjectConfig({ publishableKey });
|
|
@@ -57825,6 +57953,21 @@ function CoinbaseConnect({
|
|
|
57825
57953
|
params: defaultTokenParams,
|
|
57826
57954
|
publishableKey
|
|
57827
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
|
+
);
|
|
57828
57971
|
const sortedHoldings = (0, import_react18.useMemo)(() => {
|
|
57829
57972
|
const supported = [];
|
|
57830
57973
|
const unsupported = [];
|
|
@@ -57834,13 +57977,42 @@ function CoinbaseConnect({
|
|
|
57834
57977
|
if (isSupported) supported.push(account);
|
|
57835
57978
|
else unsupported.push(account);
|
|
57836
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
|
+
}
|
|
57837
57989
|
return [...supported, ...unsupported];
|
|
57838
|
-
}, [
|
|
57990
|
+
}, [
|
|
57991
|
+
holdings,
|
|
57992
|
+
supportedSymbols,
|
|
57993
|
+
exchangeSupportedCurrencies,
|
|
57994
|
+
defaultSourceCurrency
|
|
57995
|
+
]);
|
|
57839
57996
|
const selectedHoldingIsSupported = (0, import_react18.useMemo)(() => {
|
|
57840
57997
|
if (!selectedHolding) return false;
|
|
57841
57998
|
const currencyLower = selectedHolding.currency.toLowerCase();
|
|
57842
57999
|
return (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
|
|
57843
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
|
+
]);
|
|
57844
58016
|
const exchangeName = selectedExchange?.service_provider_display_name || "Exchange";
|
|
57845
58017
|
const {
|
|
57846
58018
|
executions: depositExecutions,
|
|
@@ -63006,6 +63178,19 @@ var WALLET_DEFINITIONS = [
|
|
|
63006
63178
|
{ id: "backpack", name: "Backpack", networks: ["solana"], installUrl: "https://backpack.app/" },
|
|
63007
63179
|
{ id: "glow", name: "Glow", networks: ["solana"], installUrl: "https://glow.app/" }
|
|
63008
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
|
+
}
|
|
63009
63194
|
function getSolanaProviders() {
|
|
63010
63195
|
if (typeof window === "undefined") return {};
|
|
63011
63196
|
const win = window;
|
|
@@ -63148,6 +63333,10 @@ function WalletConnect({
|
|
|
63148
63333
|
checkoutRemainingBaseUnits,
|
|
63149
63334
|
stablecoinParity = false,
|
|
63150
63335
|
productType,
|
|
63336
|
+
defaultSourceChainType,
|
|
63337
|
+
defaultSourceChainId,
|
|
63338
|
+
defaultSourceTokenAddress,
|
|
63339
|
+
defaultSourceSymbol,
|
|
63151
63340
|
onBack: parentOnBack,
|
|
63152
63341
|
onClose,
|
|
63153
63342
|
canGoBack = true,
|
|
@@ -63308,6 +63497,7 @@ function WalletConnect({
|
|
|
63308
63497
|
metamask: "metamask"
|
|
63309
63498
|
};
|
|
63310
63499
|
const walletType = walletIdToType[wallet.id] || "metamask";
|
|
63500
|
+
setStoredWalletState(walletType);
|
|
63311
63501
|
connectedInfo = { type: walletType, name: wallet.name, address: accounts[0], icon: wallet.id };
|
|
63312
63502
|
} else {
|
|
63313
63503
|
const solProviders = getSolanaProviders();
|
|
@@ -63336,6 +63526,7 @@ function WalletConnect({
|
|
|
63336
63526
|
const response = await provider.connect();
|
|
63337
63527
|
setUserDisconnectedWallet(false);
|
|
63338
63528
|
const walletType = wallet.id === "solflare" ? "solflare" : wallet.id === "backpack" ? "backpack" : wallet.id === "glow" ? "glow" : "phantom-solana";
|
|
63529
|
+
setStoredWalletState(walletType);
|
|
63339
63530
|
connectedInfo = { type: walletType, name: wallet.name, address: response.publicKey.toString(), icon: wallet.id };
|
|
63340
63531
|
}
|
|
63341
63532
|
const walletChainType = network === "solana" ? "solana" : "ethereum";
|
|
@@ -63450,18 +63641,33 @@ function WalletConnect({
|
|
|
63450
63641
|
getAddressBalances(activeWalletInfo.address, sct, publishableKey).then((response) => {
|
|
63451
63642
|
if (cancelled) return;
|
|
63452
63643
|
const nonZero = response.balances.filter((b) => b.amount !== "0");
|
|
63453
|
-
const
|
|
63454
|
-
|
|
63455
|
-
|
|
63456
|
-
|
|
63457
|
-
|
|
63458
|
-
|
|
63459
|
-
|
|
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
|
+
);
|
|
63460
63653
|
setBalances(sorted);
|
|
63461
63654
|
const totalUsd = nonZero.reduce((sum, b) => b.amount_usd ? sum + parseFloat(b.amount_usd) : sum, 0);
|
|
63462
63655
|
if (totalUsd > 0) setTotalBalanceUsd(totalUsd.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 }));
|
|
63463
63656
|
const eligible = sorted.filter(isBalanceEligible);
|
|
63464
|
-
|
|
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
|
+
});
|
|
63465
63671
|
}).catch((err) => {
|
|
63466
63672
|
if (!cancelled) {
|
|
63467
63673
|
console.error("[WalletConnect] Error fetching balances:", err);
|
|
@@ -63473,7 +63679,15 @@ function WalletConnect({
|
|
|
63473
63679
|
return () => {
|
|
63474
63680
|
cancelled = true;
|
|
63475
63681
|
};
|
|
63476
|
-
}, [
|
|
63682
|
+
}, [
|
|
63683
|
+
activeWalletInfo?.address,
|
|
63684
|
+
activeDepositWallet?.chain_type,
|
|
63685
|
+
publishableKey,
|
|
63686
|
+
defaultSourceChainType,
|
|
63687
|
+
defaultSourceChainId,
|
|
63688
|
+
defaultSourceTokenAddress,
|
|
63689
|
+
defaultSourceSymbol
|
|
63690
|
+
]);
|
|
63477
63691
|
const usdToTokenRate = React302.useMemo(() => {
|
|
63478
63692
|
if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
|
|
63479
63693
|
const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
|
|
@@ -63828,16 +64042,17 @@ function DepositModal({
|
|
|
63828
64042
|
defaultSourceChainId,
|
|
63829
64043
|
defaultSourceTokenAddress,
|
|
63830
64044
|
defaultSourceSymbol,
|
|
63831
|
-
hideDepositTracker
|
|
64045
|
+
hideDepositTracker,
|
|
63832
64046
|
showBalanceHeader = false,
|
|
63833
64047
|
transferInputVariant = "double_input",
|
|
63834
64048
|
depositConfirmationMode = "auto_ui",
|
|
63835
|
-
|
|
64049
|
+
enableTransferCrypto,
|
|
64050
|
+
enableConnectWallet,
|
|
63836
64051
|
browserWalletAmountQuickSelect = "percentage",
|
|
63837
64052
|
enablePayWithExchange,
|
|
63838
64053
|
enableFiatOnramp,
|
|
63839
|
-
enableConnectExchange
|
|
63840
|
-
enableCashApp
|
|
64054
|
+
enableConnectExchange,
|
|
64055
|
+
enableCashApp,
|
|
63841
64056
|
hideDepositFlowInfo = false,
|
|
63842
64057
|
hideDisplayDescription = false,
|
|
63843
64058
|
onDepositSuccess,
|
|
@@ -63855,12 +64070,13 @@ function DepositModal({
|
|
|
63855
64070
|
const { colors: colors2, fonts, components } = useTheme();
|
|
63856
64071
|
const effectiveInitialScreen = (0, import_react3.useMemo)(() => {
|
|
63857
64072
|
const s = initialScreen ?? "main";
|
|
63858
|
-
if (s === "tracker" && hideDepositTracker) return "main";
|
|
63859
|
-
if (s === "cashapp" &&
|
|
64073
|
+
if (s === "tracker" && hideDepositTracker === true) return "main";
|
|
64074
|
+
if (s === "cashapp" && enableCashApp === false) return "main";
|
|
63860
64075
|
if (s === "card" && enableFiatOnramp === false) return "main";
|
|
63861
64076
|
if (s === "pay_with_exchange") return enablePayWithExchange === false ? "main" : "exchange";
|
|
63862
|
-
if (s === "exchange_connect")
|
|
63863
|
-
|
|
64077
|
+
if (s === "exchange_connect")
|
|
64078
|
+
return enableConnectExchange === false ? "main" : "coinbase_connect";
|
|
64079
|
+
if (s === "wallet_connect") return enableConnectWallet === false ? "main" : "wallet_connect";
|
|
63864
64080
|
return s;
|
|
63865
64081
|
}, [
|
|
63866
64082
|
initialScreen,
|
|
@@ -63889,26 +64105,37 @@ function DepositModal({
|
|
|
63889
64105
|
const [browserWalletModalOpen, setBrowserWalletModalOpen] = (0, import_react3.useState)(false);
|
|
63890
64106
|
const [browserWalletInfo, setBrowserWalletInfo] = (0, import_react3.useState)(null);
|
|
63891
64107
|
const [walletSelectionModalOpen, setWalletSelectionModalOpen] = (0, import_react3.useState)(false);
|
|
63892
|
-
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react3.useState)(() =>
|
|
64108
|
+
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react3.useState)(() => getStoredWalletState()?.chainType);
|
|
63893
64109
|
const [quotesCount, setQuotesCount] = (0, import_react3.useState)(0);
|
|
63894
64110
|
const [allExecutions, setAllExecutions] = (0, import_react3.useState)([]);
|
|
63895
64111
|
const [selectedExecution, setSelectedExecution] = (0, import_react3.useState)(null);
|
|
63896
64112
|
const [depositExecutions, setDepositExecutions] = (0, import_react3.useState)([]);
|
|
63897
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;
|
|
63898
64125
|
const [integrationExchanges, setIntegrationExchanges] = (0, import_react3.useState)([]);
|
|
63899
64126
|
(0, import_react3.useEffect)(() => {
|
|
63900
|
-
if (!
|
|
64127
|
+
if (!showConnectExchange || !open) return;
|
|
63901
64128
|
getIntegrationExchanges(publishableKey).then((res) => setIntegrationExchanges(res.data)).catch(() => {
|
|
63902
64129
|
});
|
|
63903
|
-
}, [
|
|
64130
|
+
}, [showConnectExchange, open, publishableKey]);
|
|
63904
64131
|
const [connectedExchange, setConnectedExchange] = (0, import_react3.useState)(() => {
|
|
63905
|
-
if (!
|
|
64132
|
+
if (!showConnectExchange) return null;
|
|
63906
64133
|
const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
|
|
63907
64134
|
if (!stored) return null;
|
|
63908
64135
|
return { name: "Coinbase", iconUrl: void 0, balanceUsd: null, isLoading: true };
|
|
63909
64136
|
});
|
|
63910
64137
|
(0, import_react3.useEffect)(() => {
|
|
63911
|
-
if (!
|
|
64138
|
+
if (!showConnectExchange || !open || view !== "main") return;
|
|
63912
64139
|
const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
|
|
63913
64140
|
if (!stored) {
|
|
63914
64141
|
setConnectedExchange(null);
|
|
@@ -63943,7 +64170,7 @@ function DepositModal({
|
|
|
63943
64170
|
setConnectedExchange(null);
|
|
63944
64171
|
}
|
|
63945
64172
|
});
|
|
63946
|
-
}, [
|
|
64173
|
+
}, [showConnectExchange, open, view, publishableKey]);
|
|
63947
64174
|
(0, import_react3.useEffect)(() => {
|
|
63948
64175
|
if (!connectedExchange || integrationExchanges.length === 0) return;
|
|
63949
64176
|
const cbExchange = integrationExchanges.find(
|
|
@@ -63982,18 +64209,33 @@ function DepositModal({
|
|
|
63982
64209
|
setResolvedTheme(theme);
|
|
63983
64210
|
}
|
|
63984
64211
|
}, [theme]);
|
|
63985
|
-
const { projectConfig } = useProjectConfig({
|
|
63986
|
-
publishableKey,
|
|
63987
|
-
enabled: open
|
|
63988
|
-
});
|
|
63989
|
-
const showPayWithExchange = enablePayWithExchange ?? projectConfig?.pay_with_exchange?.enabled ?? true;
|
|
63990
|
-
const showFiatOnramp = enableFiatOnramp ?? projectConfig?.fiat_onramp?.enabled ?? true;
|
|
63991
64212
|
(0, import_react3.useEffect)(() => {
|
|
63992
64213
|
if (view === "card" && !showFiatOnramp) {
|
|
63993
64214
|
setView("main");
|
|
63994
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");
|
|
63995
64228
|
}
|
|
63996
|
-
}, [
|
|
64229
|
+
}, [
|
|
64230
|
+
view,
|
|
64231
|
+
showFiatOnramp,
|
|
64232
|
+
showTransferCrypto,
|
|
64233
|
+
showPayWithExchange,
|
|
64234
|
+
showCashApp,
|
|
64235
|
+
showDepositTracker,
|
|
64236
|
+
showConnectExchange,
|
|
64237
|
+
showConnectWallet
|
|
64238
|
+
]);
|
|
63997
64239
|
(0, import_react3.useEffect)(() => {
|
|
63998
64240
|
if (view === "exchange" && !showPayWithExchange) {
|
|
63999
64241
|
setView("main");
|
|
@@ -64083,7 +64325,7 @@ function DepositModal({
|
|
|
64083
64325
|
depositPrerequisiteBody = standaloneNeedsDepositPrereq ? /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, { variant: "with-icons" }) : /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(import_jsx_runtime74.Fragment, { children: [
|
|
64084
64326
|
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, { variant: "with-icons" }),
|
|
64085
64327
|
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, { variant: "with-icons" }),
|
|
64086
|
-
|
|
64328
|
+
showDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, {})
|
|
64087
64329
|
] });
|
|
64088
64330
|
} else if (countryError) {
|
|
64089
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: [
|
|
@@ -64115,7 +64357,7 @@ function DepositModal({
|
|
|
64115
64357
|
const themeClass = resolvedTheme === "dark" ? "uf-dark" : "";
|
|
64116
64358
|
const handleWalletDisconnect = () => {
|
|
64117
64359
|
setUserDisconnectedWallet(true);
|
|
64118
|
-
|
|
64360
|
+
clearStoredWalletState();
|
|
64119
64361
|
setBrowserWalletChainType(void 0);
|
|
64120
64362
|
setBrowserWalletInfo(null);
|
|
64121
64363
|
setBrowserWalletModalOpen(false);
|
|
@@ -64193,7 +64435,7 @@ function DepositModal({
|
|
|
64193
64435
|
};
|
|
64194
64436
|
const handleBrowserWalletClick = (walletInfo) => {
|
|
64195
64437
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
64196
|
-
|
|
64438
|
+
setStoredWalletState(walletInfo.type);
|
|
64197
64439
|
setBrowserWalletChainType(walletChainType);
|
|
64198
64440
|
const matchingDepositWallet = wallets.find(
|
|
64199
64441
|
(w) => w.chain_type === walletChainType
|
|
@@ -64224,7 +64466,7 @@ function DepositModal({
|
|
|
64224
64466
|
};
|
|
64225
64467
|
const handleWalletConnected = (walletInfo) => {
|
|
64226
64468
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
64227
|
-
|
|
64469
|
+
setStoredWalletState(walletInfo.type);
|
|
64228
64470
|
setBrowserWalletChainType(walletChainType);
|
|
64229
64471
|
const matchingDepositWallet = wallets.find(
|
|
64230
64472
|
(w) => w.chain_type === walletChainType
|
|
@@ -64291,7 +64533,7 @@ function DepositModal({
|
|
|
64291
64533
|
),
|
|
64292
64534
|
/* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
64293
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: [
|
|
64294
|
-
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
64536
|
+
showTransferCrypto && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
64295
64537
|
TransferCryptoButton,
|
|
64296
64538
|
{
|
|
64297
64539
|
onClick: () => setView("transfer"),
|
|
@@ -64300,7 +64542,7 @@ function DepositModal({
|
|
|
64300
64542
|
featuredTokens: projectConfig?.transfer_crypto.networks
|
|
64301
64543
|
}
|
|
64302
64544
|
),
|
|
64303
|
-
|
|
64545
|
+
showConnectWallet && !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
64304
64546
|
BrowserWalletButton,
|
|
64305
64547
|
{
|
|
64306
64548
|
onClick: handleBrowserWalletClick,
|
|
@@ -64330,7 +64572,7 @@ function DepositModal({
|
|
|
64330
64572
|
loading: exchangesLoading
|
|
64331
64573
|
}
|
|
64332
64574
|
),
|
|
64333
|
-
|
|
64575
|
+
showConnectExchange && connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
64334
64576
|
ConnectExchangeButton,
|
|
64335
64577
|
{
|
|
64336
64578
|
onClick: () => {
|
|
@@ -64344,7 +64586,7 @@ function DepositModal({
|
|
|
64344
64586
|
connectedExchange
|
|
64345
64587
|
}
|
|
64346
64588
|
),
|
|
64347
|
-
|
|
64589
|
+
showConnectExchange && !connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
64348
64590
|
ConnectExchangeButton,
|
|
64349
64591
|
{
|
|
64350
64592
|
onClick: () => {
|
|
@@ -64356,7 +64598,7 @@ function DepositModal({
|
|
|
64356
64598
|
exchanges: integrationExchanges
|
|
64357
64599
|
}
|
|
64358
64600
|
),
|
|
64359
|
-
|
|
64601
|
+
showCashApp && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
64360
64602
|
CashAppButton,
|
|
64361
64603
|
{
|
|
64362
64604
|
onClick: () => setView("cashapp"),
|
|
@@ -64365,7 +64607,7 @@ function DepositModal({
|
|
|
64365
64607
|
iconUrl: projectConfig?.asset_cdn_url ? `${projectConfig.asset_cdn_url}/api/public/icons/onramps/svg/cashapp.svg` : void 0
|
|
64366
64608
|
}
|
|
64367
64609
|
),
|
|
64368
|
-
|
|
64610
|
+
showDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
64369
64611
|
DepositTrackerButton,
|
|
64370
64612
|
{
|
|
64371
64613
|
onClick: () => {
|
|
@@ -64570,7 +64812,11 @@ function DepositModal({
|
|
|
64570
64812
|
onDisconnect: handleExchangeDisconnect,
|
|
64571
64813
|
skipToHoldings: coinbaseSkipToHoldings,
|
|
64572
64814
|
canGoBack: sessionOpenedFromMenu,
|
|
64573
|
-
onExecutionsChange: setDepositExecutions
|
|
64815
|
+
onExecutionsChange: setDepositExecutions,
|
|
64816
|
+
defaultSourceChainType,
|
|
64817
|
+
defaultSourceChainId,
|
|
64818
|
+
defaultSourceTokenAddress,
|
|
64819
|
+
defaultSourceSymbol
|
|
64574
64820
|
}
|
|
64575
64821
|
),
|
|
64576
64822
|
depositPoweredByFooter
|
|
@@ -64603,11 +64849,15 @@ function DepositModal({
|
|
|
64603
64849
|
onWalletDisconnect: handleWalletDisconnect,
|
|
64604
64850
|
onWalletConnected: (info, dw) => {
|
|
64605
64851
|
setBrowserWalletInfo({ ...info, depositWallet: dw });
|
|
64606
|
-
|
|
64852
|
+
setStoredWalletState(info.type);
|
|
64607
64853
|
setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
|
|
64608
64854
|
},
|
|
64609
64855
|
onBack: handleBack,
|
|
64610
64856
|
onClose: handleClose,
|
|
64857
|
+
defaultSourceChainType,
|
|
64858
|
+
defaultSourceChainId,
|
|
64859
|
+
defaultSourceTokenAddress,
|
|
64860
|
+
defaultSourceSymbol,
|
|
64611
64861
|
canGoBack: sessionOpenedFromMenu,
|
|
64612
64862
|
depositWalletsLoading: walletsLoading
|
|
64613
64863
|
}
|
|
@@ -64710,7 +64960,8 @@ function CheckoutModal({
|
|
|
64710
64960
|
clientSecret,
|
|
64711
64961
|
publishableKey,
|
|
64712
64962
|
modalTitle,
|
|
64713
|
-
|
|
64963
|
+
enableTransferCrypto,
|
|
64964
|
+
enableConnectWallet,
|
|
64714
64965
|
defaultSourceChainType,
|
|
64715
64966
|
defaultSourceChainId,
|
|
64716
64967
|
defaultSourceTokenAddress,
|
|
@@ -64727,7 +64978,7 @@ function CheckoutModal({
|
|
|
64727
64978
|
const [browserWalletModalOpen, setBrowserWalletModalOpen] = (0, import_react29.useState)(false);
|
|
64728
64979
|
const [browserWalletInfo, setBrowserWalletInfo] = (0, import_react29.useState)(null);
|
|
64729
64980
|
const [walletSelectionModalOpen, setWalletSelectionModalOpen] = (0, import_react29.useState)(false);
|
|
64730
|
-
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react29.useState)(() =>
|
|
64981
|
+
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react29.useState)(() => getStoredWalletState()?.chainType);
|
|
64731
64982
|
const isMobileView = useIsMobileViewport();
|
|
64732
64983
|
const [resolvedTheme, setResolvedTheme] = (0, import_react29.useState)(
|
|
64733
64984
|
theme === "auto" ? "dark" : theme
|
|
@@ -64760,6 +65011,15 @@ function CheckoutModal({
|
|
|
64760
65011
|
publishableKey,
|
|
64761
65012
|
enabled: open
|
|
64762
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]);
|
|
64763
65023
|
const prevStatusRef = (0, import_react29.useRef)(null);
|
|
64764
65024
|
(0, import_react29.useEffect)(() => {
|
|
64765
65025
|
if (!paymentIntent) return;
|
|
@@ -64850,7 +65110,7 @@ function CheckoutModal({
|
|
|
64850
65110
|
const handleBrowserWalletClick = (0, import_react29.useCallback)(
|
|
64851
65111
|
(walletInfo) => {
|
|
64852
65112
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
64853
|
-
|
|
65113
|
+
setStoredWalletState(walletInfo.type);
|
|
64854
65114
|
setBrowserWalletChainType(walletChainType);
|
|
64855
65115
|
const matchingDepositWallet = wallets.find(
|
|
64856
65116
|
(w) => w.chain_type === walletChainType
|
|
@@ -64877,7 +65137,7 @@ function CheckoutModal({
|
|
|
64877
65137
|
const handleWalletConnected = (0, import_react29.useCallback)(
|
|
64878
65138
|
(walletInfo) => {
|
|
64879
65139
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
64880
|
-
|
|
65140
|
+
setStoredWalletState(walletInfo.type);
|
|
64881
65141
|
setBrowserWalletChainType(walletChainType);
|
|
64882
65142
|
const matchingDepositWallet = wallets.find(
|
|
64883
65143
|
(w) => w.chain_type === walletChainType
|
|
@@ -64901,7 +65161,7 @@ function CheckoutModal({
|
|
|
64901
65161
|
);
|
|
64902
65162
|
const handleWalletDisconnect = (0, import_react29.useCallback)(() => {
|
|
64903
65163
|
setUserDisconnectedWallet(true);
|
|
64904
|
-
|
|
65164
|
+
clearStoredWalletState();
|
|
64905
65165
|
setBrowserWalletChainType(void 0);
|
|
64906
65166
|
setBrowserWalletInfo(null);
|
|
64907
65167
|
setBrowserWalletModalOpen(false);
|
|
@@ -65136,7 +65396,7 @@ function CheckoutModal({
|
|
|
65136
65396
|
] }) : paymentIntent ? /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "uf-space-y-3", children: [
|
|
65137
65397
|
progressSection,
|
|
65138
65398
|
(paymentIntent.status === "requires_payment" || paymentIntent.status === "processing") && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_jsx_runtime75.Fragment, { children: [
|
|
65139
|
-
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
65399
|
+
showTransferCrypto && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
65140
65400
|
TransferCryptoButton,
|
|
65141
65401
|
{
|
|
65142
65402
|
onClick: () => setView("transfer"),
|
|
@@ -65145,7 +65405,7 @@ function CheckoutModal({
|
|
|
65145
65405
|
featuredTokens: projectConfig?.transfer_crypto.networks
|
|
65146
65406
|
}
|
|
65147
65407
|
),
|
|
65148
|
-
|
|
65408
|
+
showConnectWallet && !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
65149
65409
|
BrowserWalletButton,
|
|
65150
65410
|
{
|
|
65151
65411
|
onClick: handleBrowserWalletClick,
|
|
@@ -65286,14 +65546,18 @@ function CheckoutModal({
|
|
|
65286
65546
|
onWalletDisconnect: handleWalletDisconnect,
|
|
65287
65547
|
onWalletConnected: (info, dw) => {
|
|
65288
65548
|
setBrowserWalletInfo({ ...info, depositWallet: dw });
|
|
65289
|
-
|
|
65549
|
+
setStoredWalletState(info.type);
|
|
65290
65550
|
setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
|
|
65291
65551
|
},
|
|
65292
65552
|
onNewDeposit: () => setView("main"),
|
|
65293
65553
|
onDone: () => setView("main"),
|
|
65294
65554
|
paymentIntentStatus: paymentIntent.status,
|
|
65295
65555
|
onBack: handleBack,
|
|
65296
|
-
onClose: handleClose
|
|
65556
|
+
onClose: handleClose,
|
|
65557
|
+
defaultSourceChainType,
|
|
65558
|
+
defaultSourceChainId,
|
|
65559
|
+
defaultSourceTokenAddress,
|
|
65560
|
+
defaultSourceSymbol
|
|
65297
65561
|
}
|
|
65298
65562
|
),
|
|
65299
65563
|
poweredByFooter
|
|
@@ -67256,6 +67520,7 @@ function UnifoldProvider2({
|
|
|
67256
67520
|
onOpenChange: closeCheckout,
|
|
67257
67521
|
clientSecret: checkoutConfig.clientSecret,
|
|
67258
67522
|
publishableKey,
|
|
67523
|
+
enableTransferCrypto: config?.enableTransferCrypto,
|
|
67259
67524
|
enableConnectWallet: config?.enableConnectWallet,
|
|
67260
67525
|
defaultSourceChainType: checkoutConfig.defaultSourceChainType,
|
|
67261
67526
|
defaultSourceChainId: checkoutConfig.defaultSourceChainId,
|
|
@@ -67312,6 +67577,7 @@ function UnifoldProvider2({
|
|
|
67312
67577
|
hideDepositTracker: config?.hideDepositTracker,
|
|
67313
67578
|
showBalanceHeader: config?.showBalanceHeader,
|
|
67314
67579
|
transferInputVariant: config?.transferInputVariant,
|
|
67580
|
+
enableTransferCrypto: config?.enableTransferCrypto,
|
|
67315
67581
|
enableConnectWallet: config?.enableConnectWallet,
|
|
67316
67582
|
enablePayWithExchange: config?.enablePayWithExchange,
|
|
67317
67583
|
enableFiatOnramp: config?.enableFiatOnramp,
|