@unifold/connect-react 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/README.md +1 -1
- package/dist/index.d.mts +11 -9
- package/dist/index.d.ts +11 -9
- package/dist/index.js +428 -162
- package/dist/index.mjs +428 -162
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -6151,6 +6151,42 @@ var import_react9 = require("react");
|
|
|
6151
6151
|
|
|
6152
6152
|
// ../core/dist/index.mjs
|
|
6153
6153
|
var import_react_query2 = require("@tanstack/react-query");
|
|
6154
|
+
function formatStablecoinAmount(baseUnits, decimals) {
|
|
6155
|
+
const raw = Number(baseUnits) / 10 ** decimals;
|
|
6156
|
+
const floored = Math.floor(raw * 100) / 100;
|
|
6157
|
+
const ceiled = raw > floored ? floored + 0.01 : raw;
|
|
6158
|
+
return ceiled.toFixed(2);
|
|
6159
|
+
}
|
|
6160
|
+
function generateKSUID() {
|
|
6161
|
+
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
6162
|
+
const KSUID_EPOCH = 14e8;
|
|
6163
|
+
const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
|
|
6164
|
+
const payload = new Uint8Array(20);
|
|
6165
|
+
payload[0] = timestampSeconds >>> 24 & 255;
|
|
6166
|
+
payload[1] = timestampSeconds >>> 16 & 255;
|
|
6167
|
+
payload[2] = timestampSeconds >>> 8 & 255;
|
|
6168
|
+
payload[3] = timestampSeconds & 255;
|
|
6169
|
+
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
6170
|
+
crypto.getRandomValues(payload.subarray(4));
|
|
6171
|
+
} else {
|
|
6172
|
+
for (let i = 4; i < 20; i++) {
|
|
6173
|
+
payload[i] = Math.floor(Math.random() * 256);
|
|
6174
|
+
}
|
|
6175
|
+
}
|
|
6176
|
+
let value = 0n;
|
|
6177
|
+
for (const byte of payload) {
|
|
6178
|
+
value = value << 8n | BigInt(byte);
|
|
6179
|
+
}
|
|
6180
|
+
let encoded = "";
|
|
6181
|
+
while (value > 0n) {
|
|
6182
|
+
encoded = BASE62[Number(value % 62n)] + encoded;
|
|
6183
|
+
value = value / 62n;
|
|
6184
|
+
}
|
|
6185
|
+
return encoded.padStart(27, "0");
|
|
6186
|
+
}
|
|
6187
|
+
function generatePrefixedKSUID(prefix) {
|
|
6188
|
+
return `${prefix}_${generateKSUID()}`;
|
|
6189
|
+
}
|
|
6154
6190
|
var API_BASE_URL = (() => {
|
|
6155
6191
|
try {
|
|
6156
6192
|
return process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.unifold.io";
|
|
@@ -6477,9 +6513,7 @@ function getOnrampSessionStartUrl(request, publishableKey) {
|
|
|
6477
6513
|
if (request.subdivision_code) {
|
|
6478
6514
|
params.append("subdivision_code", request.subdivision_code);
|
|
6479
6515
|
}
|
|
6480
|
-
|
|
6481
|
-
params.append("external_id", request.external_id);
|
|
6482
|
-
}
|
|
6516
|
+
params.append("external_id", request.external_id ?? generatePrefixedKSUID("ors"));
|
|
6483
6517
|
if (request.email) {
|
|
6484
6518
|
params.append("email", request.email);
|
|
6485
6519
|
}
|
|
@@ -6694,9 +6728,7 @@ function getExchangeSessionStartUrl(request, publishableKey) {
|
|
|
6694
6728
|
if (request.source_amount) {
|
|
6695
6729
|
params.append("source_amount", request.source_amount);
|
|
6696
6730
|
}
|
|
6697
|
-
|
|
6698
|
-
params.append("external_id", request.external_id);
|
|
6699
|
-
}
|
|
6731
|
+
params.append("external_id", request.external_id ?? generatePrefixedKSUID("exc"));
|
|
6700
6732
|
return `${API_BASE_URL}/v1/public/onramps/exchanges/sessions/start?${params.toString()}`;
|
|
6701
6733
|
}
|
|
6702
6734
|
async function getIntegrationExchanges(publishableKey) {
|
|
@@ -7030,40 +7062,6 @@ async function getCashAppSessionStatus(externalId, publishableKey) {
|
|
|
7030
7062
|
}
|
|
7031
7063
|
return response.json();
|
|
7032
7064
|
}
|
|
7033
|
-
function formatStablecoinAmount(baseUnits, decimals) {
|
|
7034
|
-
const raw = Number(baseUnits) / 10 ** decimals;
|
|
7035
|
-
const floored = Math.floor(raw * 100) / 100;
|
|
7036
|
-
const ceiled = raw > floored ? floored + 0.01 : raw;
|
|
7037
|
-
return ceiled.toFixed(2);
|
|
7038
|
-
}
|
|
7039
|
-
function generatePrefixedKSUID(prefix) {
|
|
7040
|
-
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
7041
|
-
const KSUID_EPOCH = 14e8;
|
|
7042
|
-
const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
|
|
7043
|
-
const payload = new Uint8Array(20);
|
|
7044
|
-
payload[0] = timestampSeconds >>> 24 & 255;
|
|
7045
|
-
payload[1] = timestampSeconds >>> 16 & 255;
|
|
7046
|
-
payload[2] = timestampSeconds >>> 8 & 255;
|
|
7047
|
-
payload[3] = timestampSeconds & 255;
|
|
7048
|
-
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
7049
|
-
crypto.getRandomValues(payload.subarray(4));
|
|
7050
|
-
} else {
|
|
7051
|
-
for (let i = 4; i < 20; i++) {
|
|
7052
|
-
payload[i] = Math.floor(Math.random() * 256);
|
|
7053
|
-
}
|
|
7054
|
-
}
|
|
7055
|
-
let value = 0n;
|
|
7056
|
-
for (const byte of payload) {
|
|
7057
|
-
value = value << 8n | BigInt(byte);
|
|
7058
|
-
}
|
|
7059
|
-
let encoded = "";
|
|
7060
|
-
while (value > 0n) {
|
|
7061
|
-
encoded = BASE62[Number(value % 62n)] + encoded;
|
|
7062
|
-
value = value / 62n;
|
|
7063
|
-
}
|
|
7064
|
-
encoded = encoded.padStart(27, "0");
|
|
7065
|
-
return `${prefix}_${encoded}`;
|
|
7066
|
-
}
|
|
7067
7065
|
var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
|
|
7068
7066
|
DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
|
|
7069
7067
|
return DepositEventType2;
|
|
@@ -13500,8 +13498,32 @@ var import_jsx_runtime79 = require("react/jsx-runtime");
|
|
|
13500
13498
|
function cn(...inputs) {
|
|
13501
13499
|
return twMerge(clsx(inputs));
|
|
13502
13500
|
}
|
|
13503
|
-
var
|
|
13501
|
+
var WALLET_STATE_STORAGE_KEY = "unifold_wallet_state";
|
|
13502
|
+
var LEGACY_WALLET_KEYS = [
|
|
13503
|
+
"unifold_last_wallet_type",
|
|
13504
|
+
"unifold_last_connected_wallet"
|
|
13505
|
+
];
|
|
13504
13506
|
var WALLET_USER_DISCONNECTED_KEY = "unifold_wallet_user_disconnected";
|
|
13507
|
+
var SOLANA_WALLET_TYPES = /* @__PURE__ */ new Set([
|
|
13508
|
+
"phantom-solana",
|
|
13509
|
+
"solflare",
|
|
13510
|
+
"backpack",
|
|
13511
|
+
"glow"
|
|
13512
|
+
]);
|
|
13513
|
+
var ETHEREUM_WALLET_TYPES = /* @__PURE__ */ new Set([
|
|
13514
|
+
"metamask",
|
|
13515
|
+
"phantom-ethereum",
|
|
13516
|
+
"coinbase",
|
|
13517
|
+
"trust",
|
|
13518
|
+
"rainbow",
|
|
13519
|
+
"rabby",
|
|
13520
|
+
"okx"
|
|
13521
|
+
]);
|
|
13522
|
+
function walletTypeToChain(t12) {
|
|
13523
|
+
if (SOLANA_WALLET_TYPES.has(t12)) return "solana";
|
|
13524
|
+
if (ETHEREUM_WALLET_TYPES.has(t12)) return "ethereum";
|
|
13525
|
+
return void 0;
|
|
13526
|
+
}
|
|
13505
13527
|
function getUserDisconnectedWallet() {
|
|
13506
13528
|
if (typeof window === "undefined") return false;
|
|
13507
13529
|
try {
|
|
@@ -13521,26 +13543,35 @@ function setUserDisconnectedWallet(disconnected) {
|
|
|
13521
13543
|
} catch {
|
|
13522
13544
|
}
|
|
13523
13545
|
}
|
|
13524
|
-
function
|
|
13546
|
+
function getStoredWalletState() {
|
|
13525
13547
|
if (typeof window === "undefined") return void 0;
|
|
13526
13548
|
try {
|
|
13527
|
-
const
|
|
13528
|
-
if (
|
|
13549
|
+
const raw = localStorage.getItem(WALLET_STATE_STORAGE_KEY);
|
|
13550
|
+
if (!raw) return void 0;
|
|
13551
|
+
const chainType = walletTypeToChain(raw);
|
|
13552
|
+
if (!chainType) {
|
|
13553
|
+
localStorage.removeItem(WALLET_STATE_STORAGE_KEY);
|
|
13554
|
+
return void 0;
|
|
13555
|
+
}
|
|
13556
|
+
return { walletType: raw, chainType };
|
|
13529
13557
|
} catch {
|
|
13558
|
+
return void 0;
|
|
13530
13559
|
}
|
|
13531
|
-
return void 0;
|
|
13532
13560
|
}
|
|
13533
|
-
function
|
|
13561
|
+
function setStoredWalletState(walletType) {
|
|
13534
13562
|
if (typeof window === "undefined") return;
|
|
13563
|
+
if (!walletTypeToChain(walletType)) return;
|
|
13535
13564
|
try {
|
|
13536
|
-
localStorage.setItem(
|
|
13565
|
+
localStorage.setItem(WALLET_STATE_STORAGE_KEY, walletType);
|
|
13566
|
+
for (const key of LEGACY_WALLET_KEYS) localStorage.removeItem(key);
|
|
13537
13567
|
} catch {
|
|
13538
13568
|
}
|
|
13539
13569
|
}
|
|
13540
|
-
function
|
|
13570
|
+
function clearStoredWalletState() {
|
|
13541
13571
|
if (typeof window === "undefined") return;
|
|
13542
13572
|
try {
|
|
13543
|
-
localStorage.removeItem(
|
|
13573
|
+
localStorage.removeItem(WALLET_STATE_STORAGE_KEY);
|
|
13574
|
+
for (const key of LEGACY_WALLET_KEYS) localStorage.removeItem(key);
|
|
13544
13575
|
} catch {
|
|
13545
13576
|
}
|
|
13546
13577
|
}
|
|
@@ -14103,6 +14134,60 @@ function useDepositAddress(params) {
|
|
|
14103
14134
|
// 1s, 2s, 4s (max 10s)
|
|
14104
14135
|
});
|
|
14105
14136
|
}
|
|
14137
|
+
var normalize = (value) => value?.toLowerCase();
|
|
14138
|
+
function sourceTokenMatchesDefaultSource(token, defaultSource) {
|
|
14139
|
+
if (!token || !defaultSource.defaultSourceChainType || !defaultSource.defaultSourceChainId) {
|
|
14140
|
+
return false;
|
|
14141
|
+
}
|
|
14142
|
+
if (token.chain_type !== defaultSource.defaultSourceChainType || token.chain_id !== defaultSource.defaultSourceChainId) {
|
|
14143
|
+
return false;
|
|
14144
|
+
}
|
|
14145
|
+
if (defaultSource.defaultSourceTokenAddress && normalize(token.token_address) === normalize(defaultSource.defaultSourceTokenAddress)) {
|
|
14146
|
+
return true;
|
|
14147
|
+
}
|
|
14148
|
+
if (defaultSource.defaultSourceTokenAddress) {
|
|
14149
|
+
return false;
|
|
14150
|
+
}
|
|
14151
|
+
return !!defaultSource.defaultSourceSymbol && normalize(token.symbol) === normalize(defaultSource.defaultSourceSymbol);
|
|
14152
|
+
}
|
|
14153
|
+
function isDefaultSourceBalance(balance, defaultSource) {
|
|
14154
|
+
return isBalanceEligible(balance) && sourceTokenMatchesDefaultSource(getTokenFromBalance(balance), defaultSource);
|
|
14155
|
+
}
|
|
14156
|
+
function compareBalancesWithDefaultSource(a, b, defaultSource) {
|
|
14157
|
+
const aDefault = isDefaultSourceBalance(a, defaultSource);
|
|
14158
|
+
const bDefault = isDefaultSourceBalance(b, defaultSource);
|
|
14159
|
+
if (aDefault && !bDefault) return -1;
|
|
14160
|
+
if (!aDefault && bDefault) return 1;
|
|
14161
|
+
const aEligible = isBalanceEligible(a);
|
|
14162
|
+
const bEligible = isBalanceEligible(b);
|
|
14163
|
+
if (aEligible && !bEligible) return -1;
|
|
14164
|
+
if (!aEligible && bEligible) return 1;
|
|
14165
|
+
return 0;
|
|
14166
|
+
}
|
|
14167
|
+
function resolveDefaultSourceSymbol(supportedTokens, defaultSource) {
|
|
14168
|
+
if (!supportedTokens?.length || !defaultSource.defaultSourceChainType || !defaultSource.defaultSourceChainId) {
|
|
14169
|
+
return null;
|
|
14170
|
+
}
|
|
14171
|
+
if (defaultSource.defaultSourceTokenAddress) {
|
|
14172
|
+
for (const token of supportedTokens) {
|
|
14173
|
+
const matchingChain = token.chains.find(
|
|
14174
|
+
(chain) => chain.chain_type === defaultSource.defaultSourceChainType && chain.chain_id === defaultSource.defaultSourceChainId && normalize(chain.token_address) === normalize(defaultSource.defaultSourceTokenAddress)
|
|
14175
|
+
);
|
|
14176
|
+
if (matchingChain) return token.symbol;
|
|
14177
|
+
}
|
|
14178
|
+
}
|
|
14179
|
+
if (!defaultSource.defaultSourceSymbol) return null;
|
|
14180
|
+
for (const token of supportedTokens) {
|
|
14181
|
+
if (normalize(token.symbol) !== normalize(defaultSource.defaultSourceSymbol)) {
|
|
14182
|
+
continue;
|
|
14183
|
+
}
|
|
14184
|
+
const matchingChain = token.chains.find(
|
|
14185
|
+
(chain) => chain.chain_type === defaultSource.defaultSourceChainType && chain.chain_id === defaultSource.defaultSourceChainId
|
|
14186
|
+
);
|
|
14187
|
+
if (matchingChain) return token.symbol;
|
|
14188
|
+
}
|
|
14189
|
+
return null;
|
|
14190
|
+
}
|
|
14106
14191
|
function formatUsdFromBalancePercent(maxUsdAmount, percent) {
|
|
14107
14192
|
if (maxUsdAmount <= 0 || percent < 0) return "";
|
|
14108
14193
|
const raw = maxUsdAmount * percent / 100;
|
|
@@ -18616,70 +18701,106 @@ function identifyEthWallet(provider, hint) {
|
|
|
18616
18701
|
}
|
|
18617
18702
|
return { type: "metamask", name: "Wallet", icon: "metamask" };
|
|
18618
18703
|
}
|
|
18704
|
+
var EIP6963_ID_TO_WALLET_TYPE = {
|
|
18705
|
+
metamask: "metamask",
|
|
18706
|
+
phantom: "phantom-ethereum",
|
|
18707
|
+
coinbase: "coinbase",
|
|
18708
|
+
trust: "trust",
|
|
18709
|
+
rainbow: "rainbow",
|
|
18710
|
+
rabby: "rabby",
|
|
18711
|
+
okx: "okx"
|
|
18712
|
+
};
|
|
18713
|
+
function inferEthWalletType(provider, walletId) {
|
|
18714
|
+
if (EIP6963_ID_TO_WALLET_TYPE[walletId]) return EIP6963_ID_TO_WALLET_TYPE[walletId];
|
|
18715
|
+
const any = provider;
|
|
18716
|
+
if (provider.isPhantom) return "phantom-ethereum";
|
|
18717
|
+
if (any.isCoinbaseWallet) return "coinbase";
|
|
18718
|
+
if (any.isRabby) return "rabby";
|
|
18719
|
+
if (any.isTrust) return "trust";
|
|
18720
|
+
if (any.isRainbow) return "rainbow";
|
|
18721
|
+
if (any.isOkxWallet) return "okx";
|
|
18722
|
+
if (provider.isMetaMask && !provider.isPhantom) return "metamask";
|
|
18723
|
+
return null;
|
|
18724
|
+
}
|
|
18725
|
+
function solanaCandidate(provider, type, name, icon) {
|
|
18726
|
+
return {
|
|
18727
|
+
walletType: type,
|
|
18728
|
+
detect: async () => {
|
|
18729
|
+
if (!provider) return null;
|
|
18730
|
+
if (provider.isConnected && provider.publicKey) {
|
|
18731
|
+
return { type, name, address: provider.publicKey.toString(), icon };
|
|
18732
|
+
}
|
|
18733
|
+
try {
|
|
18734
|
+
const resp = await provider.connect({ onlyIfTrusted: true });
|
|
18735
|
+
if (resp.publicKey) {
|
|
18736
|
+
return { type, name, address: resp.publicKey.toString(), icon };
|
|
18737
|
+
}
|
|
18738
|
+
} catch {
|
|
18739
|
+
}
|
|
18740
|
+
return null;
|
|
18741
|
+
}
|
|
18742
|
+
};
|
|
18743
|
+
}
|
|
18744
|
+
function ethereumCandidate(provider, walletId) {
|
|
18745
|
+
return {
|
|
18746
|
+
walletType: inferEthWalletType(provider, walletId),
|
|
18747
|
+
detect: async () => {
|
|
18748
|
+
try {
|
|
18749
|
+
const accounts = await provider.request({ method: "eth_accounts" });
|
|
18750
|
+
if (!accounts?.length) return null;
|
|
18751
|
+
const resolved = identifyEthWallet(provider, walletId);
|
|
18752
|
+
return { ...resolved, address: accounts[0] };
|
|
18753
|
+
} catch {
|
|
18754
|
+
return null;
|
|
18755
|
+
}
|
|
18756
|
+
}
|
|
18757
|
+
};
|
|
18758
|
+
}
|
|
18759
|
+
function buildCandidates(win, chainType) {
|
|
18760
|
+
const candidates = [];
|
|
18761
|
+
if (!chainType || chainType === "solana") {
|
|
18762
|
+
candidates.push(
|
|
18763
|
+
solanaCandidate(win.phantom?.solana, "phantom-solana", "Phantom", "phantom"),
|
|
18764
|
+
solanaCandidate(win.solflare, "solflare", "Solflare", "solflare"),
|
|
18765
|
+
solanaCandidate(win.backpack, "backpack", "Backpack", "backpack"),
|
|
18766
|
+
solanaCandidate(win.glow, "glow", "Glow", "glow")
|
|
18767
|
+
);
|
|
18768
|
+
}
|
|
18769
|
+
if (!chainType || chainType === "ethereum") {
|
|
18770
|
+
const seen = /* @__PURE__ */ new Set();
|
|
18771
|
+
const addEth = (provider, walletId) => {
|
|
18772
|
+
if (!provider || seen.has(provider)) return;
|
|
18773
|
+
seen.add(provider);
|
|
18774
|
+
candidates.push(ethereumCandidate(provider, walletId));
|
|
18775
|
+
};
|
|
18776
|
+
for (const { provider, walletId } of getEip6963Providers()) {
|
|
18777
|
+
addEth(
|
|
18778
|
+
provider,
|
|
18779
|
+
walletId === "unknown" ? "default" : walletId
|
|
18780
|
+
);
|
|
18781
|
+
}
|
|
18782
|
+
addEth(win.phantom?.ethereum, "phantom");
|
|
18783
|
+
addEth(win.coinbaseWalletExtension, "coinbase");
|
|
18784
|
+
addEth(win.okxwallet, "okx");
|
|
18785
|
+
addEth(win.trustwallet?.ethereum, "trust");
|
|
18786
|
+
addEth(win.ethereum, "default");
|
|
18787
|
+
}
|
|
18788
|
+
return candidates;
|
|
18789
|
+
}
|
|
18619
18790
|
async function detectConnectedBrowserWallet(chainType) {
|
|
18620
18791
|
if (typeof window === "undefined") return null;
|
|
18621
18792
|
if (getUserDisconnectedWallet()) return null;
|
|
18622
18793
|
try {
|
|
18623
18794
|
const win = window;
|
|
18624
|
-
|
|
18625
|
-
|
|
18626
|
-
|
|
18627
|
-
|
|
18628
|
-
|
|
18629
|
-
|
|
18630
|
-
|
|
18631
|
-
|
|
18632
|
-
|
|
18633
|
-
return { type, name, address: resp.publicKey.toString(), icon };
|
|
18634
|
-
}
|
|
18635
|
-
} catch {
|
|
18636
|
-
}
|
|
18637
|
-
return null;
|
|
18638
|
-
};
|
|
18639
|
-
const solanaCandidates = [
|
|
18640
|
-
[win.phantom?.solana, "phantom-solana", "Phantom", "phantom"],
|
|
18641
|
-
[win.solflare, "solflare", "Solflare", "solflare"],
|
|
18642
|
-
[win.backpack, "backpack", "Backpack", "backpack"],
|
|
18643
|
-
[win.glow, "glow", "Glow", "glow"]
|
|
18644
|
-
];
|
|
18645
|
-
for (const [provider, type, name, icon] of solanaCandidates) {
|
|
18646
|
-
const found = await trySilentSolana(provider, type, name, icon);
|
|
18647
|
-
if (found) return found;
|
|
18648
|
-
}
|
|
18649
|
-
}
|
|
18650
|
-
if (!chainType || chainType === "ethereum") {
|
|
18651
|
-
const allProviders = [];
|
|
18652
|
-
const eip6963 = getEip6963Providers();
|
|
18653
|
-
for (const { provider, walletId } of eip6963) {
|
|
18654
|
-
allProviders.push({
|
|
18655
|
-
provider,
|
|
18656
|
-
walletId: walletId === "unknown" ? "default" : walletId
|
|
18657
|
-
});
|
|
18658
|
-
}
|
|
18659
|
-
if (allProviders.length === 0) {
|
|
18660
|
-
if (win.phantom?.ethereum) {
|
|
18661
|
-
allProviders.push({ provider: win.phantom.ethereum, walletId: "phantom" });
|
|
18662
|
-
}
|
|
18663
|
-
if (win.okxwallet) {
|
|
18664
|
-
allProviders.push({ provider: win.okxwallet, walletId: "okx" });
|
|
18665
|
-
}
|
|
18666
|
-
if (win.coinbaseWalletExtension) {
|
|
18667
|
-
allProviders.push({ provider: win.coinbaseWalletExtension, walletId: "coinbase" });
|
|
18668
|
-
}
|
|
18669
|
-
if (win.ethereum && !allProviders.some((p) => p.provider === win.ethereum)) {
|
|
18670
|
-
allProviders.push({ provider: win.ethereum, walletId: "default" });
|
|
18671
|
-
}
|
|
18672
|
-
}
|
|
18673
|
-
for (const { provider, walletId } of allProviders) {
|
|
18674
|
-
if (!provider) continue;
|
|
18675
|
-
try {
|
|
18676
|
-
const accounts = await provider.request({ method: "eth_accounts" });
|
|
18677
|
-
if (!accounts || accounts.length === 0) continue;
|
|
18678
|
-
const resolved = identifyEthWallet(provider, walletId);
|
|
18679
|
-
return { ...resolved, address: accounts[0] };
|
|
18680
|
-
} catch {
|
|
18681
|
-
}
|
|
18682
|
-
}
|
|
18795
|
+
const candidates = buildCandidates(win, chainType);
|
|
18796
|
+
const preferred = getStoredWalletState();
|
|
18797
|
+
if (preferred && (!chainType || preferred.chainType === chainType)) {
|
|
18798
|
+
const idx = candidates.findIndex((c) => c.walletType === preferred.walletType);
|
|
18799
|
+
if (idx > 0) candidates.unshift(...candidates.splice(idx, 1));
|
|
18800
|
+
}
|
|
18801
|
+
for (const c of candidates) {
|
|
18802
|
+
const found = await c.detect();
|
|
18803
|
+
if (found) return found;
|
|
18683
18804
|
}
|
|
18684
18805
|
} catch (error) {
|
|
18685
18806
|
console.error("[detectConnectedBrowserWallet] detection error:", error);
|
|
@@ -20825,6 +20946,7 @@ function BrowserWalletButton({
|
|
|
20825
20946
|
if (solanaProvider?.isPhantom) {
|
|
20826
20947
|
const { publicKey } = await solanaProvider.connect();
|
|
20827
20948
|
setUserDisconnectedWallet(false);
|
|
20949
|
+
setStoredWalletState("phantom-solana");
|
|
20828
20950
|
setWallet({
|
|
20829
20951
|
type: "phantom-solana",
|
|
20830
20952
|
name: "Phantom",
|
|
@@ -20844,8 +20966,10 @@ function BrowserWalletButton({
|
|
|
20844
20966
|
if (accounts && accounts.length > 0) {
|
|
20845
20967
|
setUserDisconnectedWallet(false);
|
|
20846
20968
|
const isPhantom = ethProvider.isPhantom;
|
|
20969
|
+
const walletType = isPhantom ? "phantom-ethereum" : "metamask";
|
|
20970
|
+
setStoredWalletState(walletType);
|
|
20847
20971
|
setWallet({
|
|
20848
|
-
type:
|
|
20972
|
+
type: walletType,
|
|
20849
20973
|
name: isPhantom ? "Phantom" : "MetaMask",
|
|
20850
20974
|
address: accounts[0],
|
|
20851
20975
|
icon: isPhantom ? "phantom" : "metamask"
|
|
@@ -21155,7 +21279,11 @@ function CoinbaseConnect({
|
|
|
21155
21279
|
onDisconnect,
|
|
21156
21280
|
skipToHoldings,
|
|
21157
21281
|
canGoBack = true,
|
|
21158
|
-
onExecutionsChange
|
|
21282
|
+
onExecutionsChange,
|
|
21283
|
+
defaultSourceChainType,
|
|
21284
|
+
defaultSourceChainId,
|
|
21285
|
+
defaultSourceTokenAddress,
|
|
21286
|
+
defaultSourceSymbol
|
|
21159
21287
|
}) {
|
|
21160
21288
|
const { colors: colors2, fonts, components } = useTheme();
|
|
21161
21289
|
const { projectConfig } = useProjectConfig({ publishableKey });
|
|
@@ -21220,6 +21348,21 @@ function CoinbaseConnect({
|
|
|
21220
21348
|
params: defaultTokenParams,
|
|
21221
21349
|
publishableKey
|
|
21222
21350
|
});
|
|
21351
|
+
const defaultSourceCurrency = (0, import_react20.useMemo)(
|
|
21352
|
+
() => resolveDefaultSourceSymbol(supportedTokensData?.data, {
|
|
21353
|
+
defaultSourceChainType,
|
|
21354
|
+
defaultSourceChainId,
|
|
21355
|
+
defaultSourceTokenAddress,
|
|
21356
|
+
defaultSourceSymbol
|
|
21357
|
+
})?.toLowerCase() ?? null,
|
|
21358
|
+
[
|
|
21359
|
+
supportedTokensData,
|
|
21360
|
+
defaultSourceChainType,
|
|
21361
|
+
defaultSourceChainId,
|
|
21362
|
+
defaultSourceTokenAddress,
|
|
21363
|
+
defaultSourceSymbol
|
|
21364
|
+
]
|
|
21365
|
+
);
|
|
21223
21366
|
const sortedHoldings = (0, import_react20.useMemo)(() => {
|
|
21224
21367
|
const supported = [];
|
|
21225
21368
|
const unsupported = [];
|
|
@@ -21229,13 +21372,42 @@ function CoinbaseConnect({
|
|
|
21229
21372
|
if (isSupported) supported.push(account);
|
|
21230
21373
|
else unsupported.push(account);
|
|
21231
21374
|
});
|
|
21375
|
+
if (defaultSourceCurrency) {
|
|
21376
|
+
const defaultIndex = supported.findIndex(
|
|
21377
|
+
(account) => account.currency.toLowerCase() === defaultSourceCurrency
|
|
21378
|
+
);
|
|
21379
|
+
if (defaultIndex > 0) {
|
|
21380
|
+
const [defaultHolding] = supported.splice(defaultIndex, 1);
|
|
21381
|
+
supported.unshift(defaultHolding);
|
|
21382
|
+
}
|
|
21383
|
+
}
|
|
21232
21384
|
return [...supported, ...unsupported];
|
|
21233
|
-
}, [
|
|
21385
|
+
}, [
|
|
21386
|
+
holdings,
|
|
21387
|
+
supportedSymbols,
|
|
21388
|
+
exchangeSupportedCurrencies,
|
|
21389
|
+
defaultSourceCurrency
|
|
21390
|
+
]);
|
|
21234
21391
|
const selectedHoldingIsSupported = (0, import_react20.useMemo)(() => {
|
|
21235
21392
|
if (!selectedHolding) return false;
|
|
21236
21393
|
const currencyLower = selectedHolding.currency.toLowerCase();
|
|
21237
21394
|
return (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
|
|
21238
21395
|
}, [selectedHolding, supportedSymbols, exchangeSupportedCurrencies]);
|
|
21396
|
+
(0, import_react20.useEffect)(() => {
|
|
21397
|
+
if (!defaultSourceCurrency || selectedHolding) return;
|
|
21398
|
+
const defaultHolding = sortedHoldings.find((account) => {
|
|
21399
|
+
const currencyLower = account.currency.toLowerCase();
|
|
21400
|
+
return currencyLower === defaultSourceCurrency && (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
|
|
21401
|
+
});
|
|
21402
|
+
if (!defaultHolding) return;
|
|
21403
|
+
setSelectedHolding(defaultHolding);
|
|
21404
|
+
}, [
|
|
21405
|
+
defaultSourceCurrency,
|
|
21406
|
+
selectedHolding,
|
|
21407
|
+
sortedHoldings,
|
|
21408
|
+
supportedSymbols,
|
|
21409
|
+
exchangeSupportedCurrencies
|
|
21410
|
+
]);
|
|
21239
21411
|
const exchangeName = selectedExchange?.service_provider_display_name || "Exchange";
|
|
21240
21412
|
const {
|
|
21241
21413
|
executions: depositExecutions,
|
|
@@ -26401,6 +26573,19 @@ var WALLET_DEFINITIONS = [
|
|
|
26401
26573
|
{ id: "backpack", name: "Backpack", networks: ["solana"], installUrl: "https://backpack.app/" },
|
|
26402
26574
|
{ id: "glow", name: "Glow", networks: ["solana"], installUrl: "https://glow.app/" }
|
|
26403
26575
|
];
|
|
26576
|
+
function normalizeTokenAddress(address) {
|
|
26577
|
+
const normalized = (address ?? "").toLowerCase();
|
|
26578
|
+
if (normalized === "" || normalized === "native" || normalized === "0x0000000000000000000000000000000000000000") {
|
|
26579
|
+
return "native";
|
|
26580
|
+
}
|
|
26581
|
+
return normalized;
|
|
26582
|
+
}
|
|
26583
|
+
function balancesRepresentSameToken(a, b) {
|
|
26584
|
+
const tokenA = getTokenFromBalance(a);
|
|
26585
|
+
const tokenB = getTokenFromBalance(b);
|
|
26586
|
+
if (!tokenA || !tokenB) return false;
|
|
26587
|
+
return tokenA.chain_type === tokenB.chain_type && tokenA.chain_id === tokenB.chain_id && normalizeTokenAddress(tokenA.token_address) === normalizeTokenAddress(tokenB.token_address);
|
|
26588
|
+
}
|
|
26404
26589
|
function getSolanaProviders() {
|
|
26405
26590
|
if (typeof window === "undefined") return {};
|
|
26406
26591
|
const win = window;
|
|
@@ -26543,6 +26728,10 @@ function WalletConnect({
|
|
|
26543
26728
|
checkoutRemainingBaseUnits,
|
|
26544
26729
|
stablecoinParity = false,
|
|
26545
26730
|
productType,
|
|
26731
|
+
defaultSourceChainType,
|
|
26732
|
+
defaultSourceChainId,
|
|
26733
|
+
defaultSourceTokenAddress,
|
|
26734
|
+
defaultSourceSymbol,
|
|
26546
26735
|
onBack: parentOnBack,
|
|
26547
26736
|
onClose,
|
|
26548
26737
|
canGoBack = true,
|
|
@@ -26703,6 +26892,7 @@ function WalletConnect({
|
|
|
26703
26892
|
metamask: "metamask"
|
|
26704
26893
|
};
|
|
26705
26894
|
const walletType = walletIdToType[wallet.id] || "metamask";
|
|
26895
|
+
setStoredWalletState(walletType);
|
|
26706
26896
|
connectedInfo = { type: walletType, name: wallet.name, address: accounts[0], icon: wallet.id };
|
|
26707
26897
|
} else {
|
|
26708
26898
|
const solProviders = getSolanaProviders();
|
|
@@ -26731,6 +26921,7 @@ function WalletConnect({
|
|
|
26731
26921
|
const response = await provider.connect();
|
|
26732
26922
|
setUserDisconnectedWallet(false);
|
|
26733
26923
|
const walletType = wallet.id === "solflare" ? "solflare" : wallet.id === "backpack" ? "backpack" : wallet.id === "glow" ? "glow" : "phantom-solana";
|
|
26924
|
+
setStoredWalletState(walletType);
|
|
26734
26925
|
connectedInfo = { type: walletType, name: wallet.name, address: response.publicKey.toString(), icon: wallet.id };
|
|
26735
26926
|
}
|
|
26736
26927
|
const walletChainType = network === "solana" ? "solana" : "ethereum";
|
|
@@ -26845,18 +27036,33 @@ function WalletConnect({
|
|
|
26845
27036
|
getAddressBalances(activeWalletInfo.address, sct, publishableKey).then((response) => {
|
|
26846
27037
|
if (cancelled) return;
|
|
26847
27038
|
const nonZero = response.balances.filter((b) => b.amount !== "0");
|
|
26848
|
-
const
|
|
26849
|
-
|
|
26850
|
-
|
|
26851
|
-
|
|
26852
|
-
|
|
26853
|
-
|
|
26854
|
-
|
|
27039
|
+
const defaultSource = {
|
|
27040
|
+
defaultSourceChainType,
|
|
27041
|
+
defaultSourceChainId,
|
|
27042
|
+
defaultSourceTokenAddress,
|
|
27043
|
+
defaultSourceSymbol
|
|
27044
|
+
};
|
|
27045
|
+
const sorted = [...nonZero].sort(
|
|
27046
|
+
(a, b) => compareBalancesWithDefaultSource(a, b, defaultSource)
|
|
27047
|
+
);
|
|
26855
27048
|
setBalances(sorted);
|
|
26856
27049
|
const totalUsd = nonZero.reduce((sum, b) => b.amount_usd ? sum + parseFloat(b.amount_usd) : sum, 0);
|
|
26857
27050
|
if (totalUsd > 0) setTotalBalanceUsd(totalUsd.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 }));
|
|
26858
27051
|
const eligible = sorted.filter(isBalanceEligible);
|
|
26859
|
-
|
|
27052
|
+
const defaultBalance = sorted.find(
|
|
27053
|
+
(balance) => isDefaultSourceBalance(balance, defaultSource)
|
|
27054
|
+
);
|
|
27055
|
+
setSelectedBalance((current) => {
|
|
27056
|
+
if (current) {
|
|
27057
|
+
const currentInNewBalances = sorted.find(
|
|
27058
|
+
(balance) => balancesRepresentSameToken(balance, current)
|
|
27059
|
+
);
|
|
27060
|
+
if (currentInNewBalances) return currentInNewBalances;
|
|
27061
|
+
}
|
|
27062
|
+
if (defaultBalance) return defaultBalance;
|
|
27063
|
+
if (eligible.length === 1) return eligible[0];
|
|
27064
|
+
return null;
|
|
27065
|
+
});
|
|
26860
27066
|
}).catch((err) => {
|
|
26861
27067
|
if (!cancelled) {
|
|
26862
27068
|
console.error("[WalletConnect] Error fetching balances:", err);
|
|
@@ -26868,7 +27074,15 @@ function WalletConnect({
|
|
|
26868
27074
|
return () => {
|
|
26869
27075
|
cancelled = true;
|
|
26870
27076
|
};
|
|
26871
|
-
}, [
|
|
27077
|
+
}, [
|
|
27078
|
+
activeWalletInfo?.address,
|
|
27079
|
+
activeDepositWallet?.chain_type,
|
|
27080
|
+
publishableKey,
|
|
27081
|
+
defaultSourceChainType,
|
|
27082
|
+
defaultSourceChainId,
|
|
27083
|
+
defaultSourceTokenAddress,
|
|
27084
|
+
defaultSourceSymbol
|
|
27085
|
+
]);
|
|
26872
27086
|
const usdToTokenRate = React302.useMemo(() => {
|
|
26873
27087
|
if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
|
|
26874
27088
|
const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
|
|
@@ -27223,16 +27437,17 @@ function DepositModal({
|
|
|
27223
27437
|
defaultSourceChainId,
|
|
27224
27438
|
defaultSourceTokenAddress,
|
|
27225
27439
|
defaultSourceSymbol,
|
|
27226
|
-
hideDepositTracker
|
|
27440
|
+
hideDepositTracker,
|
|
27227
27441
|
showBalanceHeader = false,
|
|
27228
27442
|
transferInputVariant = "double_input",
|
|
27229
27443
|
depositConfirmationMode = "auto_ui",
|
|
27230
|
-
|
|
27444
|
+
enableTransferCrypto,
|
|
27445
|
+
enableConnectWallet,
|
|
27231
27446
|
browserWalletAmountQuickSelect = "percentage",
|
|
27232
27447
|
enablePayWithExchange,
|
|
27233
27448
|
enableFiatOnramp,
|
|
27234
|
-
enableConnectExchange
|
|
27235
|
-
enableCashApp
|
|
27449
|
+
enableConnectExchange,
|
|
27450
|
+
enableCashApp,
|
|
27236
27451
|
hideDepositFlowInfo = false,
|
|
27237
27452
|
hideDisplayDescription = false,
|
|
27238
27453
|
onDepositSuccess,
|
|
@@ -27250,12 +27465,13 @@ function DepositModal({
|
|
|
27250
27465
|
const { colors: colors2, fonts, components } = useTheme();
|
|
27251
27466
|
const effectiveInitialScreen = (0, import_react8.useMemo)(() => {
|
|
27252
27467
|
const s = initialScreen ?? "main";
|
|
27253
|
-
if (s === "tracker" && hideDepositTracker) return "main";
|
|
27254
|
-
if (s === "cashapp" &&
|
|
27468
|
+
if (s === "tracker" && hideDepositTracker === true) return "main";
|
|
27469
|
+
if (s === "cashapp" && enableCashApp === false) return "main";
|
|
27255
27470
|
if (s === "card" && enableFiatOnramp === false) return "main";
|
|
27256
27471
|
if (s === "pay_with_exchange") return enablePayWithExchange === false ? "main" : "exchange";
|
|
27257
|
-
if (s === "exchange_connect")
|
|
27258
|
-
|
|
27472
|
+
if (s === "exchange_connect")
|
|
27473
|
+
return enableConnectExchange === false ? "main" : "coinbase_connect";
|
|
27474
|
+
if (s === "wallet_connect") return enableConnectWallet === false ? "main" : "wallet_connect";
|
|
27259
27475
|
return s;
|
|
27260
27476
|
}, [
|
|
27261
27477
|
initialScreen,
|
|
@@ -27284,26 +27500,37 @@ function DepositModal({
|
|
|
27284
27500
|
const [browserWalletModalOpen, setBrowserWalletModalOpen] = (0, import_react8.useState)(false);
|
|
27285
27501
|
const [browserWalletInfo, setBrowserWalletInfo] = (0, import_react8.useState)(null);
|
|
27286
27502
|
const [walletSelectionModalOpen, setWalletSelectionModalOpen] = (0, import_react8.useState)(false);
|
|
27287
|
-
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react8.useState)(() =>
|
|
27503
|
+
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react8.useState)(() => getStoredWalletState()?.chainType);
|
|
27288
27504
|
const [quotesCount, setQuotesCount] = (0, import_react8.useState)(0);
|
|
27289
27505
|
const [allExecutions, setAllExecutions] = (0, import_react8.useState)([]);
|
|
27290
27506
|
const [selectedExecution, setSelectedExecution] = (0, import_react8.useState)(null);
|
|
27291
27507
|
const [depositExecutions, setDepositExecutions] = (0, import_react8.useState)([]);
|
|
27292
27508
|
const isMobileView = useIsMobileViewport();
|
|
27509
|
+
const { projectConfig } = useProjectConfig({
|
|
27510
|
+
publishableKey,
|
|
27511
|
+
enabled: open
|
|
27512
|
+
});
|
|
27513
|
+
const showTransferCrypto = enableTransferCrypto ?? projectConfig?.transfer_crypto?.enabled ?? true;
|
|
27514
|
+
const showConnectWallet = enableConnectWallet ?? projectConfig?.connect_wallet?.enabled ?? true;
|
|
27515
|
+
const showPayWithExchange = enablePayWithExchange ?? projectConfig?.pay_with_exchange?.enabled ?? true;
|
|
27516
|
+
const showFiatOnramp = enableFiatOnramp ?? projectConfig?.fiat_onramp?.enabled ?? true;
|
|
27517
|
+
const showConnectExchange = enableConnectExchange ?? projectConfig?.connect_exchange?.enabled ?? true;
|
|
27518
|
+
const showCashApp = enableCashApp ?? projectConfig?.cash_app?.enabled ?? true;
|
|
27519
|
+
const showDepositTracker = hideDepositTracker ? false : projectConfig?.deposit_tracker?.enabled ?? true;
|
|
27293
27520
|
const [integrationExchanges, setIntegrationExchanges] = (0, import_react8.useState)([]);
|
|
27294
27521
|
(0, import_react8.useEffect)(() => {
|
|
27295
|
-
if (!
|
|
27522
|
+
if (!showConnectExchange || !open) return;
|
|
27296
27523
|
getIntegrationExchanges(publishableKey).then((res) => setIntegrationExchanges(res.data)).catch(() => {
|
|
27297
27524
|
});
|
|
27298
|
-
}, [
|
|
27525
|
+
}, [showConnectExchange, open, publishableKey]);
|
|
27299
27526
|
const [connectedExchange, setConnectedExchange] = (0, import_react8.useState)(() => {
|
|
27300
|
-
if (!
|
|
27527
|
+
if (!showConnectExchange) return null;
|
|
27301
27528
|
const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
|
|
27302
27529
|
if (!stored) return null;
|
|
27303
27530
|
return { name: "Coinbase", iconUrl: void 0, balanceUsd: null, isLoading: true };
|
|
27304
27531
|
});
|
|
27305
27532
|
(0, import_react8.useEffect)(() => {
|
|
27306
|
-
if (!
|
|
27533
|
+
if (!showConnectExchange || !open || view !== "main") return;
|
|
27307
27534
|
const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
|
|
27308
27535
|
if (!stored) {
|
|
27309
27536
|
setConnectedExchange(null);
|
|
@@ -27338,7 +27565,7 @@ function DepositModal({
|
|
|
27338
27565
|
setConnectedExchange(null);
|
|
27339
27566
|
}
|
|
27340
27567
|
});
|
|
27341
|
-
}, [
|
|
27568
|
+
}, [showConnectExchange, open, view, publishableKey]);
|
|
27342
27569
|
(0, import_react8.useEffect)(() => {
|
|
27343
27570
|
if (!connectedExchange || integrationExchanges.length === 0) return;
|
|
27344
27571
|
const cbExchange = integrationExchanges.find(
|
|
@@ -27377,18 +27604,33 @@ function DepositModal({
|
|
|
27377
27604
|
setResolvedTheme(theme);
|
|
27378
27605
|
}
|
|
27379
27606
|
}, [theme]);
|
|
27380
|
-
const { projectConfig } = useProjectConfig({
|
|
27381
|
-
publishableKey,
|
|
27382
|
-
enabled: open
|
|
27383
|
-
});
|
|
27384
|
-
const showPayWithExchange = enablePayWithExchange ?? projectConfig?.pay_with_exchange?.enabled ?? true;
|
|
27385
|
-
const showFiatOnramp = enableFiatOnramp ?? projectConfig?.fiat_onramp?.enabled ?? true;
|
|
27386
27607
|
(0, import_react8.useEffect)(() => {
|
|
27387
27608
|
if (view === "card" && !showFiatOnramp) {
|
|
27388
27609
|
setView("main");
|
|
27389
27610
|
setCardView("amount");
|
|
27611
|
+
} else if (view === "transfer" && !showTransferCrypto) {
|
|
27612
|
+
setView("main");
|
|
27613
|
+
} else if (view === "exchange" && !showPayWithExchange) {
|
|
27614
|
+
setView("main");
|
|
27615
|
+
} else if (view === "cashapp" && !showCashApp) {
|
|
27616
|
+
setView("main");
|
|
27617
|
+
} else if (view === "tracker" && !showDepositTracker) {
|
|
27618
|
+
setView("main");
|
|
27619
|
+
} else if (view === "coinbase_connect" && !showConnectExchange) {
|
|
27620
|
+
setView("main");
|
|
27621
|
+
} else if (view === "wallet_connect" && !showConnectWallet) {
|
|
27622
|
+
setView("main");
|
|
27390
27623
|
}
|
|
27391
|
-
}, [
|
|
27624
|
+
}, [
|
|
27625
|
+
view,
|
|
27626
|
+
showFiatOnramp,
|
|
27627
|
+
showTransferCrypto,
|
|
27628
|
+
showPayWithExchange,
|
|
27629
|
+
showCashApp,
|
|
27630
|
+
showDepositTracker,
|
|
27631
|
+
showConnectExchange,
|
|
27632
|
+
showConnectWallet
|
|
27633
|
+
]);
|
|
27392
27634
|
(0, import_react8.useEffect)(() => {
|
|
27393
27635
|
if (view === "exchange" && !showPayWithExchange) {
|
|
27394
27636
|
setView("main");
|
|
@@ -27478,7 +27720,7 @@ function DepositModal({
|
|
|
27478
27720
|
depositPrerequisiteBody = standaloneNeedsDepositPrereq ? /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(SkeletonButton, { variant: "with-icons" }) : /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [
|
|
27479
27721
|
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(SkeletonButton, { variant: "with-icons" }),
|
|
27480
27722
|
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(SkeletonButton, { variant: "with-icons" }),
|
|
27481
|
-
|
|
27723
|
+
showDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(SkeletonButton, {})
|
|
27482
27724
|
] });
|
|
27483
27725
|
} else if (countryError) {
|
|
27484
27726
|
depositPrerequisiteBody = /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-8 uf-px-4 uf-text-center", children: [
|
|
@@ -27510,7 +27752,7 @@ function DepositModal({
|
|
|
27510
27752
|
const themeClass = resolvedTheme === "dark" ? "uf-dark" : "";
|
|
27511
27753
|
const handleWalletDisconnect = () => {
|
|
27512
27754
|
setUserDisconnectedWallet(true);
|
|
27513
|
-
|
|
27755
|
+
clearStoredWalletState();
|
|
27514
27756
|
setBrowserWalletChainType(void 0);
|
|
27515
27757
|
setBrowserWalletInfo(null);
|
|
27516
27758
|
setBrowserWalletModalOpen(false);
|
|
@@ -27588,7 +27830,7 @@ function DepositModal({
|
|
|
27588
27830
|
};
|
|
27589
27831
|
const handleBrowserWalletClick = (walletInfo) => {
|
|
27590
27832
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
27591
|
-
|
|
27833
|
+
setStoredWalletState(walletInfo.type);
|
|
27592
27834
|
setBrowserWalletChainType(walletChainType);
|
|
27593
27835
|
const matchingDepositWallet = wallets.find(
|
|
27594
27836
|
(w) => w.chain_type === walletChainType
|
|
@@ -27619,7 +27861,7 @@ function DepositModal({
|
|
|
27619
27861
|
};
|
|
27620
27862
|
const handleWalletConnected = (walletInfo) => {
|
|
27621
27863
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
27622
|
-
|
|
27864
|
+
setStoredWalletState(walletInfo.type);
|
|
27623
27865
|
setBrowserWalletChainType(walletChainType);
|
|
27624
27866
|
const matchingDepositWallet = wallets.find(
|
|
27625
27867
|
(w) => w.chain_type === walletChainType
|
|
@@ -27686,7 +27928,7 @@ function DepositModal({
|
|
|
27686
27928
|
),
|
|
27687
27929
|
/* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
27688
27930
|
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "uf-space-y-3", children: depositPrerequisiteBody ?? /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [
|
|
27689
|
-
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
27931
|
+
showTransferCrypto && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
27690
27932
|
TransferCryptoButton,
|
|
27691
27933
|
{
|
|
27692
27934
|
onClick: () => setView("transfer"),
|
|
@@ -27695,7 +27937,7 @@ function DepositModal({
|
|
|
27695
27937
|
featuredTokens: projectConfig?.transfer_crypto.networks
|
|
27696
27938
|
}
|
|
27697
27939
|
),
|
|
27698
|
-
|
|
27940
|
+
showConnectWallet && !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
27699
27941
|
BrowserWalletButton,
|
|
27700
27942
|
{
|
|
27701
27943
|
onClick: handleBrowserWalletClick,
|
|
@@ -27725,7 +27967,7 @@ function DepositModal({
|
|
|
27725
27967
|
loading: exchangesLoading
|
|
27726
27968
|
}
|
|
27727
27969
|
),
|
|
27728
|
-
|
|
27970
|
+
showConnectExchange && connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
27729
27971
|
ConnectExchangeButton,
|
|
27730
27972
|
{
|
|
27731
27973
|
onClick: () => {
|
|
@@ -27739,7 +27981,7 @@ function DepositModal({
|
|
|
27739
27981
|
connectedExchange
|
|
27740
27982
|
}
|
|
27741
27983
|
),
|
|
27742
|
-
|
|
27984
|
+
showConnectExchange && !connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
27743
27985
|
ConnectExchangeButton,
|
|
27744
27986
|
{
|
|
27745
27987
|
onClick: () => {
|
|
@@ -27751,7 +27993,7 @@ function DepositModal({
|
|
|
27751
27993
|
exchanges: integrationExchanges
|
|
27752
27994
|
}
|
|
27753
27995
|
),
|
|
27754
|
-
|
|
27996
|
+
showCashApp && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
27755
27997
|
CashAppButton,
|
|
27756
27998
|
{
|
|
27757
27999
|
onClick: () => setView("cashapp"),
|
|
@@ -27760,7 +28002,7 @@ function DepositModal({
|
|
|
27760
28002
|
iconUrl: projectConfig?.asset_cdn_url ? `${projectConfig.asset_cdn_url}/api/public/icons/onramps/svg/cashapp.svg` : void 0
|
|
27761
28003
|
}
|
|
27762
28004
|
),
|
|
27763
|
-
|
|
28005
|
+
showDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
27764
28006
|
DepositTrackerButton,
|
|
27765
28007
|
{
|
|
27766
28008
|
onClick: () => {
|
|
@@ -27965,7 +28207,11 @@ function DepositModal({
|
|
|
27965
28207
|
onDisconnect: handleExchangeDisconnect,
|
|
27966
28208
|
skipToHoldings: coinbaseSkipToHoldings,
|
|
27967
28209
|
canGoBack: sessionOpenedFromMenu,
|
|
27968
|
-
onExecutionsChange: setDepositExecutions
|
|
28210
|
+
onExecutionsChange: setDepositExecutions,
|
|
28211
|
+
defaultSourceChainType,
|
|
28212
|
+
defaultSourceChainId,
|
|
28213
|
+
defaultSourceTokenAddress,
|
|
28214
|
+
defaultSourceSymbol
|
|
27969
28215
|
}
|
|
27970
28216
|
),
|
|
27971
28217
|
depositPoweredByFooter
|
|
@@ -27998,11 +28244,15 @@ function DepositModal({
|
|
|
27998
28244
|
onWalletDisconnect: handleWalletDisconnect,
|
|
27999
28245
|
onWalletConnected: (info, dw) => {
|
|
28000
28246
|
setBrowserWalletInfo({ ...info, depositWallet: dw });
|
|
28001
|
-
|
|
28247
|
+
setStoredWalletState(info.type);
|
|
28002
28248
|
setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
|
|
28003
28249
|
},
|
|
28004
28250
|
onBack: handleBack,
|
|
28005
28251
|
onClose: handleClose,
|
|
28252
|
+
defaultSourceChainType,
|
|
28253
|
+
defaultSourceChainId,
|
|
28254
|
+
defaultSourceTokenAddress,
|
|
28255
|
+
defaultSourceSymbol,
|
|
28006
28256
|
canGoBack: sessionOpenedFromMenu,
|
|
28007
28257
|
depositWalletsLoading: walletsLoading
|
|
28008
28258
|
}
|
|
@@ -28105,7 +28355,8 @@ function CheckoutModal({
|
|
|
28105
28355
|
clientSecret,
|
|
28106
28356
|
publishableKey,
|
|
28107
28357
|
modalTitle,
|
|
28108
|
-
|
|
28358
|
+
enableTransferCrypto,
|
|
28359
|
+
enableConnectWallet,
|
|
28109
28360
|
defaultSourceChainType,
|
|
28110
28361
|
defaultSourceChainId,
|
|
28111
28362
|
defaultSourceTokenAddress,
|
|
@@ -28122,7 +28373,7 @@ function CheckoutModal({
|
|
|
28122
28373
|
const [browserWalletModalOpen, setBrowserWalletModalOpen] = (0, import_react28.useState)(false);
|
|
28123
28374
|
const [browserWalletInfo, setBrowserWalletInfo] = (0, import_react28.useState)(null);
|
|
28124
28375
|
const [walletSelectionModalOpen, setWalletSelectionModalOpen] = (0, import_react28.useState)(false);
|
|
28125
|
-
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react28.useState)(() =>
|
|
28376
|
+
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react28.useState)(() => getStoredWalletState()?.chainType);
|
|
28126
28377
|
const isMobileView = useIsMobileViewport();
|
|
28127
28378
|
const [resolvedTheme, setResolvedTheme] = (0, import_react28.useState)(
|
|
28128
28379
|
theme === "auto" ? "dark" : theme
|
|
@@ -28155,6 +28406,15 @@ function CheckoutModal({
|
|
|
28155
28406
|
publishableKey,
|
|
28156
28407
|
enabled: open
|
|
28157
28408
|
});
|
|
28409
|
+
const showTransferCrypto = enableTransferCrypto ?? projectConfig?.transfer_crypto?.enabled ?? true;
|
|
28410
|
+
const showConnectWallet = enableConnectWallet ?? projectConfig?.connect_wallet?.enabled ?? true;
|
|
28411
|
+
(0, import_react28.useEffect)(() => {
|
|
28412
|
+
if (view === "transfer" && !showTransferCrypto) {
|
|
28413
|
+
setView("main");
|
|
28414
|
+
} else if (view === "wallet_connect" && !showConnectWallet) {
|
|
28415
|
+
setView("main");
|
|
28416
|
+
}
|
|
28417
|
+
}, [showConnectWallet, showTransferCrypto, view]);
|
|
28158
28418
|
const prevStatusRef = (0, import_react28.useRef)(null);
|
|
28159
28419
|
(0, import_react28.useEffect)(() => {
|
|
28160
28420
|
if (!paymentIntent) return;
|
|
@@ -28245,7 +28505,7 @@ function CheckoutModal({
|
|
|
28245
28505
|
const handleBrowserWalletClick = (0, import_react28.useCallback)(
|
|
28246
28506
|
(walletInfo) => {
|
|
28247
28507
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
28248
|
-
|
|
28508
|
+
setStoredWalletState(walletInfo.type);
|
|
28249
28509
|
setBrowserWalletChainType(walletChainType);
|
|
28250
28510
|
const matchingDepositWallet = wallets.find(
|
|
28251
28511
|
(w) => w.chain_type === walletChainType
|
|
@@ -28272,7 +28532,7 @@ function CheckoutModal({
|
|
|
28272
28532
|
const handleWalletConnected = (0, import_react28.useCallback)(
|
|
28273
28533
|
(walletInfo) => {
|
|
28274
28534
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
28275
|
-
|
|
28535
|
+
setStoredWalletState(walletInfo.type);
|
|
28276
28536
|
setBrowserWalletChainType(walletChainType);
|
|
28277
28537
|
const matchingDepositWallet = wallets.find(
|
|
28278
28538
|
(w) => w.chain_type === walletChainType
|
|
@@ -28296,7 +28556,7 @@ function CheckoutModal({
|
|
|
28296
28556
|
);
|
|
28297
28557
|
const handleWalletDisconnect = (0, import_react28.useCallback)(() => {
|
|
28298
28558
|
setUserDisconnectedWallet(true);
|
|
28299
|
-
|
|
28559
|
+
clearStoredWalletState();
|
|
28300
28560
|
setBrowserWalletChainType(void 0);
|
|
28301
28561
|
setBrowserWalletInfo(null);
|
|
28302
28562
|
setBrowserWalletModalOpen(false);
|
|
@@ -28531,7 +28791,7 @@ function CheckoutModal({
|
|
|
28531
28791
|
] }) : paymentIntent ? /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-space-y-3", children: [
|
|
28532
28792
|
progressSection,
|
|
28533
28793
|
(paymentIntent.status === "requires_payment" || paymentIntent.status === "processing") && /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_jsx_runtime73.Fragment, { children: [
|
|
28534
|
-
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
28794
|
+
showTransferCrypto && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
28535
28795
|
TransferCryptoButton,
|
|
28536
28796
|
{
|
|
28537
28797
|
onClick: () => setView("transfer"),
|
|
@@ -28540,7 +28800,7 @@ function CheckoutModal({
|
|
|
28540
28800
|
featuredTokens: projectConfig?.transfer_crypto.networks
|
|
28541
28801
|
}
|
|
28542
28802
|
),
|
|
28543
|
-
|
|
28803
|
+
showConnectWallet && !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
28544
28804
|
BrowserWalletButton,
|
|
28545
28805
|
{
|
|
28546
28806
|
onClick: handleBrowserWalletClick,
|
|
@@ -28681,14 +28941,18 @@ function CheckoutModal({
|
|
|
28681
28941
|
onWalletDisconnect: handleWalletDisconnect,
|
|
28682
28942
|
onWalletConnected: (info, dw) => {
|
|
28683
28943
|
setBrowserWalletInfo({ ...info, depositWallet: dw });
|
|
28684
|
-
|
|
28944
|
+
setStoredWalletState(info.type);
|
|
28685
28945
|
setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
|
|
28686
28946
|
},
|
|
28687
28947
|
onNewDeposit: () => setView("main"),
|
|
28688
28948
|
onDone: () => setView("main"),
|
|
28689
28949
|
paymentIntentStatus: paymentIntent.status,
|
|
28690
28950
|
onBack: handleBack,
|
|
28691
|
-
onClose: handleClose
|
|
28951
|
+
onClose: handleClose,
|
|
28952
|
+
defaultSourceChainType,
|
|
28953
|
+
defaultSourceChainId,
|
|
28954
|
+
defaultSourceTokenAddress,
|
|
28955
|
+
defaultSourceSymbol
|
|
28692
28956
|
}
|
|
28693
28957
|
),
|
|
28694
28958
|
poweredByFooter
|
|
@@ -30654,6 +30918,7 @@ function UnifoldProvider2({
|
|
|
30654
30918
|
onOpenChange: closeCheckout,
|
|
30655
30919
|
clientSecret: checkoutConfig.clientSecret,
|
|
30656
30920
|
publishableKey,
|
|
30921
|
+
enableTransferCrypto: config?.enableTransferCrypto,
|
|
30657
30922
|
enableConnectWallet: config?.enableConnectWallet,
|
|
30658
30923
|
defaultSourceChainType: checkoutConfig.defaultSourceChainType,
|
|
30659
30924
|
defaultSourceChainId: checkoutConfig.defaultSourceChainId,
|
|
@@ -30710,6 +30975,7 @@ function UnifoldProvider2({
|
|
|
30710
30975
|
hideDepositTracker: config?.hideDepositTracker,
|
|
30711
30976
|
showBalanceHeader: config?.showBalanceHeader,
|
|
30712
30977
|
transferInputVariant: config?.transferInputVariant,
|
|
30978
|
+
enableTransferCrypto: config?.enableTransferCrypto,
|
|
30713
30979
|
enableConnectWallet: config?.enableConnectWallet,
|
|
30714
30980
|
enablePayWithExchange: config?.enablePayWithExchange,
|
|
30715
30981
|
enableFiatOnramp: config?.enableFiatOnramp,
|