mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-09 16:58:32 +01:00
fix(suite): change condition so that btc-only device with universal fw updates to universal
This commit is contained in:
@@ -19,7 +19,10 @@ export const getFirmwareVersion = (device?: Device) => {
|
||||
return `${features.major_version}.${features.minor_version}.${features.patch_version}`;
|
||||
};
|
||||
|
||||
// This can give a false negative in bootloader mode for T1B1 and T2T1.
|
||||
export const hasBitcoinOnlyFirmware = (device?: Device) =>
|
||||
device?.firmwareType === FirmwareType.BitcoinOnly;
|
||||
|
||||
export const isBitcoinOnlyDevice = (device?: Device) => device?.features?.unit_btconly;
|
||||
// Bitcoin-only device with Universal firmware is treated as a regular device.
|
||||
export const isBitcoinOnlyDevice = (device?: Device) =>
|
||||
!!device?.features?.unit_btconly && device?.firmwareType !== FirmwareType.Regular;
|
||||
|
||||
@@ -159,17 +159,16 @@ export const FirmwareInitial = ({
|
||||
currentFwVersion &&
|
||||
availableFwVersion === currentFwVersion
|
||||
);
|
||||
const bitcoinOnlyDevice = isBitcoinOnlyDevice(device);
|
||||
const isCurrentlyBitcoinOnly = hasBitcoinOnlyFirmware(device) || bitcoinOnlyDevice;
|
||||
const isCurrentlyBitcoinOnly = hasBitcoinOnlyFirmware(device);
|
||||
const targetFirmwareType =
|
||||
// switching to Regular
|
||||
(isCurrentlyBitcoinOnly && shouldSwitchFirmwareType) ||
|
||||
// updating Regular
|
||||
(!isCurrentlyBitcoinOnly && !shouldSwitchFirmwareType) ||
|
||||
// attempting to switch to Bitcoin-only from old firmware
|
||||
(!isCurrentlyBitcoinOnly && shouldSwitchFirmwareType && !isBitcoinOnlyAvailable)
|
||||
? FirmwareType.Regular
|
||||
: FirmwareType.BitcoinOnly;
|
||||
// updating Bitcoin-only
|
||||
(isCurrentlyBitcoinOnly && !shouldSwitchFirmwareType) ||
|
||||
// switching to Bitcoin-only
|
||||
(!isCurrentlyBitcoinOnly && shouldSwitchFirmwareType && isBitcoinOnlyAvailable) ||
|
||||
// Bitcoin-only device
|
||||
isBitcoinOnlyDevice(device)
|
||||
? FirmwareType.BitcoinOnly
|
||||
: FirmwareType.Regular;
|
||||
|
||||
const installFirmware = (type: FirmwareType) => {
|
||||
onInstall(type);
|
||||
@@ -196,7 +195,10 @@ export const FirmwareInitial = ({
|
||||
</Description>
|
||||
),
|
||||
body: cachedDevice?.firmwareRelease ? (
|
||||
<FirmwareOffer device={cachedDevice} />
|
||||
<FirmwareOffer
|
||||
device={cachedDevice}
|
||||
targetFirmwareType={FirmwareType.BitcoinOnly}
|
||||
/>
|
||||
) : undefined,
|
||||
innerActions: (
|
||||
<ButtonRow>
|
||||
|
||||
@@ -2,7 +2,7 @@ import styled from 'styled-components';
|
||||
|
||||
import { getFwUpdateVersion, parseFirmwareChangelog } from '@suite-common/suite-utils';
|
||||
import { Icon, Tooltip, variables } from '@trezor/components';
|
||||
import { getFirmwareVersion, isBitcoinOnlyDevice } from '@trezor/device-utils';
|
||||
import { getFirmwareVersion } from '@trezor/device-utils';
|
||||
import { AcquiredDevice } from '@suite-common/suite-types';
|
||||
import { FirmwareType } from '@trezor/connect';
|
||||
|
||||
@@ -63,20 +63,12 @@ export const FirmwareOffer = ({
|
||||
? null
|
||||
: parseFirmwareChangelog(device.firmwareRelease?.release);
|
||||
|
||||
const firmwareType =
|
||||
device.firmwareType ||
|
||||
(isBitcoinOnlyDevice(device) ? FirmwareType.BitcoinOnly : FirmwareType.Regular);
|
||||
|
||||
const currentFirmwareType = getSuiteFirmwareTypeString(firmwareType);
|
||||
|
||||
// firmware type is undefined in bootloader on non-btc-only devices, regular type will be installed by default
|
||||
const futureFirmwareType = getSuiteFirmwareTypeString(
|
||||
targetFirmwareType || targetType || FirmwareType.Regular,
|
||||
);
|
||||
const currentFirmwareType = getSuiteFirmwareTypeString(device.firmwareType);
|
||||
const futureFirmwareType = getSuiteFirmwareTypeString(targetFirmwareType || targetType);
|
||||
|
||||
const nextVersionElement = (
|
||||
<Version isNew data-test="@firmware/offer-version/new">
|
||||
<Translation id={futureFirmwareType!} />
|
||||
{futureFirmwareType ? translationString(futureFirmwareType) : ''}
|
||||
{nextVersion ? ` ${nextVersion}` : ''}
|
||||
{useDevkit ? ' DEVKIT' : ''}
|
||||
</Version>
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
} from '@trezor/device-utils';
|
||||
import { HELP_FIRMWARE_TYPE } from '@trezor/urls';
|
||||
import { getSuiteFirmwareTypeString } from 'src/utils/firmware';
|
||||
import { FirmwareType } from '@trezor/connect';
|
||||
|
||||
const Version = styled.div`
|
||||
span {
|
||||
@@ -42,9 +41,7 @@ export const FirmwareTypeChange = ({ isDeviceLocked }: FirmwareTypeProps) => {
|
||||
|
||||
const bitcoinOnlyDevice = isBitcoinOnlyDevice(device);
|
||||
const currentFwVersion = getFirmwareVersion(device);
|
||||
const currentFwType = getSuiteFirmwareTypeString(
|
||||
device.firmwareType || (bitcoinOnlyDevice ? FirmwareType.BitcoinOnly : undefined),
|
||||
);
|
||||
const currentFwType = getSuiteFirmwareTypeString(device.firmwareType);
|
||||
const actionButtonId = hasBitcoinOnlyFirmware(device)
|
||||
? 'TR_SWITCH_TO_REGULAR'
|
||||
: 'TR_SWITCH_TO_BITCOIN_ONLY';
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
getBootloaderVersion,
|
||||
getFirmwareVersion,
|
||||
hasBitcoinOnlyFirmware,
|
||||
isBitcoinOnlyDevice,
|
||||
} from '@trezor/device-utils';
|
||||
import { Await } from '@trezor/type-utils';
|
||||
import { isDesktop } from '@trezor/env-utils';
|
||||
@@ -101,19 +102,24 @@ const firmwareInstallThunk = createThunk(
|
||||
|
||||
// update to same variant as is currently installed or to the regular one if device does not have any fw (new/wiped device),
|
||||
// unless the user wants to switch firmware type
|
||||
let toBitcoinOnlyFirmware = firmwareType === FirmwareType.BitcoinOnly;
|
||||
if (!firmwareType) {
|
||||
toBitcoinOnlyFirmware = !prevDevice ? false : hasBitcoinOnlyFirmware(prevDevice);
|
||||
}
|
||||
const getTargetFirmwareType = () => {
|
||||
if (firmwareType) {
|
||||
return firmwareType;
|
||||
}
|
||||
return hasBitcoinOnlyFirmware(prevDevice) || isBitcoinOnlyDevice(prevDevice)
|
||||
? FirmwareType.BitcoinOnly
|
||||
: FirmwareType.Regular;
|
||||
};
|
||||
|
||||
const targetFirmwareType = getTargetFirmwareType();
|
||||
const toBitcoinOnlyFirmware = targetFirmwareType === FirmwareType.BitcoinOnly;
|
||||
|
||||
const targetFirmwareVersion = release.version.join('.');
|
||||
|
||||
console.warn(
|
||||
intermediaryVersion
|
||||
? `Cannot install latest firmware. Will install intermediary v${intermediaryVersion} instead.`
|
||||
: `Installing ${
|
||||
toBitcoinOnlyFirmware ? FirmwareType.BitcoinOnly : FirmwareType.Regular
|
||||
} firmware ${targetFirmwareVersion}.`,
|
||||
: `Installing ${targetFirmwareType} firmware ${targetFirmwareVersion}.`,
|
||||
);
|
||||
|
||||
analyticsPayload = {
|
||||
|
||||
Reference in New Issue
Block a user