Updated blance display with max decimals (#3266)
This commit is contained in:
parent
b33b237f76
commit
b17ce6c9a5
@ -44,7 +44,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.balanceValue {
|
.balanceValue {
|
||||||
margin: 0 1em 0 0;
|
margin: 0 0.5em 0 0;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
@ -44,15 +44,30 @@ class Balance extends Component {
|
|||||||
.filter((balance) => new BigNumber(balance.value).gt(0))
|
.filter((balance) => new BigNumber(balance.value).gt(0))
|
||||||
.map((balance) => {
|
.map((balance) => {
|
||||||
const token = balance.token;
|
const token = balance.token;
|
||||||
const value = token.format
|
|
||||||
? new BigNumber(balance.value).div(new BigNumber(token.format)).toFormat(3)
|
let value;
|
||||||
: api.util.fromWei(balance.value).toFormat(3);
|
if (token.format) {
|
||||||
|
const bnf = new BigNumber(token.format);
|
||||||
|
|
||||||
|
let decimals = 0;
|
||||||
|
if (bnf.gte(1000)) {
|
||||||
|
decimals = 3;
|
||||||
|
} else if (bnf.gte(100)) {
|
||||||
|
decimals = 2;
|
||||||
|
} else if (bnf.gte(10)) {
|
||||||
|
decimals = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
value = new BigNumber(balance.value).div(bnf).toFormat(decimals);
|
||||||
|
} else {
|
||||||
|
value = api.util.fromWei(balance.value).toFormat(3);
|
||||||
|
}
|
||||||
|
|
||||||
let imagesrc = token.image;
|
let imagesrc = token.image;
|
||||||
if (!imagesrc) {
|
if (!imagesrc) {
|
||||||
imagesrc =
|
imagesrc = images[token.address]
|
||||||
images[token.address]
|
? `${api.dappsUrl}${images[token.address]}`
|
||||||
? `${api.dappsUrl}${images[token.address]}`
|
: unknownImage;
|
||||||
: unknownImage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user