aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/util.js
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2016-07-12 07:01:52 +0800
committerKevin Serrano <kevgagser@gmail.com>2016-07-12 07:01:52 +0800
commit37f21cf18f3495b255d25cfe57c2cbf495ba6b69 (patch)
tree2e9c01134e85f5f04f6242ab8f2b916505dae8a2 /ui/app/util.js
parent31d0d1ec080546b591d0c8ffd85c8bd983791f99 (diff)
downloadtangerine-wallet-browser-37f21cf18f3495b255d25cfe57c2cbf495ba6b69.tar
tangerine-wallet-browser-37f21cf18f3495b255d25cfe57c2cbf495ba6b69.tar.gz
tangerine-wallet-browser-37f21cf18f3495b255d25cfe57c2cbf495ba6b69.tar.bz2
tangerine-wallet-browser-37f21cf18f3495b255d25cfe57c2cbf495ba6b69.tar.lz
tangerine-wallet-browser-37f21cf18f3495b255d25cfe57c2cbf495ba6b69.tar.xz
tangerine-wallet-browser-37f21cf18f3495b255d25cfe57c2cbf495ba6b69.tar.zst
tangerine-wallet-browser-37f21cf18f3495b255d25cfe57c2cbf495ba6b69.zip
Remove unused functions. Readd if necessary.
Diffstat (limited to 'ui/app/util.js')
-rw-r--r--ui/app/util.js22
1 files changed, 4 insertions, 18 deletions
diff --git a/ui/app/util.js b/ui/app/util.js
index b86bc6035..216ded49f 100644
--- a/ui/app/util.js
+++ b/ui/app/util.js
@@ -30,8 +30,6 @@ module.exports = {
generateBalanceObject: generateBalanceObject,
dataSize: dataSize,
readableDate: readableDate,
- ethToWei: ethToWei,
- weiToEth: weiToEth,
normalizeToWei: normalizeToWei,
normalizeEthStringToWei: normalizeEthStringToWei,
normalizeNumberToWei: normalizeNumberToWei,
@@ -79,27 +77,15 @@ function numericBalance (balance) {
return new ethUtil.BN(stripped, 16)
}
-// Takes eth BN, returns BN wei
-function ethToWei (bn) {
- var eth = new ethUtil.BN('1000000000000000000')
- var wei = bn.mul(eth)
- return wei
-}
-
-// Takes BN in Wei, returns BN in eth
-function weiToEth (bn) {
- var diff = new ethUtil.BN('1000000000000000000')
- var eth = bn.div(diff)
- return eth
-}
-
// Takes hex, returns [beforeDecimal, afterDecimal]
function parseBalance (balance) {
var beforeDecimal, afterDecimal
- const wei = numericBalance(balance).toString()
+ const wei = numericBalance(balance)
+ var weiString = wei.toString()
const trailingZeros = /0+$/
- beforeDecimal = wei.length > 18 ? wei.slice(0, wei.length - 18) : '0'
+ beforeDecimal = weiString.length > 18 ? weiString.slice(0, weiString.length - 18) : '0'
+ // We don't use weiToEth here because we need to maintain decimal precision.
afterDecimal = ('000000000000000000' + wei).slice(-18).replace(trailingZeros, '')
if (afterDecimal === '') { afterDecimal = '0' }
return [beforeDecimal, afterDecimal]