mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-10-23 03:36:18 +02:00
Set custom gas data in state from inline advance gas controls on send screen (#6114)
This commit is contained in:
parent
798930afba
commit
97e92a1b68
@ -27,10 +27,13 @@ import {
|
|||||||
} from '../../../../ducks/send.duck'
|
} from '../../../../ducks/send.duck'
|
||||||
import {
|
import {
|
||||||
resetCustomData,
|
resetCustomData,
|
||||||
|
setCustomGasPrice,
|
||||||
|
setCustomGasLimit,
|
||||||
} from '../../../../ducks/gas.duck'
|
} from '../../../../ducks/gas.duck'
|
||||||
import { getGasLoadingError, gasFeeIsInError, getGasButtonGroupShown } from './send-gas-row.selectors.js'
|
import { getGasLoadingError, gasFeeIsInError, getGasButtonGroupShown } from './send-gas-row.selectors.js'
|
||||||
import { showModal, setGasPrice, setGasLimit, setGasTotal } from '../../../../actions'
|
import { showModal, setGasPrice, setGasLimit, setGasTotal } from '../../../../actions'
|
||||||
import { getAdvancedInlineGasShown, getCurrentEthBalance } from '../../../../selectors'
|
import { getAdvancedInlineGasShown, getCurrentEthBalance } from '../../../../selectors'
|
||||||
|
import { addHexPrefix } from 'ethereumjs-util'
|
||||||
import SendGasRow from './send-gas-row.component'
|
import SendGasRow from './send-gas-row.component'
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(SendGasRow)
|
export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(SendGasRow)
|
||||||
@ -79,11 +82,13 @@ function mapDispatchToProps (dispatch) {
|
|||||||
setGasPrice: (newPrice, gasLimit) => {
|
setGasPrice: (newPrice, gasLimit) => {
|
||||||
newPrice = decGWEIToHexWEI(newPrice)
|
newPrice = decGWEIToHexWEI(newPrice)
|
||||||
dispatch(setGasPrice(newPrice))
|
dispatch(setGasPrice(newPrice))
|
||||||
|
dispatch(setCustomGasPrice(addHexPrefix(newPrice)))
|
||||||
dispatch(setGasTotal(calcGasTotal(gasLimit, newPrice)))
|
dispatch(setGasTotal(calcGasTotal(gasLimit, newPrice)))
|
||||||
},
|
},
|
||||||
setGasLimit: (newLimit, gasPrice) => {
|
setGasLimit: (newLimit, gasPrice) => {
|
||||||
newLimit = decimalToHex(newLimit)
|
newLimit = decimalToHex(newLimit)
|
||||||
dispatch(setGasLimit(newLimit))
|
dispatch(setGasLimit(newLimit))
|
||||||
|
dispatch(setCustomGasLimit(addHexPrefix(newLimit.toString(16))))
|
||||||
dispatch(setGasTotal(calcGasTotal(newLimit, gasPrice)))
|
dispatch(setGasTotal(calcGasTotal(newLimit, gasPrice)))
|
||||||
},
|
},
|
||||||
showGasButtonGroup: () => dispatch(showGasButtonGroup()),
|
showGasButtonGroup: () => dispatch(showGasButtonGroup()),
|
||||||
|
@ -19,6 +19,8 @@ const sendDuckSpies = {
|
|||||||
|
|
||||||
const gasDuckSpies = {
|
const gasDuckSpies = {
|
||||||
resetCustomData: sinon.spy(),
|
resetCustomData: sinon.spy(),
|
||||||
|
setCustomGasPrice: sinon.spy(),
|
||||||
|
setCustomGasLimit: sinon.spy(),
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyquire('../send-gas-row.container.js', {
|
proxyquire('../send-gas-row.container.js', {
|
||||||
@ -123,9 +125,10 @@ describe('send-gas-row container', () => {
|
|||||||
describe('setGasPrice()', () => {
|
describe('setGasPrice()', () => {
|
||||||
it('should dispatch an action', () => {
|
it('should dispatch an action', () => {
|
||||||
mapDispatchToPropsObject.setGasPrice('mockNewPrice', 'mockLimit')
|
mapDispatchToPropsObject.setGasPrice('mockNewPrice', 'mockLimit')
|
||||||
assert(dispatchSpy.calledTwice)
|
assert(dispatchSpy.calledThrice)
|
||||||
assert(actionSpies.setGasPrice.calledOnce)
|
assert(actionSpies.setGasPrice.calledOnce)
|
||||||
assert.equal(actionSpies.setGasPrice.getCall(0).args[0], '0xmockNewPrice000')
|
assert.equal(actionSpies.setGasPrice.getCall(0).args[0], '0xmockNewPrice000')
|
||||||
|
assert.equal(gasDuckSpies.setCustomGasPrice.getCall(0).args[0], '0xmockNewPrice000')
|
||||||
assert(actionSpies.setGasTotal.calledOnce)
|
assert(actionSpies.setGasTotal.calledOnce)
|
||||||
assert.equal(actionSpies.setGasTotal.getCall(0).args[0], 'mockLimit0xmockNewPrice000')
|
assert.equal(actionSpies.setGasTotal.getCall(0).args[0], 'mockLimit0xmockNewPrice000')
|
||||||
})
|
})
|
||||||
@ -134,9 +137,10 @@ describe('send-gas-row container', () => {
|
|||||||
describe('setGasLimit()', () => {
|
describe('setGasLimit()', () => {
|
||||||
it('should dispatch an action', () => {
|
it('should dispatch an action', () => {
|
||||||
mapDispatchToPropsObject.setGasLimit('mockNewLimit', 'mockPrice')
|
mapDispatchToPropsObject.setGasLimit('mockNewLimit', 'mockPrice')
|
||||||
assert(dispatchSpy.calledTwice)
|
assert(dispatchSpy.calledThrice)
|
||||||
assert(actionSpies.setGasLimit.calledOnce)
|
assert(actionSpies.setGasLimit.calledOnce)
|
||||||
assert.equal(actionSpies.setGasLimit.getCall(0).args[0], '0xmockNewLimit')
|
assert.equal(actionSpies.setGasLimit.getCall(0).args[0], '0xmockNewLimit')
|
||||||
|
assert.equal(gasDuckSpies.setCustomGasLimit.getCall(0).args[0], '0xmockNewLimit')
|
||||||
assert(actionSpies.setGasTotal.calledOnce)
|
assert(actionSpies.setGasTotal.calledOnce)
|
||||||
assert.equal(actionSpies.setGasTotal.getCall(0).args[0], '0xmockNewLimitmockPrice')
|
assert.equal(actionSpies.setGasTotal.getCall(0).args[0], '0xmockNewLimitmockPrice')
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user