Skip to content

Commit

Permalink
Ledger trezor display (#18637)
Browse files Browse the repository at this point in the history
* gst

* Only display ledger info on approval screen for ledger hardware wallets
  • Loading branch information
danjm authored Apr 18, 2023
1 parent 599bef9 commit 39f6042
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions ui/pages/confirm-approve/confirm-approve.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export default function ConfirmApprove({
toAddress={toAddress}
tokenSymbol={tokenSymbol}
decimals={decimals}
fromAddressIsLedger={fromAddressIsLedger}
/>
{showCustomizeGasPopover && !supportsEIP1559 && (
<EditGasPopover
Expand Down
9 changes: 6 additions & 3 deletions ui/pages/token-allowance/token-allowance.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
getUnapprovedTxCount,
getUnapprovedTransactions,
getUseCurrencyRateCheck,
isHardwareWallet,
} from '../../selectors';
import { NETWORK_TO_NAME_MAP } from '../../../shared/constants/network';
import {
Expand Down Expand Up @@ -95,6 +94,7 @@ export default function TokenAllowance({
currentTokenBalance,
toAddress,
tokenSymbol,
fromAddressIsLedger,
}) {
const t = useContext(I18nContext);
const dispatch = useDispatch();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -516,7 +515,7 @@ export default function TokenAllowance({
</Box>
</Box>
) : null}
{!isFirstPage && isHardwareWalletConnected && (
{!isFirstPage && fromAddressIsLedger && (
<Box paddingLeft={2} paddingRight={2}>
<LedgerInstructionField showDataInstruction />
</Box>
Expand Down Expand Up @@ -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,
};
22 changes: 15 additions & 7 deletions ui/pages/token-allowance/token-allowance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ const state = {
},
],
unapprovedTxs: {},
keyringTypes: [KeyringType.ledger],
keyringTypes: [],
keyrings: [
{
type: KeyringType.ledger,
type: KeyringType.hdKeyTree,
accounts: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'],
},
],
Expand Down Expand Up @@ -256,9 +256,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,
);

Expand All @@ -273,12 +273,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();
});

Expand Down

0 comments on commit 39f6042

Please sign in to comment.