mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Disable fiat conversion in Approve Screen when Show balance and token price checker
is OFF (#17443)
This commit is contained in:
parent
0c24448037
commit
769efc9fe3
@ -45,6 +45,7 @@ export default function ApproveContentCard({
|
|||||||
data,
|
data,
|
||||||
userAcknowledgedGasMissing,
|
userAcknowledgedGasMissing,
|
||||||
renderSimulationFailureWarning,
|
renderSimulationFailureWarning,
|
||||||
|
useCurrencyRateCheck,
|
||||||
}) {
|
}) {
|
||||||
const t = useContext(I18nContext);
|
const t = useContext(I18nContext);
|
||||||
|
|
||||||
@ -163,15 +164,20 @@ export default function ApproveContentCard({
|
|||||||
alignItems={AlignItems.flexEnd}
|
alignItems={AlignItems.flexEnd}
|
||||||
textAlign={TEXT_ALIGN.RIGHT}
|
textAlign={TEXT_ALIGN.RIGHT}
|
||||||
>
|
>
|
||||||
<Box>
|
{useCurrencyRateCheck && (
|
||||||
<Typography
|
<Box>
|
||||||
variant={TypographyVariant.H4}
|
<Typography
|
||||||
fontWeight={FONT_WEIGHT.BOLD}
|
variant={TypographyVariant.H4}
|
||||||
color={TextColor.textDefault}
|
fontWeight={FONT_WEIGHT.BOLD}
|
||||||
>
|
color={TextColor.TEXT_DEFAULT}
|
||||||
{formatCurrency(fiatTransactionTotal, currentCurrency)}
|
>
|
||||||
</Typography>
|
{formatCurrency(
|
||||||
</Box>
|
fiatTransactionTotal,
|
||||||
|
currentCurrency,
|
||||||
|
)}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
<Box>
|
<Box>
|
||||||
<Typography
|
<Typography
|
||||||
variant={TypographyVariant.H6}
|
variant={TypographyVariant.H6}
|
||||||
@ -320,4 +326,8 @@ ApproveContentCard.propTypes = {
|
|||||||
* Render simulation failure warning
|
* Render simulation failure warning
|
||||||
*/
|
*/
|
||||||
renderSimulationFailureWarning: PropTypes.bool,
|
renderSimulationFailureWarning: PropTypes.bool,
|
||||||
|
/**
|
||||||
|
* Fiat conversion control
|
||||||
|
*/
|
||||||
|
useCurrencyRateCheck: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
@ -74,6 +74,7 @@ export default class ConfirmApproveContent extends Component {
|
|||||||
userAcknowledgedGasMissing: PropTypes.bool,
|
userAcknowledgedGasMissing: PropTypes.bool,
|
||||||
setUserAcknowledgedGasMissing: PropTypes.func,
|
setUserAcknowledgedGasMissing: PropTypes.func,
|
||||||
renderSimulationFailureWarning: PropTypes.bool,
|
renderSimulationFailureWarning: PropTypes.bool,
|
||||||
|
useCurrencyRateCheck: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
@ -159,6 +160,7 @@ export default class ConfirmApproveContent extends Component {
|
|||||||
supportsEIP1559,
|
supportsEIP1559,
|
||||||
userAcknowledgedGasMissing,
|
userAcknowledgedGasMissing,
|
||||||
renderSimulationFailureWarning,
|
renderSimulationFailureWarning,
|
||||||
|
useCurrencyRateCheck,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
if (
|
if (
|
||||||
!isMultiLayerFeeNetwork &&
|
!isMultiLayerFeeNetwork &&
|
||||||
@ -193,7 +195,8 @@ export default class ConfirmApproveContent extends Component {
|
|||||||
</div>
|
</div>
|
||||||
<div className="confirm-approve-content__transaction-details-content__fee">
|
<div className="confirm-approve-content__transaction-details-content__fee">
|
||||||
<div className="confirm-approve-content__transaction-details-content__primary-fee">
|
<div className="confirm-approve-content__transaction-details-content__primary-fee">
|
||||||
{formatCurrency(fiatTransactionTotal, currentCurrency)}
|
{useCurrencyRateCheck &&
|
||||||
|
formatCurrency(fiatTransactionTotal, currentCurrency)}
|
||||||
</div>
|
</div>
|
||||||
<div className="confirm-approve-content__transaction-details-content__secondary-fee">
|
<div className="confirm-approve-content__transaction-details-content__secondary-fee">
|
||||||
{`${ethTransactionTotal} ${nativeCurrency}`}
|
{`${ethTransactionTotal} ${nativeCurrency}`}
|
||||||
|
@ -21,7 +21,7 @@ const props = {
|
|||||||
showCustomizeGasModal: jest.fn(),
|
showCustomizeGasModal: jest.fn(),
|
||||||
data: '0x095ea7b30000000000000000000000009bc5baf874d2da8d216ae9f137804184ee5afef40000000000000000000000000000000000000000000000000000000000011170',
|
data: '0x095ea7b30000000000000000000000009bc5baf874d2da8d216ae9f137804184ee5afef40000000000000000000000000000000000000000000000000000000000011170',
|
||||||
toAddress: '0x9bc5baf874d2da8d216ae9f137804184ee5afef4',
|
toAddress: '0x9bc5baf874d2da8d216ae9f137804184ee5afef4',
|
||||||
currentCurrency: 'TST',
|
currentCurrency: 'usd',
|
||||||
nativeCurrency: 'ETH',
|
nativeCurrency: 'ETH',
|
||||||
ethTransactionTotal: '20',
|
ethTransactionTotal: '20',
|
||||||
fiatTransactionTotal: '10',
|
fiatTransactionTotal: '10',
|
||||||
@ -36,6 +36,7 @@ const props = {
|
|||||||
chainId: '1337',
|
chainId: '1337',
|
||||||
rpcPrefs: {},
|
rpcPrefs: {},
|
||||||
isContract: true,
|
isContract: true,
|
||||||
|
useCurrencyRateCheck: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('ConfirmApproveContent Component', () => {
|
describe('ConfirmApproveContent Component', () => {
|
||||||
@ -69,6 +70,7 @@ describe('ConfirmApproveContent Component', () => {
|
|||||||
queryByText('A fee is associated with this request.'),
|
queryByText('A fee is associated with this request.'),
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
expect(queryByText(`${props.ethTransactionTotal} ETH`)).toBeInTheDocument();
|
expect(queryByText(`${props.ethTransactionTotal} ETH`)).toBeInTheDocument();
|
||||||
|
expect(queryByText(`$10.00`)).toBeInTheDocument();
|
||||||
fireEvent.click(editButtons[0]);
|
fireEvent.click(editButtons[0]);
|
||||||
expect(props.showCustomizeGasModal).toHaveBeenCalledTimes(1);
|
expect(props.showCustomizeGasModal).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
@ -98,10 +100,12 @@ describe('ConfirmApproveContent Component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should render Confirm approve page correctly and simulation error message without I want to procced anyway link', () => {
|
it('should render Confirm approve page correctly and simulation error message without I want to procced anyway link', () => {
|
||||||
props.userAcknowledgedGasMissing = true;
|
|
||||||
props.renderSimulationFailureWarning = true;
|
|
||||||
const { queryByText, getByText, getAllByText, getByTestId } =
|
const { queryByText, getByText, getAllByText, getByTestId } =
|
||||||
renderComponent(props);
|
renderComponent({
|
||||||
|
...props,
|
||||||
|
userAcknowledgedGasMissing: true,
|
||||||
|
renderSimulationFailureWarning: true,
|
||||||
|
});
|
||||||
expect(
|
expect(
|
||||||
queryByText('https://metamask.github.io/test-dapp/'),
|
queryByText('https://metamask.github.io/test-dapp/'),
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
@ -158,10 +162,12 @@ describe('ConfirmApproveContent Component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should render Confirm approve page correctly and simulation error message with I want to procced anyway link', () => {
|
it('should render Confirm approve page correctly and simulation error message with I want to procced anyway link', () => {
|
||||||
props.userAcknowledgedGasMissing = false;
|
|
||||||
props.renderSimulationFailureWarning = true;
|
|
||||||
const { queryByText, getByText, getAllByText, getByTestId } =
|
const { queryByText, getByText, getAllByText, getByTestId } =
|
||||||
renderComponent(props);
|
renderComponent({
|
||||||
|
...props,
|
||||||
|
userAcknowledgedGasMissing: false,
|
||||||
|
renderSimulationFailureWarning: true,
|
||||||
|
});
|
||||||
expect(
|
expect(
|
||||||
queryByText('https://metamask.github.io/test-dapp/'),
|
queryByText('https://metamask.github.io/test-dapp/'),
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
@ -216,4 +222,63 @@ describe('ConfirmApproveContent Component', () => {
|
|||||||
),
|
),
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should render Confirm approve page correctly when the fiat conversion is OFF', () => {
|
||||||
|
const { queryByText, getByText, getAllByText, getByTestId } =
|
||||||
|
renderComponent({ ...props, useCurrencyRateCheck: false });
|
||||||
|
expect(
|
||||||
|
queryByText('https://metamask.github.io/test-dapp/'),
|
||||||
|
).toBeInTheDocument();
|
||||||
|
expect(getByTestId('confirm-approve-title').textContent).toStrictEqual(
|
||||||
|
' Allow access to and transfer of your TestDappCollectibles (#1)? ',
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
queryByText(
|
||||||
|
'This allows a third party to access and transfer the following NFTs without further notice until you revoke its access.',
|
||||||
|
),
|
||||||
|
).toBeInTheDocument();
|
||||||
|
expect(queryByText('Verify contract details')).toBeInTheDocument();
|
||||||
|
expect(
|
||||||
|
queryByText(
|
||||||
|
'We were not able to estimate gas. There might be an error in the contract and this transaction may fail.',
|
||||||
|
),
|
||||||
|
).not.toBeInTheDocument();
|
||||||
|
expect(queryByText('I want to proceed anyway')).not.toBeInTheDocument();
|
||||||
|
expect(queryByText('View full transaction details')).toBeInTheDocument();
|
||||||
|
|
||||||
|
const editButtons = getAllByText('Edit');
|
||||||
|
|
||||||
|
expect(queryByText('Transaction fee')).toBeInTheDocument();
|
||||||
|
expect(
|
||||||
|
queryByText('A fee is associated with this request.'),
|
||||||
|
).toBeInTheDocument();
|
||||||
|
expect(queryByText(`${props.ethTransactionTotal} ETH`)).toBeInTheDocument();
|
||||||
|
expect(queryByText(`$10.00`)).not.toBeInTheDocument();
|
||||||
|
fireEvent.click(editButtons[0]);
|
||||||
|
expect(props.showCustomizeGasModal).toHaveBeenCalledTimes(4);
|
||||||
|
|
||||||
|
expect(queryByText('Nonce')).toBeInTheDocument();
|
||||||
|
expect(queryByText('2')).toBeInTheDocument();
|
||||||
|
fireEvent.click(editButtons[1]);
|
||||||
|
expect(props.showCustomizeNonceModal).toHaveBeenCalledTimes(4);
|
||||||
|
|
||||||
|
const showViewTxDetails = getByText('View full transaction details');
|
||||||
|
expect(queryByText('Permission request')).not.toBeInTheDocument();
|
||||||
|
expect(queryByText('Approved asset:')).not.toBeInTheDocument();
|
||||||
|
expect(queryByText('Granted to:')).not.toBeInTheDocument();
|
||||||
|
expect(queryByText('Data')).not.toBeInTheDocument();
|
||||||
|
fireEvent.click(showViewTxDetails);
|
||||||
|
expect(getByText('Hide full transaction details')).toBeInTheDocument();
|
||||||
|
expect(getByText('Permission request')).toBeInTheDocument();
|
||||||
|
expect(getByText('Approved asset:')).toBeInTheDocument();
|
||||||
|
expect(getByText('Granted to:')).toBeInTheDocument();
|
||||||
|
expect(getByText('Contract (0x9bc5baF8...fEF4)')).toBeInTheDocument();
|
||||||
|
expect(getByText('Data')).toBeInTheDocument();
|
||||||
|
expect(getByText('Function: Approve')).toBeInTheDocument();
|
||||||
|
expect(
|
||||||
|
getByText(
|
||||||
|
'0x095ea7b30000000000000000000000009bc5baf874d2da8d216ae9f137804184ee5afef40000000000000000000000000000000000000000000000000000000000011170',
|
||||||
|
),
|
||||||
|
).toBeInTheDocument();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -27,6 +27,7 @@ import {
|
|||||||
getRpcPrefsForCurrentProvider,
|
getRpcPrefsForCurrentProvider,
|
||||||
getIsMultiLayerFeeNetwork,
|
getIsMultiLayerFeeNetwork,
|
||||||
checkNetworkAndAccountSupports1559,
|
checkNetworkAndAccountSupports1559,
|
||||||
|
getUseCurrencyRateCheck,
|
||||||
} from '../../selectors';
|
} from '../../selectors';
|
||||||
import { useApproveTransaction } from '../../hooks/useApproveTransaction';
|
import { useApproveTransaction } from '../../hooks/useApproveTransaction';
|
||||||
import { useSimulationFailureWarning } from '../../hooks/useSimulationFailureWarning';
|
import { useSimulationFailureWarning } from '../../hooks/useSimulationFailureWarning';
|
||||||
@ -81,6 +82,7 @@ export default function ConfirmApprove({
|
|||||||
const fromAddressIsLedger = useSelector(
|
const fromAddressIsLedger = useSelector(
|
||||||
isAddressLedgerByFromAddress(userAddress),
|
isAddressLedgerByFromAddress(userAddress),
|
||||||
);
|
);
|
||||||
|
const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck);
|
||||||
const [customPermissionAmount, setCustomPermissionAmount] = useState('');
|
const [customPermissionAmount, setCustomPermissionAmount] = useState('');
|
||||||
const [submitWarning, setSubmitWarning] = useState('');
|
const [submitWarning, setSubmitWarning] = useState('');
|
||||||
const [isContract, setIsContract] = useState(false);
|
const [isContract, setIsContract] = useState(false);
|
||||||
@ -287,6 +289,7 @@ export default function ConfirmApprove({
|
|||||||
isContract={isContract}
|
isContract={isContract}
|
||||||
isMultiLayerFeeNetwork={isMultiLayerFeeNetwork}
|
isMultiLayerFeeNetwork={isMultiLayerFeeNetwork}
|
||||||
supportsEIP1559={supportsEIP1559}
|
supportsEIP1559={supportsEIP1559}
|
||||||
|
useCurrencyRateCheck={useCurrencyRateCheck}
|
||||||
/>
|
/>
|
||||||
{showCustomizeGasPopover && !supportsEIP1559 && (
|
{showCustomizeGasPopover && !supportsEIP1559 && (
|
||||||
<EditGasPopover
|
<EditGasPopover
|
||||||
|
@ -34,6 +34,7 @@ import {
|
|||||||
getCustomTokenAmount,
|
getCustomTokenAmount,
|
||||||
getUnapprovedTxCount,
|
getUnapprovedTxCount,
|
||||||
getUnapprovedTransactions,
|
getUnapprovedTransactions,
|
||||||
|
getUseCurrencyRateCheck,
|
||||||
} from '../../selectors';
|
} from '../../selectors';
|
||||||
import { NETWORK_TO_NAME_MAP } from '../../../shared/constants/network';
|
import { NETWORK_TO_NAME_MAP } from '../../../shared/constants/network';
|
||||||
import {
|
import {
|
||||||
@ -109,6 +110,7 @@ export default function TokenAllowance({
|
|||||||
const customTokenAmount = useSelector(getCustomTokenAmount);
|
const customTokenAmount = useSelector(getCustomTokenAmount);
|
||||||
const unapprovedTxCount = useSelector(getUnapprovedTxCount);
|
const unapprovedTxCount = useSelector(getUnapprovedTxCount);
|
||||||
const unapprovedTxs = useSelector(getUnapprovedTransactions);
|
const unapprovedTxs = useSelector(getUnapprovedTransactions);
|
||||||
|
const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck);
|
||||||
|
|
||||||
const replaceCommaToDot = (inputValue) => {
|
const replaceCommaToDot = (inputValue) => {
|
||||||
return inputValue.replace(/,/gu, '.');
|
return inputValue.replace(/,/gu, '.');
|
||||||
@ -436,6 +438,7 @@ export default function TokenAllowance({
|
|||||||
hexTransactionTotal={hexTransactionTotal}
|
hexTransactionTotal={hexTransactionTotal}
|
||||||
fiatTransactionTotal={fiatTransactionTotal}
|
fiatTransactionTotal={fiatTransactionTotal}
|
||||||
currentCurrency={currentCurrency}
|
currentCurrency={currentCurrency}
|
||||||
|
useCurrencyRateCheck={useCurrencyRateCheck}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
@ -483,6 +486,7 @@ export default function TokenAllowance({
|
|||||||
renderSimulationFailureWarning={renderSimulationFailureWarning}
|
renderSimulationFailureWarning={renderSimulationFailureWarning}
|
||||||
isApprovalOrRejection={isApprovalOrRejection}
|
isApprovalOrRejection={isApprovalOrRejection}
|
||||||
data={customTxParamsData || data}
|
data={customTxParamsData || data}
|
||||||
|
useCurrencyRateCheck={useCurrencyRateCheck}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
Loading…
Reference in New Issue
Block a user