1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

add space between sentences in insufficient currency warning (#14019)

* add space between sentences in insufficient currency warning and add link to buy modal for all buyable networks
This commit is contained in:
Alex Donesky 2022-03-25 09:02:08 -05:00 committed by GitHub
parent 6688117c7e
commit 3e2506b2e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 112 additions and 130 deletions

View File

@ -405,6 +405,10 @@
"buy": { "buy": {
"message": "Buy" "message": "Buy"
}, },
"buyAsset": {
"message": "Buy $1",
"description": "$1 is the ticker symbol of a an asset the user is being prompted to purchase"
},
"buyCryptoWithMoonPay": { "buyCryptoWithMoonPay": {
"message": "Buy $1 with MoonPay", "message": "Buy $1 with MoonPay",
"description": "$1 represents the cypto symbol to be purchased" "description": "$1 represents the cypto symbol to be purchased"
@ -420,13 +424,6 @@
"message": "Transak supports credit & debit cards, Apple Pay, MobiKwik, and bank transfers (depending on location) in 100+ countries. $1 deposits directly into your MetaMask account.", "message": "Transak supports credit & debit cards, Apple Pay, MobiKwik, and bank transfers (depending on location) in 100+ countries. $1 deposits directly into your MetaMask account.",
"description": "$1 represents the crypto symbol to be purchased" "description": "$1 represents the crypto symbol to be purchased"
}, },
"buyEth": {
"message": "Buy ETH"
},
"buyOther": {
"message": "Buy $1 or deposit from another account.",
"description": "$1 is a token symbol"
},
"buyWithWyre": { "buyWithWyre": {
"message": "Buy ETH with Wyre" "message": "Buy ETH with Wyre"
}, },
@ -1525,9 +1522,13 @@
"insufficientBalance": { "insufficientBalance": {
"message": "Insufficient balance." "message": "Insufficient balance."
}, },
"insufficientCurrency": { "insufficientCurrencyBuyOrDeposit": {
"message": "You do not have enough $1 in your account to pay for transaction fees on $2 network.", "message": "You do not have enough $1 in your account to pay for transaction fees on $2 network. $3 or deposit from another account.",
"description": "$1 is currency, $2 is network" "description": "$1 is the native currency of the network, $2 is the name of the current network, $3 is the key 'buy' + the ticker symbol of the native currency of the chain wrapped in a button"
},
"insufficientCurrencyDeposit": {
"message": "You do not have enough $1 in your account to pay for transaction fees on $2 network. Deposit $1 from another account.",
"description": "$1 is the native currency of the network, $2 is the name of the current network"
}, },
"insufficientFunds": { "insufficientFunds": {
"message": "Insufficient funds." "message": "Insufficient funds."
@ -2279,9 +2280,6 @@
"or": { "or": {
"message": "or" "message": "or"
}, },
"orDeposit": {
"message": "or deposit from another account."
},
"origin": { "origin": {
"message": "Origin" "message": "Origin"
}, },

View File

@ -10,7 +10,6 @@ import { INSUFFICIENT_FUNDS_ERROR_KEY } from '../../../../helpers/constants/erro
import Typography from '../../../ui/typography'; import Typography from '../../../ui/typography';
import { TYPOGRAPHY } from '../../../../helpers/constants/design-system'; import { TYPOGRAPHY } from '../../../../helpers/constants/design-system';
import { TRANSACTION_TYPES } from '../../../../../shared/constants/transaction'; import { TRANSACTION_TYPES } from '../../../../../shared/constants/transaction';
import { MAINNET_CHAIN_ID } from '../../../../../shared/constants/network';
import { ConfirmPageContainerSummary, ConfirmPageContainerWarning } from '.'; import { ConfirmPageContainerSummary, ConfirmPageContainerWarning } from '.';
@ -57,6 +56,7 @@ export default class ConfirmPageContainerContent extends Component {
showBuyModal: PropTypes.func, showBuyModal: PropTypes.func,
toAddress: PropTypes.string, toAddress: PropTypes.string,
transactionType: PropTypes.string, transactionType: PropTypes.string,
isBuyableChain: PropTypes.bool,
}; };
renderContent() { renderContent() {
@ -132,6 +132,7 @@ export default class ConfirmPageContainerContent extends Component {
showBuyModal, showBuyModal,
toAddress, toAddress,
transactionType, transactionType,
isBuyableChain,
} = this.props; } = this.props;
const primaryAction = hideUserAcknowledgedGasMissing const primaryAction = hideUserAcknowledgedGasMissing
@ -196,42 +197,38 @@ export default class ConfirmPageContainerContent extends Component {
)} )}
{showInsuffienctFundsError && ( {showInsuffienctFundsError && (
<div className="confirm-page-container-content__error-container"> <div className="confirm-page-container-content__error-container">
{currentTransaction.chainId === MAINNET_CHAIN_ID ? ( <ActionableMessage
<ActionableMessage className="actionable-message--warning"
className="actionable-message--warning" message={
message={ isBuyableChain ? (
<Typography variant={TYPOGRAPHY.H7} align="left"> <Typography variant={TYPOGRAPHY.H7} align="left">
{t('insufficientCurrency', [nativeCurrency, networkName])} {t('insufficientCurrencyBuyOrDeposit', [
<Button nativeCurrency,
key="link" networkName,
type="secondary"
className="confirm-page-container-content__link"
onClick={showBuyModal}
>
{t('buyEth')}
</Button>
{t('orDeposit')} <Button
type="inline"
className="confirm-page-container-content__link"
onClick={showBuyModal}
key={`${nativeCurrency}-buy-button`}
>
{t('buyAsset', [nativeCurrency])}
</Button>,
])}
</Typography> </Typography>
} ) : (
useIcon
iconFillColor="#d73a49"
type="danger"
/>
) : (
<ActionableMessage
className="actionable-message--warning"
message={
<Typography variant={TYPOGRAPHY.H7} align="left"> <Typography variant={TYPOGRAPHY.H7} align="left">
{t('insufficientCurrency', [nativeCurrency, networkName])} {t('insufficientCurrencyDeposit', [
{t('buyOther', [nativeCurrency])} nativeCurrency,
networkName,
])}
</Typography> </Typography>
} )
useIcon }
iconFillColor="#d73a49" useIcon
type="danger" iconFillColor="var(--color-error-default)"
/> type="danger"
)} />
</div> </div>
)} )}

