chore(device-utils): use connect Device type

This commit is contained in:
tomasklim
2023-08-21 13:10:16 +02:00
committed by Tomáš Klíma
parent 5eaa652ee2
commit 19309be6d7
4 changed files with 11 additions and 37 deletions

View File

@@ -1,10 +1,10 @@
import { PartialDevice } from './types';
import { Device } from '@trezor/connect';
import { isDeviceInBootloaderMode } from './modeUtils';
export const getBootloaderHash = (device?: PartialDevice) =>
device?.features?.bootloader_hash || '';
export const getBootloaderHash = (device?: Device) => device?.features?.bootloader_hash || '';
export const getBootloaderVersion = (device?: PartialDevice) => {
export const getBootloaderVersion = (device?: Device) => {
if (!device?.features) {
return '';
}

View File

@@ -1,11 +1,10 @@
import { FirmwareType } from '@trezor/connect';
import { FirmwareType, Device } from '@trezor/connect';
import { PartialDevice } from './types';
import { isDeviceInBootloaderMode } from './modeUtils';
export const getFirmwareRevision = (device?: PartialDevice) => device?.features?.revision || '';
export const getFirmwareRevision = (device?: Device) => device?.features?.revision || '';
export const getFirmwareVersion = (device?: PartialDevice) => {
export const getFirmwareVersion = (device?: Device) => {
if (!device?.features) {
return '';
}
@@ -20,5 +19,5 @@ export const getFirmwareVersion = (device?: PartialDevice) => {
return `${features.major_version}.${features.minor_version}.${features.patch_version}`;
};
export const hasBitcoinOnlyFirmware = (device?: PartialDevice) =>
export const hasBitcoinOnlyFirmware = (device?: Device) =>
device?.firmwareType === FirmwareType.BitcoinOnly;

View File

@@ -1,9 +1,8 @@
import { PartialDevice } from './types';
import { Device } from '@trezor/connect';
export const isDeviceInBootloaderMode = (device?: PartialDevice) =>
!!device?.features?.bootloader_mode;
export const isDeviceInBootloaderMode = (device?: Device) => !!device?.features?.bootloader_mode;
export const getDeviceMode = (device?: PartialDevice) => {
export const getDeviceMode = (device?: Device) => {
if (device?.features?.bootloader_mode) return 'bootloader';
if (!device?.features?.initialized) return 'initialize';
if (device?.features?.no_backup) return 'seedless';

View File

@@ -1,24 +0,0 @@
// TODO: ⬇️ comment does not apply anymore
// define required device attributes here to avoid dependencies
import { FirmwareType } from '@trezor/connect';
// can be replaced in the future when we create a device types package
export type PartialDevice = Partial<{
features: {
bootloader_mode: boolean | null;
bootloader_hash: string | null;
revision: string | null;
major_version: number | null;
minor_version: number | null;
patch_version: number | null;
fw_major: number | null;
fw_minor: number | null;
fw_patch: number | null;
initialized: boolean | null;
no_backup: boolean | null;
model: string | null;
internal_model: string | null;
};
firmwareType?: FirmwareType;
}>;