Skip to content

Commit a0edc7e

Browse files
committed
feat(suite): useRetryFwAuthenticityChecks in Desktop
1 parent 8c9066f commit a0edc7e

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

packages/suite/src/components/suite/Preloader/Preloader.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import { type FC, type PropsWithChildren, useEffect } from 'react';
22

3-
import { selectShouldDisplayDeviceCompromisedOnRoute } from '@suite/authenticity-checks';
3+
import {
4+
selectFirmwareRevisionCheckErrorIfEnabled,
5+
selectShouldDisplayDeviceCompromisedOnRoute,
6+
} from '@suite/authenticity-checks';
47
import { selectDesktopUpdateAllowPrerelease } from '@suite/desktop-update';
5-
import { useDevice } from '@suite/device';
8+
import { rerunFwAuthenticityChecksThunk, useDevice } from '@suite/device';
69
import { KillswitchMessageScreen } from '@suite/message-system';
710
import { selectIsAnalyticsConfirmed } from '@suite-common/analytics-redux';
8-
import { useReportDeviceCompromised } from '@suite-common/firmware-authenticity';
11+
import {
12+
useReportDeviceCompromised,
13+
useRetryFwAuthenticityChecks,
14+
} from '@suite-common/firmware-authenticity';
915
import { selectActiveKillswitchMessage } from '@suite-common/message-system';
1016
import { Card } from '@trezor/components';
1117

@@ -67,6 +73,10 @@ export const Preloader = ({ children }: PropsWithChildren) => {
6773

6874
const dispatch = useDispatch();
6975

76+
const firmwareRevisionCheckError = useSelector(selectFirmwareRevisionCheckErrorIfEnabled);
77+
const rerunFwAuthenticityChecksCall = () => dispatch(rerunFwAuthenticityChecksThunk());
78+
useRetryFwAuthenticityChecks({ firmwareRevisionCheckError, rerunFwAuthenticityChecksCall });
79+
7080
useEffect(() => {
7181
// Analytics needs to be resolved before we show anything to the user. Until this is solved,
7282
// we do not init anything. Especially nothing related to the devices/connect. With THP,

suite/device/src/deviceThunks.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import { selectIsDeviceLocked } from '@suite/locks';
12
import { selectRouterApp } from '@suite/router';
23
import { selectSelectedDevice } from '@suite-common/device';
34
import { createThunk } from '@suite-common/redux-utils';
45
import type { TrezorDevice } from '@suite-common/suite-types';
56
import { handleDeviceDisconnect, selectDeviceThunk } from '@suite-common/wallet-core';
67
import type { Device } from '@trezor/connect';
8+
import TrezorConnect from '@trezor/connect';
79

810
const DEVICE_MODULE_PREFIX = '@suite';
911

@@ -29,3 +31,14 @@ export const disconnectDeviceThunk = createThunk(
2931
dispatch(handleDeviceDisconnect(device));
3032
},
3133
);
34+
35+
/**
36+
* Connect call to rerun FW authenticity checks (getFeatures used as the most basic no-op device call).
37+
*/
38+
export const rerunFwAuthenticityChecksThunk = createThunk(
39+
`${DEVICE_MODULE_PREFIX}/rerunFwAuthenticityChecksThunk`,
40+
(_, { getState }) => {
41+
if (selectIsDeviceLocked(getState())) return;
42+
TrezorConnect.getFeatures();
43+
},
44+
);

0 commit comments

Comments
 (0)