mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-22 09:23:21 +01:00
Remove unused functions. Readd if necessary.
This commit is contained in:
parent
31d0d1ec08
commit
37f21cf18f
@ -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() {
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user