Skip to content

Commit

Permalink
feat(nami): accept trezor safe 5 device (#1478)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceahasegan authored and mchappell committed Oct 25, 2024
1 parent d17e330 commit e653576
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/nami/src/ui/app/hw/connect-hw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React from 'react';

import { ChevronRightIcon } from '@chakra-ui/icons';
import { Box, Button, Icon, Image, Text, useColorMode } from '@chakra-ui/react';
import { ledgerUSBVendorId } from '@ledgerhq/devices';
import { MdUsb } from 'react-icons/md';

import LedgerLogo from '../../../assets/img/ledgerLogo.svg';
Expand All @@ -20,9 +21,9 @@ interface ConnectHWProps {
onConfirm: (data: Readonly<Wallet.HardwareWalletConnection>) => void;
}

const MANUFACTURER: Record<string, string> = {
ledger: 'Ledger',
trezor: 'SatoshiLabs',
const VENDOR_IDS: Record<string, number[]> = {
ledger: [ledgerUSBVendorId],
trezor: [0x53_4c, 0x12_09], // Model T HID 0x534c and others 0x1209 - taken from https://github.com/vacuumlabs/trezor-suite/blob/develop/packages/transport/src/constants.ts#L13-L21
};

export const ConnectHW = ({ onConfirm }: ConnectHWProps): ReactElement => {
Expand All @@ -41,7 +42,7 @@ export const ConnectHW = ({ onConfirm }: ConnectHWProps): ReactElement => {
const device = await navigator.usb.requestDevice({
filters: [],
});
if (device.manufacturerName !== MANUFACTURER[selected]) {
if (!VENDOR_IDS[selected].includes(device.vendorId)) {
setError(
`Device is not a ${selected === HW.ledger ? 'Ledger' : 'Trezor'}`,
);
Expand Down

0 comments on commit e653576

Please sign in to comment.