feat(device-utils): internal_model, display name utility in device-utils

This commit is contained in:
tomasklim
2023-07-18 13:45:19 +02:00
committed by Matěj Kříž
parent 8c0b6415e9
commit d39278cfd9
5 changed files with 27 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ export const getDeviceFeatures = (feat?: Partial<Features>): Features => ({
needs_backup: false,
flags: 0,
model: 'T',
internal_model: 'T2T1',
fw_major: null,
fw_minor: null,
fw_patch: null,

View File

@@ -7,6 +7,27 @@ export enum DeviceModel {
UNKNOWN = '',
}
export enum DeviceInternalModel {
T1 = 'T1B1',
TT = 'T2T1',
T2B1 = 'T2B1',
UNKNOWN = '',
}
export const getDeviceDisplayName = (deviceModel: DeviceModel) => {
switch (deviceModel) {
case DeviceModel.T1:
return 'Trezor Model One';
case DeviceModel.TT:
return 'Trezor Model T';
case DeviceModel.T2B1:
return 'Trezor Model R';
default:
console.error('Unknown Trezor device');
return 'Trezor';
}
};
export const getDeviceModel = (device?: PartialDevice): DeviceModel => {
const deviceModel = device?.features?.model;

View File

@@ -14,6 +14,7 @@ export type PartialDevice = Partial<{
initialized: boolean | null;
no_backup: boolean | null;
model: string | null;
internal_model: string | null;
};
firmwareType: string | null;
}>;

View File

@@ -17,7 +17,7 @@ import {
BlockchainNetworks,
} from '@suite-common/wallet-types';
import { networksCompatibility } from '@suite-common/wallet-config';
import { DeviceModel } from '@trezor/device-utils';
import { DeviceModel, DeviceInternalModel } from '@trezor/device-utils';
// in-memory implementation of indexedDB
import 'fake-indexeddb/auto';
@@ -111,6 +111,7 @@ const getDeviceFeatures = (feat?: Partial<Features>): Features => ({
needs_backup: false,
flags: 0,
model: DeviceModel.TT,
internal_model: DeviceInternalModel.TT,
fw_major: null,
fw_minor: null,
fw_patch: null,

View File

@@ -34,7 +34,9 @@ export const hiddenDevice: TrezorDevice = {
firmware_present: null,
needs_backup: false,
flags: 0,
// TODO: use DeviceModel, DeviceInternalModel enums
model: 'T',
internal_model: 'T2T1',
fw_major: null,
fw_minor: null,
fw_patch: null,