From 5ada8359ad7be82a7e441f4da8e68fd69135299c Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Wed, 6 Feb 2019 13:23:49 -0330 Subject: [PATCH] Ensure that custom gas data in state gets set from inline advance gas controls on send screen. --- .../send-content/send-gas-row/send-gas-row.container.js | 5 +++++ .../send-gas-row/tests/send-gas-row-container.test.js | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js b/ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js index b32928b75f31..96a6de42445f 100644 --- a/ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js +++ b/ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js @@ -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()), diff --git a/ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-container.test.js b/ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-container.test.js index 439f2ef6a0e6..0d5dc4117e6c 100644 --- a/ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-container.test.js +++ b/ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-container.test.js @@ -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') })