View File

@ -100,12 +100,4 @@
&__total-value { &__total-value {
position: relative; position: relative;
} }
&__link {
background: transparent;
border: 0 transparent;
display: inline;
padding: 0;
font-size: $font-size-h7;
}
} }

View File

@ -4,10 +4,7 @@ import PropTypes from 'prop-types';
import { EDIT_GAS_MODES } from '../../../../shared/constants/gas'; import { EDIT_GAS_MODES } from '../../../../shared/constants/gas';
import { GasFeeContextProvider } from '../../../contexts/gasFee'; import { GasFeeContextProvider } from '../../../contexts/gasFee';
import { TRANSACTION_TYPES } from '../../../../shared/constants/transaction'; import { TRANSACTION_TYPES } from '../../../../shared/constants/transaction';
import { import { NETWORK_TO_NAME_MAP } from '../../../../shared/constants/network';
NETWORK_TO_NAME_MAP,
MAINNET_CHAIN_ID,
} from '../../../../shared/constants/network';
import { PageContainerFooter } from '../../ui/page-container'; import { PageContainerFooter } from '../../ui/page-container';
import Dialog from '../../ui/dialog'; import Dialog from '../../ui/dialog';
@ -98,6 +95,7 @@ export default class ConfirmPageContainer extends Component {
supportsEIP1559V2: PropTypes.bool, supportsEIP1559V2: PropTypes.bool,
nativeCurrency: PropTypes.string, nativeCurrency: PropTypes.string,
showBuyModal: PropTypes.func, showBuyModal: PropTypes.func,
isBuyableChain: PropTypes.bool,
}; };
render() { render() {
@ -152,6 +150,7 @@ export default class ConfirmPageContainer extends Component {
supportsEIP1559V2, supportsEIP1559V2,
nativeCurrency, nativeCurrency,
showBuyModal, showBuyModal,
isBuyableChain,
} = this.props; } = this.props;
const showAddToAddressDialog = const showAddToAddressDialog =
@ -258,47 +257,41 @@ export default class ConfirmPageContainer extends Component {
showBuyModal={showBuyModal} showBuyModal={showBuyModal}
toAddress={toAddress} toAddress={toAddress}
transactionType={currentTransaction.type} transactionType={currentTransaction.type}
isBuyableChain={isBuyableChain}
/> />
)} )}
{shouldDisplayWarning && errorKey === INSUFFICIENT_FUNDS_ERROR_KEY && ( {shouldDisplayWarning && errorKey === INSUFFICIENT_FUNDS_ERROR_KEY && (
<div className="confirm-approve-content__warning"> <div className="confirm-approve-content__warning">
{currentTransaction.chainId === MAINNET_CHAIN_ID ? ( <ActionableMessage
<ActionableMessage message={
message={ isBuyableChain ? (
<Typography variant={TYPOGRAPHY.H7} align="left"> <Typography variant={TYPOGRAPHY.H7} align="left">
{t('insufficientCurrency', [nativeCurrency, networkName])} {t('insufficientCurrencyBuyOrDeposit', [
<Button nativeCurrency,
type="link" networkName,
className="page-container__link" <Button
onClick={showBuyModal} type="inline"
> className="confirm-page-container-content__link"
{t('buyEth')} onClick={showBuyModal}
</Button> key={`${nativeCurrency}-buy-button`}
>
{t('orDeposit')} {t('buyAsset', [nativeCurrency])}
</Button>,
])}
</Typography> </Typography>
} ) : (
useIcon <Typography variant={TYPOGRAPHY.H7} align="left">
iconFillColor="#d73a49" {t('insufficientCurrencyDeposit', [
type="danger" nativeCurrency,
/> networkName,
) : ( ])}
<ActionableMessage
message={
<Typography
variant={TYPOGRAPHY.H7}
align="left"
margin={[0, 0]}
>
{t('insufficientCurrency', [nativeCurrency, networkName])}
{t('buyOther', [nativeCurrency])}
</Typography> </Typography>
} )
useIcon }
iconFillColor="#d73a49" useIcon
type="danger" iconFillColor="var(--color-error-default)"
/> type="danger"
)} />
</div> </div>
)} )}
{shouldDisplayWarning && errorKey !== INSUFFICIENT_FUNDS_ERROR_KEY && ( {shouldDisplayWarning && errorKey !== INSUFFICIENT_FUNDS_ERROR_KEY && (

View File

@ -1,13 +1,18 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { getAccountsWithLabels, getAddressBookEntry } from '../../../selectors'; import {
getAccountsWithLabels,
getAddressBookEntry,
getIsBuyableChain,
} from '../../../selectors';
import { showModal } from '../../../store/actions'; import { showModal } from '../../../store/actions';
import ConfirmPageContainer from './confirm-page-container.component'; import ConfirmPageContainer from './confirm-page-container.component';
function mapStateToProps(state, ownProps) { function mapStateToProps(state, ownProps) {
const to = ownProps.toAddress; const to = ownProps.toAddress;
const isBuyableChain = getIsBuyableChain(state);
const contact = getAddressBookEntry(state, to); const contact = getAddressBookEntry(state, to);
return { return {
isBuyableChain,
contact, contact,
toName: contact?.name || ownProps.toName, toName: contact?.name || ownProps.toName,
isOwnedAccount: getAccountsWithLabels(state) isOwnedAccount: getAccountsWithLabels(state)

View File

@ -302,7 +302,7 @@ input[type="submit"][disabled] {
.btn--inline { .btn--inline {
display: inline; display: inline;
padding: 0 4px; padding: 0;
font-size: inherit; font-size: inherit;
width: auto; width: auto;
color: var(--color-primary-default); color: var(--color-primary-default);

View File

@ -146,6 +146,7 @@ export default class ConfirmTransactionBase extends Component {
isMultiLayerFeeNetwork: PropTypes.bool, isMultiLayerFeeNetwork: PropTypes.bool,
eip1559V2Enabled: PropTypes.bool, eip1559V2Enabled: PropTypes.bool,
showBuyModal: PropTypes.func, showBuyModal: PropTypes.func,
isBuyableChain: PropTypes.bool,
}; };
state = { state = {
@ -326,6 +327,7 @@ export default class ConfirmTransactionBase extends Component {
isMultiLayerFeeNetwork, isMultiLayerFeeNetwork,
nativeCurrency, nativeCurrency,
showBuyModal, showBuyModal,
isBuyableChain,
} = this.props; } = this.props;
const { t } = this.context; const { t } = this.context;
const { userAcknowledgedGasMissing } = this.state; const { userAcknowledgedGasMissing } = this.state;
@ -585,11 +587,11 @@ export default class ConfirmTransactionBase extends Component {
this.setUserAcknowledgedGasMissing() this.setUserAcknowledgedGasMissing()
} }
userAcknowledgedGasMissing={userAcknowledgedGasMissing} userAcknowledgedGasMissing={userAcknowledgedGasMissing}
chainId={txData.chainId}
nativeCurrency={nativeCurrency} nativeCurrency={nativeCurrency}
networkName={networkName} networkName={networkName}
showBuyModal={showBuyModal} showBuyModal={showBuyModal}
type={txData.type} type={txData.type}
isBuyableChain={isBuyableChain}
/> />
<TransactionDetail <TransactionDetail
disabled={isDisabled()} disabled={isDisabled()}

View File

@ -33,6 +33,7 @@ import {
getTokenList, getTokenList,
getIsMultiLayerFeeNetwork, getIsMultiLayerFeeNetwork,
getEIP1559V2Enabled, getEIP1559V2Enabled,
getIsBuyableChain,
} from '../../selectors'; } from '../../selectors';
import { getMostRecentOverviewPage } from '../../ducks/history/history'; import { getMostRecentOverviewPage } from '../../ducks/history/history';
import { import {
@ -76,7 +77,7 @@ const mapStateToProps = (state, ownProps) => {
const isGasEstimatesLoading = getIsGasEstimatesLoading(state); const isGasEstimatesLoading = getIsGasEstimatesLoading(state);
const gasLoadingAnimationIsShowing = getGasLoadingAnimationIsShowing(state); const gasLoadingAnimationIsShowing = getGasLoadingAnimationIsShowing(state);
const isBuyableChain = getIsBuyableChain(state);
const { confirmTransaction, metamask } = state; const { confirmTransaction, metamask } = state;
const { const {
ensResolutionsByAddress, ensResolutionsByAddress,
@ -253,6 +254,7 @@ const mapStateToProps = (state, ownProps) => {
isMultiLayerFeeNetwork, isMultiLayerFeeNetwork,
chainId, chainId,
eip1559V2Enabled, eip1559V2Enabled,
isBuyableChain,
}; };
}; };

View File

@ -12,12 +12,11 @@ import Button from '../../../components/ui/button';
import Typography from '../../../components/ui/typography'; import Typography from '../../../components/ui/typography';
import { TYPOGRAPHY } from '../../../helpers/constants/design-system'; import { TYPOGRAPHY } from '../../../helpers/constants/design-system';
import { TRANSACTION_TYPES } from '../../../../shared/constants/transaction'; import { TRANSACTION_TYPES } from '../../../../shared/constants/transaction';
import { MAINNET_CHAIN_ID } from '../../../../shared/constants/network';
const TransactionAlerts = ({ const TransactionAlerts = ({
userAcknowledgedGasMissing, userAcknowledgedGasMissing,
setUserAcknowledgedGasMissing, setUserAcknowledgedGasMissing,
chainId, isBuyableChain,
nativeCurrency, nativeCurrency,
networkName, networkName,
showBuyModal, showBuyModal,
@ -96,42 +95,36 @@ const TransactionAlerts = ({
type="warning" type="warning"
/> />
)} )}
{balanceError && {balanceError && type === TRANSACTION_TYPES.DEPLOY_CONTRACT ? (
chainId === MAINNET_CHAIN_ID &&
type === TRANSACTION_TYPES.DEPLOY_CONTRACT ? (
<ActionableMessage <ActionableMessage
className="actionable-message--warning" className="actionable-message--warning"
message={ message={
<Typography variant={TYPOGRAPHY.H7} align="left"> isBuyableChain ? (
{t('insufficientCurrency', [nativeCurrency, networkName])}{' '} <Typography variant={TYPOGRAPHY.H7} align="left">
<Button {t('insufficientCurrencyBuyOrDeposit', [
type="link" nativeCurrency,
className="transaction-alerts__link" networkName,
onClick={showBuyModal} <Button
> type="inline"
{t('buyEth')} className="confirm-page-container-content__link"
</Button>{' '} onClick={showBuyModal}
{t('orDeposit')} key={`${nativeCurrency}-buy-button`}
</Typography> >
{t('buyAsset', [nativeCurrency])}
</Button>,
])}
</Typography>
) : (
<Typography variant={TYPOGRAPHY.H7} align="left">
{t('insufficientCurrencyDeposit', [
nativeCurrency,
networkName,
])}
</Typography>
)
} }
useIcon useIcon
iconFillColor="#d73a49" iconFillColor="var(--color-error-default)"
type="danger"
/>
) : null}
{balanceError &&
chainId !== MAINNET_CHAIN_ID &&
type === TRANSACTION_TYPES.DEPLOY_CONTRACT ? (
<ActionableMessage
className="actionable-message--warning"
message={
<Typography variant={TYPOGRAPHY.H7} align="left">
{t('insufficientCurrency', [nativeCurrency, networkName])}
{t('buyOther', [nativeCurrency])}
</Typography>
}
useIcon
iconFillColor="#d73a49"
type="danger" type="danger"
/> />
) : null} ) : null}
@ -177,11 +170,11 @@ const TransactionAlerts = ({
TransactionAlerts.propTypes = { TransactionAlerts.propTypes = {
userAcknowledgedGasMissing: PropTypes.bool, userAcknowledgedGasMissing: PropTypes.bool,
setUserAcknowledgedGasMissing: PropTypes.func, setUserAcknowledgedGasMissing: PropTypes.func,
chainId: PropTypes.string,
nativeCurrency: PropTypes.string, nativeCurrency: PropTypes.string,
networkName: PropTypes.string, networkName: PropTypes.string,
showBuyModal: PropTypes.func, showBuyModal: PropTypes.func,
type: PropTypes.string, type: PropTypes.string,
isBuyableChain: PropTypes.bool,
}; };
export default TransactionAlerts; export default TransactionAlerts;