@rhinestone/deposit-modal 0.1.48 → 0.1.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/{DepositModalReown-3V2EFXH5.mjs → DepositModalReown-EKRWDULN.mjs} +17 -6
- package/dist/{DepositModalReown-SV6QIUTL.cjs → DepositModalReown-SUED62QO.cjs} +20 -9
- package/dist/{WithdrawModalReown-FODH7PY5.mjs → WithdrawModalReown-AHHM3VTB.mjs} +2 -2
- package/dist/{WithdrawModalReown-ZSR3RP44.cjs → WithdrawModalReown-JIKBNJU7.cjs} +5 -5
- package/dist/{chunk-PW55TOFK.cjs → chunk-CTZVI5NR.cjs} +1 -1
- package/dist/{chunk-HCZNF6CR.mjs → chunk-GZIGVCI2.mjs} +1 -1
- package/dist/{chunk-ZK6VAHSB.cjs → chunk-HXNHL64V.cjs} +211 -117
- package/dist/{chunk-ZAQISJAP.mjs → chunk-N5BRA3ZN.mjs} +178 -84
- package/dist/{chunk-JGB6XSYS.mjs → chunk-UPA7N6GY.mjs} +11 -12
- package/dist/{chunk-XLRQCIYD.cjs → chunk-XAGXQV4K.cjs} +11 -12
- package/dist/deposit.cjs +2 -2
- package/dist/deposit.d.cts +2 -2
- package/dist/deposit.d.ts +2 -2
- package/dist/deposit.mjs +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/reown.cjs +3 -3
- package/dist/reown.d.cts +1 -1
- package/dist/reown.d.ts +1 -1
- package/dist/reown.mjs +2 -2
- package/dist/{types-dY70pF2y.d.cts → types-C2uBaYtU.d.cts} +1 -0
- package/dist/{types-B0FLVdXb.d.ts → types-Qv3sYfjZ.d.ts} +1 -0
- package/dist/withdraw.cjs +2 -2
- package/dist/withdraw.d.cts +2 -2
- package/dist/withdraw.d.ts +2 -2
- package/dist/withdraw.mjs +1 -1
- package/package.json +1 -1
|
@@ -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";
|
|
@@ -85,6 +84,7 @@ function SetupStep({
|
|
|
85
84
|
sessionChainIds,
|
|
86
85
|
recipient,
|
|
87
86
|
forceRegister,
|
|
87
|
+
enableSolana = true,
|
|
88
88
|
service,
|
|
89
89
|
onSetupComplete,
|
|
90
90
|
onError,
|
|
@@ -115,7 +115,10 @@ function SetupStep({
|
|
|
115
115
|
if (!setup.needsRegistration) {
|
|
116
116
|
setState({ type: "ready", smartAccount });
|
|
117
117
|
onConnected?.(address, smartAccount);
|
|
118
|
-
onSetupComplete(
|
|
118
|
+
onSetupComplete(
|
|
119
|
+
smartAccount,
|
|
120
|
+
enableSolana ? setup.solanaDepositAddress : void 0
|
|
121
|
+
);
|
|
119
122
|
return;
|
|
120
123
|
}
|
|
121
124
|
setState({ type: "signing-session" });
|
|
@@ -151,7 +154,10 @@ function SetupStep({
|
|
|
151
154
|
});
|
|
152
155
|
setState({ type: "ready", smartAccount });
|
|
153
156
|
onConnected?.(address, smartAccount);
|
|
154
|
-
onSetupComplete(
|
|
157
|
+
onSetupComplete(
|
|
158
|
+
smartAccount,
|
|
159
|
+
enableSolana ? registerResult.solanaDepositAddress : void 0
|
|
160
|
+
);
|
|
155
161
|
} catch (error) {
|
|
156
162
|
const message = error instanceof Error ? error.message : "Setup failed";
|
|
157
163
|
setState({ type: "error", message });
|
|
@@ -166,6 +172,7 @@ function SetupStep({
|
|
|
166
172
|
sessionChainIds,
|
|
167
173
|
recipient,
|
|
168
174
|
forceRegister,
|
|
175
|
+
enableSolana,
|
|
169
176
|
service,
|
|
170
177
|
onSetupComplete,
|
|
171
178
|
onError,
|
|
@@ -1998,7 +2005,7 @@ function SolanaTokenSelectStep({
|
|
|
1998
2005
|
}
|
|
1999
2006
|
|
|
2000
2007
|
// src/components/steps/SolanaAmountStep.tsx
|
|
2001
|
-
import {
|
|
2008
|
+
import { useEffect as useEffect8, useMemo as useMemo6, useState as useState8 } from "react";
|
|
2002
2009
|
import { formatUnits as formatUnits4, parseUnits as parseUnits3 } from "viem";
|
|
2003
2010
|
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2004
2011
|
var SOL_FEE_RESERVE_LAMPORTS = 1000000n;
|
|
@@ -2006,11 +2013,36 @@ function SolanaAmountStep({
|
|
|
2006
2013
|
token,
|
|
2007
2014
|
balance,
|
|
2008
2015
|
balanceUsd,
|
|
2016
|
+
defaultAmount,
|
|
2017
|
+
uiConfig,
|
|
2009
2018
|
onContinue,
|
|
2010
2019
|
debug
|
|
2011
2020
|
}) {
|
|
2012
2021
|
const [amount, setAmount] = useState8("");
|
|
2013
2022
|
const [error, setError] = useState8(null);
|
|
2023
|
+
const isSourceStablecoin = isStablecoinSymbol(token.symbol);
|
|
2024
|
+
const tokenPriceUsd = useMemo6(() => {
|
|
2025
|
+
if (isSourceStablecoin) return 1;
|
|
2026
|
+
try {
|
|
2027
|
+
const balanceUnits = Number(formatUnits4(balance, token.decimals));
|
|
2028
|
+
if (!Number.isFinite(balanceUnits) || balanceUnits <= 0 || balanceUsd <= 0) {
|
|
2029
|
+
return null;
|
|
2030
|
+
}
|
|
2031
|
+
const price = balanceUsd / balanceUnits;
|
|
2032
|
+
return price > 0 ? price : null;
|
|
2033
|
+
} catch {
|
|
2034
|
+
return null;
|
|
2035
|
+
}
|
|
2036
|
+
}, [isSourceStablecoin, balance, token.decimals, balanceUsd]);
|
|
2037
|
+
const hasPricing = tokenPriceUsd !== null;
|
|
2038
|
+
useEffect8(() => {
|
|
2039
|
+
if (defaultAmount && !amount) {
|
|
2040
|
+
const parsed = Number(defaultAmount);
|
|
2041
|
+
if (Number.isFinite(parsed) && parsed > 0) {
|
|
2042
|
+
setAmount(parsed.toString());
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
}, [defaultAmount, amount]);
|
|
2014
2046
|
const formattedBalance = useMemo6(() => {
|
|
2015
2047
|
try {
|
|
2016
2048
|
const raw = formatUnits4(balance, token.decimals);
|
|
@@ -2021,20 +2053,41 @@ function SolanaAmountStep({
|
|
|
2021
2053
|
return "...";
|
|
2022
2054
|
}
|
|
2023
2055
|
}, [balance, token.decimals]);
|
|
2056
|
+
const computedBalanceUsd = useMemo6(() => {
|
|
2057
|
+
try {
|
|
2058
|
+
const balanceUnits = Number(formatUnits4(balance, token.decimals));
|
|
2059
|
+
if (!Number.isFinite(balanceUnits) || balanceUnits < 0) return null;
|
|
2060
|
+
if (tokenPriceUsd !== null) return balanceUnits * tokenPriceUsd;
|
|
2061
|
+
if (Number.isFinite(balanceUsd) && balanceUsd > 0) return balanceUsd;
|
|
2062
|
+
return null;
|
|
2063
|
+
} catch {
|
|
2064
|
+
return null;
|
|
2065
|
+
}
|
|
2066
|
+
}, [balance, token.decimals, tokenPriceUsd, balanceUsd]);
|
|
2024
2067
|
const formattedBalanceUsd = useMemo6(() => {
|
|
2025
|
-
if (
|
|
2026
|
-
return currencyFormatter.format(
|
|
2027
|
-
}, [
|
|
2068
|
+
if (computedBalanceUsd === null || computedBalanceUsd <= 0) return null;
|
|
2069
|
+
return currencyFormatter.format(computedBalanceUsd);
|
|
2070
|
+
}, [computedBalanceUsd]);
|
|
2028
2071
|
const spendableBalance = useMemo6(() => {
|
|
2029
2072
|
if (!isNativeSol(token)) return balance;
|
|
2030
2073
|
return balance > SOL_FEE_RESERVE_LAMPORTS ? balance - SOL_FEE_RESERVE_LAMPORTS : 0n;
|
|
2031
2074
|
}, [balance, token]);
|
|
2075
|
+
const spendableBalanceUsd = useMemo6(() => {
|
|
2076
|
+
try {
|
|
2077
|
+
const spendableUnits = Number(formatUnits4(spendableBalance, token.decimals));
|
|
2078
|
+
if (!Number.isFinite(spendableUnits) || spendableUnits < 0) return null;
|
|
2079
|
+
if (tokenPriceUsd !== null) return spendableUnits * tokenPriceUsd;
|
|
2080
|
+
return null;
|
|
2081
|
+
} catch {
|
|
2082
|
+
return null;
|
|
2083
|
+
}
|
|
2084
|
+
}, [spendableBalance, token.decimals, tokenPriceUsd]);
|
|
2032
2085
|
const handlePresetClick = (percentage) => {
|
|
2033
2086
|
try {
|
|
2034
2087
|
const spendableUnits = Number(formatUnits4(spendableBalance, token.decimals));
|
|
2035
2088
|
if (!Number.isFinite(spendableUnits) || spendableUnits <= 0) return;
|
|
2036
|
-
const value = spendableUnits * percentage / 100;
|
|
2037
|
-
const maxDecimals =
|
|
2089
|
+
const value = isSourceStablecoin || !hasPricing ? spendableUnits * percentage / 100 : (spendableBalanceUsd ?? 0) * percentage / 100;
|
|
2090
|
+
const maxDecimals = 3;
|
|
2038
2091
|
const factor = 10 ** maxDecimals;
|
|
2039
2092
|
const truncated = Math.floor(value * factor) / factor;
|
|
2040
2093
|
const formatted = truncated.toFixed(maxDecimals).replace(/\.?0+$/, "");
|
|
@@ -2059,12 +2112,30 @@ function SolanaAmountStep({
|
|
|
2059
2112
|
setError("Please enter a valid amount");
|
|
2060
2113
|
return;
|
|
2061
2114
|
}
|
|
2115
|
+
const sourceAmount = isSourceStablecoin || !hasPricing ? numericAmount : numericAmount / tokenPriceUsd;
|
|
2116
|
+
if (hasPricing) {
|
|
2117
|
+
const usdValue = numericAmount;
|
|
2118
|
+
if (uiConfig?.maxDepositUsd && usdValue > uiConfig.maxDepositUsd) {
|
|
2119
|
+
setError(
|
|
2120
|
+
`Maximum deposit is ${currencyFormatter.format(uiConfig.maxDepositUsd)}`
|
|
2121
|
+
);
|
|
2122
|
+
return;
|
|
2123
|
+
}
|
|
2124
|
+
if (uiConfig?.minDepositUsd && usdValue < uiConfig.minDepositUsd) {
|
|
2125
|
+
setError(
|
|
2126
|
+
`Minimum deposit is ${currencyFormatter.format(uiConfig.minDepositUsd)}`
|
|
2127
|
+
);
|
|
2128
|
+
return;
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
const sourceAmountStr = sourceAmount.toString();
|
|
2062
2132
|
let amountInUnits;
|
|
2063
2133
|
try {
|
|
2064
|
-
amountInUnits = parseUnits3(
|
|
2134
|
+
amountInUnits = parseUnits3(sourceAmountStr, token.decimals);
|
|
2065
2135
|
} catch {
|
|
2066
2136
|
debugLog(debug, "solana-amount", "amount:invalid", {
|
|
2067
2137
|
amount,
|
|
2138
|
+
sourceAmount: sourceAmountStr,
|
|
2068
2139
|
reason: "parse-units-failed"
|
|
2069
2140
|
});
|
|
2070
2141
|
setError("Please enter a valid amount");
|
|
@@ -2086,46 +2157,47 @@ function SolanaAmountStep({
|
|
|
2086
2157
|
}
|
|
2087
2158
|
debugLog(debug, "solana-amount", "amount:continue", {
|
|
2088
2159
|
symbol: token.symbol,
|
|
2089
|
-
amount,
|
|
2160
|
+
inputAmountUsd: amount,
|
|
2161
|
+
sourceAmount: sourceAmountStr,
|
|
2090
2162
|
amountInUnits: amountInUnits.toString()
|
|
2091
2163
|
});
|
|
2092
2164
|
setError(null);
|
|
2093
|
-
onContinue(token, amount);
|
|
2165
|
+
onContinue(token, sourceAmountStr, amount);
|
|
2094
2166
|
};
|
|
2095
2167
|
return /* @__PURE__ */ jsxs8("div", { className: "rs-step", children: [
|
|
2096
2168
|
/* @__PURE__ */ jsx8("div", { style: { padding: "12px 12px 4px" }, children: /* @__PURE__ */ jsx8("div", { className: "rs-step-title", children: "Enter amount" }) }),
|
|
2097
2169
|
/* @__PURE__ */ jsxs8("div", { className: "rs-step-body", style: { paddingTop: 0 }, children: [
|
|
2098
2170
|
/* @__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
|
-
|
|
2171
|
+
/* @__PURE__ */ jsx8("div", { className: "rs-amount-input-wrapper", children: /* @__PURE__ */ jsx8(
|
|
2172
|
+
"input",
|
|
2173
|
+
{
|
|
2174
|
+
type: "text",
|
|
2175
|
+
inputMode: "decimal",
|
|
2176
|
+
className: "rs-amount-input-large",
|
|
2177
|
+
placeholder: "$0.00",
|
|
2178
|
+
value: amount ? `$${amount}` : "",
|
|
2179
|
+
onChange: (e) => {
|
|
2180
|
+
const raw = e.target.value.replace(/[^0-9.]/g, "");
|
|
2181
|
+
const parts = raw.split(".");
|
|
2182
|
+
if (parts.length > 2) return;
|
|
2183
|
+
setAmount(raw);
|
|
2184
|
+
if (error) setError(null);
|
|
2185
|
+
},
|
|
2186
|
+
autoFocus: true
|
|
2187
|
+
}
|
|
2188
|
+
) }),
|
|
2189
|
+
!isSourceStablecoin && /* @__PURE__ */ jsx8("div", { className: "rs-amount-available", children: /* @__PURE__ */ jsxs8("span", { className: "rs-amount-available-value", children: [
|
|
2190
|
+
formattedBalance,
|
|
2191
|
+
" ",
|
|
2192
|
+
token.symbol,
|
|
2193
|
+
" available",
|
|
2194
|
+
formattedBalanceUsd && /* @__PURE__ */ jsxs8("span", { style: { color: "var(--rs-muted-foreground)" }, children: [
|
|
2123
2195
|
" ",
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
] })
|
|
2196
|
+
"(",
|
|
2197
|
+
formattedBalanceUsd,
|
|
2198
|
+
")"
|
|
2199
|
+
] })
|
|
2200
|
+
] }) })
|
|
2129
2201
|
] }),
|
|
2130
2202
|
/* @__PURE__ */ jsxs8("div", { className: "rs-amount-presets", children: [
|
|
2131
2203
|
[25, 50, 75].map((pct) => /* @__PURE__ */ jsxs8(
|
|
@@ -2195,7 +2267,8 @@ function SolanaConfirmStep({
|
|
|
2195
2267
|
solanaAddress,
|
|
2196
2268
|
solanaDepositAddress,
|
|
2197
2269
|
token,
|
|
2198
|
-
|
|
2270
|
+
sourceAmount,
|
|
2271
|
+
inputAmountUsd,
|
|
2199
2272
|
targetAmount,
|
|
2200
2273
|
targetTokenPriceUsd,
|
|
2201
2274
|
targetChain,
|
|
@@ -2210,7 +2283,7 @@ function SolanaConfirmStep({
|
|
|
2210
2283
|
const [error, setError] = useState9(null);
|
|
2211
2284
|
const targetSymbol = getTokenSymbol(targetToken, targetChain);
|
|
2212
2285
|
const isSameToken = token.symbol.toUpperCase() === targetSymbol.toUpperCase();
|
|
2213
|
-
const formattedAmount =
|
|
2286
|
+
const formattedAmount = sourceAmount && !Number.isNaN(Number(sourceAmount)) ? Number(sourceAmount).toLocaleString("en-US", { maximumFractionDigits: 6 }) : "0";
|
|
2214
2287
|
const formattedReceiveAmount = (() => {
|
|
2215
2288
|
if (isSameToken) return formattedAmount;
|
|
2216
2289
|
const dollarValue = Number(targetAmount);
|
|
@@ -2231,11 +2304,11 @@ function SolanaConfirmStep({
|
|
|
2231
2304
|
setError("Solana wallet not connected");
|
|
2232
2305
|
return;
|
|
2233
2306
|
}
|
|
2234
|
-
const parsedAmount = parseFloat(
|
|
2307
|
+
const parsedAmount = parseFloat(sourceAmount);
|
|
2235
2308
|
if (isNaN(parsedAmount) || parsedAmount <= 0) {
|
|
2236
2309
|
debugLog(debug, "solana-confirm", "submit:blocked", {
|
|
2237
2310
|
reason: "invalid-amount",
|
|
2238
|
-
|
|
2311
|
+
sourceAmount
|
|
2239
2312
|
});
|
|
2240
2313
|
setError("Please enter a valid amount");
|
|
2241
2314
|
return;
|
|
@@ -2247,7 +2320,8 @@ function SolanaConfirmStep({
|
|
|
2247
2320
|
solanaAddress,
|
|
2248
2321
|
solanaDepositAddress,
|
|
2249
2322
|
token: token.symbol,
|
|
2250
|
-
|
|
2323
|
+
sourceAmount,
|
|
2324
|
+
inputAmountUsd
|
|
2251
2325
|
});
|
|
2252
2326
|
try {
|
|
2253
2327
|
const check = await service.checkAccount(smartAccount);
|
|
@@ -2263,10 +2337,10 @@ function SolanaConfirmStep({
|
|
|
2263
2337
|
);
|
|
2264
2338
|
}
|
|
2265
2339
|
const connection = getSolanaConnection();
|
|
2266
|
-
const amountUnits = parseUnits4(
|
|
2340
|
+
const amountUnits = parseUnits4(sourceAmount, token.decimals);
|
|
2267
2341
|
debugLog(debug, "solana-confirm", "tx:build:start", {
|
|
2268
2342
|
token: token.symbol,
|
|
2269
|
-
|
|
2343
|
+
sourceAmount,
|
|
2270
2344
|
amountUnits: amountUnits.toString()
|
|
2271
2345
|
});
|
|
2272
2346
|
const transaction = isNativeSol(token) ? await buildSolTransferTransaction(
|
|
@@ -2303,7 +2377,7 @@ function SolanaConfirmStep({
|
|
|
2303
2377
|
debugError(debug, "solana-confirm", "submit:failure", err, {
|
|
2304
2378
|
smartAccount,
|
|
2305
2379
|
token: token.symbol,
|
|
2306
|
-
|
|
2380
|
+
sourceAmount
|
|
2307
2381
|
});
|
|
2308
2382
|
setError(message);
|
|
2309
2383
|
onError?.(message, "SOLANA_TRANSFER_ERROR");
|
|
@@ -2437,7 +2511,7 @@ function SolanaConfirmStep({
|
|
|
2437
2511
|
{
|
|
2438
2512
|
onClick: handleConfirm,
|
|
2439
2513
|
loading: isSubmitting,
|
|
2440
|
-
disabled: !
|
|
2514
|
+
disabled: !sourceAmount || Number(sourceAmount) <= 0,
|
|
2441
2515
|
fullWidth: true,
|
|
2442
2516
|
children: "Confirm Order"
|
|
2443
2517
|
}
|
|
@@ -2469,6 +2543,7 @@ function DepositFlow({
|
|
|
2469
2543
|
sessionChainIds,
|
|
2470
2544
|
forceRegister = false,
|
|
2471
2545
|
waitForFinalTx = true,
|
|
2546
|
+
enableSolana = true,
|
|
2472
2547
|
reownWallet,
|
|
2473
2548
|
onConnect,
|
|
2474
2549
|
onDisconnect,
|
|
@@ -2544,7 +2619,7 @@ function DepositFlow({
|
|
|
2544
2619
|
});
|
|
2545
2620
|
seen.add(id);
|
|
2546
2621
|
}
|
|
2547
|
-
if (reownWallet?.isConnected && reownWallet.isSolana && reownWallet.solanaAddress && dappAddress) {
|
|
2622
|
+
if (enableSolana && reownWallet?.isConnected && reownWallet.isSolana && reownWallet.solanaAddress && dappAddress) {
|
|
2548
2623
|
const id = reownWallet.caipAddress ?? `solana:${reownWallet.solanaAddress}`;
|
|
2549
2624
|
if (!seen.has(id)) {
|
|
2550
2625
|
options.push({
|
|
@@ -2578,6 +2653,7 @@ function DepositFlow({
|
|
|
2578
2653
|
reownWallet?.walletClient,
|
|
2579
2654
|
reownWallet?.publicClient,
|
|
2580
2655
|
reownWallet?.icon,
|
|
2656
|
+
enableSolana,
|
|
2581
2657
|
reownWallet?.isSolana,
|
|
2582
2658
|
reownWallet?.solanaAddress,
|
|
2583
2659
|
reownWallet?.caipAddress
|
|
@@ -2585,7 +2661,7 @@ function DepositFlow({
|
|
|
2585
2661
|
const canAutoLock = dappWalletClient?.account && dappAddress && !reownWallet;
|
|
2586
2662
|
const hasWalletOptions = walletOptions.length > 0;
|
|
2587
2663
|
const hasReownSession = Boolean(
|
|
2588
|
-
reownWallet?.isConnected || reownWallet?.address
|
|
2664
|
+
enableSolana ? reownWallet?.isConnected || reownWallet?.address : reownWallet?.address
|
|
2589
2665
|
);
|
|
2590
2666
|
const showConnectStep = flowMode === null && !canAutoLock && !isConnectSelectionConfirmed;
|
|
2591
2667
|
const walletSelectionKey = useMemo7(() => {
|
|
@@ -2668,7 +2744,7 @@ function DepositFlow({
|
|
|
2668
2744
|
reownWallet,
|
|
2669
2745
|
targetChain
|
|
2670
2746
|
]);
|
|
2671
|
-
|
|
2747
|
+
useEffect9(() => {
|
|
2672
2748
|
if (flowMode !== "wallet") {
|
|
2673
2749
|
stableWalletSelectionKeyRef.current = null;
|
|
2674
2750
|
stableWalletSignerRef.current = null;
|
|
@@ -2713,7 +2789,7 @@ function DepositFlow({
|
|
|
2713
2789
|
]);
|
|
2714
2790
|
const sessionKeyAddress = dappAddress ?? signerContext?.ownerAddress ?? null;
|
|
2715
2791
|
const lastTargetRef = useRef5(null);
|
|
2716
|
-
|
|
2792
|
+
useEffect9(() => {
|
|
2717
2793
|
const prev = lastTargetRef.current;
|
|
2718
2794
|
if (prev && (prev.chain !== targetChain || prev.token.toLowerCase() !== targetToken.toLowerCase())) {
|
|
2719
2795
|
if (step.type !== "processing") {
|
|
@@ -2770,7 +2846,8 @@ function DepositFlow({
|
|
|
2770
2846
|
solanaDepositAddress: prev.solanaDepositAddress,
|
|
2771
2847
|
token: prev.token,
|
|
2772
2848
|
balance: prev.balance,
|
|
2773
|
-
balanceUsd: prev.balanceUsd
|
|
2849
|
+
balanceUsd: prev.balanceUsd,
|
|
2850
|
+
inputAmountUsd: prev.inputAmountUsd
|
|
2774
2851
|
};
|
|
2775
2852
|
});
|
|
2776
2853
|
}, []);
|
|
@@ -2786,10 +2863,10 @@ function DepositFlow({
|
|
|
2786
2863
|
}, []);
|
|
2787
2864
|
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
2865
|
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
|
-
|
|
2866
|
+
useEffect9(() => {
|
|
2790
2867
|
onStepChange?.(stepIndex, currentBackHandler);
|
|
2791
2868
|
}, [stepIndex, currentBackHandler, onStepChange]);
|
|
2792
|
-
|
|
2869
|
+
useEffect9(() => {
|
|
2793
2870
|
logFlow("state:changed", {
|
|
2794
2871
|
step: step.type,
|
|
2795
2872
|
flowMode,
|
|
@@ -2805,7 +2882,7 @@ function DepositFlow({
|
|
|
2805
2882
|
targetChain,
|
|
2806
2883
|
targetToken
|
|
2807
2884
|
]);
|
|
2808
|
-
|
|
2885
|
+
useEffect9(() => {
|
|
2809
2886
|
onTotalBalanceChange?.(totalBalanceUsd);
|
|
2810
2887
|
}, [totalBalanceUsd, onTotalBalanceChange]);
|
|
2811
2888
|
const isDepositAddressMode = flowMode === "deposit-address";
|
|
@@ -2898,38 +2975,35 @@ function DepositFlow({
|
|
|
2898
2975
|
solanaDepositAddress: prev.solanaDepositAddress,
|
|
2899
2976
|
token,
|
|
2900
2977
|
balance,
|
|
2901
|
-
balanceUsd
|
|
2978
|
+
balanceUsd,
|
|
2979
|
+
inputAmountUsd: defaultAmount
|
|
2902
2980
|
};
|
|
2903
2981
|
});
|
|
2904
2982
|
},
|
|
2905
|
-
[logFlow]
|
|
2983
|
+
[defaultAmount, logFlow]
|
|
2906
2984
|
);
|
|
2907
2985
|
const handleSolanaAmountContinue = useCallback3(
|
|
2908
|
-
(token,
|
|
2986
|
+
(token, sourceAmount, inputAmountUsd) => {
|
|
2909
2987
|
const targetSym = getTokenSymbol(targetToken, targetChain);
|
|
2910
2988
|
const isTargetStable = isStablecoinSymbol(targetSym);
|
|
2911
2989
|
const targetTokenPriceUsd = isTargetStable ? 1 : getTokenPriceUsd(targetSym);
|
|
2912
2990
|
logFlow("solana:amount:continue", {
|
|
2913
2991
|
token: token.symbol,
|
|
2914
|
-
|
|
2992
|
+
sourceAmount,
|
|
2993
|
+
inputAmountUsd,
|
|
2915
2994
|
targetSymbol: targetSym,
|
|
2916
2995
|
targetTokenPriceUsd
|
|
2917
2996
|
});
|
|
2918
2997
|
setStep((prev) => {
|
|
2919
2998
|
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
2999
|
return {
|
|
2927
3000
|
type: "solana-confirm",
|
|
2928
3001
|
smartAccount: prev.smartAccount,
|
|
2929
3002
|
solanaDepositAddress: prev.solanaDepositAddress,
|
|
2930
3003
|
token,
|
|
2931
|
-
|
|
2932
|
-
|
|
3004
|
+
sourceAmount,
|
|
3005
|
+
inputAmountUsd,
|
|
3006
|
+
targetAmount: inputAmountUsd,
|
|
2933
3007
|
targetTokenPriceUsd,
|
|
2934
3008
|
balance: prev.balance,
|
|
2935
3009
|
balanceUsd: prev.balanceUsd
|
|
@@ -3071,7 +3145,7 @@ function DepositFlow({
|
|
|
3071
3145
|
[walletOptions]
|
|
3072
3146
|
);
|
|
3073
3147
|
const hasNavigatedBackRef = useRef5(false);
|
|
3074
|
-
|
|
3148
|
+
useEffect9(() => {
|
|
3075
3149
|
if (flowModeRef.current) {
|
|
3076
3150
|
return;
|
|
3077
3151
|
}
|
|
@@ -3082,14 +3156,25 @@ function DepositFlow({
|
|
|
3082
3156
|
setStep({ type: "setup" });
|
|
3083
3157
|
}
|
|
3084
3158
|
}, [walletOptionsKey]);
|
|
3085
|
-
|
|
3159
|
+
useEffect9(() => {
|
|
3086
3160
|
if (!showConnectStep && isConnectSelectionConfirmed && flowMode === "wallet" && !signerContext) {
|
|
3087
3161
|
setSelectedWalletId(null);
|
|
3088
3162
|
setIsConnectSelectionConfirmed(false);
|
|
3089
3163
|
setFlowMode(null);
|
|
3090
3164
|
}
|
|
3091
3165
|
}, [showConnectStep, isConnectSelectionConfirmed, flowMode, signerContext]);
|
|
3092
|
-
|
|
3166
|
+
useEffect9(() => {
|
|
3167
|
+
if (enableSolana || flowMode !== "solana-wallet") {
|
|
3168
|
+
return;
|
|
3169
|
+
}
|
|
3170
|
+
setFlowMode(null);
|
|
3171
|
+
setIsConnectSelectionConfirmed(false);
|
|
3172
|
+
setSelectedWalletId(null);
|
|
3173
|
+
if (step.type !== "processing") {
|
|
3174
|
+
setStep({ type: "setup" });
|
|
3175
|
+
}
|
|
3176
|
+
}, [enableSolana, flowMode, step.type]);
|
|
3177
|
+
useEffect9(() => {
|
|
3093
3178
|
if (hasNavigatedBackRef.current || isConnectSelectionConfirmed || flowMode) {
|
|
3094
3179
|
return;
|
|
3095
3180
|
}
|
|
@@ -3098,7 +3183,7 @@ function DepositFlow({
|
|
|
3098
3183
|
if (walletId) {
|
|
3099
3184
|
const selectedOption = walletOptions.find((o) => o.id === walletId);
|
|
3100
3185
|
setSelectedWalletId(walletId);
|
|
3101
|
-
if (selectedOption?.kind === "solana") {
|
|
3186
|
+
if (enableSolana && selectedOption?.kind === "solana") {
|
|
3102
3187
|
handleSelectSolanaWallet();
|
|
3103
3188
|
} else {
|
|
3104
3189
|
handleSelectProvider();
|
|
@@ -3114,6 +3199,7 @@ function DepositFlow({
|
|
|
3114
3199
|
}, [
|
|
3115
3200
|
hasWalletOptions,
|
|
3116
3201
|
hasReownSession,
|
|
3202
|
+
enableSolana,
|
|
3117
3203
|
isConnectSelectionConfirmed,
|
|
3118
3204
|
flowMode,
|
|
3119
3205
|
selectedWalletIdEffective,
|
|
@@ -3145,7 +3231,7 @@ function DepositFlow({
|
|
|
3145
3231
|
const selectedOption = walletOptions.find(
|
|
3146
3232
|
(o) => o.id === selectedWalletIdEffective
|
|
3147
3233
|
);
|
|
3148
|
-
if (selectedOption?.kind === "solana") {
|
|
3234
|
+
if (enableSolana && selectedOption?.kind === "solana") {
|
|
3149
3235
|
handleSelectSolanaWallet();
|
|
3150
3236
|
} else {
|
|
3151
3237
|
handleSelectProvider();
|
|
@@ -3169,6 +3255,7 @@ function DepositFlow({
|
|
|
3169
3255
|
sessionChainIds,
|
|
3170
3256
|
recipient,
|
|
3171
3257
|
forceRegister,
|
|
3258
|
+
enableSolana,
|
|
3172
3259
|
service,
|
|
3173
3260
|
onSetupComplete: handleSetupComplete,
|
|
3174
3261
|
onConnected: handleConnected,
|
|
@@ -3179,7 +3266,7 @@ function DepositFlow({
|
|
|
3179
3266
|
DepositAddressStep,
|
|
3180
3267
|
{
|
|
3181
3268
|
smartAccount: step.smartAccount,
|
|
3182
|
-
solanaDepositAddress: step.solanaDepositAddress,
|
|
3269
|
+
solanaDepositAddress: enableSolana ? step.solanaDepositAddress : void 0,
|
|
3183
3270
|
service,
|
|
3184
3271
|
onDepositDetected: handleDepositAddressDetected,
|
|
3185
3272
|
onError: handleError
|
|
@@ -3224,6 +3311,7 @@ function DepositFlow({
|
|
|
3224
3311
|
sessionChainIds,
|
|
3225
3312
|
recipient,
|
|
3226
3313
|
forceRegister,
|
|
3314
|
+
enableSolana,
|
|
3227
3315
|
service,
|
|
3228
3316
|
onSetupComplete: handleSetupComplete,
|
|
3229
3317
|
onConnected: handleConnected,
|
|
@@ -3246,6 +3334,8 @@ function DepositFlow({
|
|
|
3246
3334
|
token: step.token,
|
|
3247
3335
|
balance: step.balance,
|
|
3248
3336
|
balanceUsd: step.balanceUsd,
|
|
3337
|
+
defaultAmount: step.inputAmountUsd,
|
|
3338
|
+
uiConfig,
|
|
3249
3339
|
onContinue: handleSolanaAmountContinue,
|
|
3250
3340
|
debug
|
|
3251
3341
|
}
|
|
@@ -3257,7 +3347,8 @@ function DepositFlow({
|
|
|
3257
3347
|
solanaAddress: solanaAddr,
|
|
3258
3348
|
solanaDepositAddress: step.solanaDepositAddress,
|
|
3259
3349
|
token: step.token,
|
|
3260
|
-
|
|
3350
|
+
sourceAmount: step.sourceAmount,
|
|
3351
|
+
inputAmountUsd: step.inputAmountUsd,
|
|
3261
3352
|
targetAmount: step.targetAmount,
|
|
3262
3353
|
targetTokenPriceUsd: step.targetTokenPriceUsd,
|
|
3263
3354
|
targetChain,
|
|
@@ -3349,6 +3440,7 @@ function DepositFlow({
|
|
|
3349
3440
|
sessionChainIds,
|
|
3350
3441
|
recipient,
|
|
3351
3442
|
forceRegister,
|
|
3443
|
+
enableSolana,
|
|
3352
3444
|
service,
|
|
3353
3445
|
onSetupComplete: handleSetupComplete,
|
|
3354
3446
|
onConnected: handleConnected,
|
|
@@ -3432,7 +3524,7 @@ function DepositFlow({
|
|
|
3432
3524
|
// src/DepositModal.tsx
|
|
3433
3525
|
import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3434
3526
|
var ReownDepositInner = lazy(
|
|
3435
|
-
() => import("./DepositModalReown-
|
|
3527
|
+
() => import("./DepositModalReown-EKRWDULN.mjs").then((m) => ({ default: m.DepositModalReown }))
|
|
3436
3528
|
);
|
|
3437
3529
|
function DepositModal(props) {
|
|
3438
3530
|
const needsReown = !!props.reownAppId;
|
|
@@ -3461,6 +3553,7 @@ function DepositModalInner({
|
|
|
3461
3553
|
sessionChainIds,
|
|
3462
3554
|
forceRegister = false,
|
|
3463
3555
|
waitForFinalTx = true,
|
|
3556
|
+
enableSolana = true,
|
|
3464
3557
|
reownWallet,
|
|
3465
3558
|
onConnect,
|
|
3466
3559
|
onDisconnect,
|
|
@@ -3492,22 +3585,22 @@ function DepositModalInner({
|
|
|
3492
3585
|
}),
|
|
3493
3586
|
[backendUrl, debug]
|
|
3494
3587
|
);
|
|
3495
|
-
|
|
3588
|
+
useEffect10(() => {
|
|
3496
3589
|
if (isOpen && modalRef.current) {
|
|
3497
3590
|
applyTheme(modalRef.current, theme);
|
|
3498
3591
|
}
|
|
3499
3592
|
}, [isOpen, theme]);
|
|
3500
|
-
|
|
3593
|
+
useEffect10(() => {
|
|
3501
3594
|
configureSolanaRpcUrl(solanaRpcUrl);
|
|
3502
3595
|
}, [solanaRpcUrl]);
|
|
3503
3596
|
const hasCalledReady = useRef6(false);
|
|
3504
|
-
|
|
3597
|
+
useEffect10(() => {
|
|
3505
3598
|
if (isOpen && !hasCalledReady.current) {
|
|
3506
3599
|
hasCalledReady.current = true;
|
|
3507
3600
|
onReady?.();
|
|
3508
3601
|
}
|
|
3509
3602
|
}, [isOpen, onReady]);
|
|
3510
|
-
|
|
3603
|
+
useEffect10(() => {
|
|
3511
3604
|
if (!isOpen) {
|
|
3512
3605
|
setCurrentStepIndex(0);
|
|
3513
3606
|
}
|
|
@@ -3641,6 +3734,7 @@ function DepositModalInner({
|
|
|
3641
3734
|
sessionChainIds,
|
|
3642
3735
|
forceRegister,
|
|
3643
3736
|
waitForFinalTx,
|
|
3737
|
+
enableSolana,
|
|
3644
3738
|
reownWallet,
|
|
3645
3739
|
onConnect,
|
|
3646
3740
|
onDisconnect,
|
|
@@ -24,12 +24,8 @@ var EVM_NETWORKS = [
|
|
|
24
24
|
polygon,
|
|
25
25
|
bsc
|
|
26
26
|
];
|
|
27
|
-
var ALL_NETWORKS = [
|
|
28
|
-
...EVM_NETWORKS,
|
|
29
|
-
solana
|
|
30
|
-
];
|
|
31
27
|
var cachedAdapter = null;
|
|
32
|
-
var
|
|
28
|
+
var cachedAdapterKey = null;
|
|
33
29
|
function mapTheme(theme) {
|
|
34
30
|
const themeMode = theme?.mode === "light" ? "light" : "dark";
|
|
35
31
|
const themeVariables = {};
|
|
@@ -38,18 +34,20 @@ function mapTheme(theme) {
|
|
|
38
34
|
}
|
|
39
35
|
return { themeMode, themeVariables };
|
|
40
36
|
}
|
|
41
|
-
function getOrCreateAdapter(projectId, theme) {
|
|
42
|
-
|
|
37
|
+
function getOrCreateAdapter(projectId, enableSolana, theme) {
|
|
38
|
+
const adapterKey = `${projectId}:${enableSolana ? "solana" : "evm"}`;
|
|
39
|
+
if (cachedAdapter && cachedAdapterKey === adapterKey) return cachedAdapter;
|
|
43
40
|
cachedAdapter = new WagmiAdapter({
|
|
44
41
|
networks: EVM_NETWORKS,
|
|
45
42
|
projectId
|
|
46
43
|
});
|
|
47
|
-
|
|
48
|
-
const solanaAdapter = new SolanaAdapter();
|
|
44
|
+
cachedAdapterKey = adapterKey;
|
|
49
45
|
const { themeMode, themeVariables } = mapTheme(theme);
|
|
46
|
+
const adapters = enableSolana ? [cachedAdapter, new SolanaAdapter()] : [cachedAdapter];
|
|
47
|
+
const networks = enableSolana ? [...EVM_NETWORKS, solana] : EVM_NETWORKS;
|
|
50
48
|
createAppKit({
|
|
51
|
-
adapters
|
|
52
|
-
networks
|
|
49
|
+
adapters,
|
|
50
|
+
networks,
|
|
53
51
|
projectId,
|
|
54
52
|
themeMode,
|
|
55
53
|
themeVariables,
|
|
@@ -65,10 +63,11 @@ function getOrCreateAdapter(projectId, theme) {
|
|
|
65
63
|
function ReownWalletProvider({
|
|
66
64
|
projectId,
|
|
67
65
|
theme,
|
|
66
|
+
enableSolana = true,
|
|
68
67
|
children
|
|
69
68
|
}) {
|
|
70
69
|
const [queryClient] = useState(() => new QueryClient());
|
|
71
|
-
const adapter = getOrCreateAdapter(projectId, theme);
|
|
70
|
+
const adapter = getOrCreateAdapter(projectId, enableSolana, theme);
|
|
72
71
|
const config = adapter.wagmiConfig;
|
|
73
72
|
return /* @__PURE__ */ jsx(WagmiProvider, { config, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children }) });
|
|
74
73
|
}
|