Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ledger trezor display #18637

Merged
merged 2 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -199,6 +199,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