Skip to content

Commit

Permalink
feat(suite-native): do not report FW revision offline error
Browse files Browse the repository at this point in the history
  • Loading branch information
Lemonexe committed Feb 6, 2025
1 parent dff99b4 commit 41c1919
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions suite-native/device/src/config/firmware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { FirmwareRevisionCheckError } from '@trezor/connect';
*/

// display a warning banner
type SoftWarningBehavior = { type: 'softWarning'; shouldReport: true };
type SoftWarningBehavior = { type: 'softWarning'; shouldReport: boolean };
// display "Device Compromised" modal, after closing it dispaly a warning banner, block receiving address
type HardModalBehavior = { type: 'hardModal'; shouldReport: true };

Expand All @@ -16,6 +16,6 @@ type RevisionCheckErrorScenarios = Record<FirmwareRevisionCheckError, RevisionEr
export const revisionCheckErrorScenarios = {
'revision-mismatch': { type: 'hardModal', shouldReport: true },
'firmware-version-unknown': { type: 'hardModal', shouldReport: true },
'cannot-perform-check-offline': { type: 'softWarning', shouldReport: true },
'cannot-perform-check-offline': { type: 'softWarning', shouldReport: false },
'other-error': { type: 'softWarning', shouldReport: true },
} satisfies RevisionCheckErrorScenarios;
6 changes: 5 additions & 1 deletion suite-native/device/src/hooks/useReportDeviceCompromised.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as Sentry from '@sentry/react-native';
import { selectSelectedDevice } from '@suite-common/wallet-core';
import { getFirmwareVersion } from '@trezor/device-utils';

import { revisionCheckErrorScenarios } from '../config/firmware';
import { selectFirmwareRevisionCheckError } from '../selectors';

const reportCheckFail = (checkType: 'Firmware revision', contextData: any) => {
Expand All @@ -31,7 +32,10 @@ export const useReportDeviceCompromised = () => {
const revisionCheckError = useSelector(selectFirmwareRevisionCheckError);

useEffect(() => {
if (revisionCheckError !== null) {
if (
revisionCheckError !== null &&
revisionCheckErrorScenarios[revisionCheckError].shouldReport
) {
reportCheckFail('Firmware revision', { ...commonData, revisionCheckError });
}
}, [commonData, revisionCheckError]);
Expand Down

0 comments on commit 41c1919

Please sign in to comment.