aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-03-24 08:00:59 +0800
committerDan Finlay <dan@danfinlay.com>2017-03-24 08:00:59 +0800
commit6a46e9ce0662413f6351756658b2bae8a895a33b (patch)
treee0662061d7906844aa1ebecb159cbd4f11f46836 /ui
parent9bea31a402d0b343bae6a9ef055efa2b83be9071 (diff)
downloadtangerine-wallet-browser-6a46e9ce0662413f6351756658b2bae8a895a33b.tar
tangerine-wallet-browser-6a46e9ce0662413f6351756658b2bae8a895a33b.tar.gz
tangerine-wallet-browser-6a46e9ce0662413f6351756658b2bae8a895a33b.tar.bz2
tangerine-wallet-browser-6a46e9ce0662413f6351756658b2bae8a895a33b.tar.lz
tangerine-wallet-browser-6a46e9ce0662413f6351756658b2bae8a895a33b.tar.xz
tangerine-wallet-browser-6a46e9ce0662413f6351756658b2bae8a895a33b.tar.zst
tangerine-wallet-browser-6a46e9ce0662413f6351756658b2bae8a895a33b.zip
Make gas calculations on render more consistent
Diffstat (limited to 'ui')
-rw-r--r--ui/app/components/pending-tx.js26
1 files changed, 16 insertions, 10 deletions
diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js
index 9a3ef272d..2f9e9885b 100644
--- a/ui/app/components/pending-tx.js
+++ b/ui/app/components/pending-tx.js
@@ -21,40 +21,46 @@ const MIN_GAS_PRICE_BN = new BN(20000000)
module.exports = connect(mapStateToProps)(PendingTx)
function mapStateToProps (state) {
- return {
-
- }
+ return {}
}
inherits(PendingTx, Component)
function PendingTx () {
Component.call(this)
- this.state = { valid: true }
+ this.state = {
+ valid: true,
+ gas: null,
+ gasPrice: null,
+ txData: null,
+ }
}
PendingTx.prototype.render = function () {
const props = this.props
- const txData = props.txData
-
const state = this.state
+ const txData = state.txData || props.txData
const txParams = txData.txParams || {}
+
const address = txParams.from || props.selectedAddress
const identity = props.identities[address] || { address: address }
const account = props.accounts[address]
const balance = account ? account.balance : '0x0'
-
- const gas = (state.gas === undefined) ? txParams.gas : state.gas
- const gasPrice = (state.gasPrice === undefined) ? txData.gasPrice : state.gasPrice
+ const gas = state.gas || txParams.gas
+ const gasPrice = state.gasPrice || txData.gasPrice
const gasBn = new BN(gas, 16)
const gasPriceBn = new BN(gasPrice, 16)
const txFeeBn = gasBn.mul(gasPriceBn)
- const maxCost = state.maxCost || txData.maxCost || ''
+ const valueBn = new BN(ethUtil.stripHexPrefix(txParams.value), 16)
+ const maxCost = txFeeBn.add(valueBn)
+
const dataLength = txParams.data ? (txParams.data.length - 2) / 2 : 0
const imageify = props.imageifyIdenticons === undefined ? true : props.imageifyIdenticons
+ log.info(`rendering pending-tx form with gas limit ${gas.toString()}, gasPrice ${gasPrice.toString()}, `)
+
this.inputs = []
return (