@unifold/connect-react 0.1.61 → 0.1.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.d.mts +18 -12
- package/dist/index.d.ts +18 -12
- package/dist/index.js +739 -460
- package/dist/index.mjs +895 -616
- 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;
|
|
@@ -7382,7 +7380,7 @@ var React102 = __toESM(require("react"), 1);
|
|
|
7382
7380
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
7383
7381
|
var React112 = __toESM(require("react"), 1);
|
|
7384
7382
|
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
7385
|
-
var
|
|
7383
|
+
var React252 = __toESM(require("react"), 1);
|
|
7386
7384
|
|
|
7387
7385
|
// ../../node_modules/.pnpm/mipd@0.0.7_typescript@5.9.3/node_modules/mipd/dist/esm/utils.js
|
|
7388
7386
|
function requestProviders(listener) {
|
|
@@ -7440,28 +7438,29 @@ function createStore() {
|
|
|
7440
7438
|
|
|
7441
7439
|
// ../ui-react/dist/index.mjs
|
|
7442
7440
|
var React122 = __toESM(require("react"), 1);
|
|
7443
|
-
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
7444
7441
|
var React132 = __toESM(require("react"), 1);
|
|
7445
|
-
var
|
|
7442
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
7446
7443
|
var React142 = __toESM(require("react"), 1);
|
|
7447
|
-
var
|
|
7444
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
7448
7445
|
var React152 = __toESM(require("react"), 1);
|
|
7449
|
-
var
|
|
7446
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
7450
7447
|
var React162 = __toESM(require("react"), 1);
|
|
7451
|
-
var
|
|
7448
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
7452
7449
|
var React172 = __toESM(require("react"), 1);
|
|
7453
|
-
var
|
|
7450
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
7454
7451
|
var React182 = __toESM(require("react"), 1);
|
|
7455
|
-
var
|
|
7452
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
7456
7453
|
var React192 = __toESM(require("react"), 1);
|
|
7457
|
-
var
|
|
7454
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
7458
7455
|
var React202 = __toESM(require("react"), 1);
|
|
7459
|
-
var
|
|
7456
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
7460
7457
|
var React212 = __toESM(require("react"), 1);
|
|
7461
|
-
var
|
|
7458
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
7462
7459
|
var React222 = __toESM(require("react"), 1);
|
|
7463
|
-
var
|
|
7460
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
7464
7461
|
var React232 = __toESM(require("react"), 1);
|
|
7462
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
7463
|
+
var React242 = __toESM(require("react"), 1);
|
|
7465
7464
|
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
7466
7465
|
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
7467
7466
|
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
@@ -7476,7 +7475,7 @@ var import_react_query11 = require("@tanstack/react-query");
|
|
|
7476
7475
|
var import_react_query12 = require("@tanstack/react-query");
|
|
7477
7476
|
var import_react21 = require("react");
|
|
7478
7477
|
var import_react22 = require("react");
|
|
7479
|
-
var
|
|
7478
|
+
var React272 = __toESM(require("react"), 1);
|
|
7480
7479
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
7481
7480
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
7482
7481
|
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
@@ -9486,7 +9485,7 @@ var import_react24 = require("react");
|
|
|
9486
9485
|
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
9487
9486
|
var import_jsx_runtime60 = require("react/jsx-runtime");
|
|
9488
9487
|
var import_react25 = require("react");
|
|
9489
|
-
var
|
|
9488
|
+
var React282 = __toESM(require("react"), 1);
|
|
9490
9489
|
|
|
9491
9490
|
// ../../node_modules/.pnpm/@radix-ui+react-tooltip@1.2.8_@types+react-dom@19.2.3_@types+react@19.2.9__@types+react@19.2._udyjcec5g7ve3mpsxbgla63vgi/node_modules/@radix-ui/react-tooltip/dist/index.mjs
|
|
9492
9491
|
var React31 = __toESM(require("react"), 1);
|
|
@@ -12228,7 +12227,7 @@ var import_react_query13 = require("@tanstack/react-query");
|
|
|
12228
12227
|
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
12229
12228
|
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
12230
12229
|
var import_react26 = require("react");
|
|
12231
|
-
var
|
|
12230
|
+
var React292 = __toESM(require("react"), 1);
|
|
12232
12231
|
|
|
12233
12232
|
// ../../node_modules/.pnpm/@radix-ui+react-select@2.2.6_@types+react-dom@19.2.3_@types+react@19.2.9__@types+react@19.2.9_cot3leusltbsophitaz3dgdqdm/node_modules/@radix-ui/react-select/dist/index.mjs
|
|
12234
12233
|
var React35 = __toESM(require("react"), 1);
|
|
@@ -13465,7 +13464,7 @@ var Separator = SelectSeparator;
|
|
|
13465
13464
|
// ../ui-react/dist/index.mjs
|
|
13466
13465
|
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
13467
13466
|
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
13468
|
-
var
|
|
13467
|
+
var React302 = __toESM(require("react"), 1);
|
|
13469
13468
|
var import_react_query14 = require("@tanstack/react-query");
|
|
13470
13469
|
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
13471
13470
|
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
@@ -13499,8 +13498,32 @@ var import_jsx_runtime79 = require("react/jsx-runtime");
|
|
|
13499
13498
|
function cn(...inputs) {
|
|
13500
13499
|
return twMerge(clsx(inputs));
|
|
13501
13500
|
}
|
|
13502
|
-
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
|
+
];
|
|
13503
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
|
+
}
|
|
13504
13527
|
function getUserDisconnectedWallet() {
|
|
13505
13528
|
if (typeof window === "undefined") return false;
|
|
13506
13529
|
try {
|
|
@@ -13520,26 +13543,35 @@ function setUserDisconnectedWallet(disconnected) {
|
|
|
13520
13543
|
} catch {
|
|
13521
13544
|
}
|
|
13522
13545
|
}
|
|
13523
|
-
function
|
|
13546
|
+
function getStoredWalletState() {
|
|
13524
13547
|
if (typeof window === "undefined") return void 0;
|
|
13525
13548
|
try {
|
|
13526
|
-
const
|
|
13527
|
-
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 };
|
|
13528
13557
|
} catch {
|
|
13558
|
+
return void 0;
|
|
13529
13559
|
}
|
|
13530
|
-
return void 0;
|
|
13531
13560
|
}
|
|
13532
|
-
function
|
|
13561
|
+
function setStoredWalletState(walletType) {
|
|
13533
13562
|
if (typeof window === "undefined") return;
|
|
13563
|
+
if (!walletTypeToChain(walletType)) return;
|
|
13534
13564
|
try {
|
|
13535
|
-
localStorage.setItem(
|
|
13565
|
+
localStorage.setItem(WALLET_STATE_STORAGE_KEY, walletType);
|
|
13566
|
+
for (const key of LEGACY_WALLET_KEYS) localStorage.removeItem(key);
|
|
13536
13567
|
} catch {
|
|
13537
13568
|
}
|
|
13538
13569
|
}
|
|
13539
|
-
function
|
|
13570
|
+
function clearStoredWalletState() {
|
|
13540
13571
|
if (typeof window === "undefined") return;
|
|
13541
13572
|
try {
|
|
13542
|
-
localStorage.removeItem(
|
|
13573
|
+
localStorage.removeItem(WALLET_STATE_STORAGE_KEY);
|
|
13574
|
+
for (const key of LEGACY_WALLET_KEYS) localStorage.removeItem(key);
|
|
13543
13575
|
} catch {
|
|
13544
13576
|
}
|
|
13545
13577
|
}
|
|
@@ -14102,6 +14134,60 @@ function useDepositAddress(params) {
|
|
|
14102
14134
|
// 1s, 2s, 4s (max 10s)
|
|
14103
14135
|
});
|
|
14104
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
|
+
}
|
|
14105
14191
|
function formatUsdFromBalancePercent(maxUsdAmount, percent) {
|
|
14106
14192
|
if (maxUsdAmount <= 0 || percent < 0) return "";
|
|
14107
14193
|
const raw = maxUsdAmount * percent / 100;
|
|
@@ -18577,6 +18663,226 @@ function collectAllEip6963EthProviders() {
|
|
|
18577
18663
|
if (!store) return [];
|
|
18578
18664
|
return store.getProviders().map((d) => d.provider);
|
|
18579
18665
|
}
|
|
18666
|
+
function identifyEthWallet(provider, hint) {
|
|
18667
|
+
switch (hint) {
|
|
18668
|
+
case "metamask":
|
|
18669
|
+
return { type: "metamask", name: "MetaMask", icon: "metamask" };
|
|
18670
|
+
case "phantom":
|
|
18671
|
+
return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
|
|
18672
|
+
case "coinbase":
|
|
18673
|
+
return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
|
|
18674
|
+
case "okx":
|
|
18675
|
+
return { type: "okx", name: "OKX Wallet", icon: "okx" };
|
|
18676
|
+
case "rabby":
|
|
18677
|
+
return { type: "rabby", name: "Rabby", icon: "rabby" };
|
|
18678
|
+
case "trust":
|
|
18679
|
+
return { type: "trust", name: "Trust Wallet", icon: "trust" };
|
|
18680
|
+
case "rainbow":
|
|
18681
|
+
return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
|
|
18682
|
+
}
|
|
18683
|
+
const anyProvider = provider;
|
|
18684
|
+
if (provider.isPhantom) {
|
|
18685
|
+
return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
|
|
18686
|
+
}
|
|
18687
|
+
if (anyProvider.isCoinbaseWallet) {
|
|
18688
|
+
return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
|
|
18689
|
+
}
|
|
18690
|
+
if (anyProvider.isRabby) {
|
|
18691
|
+
return { type: "rabby", name: "Rabby", icon: "rabby" };
|
|
18692
|
+
}
|
|
18693
|
+
if (anyProvider.isTrust) {
|
|
18694
|
+
return { type: "trust", name: "Trust Wallet", icon: "trust" };
|
|
18695
|
+
}
|
|
18696
|
+
if (anyProvider.isRainbow) {
|
|
18697
|
+
return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
|
|
18698
|
+
}
|
|
18699
|
+
if (provider.isMetaMask && !provider.isPhantom) {
|
|
18700
|
+
return { type: "metamask", name: "MetaMask", icon: "metamask" };
|
|
18701
|
+
}
|
|
18702
|
+
return { type: "metamask", name: "Wallet", icon: "metamask" };
|
|
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
|
+
}
|
|
18790
|
+
async function detectConnectedBrowserWallet(chainType) {
|
|
18791
|
+
if (typeof window === "undefined") return null;
|
|
18792
|
+
if (getUserDisconnectedWallet()) return null;
|
|
18793
|
+
try {
|
|
18794
|
+
const win = window;
|
|
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;
|
|
18804
|
+
}
|
|
18805
|
+
} catch (error) {
|
|
18806
|
+
console.error("[detectConnectedBrowserWallet] detection error:", error);
|
|
18807
|
+
}
|
|
18808
|
+
return null;
|
|
18809
|
+
}
|
|
18810
|
+
function useDetectedBrowserWallet(opts = {}) {
|
|
18811
|
+
const { chainType, enabled = true, onDisconnect } = opts;
|
|
18812
|
+
const [wallet, setWallet] = React122.useState(null);
|
|
18813
|
+
const [isLoading, setIsLoading] = React122.useState(enabled);
|
|
18814
|
+
const [eip6963ProviderCount, setEip6963ProviderCount] = React122.useState(0);
|
|
18815
|
+
const onDisconnectRef = React122.useRef(onDisconnect);
|
|
18816
|
+
onDisconnectRef.current = onDisconnect;
|
|
18817
|
+
React122.useEffect(() => {
|
|
18818
|
+
const store = getEip6963Store();
|
|
18819
|
+
if (!store) return;
|
|
18820
|
+
setEip6963ProviderCount(store.getProviders().length);
|
|
18821
|
+
return store.subscribe((providers) => setEip6963ProviderCount(providers.length));
|
|
18822
|
+
}, []);
|
|
18823
|
+
React122.useEffect(() => {
|
|
18824
|
+
if (!enabled) {
|
|
18825
|
+
setWallet(null);
|
|
18826
|
+
setIsLoading(false);
|
|
18827
|
+
return;
|
|
18828
|
+
}
|
|
18829
|
+
let mounted = true;
|
|
18830
|
+
const detect = async () => {
|
|
18831
|
+
if (!mounted) return;
|
|
18832
|
+
setIsLoading(true);
|
|
18833
|
+
const detected = await detectConnectedBrowserWallet(chainType);
|
|
18834
|
+
if (!mounted) return;
|
|
18835
|
+
setWallet(detected);
|
|
18836
|
+
setIsLoading(false);
|
|
18837
|
+
};
|
|
18838
|
+
detect();
|
|
18839
|
+
const onChange = () => detect();
|
|
18840
|
+
const onDisc = () => {
|
|
18841
|
+
onDisconnectRef.current?.();
|
|
18842
|
+
detect();
|
|
18843
|
+
};
|
|
18844
|
+
const onEthAccounts = (accounts) => {
|
|
18845
|
+
if (Array.isArray(accounts) && accounts.length === 0) onDisconnectRef.current?.();
|
|
18846
|
+
detect();
|
|
18847
|
+
};
|
|
18848
|
+
const win = typeof window !== "undefined" ? window : void 0;
|
|
18849
|
+
const solanaProvider = win?.phantom?.solana || win?.solana;
|
|
18850
|
+
if (solanaProvider) {
|
|
18851
|
+
solanaProvider.on("connect", onChange);
|
|
18852
|
+
solanaProvider.on("disconnect", onDisc);
|
|
18853
|
+
solanaProvider.on("accountChanged", onChange);
|
|
18854
|
+
}
|
|
18855
|
+
const ethProviders = [];
|
|
18856
|
+
for (const { provider } of getEip6963Providers()) {
|
|
18857
|
+
const p = provider;
|
|
18858
|
+
if (p && !ethProviders.includes(p)) ethProviders.push(p);
|
|
18859
|
+
}
|
|
18860
|
+
if (win?.ethereum && !ethProviders.includes(win.ethereum)) ethProviders.push(win.ethereum);
|
|
18861
|
+
if (win?.phantom?.ethereum && !ethProviders.includes(win.phantom.ethereum)) {
|
|
18862
|
+
ethProviders.push(win.phantom.ethereum);
|
|
18863
|
+
}
|
|
18864
|
+
for (const p of ethProviders) {
|
|
18865
|
+
p.on("accountsChanged", onEthAccounts);
|
|
18866
|
+
p.on("chainChanged", onChange);
|
|
18867
|
+
}
|
|
18868
|
+
return () => {
|
|
18869
|
+
mounted = false;
|
|
18870
|
+
if (solanaProvider) {
|
|
18871
|
+
solanaProvider.off?.("connect", onChange);
|
|
18872
|
+
solanaProvider.off?.("disconnect", onDisc);
|
|
18873
|
+
solanaProvider.off?.("accountChanged", onChange);
|
|
18874
|
+
}
|
|
18875
|
+
for (const p of ethProviders) {
|
|
18876
|
+
const off = p.off?.bind(p) ?? p.removeListener?.bind(p);
|
|
18877
|
+
if (off) {
|
|
18878
|
+
off("accountsChanged", onEthAccounts);
|
|
18879
|
+
off("chainChanged", onChange);
|
|
18880
|
+
}
|
|
18881
|
+
}
|
|
18882
|
+
};
|
|
18883
|
+
}, [chainType, eip6963ProviderCount, enabled]);
|
|
18884
|
+
return { wallet, isLoading, setWallet };
|
|
18885
|
+
}
|
|
18580
18886
|
var SOLANA_DISCONNECT_TYPES = [
|
|
18581
18887
|
"phantom-solana",
|
|
18582
18888
|
"solflare",
|
|
@@ -18664,7 +18970,7 @@ function MetamaskIcon({
|
|
|
18664
18970
|
className,
|
|
18665
18971
|
variant = "color"
|
|
18666
18972
|
}) {
|
|
18667
|
-
const id =
|
|
18973
|
+
const id = React132.useId();
|
|
18668
18974
|
if (variant === "light" || variant === "dark") {
|
|
18669
18975
|
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
|
|
18670
18976
|
"svg",
|
|
@@ -18789,7 +19095,7 @@ function PhantomIcon({
|
|
|
18789
19095
|
className,
|
|
18790
19096
|
variant = "color"
|
|
18791
19097
|
}) {
|
|
18792
|
-
const id =
|
|
19098
|
+
const id = React142.useId();
|
|
18793
19099
|
if (variant === "light") {
|
|
18794
19100
|
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
18795
19101
|
"svg",
|
|
@@ -18860,7 +19166,7 @@ function CoinbaseIcon({
|
|
|
18860
19166
|
className,
|
|
18861
19167
|
variant = "color"
|
|
18862
19168
|
}) {
|
|
18863
|
-
const id =
|
|
19169
|
+
const id = React152.useId();
|
|
18864
19170
|
if (variant === "light") {
|
|
18865
19171
|
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
|
|
18866
19172
|
"svg",
|
|
@@ -18944,7 +19250,7 @@ function RabbyIcon({
|
|
|
18944
19250
|
className,
|
|
18945
19251
|
variant = "color"
|
|
18946
19252
|
}) {
|
|
18947
|
-
const id =
|
|
19253
|
+
const id = React162.useId();
|
|
18948
19254
|
if (variant === "light") {
|
|
18949
19255
|
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
18950
19256
|
"svg",
|
|
@@ -19295,7 +19601,7 @@ function RainbowIcon({
|
|
|
19295
19601
|
className,
|
|
19296
19602
|
variant = "color"
|
|
19297
19603
|
}) {
|
|
19298
|
-
const id =
|
|
19604
|
+
const id = React172.useId();
|
|
19299
19605
|
if (variant === "light") {
|
|
19300
19606
|
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
|
|
19301
19607
|
"svg",
|
|
@@ -19761,7 +20067,7 @@ function TrustIcon({
|
|
|
19761
20067
|
className,
|
|
19762
20068
|
variant = "color"
|
|
19763
20069
|
}) {
|
|
19764
|
-
const id =
|
|
20070
|
+
const id = React182.useId();
|
|
19765
20071
|
if (variant === "light") {
|
|
19766
20072
|
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
19767
20073
|
"svg",
|
|
@@ -19854,7 +20160,7 @@ function OkxIcon({
|
|
|
19854
20160
|
className,
|
|
19855
20161
|
variant = "color"
|
|
19856
20162
|
}) {
|
|
19857
|
-
const id =
|
|
20163
|
+
const id = React192.useId();
|
|
19858
20164
|
if (variant === "light") {
|
|
19859
20165
|
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
19860
20166
|
"svg",
|
|
@@ -19925,7 +20231,7 @@ function GlowIcon({
|
|
|
19925
20231
|
className,
|
|
19926
20232
|
variant = "color"
|
|
19927
20233
|
}) {
|
|
19928
|
-
const id =
|
|
20234
|
+
const id = React202.useId();
|
|
19929
20235
|
if (variant === "light") {
|
|
19930
20236
|
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
19931
20237
|
"svg",
|
|
@@ -20030,7 +20336,7 @@ function BackpackIcon({
|
|
|
20030
20336
|
className,
|
|
20031
20337
|
variant = "color"
|
|
20032
20338
|
}) {
|
|
20033
|
-
const id =
|
|
20339
|
+
const id = React212.useId();
|
|
20034
20340
|
if (variant === "light") {
|
|
20035
20341
|
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
20036
20342
|
"svg",
|
|
@@ -20107,7 +20413,7 @@ function SolflareIcon({
|
|
|
20107
20413
|
className,
|
|
20108
20414
|
variant = "color"
|
|
20109
20415
|
}) {
|
|
20110
|
-
const id =
|
|
20416
|
+
const id = React222.useId();
|
|
20111
20417
|
if (variant === "light") {
|
|
20112
20418
|
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
20113
20419
|
"svg",
|
|
@@ -20178,7 +20484,7 @@ function EthereumIcon({
|
|
|
20178
20484
|
className,
|
|
20179
20485
|
variant = "color"
|
|
20180
20486
|
}) {
|
|
20181
|
-
const id =
|
|
20487
|
+
const id = React232.useId();
|
|
20182
20488
|
if (variant === "light") {
|
|
20183
20489
|
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
20184
20490
|
"svg",
|
|
@@ -20312,7 +20618,7 @@ function SolanaIcon({
|
|
|
20312
20618
|
className,
|
|
20313
20619
|
variant = "color"
|
|
20314
20620
|
}) {
|
|
20315
|
-
const id =
|
|
20621
|
+
const id = React242.useId();
|
|
20316
20622
|
if (variant === "light") {
|
|
20317
20623
|
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
20318
20624
|
"svg",
|
|
@@ -20561,44 +20867,6 @@ function truncateAddress3(address) {
|
|
|
20561
20867
|
if (address.length <= 10) return address;
|
|
20562
20868
|
return `${address.slice(0, 4)}...${address.slice(-4)}`;
|
|
20563
20869
|
}
|
|
20564
|
-
function identifyEthWallet(provider, _win, hint) {
|
|
20565
|
-
switch (hint) {
|
|
20566
|
-
case "metamask":
|
|
20567
|
-
return { type: "metamask", name: "MetaMask", icon: "metamask" };
|
|
20568
|
-
case "phantom":
|
|
20569
|
-
return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
|
|
20570
|
-
case "coinbase":
|
|
20571
|
-
return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
|
|
20572
|
-
case "okx":
|
|
20573
|
-
return { type: "okx", name: "OKX Wallet", icon: "okx" };
|
|
20574
|
-
case "rabby":
|
|
20575
|
-
return { type: "rabby", name: "Rabby", icon: "rabby" };
|
|
20576
|
-
case "trust":
|
|
20577
|
-
return { type: "trust", name: "Trust Wallet", icon: "trust" };
|
|
20578
|
-
case "rainbow":
|
|
20579
|
-
return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
|
|
20580
|
-
}
|
|
20581
|
-
const anyProvider = provider;
|
|
20582
|
-
if (provider.isPhantom) {
|
|
20583
|
-
return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
|
|
20584
|
-
}
|
|
20585
|
-
if (anyProvider.isCoinbaseWallet) {
|
|
20586
|
-
return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
|
|
20587
|
-
}
|
|
20588
|
-
if (anyProvider.isRabby) {
|
|
20589
|
-
return { type: "rabby", name: "Rabby", icon: "rabby" };
|
|
20590
|
-
}
|
|
20591
|
-
if (anyProvider.isTrust) {
|
|
20592
|
-
return { type: "trust", name: "Trust Wallet", icon: "trust" };
|
|
20593
|
-
}
|
|
20594
|
-
if (anyProvider.isRainbow) {
|
|
20595
|
-
return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
|
|
20596
|
-
}
|
|
20597
|
-
if (provider.isMetaMask && !provider.isPhantom) {
|
|
20598
|
-
return { type: "metamask", name: "MetaMask", icon: "metamask" };
|
|
20599
|
-
}
|
|
20600
|
-
return { type: "metamask", name: "Wallet", icon: "metamask" };
|
|
20601
|
-
}
|
|
20602
20870
|
function BrowserWalletButton({
|
|
20603
20871
|
onClick,
|
|
20604
20872
|
onConnectClick,
|
|
@@ -20609,30 +20877,19 @@ function BrowserWalletButton({
|
|
|
20609
20877
|
subtitle = i18n2.depositModal.browserWallet.subtitle
|
|
20610
20878
|
}) {
|
|
20611
20879
|
const { colors: colors2, fonts, components } = useTheme();
|
|
20612
|
-
const [isHovered, setIsHovered] =
|
|
20613
|
-
const [isTouchDevice, setIsTouchDevice] =
|
|
20614
|
-
const
|
|
20615
|
-
const [
|
|
20616
|
-
const [
|
|
20617
|
-
const [
|
|
20618
|
-
const [
|
|
20619
|
-
const
|
|
20620
|
-
const onDisconnectRef = React242.useRef(onDisconnect);
|
|
20880
|
+
const [isHovered, setIsHovered] = React252.useState(false);
|
|
20881
|
+
const [isTouchDevice, setIsTouchDevice] = React252.useState(false);
|
|
20882
|
+
const { wallet, isLoading, setWallet } = useDetectedBrowserWallet({ chainType, onDisconnect });
|
|
20883
|
+
const [isConnecting, setIsConnecting] = React252.useState(false);
|
|
20884
|
+
const [balanceText, setBalanceText] = React252.useState(null);
|
|
20885
|
+
const [isLoadingBalance, setIsLoadingBalance] = React252.useState(false);
|
|
20886
|
+
const [isDisconnecting, setIsDisconnecting] = React252.useState(false);
|
|
20887
|
+
const onDisconnectRef = React252.useRef(onDisconnect);
|
|
20621
20888
|
onDisconnectRef.current = onDisconnect;
|
|
20622
|
-
|
|
20889
|
+
React252.useEffect(() => {
|
|
20623
20890
|
setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
20624
20891
|
}, []);
|
|
20625
|
-
|
|
20626
|
-
React242.useEffect(() => {
|
|
20627
|
-
const store = getEip6963Store();
|
|
20628
|
-
if (!store) return;
|
|
20629
|
-
setEip6963ProviderCount(store.getProviders().length);
|
|
20630
|
-
const unsubscribe = store.subscribe((providers) => {
|
|
20631
|
-
setEip6963ProviderCount(providers.length);
|
|
20632
|
-
});
|
|
20633
|
-
return unsubscribe;
|
|
20634
|
-
}, []);
|
|
20635
|
-
React242.useEffect(() => {
|
|
20892
|
+
React252.useEffect(() => {
|
|
20636
20893
|
if (!wallet || !publishableKey) {
|
|
20637
20894
|
setBalanceText(null);
|
|
20638
20895
|
return;
|
|
@@ -20673,206 +20930,6 @@ function BrowserWalletButton({
|
|
|
20673
20930
|
cancelled = true;
|
|
20674
20931
|
};
|
|
20675
20932
|
}, [wallet, publishableKey]);
|
|
20676
|
-
React242.useEffect(() => {
|
|
20677
|
-
let mounted = true;
|
|
20678
|
-
const detectWallet = async () => {
|
|
20679
|
-
if (!mounted) return;
|
|
20680
|
-
setIsLoading(true);
|
|
20681
|
-
try {
|
|
20682
|
-
const win = typeof window !== "undefined" ? window : null;
|
|
20683
|
-
if (!win) return;
|
|
20684
|
-
if (getUserDisconnectedWallet()) {
|
|
20685
|
-
if (mounted) {
|
|
20686
|
-
setWallet(null);
|
|
20687
|
-
setIsLoading(false);
|
|
20688
|
-
}
|
|
20689
|
-
return;
|
|
20690
|
-
}
|
|
20691
|
-
if (!chainType || chainType === "solana") {
|
|
20692
|
-
const anyWin = win;
|
|
20693
|
-
const trySilentSolana = async (provider, type, name, icon) => {
|
|
20694
|
-
if (!provider) return false;
|
|
20695
|
-
if (provider.isConnected && provider.publicKey) {
|
|
20696
|
-
if (mounted) {
|
|
20697
|
-
setWallet({
|
|
20698
|
-
type,
|
|
20699
|
-
name,
|
|
20700
|
-
address: provider.publicKey.toString(),
|
|
20701
|
-
icon
|
|
20702
|
-
});
|
|
20703
|
-
setIsLoading(false);
|
|
20704
|
-
}
|
|
20705
|
-
return true;
|
|
20706
|
-
}
|
|
20707
|
-
try {
|
|
20708
|
-
const resp = await provider.connect({ onlyIfTrusted: true });
|
|
20709
|
-
if (mounted && resp.publicKey) {
|
|
20710
|
-
setWallet({
|
|
20711
|
-
type,
|
|
20712
|
-
name,
|
|
20713
|
-
address: resp.publicKey.toString(),
|
|
20714
|
-
icon
|
|
20715
|
-
});
|
|
20716
|
-
setIsLoading(false);
|
|
20717
|
-
return true;
|
|
20718
|
-
}
|
|
20719
|
-
} catch {
|
|
20720
|
-
}
|
|
20721
|
-
return false;
|
|
20722
|
-
};
|
|
20723
|
-
if (await trySilentSolana(
|
|
20724
|
-
win.phantom?.solana,
|
|
20725
|
-
"phantom-solana",
|
|
20726
|
-
"Phantom",
|
|
20727
|
-
"phantom"
|
|
20728
|
-
))
|
|
20729
|
-
return;
|
|
20730
|
-
if (await trySilentSolana(
|
|
20731
|
-
anyWin.solflare,
|
|
20732
|
-
"solflare",
|
|
20733
|
-
"Solflare",
|
|
20734
|
-
"solflare"
|
|
20735
|
-
))
|
|
20736
|
-
return;
|
|
20737
|
-
if (await trySilentSolana(
|
|
20738
|
-
anyWin.backpack,
|
|
20739
|
-
"backpack",
|
|
20740
|
-
"Backpack",
|
|
20741
|
-
"backpack"
|
|
20742
|
-
))
|
|
20743
|
-
return;
|
|
20744
|
-
if (await trySilentSolana(
|
|
20745
|
-
anyWin.glow,
|
|
20746
|
-
"glow",
|
|
20747
|
-
"Glow",
|
|
20748
|
-
"glow"
|
|
20749
|
-
))
|
|
20750
|
-
return;
|
|
20751
|
-
}
|
|
20752
|
-
if (!chainType || chainType === "ethereum") {
|
|
20753
|
-
const anyWin = win;
|
|
20754
|
-
const allProviders = [];
|
|
20755
|
-
const eip6963 = getEip6963Providers();
|
|
20756
|
-
for (const { provider, walletId } of eip6963) {
|
|
20757
|
-
allProviders.push({
|
|
20758
|
-
provider,
|
|
20759
|
-
walletId: walletId === "unknown" ? "default" : walletId
|
|
20760
|
-
});
|
|
20761
|
-
}
|
|
20762
|
-
if (allProviders.length === 0) {
|
|
20763
|
-
if (win.phantom?.ethereum) {
|
|
20764
|
-
allProviders.push({
|
|
20765
|
-
provider: win.phantom.ethereum,
|
|
20766
|
-
walletId: "phantom"
|
|
20767
|
-
});
|
|
20768
|
-
}
|
|
20769
|
-
if (anyWin.okxwallet) {
|
|
20770
|
-
allProviders.push({
|
|
20771
|
-
provider: anyWin.okxwallet,
|
|
20772
|
-
walletId: "okx"
|
|
20773
|
-
});
|
|
20774
|
-
}
|
|
20775
|
-
if (anyWin.coinbaseWalletExtension) {
|
|
20776
|
-
allProviders.push({
|
|
20777
|
-
provider: anyWin.coinbaseWalletExtension,
|
|
20778
|
-
walletId: "coinbase"
|
|
20779
|
-
});
|
|
20780
|
-
}
|
|
20781
|
-
if (win.ethereum) {
|
|
20782
|
-
const isDuplicate = allProviders.some(
|
|
20783
|
-
(p) => p.provider === win.ethereum
|
|
20784
|
-
);
|
|
20785
|
-
if (!isDuplicate) {
|
|
20786
|
-
allProviders.push({
|
|
20787
|
-
provider: win.ethereum,
|
|
20788
|
-
walletId: "default"
|
|
20789
|
-
});
|
|
20790
|
-
}
|
|
20791
|
-
}
|
|
20792
|
-
}
|
|
20793
|
-
for (const { provider, walletId } of allProviders) {
|
|
20794
|
-
if (!provider) continue;
|
|
20795
|
-
try {
|
|
20796
|
-
const accounts = await provider.request({
|
|
20797
|
-
method: "eth_accounts"
|
|
20798
|
-
});
|
|
20799
|
-
if (!accounts || accounts.length === 0) continue;
|
|
20800
|
-
const address = accounts[0];
|
|
20801
|
-
const resolved = identifyEthWallet(provider, anyWin, walletId);
|
|
20802
|
-
if (mounted) {
|
|
20803
|
-
setWallet({ ...resolved, address });
|
|
20804
|
-
setIsLoading(false);
|
|
20805
|
-
}
|
|
20806
|
-
return;
|
|
20807
|
-
} catch {
|
|
20808
|
-
}
|
|
20809
|
-
}
|
|
20810
|
-
}
|
|
20811
|
-
if (mounted) {
|
|
20812
|
-
setWallet(null);
|
|
20813
|
-
setIsLoading(false);
|
|
20814
|
-
}
|
|
20815
|
-
} catch (error) {
|
|
20816
|
-
console.error("[BrowserWalletButton] Error detecting wallet:", error);
|
|
20817
|
-
if (mounted) {
|
|
20818
|
-
setWallet(null);
|
|
20819
|
-
setIsLoading(false);
|
|
20820
|
-
}
|
|
20821
|
-
}
|
|
20822
|
-
};
|
|
20823
|
-
detectWallet();
|
|
20824
|
-
const handleAccountsChanged = () => {
|
|
20825
|
-
detectWallet();
|
|
20826
|
-
};
|
|
20827
|
-
const handleDisconnect = () => {
|
|
20828
|
-
onDisconnectRef.current?.();
|
|
20829
|
-
detectWallet();
|
|
20830
|
-
};
|
|
20831
|
-
const handleEthAccountsChanged = (accounts) => {
|
|
20832
|
-
if (Array.isArray(accounts) && accounts.length === 0) {
|
|
20833
|
-
onDisconnectRef.current?.();
|
|
20834
|
-
}
|
|
20835
|
-
detectWallet();
|
|
20836
|
-
};
|
|
20837
|
-
const solanaProvider = window.phantom?.solana || window.solana;
|
|
20838
|
-
if (solanaProvider) {
|
|
20839
|
-
solanaProvider.on("connect", handleAccountsChanged);
|
|
20840
|
-
solanaProvider.on("disconnect", handleDisconnect);
|
|
20841
|
-
solanaProvider.on("accountChanged", handleAccountsChanged);
|
|
20842
|
-
}
|
|
20843
|
-
const ethProviders = [];
|
|
20844
|
-
for (const { provider } of getEip6963Providers()) {
|
|
20845
|
-
const p = provider;
|
|
20846
|
-
if (p && !ethProviders.includes(p)) {
|
|
20847
|
-
ethProviders.push(p);
|
|
20848
|
-
}
|
|
20849
|
-
}
|
|
20850
|
-
if (window.ethereum && !ethProviders.includes(window.ethereum)) {
|
|
20851
|
-
ethProviders.push(window.ethereum);
|
|
20852
|
-
}
|
|
20853
|
-
if (window.phantom?.ethereum && !ethProviders.includes(window.phantom.ethereum)) {
|
|
20854
|
-
ethProviders.push(window.phantom.ethereum);
|
|
20855
|
-
}
|
|
20856
|
-
for (const provider of ethProviders) {
|
|
20857
|
-
provider.on("accountsChanged", handleEthAccountsChanged);
|
|
20858
|
-
provider.on("chainChanged", handleAccountsChanged);
|
|
20859
|
-
}
|
|
20860
|
-
return () => {
|
|
20861
|
-
mounted = false;
|
|
20862
|
-
if (solanaProvider) {
|
|
20863
|
-
solanaProvider.off("connect", handleAccountsChanged);
|
|
20864
|
-
solanaProvider.off("disconnect", handleDisconnect);
|
|
20865
|
-
solanaProvider.off("accountChanged", handleAccountsChanged);
|
|
20866
|
-
}
|
|
20867
|
-
for (const provider of ethProviders) {
|
|
20868
|
-
const off = provider.off?.bind(provider) ?? provider.removeListener?.bind(provider);
|
|
20869
|
-
if (off) {
|
|
20870
|
-
off("accountsChanged", handleEthAccountsChanged);
|
|
20871
|
-
off("chainChanged", handleAccountsChanged);
|
|
20872
|
-
}
|
|
20873
|
-
}
|
|
20874
|
-
};
|
|
20875
|
-
}, [chainType, eip6963ProviderCount]);
|
|
20876
20933
|
const handleConnect = async () => {
|
|
20877
20934
|
if (wallet) {
|
|
20878
20935
|
onClick(wallet);
|
|
@@ -20889,6 +20946,7 @@ function BrowserWalletButton({
|
|
|
20889
20946
|
if (solanaProvider?.isPhantom) {
|
|
20890
20947
|
const { publicKey } = await solanaProvider.connect();
|
|
20891
20948
|
setUserDisconnectedWallet(false);
|
|
20949
|
+
setStoredWalletState("phantom-solana");
|
|
20892
20950
|
setWallet({
|
|
20893
20951
|
type: "phantom-solana",
|
|
20894
20952
|
name: "Phantom",
|
|
@@ -20908,8 +20966,10 @@ function BrowserWalletButton({
|
|
|
20908
20966
|
if (accounts && accounts.length > 0) {
|
|
20909
20967
|
setUserDisconnectedWallet(false);
|
|
20910
20968
|
const isPhantom = ethProvider.isPhantom;
|
|
20969
|
+
const walletType = isPhantom ? "phantom-ethereum" : "metamask";
|
|
20970
|
+
setStoredWalletState(walletType);
|
|
20911
20971
|
setWallet({
|
|
20912
|
-
type:
|
|
20972
|
+
type: walletType,
|
|
20913
20973
|
name: isPhantom ? "Phantom" : "MetaMask",
|
|
20914
20974
|
address: accounts[0],
|
|
20915
20975
|
icon: isPhantom ? "phantom" : "metamask"
|
|
@@ -20956,7 +21016,7 @@ function BrowserWalletButton({
|
|
|
20956
21016
|
border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
|
|
20957
21017
|
};
|
|
20958
21018
|
const sortedWallets = featuredWallets ? [...featuredWallets].sort((a, b) => a.position - b.position) : [];
|
|
20959
|
-
const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ?
|
|
21019
|
+
const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React252.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
|
|
20960
21020
|
size: 36,
|
|
20961
21021
|
className: "uf-rounded-lg",
|
|
20962
21022
|
variant: "color"
|
|
@@ -21218,7 +21278,12 @@ function CoinbaseConnect({
|
|
|
21218
21278
|
onBack: parentOnBack,
|
|
21219
21279
|
onDisconnect,
|
|
21220
21280
|
skipToHoldings,
|
|
21221
|
-
|
|
21281
|
+
canGoBack = true,
|
|
21282
|
+
onExecutionsChange,
|
|
21283
|
+
defaultSourceChainType,
|
|
21284
|
+
defaultSourceChainId,
|
|
21285
|
+
defaultSourceTokenAddress,
|
|
21286
|
+
defaultSourceSymbol
|
|
21222
21287
|
}) {
|
|
21223
21288
|
const { colors: colors2, fonts, components } = useTheme();
|
|
21224
21289
|
const { projectConfig } = useProjectConfig({ publishableKey });
|
|
@@ -21283,6 +21348,21 @@ function CoinbaseConnect({
|
|
|
21283
21348
|
params: defaultTokenParams,
|
|
21284
21349
|
publishableKey
|
|
21285
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
|
+
);
|
|
21286
21366
|
const sortedHoldings = (0, import_react20.useMemo)(() => {
|
|
21287
21367
|
const supported = [];
|
|
21288
21368
|
const unsupported = [];
|
|
@@ -21292,13 +21372,42 @@ function CoinbaseConnect({
|
|
|
21292
21372
|
if (isSupported) supported.push(account);
|
|
21293
21373
|
else unsupported.push(account);
|
|
21294
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
|
+
}
|
|
21295
21384
|
return [...supported, ...unsupported];
|
|
21296
|
-
}, [
|
|
21385
|
+
}, [
|
|
21386
|
+
holdings,
|
|
21387
|
+
supportedSymbols,
|
|
21388
|
+
exchangeSupportedCurrencies,
|
|
21389
|
+
defaultSourceCurrency
|
|
21390
|
+
]);
|
|
21297
21391
|
const selectedHoldingIsSupported = (0, import_react20.useMemo)(() => {
|
|
21298
21392
|
if (!selectedHolding) return false;
|
|
21299
21393
|
const currencyLower = selectedHolding.currency.toLowerCase();
|
|
21300
21394
|
return (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
|
|
21301
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
|
+
]);
|
|
21302
21411
|
const exchangeName = selectedExchange?.service_provider_display_name || "Exchange";
|
|
21303
21412
|
const {
|
|
21304
21413
|
executions: depositExecutions,
|
|
@@ -21605,6 +21714,16 @@ function CoinbaseConnect({
|
|
|
21605
21714
|
setIsLoading(false);
|
|
21606
21715
|
}
|
|
21607
21716
|
};
|
|
21717
|
+
const handleDisconnect = () => {
|
|
21718
|
+
onDisconnect?.();
|
|
21719
|
+
if (!canGoBack) {
|
|
21720
|
+
setAccessToken(null);
|
|
21721
|
+
setHoldings([]);
|
|
21722
|
+
setSelectedHolding(null);
|
|
21723
|
+
setSelectedAsset(null);
|
|
21724
|
+
transitionTo("select_exchange");
|
|
21725
|
+
}
|
|
21726
|
+
};
|
|
21608
21727
|
const handleBack = () => {
|
|
21609
21728
|
switch (view) {
|
|
21610
21729
|
case "select_exchange":
|
|
@@ -21665,7 +21784,7 @@ function CoinbaseConnect({
|
|
|
21665
21784
|
DepositHeader,
|
|
21666
21785
|
{
|
|
21667
21786
|
title: t12.title,
|
|
21668
|
-
showBack:
|
|
21787
|
+
showBack: canGoBack,
|
|
21669
21788
|
onBack: handleBack,
|
|
21670
21789
|
onClose
|
|
21671
21790
|
}
|
|
@@ -21678,7 +21797,7 @@ function CoinbaseConnect({
|
|
|
21678
21797
|
DepositHeader,
|
|
21679
21798
|
{
|
|
21680
21799
|
title: t12.title,
|
|
21681
|
-
showBack:
|
|
21800
|
+
showBack: canGoBack,
|
|
21682
21801
|
onBack: handleBack,
|
|
21683
21802
|
onClose
|
|
21684
21803
|
}
|
|
@@ -22390,7 +22509,7 @@ function CoinbaseConnect({
|
|
|
22390
22509
|
borderRadius: components.button.borderRadius,
|
|
22391
22510
|
fontFamily: fonts.medium
|
|
22392
22511
|
},
|
|
22393
|
-
onClick:
|
|
22512
|
+
onClick: handleDisconnect,
|
|
22394
22513
|
children: t12.disconnect
|
|
22395
22514
|
}
|
|
22396
22515
|
)
|
|
@@ -23177,7 +23296,7 @@ function ThemeStyleInjector({
|
|
|
23177
23296
|
className
|
|
23178
23297
|
}) {
|
|
23179
23298
|
const { colors: colors2, fonts, mode } = useTheme();
|
|
23180
|
-
const cssVars =
|
|
23299
|
+
const cssVars = React272.useMemo(() => {
|
|
23181
23300
|
const hexToHSL = (hex) => {
|
|
23182
23301
|
hex = hex.replace("#", "");
|
|
23183
23302
|
const r2 = parseInt(hex.slice(0, 2), 16) / 255;
|
|
@@ -23237,7 +23356,7 @@ function ThemeStyleInjector({
|
|
|
23237
23356
|
...fonts.regular ? { "--uf-font-family": fonts.regular } : {}
|
|
23238
23357
|
};
|
|
23239
23358
|
}, [colors2, fonts.regular]);
|
|
23240
|
-
|
|
23359
|
+
React272.useEffect(() => {
|
|
23241
23360
|
if (typeof document === "undefined") return;
|
|
23242
23361
|
if (fonts.regular) {
|
|
23243
23362
|
document.documentElement.style.setProperty(
|
|
@@ -24196,14 +24315,14 @@ function useCopyAddress() {
|
|
|
24196
24315
|
return { copied, handleCopy };
|
|
24197
24316
|
}
|
|
24198
24317
|
var TooltipProvider2 = Provider;
|
|
24199
|
-
var TooltipContext =
|
|
24318
|
+
var TooltipContext = React282.createContext({
|
|
24200
24319
|
open: false,
|
|
24201
24320
|
onOpenChange: () => {
|
|
24202
24321
|
}
|
|
24203
24322
|
});
|
|
24204
|
-
var TooltipTrigger2 =
|
|
24205
|
-
const { open, onOpenChange } =
|
|
24206
|
-
const handleClick =
|
|
24323
|
+
var TooltipTrigger2 = React282.forwardRef(({ onClick, ...props }, ref) => {
|
|
24324
|
+
const { open, onOpenChange } = React282.useContext(TooltipContext);
|
|
24325
|
+
const handleClick = React282.useCallback(
|
|
24207
24326
|
(e) => {
|
|
24208
24327
|
onOpenChange(!open);
|
|
24209
24328
|
onClick?.(e);
|
|
@@ -24213,7 +24332,7 @@ var TooltipTrigger2 = React272.forwardRef(({ onClick, ...props }, ref) => {
|
|
|
24213
24332
|
return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Trigger, { ref, onClick: handleClick, ...props });
|
|
24214
24333
|
});
|
|
24215
24334
|
TooltipTrigger2.displayName = Trigger.displayName;
|
|
24216
|
-
var TooltipContent2 =
|
|
24335
|
+
var TooltipContent2 = React282.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
|
|
24217
24336
|
const { themeClass, colors: colors2 } = useTheme();
|
|
24218
24337
|
return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Portal3, { children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
24219
24338
|
Content22,
|
|
@@ -24818,7 +24937,7 @@ function TransferCryptoSingleInput({
|
|
|
24818
24937
|
}
|
|
24819
24938
|
var Select2 = Root23;
|
|
24820
24939
|
var SelectValue2 = Value;
|
|
24821
|
-
var SelectTrigger2 =
|
|
24940
|
+
var SelectTrigger2 = React292.forwardRef(({ className, style, children, ...props }, ref) => {
|
|
24822
24941
|
const { components } = useTheme();
|
|
24823
24942
|
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
24824
24943
|
Trigger2,
|
|
@@ -24842,7 +24961,7 @@ var SelectTrigger2 = React282.forwardRef(({ className, style, children, ...props
|
|
|
24842
24961
|
);
|
|
24843
24962
|
});
|
|
24844
24963
|
SelectTrigger2.displayName = Trigger2.displayName;
|
|
24845
|
-
var SelectScrollUpButton2 =
|
|
24964
|
+
var SelectScrollUpButton2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
24846
24965
|
ScrollUpButton,
|
|
24847
24966
|
{
|
|
24848
24967
|
ref,
|
|
@@ -24855,7 +24974,7 @@ var SelectScrollUpButton2 = React282.forwardRef(({ className, ...props }, ref) =
|
|
|
24855
24974
|
}
|
|
24856
24975
|
));
|
|
24857
24976
|
SelectScrollUpButton2.displayName = ScrollUpButton.displayName;
|
|
24858
|
-
var SelectScrollDownButton2 =
|
|
24977
|
+
var SelectScrollDownButton2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
24859
24978
|
ScrollDownButton,
|
|
24860
24979
|
{
|
|
24861
24980
|
ref,
|
|
@@ -24868,7 +24987,7 @@ var SelectScrollDownButton2 = React282.forwardRef(({ className, ...props }, ref)
|
|
|
24868
24987
|
}
|
|
24869
24988
|
));
|
|
24870
24989
|
SelectScrollDownButton2.displayName = ScrollDownButton.displayName;
|
|
24871
|
-
var SelectContent2 =
|
|
24990
|
+
var SelectContent2 = React292.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
|
|
24872
24991
|
const { themeClass, colors: colors2, components } = useTheme();
|
|
24873
24992
|
return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Portal4, { children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
24874
24993
|
Content23,
|
|
@@ -24906,7 +25025,7 @@ var SelectContent2 = React282.forwardRef(({ className, style, children, position
|
|
|
24906
25025
|
) });
|
|
24907
25026
|
});
|
|
24908
25027
|
SelectContent2.displayName = Content23.displayName;
|
|
24909
|
-
var SelectLabel2 =
|
|
25028
|
+
var SelectLabel2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
24910
25029
|
Label,
|
|
24911
25030
|
{
|
|
24912
25031
|
ref,
|
|
@@ -24918,7 +25037,7 @@ var SelectLabel2 = React282.forwardRef(({ className, ...props }, ref) => /* @__P
|
|
|
24918
25037
|
}
|
|
24919
25038
|
));
|
|
24920
25039
|
SelectLabel2.displayName = Label.displayName;
|
|
24921
|
-
var SelectItem2 =
|
|
25040
|
+
var SelectItem2 = React292.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
24922
25041
|
Item,
|
|
24923
25042
|
{
|
|
24924
25043
|
ref,
|
|
@@ -24934,7 +25053,7 @@ var SelectItem2 = React282.forwardRef(({ className, children, ...props }, ref) =
|
|
|
24934
25053
|
}
|
|
24935
25054
|
));
|
|
24936
25055
|
SelectItem2.displayName = Item.displayName;
|
|
24937
|
-
var SelectSeparator2 =
|
|
25056
|
+
var SelectSeparator2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
24938
25057
|
Separator,
|
|
24939
25058
|
{
|
|
24940
25059
|
ref,
|
|
@@ -26454,6 +26573,19 @@ var WALLET_DEFINITIONS = [
|
|
|
26454
26573
|
{ id: "backpack", name: "Backpack", networks: ["solana"], installUrl: "https://backpack.app/" },
|
|
26455
26574
|
{ id: "glow", name: "Glow", networks: ["solana"], installUrl: "https://glow.app/" }
|
|
26456
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
|
+
}
|
|
26457
26589
|
function getSolanaProviders() {
|
|
26458
26590
|
if (typeof window === "undefined") return {};
|
|
26459
26591
|
const win = window;
|
|
@@ -26596,24 +26728,33 @@ function WalletConnect({
|
|
|
26596
26728
|
checkoutRemainingBaseUnits,
|
|
26597
26729
|
stablecoinParity = false,
|
|
26598
26730
|
productType,
|
|
26731
|
+
defaultSourceChainType,
|
|
26732
|
+
defaultSourceChainId,
|
|
26733
|
+
defaultSourceTokenAddress,
|
|
26734
|
+
defaultSourceSymbol,
|
|
26599
26735
|
onBack: parentOnBack,
|
|
26600
26736
|
onClose,
|
|
26737
|
+
canGoBack = true,
|
|
26738
|
+
depositWalletsLoading = false,
|
|
26601
26739
|
onExecutionsChange
|
|
26602
26740
|
}) {
|
|
26603
26741
|
const { colors: colors2, fonts, components } = useTheme();
|
|
26604
|
-
const walletProvidedAtMount =
|
|
26605
|
-
const [activeWalletInfo, setActiveWalletInfo] =
|
|
26606
|
-
const [activeDepositWallet, setActiveDepositWallet] =
|
|
26742
|
+
const walletProvidedAtMount = React302.useRef(!!initialWalletInfo && !!initialDepositWallet);
|
|
26743
|
+
const [activeWalletInfo, setActiveWalletInfo] = React302.useState(initialWalletInfo ?? null);
|
|
26744
|
+
const [activeDepositWallet, setActiveDepositWallet] = React302.useState(initialDepositWallet ?? null);
|
|
26607
26745
|
const initialView = initialWalletInfo && initialDepositWallet ? "select_token" : "select_wallet";
|
|
26608
|
-
const [view, setView] =
|
|
26609
|
-
const [isTransitioning, setIsTransitioning] =
|
|
26610
|
-
const viewRef =
|
|
26611
|
-
const
|
|
26612
|
-
const
|
|
26613
|
-
const [
|
|
26614
|
-
const [
|
|
26615
|
-
const [
|
|
26616
|
-
|
|
26746
|
+
const [view, setView] = React302.useState(initialView);
|
|
26747
|
+
const [isTransitioning, setIsTransitioning] = React302.useState(false);
|
|
26748
|
+
const viewRef = React302.useRef(initialView);
|
|
26749
|
+
const standalone = !canGoBack && !walletProvidedAtMount.current;
|
|
26750
|
+
const { wallet: detectedWallet, isLoading: detectingWallet } = useDetectedBrowserWallet({ enabled: standalone });
|
|
26751
|
+
const [autoResolved, setAutoResolved] = React302.useState(false);
|
|
26752
|
+
const [selectedWalletDef, setSelectedWalletDef] = React302.useState(null);
|
|
26753
|
+
const [connectingNetwork, setConnectingNetwork] = React302.useState(null);
|
|
26754
|
+
const [walletError, setWalletError] = React302.useState(null);
|
|
26755
|
+
const [isWalletConnecting, setIsWalletConnecting] = React302.useState(false);
|
|
26756
|
+
const [eip6963ProviderCount, setEip6963ProviderCount] = React302.useState(0);
|
|
26757
|
+
React302.useEffect(() => {
|
|
26617
26758
|
const store = getEip6963Store();
|
|
26618
26759
|
if (!store) return;
|
|
26619
26760
|
setEip6963ProviderCount(store.getProviders().length);
|
|
@@ -26621,20 +26762,44 @@ function WalletConnect({
|
|
|
26621
26762
|
setEip6963ProviderCount(providers.length);
|
|
26622
26763
|
});
|
|
26623
26764
|
}, []);
|
|
26624
|
-
const availableWallets =
|
|
26625
|
-
|
|
26626
|
-
|
|
26627
|
-
|
|
26628
|
-
|
|
26629
|
-
|
|
26630
|
-
|
|
26631
|
-
|
|
26632
|
-
|
|
26633
|
-
|
|
26634
|
-
|
|
26635
|
-
|
|
26636
|
-
|
|
26637
|
-
|
|
26765
|
+
const availableWallets = React302.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
|
|
26766
|
+
React302.useEffect(() => {
|
|
26767
|
+
if (!standalone || autoResolved || detectingWallet) return;
|
|
26768
|
+
if (!detectedWallet) {
|
|
26769
|
+
setAutoResolved(true);
|
|
26770
|
+
return;
|
|
26771
|
+
}
|
|
26772
|
+
const wct = detectedWallet.type === "phantom-solana" || detectedWallet.type === "solflare" || detectedWallet.type === "backpack" || detectedWallet.type === "glow" ? "solana" : "ethereum";
|
|
26773
|
+
const matching = depositWallets?.find((w) => w.chain_type === wct);
|
|
26774
|
+
if (!matching) {
|
|
26775
|
+
if (!depositWalletsLoading) setAutoResolved(true);
|
|
26776
|
+
return;
|
|
26777
|
+
}
|
|
26778
|
+
setActiveWalletInfo(detectedWallet);
|
|
26779
|
+
setActiveDepositWallet(matching);
|
|
26780
|
+
onWalletConnected?.(detectedWallet, matching);
|
|
26781
|
+
setView("select_token");
|
|
26782
|
+
viewRef.current = "select_token";
|
|
26783
|
+
setAutoResolved(true);
|
|
26784
|
+
}, [standalone, autoResolved, detectingWallet, detectedWallet, depositWallets, depositWalletsLoading]);
|
|
26785
|
+
React302.useEffect(() => {
|
|
26786
|
+
if (!standalone || autoResolved) return;
|
|
26787
|
+
const t12 = setTimeout(() => setAutoResolved(true), 5e3);
|
|
26788
|
+
return () => clearTimeout(t12);
|
|
26789
|
+
}, [standalone, autoResolved]);
|
|
26790
|
+
const [balances, setBalances] = React302.useState([]);
|
|
26791
|
+
const [isLoading, setIsLoading] = React302.useState(false);
|
|
26792
|
+
const [selectedBalance, setSelectedBalance] = React302.useState(null);
|
|
26793
|
+
const [totalBalanceUsd, setTotalBalanceUsd] = React302.useState(null);
|
|
26794
|
+
const [error, setError] = React302.useState(null);
|
|
26795
|
+
const [isDisconnectingWallet, setIsDisconnectingWallet] = React302.useState(false);
|
|
26796
|
+
const [amountUsd, setAmountUsd] = React302.useState(prefillAmountUsd ?? "");
|
|
26797
|
+
const [isConfirming, setIsConfirming] = React302.useState(false);
|
|
26798
|
+
const [hasSignedTransaction, setHasSignedTransaction] = React302.useState(false);
|
|
26799
|
+
const [tokenChainDetails, setTokenChainDetails] = React302.useState(null);
|
|
26800
|
+
const [loadingTokenDetails, setLoadingTokenDetails] = React302.useState(false);
|
|
26801
|
+
const [showTransactionDetails, setShowTransactionDetails] = React302.useState(false);
|
|
26802
|
+
const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React302.useState(null);
|
|
26638
26803
|
const walletInfo = activeWalletInfo;
|
|
26639
26804
|
const depositWallet = activeDepositWallet;
|
|
26640
26805
|
const hasWallet = !!activeWalletInfo && !!activeDepositWallet;
|
|
@@ -26642,7 +26807,7 @@ function WalletConnect({
|
|
|
26642
26807
|
const recipientAddress = activeDepositWallet?.address ?? "";
|
|
26643
26808
|
const isCheckoutMode = !!checkoutAmountUsd;
|
|
26644
26809
|
const supportedChainType = chainType === "algorand" || chainType === "xrpl" ? "ethereum" : chainType;
|
|
26645
|
-
const transitionTo =
|
|
26810
|
+
const transitionTo = React302.useCallback((nextView) => {
|
|
26646
26811
|
if (nextView === viewRef.current) return;
|
|
26647
26812
|
setIsTransitioning(true);
|
|
26648
26813
|
setTimeout(() => {
|
|
@@ -26727,6 +26892,7 @@ function WalletConnect({
|
|
|
26727
26892
|
metamask: "metamask"
|
|
26728
26893
|
};
|
|
26729
26894
|
const walletType = walletIdToType[wallet.id] || "metamask";
|
|
26895
|
+
setStoredWalletState(walletType);
|
|
26730
26896
|
connectedInfo = { type: walletType, name: wallet.name, address: accounts[0], icon: wallet.id };
|
|
26731
26897
|
} else {
|
|
26732
26898
|
const solProviders = getSolanaProviders();
|
|
@@ -26755,6 +26921,7 @@ function WalletConnect({
|
|
|
26755
26921
|
const response = await provider.connect();
|
|
26756
26922
|
setUserDisconnectedWallet(false);
|
|
26757
26923
|
const walletType = wallet.id === "solflare" ? "solflare" : wallet.id === "backpack" ? "backpack" : wallet.id === "glow" ? "glow" : "phantom-solana";
|
|
26924
|
+
setStoredWalletState(walletType);
|
|
26758
26925
|
connectedInfo = { type: walletType, name: wallet.name, address: response.publicKey.toString(), icon: wallet.id };
|
|
26759
26926
|
}
|
|
26760
26927
|
const walletChainType = network === "solana" ? "solana" : "ethereum";
|
|
@@ -26779,7 +26946,7 @@ function WalletConnect({
|
|
|
26779
26946
|
}
|
|
26780
26947
|
};
|
|
26781
26948
|
const selectedToken = selectedBalance ? getTokenFromBalance(selectedBalance) : null;
|
|
26782
|
-
const effectiveDestinationAmount =
|
|
26949
|
+
const effectiveDestinationAmount = React302.useMemo(() => {
|
|
26783
26950
|
if (!checkoutRemainingBaseUnits || checkoutRemainingBaseUnits === "0") return "0";
|
|
26784
26951
|
if (!checkoutAmountUsd) return checkoutRemainingBaseUnits;
|
|
26785
26952
|
const remaining = BigInt(checkoutRemainingBaseUnits);
|
|
@@ -26807,7 +26974,7 @@ function WalletConnect({
|
|
|
26807
26974
|
stablecoinParity,
|
|
26808
26975
|
enabled: isCheckoutMode && !!selectedToken && !!checkoutDestination && effectiveDestinationAmount !== "0"
|
|
26809
26976
|
});
|
|
26810
|
-
const activeCheckoutQuote =
|
|
26977
|
+
const activeCheckoutQuote = React302.useMemo(() => {
|
|
26811
26978
|
if (!isCheckoutMode) return null;
|
|
26812
26979
|
if (walletCheckoutQuote) return { sourceAmount: walletCheckoutQuote.source_amount, sourceTokenDecimals: walletCheckoutQuote.source_token_decimals, sourceTokenSymbol: walletCheckoutQuote.source_token_symbol, sourceAmountUsd: walletCheckoutQuote.source_amount_usd, slippageBufferPercent: walletCheckoutQuote.slippage_buffer_percent ?? null };
|
|
26813
26980
|
return checkoutQuote ?? null;
|
|
@@ -26821,19 +26988,19 @@ function WalletConnect({
|
|
|
26821
26988
|
onDepositSuccess,
|
|
26822
26989
|
onDepositError
|
|
26823
26990
|
});
|
|
26824
|
-
|
|
26991
|
+
React302.useEffect(() => {
|
|
26825
26992
|
onExecutionsChange?.(depositExecutions);
|
|
26826
26993
|
}, [depositExecutions, onExecutionsChange]);
|
|
26827
|
-
|
|
26994
|
+
React302.useEffect(() => {
|
|
26828
26995
|
if (!prefillAmountUsd || !tokenChainDetails || view !== "enter_amount") return;
|
|
26829
26996
|
const minDeposit = tokenChainDetails.minimum_deposit_amount_usd || 0;
|
|
26830
26997
|
const currentAmount = parseFloat(amountUsd) || 0;
|
|
26831
26998
|
if (currentAmount > 0 && currentAmount < minDeposit) setAmountUsd(minDeposit.toFixed(2));
|
|
26832
26999
|
}, [tokenChainDetails, view, prefillAmountUsd]);
|
|
26833
|
-
|
|
27000
|
+
React302.useEffect(() => {
|
|
26834
27001
|
if (view === "review") setShowTransactionDetails(false);
|
|
26835
27002
|
}, [view]);
|
|
26836
|
-
|
|
27003
|
+
React302.useEffect(() => {
|
|
26837
27004
|
if (view !== "enter_amount" && view !== "review" || !selectedBalance || !activeDepositWallet) return;
|
|
26838
27005
|
let cancelled = false;
|
|
26839
27006
|
const fetchTokenDetails = async () => {
|
|
@@ -26860,7 +27027,7 @@ function WalletConnect({
|
|
|
26860
27027
|
cancelled = true;
|
|
26861
27028
|
};
|
|
26862
27029
|
}, [view, selectedBalance, publishableKey, activeDepositWallet]);
|
|
26863
|
-
|
|
27030
|
+
React302.useEffect(() => {
|
|
26864
27031
|
if (!activeWalletInfo || !activeDepositWallet) return;
|
|
26865
27032
|
let cancelled = false;
|
|
26866
27033
|
setIsLoading(true);
|
|
@@ -26869,18 +27036,33 @@ function WalletConnect({
|
|
|
26869
27036
|
getAddressBalances(activeWalletInfo.address, sct, publishableKey).then((response) => {
|
|
26870
27037
|
if (cancelled) return;
|
|
26871
27038
|
const nonZero = response.balances.filter((b) => b.amount !== "0");
|
|
26872
|
-
const
|
|
26873
|
-
|
|
26874
|
-
|
|
26875
|
-
|
|
26876
|
-
|
|
26877
|
-
|
|
26878
|
-
|
|
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
|
+
);
|
|
26879
27048
|
setBalances(sorted);
|
|
26880
27049
|
const totalUsd = nonZero.reduce((sum, b) => b.amount_usd ? sum + parseFloat(b.amount_usd) : sum, 0);
|
|
26881
27050
|
if (totalUsd > 0) setTotalBalanceUsd(totalUsd.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 }));
|
|
26882
27051
|
const eligible = sorted.filter(isBalanceEligible);
|
|
26883
|
-
|
|
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
|
+
});
|
|
26884
27066
|
}).catch((err) => {
|
|
26885
27067
|
if (!cancelled) {
|
|
26886
27068
|
console.error("[WalletConnect] Error fetching balances:", err);
|
|
@@ -26892,21 +27074,29 @@ function WalletConnect({
|
|
|
26892
27074
|
return () => {
|
|
26893
27075
|
cancelled = true;
|
|
26894
27076
|
};
|
|
26895
|
-
}, [
|
|
26896
|
-
|
|
27077
|
+
}, [
|
|
27078
|
+
activeWalletInfo?.address,
|
|
27079
|
+
activeDepositWallet?.chain_type,
|
|
27080
|
+
publishableKey,
|
|
27081
|
+
defaultSourceChainType,
|
|
27082
|
+
defaultSourceChainId,
|
|
27083
|
+
defaultSourceTokenAddress,
|
|
27084
|
+
defaultSourceSymbol
|
|
27085
|
+
]);
|
|
27086
|
+
const usdToTokenRate = React302.useMemo(() => {
|
|
26897
27087
|
if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
|
|
26898
27088
|
const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
|
|
26899
27089
|
const balanceUsd = parseFloat(selectedBalance.amount_usd);
|
|
26900
27090
|
if (balanceAmount === 0 || balanceUsd === 0) return 0;
|
|
26901
27091
|
return balanceAmount / balanceUsd;
|
|
26902
27092
|
}, [selectedBalance, selectedToken]);
|
|
26903
|
-
const tokenAmount =
|
|
27093
|
+
const tokenAmount = React302.useMemo(() => {
|
|
26904
27094
|
if (isCheckoutMode && activeCheckoutQuote && selectedToken) return Number(activeCheckoutQuote.sourceAmount) / 10 ** activeCheckoutQuote.sourceTokenDecimals;
|
|
26905
27095
|
const usdNum = parseFloat(amountUsd) || 0;
|
|
26906
27096
|
if (usdNum === 0 || usdToTokenRate === 0) return 0;
|
|
26907
27097
|
return usdNum * usdToTokenRate;
|
|
26908
27098
|
}, [amountUsd, usdToTokenRate, isCheckoutMode, activeCheckoutQuote, selectedToken]);
|
|
26909
|
-
|
|
27099
|
+
React302.useEffect(() => {
|
|
26910
27100
|
if (isCheckoutMode && activeCheckoutQuote?.sourceAmountUsd && view === "enter_amount") setAmountUsd(activeCheckoutQuote.sourceAmountUsd);
|
|
26911
27101
|
}, [isCheckoutMode, activeCheckoutQuote, view]);
|
|
26912
27102
|
const maxTokenAmount = selectedBalance && selectedToken ? Number(selectedBalance.amount) / 10 ** selectedToken.decimals : 0;
|
|
@@ -26914,7 +27104,7 @@ function WalletConnect({
|
|
|
26914
27104
|
const inputUsdNum = parseFloat(amountUsd) || 0;
|
|
26915
27105
|
const minDepositUsd = tokenChainDetails?.minimum_deposit_amount_usd || 0;
|
|
26916
27106
|
const isValidAmount = isCheckoutMode && activeCheckoutQuote ? tokenAmount > 0 && tokenAmount <= maxTokenAmount : inputUsdNum > 0 && inputUsdNum <= maxUsdAmount && inputUsdNum >= minDepositUsd;
|
|
26917
|
-
const formattedTokenAmount =
|
|
27107
|
+
const formattedTokenAmount = React302.useMemo(() => {
|
|
26918
27108
|
if (tokenAmount === 0 || !selectedToken) return null;
|
|
26919
27109
|
return `${tokenAmount.toFixed(6)} ${selectedToken.symbol}`.replace(/\.?0+$/, "");
|
|
26920
27110
|
}, [tokenAmount, selectedToken]);
|
|
@@ -26962,16 +27152,25 @@ function WalletConnect({
|
|
|
26962
27152
|
} catch (err) {
|
|
26963
27153
|
console.warn("[WalletConnect] disconnect error:", err);
|
|
26964
27154
|
} finally {
|
|
26965
|
-
setActiveWalletInfo(null);
|
|
26966
|
-
setActiveDepositWallet(null);
|
|
26967
|
-
setSelectedBalance(null);
|
|
26968
|
-
setBalances([]);
|
|
26969
|
-
setTotalBalanceUsd(null);
|
|
26970
|
-
setAmountUsd(prefillAmountUsd ?? "");
|
|
26971
|
-
setError(null);
|
|
26972
27155
|
setIsDisconnectingWallet(false);
|
|
26973
|
-
|
|
26974
|
-
|
|
27156
|
+
const clearWalletState = () => {
|
|
27157
|
+
setActiveWalletInfo(null);
|
|
27158
|
+
setActiveDepositWallet(null);
|
|
27159
|
+
setSelectedBalance(null);
|
|
27160
|
+
setBalances([]);
|
|
27161
|
+
setTotalBalanceUsd(null);
|
|
27162
|
+
setAmountUsd(prefillAmountUsd ?? "");
|
|
27163
|
+
setError(null);
|
|
27164
|
+
};
|
|
27165
|
+
if (standalone) {
|
|
27166
|
+
onWalletDisconnect?.();
|
|
27167
|
+
transitionTo("select_wallet");
|
|
27168
|
+
setTimeout(clearWalletState, 160);
|
|
27169
|
+
} else {
|
|
27170
|
+
clearWalletState();
|
|
27171
|
+
if (onWalletDisconnect) onWalletDisconnect();
|
|
27172
|
+
else parentOnBack?.();
|
|
27173
|
+
}
|
|
26975
27174
|
}
|
|
26976
27175
|
};
|
|
26977
27176
|
const handleReview = () => {
|
|
@@ -27097,9 +27296,15 @@ function WalletConnect({
|
|
|
27097
27296
|
setIsConfirming(false);
|
|
27098
27297
|
}
|
|
27099
27298
|
};
|
|
27299
|
+
if (standalone && !autoResolved) {
|
|
27300
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { style: viewTransitionStyle, children: [
|
|
27301
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(DepositHeader, { title: "Connect Wallet", showBack: canGoBack, onBack: handleBack, onClose }),
|
|
27302
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-16", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(LoaderCircle, { className: "uf-w-8 uf-h-8 uf-animate-spin", style: { color: colors2.primary } }) })
|
|
27303
|
+
] });
|
|
27304
|
+
}
|
|
27100
27305
|
if (view === "select_wallet") {
|
|
27101
27306
|
return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { style: viewTransitionStyle, children: [
|
|
27102
|
-
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(DepositHeader, { title: "Connect Wallet", showBack:
|
|
27307
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(DepositHeader, { title: "Connect Wallet", showBack: canGoBack, onBack: handleBack, onClose }),
|
|
27103
27308
|
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "uf-pb-4", children: [
|
|
27104
27309
|
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { className: "uf-text-sm uf-text-center uf-pb-4", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: "Select a wallet to connect" }),
|
|
27105
27310
|
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "uf-space-y-2", style: { maxHeight: 330, overflowY: "auto" }, children: availableWallets.map((wallet) => /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
|
|
@@ -27232,16 +27437,17 @@ function DepositModal({
|
|
|
27232
27437
|
defaultSourceChainId,
|
|
27233
27438
|
defaultSourceTokenAddress,
|
|
27234
27439
|
defaultSourceSymbol,
|
|
27235
|
-
hideDepositTracker
|
|
27440
|
+
hideDepositTracker,
|
|
27236
27441
|
showBalanceHeader = false,
|
|
27237
27442
|
transferInputVariant = "double_input",
|
|
27238
27443
|
depositConfirmationMode = "auto_ui",
|
|
27239
|
-
|
|
27444
|
+
enableTransferCrypto,
|
|
27445
|
+
enableConnectWallet,
|
|
27240
27446
|
browserWalletAmountQuickSelect = "percentage",
|
|
27241
27447
|
enablePayWithExchange,
|
|
27242
27448
|
enableFiatOnramp,
|
|
27243
|
-
enableConnectExchange
|
|
27244
|
-
enableCashApp
|
|
27449
|
+
enableConnectExchange,
|
|
27450
|
+
enableCashApp,
|
|
27245
27451
|
hideDepositFlowInfo = false,
|
|
27246
27452
|
hideDisplayDescription = false,
|
|
27247
27453
|
onDepositSuccess,
|
|
@@ -27259,11 +27465,23 @@ function DepositModal({
|
|
|
27259
27465
|
const { colors: colors2, fonts, components } = useTheme();
|
|
27260
27466
|
const effectiveInitialScreen = (0, import_react8.useMemo)(() => {
|
|
27261
27467
|
const s = initialScreen ?? "main";
|
|
27262
|
-
if (s === "tracker" && hideDepositTracker) return "main";
|
|
27263
|
-
if (s === "cashapp" &&
|
|
27468
|
+
if (s === "tracker" && hideDepositTracker === true) return "main";
|
|
27469
|
+
if (s === "cashapp" && enableCashApp === false) return "main";
|
|
27264
27470
|
if (s === "card" && enableFiatOnramp === false) return "main";
|
|
27471
|
+
if (s === "pay_with_exchange") return enablePayWithExchange === false ? "main" : "exchange";
|
|
27472
|
+
if (s === "exchange_connect")
|
|
27473
|
+
return enableConnectExchange === false ? "main" : "coinbase_connect";
|
|
27474
|
+
if (s === "wallet_connect") return enableConnectWallet === false ? "main" : "wallet_connect";
|
|
27265
27475
|
return s;
|
|
27266
|
-
}, [
|
|
27476
|
+
}, [
|
|
27477
|
+
initialScreen,
|
|
27478
|
+
hideDepositTracker,
|
|
27479
|
+
enableCashApp,
|
|
27480
|
+
enableFiatOnramp,
|
|
27481
|
+
enablePayWithExchange,
|
|
27482
|
+
enableConnectExchange,
|
|
27483
|
+
enableConnectWallet
|
|
27484
|
+
]);
|
|
27267
27485
|
const [containerEl, setContainerEl] = (0, import_react8.useState)(null);
|
|
27268
27486
|
const containerCallbackRef = (0, import_react8.useCallback)((el) => {
|
|
27269
27487
|
setContainerEl(el);
|
|
@@ -27282,26 +27500,37 @@ function DepositModal({
|
|
|
27282
27500
|
const [browserWalletModalOpen, setBrowserWalletModalOpen] = (0, import_react8.useState)(false);
|
|
27283
27501
|
const [browserWalletInfo, setBrowserWalletInfo] = (0, import_react8.useState)(null);
|
|
27284
27502
|
const [walletSelectionModalOpen, setWalletSelectionModalOpen] = (0, import_react8.useState)(false);
|
|
27285
|
-
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react8.useState)(() =>
|
|
27503
|
+
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react8.useState)(() => getStoredWalletState()?.chainType);
|
|
27286
27504
|
const [quotesCount, setQuotesCount] = (0, import_react8.useState)(0);
|
|
27287
27505
|
const [allExecutions, setAllExecutions] = (0, import_react8.useState)([]);
|
|
27288
27506
|
const [selectedExecution, setSelectedExecution] = (0, import_react8.useState)(null);
|
|
27289
27507
|
const [depositExecutions, setDepositExecutions] = (0, import_react8.useState)([]);
|
|
27290
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;
|
|
27291
27520
|
const [integrationExchanges, setIntegrationExchanges] = (0, import_react8.useState)([]);
|
|
27292
27521
|
(0, import_react8.useEffect)(() => {
|
|
27293
|
-
if (!
|
|
27522
|
+
if (!showConnectExchange || !open) return;
|
|
27294
27523
|
getIntegrationExchanges(publishableKey).then((res) => setIntegrationExchanges(res.data)).catch(() => {
|
|
27295
27524
|
});
|
|
27296
|
-
}, [
|
|
27525
|
+
}, [showConnectExchange, open, publishableKey]);
|
|
27297
27526
|
const [connectedExchange, setConnectedExchange] = (0, import_react8.useState)(() => {
|
|
27298
|
-
if (!
|
|
27527
|
+
if (!showConnectExchange) return null;
|
|
27299
27528
|
const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
|
|
27300
27529
|
if (!stored) return null;
|
|
27301
27530
|
return { name: "Coinbase", iconUrl: void 0, balanceUsd: null, isLoading: true };
|
|
27302
27531
|
});
|
|
27303
27532
|
(0, import_react8.useEffect)(() => {
|
|
27304
|
-
if (!
|
|
27533
|
+
if (!showConnectExchange || !open || view !== "main") return;
|
|
27305
27534
|
const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
|
|
27306
27535
|
if (!stored) {
|
|
27307
27536
|
setConnectedExchange(null);
|
|
@@ -27336,7 +27565,7 @@ function DepositModal({
|
|
|
27336
27565
|
setConnectedExchange(null);
|
|
27337
27566
|
}
|
|
27338
27567
|
});
|
|
27339
|
-
}, [
|
|
27568
|
+
}, [showConnectExchange, open, view, publishableKey]);
|
|
27340
27569
|
(0, import_react8.useEffect)(() => {
|
|
27341
27570
|
if (!connectedExchange || integrationExchanges.length === 0) return;
|
|
27342
27571
|
const cbExchange = integrationExchanges.find(
|
|
@@ -27375,18 +27604,39 @@ function DepositModal({
|
|
|
27375
27604
|
setResolvedTheme(theme);
|
|
27376
27605
|
}
|
|
27377
27606
|
}, [theme]);
|
|
27378
|
-
const { projectConfig } = useProjectConfig({
|
|
27379
|
-
publishableKey,
|
|
27380
|
-
enabled: open
|
|
27381
|
-
});
|
|
27382
|
-
const showPayWithExchange = enablePayWithExchange ?? projectConfig?.pay_with_exchange?.enabled ?? true;
|
|
27383
|
-
const showFiatOnramp = enableFiatOnramp ?? projectConfig?.fiat_onramp?.enabled ?? true;
|
|
27384
27607
|
(0, import_react8.useEffect)(() => {
|
|
27385
27608
|
if (view === "card" && !showFiatOnramp) {
|
|
27386
27609
|
setView("main");
|
|
27387
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");
|
|
27623
|
+
}
|
|
27624
|
+
}, [
|
|
27625
|
+
view,
|
|
27626
|
+
showFiatOnramp,
|
|
27627
|
+
showTransferCrypto,
|
|
27628
|
+
showPayWithExchange,
|
|
27629
|
+
showCashApp,
|
|
27630
|
+
showDepositTracker,
|
|
27631
|
+
showConnectExchange,
|
|
27632
|
+
showConnectWallet
|
|
27633
|
+
]);
|
|
27634
|
+
(0, import_react8.useEffect)(() => {
|
|
27635
|
+
if (view === "exchange" && !showPayWithExchange) {
|
|
27636
|
+
setView("main");
|
|
27637
|
+
setExchangeView("providers");
|
|
27388
27638
|
}
|
|
27389
|
-
}, [view,
|
|
27639
|
+
}, [view, showPayWithExchange]);
|
|
27390
27640
|
const { exchanges, isLoading: exchangesLoading } = useExchanges({
|
|
27391
27641
|
publishableKey,
|
|
27392
27642
|
enabled: open && showPayWithExchange
|
|
@@ -27470,7 +27720,7 @@ function DepositModal({
|
|
|
27470
27720
|
depositPrerequisiteBody = standaloneNeedsDepositPrereq ? /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(SkeletonButton, { variant: "with-icons" }) : /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [
|
|
27471
27721
|
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(SkeletonButton, { variant: "with-icons" }),
|
|
27472
27722
|
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(SkeletonButton, { variant: "with-icons" }),
|
|
27473
|
-
|
|
27723
|
+
showDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(SkeletonButton, {})
|
|
27474
27724
|
] });
|
|
27475
27725
|
} else if (countryError) {
|
|
27476
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: [
|
|
@@ -27502,11 +27752,11 @@ function DepositModal({
|
|
|
27502
27752
|
const themeClass = resolvedTheme === "dark" ? "uf-dark" : "";
|
|
27503
27753
|
const handleWalletDisconnect = () => {
|
|
27504
27754
|
setUserDisconnectedWallet(true);
|
|
27505
|
-
|
|
27755
|
+
clearStoredWalletState();
|
|
27506
27756
|
setBrowserWalletChainType(void 0);
|
|
27507
27757
|
setBrowserWalletInfo(null);
|
|
27508
27758
|
setBrowserWalletModalOpen(false);
|
|
27509
|
-
if (view === "wallet_connect") setView("main");
|
|
27759
|
+
if (view === "wallet_connect" && sessionOpenedFromMenu) setView("main");
|
|
27510
27760
|
};
|
|
27511
27761
|
const handleExchangeDisconnect = () => {
|
|
27512
27762
|
const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
|
|
@@ -27515,7 +27765,7 @@ function DepositModal({
|
|
|
27515
27765
|
}
|
|
27516
27766
|
clearStoredIntegrationToken(IntegrationProvider.COINBASE);
|
|
27517
27767
|
setConnectedExchange(null);
|
|
27518
|
-
if (view === "coinbase_connect") setView("main");
|
|
27768
|
+
if (view === "coinbase_connect" && sessionOpenedFromMenu) setView("main");
|
|
27519
27769
|
};
|
|
27520
27770
|
const handleClose = () => {
|
|
27521
27771
|
onOpenChange(false);
|
|
@@ -27527,6 +27777,7 @@ function DepositModal({
|
|
|
27527
27777
|
setCardView("amount");
|
|
27528
27778
|
setExchangeView("providers");
|
|
27529
27779
|
setBrowserWalletInfo(null);
|
|
27780
|
+
setCoinbaseSkipToHoldings(false);
|
|
27530
27781
|
resetViewTimeoutRef.current = null;
|
|
27531
27782
|
}, 200);
|
|
27532
27783
|
};
|
|
@@ -27541,6 +27792,7 @@ function DepositModal({
|
|
|
27541
27792
|
setExchangeView("providers");
|
|
27542
27793
|
setBrowserWalletInfo(null);
|
|
27543
27794
|
setSelectedExecution(null);
|
|
27795
|
+
setCoinbaseSkipToHoldings(false);
|
|
27544
27796
|
}, [open, effectiveInitialScreen]);
|
|
27545
27797
|
(0, import_react8.useEffect)(
|
|
27546
27798
|
() => () => {
|
|
@@ -27578,7 +27830,7 @@ function DepositModal({
|
|
|
27578
27830
|
};
|
|
27579
27831
|
const handleBrowserWalletClick = (walletInfo) => {
|
|
27580
27832
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
27581
|
-
|
|
27833
|
+
setStoredWalletState(walletInfo.type);
|
|
27582
27834
|
setBrowserWalletChainType(walletChainType);
|
|
27583
27835
|
const matchingDepositWallet = wallets.find(
|
|
27584
27836
|
(w) => w.chain_type === walletChainType
|
|
@@ -27609,7 +27861,7 @@ function DepositModal({
|
|
|
27609
27861
|
};
|
|
27610
27862
|
const handleWalletConnected = (walletInfo) => {
|
|
27611
27863
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
27612
|
-
|
|
27864
|
+
setStoredWalletState(walletInfo.type);
|
|
27613
27865
|
setBrowserWalletChainType(walletChainType);
|
|
27614
27866
|
const matchingDepositWallet = wallets.find(
|
|
27615
27867
|
(w) => w.chain_type === walletChainType
|
|
@@ -27676,7 +27928,7 @@ function DepositModal({
|
|
|
27676
27928
|
),
|
|
27677
27929
|
/* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
27678
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: [
|
|
27679
|
-
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
27931
|
+
showTransferCrypto && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
27680
27932
|
TransferCryptoButton,
|
|
27681
27933
|
{
|
|
27682
27934
|
onClick: () => setView("transfer"),
|
|
@@ -27685,7 +27937,7 @@ function DepositModal({
|
|
|
27685
27937
|
featuredTokens: projectConfig?.transfer_crypto.networks
|
|
27686
27938
|
}
|
|
27687
27939
|
),
|
|
27688
|
-
|
|
27940
|
+
showConnectWallet && !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
27689
27941
|
BrowserWalletButton,
|
|
27690
27942
|
{
|
|
27691
27943
|
onClick: handleBrowserWalletClick,
|
|
@@ -27715,7 +27967,7 @@ function DepositModal({
|
|
|
27715
27967
|
loading: exchangesLoading
|
|
27716
27968
|
}
|
|
27717
27969
|
),
|
|
27718
|
-
|
|
27970
|
+
showConnectExchange && connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
27719
27971
|
ConnectExchangeButton,
|
|
27720
27972
|
{
|
|
27721
27973
|
onClick: () => {
|
|
@@ -27729,7 +27981,7 @@ function DepositModal({
|
|
|
27729
27981
|
connectedExchange
|
|
27730
27982
|
}
|
|
27731
27983
|
),
|
|
27732
|
-
|
|
27984
|
+
showConnectExchange && !connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
27733
27985
|
ConnectExchangeButton,
|
|
27734
27986
|
{
|
|
27735
27987
|
onClick: () => {
|
|
@@ -27741,7 +27993,7 @@ function DepositModal({
|
|
|
27741
27993
|
exchanges: integrationExchanges
|
|
27742
27994
|
}
|
|
27743
27995
|
),
|
|
27744
|
-
|
|
27996
|
+
showCashApp && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
27745
27997
|
CashAppButton,
|
|
27746
27998
|
{
|
|
27747
27999
|
onClick: () => setView("cashapp"),
|
|
@@ -27750,7 +28002,7 @@ function DepositModal({
|
|
|
27750
28002
|
iconUrl: projectConfig?.asset_cdn_url ? `${projectConfig.asset_cdn_url}/api/public/icons/onramps/svg/cashapp.svg` : void 0
|
|
27751
28003
|
}
|
|
27752
28004
|
),
|
|
27753
|
-
|
|
28005
|
+
showDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
27754
28006
|
DepositTrackerButton,
|
|
27755
28007
|
{
|
|
27756
28008
|
onClick: () => {
|
|
@@ -27900,7 +28152,7 @@ function DepositModal({
|
|
|
27900
28152
|
DepositHeader,
|
|
27901
28153
|
{
|
|
27902
28154
|
title: payWithExchangeTitle,
|
|
27903
|
-
showBack:
|
|
28155
|
+
showBack: exchangeView === "pending" || sessionOpenedFromMenu,
|
|
27904
28156
|
onBack: handleBack,
|
|
27905
28157
|
onClose: handleClose
|
|
27906
28158
|
}
|
|
@@ -27954,7 +28206,12 @@ function DepositModal({
|
|
|
27954
28206
|
onClose: handleClose,
|
|
27955
28207
|
onDisconnect: handleExchangeDisconnect,
|
|
27956
28208
|
skipToHoldings: coinbaseSkipToHoldings,
|
|
27957
|
-
|
|
28209
|
+
canGoBack: sessionOpenedFromMenu,
|
|
28210
|
+
onExecutionsChange: setDepositExecutions,
|
|
28211
|
+
defaultSourceChainType,
|
|
28212
|
+
defaultSourceChainId,
|
|
28213
|
+
defaultSourceTokenAddress,
|
|
28214
|
+
defaultSourceSymbol
|
|
27958
28215
|
}
|
|
27959
28216
|
),
|
|
27960
28217
|
depositPoweredByFooter
|
|
@@ -27987,11 +28244,17 @@ function DepositModal({
|
|
|
27987
28244
|
onWalletDisconnect: handleWalletDisconnect,
|
|
27988
28245
|
onWalletConnected: (info, dw) => {
|
|
27989
28246
|
setBrowserWalletInfo({ ...info, depositWallet: dw });
|
|
27990
|
-
|
|
28247
|
+
setStoredWalletState(info.type);
|
|
27991
28248
|
setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
|
|
27992
28249
|
},
|
|
27993
28250
|
onBack: handleBack,
|
|
27994
|
-
onClose: handleClose
|
|
28251
|
+
onClose: handleClose,
|
|
28252
|
+
defaultSourceChainType,
|
|
28253
|
+
defaultSourceChainId,
|
|
28254
|
+
defaultSourceTokenAddress,
|
|
28255
|
+
defaultSourceSymbol,
|
|
28256
|
+
canGoBack: sessionOpenedFromMenu,
|
|
28257
|
+
depositWalletsLoading: walletsLoading
|
|
27995
28258
|
}
|
|
27996
28259
|
),
|
|
27997
28260
|
depositPoweredByFooter
|
|
@@ -28000,7 +28263,7 @@ function DepositModal({
|
|
|
28000
28263
|
DepositHeader,
|
|
28001
28264
|
{
|
|
28002
28265
|
title: cashAppView !== "amount" && cashAppAmount ? `Pay $${cashAppAmount} via Cash App` : "Pay with Cash App",
|
|
28003
|
-
showBack:
|
|
28266
|
+
showBack: cashAppView !== "amount" || sessionOpenedFromMenu,
|
|
28004
28267
|
onBack: handleBack,
|
|
28005
28268
|
onClose: handleClose
|
|
28006
28269
|
}
|
|
@@ -28092,7 +28355,8 @@ function CheckoutModal({
|
|
|
28092
28355
|
clientSecret,
|
|
28093
28356
|
publishableKey,
|
|
28094
28357
|
modalTitle,
|
|
28095
|
-
|
|
28358
|
+
enableTransferCrypto,
|
|
28359
|
+
enableConnectWallet,
|
|
28096
28360
|
defaultSourceChainType,
|
|
28097
28361
|
defaultSourceChainId,
|
|
28098
28362
|
defaultSourceTokenAddress,
|
|
@@ -28109,7 +28373,7 @@ function CheckoutModal({
|
|
|
28109
28373
|
const [browserWalletModalOpen, setBrowserWalletModalOpen] = (0, import_react28.useState)(false);
|
|
28110
28374
|
const [browserWalletInfo, setBrowserWalletInfo] = (0, import_react28.useState)(null);
|
|
28111
28375
|
const [walletSelectionModalOpen, setWalletSelectionModalOpen] = (0, import_react28.useState)(false);
|
|
28112
|
-
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react28.useState)(() =>
|
|
28376
|
+
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react28.useState)(() => getStoredWalletState()?.chainType);
|
|
28113
28377
|
const isMobileView = useIsMobileViewport();
|
|
28114
28378
|
const [resolvedTheme, setResolvedTheme] = (0, import_react28.useState)(
|
|
28115
28379
|
theme === "auto" ? "dark" : theme
|
|
@@ -28142,6 +28406,15 @@ function CheckoutModal({
|
|
|
28142
28406
|
publishableKey,
|
|
28143
28407
|
enabled: open
|
|
28144
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]);
|
|
28145
28418
|
const prevStatusRef = (0, import_react28.useRef)(null);
|
|
28146
28419
|
(0, import_react28.useEffect)(() => {
|
|
28147
28420
|
if (!paymentIntent) return;
|
|
@@ -28232,7 +28505,7 @@ function CheckoutModal({
|
|
|
28232
28505
|
const handleBrowserWalletClick = (0, import_react28.useCallback)(
|
|
28233
28506
|
(walletInfo) => {
|
|
28234
28507
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
28235
|
-
|
|
28508
|
+
setStoredWalletState(walletInfo.type);
|
|
28236
28509
|
setBrowserWalletChainType(walletChainType);
|
|
28237
28510
|
const matchingDepositWallet = wallets.find(
|
|
28238
28511
|
(w) => w.chain_type === walletChainType
|
|
@@ -28259,7 +28532,7 @@ function CheckoutModal({
|
|
|
28259
28532
|
const handleWalletConnected = (0, import_react28.useCallback)(
|
|
28260
28533
|
(walletInfo) => {
|
|
28261
28534
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
28262
|
-
|
|
28535
|
+
setStoredWalletState(walletInfo.type);
|
|
28263
28536
|
setBrowserWalletChainType(walletChainType);
|
|
28264
28537
|
const matchingDepositWallet = wallets.find(
|
|
28265
28538
|
(w) => w.chain_type === walletChainType
|
|
@@ -28283,7 +28556,7 @@ function CheckoutModal({
|
|
|
28283
28556
|
);
|
|
28284
28557
|
const handleWalletDisconnect = (0, import_react28.useCallback)(() => {
|
|
28285
28558
|
setUserDisconnectedWallet(true);
|
|
28286
|
-
|
|
28559
|
+
clearStoredWalletState();
|
|
28287
28560
|
setBrowserWalletChainType(void 0);
|
|
28288
28561
|
setBrowserWalletInfo(null);
|
|
28289
28562
|
setBrowserWalletModalOpen(false);
|
|
@@ -28518,7 +28791,7 @@ function CheckoutModal({
|
|
|
28518
28791
|
] }) : paymentIntent ? /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-space-y-3", children: [
|
|
28519
28792
|
progressSection,
|
|
28520
28793
|
(paymentIntent.status === "requires_payment" || paymentIntent.status === "processing") && /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_jsx_runtime73.Fragment, { children: [
|
|
28521
|
-
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
28794
|
+
showTransferCrypto && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
28522
28795
|
TransferCryptoButton,
|
|
28523
28796
|
{
|
|
28524
28797
|
onClick: () => setView("transfer"),
|
|
@@ -28527,7 +28800,7 @@ function CheckoutModal({
|
|
|
28527
28800
|
featuredTokens: projectConfig?.transfer_crypto.networks
|
|
28528
28801
|
}
|
|
28529
28802
|
),
|
|
28530
|
-
|
|
28803
|
+
showConnectWallet && !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
28531
28804
|
BrowserWalletButton,
|
|
28532
28805
|
{
|
|
28533
28806
|
onClick: handleBrowserWalletClick,
|
|
@@ -28668,14 +28941,18 @@ function CheckoutModal({
|
|
|
28668
28941
|
onWalletDisconnect: handleWalletDisconnect,
|
|
28669
28942
|
onWalletConnected: (info, dw) => {
|
|
28670
28943
|
setBrowserWalletInfo({ ...info, depositWallet: dw });
|
|
28671
|
-
|
|
28944
|
+
setStoredWalletState(info.type);
|
|
28672
28945
|
setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
|
|
28673
28946
|
},
|
|
28674
28947
|
onNewDeposit: () => setView("main"),
|
|
28675
28948
|
onDone: () => setView("main"),
|
|
28676
28949
|
paymentIntentStatus: paymentIntent.status,
|
|
28677
28950
|
onBack: handleBack,
|
|
28678
|
-
onClose: handleClose
|
|
28951
|
+
onClose: handleClose,
|
|
28952
|
+
defaultSourceChainType,
|
|
28953
|
+
defaultSourceChainId,
|
|
28954
|
+
defaultSourceTokenAddress,
|
|
28955
|
+
defaultSourceSymbol
|
|
28679
28956
|
}
|
|
28680
28957
|
),
|
|
28681
28958
|
poweredByFooter
|
|
@@ -30641,6 +30918,7 @@ function UnifoldProvider2({
|
|
|
30641
30918
|
onOpenChange: closeCheckout,
|
|
30642
30919
|
clientSecret: checkoutConfig.clientSecret,
|
|
30643
30920
|
publishableKey,
|
|
30921
|
+
enableTransferCrypto: config?.enableTransferCrypto,
|
|
30644
30922
|
enableConnectWallet: config?.enableConnectWallet,
|
|
30645
30923
|
defaultSourceChainType: checkoutConfig.defaultSourceChainType,
|
|
30646
30924
|
defaultSourceChainId: checkoutConfig.defaultSourceChainId,
|
|
@@ -30697,6 +30975,7 @@ function UnifoldProvider2({
|
|
|
30697
30975
|
hideDepositTracker: config?.hideDepositTracker,
|
|
30698
30976
|
showBalanceHeader: config?.showBalanceHeader,
|
|
30699
30977
|
transferInputVariant: config?.transferInputVariant,
|
|
30978
|
+
enableTransferCrypto: config?.enableTransferCrypto,
|
|
30700
30979
|
enableConnectWallet: config?.enableConnectWallet,
|
|
30701
30980
|
enablePayWithExchange: config?.enablePayWithExchange,
|
|
30702
30981
|
enableFiatOnramp: config?.enableFiatOnramp,
|