diff options
author | Dan Finlay <dan@danfinlay.com> | 2016-06-22 04:19:44 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2016-06-22 04:19:44 +0800 |
commit | ab15b4c8259d6f6c5ae9d1e51548d73cfc1c67cb (patch) | |
tree | b1390a02f04b43cf78c880c1dbb4c961fbe12dd6 /ui | |
parent | a08c3bc01b11fbd0e3a243359befbe9fc909edf4 (diff) | |
parent | cfc056e34ba6dda983a1ca6b4bc090661b799d38 (diff) | |
download | tangerine-wallet-browser-ab15b4c8259d6f6c5ae9d1e51548d73cfc1c67cb.tar tangerine-wallet-browser-ab15b4c8259d6f6c5ae9d1e51548d73cfc1c67cb.tar.gz tangerine-wallet-browser-ab15b4c8259d6f6c5ae9d1e51548d73cfc1c67cb.tar.bz2 tangerine-wallet-browser-ab15b4c8259d6f6c5ae9d1e51548d73cfc1c67cb.tar.lz tangerine-wallet-browser-ab15b4c8259d6f6c5ae9d1e51548d73cfc1c67cb.tar.xz tangerine-wallet-browser-ab15b4c8259d6f6c5ae9d1e51548d73cfc1c67cb.tar.zst tangerine-wallet-browser-ab15b4c8259d6f6c5ae9d1e51548d73cfc1c67cb.zip |
Merge branch 'master' of github.com:MetaMask/metamask-plugin into AutoLint
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/util.js | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/ui/app/util.js b/ui/app/util.js index 5252fc9d3..de631dba9 100644 --- a/ui/app/util.js +++ b/ui/app/util.js @@ -84,16 +84,13 @@ function weiToEth (bn) { // Takes hex, returns [beforeDecimal, afterDecimal] function parseBalance (balance) { - if (!balance || balance === '0x0') return ['0', '0'] - var wei = numericBalance(balance).toString(10) - var eth = String(wei / valueTable['wei']) - var beforeDecimal = String(Math.floor(eth)) - var afterDecimal - if (eth.indexOf('.') > -1) { - afterDecimal = eth.slice(eth.indexOf('.') + 1) - } else { - afterDecimal = '0' - } + let beforeDecimal, afterDecimal + let wei = numericBalance(balance).toString() + let trailingZeros = /0+$/ + + beforeDecimal = wei.length > 18 ? wei.slice(0, wei.length - 18) : '0' + afterDecimal = ("000000000000000000" + wei).slice(-18).replace(trailingZeros, "") + if(afterDecimal == ""){afterDecimal = "0" } return [beforeDecimal, afterDecimal] } |