aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/conf-tx.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-03-29 02:46:33 +0800
committerDan Finlay <dan@danfinlay.com>2017-03-29 02:52:15 +0800
commit81d3658343bbdf8dd85b175f759c372d9ee00fb8 (patch)
treedf3973c062c7c16ce0c965860c6c630f821d7602 /ui/app/conf-tx.js
parent903d3aeb7a3482f9de1d43d5634bdfec59715288 (diff)
downloadtangerine-wallet-browser-81d3658343bbdf8dd85b175f759c372d9ee00fb8.tar
tangerine-wallet-browser-81d3658343bbdf8dd85b175f759c372d9ee00fb8.tar.gz
tangerine-wallet-browser-81d3658343bbdf8dd85b175f759c372d9ee00fb8.tar.bz2
tangerine-wallet-browser-81d3658343bbdf8dd85b175f759c372d9ee00fb8.tar.lz
tangerine-wallet-browser-81d3658343bbdf8dd85b175f759c372d9ee00fb8.tar.xz
tangerine-wallet-browser-81d3658343bbdf8dd85b175f759c372d9ee00fb8.tar.zst
tangerine-wallet-browser-81d3658343bbdf8dd85b175f759c372d9ee00fb8.zip
Improve UI gas calculation logic
- Now striping hex prefixed gas values, which may have been causing mis-estimation. - Unified calculation logic to be entirely functional. - Greatly simplified how the pending-tx form keeps updated form state. Still needs a commit from @kumavis to ensure the background passes in a txMeta.txParams.gasPrice value.
Diffstat (limited to 'ui/app/conf-tx.js')
-rw-r--r--ui/app/conf-tx.js30
1 files changed, 1 insertions, 29 deletions
diff --git a/ui/app/conf-tx.js b/ui/app/conf-tx.js
index 54c171a8a..3b8618992 100644
--- a/ui/app/conf-tx.js
+++ b/ui/app/conf-tx.js
@@ -7,8 +7,6 @@ const actions = require('./actions')
const NetworkIndicator = require('./components/network')
const txHelper = require('../lib/tx-helper')
const isPopupOrNotification = require('../../app/scripts/lib/is-popup-or-notification')
-const ethUtil = require('ethereumjs-util')
-const BN = ethUtil.BN
const PendingTx = require('./components/pending-tx')
const PendingMsg = require('./components/pending-msg')
@@ -104,9 +102,6 @@ ConfirmTxScreen.prototype.render = function () {
selectedAddress: props.selectedAddress,
accounts: props.accounts,
identities: props.identities,
- insufficientBalance: this.checkBalanceAgainstTx(txData),
- // State actions
- onTxChange: this.onTxChange.bind(this),
// Actions
buyEth: this.buyEth.bind(this, txParams.from || props.selectedAddress),
sendTransaction: this.sendTransaction.bind(this, txData),
@@ -145,37 +140,14 @@ function currentTxView (opts) {
}
}
-ConfirmTxScreen.prototype.checkBalanceAgainstTx = function (txData) {
- if (!txData.txParams) return false
- var props = this.props
- var address = txData.txParams.from || props.selectedAddress
- var account = props.accounts[address]
- var balance = account ? account.balance : '0x0'
- var maxCost = new BN(txData.maxCost, 16)
-
- var balanceBn = new BN(ethUtil.stripHexPrefix(balance), 16)
- return maxCost.gt(balanceBn)
-}
-
ConfirmTxScreen.prototype.buyEth = function (address, event) {
this.stopPropagation(event)
this.props.dispatch(actions.buyEthView(address))
}
-// Allows the detail view to update the gas calculations,
-// for manual gas controls.
-ConfirmTxScreen.prototype.onTxChange = function (txData) {
- log.debug(`conf-tx onTxChange triggered with ${JSON.stringify(txData)}`)
- this.setState({ txData })
-}
-
-// Must default to any local state txData,
-// to allow manual override of gas calculations.
ConfirmTxScreen.prototype.sendTransaction = function (txData, event) {
this.stopPropagation(event)
- const state = this.state || {}
- const txMeta = state.txData
- this.props.dispatch(actions.updateAndApproveTx(txMeta || txData))
+ this.props.dispatch(actions.updateAndApproveTx(txData))
}
ConfirmTxScreen.prototype.cancelTransaction = function (txData, event) {