aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/util.js
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2016-07-15 05:38:54 +0800
committerGitHub <noreply@github.com>2016-07-15 05:38:54 +0800
commite18dc1d65d2422f2d06a0effe81154f82d3c34d5 (patch)
treef29f783accff0729dab4c557fcb1802be1868de8 /ui/app/util.js
parentf84992fa33369d9dc5923c26a61c5369793fc550 (diff)
parent3b80a043ee711bbc12ec55265e7c024c9145e75d (diff)
downloadtangerine-wallet-browser-e18dc1d65d2422f2d06a0effe81154f82d3c34d5.tar.gz
tangerine-wallet-browser-e18dc1d65d2422f2d06a0effe81154f82d3c34d5.tar.zst
tangerine-wallet-browser-e18dc1d65d2422f2d06a0effe81154f82d3c34d5.zip
Merge branch 'master' into legal-beagal
Diffstat (limited to 'ui/app/util.js')
-rw-r--r--ui/app/util.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/ui/app/util.js b/ui/app/util.js
index c04612455..a08006077 100644
--- a/ui/app/util.js
+++ b/ui/app/util.js
@@ -122,7 +122,11 @@ function generateBalanceObject (formattedBalance, decimalsToKeep = 1) {
var afterDecimal = balance.split('.')[1]
var shortBalance = shortenBalance(balance, decimalsToKeep)
- if (beforeDecimal === '0' && afterDecimal.substr(0, 5) === '00000') { balance = '<1.0e-5' }
+ if (beforeDecimal === '0' && afterDecimal.substr(0, 5) === '00000') {
+ balance = '<1.0e-5'
+ } else if (beforeDecimal !== '0') {
+ balance = `${beforeDecimal}.${afterDecimal.slice(0, decimalsToKeep)}`
+ }
return { balance, label, shortBalance }
}
@@ -141,7 +145,7 @@ function shortenBalance (balance, decimalsToKeep = 1) {
truncatedValue = (convertedBalance * Math.pow(10, exponent)).toFixed(decimalsToKeep)
return `<${truncatedValue}e-${exponent}`
} else {
- return balance
+ return convertedBalance.toFixed(decimalsToKeep)
}
}