diff options
author | Whymarrh Whitby <whymarrh.whitby@gmail.com> | 2019-02-08 21:50:25 +0800 |
---|---|---|
committer | Whymarrh Whitby <whymarrh.whitby@gmail.com> | 2019-02-09 03:14:45 +0800 |
commit | 57ead4914f6f9fd1fe47b865559e4908a36f6a8a (patch) | |
tree | e9a8fedb5f7abd87e923726b070f92b9b792b4b0 /ui/app/components/send/send-content | |
parent | 57d458233b189e6752acacbaed97e8fce092b95e (diff) | |
download | tangerine-wallet-browser-57ead4914f6f9fd1fe47b865559e4908a36f6a8a.tar tangerine-wallet-browser-57ead4914f6f9fd1fe47b865559e4908a36f6a8a.tar.gz tangerine-wallet-browser-57ead4914f6f9fd1fe47b865559e4908a36f6a8a.tar.bz2 tangerine-wallet-browser-57ead4914f6f9fd1fe47b865559e4908a36f6a8a.tar.lz tangerine-wallet-browser-57ead4914f6f9fd1fe47b865559e4908a36f6a8a.tar.xz tangerine-wallet-browser-57ead4914f6f9fd1fe47b865559e4908a36f6a8a.tar.zst tangerine-wallet-browser-57ead4914f6f9fd1fe47b865559e4908a36f6a8a.zip |
Fix inline advanced gas editing
Diffstat (limited to 'ui/app/components/send/send-content')
-rw-r--r-- | ui/app/components/send/send-content/send-gas-row/send-gas-row.container.js | 20 | ||||
-rw-r--r-- | ui/app/components/send/send-content/send-gas-row/tests/send-gas-row-container.test.js | 22 |
2 files changed, 13 insertions, 29 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..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 @@ -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,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') }) }) |