1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Make tx calculations account for gas prices

This commit is contained in:
Dan Finlay 2017-09-07 12:52:49 -07:00
parent 532a4040de
commit fadc0617df

View File

@ -32,9 +32,15 @@ class PendingBalanceCalculator {
valueFor (tx) {
const txValue = tx.txParams.value
const normalized = normalize(txValue).substring(2)
const value = this.hexToBn(txValue)
return value
const gasPrice = this.hexToBn(tx.txParams.gasPrice)
const gas = tx.txParams.gas
const gasLimit = tx.txParams.gasLimit
const gasLimitBn = this.hexToBn(gas || gasLimit)
const gasCost = gasPrice.mul(gasLimitBn)
return value.add(gasCost)
}
hexToBn (hex) {