diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 4d992ed9b..868a077a7 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -763,6 +763,12 @@ "gasPrice": { "message": "Gas Price (GWEI)" }, + "gasPriceExcessive": { + "message": "Your gas fee is set unnecessarily high. Consider lowering the amount." + }, + "gasPriceExcessiveInput": { + "message": "Gas Price Is Excessive" + }, "gasPriceExtremelyLow": { "message": "Gas Price Extremely Low" }, diff --git a/ui/app/components/app/gas-customization/advanced-gas-inputs/advanced-gas-inputs.component.js b/ui/app/components/app/gas-customization/advanced-gas-inputs/advanced-gas-inputs.component.js index e394b453a..a775cec65 100644 --- a/ui/app/components/app/gas-customization/advanced-gas-inputs/advanced-gas-inputs.component.js +++ b/ui/app/components/app/gas-customization/advanced-gas-inputs/advanced-gas-inputs.component.js @@ -20,10 +20,12 @@ export default class AdvancedGasInputs extends Component { isSpeedUp: PropTypes.bool, customGasLimitMessage: PropTypes.string, minimumGasLimit: PropTypes.number, + customPriceIsExcessive: PropTypes.bool, }; static defaultProps = { minimumGasLimit: Number(MIN_GAS_LIMIT_DEC), + customPriceIsExcessive: false, }; constructor(props) { @@ -75,6 +77,7 @@ export default class AdvancedGasInputs extends Component { customPriceIsSafe, isSpeedUp, gasPrice, + customPriceIsExcessive, }) { const { t } = this.context; @@ -93,6 +96,11 @@ export default class AdvancedGasInputs extends Component { errorText: t('gasPriceExtremelyLow'), errorType: 'warning', }; + } else if (customPriceIsExcessive) { + return { + errorText: t('gasPriceExcessiveInput'), + errorType: 'error', + }; } return {}; @@ -185,6 +193,7 @@ export default class AdvancedGasInputs extends Component { isSpeedUp, customGasLimitMessage, minimumGasLimit, + customPriceIsExcessive, } = this.props; const { gasPrice, gasLimit } = this.state; @@ -196,6 +205,7 @@ export default class AdvancedGasInputs extends Component { customPriceIsSafe, isSpeedUp, gasPrice, + customPriceIsExcessive, }); const gasPriceErrorComponent = gasPriceErrorType ? (
diff --git a/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.component.js b/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.component.js index 4c27f9900..f57cce92d 100644 --- a/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.component.js +++ b/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.component.js @@ -35,6 +35,7 @@ export default class GasModalPageContainer extends Component { isSpeedUp: PropTypes.bool, isRetry: PropTypes.bool, disableSave: PropTypes.bool, + customPriceIsExcessive: PropTypes.bool.isRequired, }; componentDidMount() { @@ -57,6 +58,7 @@ export default class GasModalPageContainer extends Component { customPriceIsSafe, isSpeedUp, isRetry, + customPriceIsExcessive, infoRowProps: { transactionFee }, } = this.props; @@ -71,6 +73,7 @@ export default class GasModalPageContainer extends Component { customPriceIsSafe={customPriceIsSafe} isSpeedUp={isSpeedUp} isRetry={isRetry} + customPriceIsExcessive={customPriceIsExcessive} /> ); } diff --git a/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js b/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js index fc1b111b9..136fdccc8 100644 --- a/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js +++ b/ui/app/components/app/gas-customization/gas-modal-page-container/gas-modal-page-container.container.js @@ -37,6 +37,7 @@ import { getTokenBalance, getSendMaxModeState, getAveragePriceEstimateInHexWEI, + isCustomPriceExcessive, } from '../../../../selectors'; import { @@ -141,6 +142,7 @@ const mapStateToProps = (state, ownProps) => { customGasTotal, newTotalFiat, customPriceIsSafe: isCustomPriceSafe(state), + customPriceIsExcessive: isCustomPriceExcessive(state), maxModeOn, gasPriceButtonGroupProps: { buttonDataLoading, diff --git a/ui/app/components/app/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js b/ui/app/components/app/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js index 100e30780..0ba5aabbc 100644 --- a/ui/app/components/app/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js +++ b/ui/app/components/app/gas-customization/gas-modal-page-container/tests/gas-modal-page-container-container.test.js @@ -126,6 +126,7 @@ describe('gas-modal-page-container container', function () { conversionRate: 50, customModalGasLimitInHex: 'aaaaaaaa', customModalGasPriceInHex: 'ffffffff', + customPriceIsExcessive: false, customGasTotal: 'aaaaaaa955555556', customPriceIsSafe: true, gasPriceButtonGroupProps: { diff --git a/ui/app/pages/send/send-content/send-content.component.js b/ui/app/pages/send/send-content/send-content.component.js index 7b38d14ae..6f4fd7924 100644 --- a/ui/app/pages/send/send-content/send-content.component.js +++ b/ui/app/pages/send/send-content/send-content.component.js @@ -20,15 +20,17 @@ export default class SendContent extends Component { isOwnedAccount: PropTypes.bool, warning: PropTypes.string, error: PropTypes.string, + gasIsExcessive: PropTypes.bool.isRequired, }; updateGas = (updateData) => this.props.updateGas(updateData); render() { - const { warning, error } = this.props; + const { warning, error, gasIsExcessive } = this.props; return (