mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Adds multilayer fee display to erc20 token approval screen (#12824)
* Adds multilayer fee display to erc20 token approval screen * Change bold property name
This commit is contained in:
parent
9aa8abb55f
commit
b025baf093
@ -14,6 +14,7 @@ export default function MultilayerFeeMessage({
|
|||||||
transaction,
|
transaction,
|
||||||
layer2fee,
|
layer2fee,
|
||||||
nativeCurrency,
|
nativeCurrency,
|
||||||
|
plainStyle,
|
||||||
}) {
|
}) {
|
||||||
const t = useContext(I18nContext);
|
const t = useContext(I18nContext);
|
||||||
|
|
||||||
@ -57,12 +58,16 @@ export default function MultilayerFeeMessage({
|
|||||||
key="total-item"
|
key="total-item"
|
||||||
detailTitle={t('layer1Fees')}
|
detailTitle={t('layer1Fees')}
|
||||||
detailTotal={layer1Total}
|
detailTotal={layer1Total}
|
||||||
|
noBold={plainStyle}
|
||||||
|
flexWidthValues={plainStyle}
|
||||||
/>
|
/>
|
||||||
<TransactionDetailItem
|
<TransactionDetailItem
|
||||||
key="total-item"
|
key="total-item"
|
||||||
detailTitle={t('total')}
|
detailTitle={t('total')}
|
||||||
detailTotal={totalInEth}
|
detailTotal={totalInEth}
|
||||||
subTitle={t('transactionDetailMultiLayerTotalSubtitle')}
|
subTitle={t('transactionDetailMultiLayerTotalSubtitle')}
|
||||||
|
noBold={plainStyle}
|
||||||
|
flexWidthValues={plainStyle}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@ -72,4 +77,5 @@ MultilayerFeeMessage.propTypes = {
|
|||||||
transaction: PropTypes.object,
|
transaction: PropTypes.object,
|
||||||
layer2fee: PropTypes.string,
|
layer2fee: PropTypes.string,
|
||||||
nativeCurrency: PropTypes.string,
|
nativeCurrency: PropTypes.string,
|
||||||
|
plainStyle: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
@ -13,6 +13,17 @@
|
|||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__detail-values {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: end;
|
||||||
|
width: 55%;
|
||||||
|
|
||||||
|
&--flex-width {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.info-tooltip {
|
.info-tooltip {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-inline-start: 4px;
|
margin-inline-start: 4px;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import classnames from 'classnames';
|
||||||
|
|
||||||
import Typography from '../../ui/typography/typography';
|
import Typography from '../../ui/typography/typography';
|
||||||
import {
|
import {
|
||||||
@ -15,26 +16,35 @@ export default function TransactionDetailItem({
|
|||||||
detailTotal = '',
|
detailTotal = '',
|
||||||
subTitle = '',
|
subTitle = '',
|
||||||
subText = '',
|
subText = '',
|
||||||
|
boldHeadings = true,
|
||||||
|
flexWidthValues = false,
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className="transaction-detail-item">
|
<div className="transaction-detail-item">
|
||||||
<div className="transaction-detail-item__row">
|
<div className="transaction-detail-item__row">
|
||||||
<Typography
|
<Typography
|
||||||
color={detailTitleColor}
|
color={detailTitleColor}
|
||||||
fontWeight={FONT_WEIGHT.BOLD}
|
fontWeight={boldHeadings ? FONT_WEIGHT.BOLD : FONT_WEIGHT.NORMAL}
|
||||||
variant={TYPOGRAPHY.H6}
|
variant={TYPOGRAPHY.H6}
|
||||||
className="transaction-detail-item__title"
|
className="transaction-detail-item__title"
|
||||||
>
|
>
|
||||||
{detailTitle}
|
{detailTitle}
|
||||||
</Typography>
|
</Typography>
|
||||||
{detailText && (
|
{detailText && (
|
||||||
<Typography
|
<div
|
||||||
variant={TYPOGRAPHY.H6}
|
className={classnames('transaction-detail-item__detail-values', {
|
||||||
className="transaction-detail-item__detail-text"
|
'transaction-detail-item__detail-values--flex-width': flexWidthValues,
|
||||||
color={COLORS.UI4}
|
})}
|
||||||
>
|
>
|
||||||
{detailText}
|
<Typography
|
||||||
</Typography>
|
fontWeight={boldHeadings ? FONT_WEIGHT.BOLD : FONT_WEIGHT.NORMAL}
|
||||||
|
variant={TYPOGRAPHY.H6}
|
||||||
|
className="transaction-detail-item__detail-text"
|
||||||
|
color={COLORS.UI4}
|
||||||
|
>
|
||||||
|
{detailText}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
<Typography
|
<Typography
|
||||||
color={COLORS.BLACK}
|
color={COLORS.BLACK}
|
||||||
@ -77,4 +87,6 @@ TransactionDetailItem.propTypes = {
|
|||||||
detailTotal: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
detailTotal: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
||||||
subTitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
subTitle: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
||||||
subText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
subText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
||||||
|
boldHeadings: PropTypes.bool,
|
||||||
|
flexWidthValues: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
@ -13,6 +13,7 @@ import Box from '../../../components/ui/box';
|
|||||||
import Button from '../../../components/ui/button';
|
import Button from '../../../components/ui/button';
|
||||||
import MetaFoxLogo from '../../../components/ui/metafox-logo';
|
import MetaFoxLogo from '../../../components/ui/metafox-logo';
|
||||||
import Identicon from '../../../components/ui/identicon';
|
import Identicon from '../../../components/ui/identicon';
|
||||||
|
import MultiLayerFeeMessage from '../../../components/app/multilayer-fee-message';
|
||||||
import CopyIcon from '../../../components/ui/icon/copy-icon.component';
|
import CopyIcon from '../../../components/ui/icon/copy-icon.component';
|
||||||
import {
|
import {
|
||||||
TYPOGRAPHY,
|
TYPOGRAPHY,
|
||||||
@ -61,6 +62,8 @@ export default class ConfirmApproveContent extends Component {
|
|||||||
chainId: PropTypes.string,
|
chainId: PropTypes.string,
|
||||||
rpcPrefs: PropTypes.object,
|
rpcPrefs: PropTypes.object,
|
||||||
isContract: PropTypes.bool,
|
isContract: PropTypes.bool,
|
||||||
|
hexTransactionTotal: PropTypes.string,
|
||||||
|
isMultiLayerFeeNetwork: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
@ -121,20 +124,40 @@ export default class ConfirmApproveContent extends Component {
|
|||||||
nativeCurrency,
|
nativeCurrency,
|
||||||
ethTransactionTotal,
|
ethTransactionTotal,
|
||||||
fiatTransactionTotal,
|
fiatTransactionTotal,
|
||||||
|
hexTransactionTotal,
|
||||||
|
txData,
|
||||||
|
isMultiLayerFeeNetwork,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
return (
|
return (
|
||||||
<div className="confirm-approve-content__transaction-details-content">
|
<div className="confirm-approve-content__transaction-details-content">
|
||||||
<div className="confirm-approve-content__small-text">
|
{isMultiLayerFeeNetwork ? (
|
||||||
{t('feeAssociatedRequest')}
|
<div className="confirm-approve-content__transaction-details-extra-content">
|
||||||
</div>
|
<div className="confirm-approve-content__transaction-details-content__labelled-fee">
|
||||||
<div className="confirm-approve-content__transaction-details-content__fee">
|
<span>{t('transactionDetailLayer2GasHeading')}</span>
|
||||||
<div className="confirm-approve-content__transaction-details-content__primary-fee">
|
{`${ethTransactionTotal} ${nativeCurrency}`}
|
||||||
{formatCurrency(fiatTransactionTotal, currentCurrency)}
|
</div>
|
||||||
|
<MultiLayerFeeMessage
|
||||||
|
transaction={txData}
|
||||||
|
layer2fee={hexTransactionTotal}
|
||||||
|
nativeCurrency={nativeCurrency}
|
||||||
|
plainStyle
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="confirm-approve-content__transaction-details-content__secondary-fee">
|
) : (
|
||||||
{`${ethTransactionTotal} ${nativeCurrency}`}
|
<>
|
||||||
</div>
|
<div className="confirm-approve-content__small-text">
|
||||||
</div>
|
{t('feeAssociatedRequest')}
|
||||||
|
</div>
|
||||||
|
<div className="confirm-approve-content__transaction-details-content__fee">
|
||||||
|
<div className="confirm-approve-content__transaction-details-content__primary-fee">
|
||||||
|
{formatCurrency(fiatTransactionTotal, currentCurrency)}
|
||||||
|
</div>
|
||||||
|
<div className="confirm-approve-content__transaction-details-content__secondary-fee">
|
||||||
|
{`${ethTransactionTotal} ${nativeCurrency}`}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -254,12 +254,28 @@
|
|||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__secondary-fee {
|
&__secondary-fee,
|
||||||
|
&__labelled-fee {
|
||||||
@include H6;
|
@include H6;
|
||||||
|
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
color: #8c8e94;
|
color: #8c8e94;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__labelled-fee {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
h6.typography--h6 {
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__transaction-details-extra-content {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__view-full-tx-button-wrapper {
|
&__view-full-tx-button-wrapper {
|
||||||
|
@ -31,6 +31,7 @@ import {
|
|||||||
getNextSuggestedNonce,
|
getNextSuggestedNonce,
|
||||||
getCurrentChainId,
|
getCurrentChainId,
|
||||||
getRpcPrefsForCurrentProvider,
|
getRpcPrefsForCurrentProvider,
|
||||||
|
getIsMultiLayerFeeNetwork,
|
||||||
} from '../../selectors';
|
} from '../../selectors';
|
||||||
|
|
||||||
import { useApproveTransaction } from '../../hooks/useApproveTransaction';
|
import { useApproveTransaction } from '../../hooks/useApproveTransaction';
|
||||||
@ -64,6 +65,7 @@ export default function ConfirmApprove() {
|
|||||||
const customNonceValue = useSelector(getCustomNonceValue);
|
const customNonceValue = useSelector(getCustomNonceValue);
|
||||||
const chainId = useSelector(getCurrentChainId);
|
const chainId = useSelector(getCurrentChainId);
|
||||||
const rpcPrefs = useSelector(getRpcPrefsForCurrentProvider);
|
const rpcPrefs = useSelector(getRpcPrefsForCurrentProvider);
|
||||||
|
const isMultiLayerFeeNetwork = useSelector(getIsMultiLayerFeeNetwork);
|
||||||
|
|
||||||
const fromAddressIsLedger = useSelector(isAddressLedgerByFromAddress(from));
|
const fromAddressIsLedger = useSelector(isAddressLedgerByFromAddress(from));
|
||||||
|
|
||||||
@ -71,9 +73,11 @@ export default function ConfirmApprove() {
|
|||||||
currentNetworkTxList.find(
|
currentNetworkTxList.find(
|
||||||
({ id }) => id === (Number(paramsTransactionId) || transactionId),
|
({ id }) => id === (Number(paramsTransactionId) || transactionId),
|
||||||
) || {};
|
) || {};
|
||||||
const { ethTransactionTotal, fiatTransactionTotal } = useSelector((state) =>
|
const {
|
||||||
transactionFeeSelector(state, transaction),
|
ethTransactionTotal,
|
||||||
);
|
fiatTransactionTotal,
|
||||||
|
hexTransactionTotal,
|
||||||
|
} = useSelector((state) => transactionFeeSelector(state, transaction));
|
||||||
|
|
||||||
const currentToken = (tokens &&
|
const currentToken = (tokens &&
|
||||||
tokens.find(({ address }) =>
|
tokens.find(({ address }) =>
|
||||||
@ -207,6 +211,7 @@ export default function ConfirmApprove() {
|
|||||||
nativeCurrency={nativeCurrency}
|
nativeCurrency={nativeCurrency}
|
||||||
ethTransactionTotal={ethTransactionTotal}
|
ethTransactionTotal={ethTransactionTotal}
|
||||||
fiatTransactionTotal={fiatTransactionTotal}
|
fiatTransactionTotal={fiatTransactionTotal}
|
||||||
|
hexTransactionTotal={hexTransactionTotal}
|
||||||
useNonceField={useNonceField}
|
useNonceField={useNonceField}
|
||||||
nextNonce={nextNonce}
|
nextNonce={nextNonce}
|
||||||
customNonceValue={customNonceValue}
|
customNonceValue={customNonceValue}
|
||||||
@ -240,6 +245,7 @@ export default function ConfirmApprove() {
|
|||||||
chainId={chainId}
|
chainId={chainId}
|
||||||
rpcPrefs={rpcPrefs}
|
rpcPrefs={rpcPrefs}
|
||||||
isContract={isContract}
|
isContract={isContract}
|
||||||
|
isMultiLayerFeeNetwork={isMultiLayerFeeNetwork}
|
||||||
/>
|
/>
|
||||||
{showCustomizeGasPopover && (
|
{showCustomizeGasPopover && (
|
||||||
<EditGasPopover
|
<EditGasPopover
|
||||||
|
Loading…
Reference in New Issue
Block a user