@unifold/ui-web 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/dist/index.js +739 -460
- package/dist/index.mjs +739 -460
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -37153,30 +37153,31 @@ var React102 = __toESM(require_react(), 1);
|
|
|
37153
37153
|
var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
|
|
37154
37154
|
var React112 = __toESM(require_react(), 1);
|
|
37155
37155
|
var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
|
|
37156
|
-
var
|
|
37156
|
+
var React252 = __toESM(require_react(), 1);
|
|
37157
37157
|
var React122 = __toESM(require_react(), 1);
|
|
37158
|
-
var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
|
|
37159
37158
|
var React132 = __toESM(require_react(), 1);
|
|
37160
|
-
var
|
|
37159
|
+
var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
|
|
37161
37160
|
var React142 = __toESM(require_react(), 1);
|
|
37162
|
-
var
|
|
37161
|
+
var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
|
|
37163
37162
|
var React152 = __toESM(require_react(), 1);
|
|
37164
|
-
var
|
|
37163
|
+
var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
|
|
37165
37164
|
var React162 = __toESM(require_react(), 1);
|
|
37166
|
-
var
|
|
37165
|
+
var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
|
|
37167
37166
|
var React172 = __toESM(require_react(), 1);
|
|
37168
|
-
var
|
|
37167
|
+
var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
|
|
37169
37168
|
var React182 = __toESM(require_react(), 1);
|
|
37170
|
-
var
|
|
37169
|
+
var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
|
|
37171
37170
|
var React192 = __toESM(require_react(), 1);
|
|
37172
|
-
var
|
|
37171
|
+
var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
|
|
37173
37172
|
var React202 = __toESM(require_react(), 1);
|
|
37174
|
-
var
|
|
37173
|
+
var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
|
|
37175
37174
|
var React212 = __toESM(require_react(), 1);
|
|
37176
|
-
var
|
|
37175
|
+
var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
|
|
37177
37176
|
var React2222 = __toESM(require_react(), 1);
|
|
37178
|
-
var
|
|
37177
|
+
var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
|
|
37179
37178
|
var React232 = __toESM(require_react(), 1);
|
|
37179
|
+
var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
|
|
37180
|
+
var React242 = __toESM(require_react(), 1);
|
|
37180
37181
|
var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
|
|
37181
37182
|
var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
|
|
37182
37183
|
var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
|
|
@@ -37184,7 +37185,7 @@ var import_react18 = __toESM(require_react(), 1);
|
|
|
37184
37185
|
var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
|
|
37185
37186
|
var import_react19 = __toESM(require_react(), 1);
|
|
37186
37187
|
var import_react20 = __toESM(require_react(), 1);
|
|
37187
|
-
var
|
|
37188
|
+
var React272 = __toESM(require_react(), 1);
|
|
37188
37189
|
var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
|
|
37189
37190
|
var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
|
|
37190
37191
|
var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
|
|
@@ -37194,7 +37195,7 @@ var import_react22 = __toESM(require_react(), 1);
|
|
|
37194
37195
|
var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
|
|
37195
37196
|
var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
|
|
37196
37197
|
var import_react23 = __toESM(require_react(), 1);
|
|
37197
|
-
var
|
|
37198
|
+
var React282 = __toESM(require_react(), 1);
|
|
37198
37199
|
var React31 = __toESM(require_react(), 1);
|
|
37199
37200
|
var React29 = __toESM(require_react(), 1);
|
|
37200
37201
|
var React26 = __toESM(require_react(), 1);
|
|
@@ -37211,7 +37212,7 @@ var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
|
|
|
37211
37212
|
var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
|
|
37212
37213
|
var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
|
|
37213
37214
|
var import_react25 = __toESM(require_react(), 1);
|
|
37214
|
-
var
|
|
37215
|
+
var React292 = __toESM(require_react(), 1);
|
|
37215
37216
|
var React35 = __toESM(require_react(), 1);
|
|
37216
37217
|
var ReactDOM4 = __toESM(require_react_dom(), 1);
|
|
37217
37218
|
var import_react26 = __toESM(require_react(), 1);
|
|
@@ -37224,7 +37225,7 @@ var React34 = __toESM(require_react(), 1);
|
|
|
37224
37225
|
var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
|
|
37225
37226
|
var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
|
|
37226
37227
|
var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
|
|
37227
|
-
var
|
|
37228
|
+
var React302 = __toESM(require_react(), 1);
|
|
37228
37229
|
var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
|
|
37229
37230
|
var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
|
|
37230
37231
|
var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
|
|
@@ -43129,6 +43130,42 @@ var getDefaultConfig = () => {
|
|
|
43129
43130
|
};
|
|
43130
43131
|
};
|
|
43131
43132
|
var twMerge = /* @__PURE__ */ createTailwindMerge(getDefaultConfig);
|
|
43133
|
+
function formatStablecoinAmount(baseUnits, decimals) {
|
|
43134
|
+
const raw = Number(baseUnits) / 10 ** decimals;
|
|
43135
|
+
const floored = Math.floor(raw * 100) / 100;
|
|
43136
|
+
const ceiled = raw > floored ? floored + 0.01 : raw;
|
|
43137
|
+
return ceiled.toFixed(2);
|
|
43138
|
+
}
|
|
43139
|
+
function generateKSUID() {
|
|
43140
|
+
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
43141
|
+
const KSUID_EPOCH = 14e8;
|
|
43142
|
+
const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
|
|
43143
|
+
const payload = new Uint8Array(20);
|
|
43144
|
+
payload[0] = timestampSeconds >>> 24 & 255;
|
|
43145
|
+
payload[1] = timestampSeconds >>> 16 & 255;
|
|
43146
|
+
payload[2] = timestampSeconds >>> 8 & 255;
|
|
43147
|
+
payload[3] = timestampSeconds & 255;
|
|
43148
|
+
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
43149
|
+
crypto.getRandomValues(payload.subarray(4));
|
|
43150
|
+
} else {
|
|
43151
|
+
for (let i = 4; i < 20; i++) {
|
|
43152
|
+
payload[i] = Math.floor(Math.random() * 256);
|
|
43153
|
+
}
|
|
43154
|
+
}
|
|
43155
|
+
let value = 0n;
|
|
43156
|
+
for (const byte of payload) {
|
|
43157
|
+
value = value << 8n | BigInt(byte);
|
|
43158
|
+
}
|
|
43159
|
+
let encoded = "";
|
|
43160
|
+
while (value > 0n) {
|
|
43161
|
+
encoded = BASE62[Number(value % 62n)] + encoded;
|
|
43162
|
+
value = value / 62n;
|
|
43163
|
+
}
|
|
43164
|
+
return encoded.padStart(27, "0");
|
|
43165
|
+
}
|
|
43166
|
+
function generatePrefixedKSUID(prefix) {
|
|
43167
|
+
return `${prefix}_${generateKSUID()}`;
|
|
43168
|
+
}
|
|
43132
43169
|
var API_BASE_URL = (() => {
|
|
43133
43170
|
try {
|
|
43134
43171
|
return process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.unifold.io";
|
|
@@ -43431,9 +43468,7 @@ function getOnrampSessionStartUrl(request, publishableKey) {
|
|
|
43431
43468
|
if (request.subdivision_code) {
|
|
43432
43469
|
params.append("subdivision_code", request.subdivision_code);
|
|
43433
43470
|
}
|
|
43434
|
-
|
|
43435
|
-
params.append("external_id", request.external_id);
|
|
43436
|
-
}
|
|
43471
|
+
params.append("external_id", request.external_id ?? generatePrefixedKSUID("ors"));
|
|
43437
43472
|
if (request.email) {
|
|
43438
43473
|
params.append("email", request.email);
|
|
43439
43474
|
}
|
|
@@ -43648,9 +43683,7 @@ function getExchangeSessionStartUrl(request, publishableKey) {
|
|
|
43648
43683
|
if (request.source_amount) {
|
|
43649
43684
|
params.append("source_amount", request.source_amount);
|
|
43650
43685
|
}
|
|
43651
|
-
|
|
43652
|
-
params.append("external_id", request.external_id);
|
|
43653
|
-
}
|
|
43686
|
+
params.append("external_id", request.external_id ?? generatePrefixedKSUID("exc"));
|
|
43654
43687
|
return `${API_BASE_URL}/v1/public/onramps/exchanges/sessions/start?${params.toString()}`;
|
|
43655
43688
|
}
|
|
43656
43689
|
async function getIntegrationExchanges(publishableKey) {
|
|
@@ -43984,40 +44017,6 @@ async function getCashAppSessionStatus(externalId, publishableKey) {
|
|
|
43984
44017
|
}
|
|
43985
44018
|
return response.json();
|
|
43986
44019
|
}
|
|
43987
|
-
function formatStablecoinAmount(baseUnits, decimals) {
|
|
43988
|
-
const raw = Number(baseUnits) / 10 ** decimals;
|
|
43989
|
-
const floored = Math.floor(raw * 100) / 100;
|
|
43990
|
-
const ceiled = raw > floored ? floored + 0.01 : raw;
|
|
43991
|
-
return ceiled.toFixed(2);
|
|
43992
|
-
}
|
|
43993
|
-
function generatePrefixedKSUID(prefix) {
|
|
43994
|
-
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
43995
|
-
const KSUID_EPOCH = 14e8;
|
|
43996
|
-
const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
|
|
43997
|
-
const payload = new Uint8Array(20);
|
|
43998
|
-
payload[0] = timestampSeconds >>> 24 & 255;
|
|
43999
|
-
payload[1] = timestampSeconds >>> 16 & 255;
|
|
44000
|
-
payload[2] = timestampSeconds >>> 8 & 255;
|
|
44001
|
-
payload[3] = timestampSeconds & 255;
|
|
44002
|
-
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
44003
|
-
crypto.getRandomValues(payload.subarray(4));
|
|
44004
|
-
} else {
|
|
44005
|
-
for (let i = 4; i < 20; i++) {
|
|
44006
|
-
payload[i] = Math.floor(Math.random() * 256);
|
|
44007
|
-
}
|
|
44008
|
-
}
|
|
44009
|
-
let value = 0n;
|
|
44010
|
-
for (const byte of payload) {
|
|
44011
|
-
value = value << 8n | BigInt(byte);
|
|
44012
|
-
}
|
|
44013
|
-
let encoded = "";
|
|
44014
|
-
while (value > 0n) {
|
|
44015
|
-
encoded = BASE62[Number(value % 62n)] + encoded;
|
|
44016
|
-
value = value / 62n;
|
|
44017
|
-
}
|
|
44018
|
-
encoded = encoded.padStart(27, "0");
|
|
44019
|
-
return `${prefix}_${encoded}`;
|
|
44020
|
-
}
|
|
44021
44020
|
var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
|
|
44022
44021
|
DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
|
|
44023
44022
|
return DepositEventType2;
|
|
@@ -50117,8 +50116,32 @@ var Separator = SelectSeparator;
|
|
|
50117
50116
|
function cn(...inputs) {
|
|
50118
50117
|
return twMerge(clsx(inputs));
|
|
50119
50118
|
}
|
|
50120
|
-
var
|
|
50119
|
+
var WALLET_STATE_STORAGE_KEY = "unifold_wallet_state";
|
|
50120
|
+
var LEGACY_WALLET_KEYS = [
|
|
50121
|
+
"unifold_last_wallet_type",
|
|
50122
|
+
"unifold_last_connected_wallet"
|
|
50123
|
+
];
|
|
50121
50124
|
var WALLET_USER_DISCONNECTED_KEY = "unifold_wallet_user_disconnected";
|
|
50125
|
+
var SOLANA_WALLET_TYPES = /* @__PURE__ */ new Set([
|
|
50126
|
+
"phantom-solana",
|
|
50127
|
+
"solflare",
|
|
50128
|
+
"backpack",
|
|
50129
|
+
"glow"
|
|
50130
|
+
]);
|
|
50131
|
+
var ETHEREUM_WALLET_TYPES = /* @__PURE__ */ new Set([
|
|
50132
|
+
"metamask",
|
|
50133
|
+
"phantom-ethereum",
|
|
50134
|
+
"coinbase",
|
|
50135
|
+
"trust",
|
|
50136
|
+
"rainbow",
|
|
50137
|
+
"rabby",
|
|
50138
|
+
"okx"
|
|
50139
|
+
]);
|
|
50140
|
+
function walletTypeToChain(t12) {
|
|
50141
|
+
if (SOLANA_WALLET_TYPES.has(t12)) return "solana";
|
|
50142
|
+
if (ETHEREUM_WALLET_TYPES.has(t12)) return "ethereum";
|
|
50143
|
+
return void 0;
|
|
50144
|
+
}
|
|
50122
50145
|
function getUserDisconnectedWallet() {
|
|
50123
50146
|
if (typeof window === "undefined") return false;
|
|
50124
50147
|
try {
|
|
@@ -50138,26 +50161,35 @@ function setUserDisconnectedWallet(disconnected) {
|
|
|
50138
50161
|
} catch {
|
|
50139
50162
|
}
|
|
50140
50163
|
}
|
|
50141
|
-
function
|
|
50164
|
+
function getStoredWalletState() {
|
|
50142
50165
|
if (typeof window === "undefined") return void 0;
|
|
50143
50166
|
try {
|
|
50144
|
-
const
|
|
50145
|
-
if (
|
|
50167
|
+
const raw = localStorage.getItem(WALLET_STATE_STORAGE_KEY);
|
|
50168
|
+
if (!raw) return void 0;
|
|
50169
|
+
const chainType = walletTypeToChain(raw);
|
|
50170
|
+
if (!chainType) {
|
|
50171
|
+
localStorage.removeItem(WALLET_STATE_STORAGE_KEY);
|
|
50172
|
+
return void 0;
|
|
50173
|
+
}
|
|
50174
|
+
return { walletType: raw, chainType };
|
|
50146
50175
|
} catch {
|
|
50176
|
+
return void 0;
|
|
50147
50177
|
}
|
|
50148
|
-
return void 0;
|
|
50149
50178
|
}
|
|
50150
|
-
function
|
|
50179
|
+
function setStoredWalletState(walletType) {
|
|
50151
50180
|
if (typeof window === "undefined") return;
|
|
50181
|
+
if (!walletTypeToChain(walletType)) return;
|
|
50152
50182
|
try {
|
|
50153
|
-
localStorage.setItem(
|
|
50183
|
+
localStorage.setItem(WALLET_STATE_STORAGE_KEY, walletType);
|
|
50184
|
+
for (const key of LEGACY_WALLET_KEYS) localStorage.removeItem(key);
|
|
50154
50185
|
} catch {
|
|
50155
50186
|
}
|
|
50156
50187
|
}
|
|
50157
|
-
function
|
|
50188
|
+
function clearStoredWalletState() {
|
|
50158
50189
|
if (typeof window === "undefined") return;
|
|
50159
50190
|
try {
|
|
50160
|
-
localStorage.removeItem(
|
|
50191
|
+
localStorage.removeItem(WALLET_STATE_STORAGE_KEY);
|
|
50192
|
+
for (const key of LEGACY_WALLET_KEYS) localStorage.removeItem(key);
|
|
50161
50193
|
} catch {
|
|
50162
50194
|
}
|
|
50163
50195
|
}
|
|
@@ -50720,6 +50752,60 @@ function useDepositAddress(params) {
|
|
|
50720
50752
|
// 1s, 2s, 4s (max 10s)
|
|
50721
50753
|
});
|
|
50722
50754
|
}
|
|
50755
|
+
var normalize = (value) => value?.toLowerCase();
|
|
50756
|
+
function sourceTokenMatchesDefaultSource(token, defaultSource) {
|
|
50757
|
+
if (!token || !defaultSource.defaultSourceChainType || !defaultSource.defaultSourceChainId) {
|
|
50758
|
+
return false;
|
|
50759
|
+
}
|
|
50760
|
+
if (token.chain_type !== defaultSource.defaultSourceChainType || token.chain_id !== defaultSource.defaultSourceChainId) {
|
|
50761
|
+
return false;
|
|
50762
|
+
}
|
|
50763
|
+
if (defaultSource.defaultSourceTokenAddress && normalize(token.token_address) === normalize(defaultSource.defaultSourceTokenAddress)) {
|
|
50764
|
+
return true;
|
|
50765
|
+
}
|
|
50766
|
+
if (defaultSource.defaultSourceTokenAddress) {
|
|
50767
|
+
return false;
|
|
50768
|
+
}
|
|
50769
|
+
return !!defaultSource.defaultSourceSymbol && normalize(token.symbol) === normalize(defaultSource.defaultSourceSymbol);
|
|
50770
|
+
}
|
|
50771
|
+
function isDefaultSourceBalance(balance, defaultSource) {
|
|
50772
|
+
return isBalanceEligible(balance) && sourceTokenMatchesDefaultSource(getTokenFromBalance(balance), defaultSource);
|
|
50773
|
+
}
|
|
50774
|
+
function compareBalancesWithDefaultSource(a, b, defaultSource) {
|
|
50775
|
+
const aDefault = isDefaultSourceBalance(a, defaultSource);
|
|
50776
|
+
const bDefault = isDefaultSourceBalance(b, defaultSource);
|
|
50777
|
+
if (aDefault && !bDefault) return -1;
|
|
50778
|
+
if (!aDefault && bDefault) return 1;
|
|
50779
|
+
const aEligible = isBalanceEligible(a);
|
|
50780
|
+
const bEligible = isBalanceEligible(b);
|
|
50781
|
+
if (aEligible && !bEligible) return -1;
|
|
50782
|
+
if (!aEligible && bEligible) return 1;
|
|
50783
|
+
return 0;
|
|
50784
|
+
}
|
|
50785
|
+
function resolveDefaultSourceSymbol(supportedTokens, defaultSource) {
|
|
50786
|
+
if (!supportedTokens?.length || !defaultSource.defaultSourceChainType || !defaultSource.defaultSourceChainId) {
|
|
50787
|
+
return null;
|
|
50788
|
+
}
|
|
50789
|
+
if (defaultSource.defaultSourceTokenAddress) {
|
|
50790
|
+
for (const token of supportedTokens) {
|
|
50791
|
+
const matchingChain = token.chains.find(
|
|
50792
|
+
(chain) => chain.chain_type === defaultSource.defaultSourceChainType && chain.chain_id === defaultSource.defaultSourceChainId && normalize(chain.token_address) === normalize(defaultSource.defaultSourceTokenAddress)
|
|
50793
|
+
);
|
|
50794
|
+
if (matchingChain) return token.symbol;
|
|
50795
|
+
}
|
|
50796
|
+
}
|
|
50797
|
+
if (!defaultSource.defaultSourceSymbol) return null;
|
|
50798
|
+
for (const token of supportedTokens) {
|
|
50799
|
+
if (normalize(token.symbol) !== normalize(defaultSource.defaultSourceSymbol)) {
|
|
50800
|
+
continue;
|
|
50801
|
+
}
|
|
50802
|
+
const matchingChain = token.chains.find(
|
|
50803
|
+
(chain) => chain.chain_type === defaultSource.defaultSourceChainType && chain.chain_id === defaultSource.defaultSourceChainId
|
|
50804
|
+
);
|
|
50805
|
+
if (matchingChain) return token.symbol;
|
|
50806
|
+
}
|
|
50807
|
+
return null;
|
|
50808
|
+
}
|
|
50723
50809
|
function formatUsdFromBalancePercent(maxUsdAmount, percent) {
|
|
50724
50810
|
if (maxUsdAmount <= 0 || percent < 0) return "";
|
|
50725
50811
|
const raw = maxUsdAmount * percent / 100;
|
|
@@ -55195,6 +55281,226 @@ function collectAllEip6963EthProviders() {
|
|
|
55195
55281
|
if (!store) return [];
|
|
55196
55282
|
return store.getProviders().map((d) => d.provider);
|
|
55197
55283
|
}
|
|
55284
|
+
function identifyEthWallet(provider, hint) {
|
|
55285
|
+
switch (hint) {
|
|
55286
|
+
case "metamask":
|
|
55287
|
+
return { type: "metamask", name: "MetaMask", icon: "metamask" };
|
|
55288
|
+
case "phantom":
|
|
55289
|
+
return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
|
|
55290
|
+
case "coinbase":
|
|
55291
|
+
return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
|
|
55292
|
+
case "okx":
|
|
55293
|
+
return { type: "okx", name: "OKX Wallet", icon: "okx" };
|
|
55294
|
+
case "rabby":
|
|
55295
|
+
return { type: "rabby", name: "Rabby", icon: "rabby" };
|
|
55296
|
+
case "trust":
|
|
55297
|
+
return { type: "trust", name: "Trust Wallet", icon: "trust" };
|
|
55298
|
+
case "rainbow":
|
|
55299
|
+
return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
|
|
55300
|
+
}
|
|
55301
|
+
const anyProvider = provider;
|
|
55302
|
+
if (provider.isPhantom) {
|
|
55303
|
+
return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
|
|
55304
|
+
}
|
|
55305
|
+
if (anyProvider.isCoinbaseWallet) {
|
|
55306
|
+
return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
|
|
55307
|
+
}
|
|
55308
|
+
if (anyProvider.isRabby) {
|
|
55309
|
+
return { type: "rabby", name: "Rabby", icon: "rabby" };
|
|
55310
|
+
}
|
|
55311
|
+
if (anyProvider.isTrust) {
|
|
55312
|
+
return { type: "trust", name: "Trust Wallet", icon: "trust" };
|
|
55313
|
+
}
|
|
55314
|
+
if (anyProvider.isRainbow) {
|
|
55315
|
+
return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
|
|
55316
|
+
}
|
|
55317
|
+
if (provider.isMetaMask && !provider.isPhantom) {
|
|
55318
|
+
return { type: "metamask", name: "MetaMask", icon: "metamask" };
|
|
55319
|
+
}
|
|
55320
|
+
return { type: "metamask", name: "Wallet", icon: "metamask" };
|
|
55321
|
+
}
|
|
55322
|
+
var EIP6963_ID_TO_WALLET_TYPE = {
|
|
55323
|
+
metamask: "metamask",
|
|
55324
|
+
phantom: "phantom-ethereum",
|
|
55325
|
+
coinbase: "coinbase",
|
|
55326
|
+
trust: "trust",
|
|
55327
|
+
rainbow: "rainbow",
|
|
55328
|
+
rabby: "rabby",
|
|
55329
|
+
okx: "okx"
|
|
55330
|
+
};
|
|
55331
|
+
function inferEthWalletType(provider, walletId) {
|
|
55332
|
+
if (EIP6963_ID_TO_WALLET_TYPE[walletId]) return EIP6963_ID_TO_WALLET_TYPE[walletId];
|
|
55333
|
+
const any = provider;
|
|
55334
|
+
if (provider.isPhantom) return "phantom-ethereum";
|
|
55335
|
+
if (any.isCoinbaseWallet) return "coinbase";
|
|
55336
|
+
if (any.isRabby) return "rabby";
|
|
55337
|
+
if (any.isTrust) return "trust";
|
|
55338
|
+
if (any.isRainbow) return "rainbow";
|
|
55339
|
+
if (any.isOkxWallet) return "okx";
|
|
55340
|
+
if (provider.isMetaMask && !provider.isPhantom) return "metamask";
|
|
55341
|
+
return null;
|
|
55342
|
+
}
|
|
55343
|
+
function solanaCandidate(provider, type, name, icon) {
|
|
55344
|
+
return {
|
|
55345
|
+
walletType: type,
|
|
55346
|
+
detect: async () => {
|
|
55347
|
+
if (!provider) return null;
|
|
55348
|
+
if (provider.isConnected && provider.publicKey) {
|
|
55349
|
+
return { type, name, address: provider.publicKey.toString(), icon };
|
|
55350
|
+
}
|
|
55351
|
+
try {
|
|
55352
|
+
const resp = await provider.connect({ onlyIfTrusted: true });
|
|
55353
|
+
if (resp.publicKey) {
|
|
55354
|
+
return { type, name, address: resp.publicKey.toString(), icon };
|
|
55355
|
+
}
|
|
55356
|
+
} catch {
|
|
55357
|
+
}
|
|
55358
|
+
return null;
|
|
55359
|
+
}
|
|
55360
|
+
};
|
|
55361
|
+
}
|
|
55362
|
+
function ethereumCandidate(provider, walletId) {
|
|
55363
|
+
return {
|
|
55364
|
+
walletType: inferEthWalletType(provider, walletId),
|
|
55365
|
+
detect: async () => {
|
|
55366
|
+
try {
|
|
55367
|
+
const accounts = await provider.request({ method: "eth_accounts" });
|
|
55368
|
+
if (!accounts?.length) return null;
|
|
55369
|
+
const resolved = identifyEthWallet(provider, walletId);
|
|
55370
|
+
return { ...resolved, address: accounts[0] };
|
|
55371
|
+
} catch {
|
|
55372
|
+
return null;
|
|
55373
|
+
}
|
|
55374
|
+
}
|
|
55375
|
+
};
|
|
55376
|
+
}
|
|
55377
|
+
function buildCandidates(win, chainType) {
|
|
55378
|
+
const candidates = [];
|
|
55379
|
+
if (!chainType || chainType === "solana") {
|
|
55380
|
+
candidates.push(
|
|
55381
|
+
solanaCandidate(win.phantom?.solana, "phantom-solana", "Phantom", "phantom"),
|
|
55382
|
+
solanaCandidate(win.solflare, "solflare", "Solflare", "solflare"),
|
|
55383
|
+
solanaCandidate(win.backpack, "backpack", "Backpack", "backpack"),
|
|
55384
|
+
solanaCandidate(win.glow, "glow", "Glow", "glow")
|
|
55385
|
+
);
|
|
55386
|
+
}
|
|
55387
|
+
if (!chainType || chainType === "ethereum") {
|
|
55388
|
+
const seen = /* @__PURE__ */ new Set();
|
|
55389
|
+
const addEth = (provider, walletId) => {
|
|
55390
|
+
if (!provider || seen.has(provider)) return;
|
|
55391
|
+
seen.add(provider);
|
|
55392
|
+
candidates.push(ethereumCandidate(provider, walletId));
|
|
55393
|
+
};
|
|
55394
|
+
for (const { provider, walletId } of getEip6963Providers()) {
|
|
55395
|
+
addEth(
|
|
55396
|
+
provider,
|
|
55397
|
+
walletId === "unknown" ? "default" : walletId
|
|
55398
|
+
);
|
|
55399
|
+
}
|
|
55400
|
+
addEth(win.phantom?.ethereum, "phantom");
|
|
55401
|
+
addEth(win.coinbaseWalletExtension, "coinbase");
|
|
55402
|
+
addEth(win.okxwallet, "okx");
|
|
55403
|
+
addEth(win.trustwallet?.ethereum, "trust");
|
|
55404
|
+
addEth(win.ethereum, "default");
|
|
55405
|
+
}
|
|
55406
|
+
return candidates;
|
|
55407
|
+
}
|
|
55408
|
+
async function detectConnectedBrowserWallet(chainType) {
|
|
55409
|
+
if (typeof window === "undefined") return null;
|
|
55410
|
+
if (getUserDisconnectedWallet()) return null;
|
|
55411
|
+
try {
|
|
55412
|
+
const win = window;
|
|
55413
|
+
const candidates = buildCandidates(win, chainType);
|
|
55414
|
+
const preferred = getStoredWalletState();
|
|
55415
|
+
if (preferred && (!chainType || preferred.chainType === chainType)) {
|
|
55416
|
+
const idx = candidates.findIndex((c) => c.walletType === preferred.walletType);
|
|
55417
|
+
if (idx > 0) candidates.unshift(...candidates.splice(idx, 1));
|
|
55418
|
+
}
|
|
55419
|
+
for (const c of candidates) {
|
|
55420
|
+
const found = await c.detect();
|
|
55421
|
+
if (found) return found;
|
|
55422
|
+
}
|
|
55423
|
+
} catch (error) {
|
|
55424
|
+
console.error("[detectConnectedBrowserWallet] detection error:", error);
|
|
55425
|
+
}
|
|
55426
|
+
return null;
|
|
55427
|
+
}
|
|
55428
|
+
function useDetectedBrowserWallet(opts = {}) {
|
|
55429
|
+
const { chainType, enabled = true, onDisconnect } = opts;
|
|
55430
|
+
const [wallet, setWallet] = React122.useState(null);
|
|
55431
|
+
const [isLoading, setIsLoading] = React122.useState(enabled);
|
|
55432
|
+
const [eip6963ProviderCount, setEip6963ProviderCount] = React122.useState(0);
|
|
55433
|
+
const onDisconnectRef = React122.useRef(onDisconnect);
|
|
55434
|
+
onDisconnectRef.current = onDisconnect;
|
|
55435
|
+
React122.useEffect(() => {
|
|
55436
|
+
const store = getEip6963Store();
|
|
55437
|
+
if (!store) return;
|
|
55438
|
+
setEip6963ProviderCount(store.getProviders().length);
|
|
55439
|
+
return store.subscribe((providers) => setEip6963ProviderCount(providers.length));
|
|
55440
|
+
}, []);
|
|
55441
|
+
React122.useEffect(() => {
|
|
55442
|
+
if (!enabled) {
|
|
55443
|
+
setWallet(null);
|
|
55444
|
+
setIsLoading(false);
|
|
55445
|
+
return;
|
|
55446
|
+
}
|
|
55447
|
+
let mounted = true;
|
|
55448
|
+
const detect = async () => {
|
|
55449
|
+
if (!mounted) return;
|
|
55450
|
+
setIsLoading(true);
|
|
55451
|
+
const detected = await detectConnectedBrowserWallet(chainType);
|
|
55452
|
+
if (!mounted) return;
|
|
55453
|
+
setWallet(detected);
|
|
55454
|
+
setIsLoading(false);
|
|
55455
|
+
};
|
|
55456
|
+
detect();
|
|
55457
|
+
const onChange = () => detect();
|
|
55458
|
+
const onDisc = () => {
|
|
55459
|
+
onDisconnectRef.current?.();
|
|
55460
|
+
detect();
|
|
55461
|
+
};
|
|
55462
|
+
const onEthAccounts = (accounts) => {
|
|
55463
|
+
if (Array.isArray(accounts) && accounts.length === 0) onDisconnectRef.current?.();
|
|
55464
|
+
detect();
|
|
55465
|
+
};
|
|
55466
|
+
const win = typeof window !== "undefined" ? window : void 0;
|
|
55467
|
+
const solanaProvider = win?.phantom?.solana || win?.solana;
|
|
55468
|
+
if (solanaProvider) {
|
|
55469
|
+
solanaProvider.on("connect", onChange);
|
|
55470
|
+
solanaProvider.on("disconnect", onDisc);
|
|
55471
|
+
solanaProvider.on("accountChanged", onChange);
|
|
55472
|
+
}
|
|
55473
|
+
const ethProviders = [];
|
|
55474
|
+
for (const { provider } of getEip6963Providers()) {
|
|
55475
|
+
const p = provider;
|
|
55476
|
+
if (p && !ethProviders.includes(p)) ethProviders.push(p);
|
|
55477
|
+
}
|
|
55478
|
+
if (win?.ethereum && !ethProviders.includes(win.ethereum)) ethProviders.push(win.ethereum);
|
|
55479
|
+
if (win?.phantom?.ethereum && !ethProviders.includes(win.phantom.ethereum)) {
|
|
55480
|
+
ethProviders.push(win.phantom.ethereum);
|
|
55481
|
+
}
|
|
55482
|
+
for (const p of ethProviders) {
|
|
55483
|
+
p.on("accountsChanged", onEthAccounts);
|
|
55484
|
+
p.on("chainChanged", onChange);
|
|
55485
|
+
}
|
|
55486
|
+
return () => {
|
|
55487
|
+
mounted = false;
|
|
55488
|
+
if (solanaProvider) {
|
|
55489
|
+
solanaProvider.off?.("connect", onChange);
|
|
55490
|
+
solanaProvider.off?.("disconnect", onDisc);
|
|
55491
|
+
solanaProvider.off?.("accountChanged", onChange);
|
|
55492
|
+
}
|
|
55493
|
+
for (const p of ethProviders) {
|
|
55494
|
+
const off = p.off?.bind(p) ?? p.removeListener?.bind(p);
|
|
55495
|
+
if (off) {
|
|
55496
|
+
off("accountsChanged", onEthAccounts);
|
|
55497
|
+
off("chainChanged", onChange);
|
|
55498
|
+
}
|
|
55499
|
+
}
|
|
55500
|
+
};
|
|
55501
|
+
}, [chainType, eip6963ProviderCount, enabled]);
|
|
55502
|
+
return { wallet, isLoading, setWallet };
|
|
55503
|
+
}
|
|
55198
55504
|
var SOLANA_DISCONNECT_TYPES = [
|
|
55199
55505
|
"phantom-solana",
|
|
55200
55506
|
"solflare",
|
|
@@ -55282,7 +55588,7 @@ function MetamaskIcon({
|
|
|
55282
55588
|
className,
|
|
55283
55589
|
variant = "color"
|
|
55284
55590
|
}) {
|
|
55285
|
-
const id =
|
|
55591
|
+
const id = React132.useId();
|
|
55286
55592
|
if (variant === "light" || variant === "dark") {
|
|
55287
55593
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
55288
55594
|
"svg",
|
|
@@ -55407,7 +55713,7 @@ function PhantomIcon({
|
|
|
55407
55713
|
className,
|
|
55408
55714
|
variant = "color"
|
|
55409
55715
|
}) {
|
|
55410
|
-
const id =
|
|
55716
|
+
const id = React142.useId();
|
|
55411
55717
|
if (variant === "light") {
|
|
55412
55718
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
55413
55719
|
"svg",
|
|
@@ -55478,7 +55784,7 @@ function CoinbaseIcon({
|
|
|
55478
55784
|
className,
|
|
55479
55785
|
variant = "color"
|
|
55480
55786
|
}) {
|
|
55481
|
-
const id =
|
|
55787
|
+
const id = React152.useId();
|
|
55482
55788
|
if (variant === "light") {
|
|
55483
55789
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
55484
55790
|
"svg",
|
|
@@ -55562,7 +55868,7 @@ function RabbyIcon({
|
|
|
55562
55868
|
className,
|
|
55563
55869
|
variant = "color"
|
|
55564
55870
|
}) {
|
|
55565
|
-
const id =
|
|
55871
|
+
const id = React162.useId();
|
|
55566
55872
|
if (variant === "light") {
|
|
55567
55873
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
55568
55874
|
"svg",
|
|
@@ -55913,7 +56219,7 @@ function RainbowIcon({
|
|
|
55913
56219
|
className,
|
|
55914
56220
|
variant = "color"
|
|
55915
56221
|
}) {
|
|
55916
|
-
const id =
|
|
56222
|
+
const id = React172.useId();
|
|
55917
56223
|
if (variant === "light") {
|
|
55918
56224
|
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
55919
56225
|
"svg",
|
|
@@ -56379,7 +56685,7 @@ function TrustIcon({
|
|
|
56379
56685
|
className,
|
|
56380
56686
|
variant = "color"
|
|
56381
56687
|
}) {
|
|
56382
|
-
const id =
|
|
56688
|
+
const id = React182.useId();
|
|
56383
56689
|
if (variant === "light") {
|
|
56384
56690
|
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
56385
56691
|
"svg",
|
|
@@ -56472,7 +56778,7 @@ function OkxIcon({
|
|
|
56472
56778
|
className,
|
|
56473
56779
|
variant = "color"
|
|
56474
56780
|
}) {
|
|
56475
|
-
const id =
|
|
56781
|
+
const id = React192.useId();
|
|
56476
56782
|
if (variant === "light") {
|
|
56477
56783
|
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
56478
56784
|
"svg",
|
|
@@ -56543,7 +56849,7 @@ function GlowIcon({
|
|
|
56543
56849
|
className,
|
|
56544
56850
|
variant = "color"
|
|
56545
56851
|
}) {
|
|
56546
|
-
const id =
|
|
56852
|
+
const id = React202.useId();
|
|
56547
56853
|
if (variant === "light") {
|
|
56548
56854
|
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
56549
56855
|
"svg",
|
|
@@ -56648,7 +56954,7 @@ function BackpackIcon({
|
|
|
56648
56954
|
className,
|
|
56649
56955
|
variant = "color"
|
|
56650
56956
|
}) {
|
|
56651
|
-
const id =
|
|
56957
|
+
const id = React212.useId();
|
|
56652
56958
|
if (variant === "light") {
|
|
56653
56959
|
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
56654
56960
|
"svg",
|
|
@@ -56725,7 +57031,7 @@ function SolflareIcon({
|
|
|
56725
57031
|
className,
|
|
56726
57032
|
variant = "color"
|
|
56727
57033
|
}) {
|
|
56728
|
-
const id =
|
|
57034
|
+
const id = React2222.useId();
|
|
56729
57035
|
if (variant === "light") {
|
|
56730
57036
|
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
56731
57037
|
"svg",
|
|
@@ -56796,7 +57102,7 @@ function EthereumIcon({
|
|
|
56796
57102
|
className,
|
|
56797
57103
|
variant = "color"
|
|
56798
57104
|
}) {
|
|
56799
|
-
const id =
|
|
57105
|
+
const id = React232.useId();
|
|
56800
57106
|
if (variant === "light") {
|
|
56801
57107
|
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
|
|
56802
57108
|
"svg",
|
|
@@ -56930,7 +57236,7 @@ function SolanaIcon({
|
|
|
56930
57236
|
className,
|
|
56931
57237
|
variant = "color"
|
|
56932
57238
|
}) {
|
|
56933
|
-
const id =
|
|
57239
|
+
const id = React242.useId();
|
|
56934
57240
|
if (variant === "light") {
|
|
56935
57241
|
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
56936
57242
|
"svg",
|
|
@@ -57179,44 +57485,6 @@ function truncateAddress3(address) {
|
|
|
57179
57485
|
if (address.length <= 10) return address;
|
|
57180
57486
|
return `${address.slice(0, 4)}...${address.slice(-4)}`;
|
|
57181
57487
|
}
|
|
57182
|
-
function identifyEthWallet(provider, _win, hint) {
|
|
57183
|
-
switch (hint) {
|
|
57184
|
-
case "metamask":
|
|
57185
|
-
return { type: "metamask", name: "MetaMask", icon: "metamask" };
|
|
57186
|
-
case "phantom":
|
|
57187
|
-
return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
|
|
57188
|
-
case "coinbase":
|
|
57189
|
-
return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
|
|
57190
|
-
case "okx":
|
|
57191
|
-
return { type: "okx", name: "OKX Wallet", icon: "okx" };
|
|
57192
|
-
case "rabby":
|
|
57193
|
-
return { type: "rabby", name: "Rabby", icon: "rabby" };
|
|
57194
|
-
case "trust":
|
|
57195
|
-
return { type: "trust", name: "Trust Wallet", icon: "trust" };
|
|
57196
|
-
case "rainbow":
|
|
57197
|
-
return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
|
|
57198
|
-
}
|
|
57199
|
-
const anyProvider = provider;
|
|
57200
|
-
if (provider.isPhantom) {
|
|
57201
|
-
return { type: "phantom-ethereum", name: "Phantom", icon: "phantom" };
|
|
57202
|
-
}
|
|
57203
|
-
if (anyProvider.isCoinbaseWallet) {
|
|
57204
|
-
return { type: "coinbase", name: "Coinbase Wallet", icon: "coinbase" };
|
|
57205
|
-
}
|
|
57206
|
-
if (anyProvider.isRabby) {
|
|
57207
|
-
return { type: "rabby", name: "Rabby", icon: "rabby" };
|
|
57208
|
-
}
|
|
57209
|
-
if (anyProvider.isTrust) {
|
|
57210
|
-
return { type: "trust", name: "Trust Wallet", icon: "trust" };
|
|
57211
|
-
}
|
|
57212
|
-
if (anyProvider.isRainbow) {
|
|
57213
|
-
return { type: "rainbow", name: "Rainbow", icon: "rainbow" };
|
|
57214
|
-
}
|
|
57215
|
-
if (provider.isMetaMask && !provider.isPhantom) {
|
|
57216
|
-
return { type: "metamask", name: "MetaMask", icon: "metamask" };
|
|
57217
|
-
}
|
|
57218
|
-
return { type: "metamask", name: "Wallet", icon: "metamask" };
|
|
57219
|
-
}
|
|
57220
57488
|
function BrowserWalletButton({
|
|
57221
57489
|
onClick,
|
|
57222
57490
|
onConnectClick,
|
|
@@ -57227,30 +57495,19 @@ function BrowserWalletButton({
|
|
|
57227
57495
|
subtitle = i18n2.depositModal.browserWallet.subtitle
|
|
57228
57496
|
}) {
|
|
57229
57497
|
const { colors: colors2, fonts, components } = useTheme();
|
|
57230
|
-
const [isHovered, setIsHovered] =
|
|
57231
|
-
const [isTouchDevice, setIsTouchDevice] =
|
|
57232
|
-
const
|
|
57233
|
-
const [
|
|
57234
|
-
const [
|
|
57235
|
-
const [
|
|
57236
|
-
const [
|
|
57237
|
-
const
|
|
57238
|
-
const onDisconnectRef = React242.useRef(onDisconnect);
|
|
57498
|
+
const [isHovered, setIsHovered] = React252.useState(false);
|
|
57499
|
+
const [isTouchDevice, setIsTouchDevice] = React252.useState(false);
|
|
57500
|
+
const { wallet, isLoading, setWallet } = useDetectedBrowserWallet({ chainType, onDisconnect });
|
|
57501
|
+
const [isConnecting, setIsConnecting] = React252.useState(false);
|
|
57502
|
+
const [balanceText, setBalanceText] = React252.useState(null);
|
|
57503
|
+
const [isLoadingBalance, setIsLoadingBalance] = React252.useState(false);
|
|
57504
|
+
const [isDisconnecting, setIsDisconnecting] = React252.useState(false);
|
|
57505
|
+
const onDisconnectRef = React252.useRef(onDisconnect);
|
|
57239
57506
|
onDisconnectRef.current = onDisconnect;
|
|
57240
|
-
|
|
57507
|
+
React252.useEffect(() => {
|
|
57241
57508
|
setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
57242
57509
|
}, []);
|
|
57243
|
-
|
|
57244
|
-
React242.useEffect(() => {
|
|
57245
|
-
const store = getEip6963Store();
|
|
57246
|
-
if (!store) return;
|
|
57247
|
-
setEip6963ProviderCount(store.getProviders().length);
|
|
57248
|
-
const unsubscribe = store.subscribe((providers) => {
|
|
57249
|
-
setEip6963ProviderCount(providers.length);
|
|
57250
|
-
});
|
|
57251
|
-
return unsubscribe;
|
|
57252
|
-
}, []);
|
|
57253
|
-
React242.useEffect(() => {
|
|
57510
|
+
React252.useEffect(() => {
|
|
57254
57511
|
if (!wallet || !publishableKey) {
|
|
57255
57512
|
setBalanceText(null);
|
|
57256
57513
|
return;
|
|
@@ -57291,206 +57548,6 @@ function BrowserWalletButton({
|
|
|
57291
57548
|
cancelled = true;
|
|
57292
57549
|
};
|
|
57293
57550
|
}, [wallet, publishableKey]);
|
|
57294
|
-
React242.useEffect(() => {
|
|
57295
|
-
let mounted = true;
|
|
57296
|
-
const detectWallet = async () => {
|
|
57297
|
-
if (!mounted) return;
|
|
57298
|
-
setIsLoading(true);
|
|
57299
|
-
try {
|
|
57300
|
-
const win = typeof window !== "undefined" ? window : null;
|
|
57301
|
-
if (!win) return;
|
|
57302
|
-
if (getUserDisconnectedWallet()) {
|
|
57303
|
-
if (mounted) {
|
|
57304
|
-
setWallet(null);
|
|
57305
|
-
setIsLoading(false);
|
|
57306
|
-
}
|
|
57307
|
-
return;
|
|
57308
|
-
}
|
|
57309
|
-
if (!chainType || chainType === "solana") {
|
|
57310
|
-
const anyWin = win;
|
|
57311
|
-
const trySilentSolana = async (provider, type, name, icon) => {
|
|
57312
|
-
if (!provider) return false;
|
|
57313
|
-
if (provider.isConnected && provider.publicKey) {
|
|
57314
|
-
if (mounted) {
|
|
57315
|
-
setWallet({
|
|
57316
|
-
type,
|
|
57317
|
-
name,
|
|
57318
|
-
address: provider.publicKey.toString(),
|
|
57319
|
-
icon
|
|
57320
|
-
});
|
|
57321
|
-
setIsLoading(false);
|
|
57322
|
-
}
|
|
57323
|
-
return true;
|
|
57324
|
-
}
|
|
57325
|
-
try {
|
|
57326
|
-
const resp = await provider.connect({ onlyIfTrusted: true });
|
|
57327
|
-
if (mounted && resp.publicKey) {
|
|
57328
|
-
setWallet({
|
|
57329
|
-
type,
|
|
57330
|
-
name,
|
|
57331
|
-
address: resp.publicKey.toString(),
|
|
57332
|
-
icon
|
|
57333
|
-
});
|
|
57334
|
-
setIsLoading(false);
|
|
57335
|
-
return true;
|
|
57336
|
-
}
|
|
57337
|
-
} catch {
|
|
57338
|
-
}
|
|
57339
|
-
return false;
|
|
57340
|
-
};
|
|
57341
|
-
if (await trySilentSolana(
|
|
57342
|
-
win.phantom?.solana,
|
|
57343
|
-
"phantom-solana",
|
|
57344
|
-
"Phantom",
|
|
57345
|
-
"phantom"
|
|
57346
|
-
))
|
|
57347
|
-
return;
|
|
57348
|
-
if (await trySilentSolana(
|
|
57349
|
-
anyWin.solflare,
|
|
57350
|
-
"solflare",
|
|
57351
|
-
"Solflare",
|
|
57352
|
-
"solflare"
|
|
57353
|
-
))
|
|
57354
|
-
return;
|
|
57355
|
-
if (await trySilentSolana(
|
|
57356
|
-
anyWin.backpack,
|
|
57357
|
-
"backpack",
|
|
57358
|
-
"Backpack",
|
|
57359
|
-
"backpack"
|
|
57360
|
-
))
|
|
57361
|
-
return;
|
|
57362
|
-
if (await trySilentSolana(
|
|
57363
|
-
anyWin.glow,
|
|
57364
|
-
"glow",
|
|
57365
|
-
"Glow",
|
|
57366
|
-
"glow"
|
|
57367
|
-
))
|
|
57368
|
-
return;
|
|
57369
|
-
}
|
|
57370
|
-
if (!chainType || chainType === "ethereum") {
|
|
57371
|
-
const anyWin = win;
|
|
57372
|
-
const allProviders = [];
|
|
57373
|
-
const eip6963 = getEip6963Providers();
|
|
57374
|
-
for (const { provider, walletId } of eip6963) {
|
|
57375
|
-
allProviders.push({
|
|
57376
|
-
provider,
|
|
57377
|
-
walletId: walletId === "unknown" ? "default" : walletId
|
|
57378
|
-
});
|
|
57379
|
-
}
|
|
57380
|
-
if (allProviders.length === 0) {
|
|
57381
|
-
if (win.phantom?.ethereum) {
|
|
57382
|
-
allProviders.push({
|
|
57383
|
-
provider: win.phantom.ethereum,
|
|
57384
|
-
walletId: "phantom"
|
|
57385
|
-
});
|
|
57386
|
-
}
|
|
57387
|
-
if (anyWin.okxwallet) {
|
|
57388
|
-
allProviders.push({
|
|
57389
|
-
provider: anyWin.okxwallet,
|
|
57390
|
-
walletId: "okx"
|
|
57391
|
-
});
|
|
57392
|
-
}
|
|
57393
|
-
if (anyWin.coinbaseWalletExtension) {
|
|
57394
|
-
allProviders.push({
|
|
57395
|
-
provider: anyWin.coinbaseWalletExtension,
|
|
57396
|
-
walletId: "coinbase"
|
|
57397
|
-
});
|
|
57398
|
-
}
|
|
57399
|
-
if (win.ethereum) {
|
|
57400
|
-
const isDuplicate = allProviders.some(
|
|
57401
|
-
(p) => p.provider === win.ethereum
|
|
57402
|
-
);
|
|
57403
|
-
if (!isDuplicate) {
|
|
57404
|
-
allProviders.push({
|
|
57405
|
-
provider: win.ethereum,
|
|
57406
|
-
walletId: "default"
|
|
57407
|
-
});
|
|
57408
|
-
}
|
|
57409
|
-
}
|
|
57410
|
-
}
|
|
57411
|
-
for (const { provider, walletId } of allProviders) {
|
|
57412
|
-
if (!provider) continue;
|
|
57413
|
-
try {
|
|
57414
|
-
const accounts = await provider.request({
|
|
57415
|
-
method: "eth_accounts"
|
|
57416
|
-
});
|
|
57417
|
-
if (!accounts || accounts.length === 0) continue;
|
|
57418
|
-
const address = accounts[0];
|
|
57419
|
-
const resolved = identifyEthWallet(provider, anyWin, walletId);
|
|
57420
|
-
if (mounted) {
|
|
57421
|
-
setWallet({ ...resolved, address });
|
|
57422
|
-
setIsLoading(false);
|
|
57423
|
-
}
|
|
57424
|
-
return;
|
|
57425
|
-
} catch {
|
|
57426
|
-
}
|
|
57427
|
-
}
|
|
57428
|
-
}
|
|
57429
|
-
if (mounted) {
|
|
57430
|
-
setWallet(null);
|
|
57431
|
-
setIsLoading(false);
|
|
57432
|
-
}
|
|
57433
|
-
} catch (error) {
|
|
57434
|
-
console.error("[BrowserWalletButton] Error detecting wallet:", error);
|
|
57435
|
-
if (mounted) {
|
|
57436
|
-
setWallet(null);
|
|
57437
|
-
setIsLoading(false);
|
|
57438
|
-
}
|
|
57439
|
-
}
|
|
57440
|
-
};
|
|
57441
|
-
detectWallet();
|
|
57442
|
-
const handleAccountsChanged = () => {
|
|
57443
|
-
detectWallet();
|
|
57444
|
-
};
|
|
57445
|
-
const handleDisconnect = () => {
|
|
57446
|
-
onDisconnectRef.current?.();
|
|
57447
|
-
detectWallet();
|
|
57448
|
-
};
|
|
57449
|
-
const handleEthAccountsChanged = (accounts) => {
|
|
57450
|
-
if (Array.isArray(accounts) && accounts.length === 0) {
|
|
57451
|
-
onDisconnectRef.current?.();
|
|
57452
|
-
}
|
|
57453
|
-
detectWallet();
|
|
57454
|
-
};
|
|
57455
|
-
const solanaProvider = window.phantom?.solana || window.solana;
|
|
57456
|
-
if (solanaProvider) {
|
|
57457
|
-
solanaProvider.on("connect", handleAccountsChanged);
|
|
57458
|
-
solanaProvider.on("disconnect", handleDisconnect);
|
|
57459
|
-
solanaProvider.on("accountChanged", handleAccountsChanged);
|
|
57460
|
-
}
|
|
57461
|
-
const ethProviders = [];
|
|
57462
|
-
for (const { provider } of getEip6963Providers()) {
|
|
57463
|
-
const p = provider;
|
|
57464
|
-
if (p && !ethProviders.includes(p)) {
|
|
57465
|
-
ethProviders.push(p);
|
|
57466
|
-
}
|
|
57467
|
-
}
|
|
57468
|
-
if (window.ethereum && !ethProviders.includes(window.ethereum)) {
|
|
57469
|
-
ethProviders.push(window.ethereum);
|
|
57470
|
-
}
|
|
57471
|
-
if (window.phantom?.ethereum && !ethProviders.includes(window.phantom.ethereum)) {
|
|
57472
|
-
ethProviders.push(window.phantom.ethereum);
|
|
57473
|
-
}
|
|
57474
|
-
for (const provider of ethProviders) {
|
|
57475
|
-
provider.on("accountsChanged", handleEthAccountsChanged);
|
|
57476
|
-
provider.on("chainChanged", handleAccountsChanged);
|
|
57477
|
-
}
|
|
57478
|
-
return () => {
|
|
57479
|
-
mounted = false;
|
|
57480
|
-
if (solanaProvider) {
|
|
57481
|
-
solanaProvider.off("connect", handleAccountsChanged);
|
|
57482
|
-
solanaProvider.off("disconnect", handleDisconnect);
|
|
57483
|
-
solanaProvider.off("accountChanged", handleAccountsChanged);
|
|
57484
|
-
}
|
|
57485
|
-
for (const provider of ethProviders) {
|
|
57486
|
-
const off = provider.off?.bind(provider) ?? provider.removeListener?.bind(provider);
|
|
57487
|
-
if (off) {
|
|
57488
|
-
off("accountsChanged", handleEthAccountsChanged);
|
|
57489
|
-
off("chainChanged", handleAccountsChanged);
|
|
57490
|
-
}
|
|
57491
|
-
}
|
|
57492
|
-
};
|
|
57493
|
-
}, [chainType, eip6963ProviderCount]);
|
|
57494
57551
|
const handleConnect = async () => {
|
|
57495
57552
|
if (wallet) {
|
|
57496
57553
|
onClick(wallet);
|
|
@@ -57507,6 +57564,7 @@ function BrowserWalletButton({
|
|
|
57507
57564
|
if (solanaProvider?.isPhantom) {
|
|
57508
57565
|
const { publicKey } = await solanaProvider.connect();
|
|
57509
57566
|
setUserDisconnectedWallet(false);
|
|
57567
|
+
setStoredWalletState("phantom-solana");
|
|
57510
57568
|
setWallet({
|
|
57511
57569
|
type: "phantom-solana",
|
|
57512
57570
|
name: "Phantom",
|
|
@@ -57526,8 +57584,10 @@ function BrowserWalletButton({
|
|
|
57526
57584
|
if (accounts && accounts.length > 0) {
|
|
57527
57585
|
setUserDisconnectedWallet(false);
|
|
57528
57586
|
const isPhantom = ethProvider.isPhantom;
|
|
57587
|
+
const walletType = isPhantom ? "phantom-ethereum" : "metamask";
|
|
57588
|
+
setStoredWalletState(walletType);
|
|
57529
57589
|
setWallet({
|
|
57530
|
-
type:
|
|
57590
|
+
type: walletType,
|
|
57531
57591
|
name: isPhantom ? "Phantom" : "MetaMask",
|
|
57532
57592
|
address: accounts[0],
|
|
57533
57593
|
icon: isPhantom ? "phantom" : "metamask"
|
|
@@ -57574,7 +57634,7 @@ function BrowserWalletButton({
|
|
|
57574
57634
|
border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
|
|
57575
57635
|
};
|
|
57576
57636
|
const sortedWallets = featuredWallets ? [...featuredWallets].sort((a, b) => a.position - b.position) : [];
|
|
57577
|
-
const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ?
|
|
57637
|
+
const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React252.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
|
|
57578
57638
|
size: 36,
|
|
57579
57639
|
className: "uf-rounded-lg",
|
|
57580
57640
|
variant: "color"
|
|
@@ -57836,7 +57896,12 @@ function CoinbaseConnect({
|
|
|
57836
57896
|
onBack: parentOnBack,
|
|
57837
57897
|
onDisconnect,
|
|
57838
57898
|
skipToHoldings,
|
|
57839
|
-
|
|
57899
|
+
canGoBack = true,
|
|
57900
|
+
onExecutionsChange,
|
|
57901
|
+
defaultSourceChainType,
|
|
57902
|
+
defaultSourceChainId,
|
|
57903
|
+
defaultSourceTokenAddress,
|
|
57904
|
+
defaultSourceSymbol
|
|
57840
57905
|
}) {
|
|
57841
57906
|
const { colors: colors2, fonts, components } = useTheme();
|
|
57842
57907
|
const { projectConfig } = useProjectConfig({ publishableKey });
|
|
@@ -57901,6 +57966,21 @@ function CoinbaseConnect({
|
|
|
57901
57966
|
params: defaultTokenParams,
|
|
57902
57967
|
publishableKey
|
|
57903
57968
|
});
|
|
57969
|
+
const defaultSourceCurrency = (0, import_react18.useMemo)(
|
|
57970
|
+
() => resolveDefaultSourceSymbol(supportedTokensData?.data, {
|
|
57971
|
+
defaultSourceChainType,
|
|
57972
|
+
defaultSourceChainId,
|
|
57973
|
+
defaultSourceTokenAddress,
|
|
57974
|
+
defaultSourceSymbol
|
|
57975
|
+
})?.toLowerCase() ?? null,
|
|
57976
|
+
[
|
|
57977
|
+
supportedTokensData,
|
|
57978
|
+
defaultSourceChainType,
|
|
57979
|
+
defaultSourceChainId,
|
|
57980
|
+
defaultSourceTokenAddress,
|
|
57981
|
+
defaultSourceSymbol
|
|
57982
|
+
]
|
|
57983
|
+
);
|
|
57904
57984
|
const sortedHoldings = (0, import_react18.useMemo)(() => {
|
|
57905
57985
|
const supported = [];
|
|
57906
57986
|
const unsupported = [];
|
|
@@ -57910,13 +57990,42 @@ function CoinbaseConnect({
|
|
|
57910
57990
|
if (isSupported) supported.push(account);
|
|
57911
57991
|
else unsupported.push(account);
|
|
57912
57992
|
});
|
|
57993
|
+
if (defaultSourceCurrency) {
|
|
57994
|
+
const defaultIndex = supported.findIndex(
|
|
57995
|
+
(account) => account.currency.toLowerCase() === defaultSourceCurrency
|
|
57996
|
+
);
|
|
57997
|
+
if (defaultIndex > 0) {
|
|
57998
|
+
const [defaultHolding] = supported.splice(defaultIndex, 1);
|
|
57999
|
+
supported.unshift(defaultHolding);
|
|
58000
|
+
}
|
|
58001
|
+
}
|
|
57913
58002
|
return [...supported, ...unsupported];
|
|
57914
|
-
}, [
|
|
58003
|
+
}, [
|
|
58004
|
+
holdings,
|
|
58005
|
+
supportedSymbols,
|
|
58006
|
+
exchangeSupportedCurrencies,
|
|
58007
|
+
defaultSourceCurrency
|
|
58008
|
+
]);
|
|
57915
58009
|
const selectedHoldingIsSupported = (0, import_react18.useMemo)(() => {
|
|
57916
58010
|
if (!selectedHolding) return false;
|
|
57917
58011
|
const currencyLower = selectedHolding.currency.toLowerCase();
|
|
57918
58012
|
return (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
|
|
57919
58013
|
}, [selectedHolding, supportedSymbols, exchangeSupportedCurrencies]);
|
|
58014
|
+
(0, import_react18.useEffect)(() => {
|
|
58015
|
+
if (!defaultSourceCurrency || selectedHolding) return;
|
|
58016
|
+
const defaultHolding = sortedHoldings.find((account) => {
|
|
58017
|
+
const currencyLower = account.currency.toLowerCase();
|
|
58018
|
+
return currencyLower === defaultSourceCurrency && (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
|
|
58019
|
+
});
|
|
58020
|
+
if (!defaultHolding) return;
|
|
58021
|
+
setSelectedHolding(defaultHolding);
|
|
58022
|
+
}, [
|
|
58023
|
+
defaultSourceCurrency,
|
|
58024
|
+
selectedHolding,
|
|
58025
|
+
sortedHoldings,
|
|
58026
|
+
supportedSymbols,
|
|
58027
|
+
exchangeSupportedCurrencies
|
|
58028
|
+
]);
|
|
57920
58029
|
const exchangeName = selectedExchange?.service_provider_display_name || "Exchange";
|
|
57921
58030
|
const {
|
|
57922
58031
|
executions: depositExecutions,
|
|
@@ -58223,6 +58332,16 @@ function CoinbaseConnect({
|
|
|
58223
58332
|
setIsLoading(false);
|
|
58224
58333
|
}
|
|
58225
58334
|
};
|
|
58335
|
+
const handleDisconnect = () => {
|
|
58336
|
+
onDisconnect?.();
|
|
58337
|
+
if (!canGoBack) {
|
|
58338
|
+
setAccessToken(null);
|
|
58339
|
+
setHoldings([]);
|
|
58340
|
+
setSelectedHolding(null);
|
|
58341
|
+
setSelectedAsset(null);
|
|
58342
|
+
transitionTo("select_exchange");
|
|
58343
|
+
}
|
|
58344
|
+
};
|
|
58226
58345
|
const handleBack = () => {
|
|
58227
58346
|
switch (view) {
|
|
58228
58347
|
case "select_exchange":
|
|
@@ -58283,7 +58402,7 @@ function CoinbaseConnect({
|
|
|
58283
58402
|
DepositHeader,
|
|
58284
58403
|
{
|
|
58285
58404
|
title: t12.title,
|
|
58286
|
-
showBack:
|
|
58405
|
+
showBack: canGoBack,
|
|
58287
58406
|
onBack: handleBack,
|
|
58288
58407
|
onClose
|
|
58289
58408
|
}
|
|
@@ -58296,7 +58415,7 @@ function CoinbaseConnect({
|
|
|
58296
58415
|
DepositHeader,
|
|
58297
58416
|
{
|
|
58298
58417
|
title: t12.title,
|
|
58299
|
-
showBack:
|
|
58418
|
+
showBack: canGoBack,
|
|
58300
58419
|
onBack: handleBack,
|
|
58301
58420
|
onClose
|
|
58302
58421
|
}
|
|
@@ -59008,7 +59127,7 @@ function CoinbaseConnect({
|
|
|
59008
59127
|
borderRadius: components.button.borderRadius,
|
|
59009
59128
|
fontFamily: fonts.medium
|
|
59010
59129
|
},
|
|
59011
|
-
onClick:
|
|
59130
|
+
onClick: handleDisconnect,
|
|
59012
59131
|
children: t12.disconnect
|
|
59013
59132
|
}
|
|
59014
59133
|
)
|
|
@@ -59795,7 +59914,7 @@ function ThemeStyleInjector({
|
|
|
59795
59914
|
className
|
|
59796
59915
|
}) {
|
|
59797
59916
|
const { colors: colors2, fonts, mode } = useTheme();
|
|
59798
|
-
const cssVars =
|
|
59917
|
+
const cssVars = React272.useMemo(() => {
|
|
59799
59918
|
const hexToHSL = (hex) => {
|
|
59800
59919
|
hex = hex.replace("#", "");
|
|
59801
59920
|
const r2 = parseInt(hex.slice(0, 2), 16) / 255;
|
|
@@ -59855,7 +59974,7 @@ function ThemeStyleInjector({
|
|
|
59855
59974
|
...fonts.regular ? { "--uf-font-family": fonts.regular } : {}
|
|
59856
59975
|
};
|
|
59857
59976
|
}, [colors2, fonts.regular]);
|
|
59858
|
-
|
|
59977
|
+
React272.useEffect(() => {
|
|
59859
59978
|
if (typeof document === "undefined") return;
|
|
59860
59979
|
if (fonts.regular) {
|
|
59861
59980
|
document.documentElement.style.setProperty(
|
|
@@ -60814,14 +60933,14 @@ function useCopyAddress() {
|
|
|
60814
60933
|
return { copied, handleCopy };
|
|
60815
60934
|
}
|
|
60816
60935
|
var TooltipProvider2 = Provider;
|
|
60817
|
-
var TooltipContext =
|
|
60936
|
+
var TooltipContext = React282.createContext({
|
|
60818
60937
|
open: false,
|
|
60819
60938
|
onOpenChange: () => {
|
|
60820
60939
|
}
|
|
60821
60940
|
});
|
|
60822
|
-
var TooltipTrigger2 =
|
|
60823
|
-
const { open, onOpenChange } =
|
|
60824
|
-
const handleClick =
|
|
60941
|
+
var TooltipTrigger2 = React282.forwardRef(({ onClick, ...props }, ref) => {
|
|
60942
|
+
const { open, onOpenChange } = React282.useContext(TooltipContext);
|
|
60943
|
+
const handleClick = React282.useCallback(
|
|
60825
60944
|
(e) => {
|
|
60826
60945
|
onOpenChange(!open);
|
|
60827
60946
|
onClick?.(e);
|
|
@@ -60831,7 +60950,7 @@ var TooltipTrigger2 = React272.forwardRef(({ onClick, ...props }, ref) => {
|
|
|
60831
60950
|
return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Trigger, { ref, onClick: handleClick, ...props });
|
|
60832
60951
|
});
|
|
60833
60952
|
TooltipTrigger2.displayName = Trigger.displayName;
|
|
60834
|
-
var TooltipContent2 =
|
|
60953
|
+
var TooltipContent2 = React282.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
|
|
60835
60954
|
const { themeClass, colors: colors2 } = useTheme();
|
|
60836
60955
|
return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Portal3, { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
60837
60956
|
Content22,
|
|
@@ -61436,7 +61555,7 @@ function TransferCryptoSingleInput({
|
|
|
61436
61555
|
}
|
|
61437
61556
|
var Select2 = Root23;
|
|
61438
61557
|
var SelectValue2 = Value;
|
|
61439
|
-
var SelectTrigger2 =
|
|
61558
|
+
var SelectTrigger2 = React292.forwardRef(({ className, style, children, ...props }, ref) => {
|
|
61440
61559
|
const { components } = useTheme();
|
|
61441
61560
|
return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
|
|
61442
61561
|
Trigger2,
|
|
@@ -61460,7 +61579,7 @@ var SelectTrigger2 = React282.forwardRef(({ className, style, children, ...props
|
|
|
61460
61579
|
);
|
|
61461
61580
|
});
|
|
61462
61581
|
SelectTrigger2.displayName = Trigger2.displayName;
|
|
61463
|
-
var SelectScrollUpButton2 =
|
|
61582
|
+
var SelectScrollUpButton2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
61464
61583
|
ScrollUpButton,
|
|
61465
61584
|
{
|
|
61466
61585
|
ref,
|
|
@@ -61473,7 +61592,7 @@ var SelectScrollUpButton2 = React282.forwardRef(({ className, ...props }, ref) =
|
|
|
61473
61592
|
}
|
|
61474
61593
|
));
|
|
61475
61594
|
SelectScrollUpButton2.displayName = ScrollUpButton.displayName;
|
|
61476
|
-
var SelectScrollDownButton2 =
|
|
61595
|
+
var SelectScrollDownButton2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
61477
61596
|
ScrollDownButton,
|
|
61478
61597
|
{
|
|
61479
61598
|
ref,
|
|
@@ -61486,7 +61605,7 @@ var SelectScrollDownButton2 = React282.forwardRef(({ className, ...props }, ref)
|
|
|
61486
61605
|
}
|
|
61487
61606
|
));
|
|
61488
61607
|
SelectScrollDownButton2.displayName = ScrollDownButton.displayName;
|
|
61489
|
-
var SelectContent2 =
|
|
61608
|
+
var SelectContent2 = React292.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
|
|
61490
61609
|
const { themeClass, colors: colors2, components } = useTheme();
|
|
61491
61610
|
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Portal4, { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
|
|
61492
61611
|
Content23,
|
|
@@ -61524,7 +61643,7 @@ var SelectContent2 = React282.forwardRef(({ className, style, children, position
|
|
|
61524
61643
|
) });
|
|
61525
61644
|
});
|
|
61526
61645
|
SelectContent2.displayName = Content23.displayName;
|
|
61527
|
-
var SelectLabel2 =
|
|
61646
|
+
var SelectLabel2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
61528
61647
|
Label,
|
|
61529
61648
|
{
|
|
61530
61649
|
ref,
|
|
@@ -61536,7 +61655,7 @@ var SelectLabel2 = React282.forwardRef(({ className, ...props }, ref) => /* @__P
|
|
|
61536
61655
|
}
|
|
61537
61656
|
));
|
|
61538
61657
|
SelectLabel2.displayName = Label.displayName;
|
|
61539
|
-
var SelectItem2 =
|
|
61658
|
+
var SelectItem2 = React292.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
|
|
61540
61659
|
Item,
|
|
61541
61660
|
{
|
|
61542
61661
|
ref,
|
|
@@ -61552,7 +61671,7 @@ var SelectItem2 = React282.forwardRef(({ className, children, ...props }, ref) =
|
|
|
61552
61671
|
}
|
|
61553
61672
|
));
|
|
61554
61673
|
SelectItem2.displayName = Item.displayName;
|
|
61555
|
-
var SelectSeparator2 =
|
|
61674
|
+
var SelectSeparator2 = React292.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
61556
61675
|
Separator,
|
|
61557
61676
|
{
|
|
61558
61677
|
ref,
|
|
@@ -63072,6 +63191,19 @@ var WALLET_DEFINITIONS = [
|
|
|
63072
63191
|
{ id: "backpack", name: "Backpack", networks: ["solana"], installUrl: "https://backpack.app/" },
|
|
63073
63192
|
{ id: "glow", name: "Glow", networks: ["solana"], installUrl: "https://glow.app/" }
|
|
63074
63193
|
];
|
|
63194
|
+
function normalizeTokenAddress(address) {
|
|
63195
|
+
const normalized = (address ?? "").toLowerCase();
|
|
63196
|
+
if (normalized === "" || normalized === "native" || normalized === "0x0000000000000000000000000000000000000000") {
|
|
63197
|
+
return "native";
|
|
63198
|
+
}
|
|
63199
|
+
return normalized;
|
|
63200
|
+
}
|
|
63201
|
+
function balancesRepresentSameToken(a, b) {
|
|
63202
|
+
const tokenA = getTokenFromBalance(a);
|
|
63203
|
+
const tokenB = getTokenFromBalance(b);
|
|
63204
|
+
if (!tokenA || !tokenB) return false;
|
|
63205
|
+
return tokenA.chain_type === tokenB.chain_type && tokenA.chain_id === tokenB.chain_id && normalizeTokenAddress(tokenA.token_address) === normalizeTokenAddress(tokenB.token_address);
|
|
63206
|
+
}
|
|
63075
63207
|
function getSolanaProviders() {
|
|
63076
63208
|
if (typeof window === "undefined") return {};
|
|
63077
63209
|
const win = window;
|
|
@@ -63214,24 +63346,33 @@ function WalletConnect({
|
|
|
63214
63346
|
checkoutRemainingBaseUnits,
|
|
63215
63347
|
stablecoinParity = false,
|
|
63216
63348
|
productType,
|
|
63349
|
+
defaultSourceChainType,
|
|
63350
|
+
defaultSourceChainId,
|
|
63351
|
+
defaultSourceTokenAddress,
|
|
63352
|
+
defaultSourceSymbol,
|
|
63217
63353
|
onBack: parentOnBack,
|
|
63218
63354
|
onClose,
|
|
63355
|
+
canGoBack = true,
|
|
63356
|
+
depositWalletsLoading = false,
|
|
63219
63357
|
onExecutionsChange
|
|
63220
63358
|
}) {
|
|
63221
63359
|
const { colors: colors2, fonts, components } = useTheme();
|
|
63222
|
-
const walletProvidedAtMount =
|
|
63223
|
-
const [activeWalletInfo, setActiveWalletInfo] =
|
|
63224
|
-
const [activeDepositWallet, setActiveDepositWallet] =
|
|
63360
|
+
const walletProvidedAtMount = React302.useRef(!!initialWalletInfo && !!initialDepositWallet);
|
|
63361
|
+
const [activeWalletInfo, setActiveWalletInfo] = React302.useState(initialWalletInfo ?? null);
|
|
63362
|
+
const [activeDepositWallet, setActiveDepositWallet] = React302.useState(initialDepositWallet ?? null);
|
|
63225
63363
|
const initialView = initialWalletInfo && initialDepositWallet ? "select_token" : "select_wallet";
|
|
63226
|
-
const [view, setView] =
|
|
63227
|
-
const [isTransitioning, setIsTransitioning] =
|
|
63228
|
-
const viewRef =
|
|
63229
|
-
const
|
|
63230
|
-
const
|
|
63231
|
-
const [
|
|
63232
|
-
const [
|
|
63233
|
-
const [
|
|
63234
|
-
|
|
63364
|
+
const [view, setView] = React302.useState(initialView);
|
|
63365
|
+
const [isTransitioning, setIsTransitioning] = React302.useState(false);
|
|
63366
|
+
const viewRef = React302.useRef(initialView);
|
|
63367
|
+
const standalone = !canGoBack && !walletProvidedAtMount.current;
|
|
63368
|
+
const { wallet: detectedWallet, isLoading: detectingWallet } = useDetectedBrowserWallet({ enabled: standalone });
|
|
63369
|
+
const [autoResolved, setAutoResolved] = React302.useState(false);
|
|
63370
|
+
const [selectedWalletDef, setSelectedWalletDef] = React302.useState(null);
|
|
63371
|
+
const [connectingNetwork, setConnectingNetwork] = React302.useState(null);
|
|
63372
|
+
const [walletError, setWalletError] = React302.useState(null);
|
|
63373
|
+
const [isWalletConnecting, setIsWalletConnecting] = React302.useState(false);
|
|
63374
|
+
const [eip6963ProviderCount, setEip6963ProviderCount] = React302.useState(0);
|
|
63375
|
+
React302.useEffect(() => {
|
|
63235
63376
|
const store = getEip6963Store();
|
|
63236
63377
|
if (!store) return;
|
|
63237
63378
|
setEip6963ProviderCount(store.getProviders().length);
|
|
@@ -63239,20 +63380,44 @@ function WalletConnect({
|
|
|
63239
63380
|
setEip6963ProviderCount(providers.length);
|
|
63240
63381
|
});
|
|
63241
63382
|
}, []);
|
|
63242
|
-
const availableWallets =
|
|
63243
|
-
|
|
63244
|
-
|
|
63245
|
-
|
|
63246
|
-
|
|
63247
|
-
|
|
63248
|
-
|
|
63249
|
-
|
|
63250
|
-
|
|
63251
|
-
|
|
63252
|
-
|
|
63253
|
-
|
|
63254
|
-
|
|
63255
|
-
|
|
63383
|
+
const availableWallets = React302.useMemo(() => detectAvailableWallets(), [eip6963ProviderCount]);
|
|
63384
|
+
React302.useEffect(() => {
|
|
63385
|
+
if (!standalone || autoResolved || detectingWallet) return;
|
|
63386
|
+
if (!detectedWallet) {
|
|
63387
|
+
setAutoResolved(true);
|
|
63388
|
+
return;
|
|
63389
|
+
}
|
|
63390
|
+
const wct = detectedWallet.type === "phantom-solana" || detectedWallet.type === "solflare" || detectedWallet.type === "backpack" || detectedWallet.type === "glow" ? "solana" : "ethereum";
|
|
63391
|
+
const matching = depositWallets?.find((w) => w.chain_type === wct);
|
|
63392
|
+
if (!matching) {
|
|
63393
|
+
if (!depositWalletsLoading) setAutoResolved(true);
|
|
63394
|
+
return;
|
|
63395
|
+
}
|
|
63396
|
+
setActiveWalletInfo(detectedWallet);
|
|
63397
|
+
setActiveDepositWallet(matching);
|
|
63398
|
+
onWalletConnected?.(detectedWallet, matching);
|
|
63399
|
+
setView("select_token");
|
|
63400
|
+
viewRef.current = "select_token";
|
|
63401
|
+
setAutoResolved(true);
|
|
63402
|
+
}, [standalone, autoResolved, detectingWallet, detectedWallet, depositWallets, depositWalletsLoading]);
|
|
63403
|
+
React302.useEffect(() => {
|
|
63404
|
+
if (!standalone || autoResolved) return;
|
|
63405
|
+
const t12 = setTimeout(() => setAutoResolved(true), 5e3);
|
|
63406
|
+
return () => clearTimeout(t12);
|
|
63407
|
+
}, [standalone, autoResolved]);
|
|
63408
|
+
const [balances, setBalances] = React302.useState([]);
|
|
63409
|
+
const [isLoading, setIsLoading] = React302.useState(false);
|
|
63410
|
+
const [selectedBalance, setSelectedBalance] = React302.useState(null);
|
|
63411
|
+
const [totalBalanceUsd, setTotalBalanceUsd] = React302.useState(null);
|
|
63412
|
+
const [error, setError] = React302.useState(null);
|
|
63413
|
+
const [isDisconnectingWallet, setIsDisconnectingWallet] = React302.useState(false);
|
|
63414
|
+
const [amountUsd, setAmountUsd] = React302.useState(prefillAmountUsd ?? "");
|
|
63415
|
+
const [isConfirming, setIsConfirming] = React302.useState(false);
|
|
63416
|
+
const [hasSignedTransaction, setHasSignedTransaction] = React302.useState(false);
|
|
63417
|
+
const [tokenChainDetails, setTokenChainDetails] = React302.useState(null);
|
|
63418
|
+
const [loadingTokenDetails, setLoadingTokenDetails] = React302.useState(false);
|
|
63419
|
+
const [showTransactionDetails, setShowTransactionDetails] = React302.useState(false);
|
|
63420
|
+
const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React302.useState(null);
|
|
63256
63421
|
const walletInfo = activeWalletInfo;
|
|
63257
63422
|
const depositWallet = activeDepositWallet;
|
|
63258
63423
|
const hasWallet = !!activeWalletInfo && !!activeDepositWallet;
|
|
@@ -63260,7 +63425,7 @@ function WalletConnect({
|
|
|
63260
63425
|
const recipientAddress = activeDepositWallet?.address ?? "";
|
|
63261
63426
|
const isCheckoutMode = !!checkoutAmountUsd;
|
|
63262
63427
|
const supportedChainType = chainType === "algorand" || chainType === "xrpl" ? "ethereum" : chainType;
|
|
63263
|
-
const transitionTo =
|
|
63428
|
+
const transitionTo = React302.useCallback((nextView) => {
|
|
63264
63429
|
if (nextView === viewRef.current) return;
|
|
63265
63430
|
setIsTransitioning(true);
|
|
63266
63431
|
setTimeout(() => {
|
|
@@ -63345,6 +63510,7 @@ function WalletConnect({
|
|
|
63345
63510
|
metamask: "metamask"
|
|
63346
63511
|
};
|
|
63347
63512
|
const walletType = walletIdToType[wallet.id] || "metamask";
|
|
63513
|
+
setStoredWalletState(walletType);
|
|
63348
63514
|
connectedInfo = { type: walletType, name: wallet.name, address: accounts[0], icon: wallet.id };
|
|
63349
63515
|
} else {
|
|
63350
63516
|
const solProviders = getSolanaProviders();
|
|
@@ -63373,6 +63539,7 @@ function WalletConnect({
|
|
|
63373
63539
|
const response = await provider.connect();
|
|
63374
63540
|
setUserDisconnectedWallet(false);
|
|
63375
63541
|
const walletType = wallet.id === "solflare" ? "solflare" : wallet.id === "backpack" ? "backpack" : wallet.id === "glow" ? "glow" : "phantom-solana";
|
|
63542
|
+
setStoredWalletState(walletType);
|
|
63376
63543
|
connectedInfo = { type: walletType, name: wallet.name, address: response.publicKey.toString(), icon: wallet.id };
|
|
63377
63544
|
}
|
|
63378
63545
|
const walletChainType = network === "solana" ? "solana" : "ethereum";
|
|
@@ -63397,7 +63564,7 @@ function WalletConnect({
|
|
|
63397
63564
|
}
|
|
63398
63565
|
};
|
|
63399
63566
|
const selectedToken = selectedBalance ? getTokenFromBalance(selectedBalance) : null;
|
|
63400
|
-
const effectiveDestinationAmount =
|
|
63567
|
+
const effectiveDestinationAmount = React302.useMemo(() => {
|
|
63401
63568
|
if (!checkoutRemainingBaseUnits || checkoutRemainingBaseUnits === "0") return "0";
|
|
63402
63569
|
if (!checkoutAmountUsd) return checkoutRemainingBaseUnits;
|
|
63403
63570
|
const remaining = BigInt(checkoutRemainingBaseUnits);
|
|
@@ -63425,7 +63592,7 @@ function WalletConnect({
|
|
|
63425
63592
|
stablecoinParity,
|
|
63426
63593
|
enabled: isCheckoutMode && !!selectedToken && !!checkoutDestination && effectiveDestinationAmount !== "0"
|
|
63427
63594
|
});
|
|
63428
|
-
const activeCheckoutQuote =
|
|
63595
|
+
const activeCheckoutQuote = React302.useMemo(() => {
|
|
63429
63596
|
if (!isCheckoutMode) return null;
|
|
63430
63597
|
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 };
|
|
63431
63598
|
return checkoutQuote ?? null;
|
|
@@ -63439,19 +63606,19 @@ function WalletConnect({
|
|
|
63439
63606
|
onDepositSuccess,
|
|
63440
63607
|
onDepositError
|
|
63441
63608
|
});
|
|
63442
|
-
|
|
63609
|
+
React302.useEffect(() => {
|
|
63443
63610
|
onExecutionsChange?.(depositExecutions);
|
|
63444
63611
|
}, [depositExecutions, onExecutionsChange]);
|
|
63445
|
-
|
|
63612
|
+
React302.useEffect(() => {
|
|
63446
63613
|
if (!prefillAmountUsd || !tokenChainDetails || view !== "enter_amount") return;
|
|
63447
63614
|
const minDeposit = tokenChainDetails.minimum_deposit_amount_usd || 0;
|
|
63448
63615
|
const currentAmount = parseFloat(amountUsd) || 0;
|
|
63449
63616
|
if (currentAmount > 0 && currentAmount < minDeposit) setAmountUsd(minDeposit.toFixed(2));
|
|
63450
63617
|
}, [tokenChainDetails, view, prefillAmountUsd]);
|
|
63451
|
-
|
|
63618
|
+
React302.useEffect(() => {
|
|
63452
63619
|
if (view === "review") setShowTransactionDetails(false);
|
|
63453
63620
|
}, [view]);
|
|
63454
|
-
|
|
63621
|
+
React302.useEffect(() => {
|
|
63455
63622
|
if (view !== "enter_amount" && view !== "review" || !selectedBalance || !activeDepositWallet) return;
|
|
63456
63623
|
let cancelled = false;
|
|
63457
63624
|
const fetchTokenDetails = async () => {
|
|
@@ -63478,7 +63645,7 @@ function WalletConnect({
|
|
|
63478
63645
|
cancelled = true;
|
|
63479
63646
|
};
|
|
63480
63647
|
}, [view, selectedBalance, publishableKey, activeDepositWallet]);
|
|
63481
|
-
|
|
63648
|
+
React302.useEffect(() => {
|
|
63482
63649
|
if (!activeWalletInfo || !activeDepositWallet) return;
|
|
63483
63650
|
let cancelled = false;
|
|
63484
63651
|
setIsLoading(true);
|
|
@@ -63487,18 +63654,33 @@ function WalletConnect({
|
|
|
63487
63654
|
getAddressBalances(activeWalletInfo.address, sct, publishableKey).then((response) => {
|
|
63488
63655
|
if (cancelled) return;
|
|
63489
63656
|
const nonZero = response.balances.filter((b) => b.amount !== "0");
|
|
63490
|
-
const
|
|
63491
|
-
|
|
63492
|
-
|
|
63493
|
-
|
|
63494
|
-
|
|
63495
|
-
|
|
63496
|
-
|
|
63657
|
+
const defaultSource = {
|
|
63658
|
+
defaultSourceChainType,
|
|
63659
|
+
defaultSourceChainId,
|
|
63660
|
+
defaultSourceTokenAddress,
|
|
63661
|
+
defaultSourceSymbol
|
|
63662
|
+
};
|
|
63663
|
+
const sorted = [...nonZero].sort(
|
|
63664
|
+
(a, b) => compareBalancesWithDefaultSource(a, b, defaultSource)
|
|
63665
|
+
);
|
|
63497
63666
|
setBalances(sorted);
|
|
63498
63667
|
const totalUsd = nonZero.reduce((sum, b) => b.amount_usd ? sum + parseFloat(b.amount_usd) : sum, 0);
|
|
63499
63668
|
if (totalUsd > 0) setTotalBalanceUsd(totalUsd.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 }));
|
|
63500
63669
|
const eligible = sorted.filter(isBalanceEligible);
|
|
63501
|
-
|
|
63670
|
+
const defaultBalance = sorted.find(
|
|
63671
|
+
(balance) => isDefaultSourceBalance(balance, defaultSource)
|
|
63672
|
+
);
|
|
63673
|
+
setSelectedBalance((current) => {
|
|
63674
|
+
if (current) {
|
|
63675
|
+
const currentInNewBalances = sorted.find(
|
|
63676
|
+
(balance) => balancesRepresentSameToken(balance, current)
|
|
63677
|
+
);
|
|
63678
|
+
if (currentInNewBalances) return currentInNewBalances;
|
|
63679
|
+
}
|
|
63680
|
+
if (defaultBalance) return defaultBalance;
|
|
63681
|
+
if (eligible.length === 1) return eligible[0];
|
|
63682
|
+
return null;
|
|
63683
|
+
});
|
|
63502
63684
|
}).catch((err) => {
|
|
63503
63685
|
if (!cancelled) {
|
|
63504
63686
|
console.error("[WalletConnect] Error fetching balances:", err);
|
|
@@ -63510,21 +63692,29 @@ function WalletConnect({
|
|
|
63510
63692
|
return () => {
|
|
63511
63693
|
cancelled = true;
|
|
63512
63694
|
};
|
|
63513
|
-
}, [
|
|
63514
|
-
|
|
63695
|
+
}, [
|
|
63696
|
+
activeWalletInfo?.address,
|
|
63697
|
+
activeDepositWallet?.chain_type,
|
|
63698
|
+
publishableKey,
|
|
63699
|
+
defaultSourceChainType,
|
|
63700
|
+
defaultSourceChainId,
|
|
63701
|
+
defaultSourceTokenAddress,
|
|
63702
|
+
defaultSourceSymbol
|
|
63703
|
+
]);
|
|
63704
|
+
const usdToTokenRate = React302.useMemo(() => {
|
|
63515
63705
|
if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
|
|
63516
63706
|
const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
|
|
63517
63707
|
const balanceUsd = parseFloat(selectedBalance.amount_usd);
|
|
63518
63708
|
if (balanceAmount === 0 || balanceUsd === 0) return 0;
|
|
63519
63709
|
return balanceAmount / balanceUsd;
|
|
63520
63710
|
}, [selectedBalance, selectedToken]);
|
|
63521
|
-
const tokenAmount =
|
|
63711
|
+
const tokenAmount = React302.useMemo(() => {
|
|
63522
63712
|
if (isCheckoutMode && activeCheckoutQuote && selectedToken) return Number(activeCheckoutQuote.sourceAmount) / 10 ** activeCheckoutQuote.sourceTokenDecimals;
|
|
63523
63713
|
const usdNum = parseFloat(amountUsd) || 0;
|
|
63524
63714
|
if (usdNum === 0 || usdToTokenRate === 0) return 0;
|
|
63525
63715
|
return usdNum * usdToTokenRate;
|
|
63526
63716
|
}, [amountUsd, usdToTokenRate, isCheckoutMode, activeCheckoutQuote, selectedToken]);
|
|
63527
|
-
|
|
63717
|
+
React302.useEffect(() => {
|
|
63528
63718
|
if (isCheckoutMode && activeCheckoutQuote?.sourceAmountUsd && view === "enter_amount") setAmountUsd(activeCheckoutQuote.sourceAmountUsd);
|
|
63529
63719
|
}, [isCheckoutMode, activeCheckoutQuote, view]);
|
|
63530
63720
|
const maxTokenAmount = selectedBalance && selectedToken ? Number(selectedBalance.amount) / 10 ** selectedToken.decimals : 0;
|
|
@@ -63532,7 +63722,7 @@ function WalletConnect({
|
|
|
63532
63722
|
const inputUsdNum = parseFloat(amountUsd) || 0;
|
|
63533
63723
|
const minDepositUsd = tokenChainDetails?.minimum_deposit_amount_usd || 0;
|
|
63534
63724
|
const isValidAmount = isCheckoutMode && activeCheckoutQuote ? tokenAmount > 0 && tokenAmount <= maxTokenAmount : inputUsdNum > 0 && inputUsdNum <= maxUsdAmount && inputUsdNum >= minDepositUsd;
|
|
63535
|
-
const formattedTokenAmount =
|
|
63725
|
+
const formattedTokenAmount = React302.useMemo(() => {
|
|
63536
63726
|
if (tokenAmount === 0 || !selectedToken) return null;
|
|
63537
63727
|
return `${tokenAmount.toFixed(6)} ${selectedToken.symbol}`.replace(/\.?0+$/, "");
|
|
63538
63728
|
}, [tokenAmount, selectedToken]);
|
|
@@ -63580,16 +63770,25 @@ function WalletConnect({
|
|
|
63580
63770
|
} catch (err) {
|
|
63581
63771
|
console.warn("[WalletConnect] disconnect error:", err);
|
|
63582
63772
|
} finally {
|
|
63583
|
-
setActiveWalletInfo(null);
|
|
63584
|
-
setActiveDepositWallet(null);
|
|
63585
|
-
setSelectedBalance(null);
|
|
63586
|
-
setBalances([]);
|
|
63587
|
-
setTotalBalanceUsd(null);
|
|
63588
|
-
setAmountUsd(prefillAmountUsd ?? "");
|
|
63589
|
-
setError(null);
|
|
63590
63773
|
setIsDisconnectingWallet(false);
|
|
63591
|
-
|
|
63592
|
-
|
|
63774
|
+
const clearWalletState = () => {
|
|
63775
|
+
setActiveWalletInfo(null);
|
|
63776
|
+
setActiveDepositWallet(null);
|
|
63777
|
+
setSelectedBalance(null);
|
|
63778
|
+
setBalances([]);
|
|
63779
|
+
setTotalBalanceUsd(null);
|
|
63780
|
+
setAmountUsd(prefillAmountUsd ?? "");
|
|
63781
|
+
setError(null);
|
|
63782
|
+
};
|
|
63783
|
+
if (standalone) {
|
|
63784
|
+
onWalletDisconnect?.();
|
|
63785
|
+
transitionTo("select_wallet");
|
|
63786
|
+
setTimeout(clearWalletState, 160);
|
|
63787
|
+
} else {
|
|
63788
|
+
clearWalletState();
|
|
63789
|
+
if (onWalletDisconnect) onWalletDisconnect();
|
|
63790
|
+
else parentOnBack?.();
|
|
63791
|
+
}
|
|
63593
63792
|
}
|
|
63594
63793
|
};
|
|
63595
63794
|
const handleReview = () => {
|
|
@@ -63715,9 +63914,15 @@ function WalletConnect({
|
|
|
63715
63914
|
setIsConfirming(false);
|
|
63716
63915
|
}
|
|
63717
63916
|
};
|
|
63917
|
+
if (standalone && !autoResolved) {
|
|
63918
|
+
return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { style: viewTransitionStyle, children: [
|
|
63919
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: "Connect Wallet", showBack: canGoBack, onBack: handleBack, onClose }),
|
|
63920
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-16", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(LoaderCircle, { className: "uf-w-8 uf-h-8 uf-animate-spin", style: { color: colors2.primary } }) })
|
|
63921
|
+
] });
|
|
63922
|
+
}
|
|
63718
63923
|
if (view === "select_wallet") {
|
|
63719
63924
|
return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { style: viewTransitionStyle, children: [
|
|
63720
|
-
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: "Connect Wallet", showBack:
|
|
63925
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: "Connect Wallet", showBack: canGoBack, onBack: handleBack, onClose }),
|
|
63721
63926
|
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-pb-4", children: [
|
|
63722
63927
|
/* @__PURE__ */ (0, import_jsx_runtime73.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" }),
|
|
63723
63928
|
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-space-y-2", style: { maxHeight: 330, overflowY: "auto" }, children: availableWallets.map((wallet) => /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
|
|
@@ -63850,16 +64055,17 @@ function DepositModal({
|
|
|
63850
64055
|
defaultSourceChainId,
|
|
63851
64056
|
defaultSourceTokenAddress,
|
|
63852
64057
|
defaultSourceSymbol,
|
|
63853
|
-
hideDepositTracker
|
|
64058
|
+
hideDepositTracker,
|
|
63854
64059
|
showBalanceHeader = false,
|
|
63855
64060
|
transferInputVariant = "double_input",
|
|
63856
64061
|
depositConfirmationMode = "auto_ui",
|
|
63857
|
-
|
|
64062
|
+
enableTransferCrypto,
|
|
64063
|
+
enableConnectWallet,
|
|
63858
64064
|
browserWalletAmountQuickSelect = "percentage",
|
|
63859
64065
|
enablePayWithExchange,
|
|
63860
64066
|
enableFiatOnramp,
|
|
63861
|
-
enableConnectExchange
|
|
63862
|
-
enableCashApp
|
|
64067
|
+
enableConnectExchange,
|
|
64068
|
+
enableCashApp,
|
|
63863
64069
|
hideDepositFlowInfo = false,
|
|
63864
64070
|
hideDisplayDescription = false,
|
|
63865
64071
|
onDepositSuccess,
|
|
@@ -63877,11 +64083,23 @@ function DepositModal({
|
|
|
63877
64083
|
const { colors: colors2, fonts, components } = useTheme();
|
|
63878
64084
|
const effectiveInitialScreen = (0, import_react3.useMemo)(() => {
|
|
63879
64085
|
const s = initialScreen ?? "main";
|
|
63880
|
-
if (s === "tracker" && hideDepositTracker) return "main";
|
|
63881
|
-
if (s === "cashapp" &&
|
|
64086
|
+
if (s === "tracker" && hideDepositTracker === true) return "main";
|
|
64087
|
+
if (s === "cashapp" && enableCashApp === false) return "main";
|
|
63882
64088
|
if (s === "card" && enableFiatOnramp === false) return "main";
|
|
64089
|
+
if (s === "pay_with_exchange") return enablePayWithExchange === false ? "main" : "exchange";
|
|
64090
|
+
if (s === "exchange_connect")
|
|
64091
|
+
return enableConnectExchange === false ? "main" : "coinbase_connect";
|
|
64092
|
+
if (s === "wallet_connect") return enableConnectWallet === false ? "main" : "wallet_connect";
|
|
63883
64093
|
return s;
|
|
63884
|
-
}, [
|
|
64094
|
+
}, [
|
|
64095
|
+
initialScreen,
|
|
64096
|
+
hideDepositTracker,
|
|
64097
|
+
enableCashApp,
|
|
64098
|
+
enableFiatOnramp,
|
|
64099
|
+
enablePayWithExchange,
|
|
64100
|
+
enableConnectExchange,
|
|
64101
|
+
enableConnectWallet
|
|
64102
|
+
]);
|
|
63885
64103
|
const [containerEl, setContainerEl] = (0, import_react3.useState)(null);
|
|
63886
64104
|
const containerCallbackRef = (0, import_react3.useCallback)((el) => {
|
|
63887
64105
|
setContainerEl(el);
|
|
@@ -63900,26 +64118,37 @@ function DepositModal({
|
|
|
63900
64118
|
const [browserWalletModalOpen, setBrowserWalletModalOpen] = (0, import_react3.useState)(false);
|
|
63901
64119
|
const [browserWalletInfo, setBrowserWalletInfo] = (0, import_react3.useState)(null);
|
|
63902
64120
|
const [walletSelectionModalOpen, setWalletSelectionModalOpen] = (0, import_react3.useState)(false);
|
|
63903
|
-
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react3.useState)(() =>
|
|
64121
|
+
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react3.useState)(() => getStoredWalletState()?.chainType);
|
|
63904
64122
|
const [quotesCount, setQuotesCount] = (0, import_react3.useState)(0);
|
|
63905
64123
|
const [allExecutions, setAllExecutions] = (0, import_react3.useState)([]);
|
|
63906
64124
|
const [selectedExecution, setSelectedExecution] = (0, import_react3.useState)(null);
|
|
63907
64125
|
const [depositExecutions, setDepositExecutions] = (0, import_react3.useState)([]);
|
|
63908
64126
|
const isMobileView = useIsMobileViewport();
|
|
64127
|
+
const { projectConfig } = useProjectConfig({
|
|
64128
|
+
publishableKey,
|
|
64129
|
+
enabled: open
|
|
64130
|
+
});
|
|
64131
|
+
const showTransferCrypto = enableTransferCrypto ?? projectConfig?.transfer_crypto?.enabled ?? true;
|
|
64132
|
+
const showConnectWallet = enableConnectWallet ?? projectConfig?.connect_wallet?.enabled ?? true;
|
|
64133
|
+
const showPayWithExchange = enablePayWithExchange ?? projectConfig?.pay_with_exchange?.enabled ?? true;
|
|
64134
|
+
const showFiatOnramp = enableFiatOnramp ?? projectConfig?.fiat_onramp?.enabled ?? true;
|
|
64135
|
+
const showConnectExchange = enableConnectExchange ?? projectConfig?.connect_exchange?.enabled ?? true;
|
|
64136
|
+
const showCashApp = enableCashApp ?? projectConfig?.cash_app?.enabled ?? true;
|
|
64137
|
+
const showDepositTracker = hideDepositTracker ? false : projectConfig?.deposit_tracker?.enabled ?? true;
|
|
63909
64138
|
const [integrationExchanges, setIntegrationExchanges] = (0, import_react3.useState)([]);
|
|
63910
64139
|
(0, import_react3.useEffect)(() => {
|
|
63911
|
-
if (!
|
|
64140
|
+
if (!showConnectExchange || !open) return;
|
|
63912
64141
|
getIntegrationExchanges(publishableKey).then((res) => setIntegrationExchanges(res.data)).catch(() => {
|
|
63913
64142
|
});
|
|
63914
|
-
}, [
|
|
64143
|
+
}, [showConnectExchange, open, publishableKey]);
|
|
63915
64144
|
const [connectedExchange, setConnectedExchange] = (0, import_react3.useState)(() => {
|
|
63916
|
-
if (!
|
|
64145
|
+
if (!showConnectExchange) return null;
|
|
63917
64146
|
const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
|
|
63918
64147
|
if (!stored) return null;
|
|
63919
64148
|
return { name: "Coinbase", iconUrl: void 0, balanceUsd: null, isLoading: true };
|
|
63920
64149
|
});
|
|
63921
64150
|
(0, import_react3.useEffect)(() => {
|
|
63922
|
-
if (!
|
|
64151
|
+
if (!showConnectExchange || !open || view !== "main") return;
|
|
63923
64152
|
const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
|
|
63924
64153
|
if (!stored) {
|
|
63925
64154
|
setConnectedExchange(null);
|
|
@@ -63954,7 +64183,7 @@ function DepositModal({
|
|
|
63954
64183
|
setConnectedExchange(null);
|
|
63955
64184
|
}
|
|
63956
64185
|
});
|
|
63957
|
-
}, [
|
|
64186
|
+
}, [showConnectExchange, open, view, publishableKey]);
|
|
63958
64187
|
(0, import_react3.useEffect)(() => {
|
|
63959
64188
|
if (!connectedExchange || integrationExchanges.length === 0) return;
|
|
63960
64189
|
const cbExchange = integrationExchanges.find(
|
|
@@ -63993,18 +64222,39 @@ function DepositModal({
|
|
|
63993
64222
|
setResolvedTheme(theme);
|
|
63994
64223
|
}
|
|
63995
64224
|
}, [theme]);
|
|
63996
|
-
const { projectConfig } = useProjectConfig({
|
|
63997
|
-
publishableKey,
|
|
63998
|
-
enabled: open
|
|
63999
|
-
});
|
|
64000
|
-
const showPayWithExchange = enablePayWithExchange ?? projectConfig?.pay_with_exchange?.enabled ?? true;
|
|
64001
|
-
const showFiatOnramp = enableFiatOnramp ?? projectConfig?.fiat_onramp?.enabled ?? true;
|
|
64002
64225
|
(0, import_react3.useEffect)(() => {
|
|
64003
64226
|
if (view === "card" && !showFiatOnramp) {
|
|
64004
64227
|
setView("main");
|
|
64005
64228
|
setCardView("amount");
|
|
64229
|
+
} else if (view === "transfer" && !showTransferCrypto) {
|
|
64230
|
+
setView("main");
|
|
64231
|
+
} else if (view === "exchange" && !showPayWithExchange) {
|
|
64232
|
+
setView("main");
|
|
64233
|
+
} else if (view === "cashapp" && !showCashApp) {
|
|
64234
|
+
setView("main");
|
|
64235
|
+
} else if (view === "tracker" && !showDepositTracker) {
|
|
64236
|
+
setView("main");
|
|
64237
|
+
} else if (view === "coinbase_connect" && !showConnectExchange) {
|
|
64238
|
+
setView("main");
|
|
64239
|
+
} else if (view === "wallet_connect" && !showConnectWallet) {
|
|
64240
|
+
setView("main");
|
|
64241
|
+
}
|
|
64242
|
+
}, [
|
|
64243
|
+
view,
|
|
64244
|
+
showFiatOnramp,
|
|
64245
|
+
showTransferCrypto,
|
|
64246
|
+
showPayWithExchange,
|
|
64247
|
+
showCashApp,
|
|
64248
|
+
showDepositTracker,
|
|
64249
|
+
showConnectExchange,
|
|
64250
|
+
showConnectWallet
|
|
64251
|
+
]);
|
|
64252
|
+
(0, import_react3.useEffect)(() => {
|
|
64253
|
+
if (view === "exchange" && !showPayWithExchange) {
|
|
64254
|
+
setView("main");
|
|
64255
|
+
setExchangeView("providers");
|
|
64006
64256
|
}
|
|
64007
|
-
}, [view,
|
|
64257
|
+
}, [view, showPayWithExchange]);
|
|
64008
64258
|
const { exchanges, isLoading: exchangesLoading } = useExchanges({
|
|
64009
64259
|
publishableKey,
|
|
64010
64260
|
enabled: open && showPayWithExchange
|
|
@@ -64088,7 +64338,7 @@ function DepositModal({
|
|
|
64088
64338
|
depositPrerequisiteBody = standaloneNeedsDepositPrereq ? /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, { variant: "with-icons" }) : /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(import_jsx_runtime74.Fragment, { children: [
|
|
64089
64339
|
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, { variant: "with-icons" }),
|
|
64090
64340
|
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, { variant: "with-icons" }),
|
|
64091
|
-
|
|
64341
|
+
showDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(SkeletonButton, {})
|
|
64092
64342
|
] });
|
|
64093
64343
|
} else if (countryError) {
|
|
64094
64344
|
depositPrerequisiteBody = /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-8 uf-px-4 uf-text-center", children: [
|
|
@@ -64120,11 +64370,11 @@ function DepositModal({
|
|
|
64120
64370
|
const themeClass = resolvedTheme === "dark" ? "uf-dark" : "";
|
|
64121
64371
|
const handleWalletDisconnect = () => {
|
|
64122
64372
|
setUserDisconnectedWallet(true);
|
|
64123
|
-
|
|
64373
|
+
clearStoredWalletState();
|
|
64124
64374
|
setBrowserWalletChainType(void 0);
|
|
64125
64375
|
setBrowserWalletInfo(null);
|
|
64126
64376
|
setBrowserWalletModalOpen(false);
|
|
64127
|
-
if (view === "wallet_connect") setView("main");
|
|
64377
|
+
if (view === "wallet_connect" && sessionOpenedFromMenu) setView("main");
|
|
64128
64378
|
};
|
|
64129
64379
|
const handleExchangeDisconnect = () => {
|
|
64130
64380
|
const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
|
|
@@ -64133,7 +64383,7 @@ function DepositModal({
|
|
|
64133
64383
|
}
|
|
64134
64384
|
clearStoredIntegrationToken(IntegrationProvider.COINBASE);
|
|
64135
64385
|
setConnectedExchange(null);
|
|
64136
|
-
if (view === "coinbase_connect") setView("main");
|
|
64386
|
+
if (view === "coinbase_connect" && sessionOpenedFromMenu) setView("main");
|
|
64137
64387
|
};
|
|
64138
64388
|
const handleClose = () => {
|
|
64139
64389
|
onOpenChange(false);
|
|
@@ -64145,6 +64395,7 @@ function DepositModal({
|
|
|
64145
64395
|
setCardView("amount");
|
|
64146
64396
|
setExchangeView("providers");
|
|
64147
64397
|
setBrowserWalletInfo(null);
|
|
64398
|
+
setCoinbaseSkipToHoldings(false);
|
|
64148
64399
|
resetViewTimeoutRef.current = null;
|
|
64149
64400
|
}, 200);
|
|
64150
64401
|
};
|
|
@@ -64159,6 +64410,7 @@ function DepositModal({
|
|
|
64159
64410
|
setExchangeView("providers");
|
|
64160
64411
|
setBrowserWalletInfo(null);
|
|
64161
64412
|
setSelectedExecution(null);
|
|
64413
|
+
setCoinbaseSkipToHoldings(false);
|
|
64162
64414
|
}, [open, effectiveInitialScreen]);
|
|
64163
64415
|
(0, import_react3.useEffect)(
|
|
64164
64416
|
() => () => {
|
|
@@ -64196,7 +64448,7 @@ function DepositModal({
|
|
|
64196
64448
|
};
|
|
64197
64449
|
const handleBrowserWalletClick = (walletInfo) => {
|
|
64198
64450
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
64199
|
-
|
|
64451
|
+
setStoredWalletState(walletInfo.type);
|
|
64200
64452
|
setBrowserWalletChainType(walletChainType);
|
|
64201
64453
|
const matchingDepositWallet = wallets.find(
|
|
64202
64454
|
(w) => w.chain_type === walletChainType
|
|
@@ -64227,7 +64479,7 @@ function DepositModal({
|
|
|
64227
64479
|
};
|
|
64228
64480
|
const handleWalletConnected = (walletInfo) => {
|
|
64229
64481
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
64230
|
-
|
|
64482
|
+
setStoredWalletState(walletInfo.type);
|
|
64231
64483
|
setBrowserWalletChainType(walletChainType);
|
|
64232
64484
|
const matchingDepositWallet = wallets.find(
|
|
64233
64485
|
(w) => w.chain_type === walletChainType
|
|
@@ -64294,7 +64546,7 @@ function DepositModal({
|
|
|
64294
64546
|
),
|
|
64295
64547
|
/* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
64296
64548
|
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)("div", { className: "uf-space-y-3", children: depositPrerequisiteBody ?? /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(import_jsx_runtime74.Fragment, { children: [
|
|
64297
|
-
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
64549
|
+
showTransferCrypto && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
64298
64550
|
TransferCryptoButton,
|
|
64299
64551
|
{
|
|
64300
64552
|
onClick: () => setView("transfer"),
|
|
@@ -64303,7 +64555,7 @@ function DepositModal({
|
|
|
64303
64555
|
featuredTokens: projectConfig?.transfer_crypto.networks
|
|
64304
64556
|
}
|
|
64305
64557
|
),
|
|
64306
|
-
|
|
64558
|
+
showConnectWallet && !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
64307
64559
|
BrowserWalletButton,
|
|
64308
64560
|
{
|
|
64309
64561
|
onClick: handleBrowserWalletClick,
|
|
@@ -64333,7 +64585,7 @@ function DepositModal({
|
|
|
64333
64585
|
loading: exchangesLoading
|
|
64334
64586
|
}
|
|
64335
64587
|
),
|
|
64336
|
-
|
|
64588
|
+
showConnectExchange && connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
64337
64589
|
ConnectExchangeButton,
|
|
64338
64590
|
{
|
|
64339
64591
|
onClick: () => {
|
|
@@ -64347,7 +64599,7 @@ function DepositModal({
|
|
|
64347
64599
|
connectedExchange
|
|
64348
64600
|
}
|
|
64349
64601
|
),
|
|
64350
|
-
|
|
64602
|
+
showConnectExchange && !connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
64351
64603
|
ConnectExchangeButton,
|
|
64352
64604
|
{
|
|
64353
64605
|
onClick: () => {
|
|
@@ -64359,7 +64611,7 @@ function DepositModal({
|
|
|
64359
64611
|
exchanges: integrationExchanges
|
|
64360
64612
|
}
|
|
64361
64613
|
),
|
|
64362
|
-
|
|
64614
|
+
showCashApp && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
64363
64615
|
CashAppButton,
|
|
64364
64616
|
{
|
|
64365
64617
|
onClick: () => setView("cashapp"),
|
|
@@ -64368,7 +64620,7 @@ function DepositModal({
|
|
|
64368
64620
|
iconUrl: projectConfig?.asset_cdn_url ? `${projectConfig.asset_cdn_url}/api/public/icons/onramps/svg/cashapp.svg` : void 0
|
|
64369
64621
|
}
|
|
64370
64622
|
),
|
|
64371
|
-
|
|
64623
|
+
showDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
64372
64624
|
DepositTrackerButton,
|
|
64373
64625
|
{
|
|
64374
64626
|
onClick: () => {
|
|
@@ -64518,7 +64770,7 @@ function DepositModal({
|
|
|
64518
64770
|
DepositHeader,
|
|
64519
64771
|
{
|
|
64520
64772
|
title: payWithExchangeTitle,
|
|
64521
|
-
showBack:
|
|
64773
|
+
showBack: exchangeView === "pending" || sessionOpenedFromMenu,
|
|
64522
64774
|
onBack: handleBack,
|
|
64523
64775
|
onClose: handleClose
|
|
64524
64776
|
}
|
|
@@ -64572,7 +64824,12 @@ function DepositModal({
|
|
|
64572
64824
|
onClose: handleClose,
|
|
64573
64825
|
onDisconnect: handleExchangeDisconnect,
|
|
64574
64826
|
skipToHoldings: coinbaseSkipToHoldings,
|
|
64575
|
-
|
|
64827
|
+
canGoBack: sessionOpenedFromMenu,
|
|
64828
|
+
onExecutionsChange: setDepositExecutions,
|
|
64829
|
+
defaultSourceChainType,
|
|
64830
|
+
defaultSourceChainId,
|
|
64831
|
+
defaultSourceTokenAddress,
|
|
64832
|
+
defaultSourceSymbol
|
|
64576
64833
|
}
|
|
64577
64834
|
),
|
|
64578
64835
|
depositPoweredByFooter
|
|
@@ -64605,11 +64862,17 @@ function DepositModal({
|
|
|
64605
64862
|
onWalletDisconnect: handleWalletDisconnect,
|
|
64606
64863
|
onWalletConnected: (info, dw) => {
|
|
64607
64864
|
setBrowserWalletInfo({ ...info, depositWallet: dw });
|
|
64608
|
-
|
|
64865
|
+
setStoredWalletState(info.type);
|
|
64609
64866
|
setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
|
|
64610
64867
|
},
|
|
64611
64868
|
onBack: handleBack,
|
|
64612
|
-
onClose: handleClose
|
|
64869
|
+
onClose: handleClose,
|
|
64870
|
+
defaultSourceChainType,
|
|
64871
|
+
defaultSourceChainId,
|
|
64872
|
+
defaultSourceTokenAddress,
|
|
64873
|
+
defaultSourceSymbol,
|
|
64874
|
+
canGoBack: sessionOpenedFromMenu,
|
|
64875
|
+
depositWalletsLoading: walletsLoading
|
|
64613
64876
|
}
|
|
64614
64877
|
),
|
|
64615
64878
|
depositPoweredByFooter
|
|
@@ -64618,7 +64881,7 @@ function DepositModal({
|
|
|
64618
64881
|
DepositHeader,
|
|
64619
64882
|
{
|
|
64620
64883
|
title: cashAppView !== "amount" && cashAppAmount ? `Pay $${cashAppAmount} via Cash App` : "Pay with Cash App",
|
|
64621
|
-
showBack:
|
|
64884
|
+
showBack: cashAppView !== "amount" || sessionOpenedFromMenu,
|
|
64622
64885
|
onBack: handleBack,
|
|
64623
64886
|
onClose: handleClose
|
|
64624
64887
|
}
|
|
@@ -64710,7 +64973,8 @@ function CheckoutModal({
|
|
|
64710
64973
|
clientSecret,
|
|
64711
64974
|
publishableKey,
|
|
64712
64975
|
modalTitle,
|
|
64713
|
-
|
|
64976
|
+
enableTransferCrypto,
|
|
64977
|
+
enableConnectWallet,
|
|
64714
64978
|
defaultSourceChainType,
|
|
64715
64979
|
defaultSourceChainId,
|
|
64716
64980
|
defaultSourceTokenAddress,
|
|
@@ -64727,7 +64991,7 @@ function CheckoutModal({
|
|
|
64727
64991
|
const [browserWalletModalOpen, setBrowserWalletModalOpen] = (0, import_react29.useState)(false);
|
|
64728
64992
|
const [browserWalletInfo, setBrowserWalletInfo] = (0, import_react29.useState)(null);
|
|
64729
64993
|
const [walletSelectionModalOpen, setWalletSelectionModalOpen] = (0, import_react29.useState)(false);
|
|
64730
|
-
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react29.useState)(() =>
|
|
64994
|
+
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react29.useState)(() => getStoredWalletState()?.chainType);
|
|
64731
64995
|
const isMobileView = useIsMobileViewport();
|
|
64732
64996
|
const [resolvedTheme, setResolvedTheme] = (0, import_react29.useState)(
|
|
64733
64997
|
theme === "auto" ? "dark" : theme
|
|
@@ -64760,6 +65024,15 @@ function CheckoutModal({
|
|
|
64760
65024
|
publishableKey,
|
|
64761
65025
|
enabled: open
|
|
64762
65026
|
});
|
|
65027
|
+
const showTransferCrypto = enableTransferCrypto ?? projectConfig?.transfer_crypto?.enabled ?? true;
|
|
65028
|
+
const showConnectWallet = enableConnectWallet ?? projectConfig?.connect_wallet?.enabled ?? true;
|
|
65029
|
+
(0, import_react29.useEffect)(() => {
|
|
65030
|
+
if (view === "transfer" && !showTransferCrypto) {
|
|
65031
|
+
setView("main");
|
|
65032
|
+
} else if (view === "wallet_connect" && !showConnectWallet) {
|
|
65033
|
+
setView("main");
|
|
65034
|
+
}
|
|
65035
|
+
}, [showConnectWallet, showTransferCrypto, view]);
|
|
64763
65036
|
const prevStatusRef = (0, import_react29.useRef)(null);
|
|
64764
65037
|
(0, import_react29.useEffect)(() => {
|
|
64765
65038
|
if (!paymentIntent) return;
|
|
@@ -64850,7 +65123,7 @@ function CheckoutModal({
|
|
|
64850
65123
|
const handleBrowserWalletClick = (0, import_react29.useCallback)(
|
|
64851
65124
|
(walletInfo) => {
|
|
64852
65125
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
64853
|
-
|
|
65126
|
+
setStoredWalletState(walletInfo.type);
|
|
64854
65127
|
setBrowserWalletChainType(walletChainType);
|
|
64855
65128
|
const matchingDepositWallet = wallets.find(
|
|
64856
65129
|
(w) => w.chain_type === walletChainType
|
|
@@ -64877,7 +65150,7 @@ function CheckoutModal({
|
|
|
64877
65150
|
const handleWalletConnected = (0, import_react29.useCallback)(
|
|
64878
65151
|
(walletInfo) => {
|
|
64879
65152
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
64880
|
-
|
|
65153
|
+
setStoredWalletState(walletInfo.type);
|
|
64881
65154
|
setBrowserWalletChainType(walletChainType);
|
|
64882
65155
|
const matchingDepositWallet = wallets.find(
|
|
64883
65156
|
(w) => w.chain_type === walletChainType
|
|
@@ -64901,7 +65174,7 @@ function CheckoutModal({
|
|
|
64901
65174
|
);
|
|
64902
65175
|
const handleWalletDisconnect = (0, import_react29.useCallback)(() => {
|
|
64903
65176
|
setUserDisconnectedWallet(true);
|
|
64904
|
-
|
|
65177
|
+
clearStoredWalletState();
|
|
64905
65178
|
setBrowserWalletChainType(void 0);
|
|
64906
65179
|
setBrowserWalletInfo(null);
|
|
64907
65180
|
setBrowserWalletModalOpen(false);
|
|
@@ -65136,7 +65409,7 @@ function CheckoutModal({
|
|
|
65136
65409
|
] }) : paymentIntent ? /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "uf-space-y-3", children: [
|
|
65137
65410
|
progressSection,
|
|
65138
65411
|
(paymentIntent.status === "requires_payment" || paymentIntent.status === "processing") && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_jsx_runtime75.Fragment, { children: [
|
|
65139
|
-
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
65412
|
+
showTransferCrypto && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
65140
65413
|
TransferCryptoButton,
|
|
65141
65414
|
{
|
|
65142
65415
|
onClick: () => setView("transfer"),
|
|
@@ -65145,7 +65418,7 @@ function CheckoutModal({
|
|
|
65145
65418
|
featuredTokens: projectConfig?.transfer_crypto.networks
|
|
65146
65419
|
}
|
|
65147
65420
|
),
|
|
65148
|
-
|
|
65421
|
+
showConnectWallet && !isMobileView && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
65149
65422
|
BrowserWalletButton,
|
|
65150
65423
|
{
|
|
65151
65424
|
onClick: handleBrowserWalletClick,
|
|
@@ -65286,14 +65559,18 @@ function CheckoutModal({
|
|
|
65286
65559
|
onWalletDisconnect: handleWalletDisconnect,
|
|
65287
65560
|
onWalletConnected: (info, dw) => {
|
|
65288
65561
|
setBrowserWalletInfo({ ...info, depositWallet: dw });
|
|
65289
|
-
|
|
65562
|
+
setStoredWalletState(info.type);
|
|
65290
65563
|
setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
|
|
65291
65564
|
},
|
|
65292
65565
|
onNewDeposit: () => setView("main"),
|
|
65293
65566
|
onDone: () => setView("main"),
|
|
65294
65567
|
paymentIntentStatus: paymentIntent.status,
|
|
65295
65568
|
onBack: handleBack,
|
|
65296
|
-
onClose: handleClose
|
|
65569
|
+
onClose: handleClose,
|
|
65570
|
+
defaultSourceChainType,
|
|
65571
|
+
defaultSourceChainId,
|
|
65572
|
+
defaultSourceTokenAddress,
|
|
65573
|
+
defaultSourceSymbol
|
|
65297
65574
|
}
|
|
65298
65575
|
),
|
|
65299
65576
|
poweredByFooter
|
|
@@ -67256,6 +67533,7 @@ function UnifoldProvider2({
|
|
|
67256
67533
|
onOpenChange: closeCheckout,
|
|
67257
67534
|
clientSecret: checkoutConfig.clientSecret,
|
|
67258
67535
|
publishableKey,
|
|
67536
|
+
enableTransferCrypto: config?.enableTransferCrypto,
|
|
67259
67537
|
enableConnectWallet: config?.enableConnectWallet,
|
|
67260
67538
|
defaultSourceChainType: checkoutConfig.defaultSourceChainType,
|
|
67261
67539
|
defaultSourceChainId: checkoutConfig.defaultSourceChainId,
|
|
@@ -67312,6 +67590,7 @@ function UnifoldProvider2({
|
|
|
67312
67590
|
hideDepositTracker: config?.hideDepositTracker,
|
|
67313
67591
|
showBalanceHeader: config?.showBalanceHeader,
|
|
67314
67592
|
transferInputVariant: config?.transferInputVariant,
|
|
67593
|
+
enableTransferCrypto: config?.enableTransferCrypto,
|
|
67315
67594
|
enableConnectWallet: config?.enableConnectWallet,
|
|
67316
67595
|
enablePayWithExchange: config?.enablePayWithExchange,
|
|
67317
67596
|
enableFiatOnramp: config?.enableFiatOnramp,
|