@rhinestone/deposit-modal 0.1.47 → 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-IUZNTZ3Y.cjs → DepositModalReown-AVQEEWEQ.cjs} +3 -3
- package/dist/{DepositModalReown-DKLN3IE3.mjs → DepositModalReown-PWD3WK7I.mjs} +2 -2
- package/dist/{WithdrawModalReown-XOFREB4D.mjs → WithdrawModalReown-FODH7PY5.mjs} +2 -2
- package/dist/{WithdrawModalReown-FGUHFUVN.cjs → WithdrawModalReown-ZSR3RP44.cjs} +3 -3
- package/dist/{chunk-LT3QKJI2.cjs → chunk-7HJ7IBRH.cjs} +43 -27
- package/dist/{chunk-QIK6ONMQ.mjs → chunk-FKNYONM2.mjs} +43 -27
- package/dist/{chunk-O3VFAUSL.mjs → chunk-HCZNF6CR.mjs} +2 -2
- package/dist/{chunk-LOOU3NCI.cjs → chunk-KOYHFHYW.cjs} +298 -214
- package/dist/{chunk-MS2J6M5C.cjs → chunk-PW55TOFK.cjs} +33 -33
- package/dist/{chunk-7U5TNZZB.mjs → chunk-QLLL6ARN.mjs} +164 -80
- package/dist/deposit.cjs +3 -3
- package/dist/deposit.d.cts +2 -2
- package/dist/deposit.d.ts +2 -2
- package/dist/deposit.mjs +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/reown.cjs +4 -4
- package/dist/reown.d.cts +1 -1
- package/dist/reown.d.ts +1 -1
- package/dist/reown.mjs +3 -3
- package/dist/{types-DQG7NEBI.d.ts → types-B0FLVdXb.d.ts} +6 -1
- package/dist/{types-CyUiKQ4H.d.cts → types-dY70pF2y.d.cts} +6 -1
- package/dist/withdraw.cjs +3 -3
- package/dist/withdraw.d.cts +2 -2
- package/dist/withdraw.d.ts +2 -2
- package/dist/withdraw.mjs +2 -2
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
toEvmCaip2,
|
|
26
26
|
tokenFormatter,
|
|
27
27
|
txRefsMatch
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-FKNYONM2.mjs";
|
|
29
29
|
import {
|
|
30
30
|
DEFAULT_BACKEND_URL,
|
|
31
31
|
DEFAULT_SIGNER_ADDRESS,
|
|
@@ -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";
|
|
@@ -253,6 +252,7 @@ function AssetSelectStep({
|
|
|
253
252
|
publicClient,
|
|
254
253
|
defaultSourceChain,
|
|
255
254
|
defaultSourceToken,
|
|
255
|
+
allowedRoutes,
|
|
256
256
|
service,
|
|
257
257
|
onContinue,
|
|
258
258
|
onTotalBalanceComputed,
|
|
@@ -325,13 +325,25 @@ function AssetSelectStep({
|
|
|
325
325
|
onTotalBalanceComputed?.(total);
|
|
326
326
|
if (assets.length > 0) onAssetsLoaded?.(assets);
|
|
327
327
|
}, [assets, onTotalBalanceComputed, onAssetsLoaded]);
|
|
328
|
+
const allowedChainSet = useMemo(
|
|
329
|
+
() => allowedRoutes?.sourceChains ? new Set(allowedRoutes.sourceChains) : null,
|
|
330
|
+
[allowedRoutes?.sourceChains]
|
|
331
|
+
);
|
|
332
|
+
const allowedTokenSet = useMemo(
|
|
333
|
+
() => allowedRoutes?.sourceTokens ? new Set(allowedRoutes.sourceTokens.map((s) => s.toUpperCase())) : null,
|
|
334
|
+
[allowedRoutes?.sourceTokens]
|
|
335
|
+
);
|
|
328
336
|
const rows = useMemo(() => {
|
|
329
337
|
return assets.filter((a) => {
|
|
330
338
|
try {
|
|
331
|
-
|
|
339
|
+
if (BigInt(a.balance ?? "0") <= BigInt(0)) return false;
|
|
332
340
|
} catch {
|
|
333
341
|
return false;
|
|
334
342
|
}
|
|
343
|
+
if (allowedChainSet && !allowedChainSet.has(a.chainId)) return false;
|
|
344
|
+
if (allowedTokenSet && !allowedTokenSet.has(a.symbol.toUpperCase()))
|
|
345
|
+
return false;
|
|
346
|
+
return true;
|
|
335
347
|
}).sort((a, b) => {
|
|
336
348
|
const usdA = a.balanceUsd ?? 0;
|
|
337
349
|
const usdB = b.balanceUsd ?? 0;
|
|
@@ -342,7 +354,7 @@ function AssetSelectStep({
|
|
|
342
354
|
if (balB < balA) return -1;
|
|
343
355
|
return 0;
|
|
344
356
|
});
|
|
345
|
-
}, [assets]);
|
|
357
|
+
}, [assets, allowedChainSet, allowedTokenSet]);
|
|
346
358
|
const selectedAsset = selectedAssetId && assets.find((asset) => asset.id === selectedAssetId);
|
|
347
359
|
const formatBalance = (asset) => {
|
|
348
360
|
if (!asset.balance) return "--";
|
|
@@ -1985,7 +1997,7 @@ function SolanaTokenSelectStep({
|
|
|
1985
1997
|
}
|
|
1986
1998
|
|
|
1987
1999
|
// src/components/steps/SolanaAmountStep.tsx
|
|
1988
|
-
import {
|
|
2000
|
+
import { useEffect as useEffect8, useMemo as useMemo6, useState as useState8 } from "react";
|
|
1989
2001
|
import { formatUnits as formatUnits4, parseUnits as parseUnits3 } from "viem";
|
|
1990
2002
|
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1991
2003
|
var SOL_FEE_RESERVE_LAMPORTS = 1000000n;
|
|
@@ -1993,11 +2005,36 @@ function SolanaAmountStep({
|
|
|
1993
2005
|
token,
|
|
1994
2006
|
balance,
|
|
1995
2007
|
balanceUsd,
|
|
2008
|
+
defaultAmount,
|
|
2009
|
+
uiConfig,
|
|
1996
2010
|
onContinue,
|
|
1997
2011
|
debug
|
|
1998
2012
|
}) {
|
|
1999
2013
|
const [amount, setAmount] = useState8("");
|
|
2000
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]);
|
|
2001
2038
|
const formattedBalance = useMemo6(() => {
|
|
2002
2039
|
try {
|
|
2003
2040
|
const raw = formatUnits4(balance, token.decimals);
|
|
@@ -2008,20 +2045,41 @@ function SolanaAmountStep({
|
|
|
2008
2045
|
return "...";
|
|
2009
2046
|
}
|
|
2010
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]);
|
|
2011
2059
|
const formattedBalanceUsd = useMemo6(() => {
|
|
2012
|
-
if (
|
|
2013
|
-
return currencyFormatter.format(
|
|
2014
|
-
}, [
|
|
2060
|
+
if (computedBalanceUsd === null || computedBalanceUsd <= 0) return null;
|
|
2061
|
+
return currencyFormatter.format(computedBalanceUsd);
|
|
2062
|
+
}, [computedBalanceUsd]);
|
|
2015
2063
|
const spendableBalance = useMemo6(() => {
|
|
2016
2064
|
if (!isNativeSol(token)) return balance;
|
|
2017
2065
|
return balance > SOL_FEE_RESERVE_LAMPORTS ? balance - SOL_FEE_RESERVE_LAMPORTS : 0n;
|
|
2018
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]);
|
|
2019
2077
|
const handlePresetClick = (percentage) => {
|
|
2020
2078
|
try {
|
|
2021
2079
|
const spendableUnits = Number(formatUnits4(spendableBalance, token.decimals));
|
|
2022
2080
|
if (!Number.isFinite(spendableUnits) || spendableUnits <= 0) return;
|
|
2023
|
-
const value = spendableUnits * percentage / 100;
|
|
2024
|
-
const maxDecimals =
|
|
2081
|
+
const value = isSourceStablecoin || !hasPricing ? spendableUnits * percentage / 100 : (spendableBalanceUsd ?? 0) * percentage / 100;
|
|
2082
|
+
const maxDecimals = 3;
|
|
2025
2083
|
const factor = 10 ** maxDecimals;
|
|
2026
2084
|
const truncated = Math.floor(value * factor) / factor;
|
|
2027
2085
|
const formatted = truncated.toFixed(maxDecimals).replace(/\.?0+$/, "");
|
|
@@ -2046,12 +2104,30 @@ function SolanaAmountStep({
|
|
|
2046
2104
|
setError("Please enter a valid amount");
|
|
2047
2105
|
return;
|
|
2048
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();
|
|
2049
2124
|
let amountInUnits;
|
|
2050
2125
|
try {
|
|
2051
|
-
amountInUnits = parseUnits3(
|
|
2126
|
+
amountInUnits = parseUnits3(sourceAmountStr, token.decimals);
|
|
2052
2127
|
} catch {
|
|
2053
2128
|
debugLog(debug, "solana-amount", "amount:invalid", {
|
|
2054
2129
|
amount,
|
|
2130
|
+
sourceAmount: sourceAmountStr,
|
|
2055
2131
|
reason: "parse-units-failed"
|
|
2056
2132
|
});
|
|
2057
2133
|
setError("Please enter a valid amount");
|
|
@@ -2073,46 +2149,47 @@ function SolanaAmountStep({
|
|
|
2073
2149
|
}
|
|
2074
2150
|
debugLog(debug, "solana-amount", "amount:continue", {
|
|
2075
2151
|
symbol: token.symbol,
|
|
2076
|
-
amount,
|
|
2152
|
+
inputAmountUsd: amount,
|
|
2153
|
+
sourceAmount: sourceAmountStr,
|
|
2077
2154
|
amountInUnits: amountInUnits.toString()
|
|
2078
2155
|
});
|
|
2079
2156
|
setError(null);
|
|
2080
|
-
onContinue(token, amount);
|
|
2157
|
+
onContinue(token, sourceAmountStr, amount);
|
|
2081
2158
|
};
|
|
2082
2159
|
return /* @__PURE__ */ jsxs8("div", { className: "rs-step", children: [
|
|
2083
2160
|
/* @__PURE__ */ jsx8("div", { style: { padding: "12px 12px 4px" }, children: /* @__PURE__ */ jsx8("div", { className: "rs-step-title", children: "Enter amount" }) }),
|
|
2084
2161
|
/* @__PURE__ */ jsxs8("div", { className: "rs-step-body", style: { paddingTop: 0 }, children: [
|
|
2085
2162
|
/* @__PURE__ */ jsxs8("div", { className: "rs-amount-display", children: [
|
|
2086
|
-
/* @__PURE__ */
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
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: [
|
|
2110
2187
|
" ",
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
] })
|
|
2188
|
+
"(",
|
|
2189
|
+
formattedBalanceUsd,
|
|
2190
|
+
")"
|
|
2191
|
+
] })
|
|
2192
|
+
] }) })
|
|
2116
2193
|
] }),
|
|
2117
2194
|
/* @__PURE__ */ jsxs8("div", { className: "rs-amount-presets", children: [
|
|
2118
2195
|
[25, 50, 75].map((pct) => /* @__PURE__ */ jsxs8(
|
|
@@ -2182,7 +2259,8 @@ function SolanaConfirmStep({
|
|
|
2182
2259
|
solanaAddress,
|
|
2183
2260
|
solanaDepositAddress,
|
|
2184
2261
|
token,
|
|
2185
|
-
|
|
2262
|
+
sourceAmount,
|
|
2263
|
+
inputAmountUsd,
|
|
2186
2264
|
targetAmount,
|
|
2187
2265
|
targetTokenPriceUsd,
|
|
2188
2266
|
targetChain,
|
|
@@ -2197,7 +2275,7 @@ function SolanaConfirmStep({
|
|
|
2197
2275
|
const [error, setError] = useState9(null);
|
|
2198
2276
|
const targetSymbol = getTokenSymbol(targetToken, targetChain);
|
|
2199
2277
|
const isSameToken = token.symbol.toUpperCase() === targetSymbol.toUpperCase();
|
|
2200
|
-
const formattedAmount =
|
|
2278
|
+
const formattedAmount = sourceAmount && !Number.isNaN(Number(sourceAmount)) ? Number(sourceAmount).toLocaleString("en-US", { maximumFractionDigits: 6 }) : "0";
|
|
2201
2279
|
const formattedReceiveAmount = (() => {
|
|
2202
2280
|
if (isSameToken) return formattedAmount;
|
|
2203
2281
|
const dollarValue = Number(targetAmount);
|
|
@@ -2218,11 +2296,11 @@ function SolanaConfirmStep({
|
|
|
2218
2296
|
setError("Solana wallet not connected");
|
|
2219
2297
|
return;
|
|
2220
2298
|
}
|
|
2221
|
-
const parsedAmount = parseFloat(
|
|
2299
|
+
const parsedAmount = parseFloat(sourceAmount);
|
|
2222
2300
|
if (isNaN(parsedAmount) || parsedAmount <= 0) {
|
|
2223
2301
|
debugLog(debug, "solana-confirm", "submit:blocked", {
|
|
2224
2302
|
reason: "invalid-amount",
|
|
2225
|
-
|
|
2303
|
+
sourceAmount
|
|
2226
2304
|
});
|
|
2227
2305
|
setError("Please enter a valid amount");
|
|
2228
2306
|
return;
|
|
@@ -2234,7 +2312,8 @@ function SolanaConfirmStep({
|
|
|
2234
2312
|
solanaAddress,
|
|
2235
2313
|
solanaDepositAddress,
|
|
2236
2314
|
token: token.symbol,
|
|
2237
|
-
|
|
2315
|
+
sourceAmount,
|
|
2316
|
+
inputAmountUsd
|
|
2238
2317
|
});
|
|
2239
2318
|
try {
|
|
2240
2319
|
const check = await service.checkAccount(smartAccount);
|
|
@@ -2250,10 +2329,10 @@ function SolanaConfirmStep({
|
|
|
2250
2329
|
);
|
|
2251
2330
|
}
|
|
2252
2331
|
const connection = getSolanaConnection();
|
|
2253
|
-
const amountUnits = parseUnits4(
|
|
2332
|
+
const amountUnits = parseUnits4(sourceAmount, token.decimals);
|
|
2254
2333
|
debugLog(debug, "solana-confirm", "tx:build:start", {
|
|
2255
2334
|
token: token.symbol,
|
|
2256
|
-
|
|
2335
|
+
sourceAmount,
|
|
2257
2336
|
amountUnits: amountUnits.toString()
|
|
2258
2337
|
});
|
|
2259
2338
|
const transaction = isNativeSol(token) ? await buildSolTransferTransaction(
|
|
@@ -2290,7 +2369,7 @@ function SolanaConfirmStep({
|
|
|
2290
2369
|
debugError(debug, "solana-confirm", "submit:failure", err, {
|
|
2291
2370
|
smartAccount,
|
|
2292
2371
|
token: token.symbol,
|
|
2293
|
-
|
|
2372
|
+
sourceAmount
|
|
2294
2373
|
});
|
|
2295
2374
|
setError(message);
|
|
2296
2375
|
onError?.(message, "SOLANA_TRANSFER_ERROR");
|
|
@@ -2424,7 +2503,7 @@ function SolanaConfirmStep({
|
|
|
2424
2503
|
{
|
|
2425
2504
|
onClick: handleConfirm,
|
|
2426
2505
|
loading: isSubmitting,
|
|
2427
|
-
disabled: !
|
|
2506
|
+
disabled: !sourceAmount || Number(sourceAmount) <= 0,
|
|
2428
2507
|
fullWidth: true,
|
|
2429
2508
|
children: "Confirm Order"
|
|
2430
2509
|
}
|
|
@@ -2462,6 +2541,7 @@ function DepositFlow({
|
|
|
2462
2541
|
onRequestConnect,
|
|
2463
2542
|
connectButtonLabel,
|
|
2464
2543
|
uiConfig,
|
|
2544
|
+
allowedRoutes,
|
|
2465
2545
|
onStepChange,
|
|
2466
2546
|
onTotalBalanceChange,
|
|
2467
2547
|
onClose,
|
|
@@ -2654,7 +2734,7 @@ function DepositFlow({
|
|
|
2654
2734
|
reownWallet,
|
|
2655
2735
|
targetChain
|
|
2656
2736
|
]);
|
|
2657
|
-
|
|
2737
|
+
useEffect9(() => {
|
|
2658
2738
|
if (flowMode !== "wallet") {
|
|
2659
2739
|
stableWalletSelectionKeyRef.current = null;
|
|
2660
2740
|
stableWalletSignerRef.current = null;
|
|
@@ -2699,7 +2779,7 @@ function DepositFlow({
|
|
|
2699
2779
|
]);
|
|
2700
2780
|
const sessionKeyAddress = dappAddress ?? signerContext?.ownerAddress ?? null;
|
|
2701
2781
|
const lastTargetRef = useRef5(null);
|
|
2702
|
-
|
|
2782
|
+
useEffect9(() => {
|
|
2703
2783
|
const prev = lastTargetRef.current;
|
|
2704
2784
|
if (prev && (prev.chain !== targetChain || prev.token.toLowerCase() !== targetToken.toLowerCase())) {
|
|
2705
2785
|
if (step.type !== "processing") {
|
|
@@ -2756,7 +2836,8 @@ function DepositFlow({
|
|
|
2756
2836
|
solanaDepositAddress: prev.solanaDepositAddress,
|
|
2757
2837
|
token: prev.token,
|
|
2758
2838
|
balance: prev.balance,
|
|
2759
|
-
balanceUsd: prev.balanceUsd
|
|
2839
|
+
balanceUsd: prev.balanceUsd,
|
|
2840
|
+
inputAmountUsd: prev.inputAmountUsd
|
|
2760
2841
|
};
|
|
2761
2842
|
});
|
|
2762
2843
|
}, []);
|
|
@@ -2772,10 +2853,10 @@ function DepositFlow({
|
|
|
2772
2853
|
}, []);
|
|
2773
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;
|
|
2774
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;
|
|
2775
|
-
|
|
2856
|
+
useEffect9(() => {
|
|
2776
2857
|
onStepChange?.(stepIndex, currentBackHandler);
|
|
2777
2858
|
}, [stepIndex, currentBackHandler, onStepChange]);
|
|
2778
|
-
|
|
2859
|
+
useEffect9(() => {
|
|
2779
2860
|
logFlow("state:changed", {
|
|
2780
2861
|
step: step.type,
|
|
2781
2862
|
flowMode,
|
|
@@ -2791,7 +2872,7 @@ function DepositFlow({
|
|
|
2791
2872
|
targetChain,
|
|
2792
2873
|
targetToken
|
|
2793
2874
|
]);
|
|
2794
|
-
|
|
2875
|
+
useEffect9(() => {
|
|
2795
2876
|
onTotalBalanceChange?.(totalBalanceUsd);
|
|
2796
2877
|
}, [totalBalanceUsd, onTotalBalanceChange]);
|
|
2797
2878
|
const isDepositAddressMode = flowMode === "deposit-address";
|
|
@@ -2884,38 +2965,35 @@ function DepositFlow({
|
|
|
2884
2965
|
solanaDepositAddress: prev.solanaDepositAddress,
|
|
2885
2966
|
token,
|
|
2886
2967
|
balance,
|
|
2887
|
-
balanceUsd
|
|
2968
|
+
balanceUsd,
|
|
2969
|
+
inputAmountUsd: defaultAmount
|
|
2888
2970
|
};
|
|
2889
2971
|
});
|
|
2890
2972
|
},
|
|
2891
|
-
[logFlow]
|
|
2973
|
+
[defaultAmount, logFlow]
|
|
2892
2974
|
);
|
|
2893
2975
|
const handleSolanaAmountContinue = useCallback3(
|
|
2894
|
-
(token,
|
|
2976
|
+
(token, sourceAmount, inputAmountUsd) => {
|
|
2895
2977
|
const targetSym = getTokenSymbol(targetToken, targetChain);
|
|
2896
2978
|
const isTargetStable = isStablecoinSymbol(targetSym);
|
|
2897
2979
|
const targetTokenPriceUsd = isTargetStable ? 1 : getTokenPriceUsd(targetSym);
|
|
2898
2980
|
logFlow("solana:amount:continue", {
|
|
2899
2981
|
token: token.symbol,
|
|
2900
|
-
|
|
2982
|
+
sourceAmount,
|
|
2983
|
+
inputAmountUsd,
|
|
2901
2984
|
targetSymbol: targetSym,
|
|
2902
2985
|
targetTokenPriceUsd
|
|
2903
2986
|
});
|
|
2904
2987
|
setStep((prev) => {
|
|
2905
2988
|
if (prev.type !== "solana-amount") return prev;
|
|
2906
|
-
const sourceBalance = Number(
|
|
2907
|
-
formatUnits5(prev.balance, prev.token.decimals)
|
|
2908
|
-
);
|
|
2909
|
-
const sourceTokenPriceUsd = Number.isFinite(sourceBalance) && sourceBalance > 0 && prev.balanceUsd > 0 ? prev.balanceUsd / sourceBalance : null;
|
|
2910
|
-
const parsedAmount = Number(amount);
|
|
2911
|
-
const targetAmount = sourceTokenPriceUsd !== null && Number.isFinite(parsedAmount) && parsedAmount > 0 ? (parsedAmount * sourceTokenPriceUsd).toString() : amount;
|
|
2912
2989
|
return {
|
|
2913
2990
|
type: "solana-confirm",
|
|
2914
2991
|
smartAccount: prev.smartAccount,
|
|
2915
2992
|
solanaDepositAddress: prev.solanaDepositAddress,
|
|
2916
2993
|
token,
|
|
2917
|
-
|
|
2918
|
-
|
|
2994
|
+
sourceAmount,
|
|
2995
|
+
inputAmountUsd,
|
|
2996
|
+
targetAmount: inputAmountUsd,
|
|
2919
2997
|
targetTokenPriceUsd,
|
|
2920
2998
|
balance: prev.balance,
|
|
2921
2999
|
balanceUsd: prev.balanceUsd
|
|
@@ -3057,7 +3135,7 @@ function DepositFlow({
|
|
|
3057
3135
|
[walletOptions]
|
|
3058
3136
|
);
|
|
3059
3137
|
const hasNavigatedBackRef = useRef5(false);
|
|
3060
|
-
|
|
3138
|
+
useEffect9(() => {
|
|
3061
3139
|
if (flowModeRef.current) {
|
|
3062
3140
|
return;
|
|
3063
3141
|
}
|
|
@@ -3068,14 +3146,14 @@ function DepositFlow({
|
|
|
3068
3146
|
setStep({ type: "setup" });
|
|
3069
3147
|
}
|
|
3070
3148
|
}, [walletOptionsKey]);
|
|
3071
|
-
|
|
3149
|
+
useEffect9(() => {
|
|
3072
3150
|
if (!showConnectStep && isConnectSelectionConfirmed && flowMode === "wallet" && !signerContext) {
|
|
3073
3151
|
setSelectedWalletId(null);
|
|
3074
3152
|
setIsConnectSelectionConfirmed(false);
|
|
3075
3153
|
setFlowMode(null);
|
|
3076
3154
|
}
|
|
3077
3155
|
}, [showConnectStep, isConnectSelectionConfirmed, flowMode, signerContext]);
|
|
3078
|
-
|
|
3156
|
+
useEffect9(() => {
|
|
3079
3157
|
if (hasNavigatedBackRef.current || isConnectSelectionConfirmed || flowMode) {
|
|
3080
3158
|
return;
|
|
3081
3159
|
}
|
|
@@ -3232,6 +3310,8 @@ function DepositFlow({
|
|
|
3232
3310
|
token: step.token,
|
|
3233
3311
|
balance: step.balance,
|
|
3234
3312
|
balanceUsd: step.balanceUsd,
|
|
3313
|
+
defaultAmount: step.inputAmountUsd,
|
|
3314
|
+
uiConfig,
|
|
3235
3315
|
onContinue: handleSolanaAmountContinue,
|
|
3236
3316
|
debug
|
|
3237
3317
|
}
|
|
@@ -3243,7 +3323,8 @@ function DepositFlow({
|
|
|
3243
3323
|
solanaAddress: solanaAddr,
|
|
3244
3324
|
solanaDepositAddress: step.solanaDepositAddress,
|
|
3245
3325
|
token: step.token,
|
|
3246
|
-
|
|
3326
|
+
sourceAmount: step.sourceAmount,
|
|
3327
|
+
inputAmountUsd: step.inputAmountUsd,
|
|
3247
3328
|
targetAmount: step.targetAmount,
|
|
3248
3329
|
targetTokenPriceUsd: step.targetTokenPriceUsd,
|
|
3249
3330
|
targetChain,
|
|
@@ -3348,6 +3429,7 @@ function DepositFlow({
|
|
|
3348
3429
|
publicClient: getReadClientForChain(ownerChainId),
|
|
3349
3430
|
defaultSourceChain,
|
|
3350
3431
|
defaultSourceToken,
|
|
3432
|
+
allowedRoutes,
|
|
3351
3433
|
service,
|
|
3352
3434
|
onContinue: handleAssetContinue,
|
|
3353
3435
|
onTotalBalanceComputed: handleTotalBalanceComputed,
|
|
@@ -3417,7 +3499,7 @@ function DepositFlow({
|
|
|
3417
3499
|
// src/DepositModal.tsx
|
|
3418
3500
|
import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3419
3501
|
var ReownDepositInner = lazy(
|
|
3420
|
-
() => import("./DepositModalReown-
|
|
3502
|
+
() => import("./DepositModalReown-PWD3WK7I.mjs").then((m) => ({ default: m.DepositModalReown }))
|
|
3421
3503
|
);
|
|
3422
3504
|
function DepositModal(props) {
|
|
3423
3505
|
const needsReown = !!props.reownAppId;
|
|
@@ -3454,6 +3536,7 @@ function DepositModalInner({
|
|
|
3454
3536
|
theme,
|
|
3455
3537
|
branding,
|
|
3456
3538
|
uiConfig,
|
|
3539
|
+
allowedRoutes,
|
|
3457
3540
|
className,
|
|
3458
3541
|
onReady,
|
|
3459
3542
|
onConnected,
|
|
@@ -3476,22 +3559,22 @@ function DepositModalInner({
|
|
|
3476
3559
|
}),
|
|
3477
3560
|
[backendUrl, debug]
|
|
3478
3561
|
);
|
|
3479
|
-
|
|
3562
|
+
useEffect10(() => {
|
|
3480
3563
|
if (isOpen && modalRef.current) {
|
|
3481
3564
|
applyTheme(modalRef.current, theme);
|
|
3482
3565
|
}
|
|
3483
3566
|
}, [isOpen, theme]);
|
|
3484
|
-
|
|
3567
|
+
useEffect10(() => {
|
|
3485
3568
|
configureSolanaRpcUrl(solanaRpcUrl);
|
|
3486
3569
|
}, [solanaRpcUrl]);
|
|
3487
3570
|
const hasCalledReady = useRef6(false);
|
|
3488
|
-
|
|
3571
|
+
useEffect10(() => {
|
|
3489
3572
|
if (isOpen && !hasCalledReady.current) {
|
|
3490
3573
|
hasCalledReady.current = true;
|
|
3491
3574
|
onReady?.();
|
|
3492
3575
|
}
|
|
3493
3576
|
}, [isOpen, onReady]);
|
|
3494
|
-
|
|
3577
|
+
useEffect10(() => {
|
|
3495
3578
|
if (!isOpen) {
|
|
3496
3579
|
setCurrentStepIndex(0);
|
|
3497
3580
|
}
|
|
@@ -3631,6 +3714,7 @@ function DepositModalInner({
|
|
|
3631
3714
|
onRequestConnect,
|
|
3632
3715
|
connectButtonLabel,
|
|
3633
3716
|
uiConfig,
|
|
3717
|
+
allowedRoutes,
|
|
3634
3718
|
onStepChange: handleStepChange,
|
|
3635
3719
|
onTotalBalanceChange: handleTotalBalanceChange,
|
|
3636
3720
|
onClose,
|
package/dist/deposit.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var _chunkKOYHFHYWcjs = require('./chunk-KOYHFHYW.cjs');
|
|
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.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { d as DepositModalProps } from './types-
|
|
3
|
-
export { A as AssetOption, a as ConnectedEventData, D as DepositCompleteEventData, b as DepositFailedEventData, c as DepositModalBranding, e as DepositModalTheme, f as DepositModalUIConfig, g as DepositSubmittedEventData, E as ErrorEventData } from './types-
|
|
2
|
+
import { d as DepositModalProps } from './types-dY70pF2y.cjs';
|
|
3
|
+
export { A as AssetOption, a as ConnectedEventData, D as DepositCompleteEventData, b as DepositFailedEventData, c as DepositModalBranding, e as DepositModalTheme, f as DepositModalUIConfig, g as DepositSubmittedEventData, E as ErrorEventData } from './types-dY70pF2y.cjs';
|
|
4
4
|
import 'viem';
|
|
5
5
|
import './safe.cjs';
|
|
6
6
|
|
package/dist/deposit.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { d as DepositModalProps } from './types-
|
|
3
|
-
export { A as AssetOption, a as ConnectedEventData, D as DepositCompleteEventData, b as DepositFailedEventData, c as DepositModalBranding, e as DepositModalTheme, f as DepositModalUIConfig, g as DepositSubmittedEventData, E as ErrorEventData } from './types-
|
|
2
|
+
import { d as DepositModalProps } from './types-B0FLVdXb.js';
|
|
3
|
+
export { A as AssetOption, a as ConnectedEventData, D as DepositCompleteEventData, b as DepositFailedEventData, c as DepositModalBranding, e as DepositModalTheme, f as DepositModalUIConfig, g as DepositSubmittedEventData, E as ErrorEventData } from './types-B0FLVdXb.js';
|
|
4
4
|
import 'viem';
|
|
5
5
|
import './safe.js';
|
|
6
6
|
|
package/dist/deposit.mjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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
|
-
var
|
|
7
|
-
require('./chunk-
|
|
6
|
+
var _chunkPW55TOFKcjs = require('./chunk-PW55TOFK.cjs');
|
|
7
|
+
require('./chunk-7HJ7IBRH.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -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.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { DepositModal } from './deposit.cjs';
|
|
2
2
|
export { WithdrawModal } from './withdraw.cjs';
|
|
3
|
-
export { A as AssetOption, C as ChainId, a as ConnectedEventData, D as DepositCompleteEventData, b as DepositFailedEventData, c as DepositModalBranding, d as DepositModalProps, e as DepositModalTheme, f as DepositModalUIConfig, g as DepositSubmittedEventData, E as ErrorEventData, W as WithdrawCompleteEventData, h as WithdrawFailedEventData, i as WithdrawModalProps, j as WithdrawSubmittedEventData } from './types-
|
|
3
|
+
export { A as AssetOption, C as ChainId, a as ConnectedEventData, D as DepositCompleteEventData, b as DepositFailedEventData, c as DepositModalBranding, d as DepositModalProps, e as DepositModalTheme, f as DepositModalUIConfig, g as DepositSubmittedEventData, E as ErrorEventData, R as RouteConfig, W as WithdrawCompleteEventData, h as WithdrawFailedEventData, i as WithdrawModalProps, j as WithdrawSubmittedEventData } from './types-dY70pF2y.cjs';
|
|
4
4
|
export { CHAIN_BY_ID, DEFAULT_BACKEND_URL, DEFAULT_SIGNER_ADDRESS, NATIVE_TOKEN_ADDRESS, SOURCE_CHAINS, SUPPORTED_CHAINS, chainRegistry, findChainIdForToken, getChainBadge, getChainIcon, getChainId, getChainName, getChainObject, getExplorerName, getExplorerTxUrl, getExplorerUrl, getSupportedChainIds, getSupportedTargetTokens, getSupportedTokenSymbolsForChain, getTargetTokenSymbolsForChain, getTokenAddress, getTokenDecimals, getTokenDecimalsByAddress, getTokenIcon, getTokenSymbol, getUsdcAddress, getUsdcDecimals, isSupportedTokenAddressForChain } from './constants.cjs';
|
|
5
5
|
export { SafeTransactionRequest } from './safe.cjs';
|
|
6
6
|
import 'react/jsx-runtime';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { DepositModal } from './deposit.js';
|
|
2
2
|
export { WithdrawModal } from './withdraw.js';
|
|
3
|
-
export { A as AssetOption, C as ChainId, a as ConnectedEventData, D as DepositCompleteEventData, b as DepositFailedEventData, c as DepositModalBranding, d as DepositModalProps, e as DepositModalTheme, f as DepositModalUIConfig, g as DepositSubmittedEventData, E as ErrorEventData, W as WithdrawCompleteEventData, h as WithdrawFailedEventData, i as WithdrawModalProps, j as WithdrawSubmittedEventData } from './types-
|
|
3
|
+
export { A as AssetOption, C as ChainId, a as ConnectedEventData, D as DepositCompleteEventData, b as DepositFailedEventData, c as DepositModalBranding, d as DepositModalProps, e as DepositModalTheme, f as DepositModalUIConfig, g as DepositSubmittedEventData, E as ErrorEventData, R as RouteConfig, W as WithdrawCompleteEventData, h as WithdrawFailedEventData, i as WithdrawModalProps, j as WithdrawSubmittedEventData } from './types-B0FLVdXb.js';
|
|
4
4
|
export { CHAIN_BY_ID, DEFAULT_BACKEND_URL, DEFAULT_SIGNER_ADDRESS, NATIVE_TOKEN_ADDRESS, SOURCE_CHAINS, SUPPORTED_CHAINS, chainRegistry, findChainIdForToken, getChainBadge, getChainIcon, getChainId, getChainName, getChainObject, getExplorerName, getExplorerTxUrl, getExplorerUrl, getSupportedChainIds, getSupportedTargetTokens, getSupportedTokenSymbolsForChain, getTargetTokenSymbolsForChain, getTokenAddress, getTokenDecimals, getTokenDecimalsByAddress, getTokenIcon, getTokenSymbol, getUsdcAddress, getUsdcDecimals, isSupportedTokenAddressForChain } from './constants.js';
|
|
5
5
|
export { SafeTransactionRequest } from './safe.js';
|
|
6
6
|
import 'react/jsx-runtime';
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DepositModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QLLL6ARN.mjs";
|
|
4
4
|
import {
|
|
5
5
|
WithdrawModal
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-HCZNF6CR.mjs";
|
|
7
|
+
import "./chunk-FKNYONM2.mjs";
|
|
8
8
|
import {
|
|
9
9
|
CHAIN_BY_ID,
|
|
10
10
|
DEFAULT_BACKEND_URL,
|