From 1145a0a9ad46fda5fb9a7ad9cf5cf062c574691d Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Wed, 12 Dec 2018 11:24:03 -0330 Subject: Ensures that advanced tab gas limit reflects tx gas limit --- .../gas-modal-page-container/gas-modal-page-container.container.js | 4 ++-- ui/app/ducks/gas.duck.js | 2 +- ui/app/ducks/tests/gas-duck.test.js | 2 +- ui/app/selectors/custom-gas.js | 5 ++--- ui/app/selectors/tests/custom-gas.test.js | 5 +---- 5 files changed, 7 insertions(+), 11 deletions(-) (limited to 'ui/app') diff --git a/ui/app/components/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js b/ui/app/components/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js index dde0f2b94..1671f95fa 100644 --- a/ui/app/components/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js +++ b/ui/app/components/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js @@ -76,7 +76,7 @@ const mapStateToProps = (state, ownProps) => { const customGasTotal = calcGasTotal(customModalGasLimitInHex, customModalGasPriceInHex) - const gasButtonInfo = getRenderableBasicEstimateData(state) + const gasButtonInfo = getRenderableBasicEstimateData(state, customModalGasLimitInHex) const currentCurrency = getCurrentCurrency(state) const conversionRate = getConversionRate(state) @@ -235,7 +235,7 @@ function getTxParams (state, transactionId) { const { txParams: pendingTxParams } = pendingTransaction || {} return txData.txParams || pendingTxParams || { from: send.from, - gas: send.gasLimit, + gas: send.gasLimit || '0x5208', gasPrice: send.gasPrice || getFastPriceEstimateInHexWEI(state, true), to: send.to, value: getSelectedToken(state) ? '0x0' : send.amount, diff --git a/ui/app/ducks/gas.duck.js b/ui/app/ducks/gas.duck.js index ee235a757..957b00163 100644 --- a/ui/app/ducks/gas.duck.js +++ b/ui/app/ducks/gas.duck.js @@ -29,7 +29,7 @@ const SET_BASIC_PRICE_ESTIMATES_LAST_RETRIEVED = 'metamask/gas/SET_BASIC_PRICE_E const initState = { customData: { price: null, - limit: '0x5208', + limit: null, }, basicEstimates: { average: null, diff --git a/ui/app/ducks/tests/gas-duck.test.js b/ui/app/ducks/tests/gas-duck.test.js index 3637d8f29..cd963aed4 100644 --- a/ui/app/ducks/tests/gas-duck.test.js +++ b/ui/app/ducks/tests/gas-duck.test.js @@ -98,7 +98,7 @@ describe('Gas Duck', () => { const initState = { customData: { price: null, - limit: '0x5208', + limit: null, }, basicEstimates: { average: null, diff --git a/ui/app/selectors/custom-gas.js b/ui/app/selectors/custom-gas.js index 91c9109a5..f9cedf9fb 100644 --- a/ui/app/selectors/custom-gas.js +++ b/ui/app/selectors/custom-gas.js @@ -221,11 +221,10 @@ function getGasPriceInHexWei (price) { )(price) } -function getRenderableBasicEstimateData (state) { +function getRenderableBasicEstimateData (state, gasLimit) { if (getBasicGasEstimateLoadingStatus(state)) { return [] } - const gasLimit = state.metamask.send.gasLimit || getCustomGasLimit(state) const conversionRate = state.metamask.conversionRate const currentCurrency = getCurrentCurrency(state) const { @@ -270,7 +269,7 @@ function getRenderableEstimateDataForSmallButtonsFromGWEI (state) { if (getBasicGasEstimateLoadingStatus(state)) { return [] } - const gasLimit = state.metamask.send.gasLimit || getCustomGasLimit(state) + const gasLimit = state.metamask.send.gasLimit || getCustomGasLimit(state) || '0x5208' const conversionRate = state.metamask.conversionRate const currentCurrency = getCurrentCurrency(state) const { diff --git a/ui/app/selectors/tests/custom-gas.test.js b/ui/app/selectors/tests/custom-gas.test.js index ebc300160..e43fd0d74 100644 --- a/ui/app/selectors/tests/custom-gas.test.js +++ b/ui/app/selectors/tests/custom-gas.test.js @@ -102,9 +102,6 @@ describe('custom-gas selectors', () => { metamask: { conversionRate: 255.71, currentCurrency: 'usd', - send: { - gasLimit: '0x5208', - }, }, gas: { basicEstimates: { @@ -168,7 +165,7 @@ describe('custom-gas selectors', () => { it('should return renderable data about basic estimates', () => { tests.forEach(test => { assert.deepEqual( - getRenderableBasicEstimateData(test.mockState), + getRenderableBasicEstimateData(test.mockState, '0x5208'), test.expectedResult ) }) -- cgit