diff --git a/ui/pages/confirmations/hooks/useLedgerConnection.ts b/ui/pages/confirmations/hooks/useLedgerConnection.ts index 9e2f9d326e84..7f7480f085cc 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, @@ -22,16 +23,15 @@ import { useConfirmContext } from '../context/confirm'; const useLedgerConnection = () => { const dispatch = useDispatch(); - const { currentConfirmation } = useConfirmContext(); + const { currentConfirmation } = useConfirmContext< + 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),