From 97e92a1b68fca9cde0d105ece135730a677a7413 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Wed, 6 Feb 2019 13:43:45 -0330 Subject: Set custom gas data in state from inline advance gas controls on send screen (#6114) --- .../send/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(-) (limited to 'ui/app') 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 b32928b75..96a6de424 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 439f2ef6a..0d5dc4117 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') }) -- cgit v1.2.3