From 64644ad3804c2217634147658eeea15ef710a283 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Thu, 1 Jul 2021 09:36:48 -0500 Subject: [PATCH] Implement Dapp Acknowledgement screen for editing gas (#11424) --- app/_locales/en/messages.json | 7 ++ .../edit-gas-display.component.js | 65 +++++++++++++++---- .../edit-gas-display.stories.js | 11 ++++ ui/components/app/edit-gas-display/index.scss | 14 ++++ 4 files changed, 85 insertions(+), 12 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 316e8ec2d..b7d9c9469 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -837,6 +837,13 @@ "functionType": { "message": "Function Type" }, + "gasDisplayAcknowledgeDappButtonText": { + "message": "Edit app suggestion" + }, + "gasDisplayDappWarning": { + "message": "This gas fee has been suggested by the app $1. It’s using legacy gas estimation which may be inaccurate. However, editing this gas fee may cause unintended consequences. Please reach out to the app team if you have questions.", + "description": "$1 represents the Dapp's origin" + }, "gasFee": { "message": "Gas Fee" }, diff --git a/ui/components/app/edit-gas-display/edit-gas-display.component.js b/ui/components/app/edit-gas-display/edit-gas-display.component.js index 710bc1323..4699ea0e6 100644 --- a/ui/components/app/edit-gas-display/edit-gas-display.component.js +++ b/ui/components/app/edit-gas-display/edit-gas-display.component.js @@ -1,6 +1,7 @@ import React, { useState, useContext } from 'react'; import PropTypes from 'prop-types'; +import Button from '../../ui/button'; import Typography from '../../ui/typography/typography'; import { COLORS, @@ -21,11 +22,20 @@ export default function EditGasDisplay({ type, showEducationButton, onEducationClick, + dappSuggestedGasFee, + dappOrigin, }) { const t = useContext(I18nContext); const [warning] = useState(null); const [showAdvancedForm, setShowAdvancedForm] = useState(false); + const [ + dappSuggestedGasFeeAcknowledged, + setDappSuggestedGasFeeAcknowledged, + ] = useState(false); + + const requireDappAcknowledgement = + dappSuggestedGasFee && !dappSuggestedGasFeeAcknowledged; return (
@@ -38,6 +48,15 @@ export default function EditGasDisplay({ />
)} + {requireDappAcknowledgement && ( +
+ +
+ )} {type === 'speed-up' && (
)} + - - {!alwaysShowForm && ( + + {requireDappAcknowledgement && ( + + )} + + {!requireDappAcknowledgement && ( + + )} + {!requireDappAcknowledgement && !alwaysShowForm && ( )} - {(alwaysShowForm || showAdvancedForm) && } + {((!requireDappAcknowledgement && alwaysShowForm) || + showAdvancedForm) && } - {showEducationButton && ( + {!requireDappAcknowledgement && showEducationButton && (
); }; + +export const withDappSuggestedGas = () => { + return ( +
+ +
+ ); +}; diff --git a/ui/components/app/edit-gas-display/index.scss b/ui/components/app/edit-gas-display/index.scss index 95326868c..6c822a401 100644 --- a/ui/components/app/edit-gas-display/index.scss +++ b/ui/components/app/edit-gas-display/index.scss @@ -16,6 +16,20 @@ } } + &__dapp-acknowledgement-warning { + margin-bottom: 20px; + } + + button.edit-gas-display__dapp-acknowledgement-button { + margin: 0 auto; + display: block; + color: $secondary-1; + border: 1px solid $secondary-1; + text-transform: unset; + width: auto; + background: transparent; + } + .radio-group { margin: 20px auto; }