From 37f21cf18f3495b255d25cfe57c2cbf495ba6b69 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Mon, 11 Jul 2016 16:01:52 -0700 Subject: [PATCH] Remove unused functions. Readd if necessary. --- test/unit/util_test.js | 19 ------------------- ui/app/util.js | 22 ++++------------------ 2 files changed, 4 insertions(+), 37 deletions(-) diff --git a/test/unit/util_test.js b/test/unit/util_test.js index 91c7c83e9..9a3963ac1 100644 --- a/test/unit/util_test.js +++ b/test/unit/util_test.js @@ -122,25 +122,6 @@ describe('util', function() { }) - describe('#ethToWei', function() { - - it('should take an eth BN, returns wei BN', function() { - var input = new ethUtil.BN(1, 10) - var result = util.ethToWei(input) - assert.equal(result, ethInWei, '18 zeroes') - }) - - }) - - describe('#weiToEth', function() { - - it('should take a wei BN and return an eth BN', function() { - var result = util.weiToEth(new ethUtil.BN(ethInWei)) - assert.equal(result, '1', 'equals 1 eth') - }) - - }) - describe('#formatBalance', function() { it('when given nothing', function() { 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]