Display less than for low balances (#485)
* Display less than for short balances. * show 4 decimals places for short value
This commit is contained in:
parent
1221a73a46
commit
2451f817d4
|
@ -58,10 +58,16 @@ const UnitDisplay: React.SFC<EthProps | TokenProps> = params => {
|
||||||
|
|
||||||
if (displayShortBalance) {
|
if (displayShortBalance) {
|
||||||
const digits =
|
const digits =
|
||||||
typeof displayShortBalance === 'number' && displayShortBalance;
|
typeof displayShortBalance === 'number' ? displayShortBalance : 4;
|
||||||
formattedValue = digits
|
formattedValue = format(convertedValue, digits);
|
||||||
? format(convertedValue, digits)
|
// If the formatted value was too low, display something like < 0.01
|
||||||
: format(convertedValue);
|
if (
|
||||||
|
parseFloat(formattedValue) === 0 &&
|
||||||
|
parseFloat(convertedValue) !== 0
|
||||||
|
) {
|
||||||
|
const padding = digits !== 0 ? `.${'0'.repeat(digits - 1)}1` : '';
|
||||||
|
formattedValue = `< 0${padding}`;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
formattedValue = convertedValue;
|
formattedValue = convertedValue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue