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 {
margin: 0 1em 0 0;
margin: 0 0.5em 0 0;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;

View File

@ -44,13 +44,28 @@ class Balance extends Component {
.filter((balance) => new BigNumber(balance.value).gt(0))
.map((balance) => {
const token = balance.token;
const value = token.format
? new BigNumber(balance.value).div(new BigNumber(token.format)).toFormat(3)
: api.util.fromWei(balance.value).toFormat(3);
let value;
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;
if (!imagesrc) {
imagesrc =
images[token.address]
imagesrc = images[token.address]
? `${api.dappsUrl}${images[token.address]}`
: unknownImage;
}