1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00

Ledger trezor display (#18637)

* gst

* Only display ledger info on approval screen for ledger hardware wallets
This commit is contained in:
Dan J Miller 2023-04-18 17:19:49 -02:30 committed by Dan Miller
parent a97383d62e
commit 3cc82898a6
3 changed files with 22 additions and 10 deletions

View File

@ -199,6 +199,7 @@ export default function ConfirmApprove({
toAddress={toAddress}
tokenSymbol={tokenSymbol}
decimals={decimals}
fromAddressIsLedger={fromAddressIsLedger}
/>
{showCustomizeGasPopover && !supportsEIP1559 && (
<EditGasPopover

View File

@ -35,7 +35,6 @@ import {
getUnapprovedTxCount,
getUnapprovedTransactions,
getUseCurrencyRateCheck,
isHardwareWallet,
} from '../../selectors';
import { NETWORK_TO_NAME_MAP } from '../../../shared/constants/network';
import {
@ -95,6 +94,7 @@ export default function TokenAllowance({
currentTokenBalance,
toAddress,
tokenSymbol,
fromAddressIsLedger,
}) {
const t = useContext(I18nContext);
const dispatch = useDispatch();
@ -122,7 +122,6 @@ export default function TokenAllowance({
const unapprovedTxCount = useSelector(getUnapprovedTxCount);
const unapprovedTxs = useSelector(getUnapprovedTransactions);
const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck);
const isHardwareWalletConnected = useSelector(isHardwareWallet);
let customTokenAmount = useSelector(getCustomTokenAmount);
if (thisOriginIsAllowedToSkipFirstPage && dappProposedTokenAmount) {
customTokenAmount = dappProposedTokenAmount;
@ -516,7 +515,7 @@ export default function TokenAllowance({
</Box>
</Box>
) : null}
{!isFirstPage && isHardwareWalletConnected && (
{!isFirstPage && fromAddressIsLedger && (
<Box paddingLeft={2} paddingRight={2}>
<LedgerInstructionField showDataInstruction />
</Box>
@ -643,4 +642,8 @@ TokenAllowance.propTypes = {
* Symbol of the token that is waiting to be allowed
*/
tokenSymbol: PropTypes.string,
/**
* Whether the address sending the transaction is a ledger address
*/
fromAddressIsLedger: PropTypes.bool,
};

View File

@ -65,10 +65,10 @@ const state = {
},
],
unapprovedTxs: {},
keyringTypes: [KeyringType.ledger],
keyringTypes: [],
keyrings: [
{
type: KeyringType.ledger,
type: KeyringType.hdKeyTree,
accounts: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
},
],
@ -253,9 +253,9 @@ describe('TokenAllowancePage', () => {
expect(gotIt).not.toBeInTheDocument();
});
it('should show hardware wallet info text', () => {
it('should show ledger info text if the sending address is ledger', () => {
const { queryByText, getByText, getByTestId } = renderWithProvider(
<TokenAllowance {...props} />,
<TokenAllowance {...props} fromAddressIsLedger />,
store,
);
@ -270,12 +270,20 @@ describe('TokenAllowancePage', () => {
expect(queryByText('Prior to clicking confirm:')).toBeInTheDocument();
});
it('should not show hardware wallet info text', () => {
const { queryByText } = renderWithProvider(
<TokenAllowance {...props} />,
it('should not show ledger info text if the sending address is not ledger', () => {
const { queryByText, getByText, getByTestId } = renderWithProvider(
<TokenAllowance {...props} fromAddressIsLedger={false} />,
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:')).toBeNull();
});