mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fixed hardware wallet info popup on token allowance screen (#17881)
This commit is contained in:
parent
7215fc25a4
commit
c477e29397
@ -35,6 +35,7 @@ import {
|
|||||||
getUnapprovedTxCount,
|
getUnapprovedTxCount,
|
||||||
getUnapprovedTransactions,
|
getUnapprovedTransactions,
|
||||||
getUseCurrencyRateCheck,
|
getUseCurrencyRateCheck,
|
||||||
|
isHardwareWallet,
|
||||||
} from '../../selectors';
|
} from '../../selectors';
|
||||||
import { NETWORK_TO_NAME_MAP } from '../../../shared/constants/network';
|
import { NETWORK_TO_NAME_MAP } from '../../../shared/constants/network';
|
||||||
import {
|
import {
|
||||||
@ -62,6 +63,7 @@ import { ConfirmPageContainerNavigation } from '../../components/app/confirm-pag
|
|||||||
import { useSimulationFailureWarning } from '../../hooks/useSimulationFailureWarning';
|
import { useSimulationFailureWarning } from '../../hooks/useSimulationFailureWarning';
|
||||||
import SimulationErrorMessage from '../../components/ui/simulation-error-message';
|
import SimulationErrorMessage from '../../components/ui/simulation-error-message';
|
||||||
import { Icon, ICON_NAMES } from '../../components/component-library';
|
import { Icon, ICON_NAMES } from '../../components/component-library';
|
||||||
|
import LedgerInstructionField from '../../components/app/ledger-instruction-field/ledger-instruction-field';
|
||||||
|
|
||||||
export default function TokenAllowance({
|
export default function TokenAllowance({
|
||||||
origin,
|
origin,
|
||||||
@ -111,6 +113,7 @@ export default function TokenAllowance({
|
|||||||
const unapprovedTxCount = useSelector(getUnapprovedTxCount);
|
const unapprovedTxCount = useSelector(getUnapprovedTxCount);
|
||||||
const unapprovedTxs = useSelector(getUnapprovedTransactions);
|
const unapprovedTxs = useSelector(getUnapprovedTransactions);
|
||||||
const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck);
|
const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck);
|
||||||
|
const isHardwareWalletConnected = useSelector(isHardwareWallet);
|
||||||
|
|
||||||
const replaceCommaToDot = (inputValue) => {
|
const replaceCommaToDot = (inputValue) => {
|
||||||
return inputValue.replace(/,/gu, '.');
|
return inputValue.replace(/,/gu, '.');
|
||||||
@ -491,6 +494,11 @@ export default function TokenAllowance({
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
) : null}
|
) : null}
|
||||||
|
{!isFirstPage && isHardwareWalletConnected && (
|
||||||
|
<Box paddingLeft={2} paddingRight={2}>
|
||||||
|
<LedgerInstructionField showDataInstruction />
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
<PageContainerFooter
|
<PageContainerFooter
|
||||||
cancelText={t('reject')}
|
cancelText={t('reject')}
|
||||||
submitText={isFirstPage ? t('next') : t('approveButtonText')}
|
submitText={isFirstPage ? t('next') : t('approveButtonText')}
|
||||||
|
@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
import configureMockStore from 'redux-mock-store';
|
import configureMockStore from 'redux-mock-store';
|
||||||
import { fireEvent } from '@testing-library/react';
|
import { fireEvent } from '@testing-library/react';
|
||||||
import { renderWithProvider } from '../../../test/lib/render-helpers';
|
import { renderWithProvider } from '../../../test/lib/render-helpers';
|
||||||
|
import { HardwareKeyringTypes } from '../../../shared/constants/hardware-wallets';
|
||||||
import TokenAllowance from './token-allowance';
|
import TokenAllowance from './token-allowance';
|
||||||
|
|
||||||
const testTokenAddress = '0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F';
|
const testTokenAddress = '0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F';
|
||||||
@ -11,17 +12,17 @@ const state = {
|
|||||||
},
|
},
|
||||||
metamask: {
|
metamask: {
|
||||||
accounts: {
|
accounts: {
|
||||||
'0xAddress': {
|
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': {
|
||||||
address: '0xAddress',
|
address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
||||||
balance: '0x1F4',
|
balance: '0x0',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
gasEstimateType: 'none',
|
gasEstimateType: 'none',
|
||||||
selectedAddress: '0xAddress',
|
selectedAddress: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
||||||
identities: {
|
identities: {
|
||||||
'0xAddress': {
|
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': {
|
||||||
|
address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
||||||
name: 'Account 1',
|
name: 'Account 1',
|
||||||
address: '0xAddress',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
cachedBalances: {},
|
cachedBalances: {},
|
||||||
@ -64,6 +65,13 @@ const state = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
unapprovedTxs: {},
|
unapprovedTxs: {},
|
||||||
|
keyringTypes: [HardwareKeyringTypes.ledger],
|
||||||
|
keyrings: [
|
||||||
|
{
|
||||||
|
type: HardwareKeyringTypes.ledger,
|
||||||
|
accounts: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
history: {
|
history: {
|
||||||
mostRecentOverviewPage: '/',
|
mostRecentOverviewPage: '/',
|
||||||
@ -244,4 +252,30 @@ describe('TokenAllowancePage', () => {
|
|||||||
fireEvent.click(gotIt);
|
fireEvent.click(gotIt);
|
||||||
expect(gotIt).not.toBeInTheDocument();
|
expect(gotIt).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should show hardware wallet info text', () => {
|
||||||
|
const { queryByText, getByText, getByTestId } = renderWithProvider(
|
||||||
|
<TokenAllowance {...props} />,
|
||||||
|
store,
|
||||||
|
);
|
||||||
|
|
||||||
|
const textField = getByTestId('custom-spending-cap-input');
|
||||||
|
fireEvent.change(textField, { target: { value: '1' } });
|
||||||
|
|
||||||
|
expect(queryByText('Prior to clicking confirm:')).toBeNull();
|
||||||
|
|
||||||
|
const nextButton = getByText('Next');
|
||||||
|
fireEvent.click(nextButton);
|
||||||
|
|
||||||
|
expect(queryByText('Prior to clicking confirm:')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not show hardware wallet info text', () => {
|
||||||
|
const { queryByText } = renderWithProvider(
|
||||||
|
<TokenAllowance {...props} />,
|
||||||
|
store,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(queryByText('Prior to clicking confirm:')).toBeNull();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user