aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/conf-tx.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/conf-tx.js')
-rw-r--r--ui/app/conf-tx.js72
1 files changed, 28 insertions, 44 deletions
diff --git a/ui/app/conf-tx.js b/ui/app/conf-tx.js
index 07985094c..747d3ce2b 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')
@@ -29,6 +27,9 @@ function mapStateToProps (state) {
warning: state.appState.warning,
network: state.metamask.network,
provider: state.metamask.provider,
+ conversionRate: state.metamask.conversionRate,
+ currentCurrency: state.metamask.currentCurrency,
+ blockGasLimit: state.metamask.currentBlockGasLimit,
}
}
@@ -39,15 +40,16 @@ function ConfirmTxScreen () {
ConfirmTxScreen.prototype.render = function () {
const props = this.props
- const { network, provider, unapprovedTxs,
- unapprovedMsgs, unapprovedPersonalMsgs } = props
+ const { network, provider, unapprovedTxs, currentCurrency,
+ unapprovedMsgs, unapprovedPersonalMsgs, conversionRate, blockGasLimit } = props
var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network)
- var index = props.index !== undefined && unconfTxList[index] ? props.index : 0
- var txData = unconfTxList[index] || {}
+
+ var txData = unconfTxList[props.index] || {}
var txParams = txData.params || {}
var isNotification = isPopupOrNotification() === 'notification'
+
log.info(`rendering a combined ${unconfTxList.length} unconf msg & txs`)
if (unconfTxList.length === 0) return h(Loading, { isLoading: true })
@@ -104,12 +106,12 @@ ConfirmTxScreen.prototype.render = function () {
selectedAddress: props.selectedAddress,
accounts: props.accounts,
identities: props.identities,
- insufficientBalance: this.checkBalanceAgainstTx(txData),
- // State actions
- onTxChange: this.onTxChange.bind(this),
+ conversionRate,
+ currentCurrency,
+ blockGasLimit,
// Actions
buyEth: this.buyEth.bind(this, txParams.from || props.selectedAddress),
- sendTransaction: this.sendTransaction.bind(this, txData),
+ sendTransaction: this.sendTransaction.bind(this),
cancelTransaction: this.cancelTransaction.bind(this, txData),
signMessage: this.signMessage.bind(this, txData),
signPersonalMessage: this.signPersonalMessage.bind(this, txData),
@@ -130,14 +132,12 @@ function currentTxView (opts) {
if (txParams) {
log.debug('txParams detected, rendering pending tx')
return h(PendingTx, opts)
-
} else if (msgParams) {
log.debug('msgParams detected, rendering pending msg')
if (type === 'eth_sign') {
log.debug('rendering eth_sign message')
return h(PendingMsg, opts)
-
} else if (type === 'personal_sign') {
log.debug('rendering personal_sign message')
return h(PendingPersonalMsg, opts)
@@ -145,41 +145,19 @@ 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) {
- event.stopPropagation()
+ event.preventDefault()
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) {
- event.stopPropagation()
- const state = this.state || {}
- const txMeta = state.txData
- this.props.dispatch(actions.updateAndApproveTx(txMeta || txData))
+ this.stopPropagation(event)
+ this.props.dispatch(actions.updateAndApproveTx(txData))
}
ConfirmTxScreen.prototype.cancelTransaction = function (txData, event) {
- event.stopPropagation()
+ this.stopPropagation(event)
+ event.preventDefault()
this.props.dispatch(actions.cancelTx(txData))
}
@@ -187,32 +165,38 @@ ConfirmTxScreen.prototype.signMessage = function (msgData, event) {
log.info('conf-tx.js: signing message')
var params = msgData.msgParams
params.metamaskId = msgData.id
- event.stopPropagation()
+ this.stopPropagation(event)
this.props.dispatch(actions.signMsg(params))
}
+ConfirmTxScreen.prototype.stopPropagation = function (event) {
+ if (event.stopPropagation) {
+ event.stopPropagation()
+ }
+}
+
ConfirmTxScreen.prototype.signPersonalMessage = function (msgData, event) {
log.info('conf-tx.js: signing personal message')
var params = msgData.msgParams
params.metamaskId = msgData.id
- event.stopPropagation()
+ this.stopPropagation(event)
this.props.dispatch(actions.signPersonalMsg(params))
}
ConfirmTxScreen.prototype.cancelMessage = function (msgData, event) {
log.info('canceling message')
- event.stopPropagation()
+ this.stopPropagation(event)
this.props.dispatch(actions.cancelMsg(msgData))
}
ConfirmTxScreen.prototype.cancelPersonalMessage = function (msgData, event) {
log.info('canceling personal message')
- event.stopPropagation()
+ this.stopPropagation(event)
this.props.dispatch(actions.cancelPersonalMsg(msgData))
}
ConfirmTxScreen.prototype.goHome = function (event) {
- event.stopPropagation()
+ this.stopPropagation(event)
this.props.dispatch(actions.goHome())
}