aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-09-08 03:43:10 +0800
committerDan Finlay <dan@danfinlay.com>2017-09-08 03:43:10 +0800
commit7b92268428cc2de4374bc669c524bb61959801f1 (patch)
tree853c05b0ad08515b6aa03ac00fee86bfbda41505 /app
parent40585744365c128d1f64c5bf93ee8cedc9e91dae (diff)
downloadtangerine-wallet-browser-7b92268428cc2de4374bc669c524bb61959801f1.tar
tangerine-wallet-browser-7b92268428cc2de4374bc669c524bb61959801f1.tar.gz
tangerine-wallet-browser-7b92268428cc2de4374bc669c524bb61959801f1.tar.bz2
tangerine-wallet-browser-7b92268428cc2de4374bc669c524bb61959801f1.tar.lz
tangerine-wallet-browser-7b92268428cc2de4374bc669c524bb61959801f1.tar.xz
tangerine-wallet-browser-7b92268428cc2de4374bc669c524bb61959801f1.tar.zst
tangerine-wallet-browser-7b92268428cc2de4374bc669c524bb61959801f1.zip
Fix valueFor test
Diffstat (limited to 'app')
-rw-r--r--app/scripts/lib/pending-balance-calculator.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/app/scripts/lib/pending-balance-calculator.js b/app/scripts/lib/pending-balance-calculator.js
index f2c9ce379..e4ff1e050 100644
--- a/app/scripts/lib/pending-balance-calculator.js
+++ b/app/scripts/lib/pending-balance-calculator.js
@@ -15,32 +15,33 @@ class PendingBalanceCalculator {
this.getNetworkBalance(),
this.getPendingTransactions(),
])
- console.dir(results)
const balance = results[0]
const pending = results[1]
- console.dir({ balance, pending })
console.dir(pending)
- const pendingValue = pending.reduce(function (total, tx) {
+ const pendingValue = pending.reduce((total, tx) => {
return total.add(this.valueFor(tx))
}, new BN(0))
- const balanceBn = new BN(normalize(balance))
- console.log(`subtracting ${pendingValue.toString()} from ${balanceBn.toString()}`)
+ console.log(`subtracting ${pendingValue.toString()} from ${balance.toString()}`)
- return `0x${ balanceBn.sub(pendingValue).toString(16) }`
+ return `0x${ balance.sub(pendingValue).toString(16) }`
}
valueFor (tx) {
const txValue = tx.txParams.value
const normalized = normalize(txValue).substring(2)
console.log({ txValue, normalized })
- const value = new BN(normalize(txValue).substring(2), 16)
+ const value = this.hexToBn(txValue)
return value
}
+ hexToBn (hex) {
+ return new BN(normalize(hex).substring(2), 16)
+ }
+
}
module.exports = PendingBalanceCalculator