Updated blance display with max decimals (#3266)

This commit is contained in:
Jaco Greeff 2016-11-09 13:16:17 +01:00 committed by Gav Wood
parent b33b237f76
commit b17ce6c9a5
2 changed files with 23 additions and 8 deletions

View File

@ -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;

View File

@ -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 (