Clear send state on cancelling and signing.

feature/default_network_editable
Dan 7 years ago
parent 8f3b762461
commit b96ba55229
  1. 9
      ui/app/actions.js
  2. 1
      ui/app/components/send/send-v2-container.js
  3. 18
      ui/app/reducers/metamask.js
  4. 10
      ui/app/send-v2.js

@ -143,6 +143,7 @@ var actions = {
UPDATE_SEND_AMOUNT: 'UPDATE_SEND_AMOUNT', UPDATE_SEND_AMOUNT: 'UPDATE_SEND_AMOUNT',
UPDATE_SEND_MEMO: 'UPDATE_SEND_MEMO', UPDATE_SEND_MEMO: 'UPDATE_SEND_MEMO',
UPDATE_SEND_ERRORS: 'UPDATE_SEND_ERRORS', UPDATE_SEND_ERRORS: 'UPDATE_SEND_ERRORS',
CLEAR_SEND: 'CLEAR_SEND',
updateGasLimit, updateGasLimit,
updateGasPrice, updateGasPrice,
updateGasTotal, updateGasTotal,
@ -151,6 +152,7 @@ var actions = {
updateSendAmount, updateSendAmount,
updateSendMemo, updateSendMemo,
updateSendErrors, updateSendErrors,
clearSend,
setSelectedAddress, setSelectedAddress,
// app messages // app messages
confirmSeedWords: confirmSeedWords, confirmSeedWords: confirmSeedWords,
@ -577,13 +579,18 @@ function updateSendMemo (memo) {
} }
function updateSendErrors (error) { function updateSendErrors (error) {
console.log(`updateSendErrors error`, error);
return { return {
type: actions.UPDATE_SEND_ERRORS, type: actions.UPDATE_SEND_ERRORS,
value: error, value: error,
} }
} }
function clearSend () {
return {
type: actions.CLEAR_SEND
}
}
function sendTx (txData) { function sendTx (txData) {
log.info(`actions - sendTx: ${JSON.stringify(txData.txParams)}`) log.info(`actions - sendTx: ${JSON.stringify(txData.txParams)}`)

@ -80,5 +80,6 @@ function mapDispatchToProps (dispatch) {
updateSendMemo: newMemo => dispatch(actions.updateSendMemo(newMemo)), updateSendMemo: newMemo => dispatch(actions.updateSendMemo(newMemo)),
updateSendErrors: newError => dispatch(actions.updateSendErrors(newError)), updateSendErrors: newError => dispatch(actions.updateSendErrors(newError)),
goHome: () => dispatch(actions.goHome()), goHome: () => dispatch(actions.goHome()),
clearSend: () => dispatch(actions.clearSend())
} }
} }

@ -226,10 +226,6 @@ function reduceMetamask (state, action) {
}) })
case actions.UPDATE_SEND_ERRORS: case actions.UPDATE_SEND_ERRORS:
console.log(123, {
...metamaskState.send.errors,
...action.value,
})
return extend(metamaskState, { return extend(metamaskState, {
send: { send: {
...metamaskState.send, ...metamaskState.send,
@ -240,6 +236,20 @@ function reduceMetamask (state, action) {
}, },
}) })
case actions.CLEAR_SEND:
return extend(metamaskState, {
send: {
gasLimit: null,
gasPrice: null,
gasTotal: null,
from: '',
to: '',
amount: '0x0',
memo: '',
errors: {},
},
})
default: default:
return metamaskState return metamaskState

@ -382,11 +382,14 @@ SendTransactionScreen.prototype.renderForm = function () {
} }
SendTransactionScreen.prototype.renderFooter = function () { SendTransactionScreen.prototype.renderFooter = function () {
const { goHome } = this.props const { goHome, clearSend } = this.props
return h('div.send-v2__footer', [ return h('div.send-v2__footer', [
h('button.send-v2__cancel-btn', { h('button.send-v2__cancel-btn', {
onClick: goHome, onClick: () => {
clearSend()
goHome()
},
}, 'Cancel'), }, 'Cancel'),
h('button.send-v2__next-btn', { h('button.send-v2__next-btn', {
onClick: event => this.onSubmit(event), onClick: event => this.onSubmit(event),
@ -429,6 +432,7 @@ SendTransactionScreen.prototype.onSubmit = function (event) {
signTx, signTx,
selectedToken, selectedToken,
toAccounts, toAccounts,
clearSend,
} = this.props } = this.props
this.addToAddressBookIfNew(to) this.addToAddressBookIfNew(to)
@ -445,6 +449,8 @@ SendTransactionScreen.prototype.onSubmit = function (event) {
txParams.to = to txParams.to = to
} }
clearSend()
selectedToken selectedToken
? signTokenTx(selectedToken.address, to, amount, txParams) ? signTokenTx(selectedToken.address, to, amount, txParams)
: signTx(txParams) : signTx(txParams)

Loading…
Cancel
Save