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) {
|
||||
const digits =
|
||||
typeof displayShortBalance === 'number' && displayShortBalance;
|
||||
formattedValue = digits
|
||||
? format(convertedValue, digits)
|
||||
: format(convertedValue);
|
||||
typeof displayShortBalance === 'number' ? displayShortBalance : 4;
|
||||
formattedValue = format(convertedValue, digits);
|
||||
// If the formatted value was too low, display something like < 0.01
|
||||
if (
|
||||
parseFloat(formattedValue) === 0 &&
|
||||
parseFloat(convertedValue) !== 0
|
||||
) {
|
||||
const padding = digits !== 0 ? `.${'0'.repeat(digits - 1)}1` : '';
|
||||
formattedValue = `< 0${padding}`;
|
||||
}
|
||||
} else {
|
||||
formattedValue = convertedValue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue