Skip to content

Commit

Permalink
fix(suite): recovery_status type change
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-sanderson committed May 14, 2024
1 parent be9e7b3 commit e544383
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/suite/src/actions/recovery/recoveryActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as routerActions from 'src/actions/suite/routerActions';
import { Dispatch, GetState } from 'src/types/suite';
import { WordCount } from 'src/types/recovery';
import { DEFAULT_PASSPHRASE_PROTECTION } from 'src/constants/suite/device';
import { isRecoveryInProgress } from '../../utils/device/isRecoveryInProgress';

export type SeedInputStatus =
| 'initial'
Expand Down Expand Up @@ -167,7 +168,7 @@ const rerun = () => async (dispatch: Dispatch, getState: GetState) => {

const features = response.payload;

if (!features.recovery_mode) {
if (!isRecoveryInProgress(features.recovery_status)) {
return;
}

Expand Down
5 changes: 3 additions & 2 deletions packages/suite/src/middlewares/recovery/recoveryMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { SUITE } from 'src/actions/suite/constants';
import * as recoveryActions from 'src/actions/recovery/recoveryActions';
import * as onboardingActions from 'src/actions/onboarding/onboardingActions';
import { AppState, Action, Dispatch } from 'src/types/suite';
import { isRecoveryInProgress } from '../../utils/device/isRecoveryInProgress';

const recovery =
(api: MiddlewareAPI<Dispatch, AppState>) =>
Expand All @@ -31,7 +32,7 @@ const recovery =

if (
deviceActions.updateSelectedDevice.match(action) &&
action.payload?.features?.recovery_mode &&
isRecoveryInProgress(action.payload?.features?.recovery_status) &&
recovery.status !== 'in-progress'
) {
api.dispatch(
Expand All @@ -41,7 +42,7 @@ const recovery =
}),
);
if (!analytics.confirmed) {
// If you connect T2T1 in recovery mode to fresh Suite, you should see analytics optout option first.
// If you connect T2T1 in recovery mode to fresh Suite, you should see analytics opt-out option first.
api.dispatch(recoveryActions.setStatus('in-progress'));
} else {
api.dispatch(recoveryActions.rerun());
Expand Down
4 changes: 4 additions & 0 deletions packages/suite/src/utils/device/isRecoveryInProgress.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { PROTO } from '@trezor/connect';

export const isRecoveryInProgress = (recoveryStatus: PROTO.RecoveryStatus | undefined) =>
recoveryStatus !== undefined && recoveryStatus !== PROTO.RecoveryStatus.NoRecovery;
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ const doesSupportMultiShare = (device: TrezorDevice | undefined): boolean => {
return false;
}

if (!device.features.capabilities?.includes('Capability_ShamirGroups')) {
if (!device.features.capabilities?.includes('Capability_Shamir')) {
return false;
}

// TODO: Add IF to cover `is_extendable` flag/case

return (
device.features.backup_type !== null &&
['Slip39_Basic', 'Slip39_Advanced'].includes(device.features.backup_type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ import { WipeDevice } from './WipeDevice';
import { ChangeLanguage } from './ChangeLanguage';
import { EnableViewOnly } from './EnableViewOnly';
import { selectSuiteFlags } from 'src/reducers/suite/suiteReducer';
import { isRecoveryInProgress } from '../../../utils/device/isRecoveryInProgress';

const deviceSettingsUnavailable = (device?: TrezorDevice, transport?: Partial<TransportInfo>) => {
const noTransportAvailable = transport && !transport.type;
const wrongDeviceType = device?.type && ['unacquired', 'unreadable'].includes(device.type);
const wrongDeviceMode =
(device?.mode && ['seedless'].includes(device.mode)) || device?.features?.recovery_mode;
(device?.mode && ['seedless'].includes(device.mode)) ||
isRecoveryInProgress(device?.features?.recovery_status);
const firmwareUpdateRequired = device?.firmware === 'required';

return noTransportAvailable || wrongDeviceType || wrongDeviceMode || firmwareUpdateRequired;
Expand Down

0 comments on commit e544383

Please sign in to comment.