1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Rename gas change actions.

This commit is contained in:
Dan 2018-05-19 22:07:44 -02:30
parent 8b6d08a15d
commit 6f633a97e1
4 changed files with 22 additions and 22 deletions

View File

@ -177,9 +177,9 @@ var actions = {
CLEAR_SEND: 'CLEAR_SEND',
OPEN_FROM_DROPDOWN: 'OPEN_FROM_DROPDOWN',
CLOSE_FROM_DROPDOWN: 'CLOSE_FROM_DROPDOWN',
updateGasLimit,
updateGasPrice,
updateGasTotal,
setGasLimit,
setGasPrice,
updateGasData,
setGasTotal,
setSendTokenBalance,
updateSendTokenBalance,
@ -714,14 +714,14 @@ function estimateGas (params = {}) {
return reject(err)
}
dispatch(actions.hideWarning())
dispatch(actions.updateGasLimit(data))
dispatch(actions.setGasLimit(data))
return resolve(data)
})
})
}
}
function updateGasLimit (gasLimit) {
function setGasLimit (gasLimit) {
return {
type: actions.UPDATE_GAS_LIMIT,
value: gasLimit,
@ -737,14 +737,14 @@ function getGasPrice () {
return reject(err)
}
dispatch(actions.hideWarning())
dispatch(actions.updateGasPrice(data))
dispatch(actions.setGasPrice(data))
return resolve(data)
})
})
}
}
function updateGasPrice (gasPrice) {
function setGasPrice (gasPrice) {
return {
type: actions.UPDATE_GAS_PRICE,
value: gasPrice,
@ -772,7 +772,7 @@ function getGasEstimate ({ selectedAddress, selectedToken, data }) {
}
}
function updateGasTotal ({ selectedAddress, selectedToken, data }) {
function updateGasData ({ selectedAddress, selectedToken, data }) {
return (dispatch) => {
return dispatch(actions.getGasEstimate({ selectedAddress, selectedToken, data }))
.then((gasEstimate) => {

View File

@ -65,9 +65,9 @@ function mapStateToProps (state) {
function mapDispatchToProps (dispatch) {
return {
hideModal: () => dispatch(actions.hideModal()),
updateGasPrice: newGasPrice => dispatch(actions.updateGasPrice(newGasPrice)),
updateGasLimit: newGasLimit => dispatch(actions.updateGasLimit(newGasLimit)),
updateGasTotal: newGasTotal => dispatch(actions.setGasTotal(newGasTotal)),
setGasPrice: newGasPrice => dispatch(actions.setGasPrice(newGasPrice)),
setGasLimit: newGasLimit => dispatch(actions.setGasLimit(newGasLimit)),
updateGasData: newGasTotal => dispatch(actions.setGasTotal(newGasTotal)),
updateSendAmount: newAmount => dispatch(actions.updateSendAmount(newAmount)),
updateSendErrors: error => dispatch(updateSendErrors(error)),
}
@ -109,10 +109,10 @@ module.exports = connect(mapStateToProps, mapDispatchToProps)(CustomizeGasModal)
CustomizeGasModal.prototype.save = function (gasPrice, gasLimit, gasTotal) {
const {
updateGasPrice,
updateGasLimit,
setGasPrice,
setGasLimit,
hideModal,
updateGasTotal,
updateGasData,
maxModeOn,
selectedToken,
balance,
@ -129,9 +129,9 @@ CustomizeGasModal.prototype.save = function (gasPrice, gasLimit, gasTotal) {
updateSendAmount(maxAmount)
}
updateGasPrice(ethUtil.addHexPrefix(gasPrice))
updateGasLimit(ethUtil.addHexPrefix(gasLimit))
updateGasTotal(ethUtil.addHexPrefix(gasTotal))
setGasPrice(ethUtil.addHexPrefix(gasPrice))
setGasLimit(ethUtil.addHexPrefix(gasLimit))
updateGasData(ethUtil.addHexPrefix(gasTotal))
updateSendErrors({ insufficientFunds: false })
hideModal()
}

View File

@ -21,7 +21,7 @@ import {
} from './send.selectors'
import {
updateSendTokenBalance,
updateGasTotal,
updateGasData,
setGasTotal,
} from '../../actions'
import {
@ -73,7 +73,7 @@ function mapDispatchToProps (dispatch) {
}) => {
console.log(`editingTransactionId`, editingTransactionId)
!editingTransactionId
? dispatch(updateGasTotal({ selectedAddress, selectedToken, data }))
? dispatch(updateGasData({ selectedAddress, selectedToken, data }))
: dispatch(setGasTotal(calcGasTotal(gasLimit, gasPrice)))
},
updateSendTokenBalance: ({ selectedToken, tokenContract, address }) => {

View File

@ -7,7 +7,7 @@ let mapDispatchToProps
const actionSpies = {
updateSendTokenBalance: sinon.spy(),
updateGasTotal: sinon.spy(),
updateGasData: sinon.spy(),
setGasTotal: sinon.spy(),
}
const duckActionSpies = {
@ -104,14 +104,14 @@ describe('send container', () => {
)
})
it('should dispatch an updateGasTotal action when editingTransactionId is falsy', () => {
it('should dispatch an updateGasData action when editingTransactionId is falsy', () => {
const { selectedAddress, selectedToken, data } = mockProps
mapDispatchToPropsObject.updateAndSetGasTotal(
Object.assign(mockProps, {editingTransactionId: false})
)
assert(dispatchSpy.calledOnce)
assert.deepEqual(
actionSpies.updateGasTotal.getCall(0).args[0],
actionSpies.updateGasData.getCall(0).args[0],
{ selectedAddress, selectedToken, data }
)
})