@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.mjs
CHANGED
|
@@ -6124,6 +6124,42 @@ import { useState as useState92, useEffect as useEffect52, useRef as useRef22 }
|
|
|
6124
6124
|
|
|
6125
6125
|
// ../core/dist/index.mjs
|
|
6126
6126
|
import { useQuery } from "@tanstack/react-query";
|
|
6127
|
+
function formatStablecoinAmount(baseUnits, decimals) {
|
|
6128
|
+
const raw = Number(baseUnits) / 10 ** decimals;
|
|
6129
|
+
const floored = Math.floor(raw * 100) / 100;
|
|
6130
|
+
const ceiled = raw > floored ? floored + 0.01 : raw;
|
|
6131
|
+
return ceiled.toFixed(2);
|
|
6132
|
+
}
|
|
6133
|
+
function generateKSUID() {
|
|
6134
|
+
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
6135
|
+
const KSUID_EPOCH = 14e8;
|
|
6136
|
+
const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
|
|
6137
|
+
const payload = new Uint8Array(20);
|
|
6138
|
+
payload[0] = timestampSeconds >>> 24 & 255;
|
|
6139
|
+
payload[1] = timestampSeconds >>> 16 & 255;
|
|
6140
|
+
payload[2] = timestampSeconds >>> 8 & 255;
|
|
6141
|
+
payload[3] = timestampSeconds & 255;
|
|
6142
|
+
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
6143
|
+
crypto.getRandomValues(payload.subarray(4));
|
|
6144
|
+
} else {
|
|
6145
|
+
for (let i = 4; i < 20; i++) {
|
|
6146
|
+
payload[i] = Math.floor(Math.random() * 256);
|
|
6147
|
+
}
|
|
6148
|
+
}
|
|
6149
|
+
let value = 0n;
|
|
6150
|
+
for (const byte of payload) {
|
|
6151
|
+
value = value << 8n | BigInt(byte);
|
|
6152
|
+
}
|
|
6153
|
+
let encoded = "";
|
|
6154
|
+
while (value > 0n) {
|
|
6155
|
+
encoded = BASE62[Number(value % 62n)] + encoded;
|
|
6156
|
+
value = value / 62n;
|
|
6157
|
+
}
|
|
6158
|
+
return encoded.padStart(27, "0");
|
|
6159
|
+
}
|
|
6160
|
+
function generatePrefixedKSUID(prefix) {
|
|
6161
|
+
return `${prefix}_${generateKSUID()}`;
|
|
6162
|
+
}
|
|
6127
6163
|
var API_BASE_URL = (() => {
|
|
6128
6164
|
try {
|
|
6129
6165
|
return process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.unifold.io";
|
|
@@ -6450,9 +6486,7 @@ function getOnrampSessionStartUrl(request, publishableKey) {
|
|
|
6450
6486
|
if (request.subdivision_code) {
|
|
6451
6487
|
params.append("subdivision_code", request.subdivision_code);
|
|
6452
6488
|
}
|
|
6453
|
-
|
|
6454
|
-
params.append("external_id", request.external_id);
|
|
6455
|
-
}
|
|
6489
|
+
params.append("external_id", request.external_id ?? generatePrefixedKSUID("ors"));
|
|
6456
6490
|
if (request.email) {
|
|
6457
6491
|
params.append("email", request.email);
|
|
6458
6492
|
}
|
|
@@ -6667,9 +6701,7 @@ function getExchangeSessionStartUrl(request, publishableKey) {
|
|
|
6667
6701
|
if (request.source_amount) {
|
|
6668
6702
|
params.append("source_amount", request.source_amount);
|
|
6669
6703
|
}
|
|
6670
|
-
|
|
6671
|
-
params.append("external_id", request.external_id);
|
|
6672
|
-
}
|
|
6704
|
+
params.append("external_id", request.external_id ?? generatePrefixedKSUID("exc"));
|
|
6673
6705
|
return `${API_BASE_URL}/v1/public/onramps/exchanges/sessions/start?${params.toString()}`;
|
|
6674
6706
|
}
|
|
6675
6707
|
async function getIntegrationExchanges(publishableKey) {
|
|
@@ -7003,40 +7035,6 @@ async function getCashAppSessionStatus(externalId, publishableKey) {
|
|
|
7003
7035
|
}
|
|
7004
7036
|
return response.json();
|
|
7005
7037
|
}
|
|
7006
|
-
function formatStablecoinAmount(baseUnits, decimals) {
|
|
7007
|
-
const raw = Number(baseUnits) / 10 ** decimals;
|
|
7008
|
-
const floored = Math.floor(raw * 100) / 100;
|
|
7009
|
-
const ceiled = raw > floored ? floored + 0.01 : raw;
|
|
7010
|
-
return ceiled.toFixed(2);
|
|
7011
|
-
}
|
|
7012
|
-
function generatePrefixedKSUID(prefix) {
|
|
7013
|
-
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
7014
|
-
const KSUID_EPOCH = 14e8;
|
|
7015
|
-
const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
|
|
7016
|
-
const payload = new Uint8Array(20);
|
|
7017
|
-
payload[0] = timestampSeconds >>> 24 & 255;
|
|
7018
|
-
payload[1] = timestampSeconds >>> 16 & 255;
|
|
7019
|
-
payload[2] = timestampSeconds >>> 8 & 255;
|
|
7020
|
-
payload[3] = timestampSeconds & 255;
|
|
7021
|
-
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
7022
|
-
crypto.getRandomValues(payload.subarray(4));
|
|
7023
|
-
} else {
|
|
7024
|
-
for (let i = 4; i < 20; i++) {
|
|
7025
|
-
payload[i] = Math.floor(Math.random() * 256);
|
|
7026
|
-
}
|
|
7027
|
-
}
|
|
7028
|
-
let value = 0n;
|
|
7029
|
-
for (const byte of payload) {
|
|
7030
|
-
value = value << 8n | BigInt(byte);
|
|
7031
|
-
}
|
|
7032
|
-
let encoded = "";
|
|
7033
|
-
while (value > 0n) {
|
|
7034
|
-
encoded = BASE62[Number(value % 62n)] + encoded;
|
|
7035
|
-
value = value / 62n;
|
|
7036
|
-
}
|
|
7037
|
-
encoded = encoded.padStart(27, "0");
|
|
7038
|
-
return `${prefix}_${encoded}`;
|
|
7039
|
-
}
|
|
7040
7038
|
var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
|
|
7041
7039
|
DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
|
|
7042
7040
|
return DepositEventType2;
|
|
@@ -13486,8 +13484,32 @@ import { jsx as jsx622, jsxs as jsxs56 } from "react/jsx-runtime";
|
|
|
13486
13484
|
function cn(...inputs) {
|
|
13487
13485
|
return twMerge(clsx(inputs));
|
|
13488
13486
|
}
|
|
13489
|
-
var
|
|
13487
|
+
var WALLET_STATE_STORAGE_KEY = "unifold_wallet_state";
|
|
13488
|
+
var LEGACY_WALLET_KEYS = [
|
|
13489
|
+
"unifold_last_wallet_type",
|
|
13490
|
+
"unifold_last_connected_wallet"
|
|
13491
|
+
];
|
|
13490
13492
|
var WALLET_USER_DISCONNECTED_KEY = "unifold_wallet_user_disconnected";
|
|
13493
|
+
var SOLANA_WALLET_TYPES = /* @__PURE__ */ new Set([
|
|
13494
|
+
"phantom-solana",
|
|
13495
|
+
"solflare",
|
|
13496
|
+
"backpack",
|
|
13497
|
+
"glow"
|
|
13498
|
+
]);
|
|
13499
|
+
var ETHEREUM_WALLET_TYPES = /* @__PURE__ */ new Set([
|
|
13500
|
+
"metamask",
|
|
13501
|
+
"phantom-ethereum",
|
|
13502
|
+
"coinbase",
|
|
13503
|
+
"trust",
|
|
13504
|
+
"rainbow",
|
|
13505
|
+
"rabby",
|
|
13506
|
+
"okx"
|
|
13507
|
+
]);
|
|
13508
|
+
function walletTypeToChain(t12) {
|
|
13509
|
+
if (SOLANA_WALLET_TYPES.has(t12)) return "solana";
|
|
13510
|
+
if (ETHEREUM_WALLET_TYPES.has(t12)) return "ethereum";
|
|
13511
|
+
return void 0;
|
|
13512
|
+
}
|
|
13491
13513
|
function getUserDisconnectedWallet() {
|
|
13492
13514
|
if (typeof window === "undefined") return false;
|
|
13493
13515
|
try {
|
|
@@ -13507,26 +13529,35 @@ function setUserDisconnectedWallet(disconnected) {
|
|
|
13507
13529
|
} catch {
|
|
13508
13530
|
}
|
|
13509
13531
|
}
|
|
13510
|
-
function
|
|
13532
|
+
function getStoredWalletState() {
|
|
13511
13533
|
if (typeof window === "undefined") return void 0;
|
|
13512
13534
|
try {
|
|
13513
|
-
const
|
|
13514
|
-
if (
|
|
13535
|
+
const raw = localStorage.getItem(WALLET_STATE_STORAGE_KEY);
|
|
13536
|
+
if (!raw) return void 0;
|
|
13537
|
+
const chainType = walletTypeToChain(raw);
|
|
13538
|
+
if (!chainType) {
|
|
13539
|
+
localStorage.removeItem(WALLET_STATE_STORAGE_KEY);
|
|
13540
|
+
return void 0;
|
|
13541
|
+
}
|
|
13542
|
+
return { walletType: raw, chainType };
|
|
13515
13543
|
} catch {
|
|
13544
|
+
return void 0;
|
|
13516
13545
|
}
|
|
13517
|
-
return void 0;
|
|
13518
13546
|
}
|
|
13519
|
-
function
|
|
13547
|
+
function setStoredWalletState(walletType) {
|
|
13520
13548
|
if (typeof window === "undefined") return;
|
|
13549
|
+
if (!walletTypeToChain(walletType)) return;
|
|
13521
13550
|
try {
|
|
13522
|
-
localStorage.setItem(
|
|
13551
|
+
localStorage.setItem(WALLET_STATE_STORAGE_KEY, walletType);
|
|
13552
|
+
for (const key of LEGACY_WALLET_KEYS) localStorage.removeItem(key);
|
|
13523
13553
|
} catch {
|
|
13524
13554
|
}
|
|
13525
13555
|
}
|
|
13526
|
-
function
|
|
13556
|
+
function clearStoredWalletState() {
|
|
13527
13557
|
if (typeof window === "undefined") return;
|
|
13528
13558
|
try {
|
|
13529
|
-
localStorage.removeItem(
|
|
13559
|
+
localStorage.removeItem(WALLET_STATE_STORAGE_KEY);
|
|
13560
|
+
for (const key of LEGACY_WALLET_KEYS) localStorage.removeItem(key);
|
|
13530
13561
|
} catch {
|
|
13531
13562
|
}
|
|
13532
13563
|
}
|
|
@@ -14089,6 +14120,60 @@ function useDepositAddress(params) {
|
|
|
14089
14120
|
// 1s, 2s, 4s (max 10s)
|
|
14090
14121
|
});
|
|
14091
14122
|
}
|
|
14123
|
+
var normalize = (value) => value?.toLowerCase();
|
|
14124
|
+
function sourceTokenMatchesDefaultSource(token, defaultSource) {
|
|
14125
|
+
if (!token || !defaultSource.defaultSourceChainType || !defaultSource.defaultSourceChainId) {
|
|
14126
|
+
return false;
|
|
14127
|
+
}
|
|
14128
|
+
if (token.chain_type !== defaultSource.defaultSourceChainType || token.chain_id !== defaultSource.defaultSourceChainId) {
|
|
14129
|
+
return false;
|
|
14130
|
+
}
|
|
14131
|
+
if (defaultSource.defaultSourceTokenAddress && normalize(token.token_address) === normalize(defaultSource.defaultSourceTokenAddress)) {
|
|
14132
|
+
return true;
|
|
14133
|
+
}
|
|
14134
|
+
if (defaultSource.defaultSourceTokenAddress) {
|
|
14135
|
+
return false;
|
|
14136
|
+
}
|
|
14137
|
+
return !!defaultSource.defaultSourceSymbol && normalize(token.symbol) === normalize(defaultSource.defaultSourceSymbol);
|
|
14138
|
+
}
|
|
14139
|
+
function isDefaultSourceBalance(balance, defaultSource) {
|
|
14140
|
+
return isBalanceEligible(balance) && sourceTokenMatchesDefaultSource(getTokenFromBalance(balance), defaultSource);
|
|
14141
|
+
}
|
|
14142
|
+
function compareBalancesWithDefaultSource(a, b, defaultSource) {
|
|
14143
|
+
const aDefault = isDefaultSourceBalance(a, defaultSource);
|
|
14144
|
+
const bDefault = isDefaultSourceBalance(b, defaultSource);
|
|
14145
|
+
if (aDefault && !bDefault) return -1;
|
|
14146
|
+
if (!aDefault && bDefault) return 1;
|
|
14147
|
+
const aEligible = isBalanceEligible(a);
|
|
14148
|
+
const bEligible = isBalanceEligible(b);
|
|
14149
|
+
if (aEligible && !bEligible) return -1;
|
|
14150
|
+
if (!aEligible && bEligible) return 1;
|
|
14151
|
+
return 0;
|
|
14152
|
+
}
|
|
14153
|
+
function resolveDefaultSourceSymbol(supportedTokens, defaultSource) {
|
|
14154
|
+
if (!supportedTokens?.length || !defaultSource.defaultSourceChainType || !defaultSource.defaultSourceChainId) {
|
|
14155
|
+
return null;
|
|
14156
|
+
}
|
|
14157
|
+
if (defaultSource.defaultSourceTokenAddress) {
|
|
14158
|
+
for (const token of supportedTokens) {
|
|
14159
|
+
const matchingChain = token.chains.find(
|
|
14160
|
+
(chain) => chain.chain_type === defaultSource.defaultSourceChainType && chain.chain_id === defaultSource.defaultSourceChainId && normalize(chain.token_address) === normalize(defaultSource.defaultSourceTokenAddress)
|
|
14161
|
+
);
|
|
14162
|
+
if (matchingChain) return token.symbol;
|
|
14163
|
+
}
|
|
14164
|
+
}
|
|
14165
|
+
if (!defaultSource.defaultSourceSymbol) return null;
|
|
14166
|
+
for (const token of supportedTokens) {
|
|
14167
|
+
if (normalize(token.symbol) !== normalize(defaultSource.defaultSourceSymbol)) {
|
|
14168
|
+
continue;
|
|
14169
|
+
}
|
|
14170
|
+
const matchingChain = token.chains.find(
|
|
14171
|
+
(chain) => chain.chain_type === defaultSource.defaultSourceChainType && chain.chain_id === defaultSource.defaultSourceChainId
|
|
14172
|
+
);
|
|
14173
|
+
if (matchingChain) return token.symbol;
|
|
14174
|
+
}
|
|
14175
|
+
return null;
|
|
14176
|
+
}
|
|
14092
14177
|
function formatUsdFromBalancePercent(maxUsdAmount, percent) {
|
|
14093
14178
|
if (maxUsdAmount <= 0 || percent < 0) return "";
|
|
14094
14179
|
const raw = maxUsdAmount * percent / 100;
|
|
@@ -18602,70 +18687,106 @@ function identifyEthWallet(provider, hint) {
|
|
|
18602
18687
|
}
|
|
18603
18688
|
return { type: "metamask", name: "Wallet", icon: "metamask" };
|
|
18604
18689
|
}
|
|
18690
|
+
var EIP6963_ID_TO_WALLET_TYPE = {
|
|
18691
|
+
metamask: "metamask",
|
|
18692
|
+
phantom: "phantom-ethereum",
|
|
18693
|
+
coinbase: "coinbase",
|
|
18694
|
+
trust: "trust",
|
|
18695
|
+
rainbow: "rainbow",
|
|
18696
|
+
rabby: "rabby",
|
|
18697
|
+
okx: "okx"
|
|
18698
|
+
};
|
|
18699
|
+
function inferEthWalletType(provider, walletId) {
|
|
18700
|
+
if (EIP6963_ID_TO_WALLET_TYPE[walletId]) return EIP6963_ID_TO_WALLET_TYPE[walletId];
|
|
18701
|
+
const any = provider;
|
|
18702
|
+
if (provider.isPhantom) return "phantom-ethereum";
|
|
18703
|
+
if (any.isCoinbaseWallet) return "coinbase";
|
|
18704
|
+
if (any.isRabby) return "rabby";
|
|
18705
|
+
if (any.isTrust) return "trust";
|
|
18706
|
+
if (any.isRainbow) return "rainbow";
|
|
18707
|
+
if (any.isOkxWallet) return "okx";
|
|
18708
|
+
if (provider.isMetaMask && !provider.isPhantom) return "metamask";
|
|
18709
|
+
return null;
|
|
18710
|
+
}
|
|
18711
|
+
function solanaCandidate(provider, type, name, icon) {
|
|
18712
|
+
return {
|
|
18713
|
+
walletType: type,
|
|
18714
|
+
detect: async () => {
|
|
18715
|
+
if (!provider) return null;
|
|
18716
|
+
if (provider.isConnected && provider.publicKey) {
|
|
18717
|
+
return { type, name, address: provider.publicKey.toString(), icon };
|
|
18718
|
+
}
|
|
18719
|
+
try {
|
|
18720
|
+
const resp = await provider.connect({ onlyIfTrusted: true });
|
|
18721
|
+
if (resp.publicKey) {
|
|
18722
|
+
return { type, name, address: resp.publicKey.toString(), icon };
|
|
18723
|
+
}
|
|
18724
|
+
} catch {
|
|
18725
|
+
}
|
|
18726
|
+
return null;
|
|
18727
|
+
}
|
|
18728
|
+
};
|
|
18729
|
+
}
|
|
18730
|
+
function ethereumCandidate(provider, walletId) {
|
|
18731
|
+
return {
|
|
18732
|
+
walletType: inferEthWalletType(provider, walletId),
|
|
18733
|
+
detect: async () => {
|
|
18734
|
+
try {
|
|
18735
|
+
const accounts = await provider.request({ method: "eth_accounts" });
|
|
18736
|
+
if (!accounts?.length) return null;
|
|
18737
|
+
const resolved = identifyEthWallet(provider, walletId);
|
|
18738
|
+
return { ...resolved, address: accounts[0] };
|
|
18739
|
+
} catch {
|
|
18740
|
+
return null;
|
|
18741
|
+
}
|
|
18742
|
+
}
|
|
18743
|
+
};
|
|
18744
|
+
}
|
|
18745
|
+
function buildCandidates(win, chainType) {
|
|
18746
|
+
const candidates = [];
|
|
18747
|
+
if (!chainType || chainType === "solana") {
|
|
18748
|
+
candidates.push(
|
|
18749
|
+
solanaCandidate(win.phantom?.solana, "phantom-solana", "Phantom", "phantom"),
|
|
18750
|
+
solanaCandidate(win.solflare, "solflare", "Solflare", "solflare"),
|
|
18751
|
+
solanaCandidate(win.backpack, "backpack", "Backpack", "backpack"),
|
|
18752
|
+
solanaCandidate(win.glow, "glow", "Glow", "glow")
|
|
18753
|
+
);
|
|
18754
|
+
}
|
|
18755
|
+
if (!chainType || chainType === "ethereum") {
|
|
18756
|
+
const seen = /* @__PURE__ */ new Set();
|
|
18757
|
+
const addEth = (provider, walletId) => {
|
|
18758
|
+
if (!provider || seen.has(provider)) return;
|
|
18759
|
+
seen.add(provider);
|
|
18760
|
+
candidates.push(ethereumCandidate(provider, walletId));
|
|
18761
|
+
};
|
|
18762
|
+
for (const { provider, walletId } of getEip6963Providers()) {
|
|
18763
|
+
addEth(
|
|
18764
|
+
provider,
|
|
18765
|
+
walletId === "unknown" ? "default" : walletId
|
|
18766
|
+
);
|
|
18767
|
+
}
|
|
18768
|
+
addEth(win.phantom?.ethereum, "phantom");
|
|
18769
|
+
addEth(win.coinbaseWalletExtension, "coinbase");
|
|
18770
|
+
addEth(win.okxwallet, "okx");
|
|
18771
|
+
addEth(win.trustwallet?.ethereum, "trust");
|
|
18772
|
+
addEth(win.ethereum, "default");
|
|
18773
|
+
}
|
|
18774
|
+
return candidates;
|
|
18775
|
+
}
|
|
18605
18776
|
async function detectConnectedBrowserWallet(chainType) {
|
|
18606
18777
|
if (typeof window === "undefined") return null;
|
|
18607
18778
|
if (getUserDisconnectedWallet()) return null;
|
|
18608
18779
|
try {
|
|
18609
18780
|
const win = window;
|
|
18610
|
-
|
|
18611
|
-
|
|
18612
|
-
|
|
18613
|
-
|
|
18614
|
-
|
|
18615
|
-
|
|
18616
|
-
|
|
18617
|
-
|
|
18618
|
-
|
|
18619
|
-
return { type, name, address: resp.publicKey.toString(), icon };
|
|
18620
|
-
}
|
|
18621
|
-
} catch {
|
|
18622
|
-
}
|
|
18623
|
-
return null;
|
|
18624
|
-
};
|
|
18625
|
-
const solanaCandidates = [
|
|
18626
|
-
[win.phantom?.solana, "phantom-solana", "Phantom", "phantom"],
|
|
18627
|
-
[win.solflare, "solflare", "Solflare", "solflare"],
|
|
18628
|
-
[win.backpack, "backpack", "Backpack", "backpack"],
|
|
18629
|
-
[win.glow, "glow", "Glow", "glow"]
|
|
18630
|
-
];
|
|
18631
|
-
for (const [provider, type, name, icon] of solanaCandidates) {
|
|
18632
|
-
const found = await trySilentSolana(provider, type, name, icon);
|
|
18633
|
-
if (found) return found;
|
|
18634
|
-
}
|
|
18635
|
-
}
|
|
18636
|
-
if (!chainType || chainType === "ethereum") {
|
|
18637
|
-
const allProviders = [];
|
|
18638
|
-
const eip6963 = getEip6963Providers();
|
|
18639
|
-
for (const { provider, walletId } of eip6963) {
|
|
18640
|
-
allProviders.push({
|
|
18641
|
-
provider,
|
|
18642
|
-
walletId: walletId === "unknown" ? "default" : walletId
|
|
18643
|
-
});
|
|
18644
|
-
}
|
|
18645
|
-
if (allProviders.length === 0) {
|
|
18646
|
-
if (win.phantom?.ethereum) {
|
|
18647
|
-
allProviders.push({ provider: win.phantom.ethereum, walletId: "phantom" });
|
|
18648
|
-
}
|
|
18649
|
-
if (win.okxwallet) {
|
|
18650
|
-
allProviders.push({ provider: win.okxwallet, walletId: "okx" });
|
|
18651
|
-
}
|
|
18652
|
-
if (win.coinbaseWalletExtension) {
|
|
18653
|
-
allProviders.push({ provider: win.coinbaseWalletExtension, walletId: "coinbase" });
|
|
18654
|
-
}
|
|
18655
|
-
if (win.ethereum && !allProviders.some((p) => p.provider === win.ethereum)) {
|
|
18656
|
-
allProviders.push({ provider: win.ethereum, walletId: "default" });
|
|
18657
|
-
}
|
|
18658
|
-
}
|
|
18659
|
-
for (const { provider, walletId } of allProviders) {
|
|
18660
|
-
if (!provider) continue;
|
|
18661
|
-
try {
|
|
18662
|
-
const accounts = await provider.request({ method: "eth_accounts" });
|
|
18663
|
-
if (!accounts || accounts.length === 0) continue;
|
|
18664
|
-
const resolved = identifyEthWallet(provider, walletId);
|
|
18665
|
-
return { ...resolved, address: accounts[0] };
|
|
18666
|
-
} catch {
|
|
18667
|
-
}
|
|
18668
|
-
}
|
|
18781
|
+
const candidates = buildCandidates(win, chainType);
|
|
18782
|
+
const preferred = getStoredWalletState();
|
|
18783
|
+
if (preferred && (!chainType || preferred.chainType === chainType)) {
|
|
18784
|
+
const idx = candidates.findIndex((c) => c.walletType === preferred.walletType);
|
|
18785
|
+
if (idx > 0) candidates.unshift(...candidates.splice(idx, 1));
|
|
18786
|
+
}
|
|
18787
|
+
for (const c of candidates) {
|
|
18788
|
+
const found = await c.detect();
|
|
18789
|
+
if (found) return found;
|
|
18669
18790
|
}
|
|
18670
18791
|
} catch (error) {
|
|
18671
18792
|
console.error("[detectConnectedBrowserWallet] detection error:", error);
|
|
@@ -20811,6 +20932,7 @@ function BrowserWalletButton({
|
|
|
20811
20932
|
if (solanaProvider?.isPhantom) {
|
|
20812
20933
|
const { publicKey } = await solanaProvider.connect();
|
|
20813
20934
|
setUserDisconnectedWallet(false);
|
|
20935
|
+
setStoredWalletState("phantom-solana");
|
|
20814
20936
|
setWallet({
|
|
20815
20937
|
type: "phantom-solana",
|
|
20816
20938
|
name: "Phantom",
|
|
@@ -20830,8 +20952,10 @@ function BrowserWalletButton({
|
|
|
20830
20952
|
if (accounts && accounts.length > 0) {
|
|
20831
20953
|
setUserDisconnectedWallet(false);
|
|
20832
20954
|
const isPhantom = ethProvider.isPhantom;
|
|
20955
|
+
const walletType = isPhantom ? "phantom-ethereum" : "metamask";
|
|
20956
|
+
setStoredWalletState(walletType);
|
|
20833
20957
|
setWallet({
|
|
20834
|
-
type:
|
|
20958
|
+
type: walletType,
|
|
20835
20959
|
name: isPhantom ? "Phantom" : "MetaMask",
|
|
20836
20960
|
address: accounts[0],
|
|
20837
20961
|
icon: isPhantom ? "phantom" : "metamask"
|
|
@@ -21141,7 +21265,11 @@ function CoinbaseConnect({
|
|
|
21141
21265
|
onDisconnect,
|
|
21142
21266
|
skipToHoldings,
|
|
21143
21267
|
canGoBack = true,
|
|
21144
|
-
onExecutionsChange
|
|
21268
|
+
onExecutionsChange,
|
|
21269
|
+
defaultSourceChainType,
|
|
21270
|
+
defaultSourceChainId,
|
|
21271
|
+
defaultSourceTokenAddress,
|
|
21272
|
+
defaultSourceSymbol
|
|
21145
21273
|
}) {
|
|
21146
21274
|
const { colors: colors2, fonts, components } = useTheme();
|
|
21147
21275
|
const { projectConfig } = useProjectConfig({ publishableKey });
|
|
@@ -21206,6 +21334,21 @@ function CoinbaseConnect({
|
|
|
21206
21334
|
params: defaultTokenParams,
|
|
21207
21335
|
publishableKey
|
|
21208
21336
|
});
|
|
21337
|
+
const defaultSourceCurrency = useMemo42(
|
|
21338
|
+
() => resolveDefaultSourceSymbol(supportedTokensData?.data, {
|
|
21339
|
+
defaultSourceChainType,
|
|
21340
|
+
defaultSourceChainId,
|
|
21341
|
+
defaultSourceTokenAddress,
|
|
21342
|
+
defaultSourceSymbol
|
|
21343
|
+
})?.toLowerCase() ?? null,
|
|
21344
|
+
[
|
|
21345
|
+
supportedTokensData,
|
|
21346
|
+
defaultSourceChainType,
|
|
21347
|
+
defaultSourceChainId,
|
|
21348
|
+
defaultSourceTokenAddress,
|
|
21349
|
+
defaultSourceSymbol
|
|
21350
|
+
]
|
|
21351
|
+
);
|
|
21209
21352
|
const sortedHoldings = useMemo42(() => {
|
|
21210
21353
|
const supported = [];
|
|
21211
21354
|
const unsupported = [];
|
|
@@ -21215,13 +21358,42 @@ function CoinbaseConnect({
|
|
|
21215
21358
|
if (isSupported) supported.push(account);
|
|
21216
21359
|
else unsupported.push(account);
|
|
21217
21360
|
});
|
|
21361
|
+
if (defaultSourceCurrency) {
|
|
21362
|
+
const defaultIndex = supported.findIndex(
|
|
21363
|
+
(account) => account.currency.toLowerCase() === defaultSourceCurrency
|
|
21364
|
+
);
|
|
21365
|
+
if (defaultIndex > 0) {
|
|
21366
|
+
const [defaultHolding] = supported.splice(defaultIndex, 1);
|
|
21367
|
+
supported.unshift(defaultHolding);
|
|
21368
|
+
}
|
|
21369
|
+
}
|
|
21218
21370
|
return [...supported, ...unsupported];
|
|
21219
|
-
}, [
|
|
21371
|
+
}, [
|
|
21372
|
+
holdings,
|
|
21373
|
+
supportedSymbols,
|
|
21374
|
+
exchangeSupportedCurrencies,
|
|
21375
|
+
defaultSourceCurrency
|
|
21376
|
+
]);
|
|
21220
21377
|
const selectedHoldingIsSupported = useMemo42(() => {
|
|
21221
21378
|
if (!selectedHolding) return false;
|
|
21222
21379
|
const currencyLower = selectedHolding.currency.toLowerCase();
|
|
21223
21380
|
return (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
|
|
21224
21381
|
}, [selectedHolding, supportedSymbols, exchangeSupportedCurrencies]);
|
|
21382
|
+
useEffect172(() => {
|
|
21383
|
+
if (!defaultSourceCurrency || selectedHolding) return;
|
|
21384
|
+
const defaultHolding = sortedHoldings.find((account) => {
|
|
21385
|
+
const currencyLower = account.currency.toLowerCase();
|
|
21386
|
+
return currencyLower === defaultSourceCurrency && (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
|
|
21387
|
+
});
|
|
21388
|
+
if (!defaultHolding) return;
|
|
21389
|
+
setSelectedHolding(defaultHolding);
|
|
21390
|
+
}, [
|
|
21391
|
+
defaultSourceCurrency,
|
|
21392
|
+
selectedHolding,
|
|
21393
|
+
sortedHoldings,
|
|
21394
|
+
supportedSymbols,
|
|
21395
|
+
exchangeSupportedCurrencies
|
|
21396
|
+
]);
|
|
21225
21397
|
const exchangeName = selectedExchange?.service_provider_display_name || "Exchange";
|
|
21226
21398
|
const {
|
|
21227
21399
|
executions: depositExecutions,
|
|
@@ -26387,6 +26559,19 @@ var WALLET_DEFINITIONS = [
|
|
|
26387
26559
|
{ id: "backpack", name: "Backpack", networks: ["solana"], installUrl: "https://backpack.app/" },
|
|
26388
26560
|
{ id: "glow", name: "Glow", networks: ["solana"], installUrl: "https://glow.app/" }
|
|
26389
26561
|
];
|
|
26562
|
+
function normalizeTokenAddress(address) {
|
|
26563
|
+
const normalized = (address ?? "").toLowerCase();
|
|
26564
|
+
if (normalized === "" || normalized === "native" || normalized === "0x0000000000000000000000000000000000000000") {
|
|
26565
|
+
return "native";
|
|
26566
|
+
}
|
|
26567
|
+
return normalized;
|
|
26568
|
+
}
|
|
26569
|
+
function balancesRepresentSameToken(a, b) {
|
|
26570
|
+
const tokenA = getTokenFromBalance(a);
|
|
26571
|
+
const tokenB = getTokenFromBalance(b);
|
|
26572
|
+
if (!tokenA || !tokenB) return false;
|
|
26573
|
+
return tokenA.chain_type === tokenB.chain_type && tokenA.chain_id === tokenB.chain_id && normalizeTokenAddress(tokenA.token_address) === normalizeTokenAddress(tokenB.token_address);
|
|
26574
|
+
}
|
|
26390
26575
|
function getSolanaProviders() {
|
|
26391
26576
|
if (typeof window === "undefined") return {};
|
|
26392
26577
|
const win = window;
|
|
@@ -26529,6 +26714,10 @@ function WalletConnect({
|
|
|
26529
26714
|
checkoutRemainingBaseUnits,
|
|
26530
26715
|
stablecoinParity = false,
|
|
26531
26716
|
productType,
|
|
26717
|
+
defaultSourceChainType,
|
|
26718
|
+
defaultSourceChainId,
|
|
26719
|
+
defaultSourceTokenAddress,
|
|
26720
|
+
defaultSourceSymbol,
|
|
26532
26721
|
onBack: parentOnBack,
|
|
26533
26722
|
onClose,
|
|
26534
26723
|
canGoBack = true,
|
|
@@ -26689,6 +26878,7 @@ function WalletConnect({
|
|
|
26689
26878
|
metamask: "metamask"
|
|
26690
26879
|
};
|
|
26691
26880
|
const walletType = walletIdToType[wallet.id] || "metamask";
|
|
26881
|
+
setStoredWalletState(walletType);
|
|
26692
26882
|
connectedInfo = { type: walletType, name: wallet.name, address: accounts[0], icon: wallet.id };
|
|
26693
26883
|
} else {
|
|
26694
26884
|
const solProviders = getSolanaProviders();
|
|
@@ -26717,6 +26907,7 @@ function WalletConnect({
|
|
|
26717
26907
|
const response = await provider.connect();
|
|
26718
26908
|
setUserDisconnectedWallet(false);
|
|
26719
26909
|
const walletType = wallet.id === "solflare" ? "solflare" : wallet.id === "backpack" ? "backpack" : wallet.id === "glow" ? "glow" : "phantom-solana";
|
|
26910
|
+
setStoredWalletState(walletType);
|
|
26720
26911
|
connectedInfo = { type: walletType, name: wallet.name, address: response.publicKey.toString(), icon: wallet.id };
|
|
26721
26912
|
}
|
|
26722
26913
|
const walletChainType = network === "solana" ? "solana" : "ethereum";
|
|
@@ -26831,18 +27022,33 @@ function WalletConnect({
|
|
|
26831
27022
|
getAddressBalances(activeWalletInfo.address, sct, publishableKey).then((response) => {
|
|
26832
27023
|
if (cancelled) return;
|
|
26833
27024
|
const nonZero = response.balances.filter((b) => b.amount !== "0");
|
|
26834
|
-
const
|
|
26835
|
-
|
|
26836
|
-
|
|
26837
|
-
|
|
26838
|
-
|
|
26839
|
-
|
|
26840
|
-
|
|
27025
|
+
const defaultSource = {
|
|
27026
|
+
defaultSourceChainType,
|
|
27027
|
+
defaultSourceChainId,
|
|
27028
|
+
defaultSourceTokenAddress,
|
|
27029
|
+
defaultSourceSymbol
|
|
27030
|
+
};
|
|
27031
|
+
const sorted = [...nonZero].sort(
|
|
27032
|
+
(a, b) => compareBalancesWithDefaultSource(a, b, defaultSource)
|
|
27033
|
+
);
|
|
26841
27034
|
setBalances(sorted);
|
|
26842
27035
|
const totalUsd = nonZero.reduce((sum, b) => b.amount_usd ? sum + parseFloat(b.amount_usd) : sum, 0);
|
|
26843
27036
|
if (totalUsd > 0) setTotalBalanceUsd(totalUsd.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 }));
|
|
26844
27037
|
const eligible = sorted.filter(isBalanceEligible);
|
|
26845
|
-
|
|
27038
|
+
const defaultBalance = sorted.find(
|
|
27039
|
+
(balance) => isDefaultSourceBalance(balance, defaultSource)
|
|
27040
|
+
);
|
|
27041
|
+
setSelectedBalance((current) => {
|
|
27042
|
+
if (current) {
|
|
27043
|
+
const currentInNewBalances = sorted.find(
|
|
27044
|
+
(balance) => balancesRepresentSameToken(balance, current)
|
|
27045
|
+
);
|
|
27046
|
+
if (currentInNewBalances) return currentInNewBalances;
|
|
27047
|
+
}
|
|
27048
|
+
if (defaultBalance) return defaultBalance;
|
|
27049
|
+
if (eligible.length === 1) return eligible[0];
|
|
27050
|
+
return null;
|
|
27051
|
+
});
|
|
26846
27052
|
}).catch((err) => {
|
|
26847
27053
|
if (!cancelled) {
|
|
26848
27054
|
console.error("[WalletConnect] Error fetching balances:", err);
|
|
@@ -26854,7 +27060,15 @@ function WalletConnect({
|
|
|
26854
27060
|
return () => {
|
|
26855
27061
|
cancelled = true;
|
|
26856
27062
|
};
|
|
26857
|
-
}, [
|
|
27063
|
+
}, [
|
|
27064
|
+
activeWalletInfo?.address,
|
|
27065
|
+
activeDepositWallet?.chain_type,
|
|
27066
|
+
publishableKey,
|
|
27067
|
+
defaultSourceChainType,
|
|
27068
|
+
defaultSourceChainId,
|
|
27069
|
+
defaultSourceTokenAddress,
|
|
27070
|
+
defaultSourceSymbol
|
|
27071
|
+
]);
|
|
26858
27072
|
const usdToTokenRate = React302.useMemo(() => {
|
|
26859
27073
|
if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
|
|
26860
27074
|
const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
|
|
@@ -27209,16 +27423,17 @@ function DepositModal({
|
|
|
27209
27423
|
defaultSourceChainId,
|
|
27210
27424
|
defaultSourceTokenAddress,
|
|
27211
27425
|
defaultSourceSymbol,
|
|
27212
|
-
hideDepositTracker
|
|
27426
|
+
hideDepositTracker,
|
|
27213
27427
|
showBalanceHeader = false,
|
|
27214
27428
|
transferInputVariant = "double_input",
|
|
27215
27429
|
depositConfirmationMode = "auto_ui",
|
|
27216
|
-
|
|
27430
|
+
enableTransferCrypto,
|
|
27431
|
+
enableConnectWallet,
|
|
27217
27432
|
browserWalletAmountQuickSelect = "percentage",
|
|
27218
27433
|
enablePayWithExchange,
|
|
27219
27434
|
enableFiatOnramp,
|
|
27220
|
-
enableConnectExchange
|
|
27221
|
-
enableCashApp
|
|
27435
|
+
enableConnectExchange,
|
|
27436
|
+
enableCashApp,
|
|
27222
27437
|
hideDepositFlowInfo = false,
|
|
27223
27438
|
hideDisplayDescription = false,
|
|
27224
27439
|
onDepositSuccess,
|
|
@@ -27236,12 +27451,13 @@ function DepositModal({
|
|
|
27236
27451
|
const { colors: colors2, fonts, components } = useTheme();
|
|
27237
27452
|
const effectiveInitialScreen = useMemo10(() => {
|
|
27238
27453
|
const s = initialScreen ?? "main";
|
|
27239
|
-
if (s === "tracker" && hideDepositTracker) return "main";
|
|
27240
|
-
if (s === "cashapp" &&
|
|
27454
|
+
if (s === "tracker" && hideDepositTracker === true) return "main";
|
|
27455
|
+
if (s === "cashapp" && enableCashApp === false) return "main";
|
|
27241
27456
|
if (s === "card" && enableFiatOnramp === false) return "main";
|
|
27242
27457
|
if (s === "pay_with_exchange") return enablePayWithExchange === false ? "main" : "exchange";
|
|
27243
|
-
if (s === "exchange_connect")
|
|
27244
|
-
|
|
27458
|
+
if (s === "exchange_connect")
|
|
27459
|
+
return enableConnectExchange === false ? "main" : "coinbase_connect";
|
|
27460
|
+
if (s === "wallet_connect") return enableConnectWallet === false ? "main" : "wallet_connect";
|
|
27245
27461
|
return s;
|
|
27246
27462
|
}, [
|
|
27247
27463
|
initialScreen,
|
|
@@ -27270,26 +27486,37 @@ function DepositModal({
|
|
|
27270
27486
|
const [browserWalletModalOpen, setBrowserWalletModalOpen] = useState32(false);
|
|
27271
27487
|
const [browserWalletInfo, setBrowserWalletInfo] = useState32(null);
|
|
27272
27488
|
const [walletSelectionModalOpen, setWalletSelectionModalOpen] = useState32(false);
|
|
27273
|
-
const [browserWalletChainType, setBrowserWalletChainType] = useState32(() =>
|
|
27489
|
+
const [browserWalletChainType, setBrowserWalletChainType] = useState32(() => getStoredWalletState()?.chainType);
|
|
27274
27490
|
const [quotesCount, setQuotesCount] = useState32(0);
|
|
27275
27491
|
const [allExecutions, setAllExecutions] = useState32([]);
|
|
27276
27492
|
const [selectedExecution, setSelectedExecution] = useState32(null);
|
|
27277
27493
|
const [depositExecutions, setDepositExecutions] = useState32([]);
|
|
27278
27494
|
const isMobileView = useIsMobileViewport();
|
|
27495
|
+
const { projectConfig } = useProjectConfig({
|
|
27496
|
+
publishableKey,
|
|
27497
|
+
enabled: open
|
|
27498
|
+
});
|
|
27499
|
+
const showTransferCrypto = enableTransferCrypto ?? projectConfig?.transfer_crypto?.enabled ?? true;
|
|
27500
|
+
const showConnectWallet = enableConnectWallet ?? projectConfig?.connect_wallet?.enabled ?? true;
|
|
27501
|
+
const showPayWithExchange = enablePayWithExchange ?? projectConfig?.pay_with_exchange?.enabled ?? true;
|
|
27502
|
+
const showFiatOnramp = enableFiatOnramp ?? projectConfig?.fiat_onramp?.enabled ?? true;
|
|
27503
|
+
const showConnectExchange = enableConnectExchange ?? projectConfig?.connect_exchange?.enabled ?? true;
|
|
27504
|
+
const showCashApp = enableCashApp ?? projectConfig?.cash_app?.enabled ?? true;
|
|
27505
|
+
const showDepositTracker = hideDepositTracker ? false : projectConfig?.deposit_tracker?.enabled ?? true;
|
|
27279
27506
|
const [integrationExchanges, setIntegrationExchanges] = useState32([]);
|
|
27280
27507
|
useEffect26(() => {
|
|
27281
|
-
if (!
|
|
27508
|
+
if (!showConnectExchange || !open) return;
|
|
27282
27509
|
getIntegrationExchanges(publishableKey).then((res) => setIntegrationExchanges(res.data)).catch(() => {
|
|
27283
27510
|
});
|
|
27284
|
-
}, [
|
|
27511
|
+
}, [showConnectExchange, open, publishableKey]);
|
|
27285
27512
|
const [connectedExchange, setConnectedExchange] = useState32(() => {
|
|
27286
|
-
if (!
|
|
27513
|
+
if (!showConnectExchange) return null;
|
|
27287
27514
|
const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
|
|
27288
27515
|
if (!stored) return null;
|
|
27289
27516
|
return { name: "Coinbase", iconUrl: void 0, balanceUsd: null, isLoading: true };
|
|
27290
27517
|
});
|
|
27291
27518
|
useEffect26(() => {
|
|
27292
|
-
if (!
|
|
27519
|
+
if (!showConnectExchange || !open || view !== "main") return;
|
|
27293
27520
|
const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
|
|
27294
27521
|
if (!stored) {
|
|
27295
27522
|
setConnectedExchange(null);
|
|
@@ -27324,7 +27551,7 @@ function DepositModal({
|
|
|
27324
27551
|
setConnectedExchange(null);
|
|
27325
27552
|
}
|
|
27326
27553
|
});
|
|
27327
|
-
}, [
|
|
27554
|
+
}, [showConnectExchange, open, view, publishableKey]);
|
|
27328
27555
|
useEffect26(() => {
|
|
27329
27556
|
if (!connectedExchange || integrationExchanges.length === 0) return;
|
|
27330
27557
|
const cbExchange = integrationExchanges.find(
|
|
@@ -27363,18 +27590,33 @@ function DepositModal({
|
|
|
27363
27590
|
setResolvedTheme(theme);
|
|
27364
27591
|
}
|
|
27365
27592
|
}, [theme]);
|
|
27366
|
-
const { projectConfig } = useProjectConfig({
|
|
27367
|
-
publishableKey,
|
|
27368
|
-
enabled: open
|
|
27369
|
-
});
|
|
27370
|
-
const showPayWithExchange = enablePayWithExchange ?? projectConfig?.pay_with_exchange?.enabled ?? true;
|
|
27371
|
-
const showFiatOnramp = enableFiatOnramp ?? projectConfig?.fiat_onramp?.enabled ?? true;
|
|
27372
27593
|
useEffect26(() => {
|
|
27373
27594
|
if (view === "card" && !showFiatOnramp) {
|
|
27374
27595
|
setView("main");
|
|
27375
27596
|
setCardView("amount");
|
|
27597
|
+
} else if (view === "transfer" && !showTransferCrypto) {
|
|
27598
|
+
setView("main");
|
|
27599
|
+
} else if (view === "exchange" && !showPayWithExchange) {
|
|
27600
|
+
setView("main");
|
|
27601
|
+
} else if (view === "cashapp" && !showCashApp) {
|
|
27602
|
+
setView("main");
|
|
27603
|
+
} else if (view === "tracker" && !showDepositTracker) {
|
|
27604
|
+
setView("main");
|
|
27605
|
+
} else if (view === "coinbase_connect" && !showConnectExchange) {
|
|
27606
|
+
setView("main");
|
|
27607
|
+
} else if (view === "wallet_connect" && !showConnectWallet) {
|
|
27608
|
+
setView("main");
|
|
27376
27609
|
}
|
|
27377
|
-
}, [
|
|
27610
|
+
}, [
|
|
27611
|
+
view,
|
|
27612
|
+
showFiatOnramp,
|
|
27613
|
+
showTransferCrypto,
|
|
27614
|
+
showPayWithExchange,
|
|
27615
|
+
showCashApp,
|
|
27616
|
+
showDepositTracker,
|
|
27617
|
+
showConnectExchange,
|
|
27618
|
+
showConnectWallet
|
|
27619
|
+
]);
|
|
27378
27620
|
useEffect26(() => {
|
|
27379
27621
|
if (view === "exchange" && !showPayWithExchange) {
|
|
27380
27622
|
setView("main");
|
|
@@ -27464,7 +27706,7 @@ function DepositModal({
|
|
|
27464
27706
|
depositPrerequisiteBody = standaloneNeedsDepositPrereq ? /* @__PURE__ */ jsx55(SkeletonButton, { variant: "with-icons" }) : /* @__PURE__ */ jsxs49(Fragment11, { children: [
|
|
27465
27707
|
/* @__PURE__ */ jsx55(SkeletonButton, { variant: "with-icons" }),
|
|
27466
27708
|
/* @__PURE__ */ jsx55(SkeletonButton, { variant: "with-icons" }),
|
|
27467
|
-
|
|
27709
|
+
showDepositTracker && /* @__PURE__ */ jsx55(SkeletonButton, {})
|
|
27468
27710
|
] });
|
|
27469
27711
|
} else if (countryError) {
|
|
27470
27712
|
depositPrerequisiteBody = /* @__PURE__ */ jsxs49("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-8 uf-px-4 uf-text-center", children: [
|
|
@@ -27496,7 +27738,7 @@ function DepositModal({
|
|
|
27496
27738
|
const themeClass = resolvedTheme === "dark" ? "uf-dark" : "";
|
|
27497
27739
|
const handleWalletDisconnect = () => {
|
|
27498
27740
|
setUserDisconnectedWallet(true);
|
|
27499
|
-
|
|
27741
|
+
clearStoredWalletState();
|
|
27500
27742
|
setBrowserWalletChainType(void 0);
|
|
27501
27743
|
setBrowserWalletInfo(null);
|
|
27502
27744
|
setBrowserWalletModalOpen(false);
|
|
@@ -27574,7 +27816,7 @@ function DepositModal({
|
|
|
27574
27816
|
};
|
|
27575
27817
|
const handleBrowserWalletClick = (walletInfo) => {
|
|
27576
27818
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
27577
|
-
|
|
27819
|
+
setStoredWalletState(walletInfo.type);
|
|
27578
27820
|
setBrowserWalletChainType(walletChainType);
|
|
27579
27821
|
const matchingDepositWallet = wallets.find(
|
|
27580
27822
|
(w) => w.chain_type === walletChainType
|
|
@@ -27605,7 +27847,7 @@ function DepositModal({
|
|
|
27605
27847
|
};
|
|
27606
27848
|
const handleWalletConnected = (walletInfo) => {
|
|
27607
27849
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
27608
|
-
|
|
27850
|
+
setStoredWalletState(walletInfo.type);
|
|
27609
27851
|
setBrowserWalletChainType(walletChainType);
|
|
27610
27852
|
const matchingDepositWallet = wallets.find(
|
|
27611
27853
|
(w) => w.chain_type === walletChainType
|
|
@@ -27672,7 +27914,7 @@ function DepositModal({
|
|
|
27672
27914
|
),
|
|
27673
27915
|
/* @__PURE__ */ jsxs49("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
27674
27916
|
/* @__PURE__ */ jsx55("div", { className: "uf-space-y-3", children: depositPrerequisiteBody ?? /* @__PURE__ */ jsxs49(Fragment11, { children: [
|
|
27675
|
-
/* @__PURE__ */ jsx55(
|
|
27917
|
+
showTransferCrypto && /* @__PURE__ */ jsx55(
|
|
27676
27918
|
TransferCryptoButton,
|
|
27677
27919
|
{
|
|
27678
27920
|
onClick: () => setView("transfer"),
|
|
@@ -27681,7 +27923,7 @@ function DepositModal({
|
|
|
27681
27923
|
featuredTokens: projectConfig?.transfer_crypto.networks
|
|
27682
27924
|
}
|
|
27683
27925
|
),
|
|
27684
|
-
|
|
27926
|
+
showConnectWallet && !isMobileView && /* @__PURE__ */ jsx55(
|
|
27685
27927
|
BrowserWalletButton,
|
|
27686
27928
|
{
|
|
27687
27929
|
onClick: handleBrowserWalletClick,
|
|
@@ -27711,7 +27953,7 @@ function DepositModal({
|
|
|
27711
27953
|
loading: exchangesLoading
|
|
27712
27954
|
}
|
|
27713
27955
|
),
|
|
27714
|
-
|
|
27956
|
+
showConnectExchange && connectedExchange && /* @__PURE__ */ jsx55(
|
|
27715
27957
|
ConnectExchangeButton,
|
|
27716
27958
|
{
|
|
27717
27959
|
onClick: () => {
|
|
@@ -27725,7 +27967,7 @@ function DepositModal({
|
|
|
27725
27967
|
connectedExchange
|
|
27726
27968
|
}
|
|
27727
27969
|
),
|
|
27728
|
-
|
|
27970
|
+
showConnectExchange && !connectedExchange && /* @__PURE__ */ jsx55(
|
|
27729
27971
|
ConnectExchangeButton,
|
|
27730
27972
|
{
|
|
27731
27973
|
onClick: () => {
|
|
@@ -27737,7 +27979,7 @@ function DepositModal({
|
|
|
27737
27979
|
exchanges: integrationExchanges
|
|
27738
27980
|
}
|
|
27739
27981
|
),
|
|
27740
|
-
|
|
27982
|
+
showCashApp && /* @__PURE__ */ jsx55(
|
|
27741
27983
|
CashAppButton,
|
|
27742
27984
|
{
|
|
27743
27985
|
onClick: () => setView("cashapp"),
|
|
@@ -27746,7 +27988,7 @@ function DepositModal({
|
|
|
27746
27988
|
iconUrl: projectConfig?.asset_cdn_url ? `${projectConfig.asset_cdn_url}/api/public/icons/onramps/svg/cashapp.svg` : void 0
|
|
27747
27989
|
}
|
|
27748
27990
|
),
|
|
27749
|
-
|
|
27991
|
+
showDepositTracker && /* @__PURE__ */ jsx55(
|
|
27750
27992
|
DepositTrackerButton,
|
|
27751
27993
|
{
|
|
27752
27994
|
onClick: () => {
|
|
@@ -27951,7 +28193,11 @@ function DepositModal({
|
|
|
27951
28193
|
onDisconnect: handleExchangeDisconnect,
|
|
27952
28194
|
skipToHoldings: coinbaseSkipToHoldings,
|
|
27953
28195
|
canGoBack: sessionOpenedFromMenu,
|
|
27954
|
-
onExecutionsChange: setDepositExecutions
|
|
28196
|
+
onExecutionsChange: setDepositExecutions,
|
|
28197
|
+
defaultSourceChainType,
|
|
28198
|
+
defaultSourceChainId,
|
|
28199
|
+
defaultSourceTokenAddress,
|
|
28200
|
+
defaultSourceSymbol
|
|
27955
28201
|
}
|
|
27956
28202
|
),
|
|
27957
28203
|
depositPoweredByFooter
|
|
@@ -27984,11 +28230,15 @@ function DepositModal({
|
|
|
27984
28230
|
onWalletDisconnect: handleWalletDisconnect,
|
|
27985
28231
|
onWalletConnected: (info, dw) => {
|
|
27986
28232
|
setBrowserWalletInfo({ ...info, depositWallet: dw });
|
|
27987
|
-
|
|
28233
|
+
setStoredWalletState(info.type);
|
|
27988
28234
|
setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
|
|
27989
28235
|
},
|
|
27990
28236
|
onBack: handleBack,
|
|
27991
28237
|
onClose: handleClose,
|
|
28238
|
+
defaultSourceChainType,
|
|
28239
|
+
defaultSourceChainId,
|
|
28240
|
+
defaultSourceTokenAddress,
|
|
28241
|
+
defaultSourceSymbol,
|
|
27992
28242
|
canGoBack: sessionOpenedFromMenu,
|
|
27993
28243
|
depositWalletsLoading: walletsLoading
|
|
27994
28244
|
}
|
|
@@ -28091,7 +28341,8 @@ function CheckoutModal({
|
|
|
28091
28341
|
clientSecret,
|
|
28092
28342
|
publishableKey,
|
|
28093
28343
|
modalTitle,
|
|
28094
|
-
|
|
28344
|
+
enableTransferCrypto,
|
|
28345
|
+
enableConnectWallet,
|
|
28095
28346
|
defaultSourceChainType,
|
|
28096
28347
|
defaultSourceChainId,
|
|
28097
28348
|
defaultSourceTokenAddress,
|
|
@@ -28108,7 +28359,7 @@ function CheckoutModal({
|
|
|
28108
28359
|
const [browserWalletModalOpen, setBrowserWalletModalOpen] = useState33(false);
|
|
28109
28360
|
const [browserWalletInfo, setBrowserWalletInfo] = useState33(null);
|
|
28110
28361
|
const [walletSelectionModalOpen, setWalletSelectionModalOpen] = useState33(false);
|
|
28111
|
-
const [browserWalletChainType, setBrowserWalletChainType] = useState33(() =>
|
|
28362
|
+
const [browserWalletChainType, setBrowserWalletChainType] = useState33(() => getStoredWalletState()?.chainType);
|
|
28112
28363
|
const isMobileView = useIsMobileViewport();
|
|
28113
28364
|
const [resolvedTheme, setResolvedTheme] = useState33(
|
|
28114
28365
|
theme === "auto" ? "dark" : theme
|
|
@@ -28141,6 +28392,15 @@ function CheckoutModal({
|
|
|
28141
28392
|
publishableKey,
|
|
28142
28393
|
enabled: open
|
|
28143
28394
|
});
|
|
28395
|
+
const showTransferCrypto = enableTransferCrypto ?? projectConfig?.transfer_crypto?.enabled ?? true;
|
|
28396
|
+
const showConnectWallet = enableConnectWallet ?? projectConfig?.connect_wallet?.enabled ?? true;
|
|
28397
|
+
useEffect272(() => {
|
|
28398
|
+
if (view === "transfer" && !showTransferCrypto) {
|
|
28399
|
+
setView("main");
|
|
28400
|
+
} else if (view === "wallet_connect" && !showConnectWallet) {
|
|
28401
|
+
setView("main");
|
|
28402
|
+
}
|
|
28403
|
+
}, [showConnectWallet, showTransferCrypto, view]);
|
|
28144
28404
|
const prevStatusRef = useRef102(null);
|
|
28145
28405
|
useEffect272(() => {
|
|
28146
28406
|
if (!paymentIntent) return;
|
|
@@ -28231,7 +28491,7 @@ function CheckoutModal({
|
|
|
28231
28491
|
const handleBrowserWalletClick = useCallback62(
|
|
28232
28492
|
(walletInfo) => {
|
|
28233
28493
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
28234
|
-
|
|
28494
|
+
setStoredWalletState(walletInfo.type);
|
|
28235
28495
|
setBrowserWalletChainType(walletChainType);
|
|
28236
28496
|
const matchingDepositWallet = wallets.find(
|
|
28237
28497
|
(w) => w.chain_type === walletChainType
|
|
@@ -28258,7 +28518,7 @@ function CheckoutModal({
|
|
|
28258
28518
|
const handleWalletConnected = useCallback62(
|
|
28259
28519
|
(walletInfo) => {
|
|
28260
28520
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
28261
|
-
|
|
28521
|
+
setStoredWalletState(walletInfo.type);
|
|
28262
28522
|
setBrowserWalletChainType(walletChainType);
|
|
28263
28523
|
const matchingDepositWallet = wallets.find(
|
|
28264
28524
|
(w) => w.chain_type === walletChainType
|
|
@@ -28282,7 +28542,7 @@ function CheckoutModal({
|
|
|
28282
28542
|
);
|
|
28283
28543
|
const handleWalletDisconnect = useCallback62(() => {
|
|
28284
28544
|
setUserDisconnectedWallet(true);
|
|
28285
|
-
|
|
28545
|
+
clearStoredWalletState();
|
|
28286
28546
|
setBrowserWalletChainType(void 0);
|
|
28287
28547
|
setBrowserWalletInfo(null);
|
|
28288
28548
|
setBrowserWalletModalOpen(false);
|
|
@@ -28517,7 +28777,7 @@ function CheckoutModal({
|
|
|
28517
28777
|
] }) : paymentIntent ? /* @__PURE__ */ jsxs50("div", { className: "uf-space-y-3", children: [
|
|
28518
28778
|
progressSection,
|
|
28519
28779
|
(paymentIntent.status === "requires_payment" || paymentIntent.status === "processing") && /* @__PURE__ */ jsxs50(Fragment12, { children: [
|
|
28520
|
-
/* @__PURE__ */ jsx56(
|
|
28780
|
+
showTransferCrypto && /* @__PURE__ */ jsx56(
|
|
28521
28781
|
TransferCryptoButton,
|
|
28522
28782
|
{
|
|
28523
28783
|
onClick: () => setView("transfer"),
|
|
@@ -28526,7 +28786,7 @@ function CheckoutModal({
|
|
|
28526
28786
|
featuredTokens: projectConfig?.transfer_crypto.networks
|
|
28527
28787
|
}
|
|
28528
28788
|
),
|
|
28529
|
-
|
|
28789
|
+
showConnectWallet && !isMobileView && /* @__PURE__ */ jsx56(
|
|
28530
28790
|
BrowserWalletButton,
|
|
28531
28791
|
{
|
|
28532
28792
|
onClick: handleBrowserWalletClick,
|
|
@@ -28667,14 +28927,18 @@ function CheckoutModal({
|
|
|
28667
28927
|
onWalletDisconnect: handleWalletDisconnect,
|
|
28668
28928
|
onWalletConnected: (info, dw) => {
|
|
28669
28929
|
setBrowserWalletInfo({ ...info, depositWallet: dw });
|
|
28670
|
-
|
|
28930
|
+
setStoredWalletState(info.type);
|
|
28671
28931
|
setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
|
|
28672
28932
|
},
|
|
28673
28933
|
onNewDeposit: () => setView("main"),
|
|
28674
28934
|
onDone: () => setView("main"),
|
|
28675
28935
|
paymentIntentStatus: paymentIntent.status,
|
|
28676
28936
|
onBack: handleBack,
|
|
28677
|
-
onClose: handleClose
|
|
28937
|
+
onClose: handleClose,
|
|
28938
|
+
defaultSourceChainType,
|
|
28939
|
+
defaultSourceChainId,
|
|
28940
|
+
defaultSourceTokenAddress,
|
|
28941
|
+
defaultSourceSymbol
|
|
28678
28942
|
}
|
|
28679
28943
|
),
|
|
28680
28944
|
poweredByFooter
|
|
@@ -30640,6 +30904,7 @@ function UnifoldProvider2({
|
|
|
30640
30904
|
onOpenChange: closeCheckout,
|
|
30641
30905
|
clientSecret: checkoutConfig.clientSecret,
|
|
30642
30906
|
publishableKey,
|
|
30907
|
+
enableTransferCrypto: config?.enableTransferCrypto,
|
|
30643
30908
|
enableConnectWallet: config?.enableConnectWallet,
|
|
30644
30909
|
defaultSourceChainType: checkoutConfig.defaultSourceChainType,
|
|
30645
30910
|
defaultSourceChainId: checkoutConfig.defaultSourceChainId,
|
|
@@ -30696,6 +30961,7 @@ function UnifoldProvider2({
|
|
|
30696
30961
|
hideDepositTracker: config?.hideDepositTracker,
|
|
30697
30962
|
showBalanceHeader: config?.showBalanceHeader,
|
|
30698
30963
|
transferInputVariant: config?.transferInputVariant,
|
|
30964
|
+
enableTransferCrypto: config?.enableTransferCrypto,
|
|
30699
30965
|
enableConnectWallet: config?.enableConnectWallet,
|
|
30700
30966
|
enablePayWithExchange: config?.enablePayWithExchange,
|
|
30701
30967
|
enableFiatOnramp: config?.enableFiatOnramp,
|