fix
This commit is contained in:
@@ -14,6 +14,9 @@ export interface SendModalToken {
|
||||
/** Network this balance row belongs to. Tickers repeat across chains
|
||||
* (USDT on ETH/SOL/TRX/…), so the "Макс" lookup must match on it too. */
|
||||
chain?: Chain
|
||||
/** Token decimals (from the balance endpoint), used to convert the human
|
||||
* send amount into base units before submitting. */
|
||||
decimals?: number
|
||||
}
|
||||
|
||||
interface Props {
|
||||
@@ -83,6 +86,11 @@ export function SendModal({ open, onClose, network, tokens = [], initialToken =
|
||||
}
|
||||
const maxAmount = maxSendable()
|
||||
|
||||
// Decimals used to scale the human amount into base units before sending.
|
||||
// Native comes from chain config; tokens carry their own decimals from the
|
||||
// balance row. Undefined ⇒ we can't safely convert, so the send is blocked.
|
||||
const sendDecimals = isNative ? cfg.nativeDecimals : walletMatch?.decimals
|
||||
|
||||
useEffect(() => { setSelectedToken(initialToken) }, [initialToken])
|
||||
useEffect(() => { setSelectedToken('') }, [network])
|
||||
|
||||
@@ -115,7 +123,8 @@ export function SendModal({ open, onClose, network, tokens = [], initialToken =
|
||||
}
|
||||
|
||||
function handleSubmit() {
|
||||
const convertedAmount = isNative ? toBaseUnits(amount, cfg.nativeDecimals) : amount
|
||||
if (sendDecimals == null) return
|
||||
const convertedAmount = toBaseUnits(amount, sendDecimals)
|
||||
mutation.mutate({
|
||||
chain: network,
|
||||
to: address,
|
||||
@@ -300,7 +309,7 @@ export function SendModal({ open, onClose, network, tokens = [], initialToken =
|
||||
<button
|
||||
className={styles.submitBtn}
|
||||
type="button"
|
||||
disabled={mutation.isPending}
|
||||
disabled={mutation.isPending || sendDecimals == null}
|
||||
onClick={handleSubmit}
|
||||
>
|
||||
{mutation.isPending ? 'Отправка…' : 'Отправить'}
|
||||
|
||||
@@ -17,6 +17,9 @@ export interface Token {
|
||||
chain?: Chain
|
||||
/** Numeric USD value of the holding — used for sorting and per-network subtotals. */
|
||||
usdValue?: number
|
||||
/** Token decimals from the balance endpoint — used to convert a human send
|
||||
* amount into base units. Absent for the static placeholder catalog. */
|
||||
decimals?: number
|
||||
}
|
||||
|
||||
export const TOKENS: readonly Token[] = [
|
||||
|
||||
@@ -55,6 +55,7 @@ function nativeRowFor(chain: Chain, native: FormattedAmount): Token {
|
||||
bal: truncateDecimals(native.formatted),
|
||||
usd: formatUsd(native.usdValue),
|
||||
usdValue: native.usdValue,
|
||||
decimals: native.decimals,
|
||||
fav: false,
|
||||
}
|
||||
}
|
||||
@@ -73,6 +74,7 @@ function tokenRowFor(chain: Chain, symbol: string, amount: FormattedAmount): Tok
|
||||
bal: truncateDecimals(amount.formatted),
|
||||
usd: formatUsd(amount.usdValue),
|
||||
usdValue: amount.usdValue,
|
||||
decimals: amount.decimals,
|
||||
fav: false,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user