|
1 | 1 | import { useEffect, useMemo } from 'react';
|
2 | 2 |
|
| 3 | +import { FIRMWARE } from '@trezor/connect'; |
3 | 4 | import { getFirmwareVersion } from '@trezor/device-utils';
|
4 | 5 | import { isDeviceAcquired } from '@suite-common/suite-utils';
|
| 6 | +import { isArrayMember } from '@trezor/utils'; |
5 | 7 |
|
6 | 8 | import { useDevice, useSelector } from 'src/hooks/suite';
|
7 | 9 | import { captureSentryMessage, withSentryScope } from 'src/utils/suite/sentry';
|
@@ -76,13 +78,14 @@ const useReportHashCheck = () => {
|
76 | 78 | const attemptCount = isError ? hashCheck.attemptCount : null;
|
77 | 79 |
|
78 | 80 | useEffect(() => {
|
79 |
| - if (errorType && hashCheckErrorScenarios[errorType].shouldReport) { |
80 |
| - reportCheckFail( |
81 |
| - 'Firmware hash', |
82 |
| - { ...commonData, errorType, attemptCount }, |
83 |
| - errorPayload, |
84 |
| - ); |
85 |
| - } |
| 81 | + if (!errorType) return; |
| 82 | + if (!hashCheckErrorScenarios[errorType].shouldReport) return; |
| 83 | + const willBeRetried = |
| 84 | + isArrayMember(errorType, FIRMWARE.HASH_CHECK_RETRIABLE_ERRORS) && |
| 85 | + (attemptCount ?? 0) < FIRMWARE.HASH_CHECK_MAX_ATTEMPTS; |
| 86 | + if (willBeRetried) return; |
| 87 | + |
| 88 | + reportCheckFail('Firmware hash', { ...commonData, errorType, attemptCount }, errorPayload); |
86 | 89 | }, [commonData, errorType, errorPayload, attemptCount]);
|
87 | 90 |
|
88 | 91 | // success bears warning if it needed retries, so we report the previous error payload, see Device.ts in connect
|
|
0 commit comments