1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Merge pull request #112 from MetaMask/AddLeadingZero

ui - formatBalance bug
This commit is contained in:
Dan Finlay 2016-04-15 09:58:51 -07:00
commit 382cca4a8e
3 changed files with 4 additions and 2 deletions

View File

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

View File

@ -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`
}

View File

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