mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-09 08:48:15 +01:00
refactor: from regular to universal firmware-type
This commit is contained in:
@@ -906,7 +906,7 @@ export class Device extends TypedEmitter<DeviceEvents> {
|
||||
if (feat.fw_vendor === 'Trezor Bitcoin-only') {
|
||||
this._firmwareType = FirmwareType.BitcoinOnly;
|
||||
} else if (feat.fw_vendor === 'Trezor') {
|
||||
this._firmwareType = FirmwareType.Regular;
|
||||
this._firmwareType = FirmwareType.Universal;
|
||||
} else if (this.getMode() !== 'bootloader') {
|
||||
// Relevant for T1B1, T2T1 and custom firmware with a different vendor header. Capabilities do not work in bootloader mode.
|
||||
this._firmwareType =
|
||||
@@ -914,7 +914,7 @@ export class Device extends TypedEmitter<DeviceEvents> {
|
||||
feat.capabilities.length > 0 &&
|
||||
!feat.capabilities.includes('Capability_Bitcoin_like')
|
||||
? FirmwareType.BitcoinOnly
|
||||
: FirmwareType.Regular;
|
||||
: FirmwareType.Universal;
|
||||
}
|
||||
|
||||
const deviceInfo = models[feat.internal_model] ?? {
|
||||
|
||||
@@ -58,4 +58,4 @@ export const hasBitcoinOnlyFirmware = (device?: PartialDevice) =>
|
||||
|
||||
// Bitcoin-only device with Universal firmware is treated as a regular device.
|
||||
export const isBitcoinOnlyDevice = (device?: PartialDevice) =>
|
||||
!!device?.features?.unit_btconly && device?.firmwareType !== FirmwareType.Regular;
|
||||
!!device?.features?.unit_btconly && device?.firmwareType !== FirmwareType.Universal;
|
||||
|
||||
@@ -4,7 +4,7 @@ export type FirmwareVersionString = `${number}.${number}.${number}`;
|
||||
|
||||
export enum FirmwareType {
|
||||
BitcoinOnly = 'bitcoin-only',
|
||||
Regular = 'regular',
|
||||
Universal = 'universal',
|
||||
}
|
||||
|
||||
export type VersionArray = [number, number, number];
|
||||
|
||||
@@ -44,7 +44,7 @@ export const init: ModuleInit = ({ mainThreadEmitter }) => {
|
||||
binary,
|
||||
binaryVersion,
|
||||
internalModel,
|
||||
firmwareType = FirmwareType.Regular,
|
||||
firmwareType = FirmwareType.Universal,
|
||||
} = event;
|
||||
|
||||
const firmwareBinName = buildFirmwareFileName(
|
||||
|
||||
@@ -34,7 +34,7 @@ const firmwareUpdateResponsePayload = {
|
||||
export const actions = [
|
||||
{
|
||||
description: 'Success T2T1',
|
||||
action: () => firmwareUpdate({ firmwareType: FirmwareType.Regular }),
|
||||
action: () => firmwareUpdate({ firmwareType: FirmwareType.Universal }),
|
||||
mocks: {
|
||||
connect: {
|
||||
success: true,
|
||||
@@ -51,7 +51,7 @@ export const actions = [
|
||||
result: {
|
||||
actions: [
|
||||
{ type: firmwareActions.setStatus.type, payload: 'started' },
|
||||
{ type: firmwareActions.setTargetType.type, payload: FirmwareType.Regular },
|
||||
{ type: firmwareActions.setTargetType.type, payload: FirmwareType.Universal },
|
||||
{ type: firmwareActions.cacheDevice.type, payload: bootloaderDevice },
|
||||
{ type: firmwareActions.setStatus.type, payload: 'done' },
|
||||
],
|
||||
@@ -86,7 +86,7 @@ export const actions = [
|
||||
},
|
||||
{
|
||||
description: 'Success T1B1 (with intermediary)',
|
||||
action: () => firmwareUpdate({ firmwareType: FirmwareType.Regular }),
|
||||
action: () => firmwareUpdate({ firmwareType: FirmwareType.Universal }),
|
||||
mocks: {
|
||||
connect: {
|
||||
success: true,
|
||||
@@ -103,7 +103,7 @@ export const actions = [
|
||||
result: {
|
||||
actions: [
|
||||
{ type: firmwareActions.setStatus.type, payload: 'started' },
|
||||
{ type: firmwareActions.setTargetType.type, payload: FirmwareType.Regular },
|
||||
{ type: firmwareActions.setTargetType.type, payload: FirmwareType.Universal },
|
||||
{
|
||||
type: firmwareActions.cacheDevice.type,
|
||||
payload: bootloaderDeviceNeedsIntermediary,
|
||||
@@ -115,7 +115,7 @@ export const actions = [
|
||||
},
|
||||
{
|
||||
description: 'Success T1B1 (without intermediary)',
|
||||
action: () => firmwareUpdate({ firmwareType: FirmwareType.Regular }),
|
||||
action: () => firmwareUpdate({ firmwareType: FirmwareType.Universal }),
|
||||
mocks: {
|
||||
connect: {
|
||||
success: true,
|
||||
@@ -132,7 +132,7 @@ export const actions = [
|
||||
result: {
|
||||
actions: [
|
||||
{ type: firmwareActions.setStatus.type, payload: 'started' },
|
||||
{ type: firmwareActions.setTargetType.type, payload: FirmwareType.Regular },
|
||||
{ type: firmwareActions.setTargetType.type, payload: FirmwareType.Universal },
|
||||
{
|
||||
type: firmwareActions.cacheDevice.type,
|
||||
payload: bootloaderDeviceNoIntermediaryT1,
|
||||
@@ -144,7 +144,7 @@ export const actions = [
|
||||
},
|
||||
{
|
||||
description: 'Fails for missing device',
|
||||
action: () => firmwareUpdate({ firmwareType: FirmwareType.Regular }),
|
||||
action: () => firmwareUpdate({ firmwareType: FirmwareType.Universal }),
|
||||
initialState: {
|
||||
device: {
|
||||
selectedDevice: undefined,
|
||||
@@ -157,7 +157,7 @@ export const actions = [
|
||||
},
|
||||
{
|
||||
description: 'FirmwareUpdate call to connect fails',
|
||||
action: () => firmwareUpdate({ firmwareType: FirmwareType.Regular }),
|
||||
action: () => firmwareUpdate({ firmwareType: FirmwareType.Universal }),
|
||||
initialState: {
|
||||
device: {
|
||||
selectedDevice: bootloaderDevice,
|
||||
@@ -176,7 +176,7 @@ export const actions = [
|
||||
result: {
|
||||
actions: [
|
||||
{ type: firmwareActions.setStatus.type, payload: 'started' },
|
||||
{ type: firmwareActions.setTargetType.type, payload: FirmwareType.Regular },
|
||||
{ type: firmwareActions.setTargetType.type, payload: FirmwareType.Universal },
|
||||
{ type: firmwareActions.cacheDevice.type, payload: bootloaderDevice },
|
||||
{ type: firmwareActions.setStatus.type, payload: 'error' },
|
||||
{ type: firmwareActions.setFirmwareUpdateError.type, payload: 'foo' },
|
||||
@@ -194,7 +194,7 @@ export const actions = [
|
||||
},
|
||||
{
|
||||
description: 'FirmwareUpdate call to connect fails due to cancelling on device',
|
||||
action: () => firmwareUpdate({ firmwareType: FirmwareType.Regular }),
|
||||
action: () => firmwareUpdate({ firmwareType: FirmwareType.Universal }),
|
||||
initialState: {
|
||||
device: {
|
||||
selectedDevice: bootloaderDevice,
|
||||
@@ -213,7 +213,7 @@ export const actions = [
|
||||
result: {
|
||||
actions: [
|
||||
{ type: firmwareActions.setStatus.type, payload: 'started' },
|
||||
{ type: firmwareActions.setTargetType.type, payload: FirmwareType.Regular },
|
||||
{ type: firmwareActions.setTargetType.type, payload: FirmwareType.Universal },
|
||||
{ type: firmwareActions.cacheDevice.type, payload: bootloaderDevice },
|
||||
{ type: firmwareActions.setStatus.type, payload: 'error' },
|
||||
{
|
||||
|
||||
@@ -180,7 +180,7 @@ export const FirmwareInitial = ({
|
||||
<FirmwareButtonsRow>
|
||||
<FirmwareInstallButton
|
||||
variant="tertiary"
|
||||
onClick={() => installFirmware(FirmwareType.Regular)}
|
||||
onClick={() => installFirmware(FirmwareType.Universal)}
|
||||
multipleDevicesConnected={multipleDevicesConnected}
|
||||
>
|
||||
<Translation
|
||||
|
||||
@@ -111,7 +111,7 @@ export const stepCategories: StepCategory[] = [
|
||||
{
|
||||
id: STEP.ID_COINS_STEP,
|
||||
prerequisites: [...commonPrerequisites, ...afterInitializePrerequisites],
|
||||
supportedFirmwareTypes: [FirmwareType.Regular],
|
||||
supportedFirmwareTypes: [FirmwareType.Universal],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -457,7 +457,7 @@ export const runLegacyMigrations: OnUpgradeFunc<SuiteDBSchema> = async (
|
||||
features.capabilities &&
|
||||
!features.capabilities.includes('Capability_Bitcoin_like')
|
||||
? FirmwareType.BitcoinOnly
|
||||
: FirmwareType.Regular;
|
||||
: FirmwareType.Universal;
|
||||
|
||||
return device;
|
||||
});
|
||||
|
||||
@@ -88,7 +88,7 @@ export const getSuiteFirmwareTypeString = (firmwareType?: FirmwareType) => {
|
||||
switch (firmwareType) {
|
||||
case FirmwareType.BitcoinOnly:
|
||||
return 'TR_FIRMWARE_TYPE_BITCOIN_ONLY';
|
||||
case FirmwareType.Regular:
|
||||
case FirmwareType.Universal:
|
||||
return 'TR_FIRMWARE_TYPE_REGULAR';
|
||||
default:
|
||||
return undefined;
|
||||
|
||||
@@ -28,7 +28,7 @@ const backupStep: Step = {
|
||||
|
||||
const coinsStep: Step = {
|
||||
id: STEP.ID_COINS_STEP,
|
||||
supportedFirmwareTypes: [FirmwareType.Regular],
|
||||
supportedFirmwareTypes: [FirmwareType.Universal],
|
||||
};
|
||||
|
||||
const stepCategory: StepCategory = {
|
||||
@@ -39,7 +39,7 @@ const stepCategory: StepCategory = {
|
||||
|
||||
const defaultDevice = {
|
||||
features: { internal_model: DeviceModelInternal.T1B1 },
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
} as AcquiredDevice;
|
||||
|
||||
const propsMock: IsStepUsedProps = {
|
||||
|
||||
@@ -84,7 +84,7 @@ export const firmwareUpdate = createThunk<
|
||||
|
||||
return hasBitcoinOnlyFirmware(device) || isBitcoinOnlyDevice(device)
|
||||
? FirmwareType.BitcoinOnly
|
||||
: FirmwareType.Regular;
|
||||
: FirmwareType.Universal;
|
||||
};
|
||||
|
||||
const targetFirmwareType = getTargetFirmwareType();
|
||||
|
||||
@@ -172,7 +172,7 @@ export const useFirmwareInstallation = (
|
||||
// Bitcoin-only device:
|
||||
isBitcoinOnlyDevice(originalDevice)
|
||||
? FirmwareType.BitcoinOnly
|
||||
: FirmwareType.Regular;
|
||||
: FirmwareType.Universal;
|
||||
}, [originalDevice, shouldSwitchFirmwareType]);
|
||||
|
||||
const firmwareUpdate = useCallback(
|
||||
|
||||
@@ -465,7 +465,7 @@
|
||||
"variant": {
|
||||
"title": "Firmware Variant",
|
||||
"type": "string",
|
||||
"enum": ["*", "bitcoin-only", "regular"]
|
||||
"enum": ["*", "bitcoin-only", "universal"]
|
||||
},
|
||||
"vendor": {
|
||||
"title": "Vendor",
|
||||
|
||||
@@ -602,7 +602,7 @@ export const isDeviceCompatible = [
|
||||
patch_version: 3,
|
||||
capabilities: ['Capability_Bitcoin_like'],
|
||||
}),
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
},
|
||||
result: true,
|
||||
@@ -623,7 +623,7 @@ export const isDeviceCompatible = [
|
||||
firmware: ['3.0'],
|
||||
bootloader: '*',
|
||||
firmwareRevision: '*',
|
||||
variant: FirmwareType.Regular,
|
||||
variant: FirmwareType.Universal,
|
||||
vendor: 'trezor.io',
|
||||
},
|
||||
],
|
||||
@@ -665,7 +665,7 @@ export const isDeviceCompatible = [
|
||||
capabilities: ['Capability_Bitcoin_like'],
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: false,
|
||||
},
|
||||
@@ -677,7 +677,7 @@ export const isDeviceCompatible = [
|
||||
firmware: '1',
|
||||
bootloader: '*',
|
||||
firmwareRevision: '*',
|
||||
variant: FirmwareType.Regular,
|
||||
variant: FirmwareType.Universal,
|
||||
vendor: 'trezor.io',
|
||||
},
|
||||
],
|
||||
@@ -692,7 +692,7 @@ export const isDeviceCompatible = [
|
||||
capabilities: ['Capability_Bitcoin_like'],
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: false,
|
||||
},
|
||||
@@ -704,7 +704,7 @@ export const isDeviceCompatible = [
|
||||
firmware: '2',
|
||||
bootloader: '*',
|
||||
firmwareRevision: '*',
|
||||
variant: FirmwareType.Regular,
|
||||
variant: FirmwareType.Universal,
|
||||
vendor: 'trezor.io',
|
||||
},
|
||||
],
|
||||
@@ -719,7 +719,7 @@ export const isDeviceCompatible = [
|
||||
capabilities: ['Capability_Bitcoin_like'],
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: false,
|
||||
},
|
||||
@@ -736,7 +736,7 @@ export const isDeviceCompatible = [
|
||||
patch_version: 2,
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: false,
|
||||
},
|
||||
@@ -748,7 +748,7 @@ export const isDeviceCompatible = [
|
||||
firmware: '2',
|
||||
bootloader: '*',
|
||||
firmwareRevision: '*',
|
||||
variant: FirmwareType.Regular,
|
||||
variant: FirmwareType.Universal,
|
||||
vendor: 'trezor.io',
|
||||
},
|
||||
],
|
||||
@@ -796,7 +796,7 @@ export const isDeviceCompatible = [
|
||||
firmware: '1',
|
||||
bootloader: '*',
|
||||
firmwareRevision: '*',
|
||||
variant: FirmwareType.Regular,
|
||||
variant: FirmwareType.Universal,
|
||||
vendor: 'trezor.io',
|
||||
},
|
||||
],
|
||||
@@ -838,7 +838,7 @@ export const isDeviceCompatible = [
|
||||
capabilities: ['Capability_Bitcoin_like'],
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: false,
|
||||
},
|
||||
@@ -865,7 +865,7 @@ export const isDeviceCompatible = [
|
||||
capabilities: ['Capability_Bitcoin_like'],
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: true,
|
||||
},
|
||||
@@ -892,7 +892,7 @@ export const isDeviceCompatible = [
|
||||
capabilities: ['Capability_Bitcoin_like'],
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: false,
|
||||
},
|
||||
@@ -919,7 +919,7 @@ export const isDeviceCompatible = [
|
||||
revision: 'fa8eha',
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: true,
|
||||
},
|
||||
@@ -946,7 +946,7 @@ export const isDeviceCompatible = [
|
||||
revision: 'fa8eha',
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: true,
|
||||
},
|
||||
@@ -973,7 +973,7 @@ export const isDeviceCompatible = [
|
||||
revision: 'fa8eha',
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: false,
|
||||
},
|
||||
@@ -1000,7 +1000,7 @@ export const isDeviceCompatible = [
|
||||
bootloader_mode: true,
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: true,
|
||||
},
|
||||
@@ -1027,7 +1027,7 @@ export const isDeviceCompatible = [
|
||||
bootloader_mode: true,
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: false,
|
||||
},
|
||||
@@ -1054,7 +1054,7 @@ export const isDeviceCompatible = [
|
||||
bootloader_mode: false,
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: false,
|
||||
},
|
||||
@@ -1082,7 +1082,7 @@ export const isDeviceCompatible = [
|
||||
bootloader_mode: false,
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: false,
|
||||
},
|
||||
@@ -1112,7 +1112,7 @@ export const isDeviceCompatible = [
|
||||
bootloader_mode: true,
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: true,
|
||||
},
|
||||
@@ -1142,7 +1142,7 @@ export const isDeviceCompatible = [
|
||||
bootloader_mode: true,
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: false,
|
||||
},
|
||||
@@ -1172,7 +1172,7 @@ export const isDeviceCompatible = [
|
||||
bootloader_mode: true,
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: false,
|
||||
},
|
||||
@@ -1202,7 +1202,7 @@ export const isDeviceCompatible = [
|
||||
bootloader_mode: true,
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: true,
|
||||
},
|
||||
@@ -1229,7 +1229,7 @@ export const isDeviceCompatible = [
|
||||
revision: '123456',
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: true,
|
||||
},
|
||||
@@ -1264,7 +1264,7 @@ export const isDeviceCompatible = [
|
||||
revision: '123456',
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: true,
|
||||
},
|
||||
@@ -1291,7 +1291,7 @@ export const isDeviceCompatible = [
|
||||
revision: '123456',
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: false,
|
||||
},
|
||||
@@ -1318,7 +1318,7 @@ export const isDeviceCompatible = [
|
||||
revision: '123456',
|
||||
}),
|
||||
},
|
||||
firmwareType: FirmwareType.Regular,
|
||||
firmwareType: FirmwareType.Universal,
|
||||
},
|
||||
result: false,
|
||||
},
|
||||
@@ -1802,7 +1802,7 @@ export const getValidMessages: GetValidMessagesFixture[] = [
|
||||
firmware: '2.1.1',
|
||||
firmwareRevision: '*',
|
||||
bootloader: '*',
|
||||
variant: FirmwareType.Regular,
|
||||
variant: FirmwareType.Universal,
|
||||
vendor: 'trezor.io',
|
||||
},
|
||||
],
|
||||
|
||||
@@ -10,7 +10,7 @@ export type DateTime = string;
|
||||
export type Version = string | string[];
|
||||
export type Model = '1' | 'T' | 'T1B1' | 'T2T1' | 'T2B1' | 'Safe 3' | 'T3B1' | 'T3T1' | 'T3W1' | '';
|
||||
export type FirmwareRevision = string;
|
||||
export type FirmwareVariant = '*' | 'bitcoin-only' | 'regular';
|
||||
export type FirmwareVariant = '*' | 'bitcoin-only' | 'universal';
|
||||
/**
|
||||
* Eligible authorized vendors.
|
||||
*/
|
||||
|
||||
@@ -195,7 +195,7 @@ const getConnectDevice = (dev?: Partial<StringPath<Device>>, feat?: Partial<Feat
|
||||
firmwareType:
|
||||
feat && feat.capabilities && !feat?.capabilities.includes('Capability_Bitcoin_like')
|
||||
? FirmwareType.BitcoinOnly
|
||||
: FirmwareType.Regular,
|
||||
: FirmwareType.Universal,
|
||||
name: '',
|
||||
availableTranslations: [],
|
||||
...dev,
|
||||
@@ -371,7 +371,7 @@ const getMessageSystemConfig = (
|
||||
firmware: '2.1.1',
|
||||
bootloader: '*',
|
||||
firmwareRevision: '*',
|
||||
variant: 'regular',
|
||||
variant: 'universal',
|
||||
vendor: 'trezor.io',
|
||||
},
|
||||
],
|
||||
|
||||
@@ -43,7 +43,7 @@ describe('BuyTradeableAssetPicker', () => {
|
||||
|
||||
describe('with regular firmware', () => {
|
||||
beforeEach(async () => {
|
||||
store = await initPreloadedStore(FirmwareType.Regular);
|
||||
store = await initPreloadedStore(FirmwareType.Universal);
|
||||
form = await renderFormHook();
|
||||
});
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ describe('ExchangeTradeableAssetPicker', () => {
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
store = await initPreloadedStore(FirmwareType.Regular);
|
||||
store = await initPreloadedStore(FirmwareType.Universal);
|
||||
form = await renderFormHook();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user