Skip to content

Commit

Permalink
Disable Bluetooth Ledger in Web extension
Browse files Browse the repository at this point in the history
  • Loading branch information
lubej committed Oct 9, 2023
1 parent 9b9f7b0 commit 7abf490
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/app/pages/OpenWalletPage/Features/FromLedger/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,25 @@ import { useTranslation } from 'react-i18next'

type SelectOpenMethodProps = {
webExtensionLedgerAccess?: () => void
disableBluetoothLedger?: boolean
}

export function FromLedger({ webExtensionLedgerAccess }: SelectOpenMethodProps) {
export function FromLedger({ webExtensionLedgerAccess, disableBluetoothLedger }: SelectOpenMethodProps) {
const { t } = useTranslation()
const [supportsUsbLedger, setSupportsUsbLedger] = React.useState<boolean | undefined>(true)
const [supportsBleLedger, setSupportsBleLedger] = React.useState<boolean | undefined>(true)

useEffect(() => {
async function getLedgerSupport() {
setSupportsUsbLedger(await canAccessNavigatorUsb())
setSupportsBleLedger(await canAccessBle())
const usbLedgerSupported = await canAccessNavigatorUsb()
const bleLedgerSupported = !disableBluetoothLedger && (await canAccessBle())

setSupportsUsbLedger(usbLedgerSupported)
setSupportsBleLedger(bleLedgerSupported)
}

getLedgerSupport()
}, [])
}, [disableBluetoothLedger])

return (
<Box
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/OpenWalletPage/webextension.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export function OpenWalletPageWebExtension() {
export function FromLedgerWebExtension() {
const href = useHref('/open-wallet/connect-device')

return <FromLedger webExtensionLedgerAccess={() => openLedgerAccessPopup(href)} />
return <FromLedger webExtensionLedgerAccess={() => openLedgerAccessPopup(href)} disableBluetoothLedger />
}
1 change: 0 additions & 1 deletion src/app/state/importaccounts/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ function* enumerateAccountsFromLedger(action: PayloadAction<LedgerWalletType>) {
}
yield* setStep(ImportAccountsStep.LoadingBalances)
} catch (e: any) {
console.error(e)
let payload: ErrorPayload
if (e instanceof WalletError) {
payload = { code: e.type, message: e.message }
Expand Down

0 comments on commit 7abf490

Please sign in to comment.