Rename gas change actions.

feature/default_network_editable
Dan 7 years ago
parent 8b6d08a15d
commit 6f633a97e1
  1. 16
      ui/app/actions.js
  2. 18
      ui/app/components/customize-gas-modal/index.js
  3. 4
      ui/app/components/send_/send.container.js
  4. 6
      ui/app/components/send_/tests/send-container.test.js

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

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

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

@ -7,7 +7,7 @@ let mapDispatchToProps
const actionSpies = { const actionSpies = {
updateSendTokenBalance: sinon.spy(), updateSendTokenBalance: sinon.spy(),
updateGasTotal: sinon.spy(), updateGasData: sinon.spy(),
setGasTotal: sinon.spy(), setGasTotal: sinon.spy(),
} }
const duckActionSpies = { 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 const { selectedAddress, selectedToken, data } = mockProps
mapDispatchToPropsObject.updateAndSetGasTotal( mapDispatchToPropsObject.updateAndSetGasTotal(
Object.assign(mockProps, {editingTransactionId: false}) Object.assign(mockProps, {editingTransactionId: false})
) )
assert(dispatchSpy.calledOnce) assert(dispatchSpy.calledOnce)
assert.deepEqual( assert.deepEqual(
actionSpies.updateGasTotal.getCall(0).args[0], actionSpies.updateGasData.getCall(0).args[0],
{ selectedAddress, selectedToken, data } { selectedAddress, selectedToken, data }
) )
}) })

Loading…
Cancel
Save