diff options
Diffstat (limited to 'ui/app/components/send')
-rw-r--r-- | ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js | 28 | ||||
-rw-r--r-- | ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-container.test.js | 22 |
2 files changed, 19 insertions, 31 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 96a6de424..50cb47178 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 @@ -17,12 +17,6 @@ import { getDefaultActiveButtonIndex, } from '../../../../selectors/custom-gas' import { - decGWEIToHexWEI, - decimalToHex, - convertGasPriceForInputs, - convertGasLimitForInputs, -} from '../../../../helpers/conversions.util' -import { showGasButtonGroup, } from '../../../../ducks/send.duck' import { @@ -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,16 +72,18 @@ 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(setGasTotal(calcGasTotal(gasLimit, newPrice))) + dispatch(setCustomGasPrice(newPrice)) + if (gasLimit) { + 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))) + dispatch(setCustomGasLimit(newLimit)) + if (gasPrice) { + dispatch(setGasTotal(calcGasTotal(newLimit, gasPrice))) + } }, showGasButtonGroup: () => dispatch(showGasButtonGroup()), resetCustomData: () => dispatch(resetCustomData()), 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') }) }) |