aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/pending-tx/confirm-send-ether.js
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2017-11-09 00:44:48 +0800
committerChi Kei Chan <chikeichan@gmail.com>2017-11-15 08:18:00 +0800
commit34ca7290c593d6fb27faa98a660c8c0bca7e1457 (patch)
treef93506b3d2ab9b114b111fab2cb12ca6eeb317b8 /ui/app/components/pending-tx/confirm-send-ether.js
parent7eb083bd9f1a8ce0e9c3e83e8b6bfb4d5a7b59cc (diff)
downloadtangerine-wallet-browser-34ca7290c593d6fb27faa98a660c8c0bca7e1457.tar.gz
tangerine-wallet-browser-34ca7290c593d6fb27faa98a660c8c0bca7e1457.tar.zst
tangerine-wallet-browser-34ca7290c593d6fb27faa98a660c8c0bca7e1457.zip
Allow editing of send ether.
Diffstat (limited to 'ui/app/components/pending-tx/confirm-send-ether.js')
-rw-r--r--ui/app/components/pending-tx/confirm-send-ether.js54
1 files changed, 48 insertions, 6 deletions
diff --git a/ui/app/components/pending-tx/confirm-send-ether.js b/ui/app/components/pending-tx/confirm-send-ether.js
index d12bc499b..8b5801aec 100644
--- a/ui/app/components/pending-tx/confirm-send-ether.js
+++ b/ui/app/components/pending-tx/confirm-send-ether.js
@@ -19,6 +19,7 @@ function mapStateToProps (state) {
conversionRate,
identities,
currentCurrency,
+ send,
} = state.metamask
const accounts = state.metamask.accounts
const selectedAddress = state.metamask.selectedAddress || Object.keys(accounts)[0]
@@ -27,12 +28,30 @@ function mapStateToProps (state) {
identities,
selectedAddress,
currentCurrency,
+ send,
}
}
function mapDispatchToProps (dispatch) {
return {
- backToAccountDetail: address => dispatch(actions.backToAccountDetail(address)),
+ clearSend: () => dispatch(actions.clearSend()),
+ editTransaction: txMeta => {
+ const { id, txParams } = txMeta
+ const {
+ gas: gasLimit,
+ gasPrice,
+ from,
+ to,
+ value: amount
+ } = txParams
+ dispatch(actions.editTx(id))
+ dispatch(actions.updateGasLimit(gasLimit)),
+ dispatch(actions.updateGasPrice(gasPrice)),
+ dispatch(actions.updateSendTo(to)),
+ dispatch(actions.updateSendAmount(amount)),
+ dispatch(actions.updateSendErrors({ to: null, amount: null })),
+ dispatch(actions.showSendPage())
+ },
cancelTransaction: ({ id }) => dispatch(actions.cancelTx({ id })),
}
}
@@ -157,7 +176,7 @@ ConfirmSendEther.prototype.getData = function () {
}
ConfirmSendEther.prototype.render = function () {
- const { backToAccountDetail, selectedAddress, currentCurrency } = this.props
+ const { editTransaction, selectedAddress, currentCurrency, clearSend } = this.props
const txMeta = this.gatherTxMeta()
const txParams = txMeta.txParams || {}
@@ -199,8 +218,8 @@ ConfirmSendEther.prototype.render = function () {
h('div.confirm-screen-wrapper.flex-column.flex-grow', [
h('h3.flex-center.confirm-screen-header', [
h('button.confirm-screen-back-button', {
- onClick: () => backToAccountDetail(selectedAddress),
- }, 'BACK'),
+ onClick: () => editTransaction(txMeta),
+ }, 'EDIT'),
h('div.confirm-screen-title', 'Confirm Transaction'),
h('div.confirm-screen-header-tip'),
]),
@@ -371,7 +390,10 @@ ConfirmSendEther.prototype.render = function () {
}, [
// Cancel Button
h('div.cancel.btn-light.confirm-screen-cancel-button', {
- onClick: (event) => this.cancel(event, txMeta),
+ onClick: (event) => {
+ clearSend()
+ this.cancel(event, txMeta)
+ },
}, 'CANCEL'),
// Accept Button
@@ -419,7 +441,27 @@ ConfirmSendEther.prototype.getFormEl = function () {
ConfirmSendEther.prototype.gatherTxMeta = function () {
const props = this.props
const state = this.state
- const txData = clone(state.txData) || clone(props.txData)
+ let txData = clone(state.txData) || clone(props.txData)
+
+ if (props.send.editingTransactionId) {
+ const {
+ send: {
+ memo,
+ amount: value,
+ gasLimit: gas,
+ gasPrice,
+ }
+ } = props
+ const { txParams: { from, to } } = txData
+ txData.txParams = {
+ from: ethUtil.addHexPrefix(from),
+ to: ethUtil.addHexPrefix(to),
+ memo: memo && ethUtil.addHexPrefix(memo),
+ value: ethUtil.addHexPrefix(value),
+ gas: ethUtil.addHexPrefix(gas),
+ gasPrice: ethUtil.addHexPrefix(gasPrice),
+ }
+ }
// log.debug(`UI has defaulted to tx meta ${JSON.stringify(txData)}`)
return txData