From 44118131119536855993a13813b6c9194ef230c7 Mon Sep 17 00:00:00 2001 From: OGPoyraz Date: Mon, 23 Sep 2024 17:18:34 +0200 Subject: [PATCH] fix: Contract interactions cannot confirm a contract interaction with `Ledger` with the new redesign (#27331) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR fixes the issue where confirm button is always disabled when contract interactions with Ledger account [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27331?quickstart=1) Fixes: https://github.com/MetaMask/metamask-extension/issues/27240 1. Activate Ledger account in MM 2. Go to uniswap 3. Try swapping from Sepolia eth to Weth 4. See confirmation "Confirm" button is not disabled https://github.com/user-attachments/assets/aba4e44c-049e-4d64-b14a-9bdc4c25a9cb - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- ui/pages/confirmations/hooks/useLedgerConnection.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ui/pages/confirmations/hooks/useLedgerConnection.ts b/ui/pages/confirmations/hooks/useLedgerConnection.ts index c9bd26fef3c8..2774844262f4 100644 --- a/ui/pages/confirmations/hooks/useLedgerConnection.ts +++ b/ui/pages/confirmations/hooks/useLedgerConnection.ts @@ -1,5 +1,6 @@ import { useEffect } from 'react'; import { useDispatch, useSelector } from 'react-redux'; +import { TransactionMeta } from '@metamask/transaction-controller'; import { HardwareTransportStates, LEDGER_USB_VENDOR_ID, @@ -24,16 +25,13 @@ const useLedgerConnection = () => { const dispatch = useDispatch(); const currentConfirmation = useSelector( currentConfirmationSelector, - ) as SignatureRequestType; + ) as SignatureRequestType & TransactionMeta; const ledgerTransportType = useSelector(getLedgerTransportType); const transportStatus = useSelector(getLedgerTransportStatus); const webHidConnectedStatus = useSelector(getLedgerWebHidConnectedStatus); - let from: string | undefined; - // todo: extend to other confirmation types - if (currentConfirmation?.msgParams) { - from = currentConfirmation.msgParams.from; - } + const from = + currentConfirmation?.msgParams?.from ?? currentConfirmation?.txParams?.from; const isLedgerWallet = useSelector( (state) => from && isAddressLedger(state, from),