mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Add leading zero to account balances
This commit is contained in:
parent
dac7406ff8
commit
33dc68535d
@ -5,6 +5,8 @@
|
||||
- Corrected text above account list. Selected account is visible to all sites, not just the current domain.
|
||||
- Merged the UI codebase into the main plugin codebase for simpler maintenance.
|
||||
- Fix Ether display rounding error. Now rendering to four decimal points.
|
||||
- Fix some inpage synchronous methods
|
||||
- Change account rendering to show four decimals and a leading zero.
|
||||
|
||||
## 1.5.0 2016-04-13
|
||||
|
||||
|
@ -71,7 +71,7 @@ function formatBalance(balance) {
|
||||
var padded = wei.toString(10)
|
||||
var len = padded.length
|
||||
var nonZeroIndex = padded.match(/[^0]/) && padded.match(/[^0]/).index
|
||||
var beforeDecimal = padded.substr(nonZeroIndex ? nonZeroIndex : 0, len - 18)
|
||||
var beforeDecimal = padded.substr(nonZeroIndex ? nonZeroIndex : 0, len - 18) || '0'
|
||||
var afterDecimal = padded.substr(len - 18, decimalsToKeep)
|
||||
return `${beforeDecimal}.${afterDecimal} ETH`
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ describe('util', function() {
|
||||
it('should return eth as string followed by ETH', function() {
|
||||
var input = new ethUtil.BN(ethInWei, 10).div(new ethUtil.BN('2', 10)).toJSON()
|
||||
var result = util.formatBalance(input)
|
||||
assert.equal(result, '.5000 ETH')
|
||||
assert.equal(result, '0.5000 ETH')
|
||||
})
|
||||
|
||||
it('should display four decimal points', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user