1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00

Hide gas estimate on non-main network (#9189)

* hide advance gas on non mainnet

* hide edit gas button on non mainnet
This commit is contained in:
Patryk Łucka 2020-08-19 16:03:15 +02:00 committed by GitHub
parent a8199be553
commit 9a3c559b3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 13 deletions

View File

@ -22,12 +22,16 @@ const ConfirmDetailRow = (props) => {
{ label } { label }
</div> </div>
<div className="confirm-detail-row__details"> <div className="confirm-detail-row__details">
{
headerText && (
<div <div
className={classnames('confirm-detail-row__header-text', headerTextClassName)} className={classnames('confirm-detail-row__header-text', headerTextClassName)}
onClick={() => onHeaderClick && onHeaderClick()} onClick={() => onHeaderClick && onHeaderClick()}
> >
{ headerText } { headerText }
</div> </div>
)
}
{ {
primaryText primaryText
? ( ? (

View File

@ -97,6 +97,7 @@ export default class ConfirmTransactionBase extends Component {
hideSenderToRecipient: PropTypes.bool, hideSenderToRecipient: PropTypes.bool,
showAccountInHeader: PropTypes.bool, showAccountInHeader: PropTypes.bool,
mostRecentOverviewPage: PropTypes.string.isRequired, mostRecentOverviewPage: PropTypes.string.isRequired,
isMainnet: PropTypes.bool,
} }
state = { state = {
@ -236,12 +237,15 @@ export default class ConfirmTransactionBase extends Component {
hideFiatConversion, hideFiatConversion,
nextNonce, nextNonce,
getNextNonce, getNextNonce,
isMainnet,
} = this.props } = this.props
if (hideDetails) { if (hideDetails) {
return null return null
} }
const notMainnetOrTest = !(isMainnet || process.env.IN_TEST)
return ( return (
detailsComponent || ( detailsComponent || (
<div className="confirm-page-container-content__details"> <div className="confirm-page-container-content__details">
@ -249,12 +253,12 @@ export default class ConfirmTransactionBase extends Component {
<ConfirmDetailRow <ConfirmDetailRow
label="Gas Fee" label="Gas Fee"
value={hexTransactionFee} value={hexTransactionFee}
headerText="Edit" headerText={notMainnetOrTest ? '' : 'Edit'}
headerTextClassName="confirm-detail-row__header-text--edit" headerTextClassName={notMainnetOrTest ? '' : 'confirm-detail-row__header-text--edit'}
onHeaderClick={() => this.handleEditGas()} onHeaderClick={notMainnetOrTest ? null : () => this.handleEditGas()}
secondaryText={hideFiatConversion ? this.context.t('noConversionRateAvailable') : ''} secondaryText={hideFiatConversion ? this.context.t('noConversionRateAvailable') : ''}
/> />
{advancedInlineGasShown {advancedInlineGasShown || notMainnetOrTest
? ( ? (
<AdvancedGasInputs <AdvancedGasInputs
updateCustomGasPrice={(newGasPrice) => updateGasAndCalculate({ ...customGas, gasPrice: newGasPrice })} updateCustomGasPrice={(newGasPrice) => updateGasAndCalculate({ ...customGas, gasPrice: newGasPrice })}

View File

@ -177,6 +177,7 @@ const mapStateToProps = (state, ownProps) => {
transactionCategory, transactionCategory,
nextNonce, nextNonce,
mostRecentOverviewPage: getMostRecentOverviewPage(state), mostRecentOverviewPage: getMostRecentOverviewPage(state),
isMainnet,
} }
} }

View File

@ -26,6 +26,7 @@ export default class SendGasRow extends Component {
gasPrice: PropTypes.string, gasPrice: PropTypes.string,
gasLimit: PropTypes.string, gasLimit: PropTypes.string,
insufficientBalance: PropTypes.bool, insufficientBalance: PropTypes.bool,
isMainnet: PropTypes.bool,
} }
static contextTypes = { static contextTypes = {
@ -35,7 +36,11 @@ export default class SendGasRow extends Component {
renderAdvancedOptionsButton () { renderAdvancedOptionsButton () {
const { metricsEvent } = this.context 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 ( return (
<div <div
className="advanced-gas-options-btn" className="advanced-gas-options-btn"
@ -87,6 +92,7 @@ export default class SendGasRow extends Component {
gasPrice, gasPrice,
gasLimit, gasLimit,
insufficientBalance, insufficientBalance,
isMainnet,
} = this.props } = this.props
const { metricsEvent } = this.context const { metricsEvent } = this.context
@ -140,8 +146,8 @@ export default class SendGasRow extends Component {
{ this.renderAdvancedOptionsButton() } { this.renderAdvancedOptionsButton() }
</div> </div>
) )
// Tests should behave in same way as mainnet, but are using Localhost
if (advancedInlineGasShown) { if (advancedInlineGasShown || (!isMainnet && !process.env.IN_TEST)) {
return advancedGasInputs return advancedGasInputs
} else if (gasButtonGroupShown) { } else if (gasButtonGroupShown) {
return gasPriceButtonGroup return gasPriceButtonGroup

View File

@ -17,6 +17,7 @@ import {
getBasicGasEstimateLoadingStatus, getBasicGasEstimateLoadingStatus,
getRenderableEstimateDataForSmallButtonsFromGWEI, getRenderableEstimateDataForSmallButtonsFromGWEI,
getDefaultActiveButtonIndex, getDefaultActiveButtonIndex,
getIsMainnet,
} from '../../../../selectors' } from '../../../../selectors'
import { import {
isBalanceSufficient, isBalanceSufficient,
@ -74,6 +75,7 @@ function mapStateToProps (state) {
maxModeOn: getSendMaxModeState(state), maxModeOn: getSendMaxModeState(state),
sendToken: getSendToken(state), sendToken: getSendToken(state),
tokenBalance: getTokenBalance(state), tokenBalance: getTokenBalance(state),
isMainnet: getIsMainnet(state),
} }
} }

View File

@ -34,6 +34,7 @@ describe('SendGasRow Component', function () {
}} }}
/> />
), { context: { t: (str) => str + '_t', metricsEvent: () => ({}) } }) ), { context: { t: (str) => str + '_t', metricsEvent: () => ({}) } })
wrapper.setProps({ isMainnet: true })
}) })
afterEach(function () { afterEach(function () {