From b9f5f1c2c2bea8c4ef178cc2a55a14467b952e84 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Wed, 19 Aug 2020 17:19:59 -0300 Subject: [PATCH] Hide ETH Gas Station stimates on non-main network (#9277) * Hide gas estimate on non-main network (#9189) * Update v8.0.9 changelog --- CHANGELOG.md | 1 + .../confirm-detail-row.component.js | 16 ++++++++++------ .../confirm-transaction-base.component.js | 12 ++++++++---- .../confirm-transaction-base.container.js | 1 + .../send-gas-row/send-gas-row.component.js | 12 +++++++++--- .../send-gas-row/send-gas-row.container.js | 2 ++ .../tests/send-gas-row-component.test.js | 1 + 7 files changed, 32 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f841d700b..f4f649f0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [#9228](https://github.com/MetaMask/metamask-extension/pull/9228): Move transaction confirmation footer buttons to scrollable area - [#9256](https://github.com/MetaMask/metamask-extension/pull/9256): Handle non-String web3 property access - [#9266](https://github.com/MetaMask/metamask-extension/pull/9266): Use @metamask/controllers@2.0.5 +- [#9189](https://github.com/MetaMask/metamask-extension/pull/9189): Hide ETH Gas Station estimates on non-main network ## 8.0.8 Fri Aug 14 2020 - [#9211](https://github.com/MetaMask/metamask-extension/pull/9211): Fix Etherscan redirect on notification click diff --git a/ui/app/components/app/confirm-page-container/confirm-detail-row/confirm-detail-row.component.js b/ui/app/components/app/confirm-page-container/confirm-detail-row/confirm-detail-row.component.js index d4b6cee68..0cdb53a32 100644 --- a/ui/app/components/app/confirm-page-container/confirm-detail-row/confirm-detail-row.component.js +++ b/ui/app/components/app/confirm-page-container/confirm-detail-row/confirm-detail-row.component.js @@ -22,12 +22,16 @@ const ConfirmDetailRow = (props) => { { label }
-
onHeaderClick && onHeaderClick()} - > - { headerText } -
+ { + headerText && ( +
onHeaderClick && onHeaderClick()} + > + { headerText } +
+ ) + } { primaryText ? ( diff --git a/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js index 7f8df4168..3b6a7ef9a 100644 --- a/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js +++ b/ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js @@ -97,6 +97,7 @@ export default class ConfirmTransactionBase extends Component { hideSenderToRecipient: PropTypes.bool, showAccountInHeader: PropTypes.bool, mostRecentOverviewPage: PropTypes.string.isRequired, + isMainnet: PropTypes.bool, } state = { @@ -236,12 +237,15 @@ export default class ConfirmTransactionBase extends Component { hideFiatConversion, nextNonce, getNextNonce, + isMainnet, } = this.props if (hideDetails) { return null } + const notMainnetOrTest = !(isMainnet || process.env.IN_TEST) + return ( detailsComponent || (
@@ -249,12 +253,12 @@ export default class ConfirmTransactionBase extends Component { this.handleEditGas()} + headerText={notMainnetOrTest ? '' : 'Edit'} + headerTextClassName={notMainnetOrTest ? '' : 'confirm-detail-row__header-text--edit'} + onHeaderClick={notMainnetOrTest ? null : () => this.handleEditGas()} secondaryText={hideFiatConversion ? this.context.t('noConversionRateAvailable') : ''} /> - {advancedInlineGasShown + {advancedInlineGasShown || notMainnetOrTest ? ( updateGasAndCalculate({ ...customGas, gasPrice: newGasPrice })} diff --git a/ui/app/pages/confirm-transaction-base/confirm-transaction-base.container.js b/ui/app/pages/confirm-transaction-base/confirm-transaction-base.container.js index 11fb474fc..096593792 100644 --- a/ui/app/pages/confirm-transaction-base/confirm-transaction-base.container.js +++ b/ui/app/pages/confirm-transaction-base/confirm-transaction-base.container.js @@ -180,6 +180,7 @@ const mapStateToProps = (state, ownProps) => { transactionCategory, nextNonce, mostRecentOverviewPage: getMostRecentOverviewPage(state), + isMainnet, } } diff --git a/ui/app/pages/send/send-content/send-gas-row/send-gas-row.component.js b/ui/app/pages/send/send-content/send-gas-row/send-gas-row.component.js index 5f593e01b..9388cd2d1 100644 --- a/ui/app/pages/send/send-content/send-gas-row/send-gas-row.component.js +++ b/ui/app/pages/send/send-content/send-gas-row/send-gas-row.component.js @@ -26,6 +26,7 @@ export default class SendGasRow extends Component { gasPrice: PropTypes.string, gasLimit: PropTypes.string, insufficientBalance: PropTypes.bool, + isMainnet: PropTypes.bool, } static contextTypes = { @@ -35,7 +36,11 @@ export default class SendGasRow extends Component { renderAdvancedOptionsButton () { const { metricsEvent } = this.context - const { showCustomizeGasModal } = this.props + const { showCustomizeGasModal, isMainnet } = this.props + // Tests should behave in same way as mainnet, but are using Localhost + if (!isMainnet && !process.env.IN_TEST) { + return null + } return (
) - - if (advancedInlineGasShown) { + // Tests should behave in same way as mainnet, but are using Localhost + if (advancedInlineGasShown || (!isMainnet && !process.env.IN_TEST)) { return advancedGasInputs } else if (gasButtonGroupShown) { return gasPriceButtonGroup diff --git a/ui/app/pages/send/send-content/send-gas-row/send-gas-row.container.js b/ui/app/pages/send/send-content/send-gas-row/send-gas-row.container.js index e38a53227..7510588a4 100644 --- a/ui/app/pages/send/send-content/send-gas-row/send-gas-row.container.js +++ b/ui/app/pages/send/send-content/send-gas-row/send-gas-row.container.js @@ -17,6 +17,7 @@ import { getBasicGasEstimateLoadingStatus, getRenderableEstimateDataForSmallButtonsFromGWEI, getDefaultActiveButtonIndex, + getIsMainnet, } from '../../../../selectors' import { isBalanceSufficient, @@ -74,6 +75,7 @@ function mapStateToProps (state) { maxModeOn: getSendMaxModeState(state), sendToken: getSendToken(state), tokenBalance: getTokenBalance(state), + isMainnet: getIsMainnet(state), } } diff --git a/ui/app/pages/send/send-content/send-gas-row/tests/send-gas-row-component.test.js b/ui/app/pages/send/send-content/send-gas-row/tests/send-gas-row-component.test.js index b5b1b7f53..1664c3211 100644 --- a/ui/app/pages/send/send-content/send-gas-row/tests/send-gas-row-component.test.js +++ b/ui/app/pages/send/send-content/send-gas-row/tests/send-gas-row-component.test.js @@ -34,6 +34,7 @@ describe('SendGasRow Component', function () { }} /> ), { context: { t: (str) => str + '_t', metricsEvent: () => ({}) } }) + wrapper.setProps({ isMainnet: true }) }) afterEach(function () {