From 613599df1e3c3ff421488fbacba26f3a52ae7969 Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Tue, 18 Apr 2023 09:35:12 -0230 Subject: [PATCH 1/2] gst --- ui/pages/confirm-approve/confirm-approve.js | 1 + ui/pages/token-allowance/token-allowance.js | 9 ++++++--- .../token-allowance/token-allowance.test.js | 18 +++++++++++++----- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ui/pages/confirm-approve/confirm-approve.js b/ui/pages/confirm-approve/confirm-approve.js index 6980d4862c79..5949a8373fbd 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 30d12b9e071c..6e48d83bcad3 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'], }, ], @@ -258,7 +258,7 @@ describe('TokenAllowancePage', () => { it('should show hardware wallet info text', () => { const { queryByText, getByText, getByTestId } = renderWithProvider( - , + , store, ); @@ -274,11 +274,19 @@ describe('TokenAllowancePage', () => { }); it('should not show hardware wallet info text', () => { - const { queryByText } = renderWithProvider( - , + 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(); }); From 87de22a38719ce0ea61e43d6a5c1608d1f3e7b70 Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Tue, 18 Apr 2023 09:35:37 -0230 Subject: [PATCH 2/2] Only display ledger info on approval screen for ledger hardware wallets --- ui/pages/token-allowance/token-allowance.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/pages/token-allowance/token-allowance.test.js b/ui/pages/token-allowance/token-allowance.test.js index 6e48d83bcad3..d05c21f200ed 100644 --- a/ui/pages/token-allowance/token-allowance.test.js +++ b/ui/pages/token-allowance/token-allowance.test.js @@ -256,7 +256,7 @@ 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, @@ -273,7 +273,7 @@ describe('TokenAllowancePage', () => { expect(queryByText('Prior to clicking confirm:')).toBeInTheDocument(); }); - it('should not show hardware wallet info text', () => { + it('should not show ledger info text if the sending address is not ledger', () => { const { queryByText, getByText, getByTestId } = renderWithProvider( , store,