@rhinestone/deposit-modal 0.1.48 → 0.1.49
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/{DepositModalReown-SV6QIUTL.cjs → DepositModalReown-AVQEEWEQ.cjs} +2 -2
- package/dist/{DepositModalReown-3V2EFXH5.mjs → DepositModalReown-PWD3WK7I.mjs} +1 -1
- package/dist/{chunk-ZK6VAHSB.cjs → chunk-KOYHFHYW.cjs} +181 -114
- package/dist/{chunk-ZAQISJAP.mjs → chunk-QLLL6ARN.mjs} +144 -77
- package/dist/deposit.cjs +2 -2
- package/dist/deposit.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +1 -1
- package/dist/reown.cjs +2 -2
- package/dist/reown.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkKOYHFHYWcjs = require('./chunk-KOYHFHYW.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -29,7 +29,7 @@ function DepositModalWithReown(props) {
|
|
|
29
29
|
reown.disconnect();
|
|
30
30
|
}, [reown.disconnect]);
|
|
31
31
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
32
|
-
|
|
32
|
+
_chunkKOYHFHYWcjs.DepositModalInner,
|
|
33
33
|
{
|
|
34
34
|
...props,
|
|
35
35
|
reownWallet: reownWithSolana,
|
|
@@ -56,7 +56,6 @@ var _react = require('react');
|
|
|
56
56
|
|
|
57
57
|
// src/DepositFlow.tsx
|
|
58
58
|
|
|
59
|
-
var _viem = require('viem');
|
|
60
59
|
|
|
61
60
|
// src/components/steps/SetupStep.tsx
|
|
62
61
|
|
|
@@ -246,7 +245,7 @@ function SetupStep({
|
|
|
246
245
|
|
|
247
246
|
// src/components/steps/AssetSelectStep.tsx
|
|
248
247
|
|
|
249
|
-
|
|
248
|
+
var _viem = require('viem');
|
|
250
249
|
|
|
251
250
|
function AssetSelectStep({
|
|
252
251
|
address,
|
|
@@ -2006,35 +2005,81 @@ function SolanaAmountStep({
|
|
|
2006
2005
|
token,
|
|
2007
2006
|
balance,
|
|
2008
2007
|
balanceUsd,
|
|
2008
|
+
defaultAmount,
|
|
2009
|
+
uiConfig,
|
|
2009
2010
|
onContinue,
|
|
2010
2011
|
debug
|
|
2011
2012
|
}) {
|
|
2012
2013
|
const [amount, setAmount] = _react.useState.call(void 0, "");
|
|
2013
2014
|
const [error, setError] = _react.useState.call(void 0, null);
|
|
2015
|
+
const isSourceStablecoin = _chunkNELAYNA3cjs.isStablecoinSymbol.call(void 0, token.symbol);
|
|
2016
|
+
const tokenPriceUsd = _react.useMemo.call(void 0, () => {
|
|
2017
|
+
if (isSourceStablecoin) return 1;
|
|
2018
|
+
try {
|
|
2019
|
+
const balanceUnits = Number(_viem.formatUnits.call(void 0, balance, token.decimals));
|
|
2020
|
+
if (!Number.isFinite(balanceUnits) || balanceUnits <= 0 || balanceUsd <= 0) {
|
|
2021
|
+
return null;
|
|
2022
|
+
}
|
|
2023
|
+
const price = balanceUsd / balanceUnits;
|
|
2024
|
+
return price > 0 ? price : null;
|
|
2025
|
+
} catch (e15) {
|
|
2026
|
+
return null;
|
|
2027
|
+
}
|
|
2028
|
+
}, [isSourceStablecoin, balance, token.decimals, balanceUsd]);
|
|
2029
|
+
const hasPricing = tokenPriceUsd !== null;
|
|
2030
|
+
_react.useEffect.call(void 0, () => {
|
|
2031
|
+
if (defaultAmount && !amount) {
|
|
2032
|
+
const parsed = Number(defaultAmount);
|
|
2033
|
+
if (Number.isFinite(parsed) && parsed > 0) {
|
|
2034
|
+
setAmount(parsed.toString());
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
}, [defaultAmount, amount]);
|
|
2014
2038
|
const formattedBalance = _react.useMemo.call(void 0, () => {
|
|
2015
2039
|
try {
|
|
2016
2040
|
const raw = _viem.formatUnits.call(void 0, balance, token.decimals);
|
|
2017
2041
|
const numeric = Number(raw);
|
|
2018
2042
|
if (!Number.isFinite(numeric)) return raw;
|
|
2019
2043
|
return _chunk7HJ7IBRHcjs.tokenFormatter.format(numeric);
|
|
2020
|
-
} catch (
|
|
2044
|
+
} catch (e16) {
|
|
2021
2045
|
return "...";
|
|
2022
2046
|
}
|
|
2023
2047
|
}, [balance, token.decimals]);
|
|
2048
|
+
const computedBalanceUsd = _react.useMemo.call(void 0, () => {
|
|
2049
|
+
try {
|
|
2050
|
+
const balanceUnits = Number(_viem.formatUnits.call(void 0, balance, token.decimals));
|
|
2051
|
+
if (!Number.isFinite(balanceUnits) || balanceUnits < 0) return null;
|
|
2052
|
+
if (tokenPriceUsd !== null) return balanceUnits * tokenPriceUsd;
|
|
2053
|
+
if (Number.isFinite(balanceUsd) && balanceUsd > 0) return balanceUsd;
|
|
2054
|
+
return null;
|
|
2055
|
+
} catch (e17) {
|
|
2056
|
+
return null;
|
|
2057
|
+
}
|
|
2058
|
+
}, [balance, token.decimals, tokenPriceUsd, balanceUsd]);
|
|
2024
2059
|
const formattedBalanceUsd = _react.useMemo.call(void 0, () => {
|
|
2025
|
-
if (
|
|
2026
|
-
return _chunk7HJ7IBRHcjs.currencyFormatter.format(
|
|
2027
|
-
}, [
|
|
2060
|
+
if (computedBalanceUsd === null || computedBalanceUsd <= 0) return null;
|
|
2061
|
+
return _chunk7HJ7IBRHcjs.currencyFormatter.format(computedBalanceUsd);
|
|
2062
|
+
}, [computedBalanceUsd]);
|
|
2028
2063
|
const spendableBalance = _react.useMemo.call(void 0, () => {
|
|
2029
2064
|
if (!isNativeSol(token)) return balance;
|
|
2030
2065
|
return balance > SOL_FEE_RESERVE_LAMPORTS ? balance - SOL_FEE_RESERVE_LAMPORTS : 0n;
|
|
2031
2066
|
}, [balance, token]);
|
|
2067
|
+
const spendableBalanceUsd = _react.useMemo.call(void 0, () => {
|
|
2068
|
+
try {
|
|
2069
|
+
const spendableUnits = Number(_viem.formatUnits.call(void 0, spendableBalance, token.decimals));
|
|
2070
|
+
if (!Number.isFinite(spendableUnits) || spendableUnits < 0) return null;
|
|
2071
|
+
if (tokenPriceUsd !== null) return spendableUnits * tokenPriceUsd;
|
|
2072
|
+
return null;
|
|
2073
|
+
} catch (e18) {
|
|
2074
|
+
return null;
|
|
2075
|
+
}
|
|
2076
|
+
}, [spendableBalance, token.decimals, tokenPriceUsd]);
|
|
2032
2077
|
const handlePresetClick = (percentage) => {
|
|
2033
2078
|
try {
|
|
2034
2079
|
const spendableUnits = Number(_viem.formatUnits.call(void 0, spendableBalance, token.decimals));
|
|
2035
2080
|
if (!Number.isFinite(spendableUnits) || spendableUnits <= 0) return;
|
|
2036
|
-
const value = spendableUnits * percentage / 100;
|
|
2037
|
-
const maxDecimals =
|
|
2081
|
+
const value = isSourceStablecoin || !hasPricing ? spendableUnits * percentage / 100 : (_nullishCoalesce(spendableBalanceUsd, () => ( 0))) * percentage / 100;
|
|
2082
|
+
const maxDecimals = 3;
|
|
2038
2083
|
const factor = 10 ** maxDecimals;
|
|
2039
2084
|
const truncated = Math.floor(value * factor) / factor;
|
|
2040
2085
|
const formatted = truncated.toFixed(maxDecimals).replace(/\.?0+$/, "");
|
|
@@ -2044,7 +2089,7 @@ function SolanaAmountStep({
|
|
|
2044
2089
|
formatted
|
|
2045
2090
|
});
|
|
2046
2091
|
setAmount(formatted);
|
|
2047
|
-
} catch (
|
|
2092
|
+
} catch (e19) {
|
|
2048
2093
|
return;
|
|
2049
2094
|
}
|
|
2050
2095
|
if (error) setError(null);
|
|
@@ -2059,12 +2104,30 @@ function SolanaAmountStep({
|
|
|
2059
2104
|
setError("Please enter a valid amount");
|
|
2060
2105
|
return;
|
|
2061
2106
|
}
|
|
2107
|
+
const sourceAmount = isSourceStablecoin || !hasPricing ? numericAmount : numericAmount / tokenPriceUsd;
|
|
2108
|
+
if (hasPricing) {
|
|
2109
|
+
const usdValue = numericAmount;
|
|
2110
|
+
if (_optionalChain([uiConfig, 'optionalAccess', _38 => _38.maxDepositUsd]) && usdValue > uiConfig.maxDepositUsd) {
|
|
2111
|
+
setError(
|
|
2112
|
+
`Maximum deposit is ${_chunk7HJ7IBRHcjs.currencyFormatter.format(uiConfig.maxDepositUsd)}`
|
|
2113
|
+
);
|
|
2114
|
+
return;
|
|
2115
|
+
}
|
|
2116
|
+
if (_optionalChain([uiConfig, 'optionalAccess', _39 => _39.minDepositUsd]) && usdValue < uiConfig.minDepositUsd) {
|
|
2117
|
+
setError(
|
|
2118
|
+
`Minimum deposit is ${_chunk7HJ7IBRHcjs.currencyFormatter.format(uiConfig.minDepositUsd)}`
|
|
2119
|
+
);
|
|
2120
|
+
return;
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
const sourceAmountStr = sourceAmount.toString();
|
|
2062
2124
|
let amountInUnits;
|
|
2063
2125
|
try {
|
|
2064
|
-
amountInUnits = _viem.parseUnits.call(void 0,
|
|
2065
|
-
} catch (
|
|
2126
|
+
amountInUnits = _viem.parseUnits.call(void 0, sourceAmountStr, token.decimals);
|
|
2127
|
+
} catch (e20) {
|
|
2066
2128
|
_chunk7HJ7IBRHcjs.debugLog.call(void 0, debug, "solana-amount", "amount:invalid", {
|
|
2067
2129
|
amount,
|
|
2130
|
+
sourceAmount: sourceAmountStr,
|
|
2068
2131
|
reason: "parse-units-failed"
|
|
2069
2132
|
});
|
|
2070
2133
|
setError("Please enter a valid amount");
|
|
@@ -2086,46 +2149,47 @@ function SolanaAmountStep({
|
|
|
2086
2149
|
}
|
|
2087
2150
|
_chunk7HJ7IBRHcjs.debugLog.call(void 0, debug, "solana-amount", "amount:continue", {
|
|
2088
2151
|
symbol: token.symbol,
|
|
2089
|
-
amount,
|
|
2152
|
+
inputAmountUsd: amount,
|
|
2153
|
+
sourceAmount: sourceAmountStr,
|
|
2090
2154
|
amountInUnits: amountInUnits.toString()
|
|
2091
2155
|
});
|
|
2092
2156
|
setError(null);
|
|
2093
|
-
onContinue(token, amount);
|
|
2157
|
+
onContinue(token, sourceAmountStr, amount);
|
|
2094
2158
|
};
|
|
2095
2159
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step", children: [
|
|
2096
2160
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { style: { padding: "12px 12px 4px" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-title", children: "Enter amount" }) }),
|
|
2097
2161
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step-body", style: { paddingTop: 0 }, children: [
|
|
2098
2162
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-display", children: [
|
|
2099
|
-
/* @__PURE__ */ _jsxruntime.
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2163
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-amount-input-wrapper", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2164
|
+
"input",
|
|
2165
|
+
{
|
|
2166
|
+
type: "text",
|
|
2167
|
+
inputMode: "decimal",
|
|
2168
|
+
className: "rs-amount-input-large",
|
|
2169
|
+
placeholder: "$0.00",
|
|
2170
|
+
value: amount ? `$${amount}` : "",
|
|
2171
|
+
onChange: (e) => {
|
|
2172
|
+
const raw = e.target.value.replace(/[^0-9.]/g, "");
|
|
2173
|
+
const parts = raw.split(".");
|
|
2174
|
+
if (parts.length > 2) return;
|
|
2175
|
+
setAmount(raw);
|
|
2176
|
+
if (error) setError(null);
|
|
2177
|
+
},
|
|
2178
|
+
autoFocus: true
|
|
2179
|
+
}
|
|
2180
|
+
) }),
|
|
2181
|
+
!isSourceStablecoin && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-amount-available", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-amount-available-value", children: [
|
|
2182
|
+
formattedBalance,
|
|
2183
|
+
" ",
|
|
2184
|
+
token.symbol,
|
|
2185
|
+
" available",
|
|
2186
|
+
formattedBalanceUsd && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { style: { color: "var(--rs-muted-foreground)" }, children: [
|
|
2123
2187
|
" ",
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
] })
|
|
2188
|
+
"(",
|
|
2189
|
+
formattedBalanceUsd,
|
|
2190
|
+
")"
|
|
2191
|
+
] })
|
|
2192
|
+
] }) })
|
|
2129
2193
|
] }),
|
|
2130
2194
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-presets", children: [
|
|
2131
2195
|
[25, 50, 75].map((pct) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
@@ -2195,7 +2259,8 @@ function SolanaConfirmStep({
|
|
|
2195
2259
|
solanaAddress,
|
|
2196
2260
|
solanaDepositAddress,
|
|
2197
2261
|
token,
|
|
2198
|
-
|
|
2262
|
+
sourceAmount,
|
|
2263
|
+
inputAmountUsd,
|
|
2199
2264
|
targetAmount,
|
|
2200
2265
|
targetTokenPriceUsd,
|
|
2201
2266
|
targetChain,
|
|
@@ -2210,7 +2275,7 @@ function SolanaConfirmStep({
|
|
|
2210
2275
|
const [error, setError] = _react.useState.call(void 0, null);
|
|
2211
2276
|
const targetSymbol = _chunkNELAYNA3cjs.getTokenSymbol.call(void 0, targetToken, targetChain);
|
|
2212
2277
|
const isSameToken = token.symbol.toUpperCase() === targetSymbol.toUpperCase();
|
|
2213
|
-
const formattedAmount =
|
|
2278
|
+
const formattedAmount = sourceAmount && !Number.isNaN(Number(sourceAmount)) ? Number(sourceAmount).toLocaleString("en-US", { maximumFractionDigits: 6 }) : "0";
|
|
2214
2279
|
const formattedReceiveAmount = (() => {
|
|
2215
2280
|
if (isSameToken) return formattedAmount;
|
|
2216
2281
|
const dollarValue = Number(targetAmount);
|
|
@@ -2231,11 +2296,11 @@ function SolanaConfirmStep({
|
|
|
2231
2296
|
setError("Solana wallet not connected");
|
|
2232
2297
|
return;
|
|
2233
2298
|
}
|
|
2234
|
-
const parsedAmount = parseFloat(
|
|
2299
|
+
const parsedAmount = parseFloat(sourceAmount);
|
|
2235
2300
|
if (isNaN(parsedAmount) || parsedAmount <= 0) {
|
|
2236
2301
|
_chunk7HJ7IBRHcjs.debugLog.call(void 0, debug, "solana-confirm", "submit:blocked", {
|
|
2237
2302
|
reason: "invalid-amount",
|
|
2238
|
-
|
|
2303
|
+
sourceAmount
|
|
2239
2304
|
});
|
|
2240
2305
|
setError("Please enter a valid amount");
|
|
2241
2306
|
return;
|
|
@@ -2247,7 +2312,8 @@ function SolanaConfirmStep({
|
|
|
2247
2312
|
solanaAddress,
|
|
2248
2313
|
solanaDepositAddress,
|
|
2249
2314
|
token: token.symbol,
|
|
2250
|
-
|
|
2315
|
+
sourceAmount,
|
|
2316
|
+
inputAmountUsd
|
|
2251
2317
|
});
|
|
2252
2318
|
try {
|
|
2253
2319
|
const check = await service.checkAccount(smartAccount);
|
|
@@ -2263,10 +2329,10 @@ function SolanaConfirmStep({
|
|
|
2263
2329
|
);
|
|
2264
2330
|
}
|
|
2265
2331
|
const connection = getSolanaConnection();
|
|
2266
|
-
const amountUnits = _viem.parseUnits.call(void 0,
|
|
2332
|
+
const amountUnits = _viem.parseUnits.call(void 0, sourceAmount, token.decimals);
|
|
2267
2333
|
_chunk7HJ7IBRHcjs.debugLog.call(void 0, debug, "solana-confirm", "tx:build:start", {
|
|
2268
2334
|
token: token.symbol,
|
|
2269
|
-
|
|
2335
|
+
sourceAmount,
|
|
2270
2336
|
amountUnits: amountUnits.toString()
|
|
2271
2337
|
});
|
|
2272
2338
|
const transaction = isNativeSol(token) ? await buildSolTransferTransaction(
|
|
@@ -2284,7 +2350,7 @@ function SolanaConfirmStep({
|
|
|
2284
2350
|
_chunk7HJ7IBRHcjs.debugLog.call(void 0, debug, "solana-confirm", "tx:build:success", {
|
|
2285
2351
|
token: token.symbol,
|
|
2286
2352
|
instructionCount: transaction.instructions.length,
|
|
2287
|
-
feePayer: _optionalChain([transaction, 'access',
|
|
2353
|
+
feePayer: _optionalChain([transaction, 'access', _40 => _40.feePayer, 'optionalAccess', _41 => _41.toBase58, 'call', _42 => _42()]),
|
|
2288
2354
|
recentBlockhash: transaction.recentBlockhash
|
|
2289
2355
|
});
|
|
2290
2356
|
const txHash = await sendSolanaTransaction(
|
|
@@ -2303,10 +2369,10 @@ function SolanaConfirmStep({
|
|
|
2303
2369
|
_chunk7HJ7IBRHcjs.debugError.call(void 0, debug, "solana-confirm", "submit:failure", err, {
|
|
2304
2370
|
smartAccount,
|
|
2305
2371
|
token: token.symbol,
|
|
2306
|
-
|
|
2372
|
+
sourceAmount
|
|
2307
2373
|
});
|
|
2308
2374
|
setError(message);
|
|
2309
|
-
_optionalChain([onError, 'optionalCall',
|
|
2375
|
+
_optionalChain([onError, 'optionalCall', _43 => _43(message, "SOLANA_TRANSFER_ERROR")]);
|
|
2310
2376
|
} finally {
|
|
2311
2377
|
setIsSubmitting(false);
|
|
2312
2378
|
}
|
|
@@ -2437,7 +2503,7 @@ function SolanaConfirmStep({
|
|
|
2437
2503
|
{
|
|
2438
2504
|
onClick: handleConfirm,
|
|
2439
2505
|
loading: isSubmitting,
|
|
2440
|
-
disabled: !
|
|
2506
|
+
disabled: !sourceAmount || Number(sourceAmount) <= 0,
|
|
2441
2507
|
fullWidth: true,
|
|
2442
2508
|
children: "Confirm Order"
|
|
2443
2509
|
}
|
|
@@ -2518,19 +2584,19 @@ function DepositFlow({
|
|
|
2518
2584
|
try {
|
|
2519
2585
|
const balanceUnits = Number(asset.balance) / 10 ** asset.decimals;
|
|
2520
2586
|
if (balanceUnits > 0) return asset.balanceUsd / balanceUnits;
|
|
2521
|
-
} catch (
|
|
2587
|
+
} catch (e21) {
|
|
2522
2588
|
}
|
|
2523
2589
|
}
|
|
2524
2590
|
}
|
|
2525
2591
|
return null;
|
|
2526
2592
|
}, []);
|
|
2527
2593
|
const dappSwitchChain = _react.useMemo.call(void 0, () => {
|
|
2528
|
-
if (!_optionalChain([dappWalletClient, 'optionalAccess',
|
|
2594
|
+
if (!_optionalChain([dappWalletClient, 'optionalAccess', _44 => _44.switchChain])) return void 0;
|
|
2529
2595
|
return async (chainId) => {
|
|
2530
|
-
await _optionalChain([dappWalletClient, 'access',
|
|
2596
|
+
await _optionalChain([dappWalletClient, 'access', _45 => _45.switchChain, 'optionalCall', _46 => _46({ id: chainId })]);
|
|
2531
2597
|
};
|
|
2532
2598
|
}, [dappWalletClient]);
|
|
2533
|
-
const connectedWalletAddress = _nullishCoalesce(_optionalChain([dappWalletClient, 'optionalAccess',
|
|
2599
|
+
const connectedWalletAddress = _nullishCoalesce(_optionalChain([dappWalletClient, 'optionalAccess', _47 => _47.account, 'optionalAccess', _48 => _48.address]), () => ( null));
|
|
2534
2600
|
const walletOptions = _react.useMemo.call(void 0, () => {
|
|
2535
2601
|
const options = [];
|
|
2536
2602
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -2544,7 +2610,7 @@ function DepositFlow({
|
|
|
2544
2610
|
});
|
|
2545
2611
|
seen.add(id);
|
|
2546
2612
|
}
|
|
2547
|
-
if (_optionalChain([reownWallet, 'optionalAccess',
|
|
2613
|
+
if (_optionalChain([reownWallet, 'optionalAccess', _49 => _49.isConnected]) && reownWallet.isSolana && reownWallet.solanaAddress && dappAddress) {
|
|
2548
2614
|
const id = _nullishCoalesce(reownWallet.caipAddress, () => ( `solana:${reownWallet.solanaAddress}`));
|
|
2549
2615
|
if (!seen.has(id)) {
|
|
2550
2616
|
options.push({
|
|
@@ -2556,7 +2622,7 @@ function DepositFlow({
|
|
|
2556
2622
|
});
|
|
2557
2623
|
seen.add(id);
|
|
2558
2624
|
}
|
|
2559
|
-
} else if (_optionalChain([reownWallet, 'optionalAccess',
|
|
2625
|
+
} else if (_optionalChain([reownWallet, 'optionalAccess', _50 => _50.address]) && reownWallet.isConnected && reownWallet.walletClient && reownWallet.publicClient && !seen.has(`evm:${reownWallet.address.toLowerCase()}`)) {
|
|
2560
2626
|
const id = `evm:${reownWallet.address.toLowerCase()}`;
|
|
2561
2627
|
if (!seen.has(id)) {
|
|
2562
2628
|
options.push({
|
|
@@ -2573,19 +2639,19 @@ function DepositFlow({
|
|
|
2573
2639
|
}, [
|
|
2574
2640
|
connectedWalletAddress,
|
|
2575
2641
|
dappAddress,
|
|
2576
|
-
_optionalChain([reownWallet, 'optionalAccess',
|
|
2577
|
-
_optionalChain([reownWallet, 'optionalAccess',
|
|
2578
|
-
_optionalChain([reownWallet, 'optionalAccess',
|
|
2579
|
-
_optionalChain([reownWallet, 'optionalAccess',
|
|
2580
|
-
_optionalChain([reownWallet, 'optionalAccess',
|
|
2581
|
-
_optionalChain([reownWallet, 'optionalAccess',
|
|
2582
|
-
_optionalChain([reownWallet, 'optionalAccess',
|
|
2583
|
-
_optionalChain([reownWallet, 'optionalAccess',
|
|
2642
|
+
_optionalChain([reownWallet, 'optionalAccess', _51 => _51.address]),
|
|
2643
|
+
_optionalChain([reownWallet, 'optionalAccess', _52 => _52.isConnected]),
|
|
2644
|
+
_optionalChain([reownWallet, 'optionalAccess', _53 => _53.walletClient]),
|
|
2645
|
+
_optionalChain([reownWallet, 'optionalAccess', _54 => _54.publicClient]),
|
|
2646
|
+
_optionalChain([reownWallet, 'optionalAccess', _55 => _55.icon]),
|
|
2647
|
+
_optionalChain([reownWallet, 'optionalAccess', _56 => _56.isSolana]),
|
|
2648
|
+
_optionalChain([reownWallet, 'optionalAccess', _57 => _57.solanaAddress]),
|
|
2649
|
+
_optionalChain([reownWallet, 'optionalAccess', _58 => _58.caipAddress])
|
|
2584
2650
|
]);
|
|
2585
|
-
const canAutoLock = _optionalChain([dappWalletClient, 'optionalAccess',
|
|
2651
|
+
const canAutoLock = _optionalChain([dappWalletClient, 'optionalAccess', _59 => _59.account]) && dappAddress && !reownWallet;
|
|
2586
2652
|
const hasWalletOptions = walletOptions.length > 0;
|
|
2587
2653
|
const hasReownSession = Boolean(
|
|
2588
|
-
_optionalChain([reownWallet, 'optionalAccess',
|
|
2654
|
+
_optionalChain([reownWallet, 'optionalAccess', _60 => _60.isConnected]) || _optionalChain([reownWallet, 'optionalAccess', _61 => _61.address])
|
|
2589
2655
|
);
|
|
2590
2656
|
const showConnectStep = flowMode === null && !canAutoLock && !isConnectSelectionConfirmed;
|
|
2591
2657
|
const walletSelectionKey = _react.useMemo.call(void 0, () => {
|
|
@@ -2616,7 +2682,7 @@ function DepositFlow({
|
|
|
2616
2682
|
};
|
|
2617
2683
|
}
|
|
2618
2684
|
if (canAutoLock) {
|
|
2619
|
-
const fallbackChainId = _nullishCoalesce(_optionalChain([dappWalletClient, 'optionalAccess',
|
|
2685
|
+
const fallbackChainId = _nullishCoalesce(_optionalChain([dappWalletClient, 'optionalAccess', _62 => _62.chain, 'optionalAccess', _63 => _63.id]), () => ( targetChain));
|
|
2620
2686
|
return {
|
|
2621
2687
|
ownerAddress: dappWalletClient.account.address,
|
|
2622
2688
|
walletClient: dappWalletClient,
|
|
@@ -2638,8 +2704,8 @@ function DepositFlow({
|
|
|
2638
2704
|
switchChain: void 0
|
|
2639
2705
|
};
|
|
2640
2706
|
}
|
|
2641
|
-
if (selectedOption.kind === "connected" && _optionalChain([dappWalletClient, 'optionalAccess',
|
|
2642
|
-
const fallbackChainId = _nullishCoalesce(_optionalChain([dappWalletClient, 'optionalAccess',
|
|
2707
|
+
if (selectedOption.kind === "connected" && _optionalChain([dappWalletClient, 'optionalAccess', _64 => _64.account]) && selectedOption.address && dappWalletClient.account.address.toLowerCase() === selectedOption.address.toLowerCase()) {
|
|
2708
|
+
const fallbackChainId = _nullishCoalesce(_optionalChain([dappWalletClient, 'optionalAccess', _65 => _65.chain, 'optionalAccess', _66 => _66.id]), () => ( targetChain));
|
|
2643
2709
|
return {
|
|
2644
2710
|
ownerAddress: dappWalletClient.account.address,
|
|
2645
2711
|
walletClient: dappWalletClient,
|
|
@@ -2647,7 +2713,7 @@ function DepositFlow({
|
|
|
2647
2713
|
switchChain: dappSwitchChain
|
|
2648
2714
|
};
|
|
2649
2715
|
}
|
|
2650
|
-
if (selectedOption.kind === "external" && _optionalChain([reownWallet, 'optionalAccess',
|
|
2716
|
+
if (selectedOption.kind === "external" && _optionalChain([reownWallet, 'optionalAccess', _67 => _67.address]) && selectedOption.address && reownWallet.address.toLowerCase() === selectedOption.address.toLowerCase()) {
|
|
2651
2717
|
return {
|
|
2652
2718
|
ownerAddress: reownWallet.address,
|
|
2653
2719
|
walletClient: reownWallet.walletClient,
|
|
@@ -2711,7 +2777,7 @@ function DepositFlow({
|
|
|
2711
2777
|
walletSignerContext,
|
|
2712
2778
|
walletSelectionKey
|
|
2713
2779
|
]);
|
|
2714
|
-
const sessionKeyAddress = _nullishCoalesce(_nullishCoalesce(dappAddress, () => ( _optionalChain([signerContext, 'optionalAccess',
|
|
2780
|
+
const sessionKeyAddress = _nullishCoalesce(_nullishCoalesce(dappAddress, () => ( _optionalChain([signerContext, 'optionalAccess', _68 => _68.ownerAddress]))), () => ( null));
|
|
2715
2781
|
const lastTargetRef = _react.useRef.call(void 0, null);
|
|
2716
2782
|
_react.useEffect.call(void 0, () => {
|
|
2717
2783
|
const prev = lastTargetRef.current;
|
|
@@ -2770,7 +2836,8 @@ function DepositFlow({
|
|
|
2770
2836
|
solanaDepositAddress: prev.solanaDepositAddress,
|
|
2771
2837
|
token: prev.token,
|
|
2772
2838
|
balance: prev.balance,
|
|
2773
|
-
balanceUsd: prev.balanceUsd
|
|
2839
|
+
balanceUsd: prev.balanceUsd,
|
|
2840
|
+
inputAmountUsd: prev.inputAmountUsd
|
|
2774
2841
|
};
|
|
2775
2842
|
});
|
|
2776
2843
|
}, []);
|
|
@@ -2787,7 +2854,7 @@ function DepositFlow({
|
|
|
2787
2854
|
const stepIndex = step.type === "setup" ? 0 : step.type === "deposit-address" ? 1 : step.type === "select-asset" ? 1 : step.type === "solana-token-select" ? 1 : step.type === "solana-amount" ? 2 : step.type === "amount" ? 2 : step.type === "confirm" ? 3 : step.type === "solana-confirm" ? 3 : 4;
|
|
2788
2855
|
const currentBackHandler = step.type === "deposit-address" ? handleBackFromDepositAddress : step.type === "select-asset" && signerContext && !canAutoLock ? handleBackFromSelectAsset : step.type === "solana-token-select" ? handleBackFromSolanaTokenSelect : step.type === "solana-amount" ? handleBackFromSolanaAmount : step.type === "solana-confirm" ? handleBackFromSolanaConfirm : step.type === "amount" ? handleBackFromAmount : step.type === "confirm" ? handleBackFromConfirm : void 0;
|
|
2789
2856
|
_react.useEffect.call(void 0, () => {
|
|
2790
|
-
_optionalChain([onStepChange, 'optionalCall',
|
|
2857
|
+
_optionalChain([onStepChange, 'optionalCall', _69 => _69(stepIndex, currentBackHandler)]);
|
|
2791
2858
|
}, [stepIndex, currentBackHandler, onStepChange]);
|
|
2792
2859
|
_react.useEffect.call(void 0, () => {
|
|
2793
2860
|
logFlow("state:changed", {
|
|
@@ -2806,7 +2873,7 @@ function DepositFlow({
|
|
|
2806
2873
|
targetToken
|
|
2807
2874
|
]);
|
|
2808
2875
|
_react.useEffect.call(void 0, () => {
|
|
2809
|
-
_optionalChain([onTotalBalanceChange, 'optionalCall',
|
|
2876
|
+
_optionalChain([onTotalBalanceChange, 'optionalCall', _70 => _70(totalBalanceUsd)]);
|
|
2810
2877
|
}, [totalBalanceUsd, onTotalBalanceChange]);
|
|
2811
2878
|
const isDepositAddressMode = flowMode === "deposit-address";
|
|
2812
2879
|
const isSolanaWalletMode = flowMode === "solana-wallet";
|
|
@@ -2848,7 +2915,7 @@ function DepositFlow({
|
|
|
2848
2915
|
solanaDepositAddress
|
|
2849
2916
|
});
|
|
2850
2917
|
} else {
|
|
2851
|
-
_optionalChain([onError, 'optionalCall',
|
|
2918
|
+
_optionalChain([onError, 'optionalCall', _71 => _71({
|
|
2852
2919
|
message: "Solana deposit address not available. Please try again.",
|
|
2853
2920
|
code: "SOLANA_SETUP_FAILED"
|
|
2854
2921
|
})]);
|
|
@@ -2883,7 +2950,7 @@ function DepositFlow({
|
|
|
2883
2950
|
directTransfer
|
|
2884
2951
|
};
|
|
2885
2952
|
});
|
|
2886
|
-
_optionalChain([onDepositSubmitted, 'optionalCall',
|
|
2953
|
+
_optionalChain([onDepositSubmitted, 'optionalCall', _72 => _72({ txHash, sourceChain: chainId, amount })]);
|
|
2887
2954
|
},
|
|
2888
2955
|
[onDepositSubmitted, targetChain, targetToken]
|
|
2889
2956
|
);
|
|
@@ -2898,38 +2965,35 @@ function DepositFlow({
|
|
|
2898
2965
|
solanaDepositAddress: prev.solanaDepositAddress,
|
|
2899
2966
|
token,
|
|
2900
2967
|
balance,
|
|
2901
|
-
balanceUsd
|
|
2968
|
+
balanceUsd,
|
|
2969
|
+
inputAmountUsd: defaultAmount
|
|
2902
2970
|
};
|
|
2903
2971
|
});
|
|
2904
2972
|
},
|
|
2905
|
-
[logFlow]
|
|
2973
|
+
[defaultAmount, logFlow]
|
|
2906
2974
|
);
|
|
2907
2975
|
const handleSolanaAmountContinue = _react.useCallback.call(void 0,
|
|
2908
|
-
(token,
|
|
2976
|
+
(token, sourceAmount, inputAmountUsd) => {
|
|
2909
2977
|
const targetSym = _chunkNELAYNA3cjs.getTokenSymbol.call(void 0, targetToken, targetChain);
|
|
2910
2978
|
const isTargetStable = _chunkNELAYNA3cjs.isStablecoinSymbol.call(void 0, targetSym);
|
|
2911
2979
|
const targetTokenPriceUsd = isTargetStable ? 1 : getTokenPriceUsd(targetSym);
|
|
2912
2980
|
logFlow("solana:amount:continue", {
|
|
2913
2981
|
token: token.symbol,
|
|
2914
|
-
|
|
2982
|
+
sourceAmount,
|
|
2983
|
+
inputAmountUsd,
|
|
2915
2984
|
targetSymbol: targetSym,
|
|
2916
2985
|
targetTokenPriceUsd
|
|
2917
2986
|
});
|
|
2918
2987
|
setStep((prev) => {
|
|
2919
2988
|
if (prev.type !== "solana-amount") return prev;
|
|
2920
|
-
const sourceBalance = Number(
|
|
2921
|
-
_viem.formatUnits.call(void 0, prev.balance, prev.token.decimals)
|
|
2922
|
-
);
|
|
2923
|
-
const sourceTokenPriceUsd = Number.isFinite(sourceBalance) && sourceBalance > 0 && prev.balanceUsd > 0 ? prev.balanceUsd / sourceBalance : null;
|
|
2924
|
-
const parsedAmount = Number(amount);
|
|
2925
|
-
const targetAmount = sourceTokenPriceUsd !== null && Number.isFinite(parsedAmount) && parsedAmount > 0 ? (parsedAmount * sourceTokenPriceUsd).toString() : amount;
|
|
2926
2989
|
return {
|
|
2927
2990
|
type: "solana-confirm",
|
|
2928
2991
|
smartAccount: prev.smartAccount,
|
|
2929
2992
|
solanaDepositAddress: prev.solanaDepositAddress,
|
|
2930
2993
|
token,
|
|
2931
|
-
|
|
2932
|
-
|
|
2994
|
+
sourceAmount,
|
|
2995
|
+
inputAmountUsd,
|
|
2996
|
+
targetAmount: inputAmountUsd,
|
|
2933
2997
|
targetTokenPriceUsd,
|
|
2934
2998
|
balance: prev.balance,
|
|
2935
2999
|
balanceUsd: prev.balanceUsd
|
|
@@ -2958,7 +3022,7 @@ function DepositFlow({
|
|
|
2958
3022
|
sourceDecimals: prev.token.decimals
|
|
2959
3023
|
};
|
|
2960
3024
|
});
|
|
2961
|
-
_optionalChain([onDepositSubmitted, 'optionalCall',
|
|
3025
|
+
_optionalChain([onDepositSubmitted, 'optionalCall', _73 => _73({
|
|
2962
3026
|
txHash,
|
|
2963
3027
|
sourceChain: "solana",
|
|
2964
3028
|
amount: amountUnits
|
|
@@ -2968,7 +3032,7 @@ function DepositFlow({
|
|
|
2968
3032
|
);
|
|
2969
3033
|
const handleConnected = _react.useCallback.call(void 0,
|
|
2970
3034
|
(addr, smartAccount) => {
|
|
2971
|
-
_optionalChain([onConnected, 'optionalCall',
|
|
3035
|
+
_optionalChain([onConnected, 'optionalCall', _74 => _74({ address: addr, smartAccount })]);
|
|
2972
3036
|
},
|
|
2973
3037
|
[onConnected]
|
|
2974
3038
|
);
|
|
@@ -3031,28 +3095,28 @@ function DepositFlow({
|
|
|
3031
3095
|
);
|
|
3032
3096
|
const handleDepositSubmittedCallback = _react.useCallback.call(void 0,
|
|
3033
3097
|
(txHash, sourceChain, amount) => {
|
|
3034
|
-
_optionalChain([onDepositSubmitted, 'optionalCall',
|
|
3098
|
+
_optionalChain([onDepositSubmitted, 'optionalCall', _75 => _75({ txHash, sourceChain, amount })]);
|
|
3035
3099
|
},
|
|
3036
3100
|
[onDepositSubmitted]
|
|
3037
3101
|
);
|
|
3038
3102
|
const handleDepositComplete = _react.useCallback.call(void 0,
|
|
3039
3103
|
(txHash, destinationTxHash) => {
|
|
3040
3104
|
logFlow("deposit:complete", { txHash, destinationTxHash });
|
|
3041
|
-
_optionalChain([onDepositComplete, 'optionalCall',
|
|
3105
|
+
_optionalChain([onDepositComplete, 'optionalCall', _76 => _76({ txHash, destinationTxHash })]);
|
|
3042
3106
|
},
|
|
3043
3107
|
[logFlow, onDepositComplete]
|
|
3044
3108
|
);
|
|
3045
3109
|
const handleDepositFailed = _react.useCallback.call(void 0,
|
|
3046
3110
|
(txHash, error) => {
|
|
3047
3111
|
logFlowError("deposit:failed", error, { txHash });
|
|
3048
|
-
_optionalChain([onDepositFailed, 'optionalCall',
|
|
3112
|
+
_optionalChain([onDepositFailed, 'optionalCall', _77 => _77({ txHash, error })]);
|
|
3049
3113
|
},
|
|
3050
3114
|
[logFlowError, onDepositFailed]
|
|
3051
3115
|
);
|
|
3052
3116
|
const handleError = _react.useCallback.call(void 0,
|
|
3053
3117
|
(message, code) => {
|
|
3054
3118
|
logFlowError("flow:error", message, { code });
|
|
3055
|
-
_optionalChain([onError, 'optionalCall',
|
|
3119
|
+
_optionalChain([onError, 'optionalCall', _78 => _78({ message, code })]);
|
|
3056
3120
|
},
|
|
3057
3121
|
[logFlowError, onError]
|
|
3058
3122
|
);
|
|
@@ -3098,7 +3162,7 @@ function DepositFlow({
|
|
|
3098
3162
|
if (walletId) {
|
|
3099
3163
|
const selectedOption = walletOptions.find((o) => o.id === walletId);
|
|
3100
3164
|
setSelectedWalletId(walletId);
|
|
3101
|
-
if (_optionalChain([selectedOption, 'optionalAccess',
|
|
3165
|
+
if (_optionalChain([selectedOption, 'optionalAccess', _79 => _79.kind]) === "solana") {
|
|
3102
3166
|
handleSelectSolanaWallet();
|
|
3103
3167
|
} else {
|
|
3104
3168
|
handleSelectProvider();
|
|
@@ -3145,7 +3209,7 @@ function DepositFlow({
|
|
|
3145
3209
|
const selectedOption = walletOptions.find(
|
|
3146
3210
|
(o) => o.id === selectedWalletIdEffective
|
|
3147
3211
|
);
|
|
3148
|
-
if (_optionalChain([selectedOption, 'optionalAccess',
|
|
3212
|
+
if (_optionalChain([selectedOption, 'optionalAccess', _80 => _80.kind]) === "solana") {
|
|
3149
3213
|
handleSelectSolanaWallet();
|
|
3150
3214
|
} else {
|
|
3151
3215
|
handleSelectProvider();
|
|
@@ -3211,8 +3275,8 @@ function DepositFlow({
|
|
|
3211
3275
|
}
|
|
3212
3276
|
if (isSolanaWalletMode) {
|
|
3213
3277
|
if (!sessionKeyAddress) return null;
|
|
3214
|
-
const solanaAddr = _optionalChain([reownWallet, 'optionalAccess',
|
|
3215
|
-
const solanaProvider = _optionalChain([reownWallet, 'optionalAccess',
|
|
3278
|
+
const solanaAddr = _optionalChain([reownWallet, 'optionalAccess', _81 => _81.solanaAddress]);
|
|
3279
|
+
const solanaProvider = _optionalChain([reownWallet, 'optionalAccess', _82 => _82.solanaProvider]);
|
|
3216
3280
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-modal-body", children: [
|
|
3217
3281
|
step.type === "setup" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3218
3282
|
SetupStep,
|
|
@@ -3246,6 +3310,8 @@ function DepositFlow({
|
|
|
3246
3310
|
token: step.token,
|
|
3247
3311
|
balance: step.balance,
|
|
3248
3312
|
balanceUsd: step.balanceUsd,
|
|
3313
|
+
defaultAmount: step.inputAmountUsd,
|
|
3314
|
+
uiConfig,
|
|
3249
3315
|
onContinue: handleSolanaAmountContinue,
|
|
3250
3316
|
debug
|
|
3251
3317
|
}
|
|
@@ -3257,7 +3323,8 @@ function DepositFlow({
|
|
|
3257
3323
|
solanaAddress: solanaAddr,
|
|
3258
3324
|
solanaDepositAddress: step.solanaDepositAddress,
|
|
3259
3325
|
token: step.token,
|
|
3260
|
-
|
|
3326
|
+
sourceAmount: step.sourceAmount,
|
|
3327
|
+
inputAmountUsd: step.inputAmountUsd,
|
|
3261
3328
|
targetAmount: step.targetAmount,
|
|
3262
3329
|
targetTokenPriceUsd: step.targetTokenPriceUsd,
|
|
3263
3330
|
targetChain,
|
|
@@ -3326,13 +3393,13 @@ function DepositFlow({
|
|
|
3326
3393
|
)
|
|
3327
3394
|
] });
|
|
3328
3395
|
}
|
|
3329
|
-
if (!_optionalChain([signerContext, 'optionalAccess',
|
|
3396
|
+
if (!_optionalChain([signerContext, 'optionalAccess', _83 => _83.walletClient]) || !_optionalChain([signerContext, 'optionalAccess', _84 => _84.publicClient])) {
|
|
3330
3397
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-modal-body", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-state", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-text", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-title", children: "Connecting wallet..." }) }) }) }) });
|
|
3331
3398
|
}
|
|
3332
3399
|
const ownerAddress = signerContext.ownerAddress;
|
|
3333
|
-
const ownerChainId = _nullishCoalesce(_nullishCoalesce(_optionalChain([signerContext, 'access',
|
|
3400
|
+
const ownerChainId = _nullishCoalesce(_nullishCoalesce(_optionalChain([signerContext, 'access', _85 => _85.walletClient, 'optionalAccess', _86 => _86.chain, 'optionalAccess', _87 => _87.id]), () => ( _optionalChain([signerContext, 'access', _88 => _88.publicClient, 'access', _89 => _89.chain, 'optionalAccess', _90 => _90.id]))), () => ( targetChain));
|
|
3334
3401
|
const getReadClientForChain = (chainId) => {
|
|
3335
|
-
if (_optionalChain([signerContext, 'access',
|
|
3402
|
+
if (_optionalChain([signerContext, 'access', _91 => _91.publicClient, 'access', _92 => _92.chain, 'optionalAccess', _93 => _93.id]) === chainId) {
|
|
3336
3403
|
return signerContext.publicClient;
|
|
3337
3404
|
}
|
|
3338
3405
|
return _chunk7HJ7IBRHcjs.getPublicClient.call(void 0, chainId);
|
|
@@ -3432,7 +3499,7 @@ function DepositFlow({
|
|
|
3432
3499
|
// src/DepositModal.tsx
|
|
3433
3500
|
|
|
3434
3501
|
var ReownDepositInner = _react.lazy.call(void 0,
|
|
3435
|
-
() => Promise.resolve().then(() => _interopRequireWildcard(require("./DepositModalReown-
|
|
3502
|
+
() => Promise.resolve().then(() => _interopRequireWildcard(require("./DepositModalReown-AVQEEWEQ.cjs"))).then((m) => ({ default: m.DepositModalReown }))
|
|
3436
3503
|
);
|
|
3437
3504
|
function DepositModal(props) {
|
|
3438
3505
|
const needsReown = !!props.reownAppId;
|
|
@@ -3504,7 +3571,7 @@ function DepositModalInner({
|
|
|
3504
3571
|
_react.useEffect.call(void 0, () => {
|
|
3505
3572
|
if (isOpen && !hasCalledReady.current) {
|
|
3506
3573
|
hasCalledReady.current = true;
|
|
3507
|
-
_optionalChain([onReady, 'optionalCall',
|
|
3574
|
+
_optionalChain([onReady, 'optionalCall', _94 => _94()]);
|
|
3508
3575
|
}
|
|
3509
3576
|
}, [isOpen, onReady]);
|
|
3510
3577
|
_react.useEffect.call(void 0, () => {
|
|
@@ -3523,14 +3590,14 @@ function DepositModalInner({
|
|
|
3523
3590
|
setTotalBalanceUsd(balance2);
|
|
3524
3591
|
}, []);
|
|
3525
3592
|
const handleBack = _react.useCallback.call(void 0, () => {
|
|
3526
|
-
_optionalChain([backHandlerRef, 'access',
|
|
3593
|
+
_optionalChain([backHandlerRef, 'access', _95 => _95.current, 'optionalCall', _96 => _96()]);
|
|
3527
3594
|
}, []);
|
|
3528
|
-
const showLogo = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess',
|
|
3529
|
-
const showStepper = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess',
|
|
3530
|
-
const showBackButton = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess',
|
|
3531
|
-
const balance = _optionalChain([uiConfig, 'optionalAccess',
|
|
3532
|
-
const logoUrl = _nullishCoalesce(_optionalChain([branding, 'optionalAccess',
|
|
3533
|
-
const title = _nullishCoalesce(_optionalChain([branding, 'optionalAccess',
|
|
3595
|
+
const showLogo = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _97 => _97.showLogo]), () => ( false));
|
|
3596
|
+
const showStepper = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _98 => _98.showStepper]), () => ( false));
|
|
3597
|
+
const showBackButton = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _99 => _99.showBackButton]), () => ( true));
|
|
3598
|
+
const balance = _optionalChain([uiConfig, 'optionalAccess', _100 => _100.balance]);
|
|
3599
|
+
const logoUrl = _nullishCoalesce(_optionalChain([branding, 'optionalAccess', _101 => _101.logoUrl]), () => ( "https://github.com/rhinestonewtf.png"));
|
|
3600
|
+
const title = _nullishCoalesce(_optionalChain([branding, 'optionalAccess', _102 => _102.title]), () => ( "Deposit"));
|
|
3534
3601
|
const canGoBack = currentStepIndex > 0 && currentStepIndex < 4 && backHandlerRef.current !== void 0;
|
|
3535
3602
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3536
3603
|
_chunk7HJ7IBRHcjs.Modal,
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
// src/DepositModal.tsx
|
|
47
47
|
import {
|
|
48
48
|
useMemo as useMemo8,
|
|
49
|
-
useEffect as
|
|
49
|
+
useEffect as useEffect10,
|
|
50
50
|
useRef as useRef6,
|
|
51
51
|
useState as useState11,
|
|
52
52
|
useCallback as useCallback4,
|
|
@@ -55,8 +55,7 @@ import {
|
|
|
55
55
|
} from "react";
|
|
56
56
|
|
|
57
57
|
// src/DepositFlow.tsx
|
|
58
|
-
import { useState as useState10, useCallback as useCallback3, useMemo as useMemo7, useEffect as
|
|
59
|
-
import { formatUnits as formatUnits5 } from "viem";
|
|
58
|
+
import { useState as useState10, useCallback as useCallback3, useMemo as useMemo7, useEffect as useEffect9, useRef as useRef5 } from "react";
|
|
60
59
|
|
|
61
60
|
// src/components/steps/SetupStep.tsx
|
|
62
61
|
import { useState, useEffect, useRef, useCallback } from "react";
|
|
@@ -1998,7 +1997,7 @@ function SolanaTokenSelectStep({
|
|
|
1998
1997
|
}
|
|
1999
1998
|
|
|
2000
1999
|
// src/components/steps/SolanaAmountStep.tsx
|
|
2001
|
-
import {
|
|
2000
|
+
import { useEffect as useEffect8, useMemo as useMemo6, useState as useState8 } from "react";
|
|
2002
2001
|
import { formatUnits as formatUnits4, parseUnits as parseUnits3 } from "viem";
|
|
2003
2002
|
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2004
2003
|
var SOL_FEE_RESERVE_LAMPORTS = 1000000n;
|
|
@@ -2006,11 +2005,36 @@ function SolanaAmountStep({
|
|
|
2006
2005
|
token,
|
|
2007
2006
|
balance,
|
|
2008
2007
|
balanceUsd,
|
|
2008
|
+
defaultAmount,
|
|
2009
|
+
uiConfig,
|
|
2009
2010
|
onContinue,
|
|
2010
2011
|
debug
|
|
2011
2012
|
}) {
|
|
2012
2013
|
const [amount, setAmount] = useState8("");
|
|
2013
2014
|
const [error, setError] = useState8(null);
|
|
2015
|
+
const isSourceStablecoin = isStablecoinSymbol(token.symbol);
|
|
2016
|
+
const tokenPriceUsd = useMemo6(() => {
|
|
2017
|
+
if (isSourceStablecoin) return 1;
|
|
2018
|
+
try {
|
|
2019
|
+
const balanceUnits = Number(formatUnits4(balance, token.decimals));
|
|
2020
|
+
if (!Number.isFinite(balanceUnits) || balanceUnits <= 0 || balanceUsd <= 0) {
|
|
2021
|
+
return null;
|
|
2022
|
+
}
|
|
2023
|
+
const price = balanceUsd / balanceUnits;
|
|
2024
|
+
return price > 0 ? price : null;
|
|
2025
|
+
} catch {
|
|
2026
|
+
return null;
|
|
2027
|
+
}
|
|
2028
|
+
}, [isSourceStablecoin, balance, token.decimals, balanceUsd]);
|
|
2029
|
+
const hasPricing = tokenPriceUsd !== null;
|
|
2030
|
+
useEffect8(() => {
|
|
2031
|
+
if (defaultAmount && !amount) {
|
|
2032
|
+
const parsed = Number(defaultAmount);
|
|
2033
|
+
if (Number.isFinite(parsed) && parsed > 0) {
|
|
2034
|
+
setAmount(parsed.toString());
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
}, [defaultAmount, amount]);
|
|
2014
2038
|
const formattedBalance = useMemo6(() => {
|
|
2015
2039
|
try {
|
|
2016
2040
|
const raw = formatUnits4(balance, token.decimals);
|
|
@@ -2021,20 +2045,41 @@ function SolanaAmountStep({
|
|
|
2021
2045
|
return "...";
|
|
2022
2046
|
}
|
|
2023
2047
|
}, [balance, token.decimals]);
|
|
2048
|
+
const computedBalanceUsd = useMemo6(() => {
|
|
2049
|
+
try {
|
|
2050
|
+
const balanceUnits = Number(formatUnits4(balance, token.decimals));
|
|
2051
|
+
if (!Number.isFinite(balanceUnits) || balanceUnits < 0) return null;
|
|
2052
|
+
if (tokenPriceUsd !== null) return balanceUnits * tokenPriceUsd;
|
|
2053
|
+
if (Number.isFinite(balanceUsd) && balanceUsd > 0) return balanceUsd;
|
|
2054
|
+
return null;
|
|
2055
|
+
} catch {
|
|
2056
|
+
return null;
|
|
2057
|
+
}
|
|
2058
|
+
}, [balance, token.decimals, tokenPriceUsd, balanceUsd]);
|
|
2024
2059
|
const formattedBalanceUsd = useMemo6(() => {
|
|
2025
|
-
if (
|
|
2026
|
-
return currencyFormatter.format(
|
|
2027
|
-
}, [
|
|
2060
|
+
if (computedBalanceUsd === null || computedBalanceUsd <= 0) return null;
|
|
2061
|
+
return currencyFormatter.format(computedBalanceUsd);
|
|
2062
|
+
}, [computedBalanceUsd]);
|
|
2028
2063
|
const spendableBalance = useMemo6(() => {
|
|
2029
2064
|
if (!isNativeSol(token)) return balance;
|
|
2030
2065
|
return balance > SOL_FEE_RESERVE_LAMPORTS ? balance - SOL_FEE_RESERVE_LAMPORTS : 0n;
|
|
2031
2066
|
}, [balance, token]);
|
|
2067
|
+
const spendableBalanceUsd = useMemo6(() => {
|
|
2068
|
+
try {
|
|
2069
|
+
const spendableUnits = Number(formatUnits4(spendableBalance, token.decimals));
|
|
2070
|
+
if (!Number.isFinite(spendableUnits) || spendableUnits < 0) return null;
|
|
2071
|
+
if (tokenPriceUsd !== null) return spendableUnits * tokenPriceUsd;
|
|
2072
|
+
return null;
|
|
2073
|
+
} catch {
|
|
2074
|
+
return null;
|
|
2075
|
+
}
|
|
2076
|
+
}, [spendableBalance, token.decimals, tokenPriceUsd]);
|
|
2032
2077
|
const handlePresetClick = (percentage) => {
|
|
2033
2078
|
try {
|
|
2034
2079
|
const spendableUnits = Number(formatUnits4(spendableBalance, token.decimals));
|
|
2035
2080
|
if (!Number.isFinite(spendableUnits) || spendableUnits <= 0) return;
|
|
2036
|
-
const value = spendableUnits * percentage / 100;
|
|
2037
|
-
const maxDecimals =
|
|
2081
|
+
const value = isSourceStablecoin || !hasPricing ? spendableUnits * percentage / 100 : (spendableBalanceUsd ?? 0) * percentage / 100;
|
|
2082
|
+
const maxDecimals = 3;
|
|
2038
2083
|
const factor = 10 ** maxDecimals;
|
|
2039
2084
|
const truncated = Math.floor(value * factor) / factor;
|
|
2040
2085
|
const formatted = truncated.toFixed(maxDecimals).replace(/\.?0+$/, "");
|
|
@@ -2059,12 +2104,30 @@ function SolanaAmountStep({
|
|
|
2059
2104
|
setError("Please enter a valid amount");
|
|
2060
2105
|
return;
|
|
2061
2106
|
}
|
|
2107
|
+
const sourceAmount = isSourceStablecoin || !hasPricing ? numericAmount : numericAmount / tokenPriceUsd;
|
|
2108
|
+
if (hasPricing) {
|
|
2109
|
+
const usdValue = numericAmount;
|
|
2110
|
+
if (uiConfig?.maxDepositUsd && usdValue > uiConfig.maxDepositUsd) {
|
|
2111
|
+
setError(
|
|
2112
|
+
`Maximum deposit is ${currencyFormatter.format(uiConfig.maxDepositUsd)}`
|
|
2113
|
+
);
|
|
2114
|
+
return;
|
|
2115
|
+
}
|
|
2116
|
+
if (uiConfig?.minDepositUsd && usdValue < uiConfig.minDepositUsd) {
|
|
2117
|
+
setError(
|
|
2118
|
+
`Minimum deposit is ${currencyFormatter.format(uiConfig.minDepositUsd)}`
|
|
2119
|
+
);
|
|
2120
|
+
return;
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
const sourceAmountStr = sourceAmount.toString();
|
|
2062
2124
|
let amountInUnits;
|
|
2063
2125
|
try {
|
|
2064
|
-
amountInUnits = parseUnits3(
|
|
2126
|
+
amountInUnits = parseUnits3(sourceAmountStr, token.decimals);
|
|
2065
2127
|
} catch {
|
|
2066
2128
|
debugLog(debug, "solana-amount", "amount:invalid", {
|
|
2067
2129
|
amount,
|
|
2130
|
+
sourceAmount: sourceAmountStr,
|
|
2068
2131
|
reason: "parse-units-failed"
|
|
2069
2132
|
});
|
|
2070
2133
|
setError("Please enter a valid amount");
|
|
@@ -2086,46 +2149,47 @@ function SolanaAmountStep({
|
|
|
2086
2149
|
}
|
|
2087
2150
|
debugLog(debug, "solana-amount", "amount:continue", {
|
|
2088
2151
|
symbol: token.symbol,
|
|
2089
|
-
amount,
|
|
2152
|
+
inputAmountUsd: amount,
|
|
2153
|
+
sourceAmount: sourceAmountStr,
|
|
2090
2154
|
amountInUnits: amountInUnits.toString()
|
|
2091
2155
|
});
|
|
2092
2156
|
setError(null);
|
|
2093
|
-
onContinue(token, amount);
|
|
2157
|
+
onContinue(token, sourceAmountStr, amount);
|
|
2094
2158
|
};
|
|
2095
2159
|
return /* @__PURE__ */ jsxs8("div", { className: "rs-step", children: [
|
|
2096
2160
|
/* @__PURE__ */ jsx8("div", { style: { padding: "12px 12px 4px" }, children: /* @__PURE__ */ jsx8("div", { className: "rs-step-title", children: "Enter amount" }) }),
|
|
2097
2161
|
/* @__PURE__ */ jsxs8("div", { className: "rs-step-body", style: { paddingTop: 0 }, children: [
|
|
2098
2162
|
/* @__PURE__ */ jsxs8("div", { className: "rs-amount-display", children: [
|
|
2099
|
-
/* @__PURE__ */
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2163
|
+
/* @__PURE__ */ jsx8("div", { className: "rs-amount-input-wrapper", children: /* @__PURE__ */ jsx8(
|
|
2164
|
+
"input",
|
|
2165
|
+
{
|
|
2166
|
+
type: "text",
|
|
2167
|
+
inputMode: "decimal",
|
|
2168
|
+
className: "rs-amount-input-large",
|
|
2169
|
+
placeholder: "$0.00",
|
|
2170
|
+
value: amount ? `$${amount}` : "",
|
|
2171
|
+
onChange: (e) => {
|
|
2172
|
+
const raw = e.target.value.replace(/[^0-9.]/g, "");
|
|
2173
|
+
const parts = raw.split(".");
|
|
2174
|
+
if (parts.length > 2) return;
|
|
2175
|
+
setAmount(raw);
|
|
2176
|
+
if (error) setError(null);
|
|
2177
|
+
},
|
|
2178
|
+
autoFocus: true
|
|
2179
|
+
}
|
|
2180
|
+
) }),
|
|
2181
|
+
!isSourceStablecoin && /* @__PURE__ */ jsx8("div", { className: "rs-amount-available", children: /* @__PURE__ */ jsxs8("span", { className: "rs-amount-available-value", children: [
|
|
2182
|
+
formattedBalance,
|
|
2183
|
+
" ",
|
|
2184
|
+
token.symbol,
|
|
2185
|
+
" available",
|
|
2186
|
+
formattedBalanceUsd && /* @__PURE__ */ jsxs8("span", { style: { color: "var(--rs-muted-foreground)" }, children: [
|
|
2123
2187
|
" ",
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
] })
|
|
2188
|
+
"(",
|
|
2189
|
+
formattedBalanceUsd,
|
|
2190
|
+
")"
|
|
2191
|
+
] })
|
|
2192
|
+
] }) })
|
|
2129
2193
|
] }),
|
|
2130
2194
|
/* @__PURE__ */ jsxs8("div", { className: "rs-amount-presets", children: [
|
|
2131
2195
|
[25, 50, 75].map((pct) => /* @__PURE__ */ jsxs8(
|
|
@@ -2195,7 +2259,8 @@ function SolanaConfirmStep({
|
|
|
2195
2259
|
solanaAddress,
|
|
2196
2260
|
solanaDepositAddress,
|
|
2197
2261
|
token,
|
|
2198
|
-
|
|
2262
|
+
sourceAmount,
|
|
2263
|
+
inputAmountUsd,
|
|
2199
2264
|
targetAmount,
|
|
2200
2265
|
targetTokenPriceUsd,
|
|
2201
2266
|
targetChain,
|
|
@@ -2210,7 +2275,7 @@ function SolanaConfirmStep({
|
|
|
2210
2275
|
const [error, setError] = useState9(null);
|
|
2211
2276
|
const targetSymbol = getTokenSymbol(targetToken, targetChain);
|
|
2212
2277
|
const isSameToken = token.symbol.toUpperCase() === targetSymbol.toUpperCase();
|
|
2213
|
-
const formattedAmount =
|
|
2278
|
+
const formattedAmount = sourceAmount && !Number.isNaN(Number(sourceAmount)) ? Number(sourceAmount).toLocaleString("en-US", { maximumFractionDigits: 6 }) : "0";
|
|
2214
2279
|
const formattedReceiveAmount = (() => {
|
|
2215
2280
|
if (isSameToken) return formattedAmount;
|
|
2216
2281
|
const dollarValue = Number(targetAmount);
|
|
@@ -2231,11 +2296,11 @@ function SolanaConfirmStep({
|
|
|
2231
2296
|
setError("Solana wallet not connected");
|
|
2232
2297
|
return;
|
|
2233
2298
|
}
|
|
2234
|
-
const parsedAmount = parseFloat(
|
|
2299
|
+
const parsedAmount = parseFloat(sourceAmount);
|
|
2235
2300
|
if (isNaN(parsedAmount) || parsedAmount <= 0) {
|
|
2236
2301
|
debugLog(debug, "solana-confirm", "submit:blocked", {
|
|
2237
2302
|
reason: "invalid-amount",
|
|
2238
|
-
|
|
2303
|
+
sourceAmount
|
|
2239
2304
|
});
|
|
2240
2305
|
setError("Please enter a valid amount");
|
|
2241
2306
|
return;
|
|
@@ -2247,7 +2312,8 @@ function SolanaConfirmStep({
|
|
|
2247
2312
|
solanaAddress,
|
|
2248
2313
|
solanaDepositAddress,
|
|
2249
2314
|
token: token.symbol,
|
|
2250
|
-
|
|
2315
|
+
sourceAmount,
|
|
2316
|
+
inputAmountUsd
|
|
2251
2317
|
});
|
|
2252
2318
|
try {
|
|
2253
2319
|
const check = await service.checkAccount(smartAccount);
|
|
@@ -2263,10 +2329,10 @@ function SolanaConfirmStep({
|
|
|
2263
2329
|
);
|
|
2264
2330
|
}
|
|
2265
2331
|
const connection = getSolanaConnection();
|
|
2266
|
-
const amountUnits = parseUnits4(
|
|
2332
|
+
const amountUnits = parseUnits4(sourceAmount, token.decimals);
|
|
2267
2333
|
debugLog(debug, "solana-confirm", "tx:build:start", {
|
|
2268
2334
|
token: token.symbol,
|
|
2269
|
-
|
|
2335
|
+
sourceAmount,
|
|
2270
2336
|
amountUnits: amountUnits.toString()
|
|
2271
2337
|
});
|
|
2272
2338
|
const transaction = isNativeSol(token) ? await buildSolTransferTransaction(
|
|
@@ -2303,7 +2369,7 @@ function SolanaConfirmStep({
|
|
|
2303
2369
|
debugError(debug, "solana-confirm", "submit:failure", err, {
|
|
2304
2370
|
smartAccount,
|
|
2305
2371
|
token: token.symbol,
|
|
2306
|
-
|
|
2372
|
+
sourceAmount
|
|
2307
2373
|
});
|
|
2308
2374
|
setError(message);
|
|
2309
2375
|
onError?.(message, "SOLANA_TRANSFER_ERROR");
|
|
@@ -2437,7 +2503,7 @@ function SolanaConfirmStep({
|
|
|
2437
2503
|
{
|
|
2438
2504
|
onClick: handleConfirm,
|
|
2439
2505
|
loading: isSubmitting,
|
|
2440
|
-
disabled: !
|
|
2506
|
+
disabled: !sourceAmount || Number(sourceAmount) <= 0,
|
|
2441
2507
|
fullWidth: true,
|
|
2442
2508
|
children: "Confirm Order"
|
|
2443
2509
|
}
|
|
@@ -2668,7 +2734,7 @@ function DepositFlow({
|
|
|
2668
2734
|
reownWallet,
|
|
2669
2735
|
targetChain
|
|
2670
2736
|
]);
|
|
2671
|
-
|
|
2737
|
+
useEffect9(() => {
|
|
2672
2738
|
if (flowMode !== "wallet") {
|
|
2673
2739
|
stableWalletSelectionKeyRef.current = null;
|
|
2674
2740
|
stableWalletSignerRef.current = null;
|
|
@@ -2713,7 +2779,7 @@ function DepositFlow({
|
|
|
2713
2779
|
]);
|
|
2714
2780
|
const sessionKeyAddress = dappAddress ?? signerContext?.ownerAddress ?? null;
|
|
2715
2781
|
const lastTargetRef = useRef5(null);
|
|
2716
|
-
|
|
2782
|
+
useEffect9(() => {
|
|
2717
2783
|
const prev = lastTargetRef.current;
|
|
2718
2784
|
if (prev && (prev.chain !== targetChain || prev.token.toLowerCase() !== targetToken.toLowerCase())) {
|
|
2719
2785
|
if (step.type !== "processing") {
|
|
@@ -2770,7 +2836,8 @@ function DepositFlow({
|
|
|
2770
2836
|
solanaDepositAddress: prev.solanaDepositAddress,
|
|
2771
2837
|
token: prev.token,
|
|
2772
2838
|
balance: prev.balance,
|
|
2773
|
-
balanceUsd: prev.balanceUsd
|
|
2839
|
+
balanceUsd: prev.balanceUsd,
|
|
2840
|
+
inputAmountUsd: prev.inputAmountUsd
|
|
2774
2841
|
};
|
|
2775
2842
|
});
|
|
2776
2843
|
}, []);
|
|
@@ -2786,10 +2853,10 @@ function DepositFlow({
|
|
|
2786
2853
|
}, []);
|
|
2787
2854
|
const stepIndex = step.type === "setup" ? 0 : step.type === "deposit-address" ? 1 : step.type === "select-asset" ? 1 : step.type === "solana-token-select" ? 1 : step.type === "solana-amount" ? 2 : step.type === "amount" ? 2 : step.type === "confirm" ? 3 : step.type === "solana-confirm" ? 3 : 4;
|
|
2788
2855
|
const currentBackHandler = step.type === "deposit-address" ? handleBackFromDepositAddress : step.type === "select-asset" && signerContext && !canAutoLock ? handleBackFromSelectAsset : step.type === "solana-token-select" ? handleBackFromSolanaTokenSelect : step.type === "solana-amount" ? handleBackFromSolanaAmount : step.type === "solana-confirm" ? handleBackFromSolanaConfirm : step.type === "amount" ? handleBackFromAmount : step.type === "confirm" ? handleBackFromConfirm : void 0;
|
|
2789
|
-
|
|
2856
|
+
useEffect9(() => {
|
|
2790
2857
|
onStepChange?.(stepIndex, currentBackHandler);
|
|
2791
2858
|
}, [stepIndex, currentBackHandler, onStepChange]);
|
|
2792
|
-
|
|
2859
|
+
useEffect9(() => {
|
|
2793
2860
|
logFlow("state:changed", {
|
|
2794
2861
|
step: step.type,
|
|
2795
2862
|
flowMode,
|
|
@@ -2805,7 +2872,7 @@ function DepositFlow({
|
|
|
2805
2872
|
targetChain,
|
|
2806
2873
|
targetToken
|
|
2807
2874
|
]);
|
|
2808
|
-
|
|
2875
|
+
useEffect9(() => {
|
|
2809
2876
|
onTotalBalanceChange?.(totalBalanceUsd);
|
|
2810
2877
|
}, [totalBalanceUsd, onTotalBalanceChange]);
|
|
2811
2878
|
const isDepositAddressMode = flowMode === "deposit-address";
|
|
@@ -2898,38 +2965,35 @@ function DepositFlow({
|
|
|
2898
2965
|
solanaDepositAddress: prev.solanaDepositAddress,
|
|
2899
2966
|
token,
|
|
2900
2967
|
balance,
|
|
2901
|
-
balanceUsd
|
|
2968
|
+
balanceUsd,
|
|
2969
|
+
inputAmountUsd: defaultAmount
|
|
2902
2970
|
};
|
|
2903
2971
|
});
|
|
2904
2972
|
},
|
|
2905
|
-
[logFlow]
|
|
2973
|
+
[defaultAmount, logFlow]
|
|
2906
2974
|
);
|
|
2907
2975
|
const handleSolanaAmountContinue = useCallback3(
|
|
2908
|
-
(token,
|
|
2976
|
+
(token, sourceAmount, inputAmountUsd) => {
|
|
2909
2977
|
const targetSym = getTokenSymbol(targetToken, targetChain);
|
|
2910
2978
|
const isTargetStable = isStablecoinSymbol(targetSym);
|
|
2911
2979
|
const targetTokenPriceUsd = isTargetStable ? 1 : getTokenPriceUsd(targetSym);
|
|
2912
2980
|
logFlow("solana:amount:continue", {
|
|
2913
2981
|
token: token.symbol,
|
|
2914
|
-
|
|
2982
|
+
sourceAmount,
|
|
2983
|
+
inputAmountUsd,
|
|
2915
2984
|
targetSymbol: targetSym,
|
|
2916
2985
|
targetTokenPriceUsd
|
|
2917
2986
|
});
|
|
2918
2987
|
setStep((prev) => {
|
|
2919
2988
|
if (prev.type !== "solana-amount") return prev;
|
|
2920
|
-
const sourceBalance = Number(
|
|
2921
|
-
formatUnits5(prev.balance, prev.token.decimals)
|
|
2922
|
-
);
|
|
2923
|
-
const sourceTokenPriceUsd = Number.isFinite(sourceBalance) && sourceBalance > 0 && prev.balanceUsd > 0 ? prev.balanceUsd / sourceBalance : null;
|
|
2924
|
-
const parsedAmount = Number(amount);
|
|
2925
|
-
const targetAmount = sourceTokenPriceUsd !== null && Number.isFinite(parsedAmount) && parsedAmount > 0 ? (parsedAmount * sourceTokenPriceUsd).toString() : amount;
|
|
2926
2989
|
return {
|
|
2927
2990
|
type: "solana-confirm",
|
|
2928
2991
|
smartAccount: prev.smartAccount,
|
|
2929
2992
|
solanaDepositAddress: prev.solanaDepositAddress,
|
|
2930
2993
|
token,
|
|
2931
|
-
|
|
2932
|
-
|
|
2994
|
+
sourceAmount,
|
|
2995
|
+
inputAmountUsd,
|
|
2996
|
+
targetAmount: inputAmountUsd,
|
|
2933
2997
|
targetTokenPriceUsd,
|
|
2934
2998
|
balance: prev.balance,
|
|
2935
2999
|
balanceUsd: prev.balanceUsd
|
|
@@ -3071,7 +3135,7 @@ function DepositFlow({
|
|
|
3071
3135
|
[walletOptions]
|
|
3072
3136
|
);
|
|
3073
3137
|
const hasNavigatedBackRef = useRef5(false);
|
|
3074
|
-
|
|
3138
|
+
useEffect9(() => {
|
|
3075
3139
|
if (flowModeRef.current) {
|
|
3076
3140
|
return;
|
|
3077
3141
|
}
|
|
@@ -3082,14 +3146,14 @@ function DepositFlow({
|
|
|
3082
3146
|
setStep({ type: "setup" });
|
|
3083
3147
|
}
|
|
3084
3148
|
}, [walletOptionsKey]);
|
|
3085
|
-
|
|
3149
|
+
useEffect9(() => {
|
|
3086
3150
|
if (!showConnectStep && isConnectSelectionConfirmed && flowMode === "wallet" && !signerContext) {
|
|
3087
3151
|
setSelectedWalletId(null);
|
|
3088
3152
|
setIsConnectSelectionConfirmed(false);
|
|
3089
3153
|
setFlowMode(null);
|
|
3090
3154
|
}
|
|
3091
3155
|
}, [showConnectStep, isConnectSelectionConfirmed, flowMode, signerContext]);
|
|
3092
|
-
|
|
3156
|
+
useEffect9(() => {
|
|
3093
3157
|
if (hasNavigatedBackRef.current || isConnectSelectionConfirmed || flowMode) {
|
|
3094
3158
|
return;
|
|
3095
3159
|
}
|
|
@@ -3246,6 +3310,8 @@ function DepositFlow({
|
|
|
3246
3310
|
token: step.token,
|
|
3247
3311
|
balance: step.balance,
|
|
3248
3312
|
balanceUsd: step.balanceUsd,
|
|
3313
|
+
defaultAmount: step.inputAmountUsd,
|
|
3314
|
+
uiConfig,
|
|
3249
3315
|
onContinue: handleSolanaAmountContinue,
|
|
3250
3316
|
debug
|
|
3251
3317
|
}
|
|
@@ -3257,7 +3323,8 @@ function DepositFlow({
|
|
|
3257
3323
|
solanaAddress: solanaAddr,
|
|
3258
3324
|
solanaDepositAddress: step.solanaDepositAddress,
|
|
3259
3325
|
token: step.token,
|
|
3260
|
-
|
|
3326
|
+
sourceAmount: step.sourceAmount,
|
|
3327
|
+
inputAmountUsd: step.inputAmountUsd,
|
|
3261
3328
|
targetAmount: step.targetAmount,
|
|
3262
3329
|
targetTokenPriceUsd: step.targetTokenPriceUsd,
|
|
3263
3330
|
targetChain,
|
|
@@ -3432,7 +3499,7 @@ function DepositFlow({
|
|
|
3432
3499
|
// src/DepositModal.tsx
|
|
3433
3500
|
import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3434
3501
|
var ReownDepositInner = lazy(
|
|
3435
|
-
() => import("./DepositModalReown-
|
|
3502
|
+
() => import("./DepositModalReown-PWD3WK7I.mjs").then((m) => ({ default: m.DepositModalReown }))
|
|
3436
3503
|
);
|
|
3437
3504
|
function DepositModal(props) {
|
|
3438
3505
|
const needsReown = !!props.reownAppId;
|
|
@@ -3492,22 +3559,22 @@ function DepositModalInner({
|
|
|
3492
3559
|
}),
|
|
3493
3560
|
[backendUrl, debug]
|
|
3494
3561
|
);
|
|
3495
|
-
|
|
3562
|
+
useEffect10(() => {
|
|
3496
3563
|
if (isOpen && modalRef.current) {
|
|
3497
3564
|
applyTheme(modalRef.current, theme);
|
|
3498
3565
|
}
|
|
3499
3566
|
}, [isOpen, theme]);
|
|
3500
|
-
|
|
3567
|
+
useEffect10(() => {
|
|
3501
3568
|
configureSolanaRpcUrl(solanaRpcUrl);
|
|
3502
3569
|
}, [solanaRpcUrl]);
|
|
3503
3570
|
const hasCalledReady = useRef6(false);
|
|
3504
|
-
|
|
3571
|
+
useEffect10(() => {
|
|
3505
3572
|
if (isOpen && !hasCalledReady.current) {
|
|
3506
3573
|
hasCalledReady.current = true;
|
|
3507
3574
|
onReady?.();
|
|
3508
3575
|
}
|
|
3509
3576
|
}, [isOpen, onReady]);
|
|
3510
|
-
|
|
3577
|
+
useEffect10(() => {
|
|
3511
3578
|
if (!isOpen) {
|
|
3512
3579
|
setCurrentStepIndex(0);
|
|
3513
3580
|
}
|
package/dist/deposit.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkKOYHFHYWcjs = require('./chunk-KOYHFHYW.cjs');
|
|
4
4
|
require('./chunk-7HJ7IBRH.cjs');
|
|
5
5
|
require('./chunk-NELAYNA3.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
exports.DepositModal =
|
|
8
|
+
exports.DepositModal = _chunkKOYHFHYWcjs.DepositModal;
|
package/dist/deposit.mjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkKOYHFHYWcjs = require('./chunk-KOYHFHYW.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkPW55TOFKcjs = require('./chunk-PW55TOFK.cjs');
|
|
@@ -66,4 +66,4 @@ var _chunkNELAYNA3cjs = require('./chunk-NELAYNA3.cjs');
|
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
exports.CHAIN_BY_ID = _chunkNELAYNA3cjs.CHAIN_BY_ID; exports.DEFAULT_BACKEND_URL = _chunkNELAYNA3cjs.DEFAULT_BACKEND_URL; exports.DEFAULT_SIGNER_ADDRESS = _chunkNELAYNA3cjs.DEFAULT_SIGNER_ADDRESS; exports.DepositModal =
|
|
69
|
+
exports.CHAIN_BY_ID = _chunkNELAYNA3cjs.CHAIN_BY_ID; exports.DEFAULT_BACKEND_URL = _chunkNELAYNA3cjs.DEFAULT_BACKEND_URL; exports.DEFAULT_SIGNER_ADDRESS = _chunkNELAYNA3cjs.DEFAULT_SIGNER_ADDRESS; exports.DepositModal = _chunkKOYHFHYWcjs.DepositModal; exports.NATIVE_TOKEN_ADDRESS = _chunkNELAYNA3cjs.NATIVE_TOKEN_ADDRESS; exports.SOURCE_CHAINS = _chunkNELAYNA3cjs.SOURCE_CHAINS; exports.SUPPORTED_CHAINS = _chunkNELAYNA3cjs.SUPPORTED_CHAINS; exports.WithdrawModal = _chunkPW55TOFKcjs.WithdrawModal; exports.chainRegistry = _chunkNELAYNA3cjs.chainRegistry; exports.findChainIdForToken = _chunkNELAYNA3cjs.findChainIdForToken; exports.getChainBadge = _chunkNELAYNA3cjs.getChainBadge; exports.getChainIcon = _chunkNELAYNA3cjs.getChainIcon; exports.getChainId = _chunkNELAYNA3cjs.getChainId; exports.getChainName = _chunkNELAYNA3cjs.getChainName; exports.getChainObject = _chunkNELAYNA3cjs.getChainObject; exports.getExplorerName = _chunkNELAYNA3cjs.getExplorerName; exports.getExplorerTxUrl = _chunkNELAYNA3cjs.getExplorerTxUrl; exports.getExplorerUrl = _chunkNELAYNA3cjs.getExplorerUrl; exports.getSupportedChainIds = _chunkNELAYNA3cjs.getSupportedChainIds; exports.getSupportedTargetTokens = _chunkNELAYNA3cjs.getSupportedTargetTokens; exports.getSupportedTokenSymbolsForChain = _chunkNELAYNA3cjs.getSupportedTokenSymbolsForChain; exports.getTargetTokenSymbolsForChain = _chunkNELAYNA3cjs.getTargetTokenSymbolsForChain; exports.getTokenAddress = _chunkNELAYNA3cjs.getTokenAddress; exports.getTokenDecimals = _chunkNELAYNA3cjs.getTokenDecimals; exports.getTokenDecimalsByAddress = _chunkNELAYNA3cjs.getTokenDecimalsByAddress; exports.getTokenIcon = _chunkNELAYNA3cjs.getTokenIcon; exports.getTokenSymbol = _chunkNELAYNA3cjs.getTokenSymbol; exports.getUsdcAddress = _chunkNELAYNA3cjs.getUsdcAddress; exports.getUsdcDecimals = _chunkNELAYNA3cjs.getUsdcDecimals; exports.isSupportedTokenAddressForChain = _chunkNELAYNA3cjs.isSupportedTokenAddressForChain;
|
package/dist/index.mjs
CHANGED
package/dist/reown.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkKOYHFHYWcjs = require('./chunk-KOYHFHYW.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkPW55TOFKcjs = require('./chunk-PW55TOFK.cjs');
|
|
@@ -9,4 +9,4 @@ require('./chunk-NELAYNA3.cjs');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
exports.DepositModal =
|
|
12
|
+
exports.DepositModal = _chunkKOYHFHYWcjs.DepositModal; exports.WithdrawModal = _chunkPW55TOFKcjs.WithdrawModal;
|
package/dist/reown.mjs
CHANGED