From 57ead4914f6f9fd1fe47b865559e4908a36f6a8a Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Fri, 8 Feb 2019 10:20:25 -0330 Subject: Fix inline advanced gas editing --- .../send-gas-row/send-gas-row.container.js | 20 +++++--------------- .../tests/send-gas-row-container.test.js | 22 ++++++++-------------- 2 files changed, 13 insertions(+), 29 deletions(-) (limited to 'ui/app/components/send/send-content') 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 96a6de424..a3bc73256 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 @@ -16,12 +16,6 @@ import { getRenderableEstimateDataForSmallButtonsFromGWEI, getDefaultActiveButtonIndex, } from '../../../../selectors/custom-gas' -import { - decGWEIToHexWEI, - decimalToHex, - convertGasPriceForInputs, - convertGasLimitForInputs, -} from '../../../../helpers/conversions.util' import { showGasButtonGroup, } from '../../../../ducks/send.duck' @@ -33,7 +27,6 @@ import { 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) @@ -41,9 +34,8 @@ export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(SendGasR function mapStateToProps (state) { const gasButtonInfo = getRenderableEstimateDataForSmallButtonsFromGWEI(state) const gasPrice = getGasPrice(state) + const gasLimit = getGasLimit(state) const activeButtonIndex = getDefaultActiveButtonIndex(gasButtonInfo, gasPrice) - const renderableGasPrice = convertGasPriceForInputs(gasPrice) - const renderableGasLimit = convertGasLimitForInputs(getGasLimit(state)) const gasTotal = getGasTotal(state) const conversionRate = getConversionRate(state) @@ -70,8 +62,8 @@ function mapStateToProps (state) { }, gasButtonGroupShown: getGasButtonGroupShown(state), advancedInlineGasShown: getAdvancedInlineGasShown(state), - gasPrice: renderableGasPrice, - gasLimit: renderableGasLimit, + gasPrice, + gasLimit, insufficientBalance, } } @@ -80,15 +72,13 @@ function mapDispatchToProps (dispatch) { return { showCustomizeGasModal: () => dispatch(showModal({ name: 'CUSTOMIZE_GAS', hideBasic: true })), setGasPrice: (newPrice, gasLimit) => { - newPrice = decGWEIToHexWEI(newPrice) dispatch(setGasPrice(newPrice)) - dispatch(setCustomGasPrice(addHexPrefix(newPrice))) + dispatch(setCustomGasPrice(newPrice)) dispatch(setGasTotal(calcGasTotal(gasLimit, newPrice))) }, setGasLimit: (newLimit, gasPrice) => { - newLimit = decimalToHex(newLimit) dispatch(setGasLimit(newLimit)) - dispatch(setCustomGasLimit(addHexPrefix(newLimit.toString(16)))) + dispatch(setCustomGasLimit(newLimit)) 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 0d5dc4117..723c406f7 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 @@ -66,12 +66,6 @@ proxyquire('../send-gas-row.container.js', { }, '../../../../ducks/send.duck': sendDuckSpies, '../../../../ducks/gas.duck': gasDuckSpies, - '../../../../helpers/conversions.util': { - convertGasPriceForInputs: str => str + '*', - convertGasLimitForInputs: str => str + '**', - decGWEIToHexWEI: str => '0x' + str + '000', - decimalToHex: str => '0x' + str, - }, }) describe('send-gas-row container', () => { @@ -93,8 +87,8 @@ describe('send-gas-row container', () => { }, gasButtonGroupShown: `mockGetGasButtonGroupShown:mockState`, advancedInlineGasShown: 'mockAdvancedInlineGasShown:mockState', - gasLimit: 'mockGasLimit:mockState**', - gasPrice: 'mockGasPrice:mockState*', + gasLimit: 'mockGasLimit:mockState', + gasPrice: 'mockGasPrice:mockState', insufficientBalance: false, }) }) @@ -127,10 +121,10 @@ describe('send-gas-row container', () => { mapDispatchToPropsObject.setGasPrice('mockNewPrice', 'mockLimit') 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.equal(actionSpies.setGasPrice.getCall(0).args[0], 'mockNewPrice') + assert.equal(gasDuckSpies.setCustomGasPrice.getCall(0).args[0], 'mockNewPrice') assert(actionSpies.setGasTotal.calledOnce) - assert.equal(actionSpies.setGasTotal.getCall(0).args[0], 'mockLimit0xmockNewPrice000') + assert.equal(actionSpies.setGasTotal.getCall(0).args[0], 'mockLimitmockNewPrice') }) }) @@ -139,10 +133,10 @@ describe('send-gas-row container', () => { mapDispatchToPropsObject.setGasLimit('mockNewLimit', 'mockPrice') 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.equal(actionSpies.setGasLimit.getCall(0).args[0], 'mockNewLimit') + assert.equal(gasDuckSpies.setCustomGasLimit.getCall(0).args[0], 'mockNewLimit') assert(actionSpies.setGasTotal.calledOnce) - assert.equal(actionSpies.setGasTotal.getCall(0).args[0], '0xmockNewLimitmockPrice') + assert.equal(actionSpies.setGasTotal.getCall(0).args[0], 'mockNewLimitmockPrice') }) }) -- cgit v1.2.3