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