1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +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 }
</div>
<div className="confirm-detail-row__details">
<div
className={classnames('confirm-detail-row__header-text', headerTextClassName)}
onClick={() => onHeaderClick && onHeaderClick()}
>
{ headerText }
</div>
{
headerText && (
<div
className={classnames('confirm-detail-row__header-text', headerTextClassName)}
onClick={() => onHeaderClick && onHeaderClick()}
>
{ headerText }
</div>
)
}
{
primaryText
? (

View File

@ -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 || (
<div className="confirm-page-container-content__details">
@ -249,12 +253,12 @@ export default class ConfirmTransactionBase extends Component {
<ConfirmDetailRow
label="Gas Fee"
value={hexTransactionFee}
headerText="Edit"
headerTextClassName="confirm-detail-row__header-text--edit"
onHeaderClick={() => 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
? (
<AdvancedGasInputs
updateCustomGasPrice={(newGasPrice) => updateGasAndCalculate({ ...customGas, gasPrice: newGasPrice })}

View File

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

View File

@ -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 (
<div
className="advanced-gas-options-btn"
@ -87,6 +92,7 @@ export default class SendGasRow extends Component {
gasPrice,
gasLimit,
insufficientBalance,
isMainnet,
} = this.props
const { metricsEvent } = this.context
@ -140,8 +146,8 @@ export default class SendGasRow extends Component {
{ this.renderAdvancedOptionsButton() }
</div>
)
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

View File

@ -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),
}
}

View File

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