From 3cc82898a642db82b499a1360d47749894b08551 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Tue, 18 Apr 2023 17:19:49 -0230 Subject: [PATCH] Ledger trezor display (#18637) * gst * Only display ledger info on approval screen for ledger hardware wallets --- ui/pages/confirm-approve/confirm-approve.js | 1 + ui/pages/token-allowance/token-allowance.js | 9 +++++--- .../token-allowance/token-allowance.test.js | 22 +++++++++++++------ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ui/pages/confirm-approve/confirm-approve.js b/ui/pages/confirm-approve/confirm-approve.js index 6980d4862..5949a8373 100644 --- a/ui/pages/confirm-approve/confirm-approve.js +++ b/ui/pages/confirm-approve/confirm-approve.js @@ -199,6 +199,7 @@ export default function ConfirmApprove({ toAddress={toAddress} tokenSymbol={tokenSymbol} decimals={decimals} + fromAddressIsLedger={fromAddressIsLedger} /> {showCustomizeGasPopover && !supportsEIP1559 && ( ) : null} - {!isFirstPage && isHardwareWalletConnected && ( + {!isFirstPage && fromAddressIsLedger && ( @@ -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, }; diff --git a/ui/pages/token-allowance/token-allowance.test.js b/ui/pages/token-allowance/token-allowance.test.js index c800f1f2e..b6b1c6c1e 100644 --- a/ui/pages/token-allowance/token-allowance.test.js +++ b/ui/pages/token-allowance/token-allowance.test.js @@ -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( - , + , 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( - , + it('should not show ledger info text if the sending address is not ledger', () => { + const { queryByText, getByText, getByTestId } = renderWithProvider( + , 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(); });