mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Create single action for updating all of send in redux state.
This commit is contained in:
parent
4671f28476
commit
9e3f921ba9
@ -149,6 +149,7 @@ var actions = {
|
||||
UPDATE_SEND_AMOUNT: 'UPDATE_SEND_AMOUNT',
|
||||
UPDATE_SEND_MEMO: 'UPDATE_SEND_MEMO',
|
||||
UPDATE_SEND_ERRORS: 'UPDATE_SEND_ERRORS',
|
||||
UPDATE_SEND: 'UPDATE_SEND',
|
||||
CLEAR_SEND: 'CLEAR_SEND',
|
||||
updateGasLimit,
|
||||
updateGasPrice,
|
||||
@ -159,6 +160,7 @@ var actions = {
|
||||
updateSendAmount,
|
||||
updateSendMemo,
|
||||
updateSendErrors,
|
||||
updateSend,
|
||||
clearSend,
|
||||
setSelectedAddress,
|
||||
// app messages
|
||||
@ -632,6 +634,13 @@ function updateSendErrors (error) {
|
||||
}
|
||||
}
|
||||
|
||||
function updateSend (newSend) {
|
||||
return {
|
||||
type: actions.UPDATE_SEND,
|
||||
value: newSend,
|
||||
}
|
||||
}
|
||||
|
||||
function clearSend () {
|
||||
return {
|
||||
type: actions.CLEAR_SEND,
|
||||
|
@ -43,12 +43,15 @@ function mapDispatchToProps (dispatch) {
|
||||
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.updateSend({
|
||||
gasLimit,
|
||||
gasPrice,
|
||||
gasTotal: null,
|
||||
to,
|
||||
amount,
|
||||
errors: { to: null, amount: null },
|
||||
editingTransactionId: id,
|
||||
}))
|
||||
dispatch(actions.showSendPage())
|
||||
},
|
||||
cancelTransaction: ({ id }) => dispatch(actions.cancelTx({ id })),
|
||||
|
@ -77,13 +77,16 @@ function mapDispatchToProps (dispatch, ownProps) {
|
||||
gasPrice,
|
||||
to,
|
||||
} = 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.setSelectedToken(address))
|
||||
dispatch(actions.updateSend({
|
||||
gasLimit,
|
||||
gasPrice,
|
||||
gasTotal: null,
|
||||
to,
|
||||
amount,
|
||||
errors: { to: null, amount: null },
|
||||
editingTransactionId: id,
|
||||
}))
|
||||
dispatch(actions.showSendTokenPage())
|
||||
},
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ CurrencyDisplay.prototype.render = function () {
|
||||
onInputChange: newValue => {
|
||||
handleChange(this.getAmount(newValue))
|
||||
},
|
||||
inputRef: input => { this.currencyInput = input; },
|
||||
inputRef: input => { this.currencyInput = input },
|
||||
}),
|
||||
|
||||
h('span.currency-display__currency-symbol', primaryCurrency),
|
||||
|
@ -257,17 +257,27 @@ function reduceMetamask (state, action) {
|
||||
},
|
||||
})
|
||||
|
||||
case actions.UPDATE_SEND:
|
||||
return extend(metamaskState, {
|
||||
send: {
|
||||
...metamaskState.send,
|
||||
...action.value,
|
||||
},
|
||||
})
|
||||
|
||||
case actions.CLEAR_SEND:
|
||||
return extend(metamaskState, {
|
||||
send: {
|
||||
gasLimit: null,
|
||||
gasPrice: null,
|
||||
gasTotal: null,
|
||||
tokenBalance: null,
|
||||
from: '',
|
||||
to: '',
|
||||
amount: '0x0',
|
||||
memo: '',
|
||||
errors: {},
|
||||
editingTransactionId: null,
|
||||
},
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user