mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01: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'
|
||||
import {
|
||||
resetCustomData,
|
||||
setCustomGasPrice,
|
||||
setCustomGasLimit,
|
||||
} from '../../../../ducks/gas.duck'
|
||||
import { getGasLoadingError, gasFeeIsInError, getGasButtonGroupShown } from './send-gas-row.selectors.js'
|
||||
import { showModal, setGasPrice, setGasLimit, setGasTotal } from '../../../../actions'
|
||||
import { getAdvancedInlineGasShown, getCurrentEthBalance } from '../../../../selectors'
|
||||
import { addHexPrefix } from 'ethereumjs-util'
|
||||
import SendGasRow from './send-gas-row.component'
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(SendGasRow)
|
||||
@ -79,11 +82,13 @@ function mapDispatchToProps (dispatch) {
|
||||
setGasPrice: (newPrice, gasLimit) => {
|
||||
newPrice = decGWEIToHexWEI(newPrice)
|
||||
dispatch(setGasPrice(newPrice))
|
||||
dispatch(setCustomGasPrice(addHexPrefix(newPrice)))
|
||||
dispatch(setGasTotal(calcGasTotal(gasLimit, newPrice)))
|
||||
},
|
||||
setGasLimit: (newLimit, gasPrice) => {
|
||||
newLimit = decimalToHex(newLimit)
|
||||
dispatch(setGasLimit(newLimit))
|
||||
dispatch(setCustomGasLimit(addHexPrefix(newLimit.toString(16))))
|
||||
dispatch(setGasTotal(calcGasTotal(newLimit, gasPrice)))
|
||||
},
|
||||
showGasButtonGroup: () => dispatch(showGasButtonGroup()),
|
||||
|
@ -19,6 +19,8 @@ const sendDuckSpies = {
|
||||
|
||||
const gasDuckSpies = {
|
||||
resetCustomData: sinon.spy(),
|
||||
setCustomGasPrice: sinon.spy(),
|
||||
setCustomGasLimit: sinon.spy(),
|
||||
}
|
||||
|
||||
proxyquire('../send-gas-row.container.js', {
|
||||
@ -123,9 +125,10 @@ describe('send-gas-row container', () => {
|
||||
describe('setGasPrice()', () => {
|
||||
it('should dispatch an action', () => {
|
||||
mapDispatchToPropsObject.setGasPrice('mockNewPrice', 'mockLimit')
|
||||
assert(dispatchSpy.calledTwice)
|
||||
assert(dispatchSpy.calledThrice)
|
||||
assert(actionSpies.setGasPrice.calledOnce)
|
||||
assert.equal(actionSpies.setGasPrice.getCall(0).args[0], '0xmockNewPrice000')
|
||||
assert.equal(gasDuckSpies.setCustomGasPrice.getCall(0).args[0], '0xmockNewPrice000')
|
||||
assert(actionSpies.setGasTotal.calledOnce)
|
||||
assert.equal(actionSpies.setGasTotal.getCall(0).args[0], 'mockLimit0xmockNewPrice000')
|
||||
})
|
||||
@ -134,9 +137,10 @@ describe('send-gas-row container', () => {
|
||||
describe('setGasLimit()', () => {
|
||||
it('should dispatch an action', () => {
|
||||
mapDispatchToPropsObject.setGasLimit('mockNewLimit', 'mockPrice')
|
||||
assert(dispatchSpy.calledTwice)
|
||||
assert(dispatchSpy.calledThrice)
|
||||
assert(actionSpies.setGasLimit.calledOnce)
|
||||
assert.equal(actionSpies.setGasLimit.getCall(0).args[0], '0xmockNewLimit')
|
||||
assert.equal(gasDuckSpies.setCustomGasLimit.getCall(0).args[0], '0xmockNewLimit')
|
||||
assert(actionSpies.setGasTotal.calledOnce)
|
||||
assert.equal(actionSpies.setGasTotal.getCall(0).args[0], '0xmockNewLimitmockPrice')
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user