mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
Clear send state on cancelling and signing.
This commit is contained in:
parent
8f3b762461
commit
b96ba55229
@ -143,6 +143,7 @@ var actions = {
|
||||
UPDATE_SEND_AMOUNT: 'UPDATE_SEND_AMOUNT',
|
||||
UPDATE_SEND_MEMO: 'UPDATE_SEND_MEMO',
|
||||
UPDATE_SEND_ERRORS: 'UPDATE_SEND_ERRORS',
|
||||
CLEAR_SEND: 'CLEAR_SEND',
|
||||
updateGasLimit,
|
||||
updateGasPrice,
|
||||
updateGasTotal,
|
||||
@ -151,6 +152,7 @@ var actions = {
|
||||
updateSendAmount,
|
||||
updateSendMemo,
|
||||
updateSendErrors,
|
||||
clearSend,
|
||||
setSelectedAddress,
|
||||
// app messages
|
||||
confirmSeedWords: confirmSeedWords,
|
||||
@ -577,13 +579,18 @@ function updateSendMemo (memo) {
|
||||
}
|
||||
|
||||
function updateSendErrors (error) {
|
||||
console.log(`updateSendErrors error`, error);
|
||||
return {
|
||||
type: actions.UPDATE_SEND_ERRORS,
|
||||
value: error,
|
||||
}
|
||||
}
|
||||
|
||||
function clearSend () {
|
||||
return {
|
||||
type: actions.CLEAR_SEND
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function sendTx (txData) {
|
||||
log.info(`actions - sendTx: ${JSON.stringify(txData.txParams)}`)
|
||||
|
@ -80,5 +80,6 @@ function mapDispatchToProps (dispatch) {
|
||||
updateSendMemo: newMemo => dispatch(actions.updateSendMemo(newMemo)),
|
||||
updateSendErrors: newError => dispatch(actions.updateSendErrors(newError)),
|
||||
goHome: () => dispatch(actions.goHome()),
|
||||
clearSend: () => dispatch(actions.clearSend())
|
||||
}
|
||||
}
|
||||
|
@ -226,10 +226,6 @@ function reduceMetamask (state, action) {
|
||||
})
|
||||
|
||||
case actions.UPDATE_SEND_ERRORS:
|
||||
console.log(123, {
|
||||
...metamaskState.send.errors,
|
||||
...action.value,
|
||||
})
|
||||
return extend(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:
|
||||
return metamaskState
|
||||
|
||||
|
@ -382,11 +382,14 @@ SendTransactionScreen.prototype.renderForm = function () {
|
||||
}
|
||||
|
||||
SendTransactionScreen.prototype.renderFooter = function () {
|
||||
const { goHome } = this.props
|
||||
const { goHome, clearSend } = this.props
|
||||
|
||||
return h('div.send-v2__footer', [
|
||||
h('button.send-v2__cancel-btn', {
|
||||
onClick: goHome,
|
||||
onClick: () => {
|
||||
clearSend()
|
||||
goHome()
|
||||
},
|
||||
}, 'Cancel'),
|
||||
h('button.send-v2__next-btn', {
|
||||
onClick: event => this.onSubmit(event),
|
||||
@ -429,6 +432,7 @@ SendTransactionScreen.prototype.onSubmit = function (event) {
|
||||
signTx,
|
||||
selectedToken,
|
||||
toAccounts,
|
||||
clearSend,
|
||||
} = this.props
|
||||
|
||||
this.addToAddressBookIfNew(to)
|
||||
@ -445,6 +449,8 @@ SendTransactionScreen.prototype.onSubmit = function (event) {
|
||||
txParams.to = to
|
||||
}
|
||||
|
||||
clearSend()
|
||||
|
||||
selectedToken
|
||||
? signTokenTx(selectedToken.address, to, amount, txParams)
|
||||
: signTx(txParams)
|
||||
|
Loading…
Reference in New Issue
Block a user