aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-06-22 04:19:44 +0800
committerDan Finlay <dan@danfinlay.com>2016-06-22 04:19:44 +0800
commitab15b4c8259d6f6c5ae9d1e51548d73cfc1c67cb (patch)
treeb1390a02f04b43cf78c880c1dbb4c961fbe12dd6
parenta08c3bc01b11fbd0e3a243359befbe9fc909edf4 (diff)
parentcfc056e34ba6dda983a1ca6b4bc090661b799d38 (diff)
downloadtangerine-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
-rw-r--r--app/manifest.json2
-rw-r--r--app/scripts/lib/id-management.js2
-rw-r--r--test/unit/util_test.js16
-rw-r--r--ui/app/util.js17
4 files changed, 25 insertions, 12 deletions
diff --git a/app/manifest.json b/app/manifest.json
index 2e2d28f37..dede7402a 100644
--- a/app/manifest.json
+++ b/app/manifest.json
@@ -1,7 +1,7 @@
{
"name": "__MSG_appName__",
"short_name": "Metamask",
- "version": "2.4.0",
+ "version": "2.4.1",
"manifest_version": 2,
"description": "__MSG_appDescription__",
"icons": {
diff --git a/app/scripts/lib/id-management.js b/app/scripts/lib/id-management.js
index b9a2fc3a8..4e18bc8a9 100644
--- a/app/scripts/lib/id-management.js
+++ b/app/scripts/lib/id-management.js
@@ -1,4 +1,6 @@
const ethUtil = require('ethereumjs-util')
+const Transaction = require('ethereumjs-tx')
+const configManager = require('./config-manager-singleton')
module.exports = IdManagement
diff --git a/test/unit/util_test.js b/test/unit/util_test.js
index 12a16999e..e2390c8d4 100644
--- a/test/unit/util_test.js
+++ b/test/unit/util_test.js
@@ -25,12 +25,26 @@ describe('util', function() {
})
})
describe('parseBalance', function() {
- it('should render 0.01 eth correctly', function() {
+ it('should render 12.023 eth correctly', function() {
const input = 'A6DA46CCA6858000'
const output = util.parseBalance(input)
assert.deepEqual(output, ['12', '023'])
})
})
+ describe('parseBalance', function() {
+ it('should render 0.0000000342422 eth correctly', function() {
+ const input = '0x7F8FE81C0'
+ const output = util.parseBalance(input)
+ assert.deepEqual(output, ['0', '0000000342422'])
+ })
+ })
+ describe('parseBalance', function() {
+ it('should render 0 eth correctly', function() {
+ const input = '0x0'
+ const output = util.parseBalance(input)
+ assert.deepEqual(output, ['0', '0'])
+ })
+ })
describe('addressSummary', function() {
it('should add case-sensitive checksum', function() {
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]
}