Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@fireblocks/recovery-utility): 🐛 ncw checkbox fix on recover … #70

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 28 additions & 17 deletions apps/recovery-utility/renderer/components/RecoveryForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
useWrappedState,
useOfflineMutation,
} from '@fireblocks/recovery-shared';
import { Checkbox, FormControlLabel, Typography, Box, Grid } from '@mui/material';
import { Checkbox, FormControlLabel, Typography, Box, Grid, Tooltip } from '@mui/material';
import { readFileToBase64 } from '@fireblocks/recovery-shared/lib/readFile';
import { useWorkspace } from '../../context/Workspace';
import { recoverExtendedKeys } from '../../lib/recoverExtendedKeys';
Expand Down Expand Up @@ -109,7 +109,8 @@ export const RecoveryForm = ({ verifyOnly }: Props) => {

const onDropAGPRsaPrivateKey = async (file: File) => setValue('agpRsaKey', await readFileToBase64(file));

const onSubmit = (formData: FormData) => (verifyOnly ? recoverMutation.mutate(formData) : setRecoveryData(formData));
const onSubmit = (formData: FormData) =>
verifyOnly || recoverOnlyNCW ? recoverMutation.mutate(formData) : setRecoveryData(formData);

const onConfirmRecover = () => recoverMutation.mutate(recoveryData as FormData);

Expand Down Expand Up @@ -174,15 +175,22 @@ export const RecoveryForm = ({ verifyOnly }: Props) => {
{...register('agpRsaPassphrase')}
/>
) : (
<TextField
id='passphrase'
type='password'
label='Mobile App Recovery Passphrase'
helpText='Set by the workspace owner during onboarding'
error={errors.passphrase?.message}
disabled={recoverMutation.isLoading}
{...register('passphrase')}
/>
<Tooltip title={recoverOnlyNCW ? 'Mobile passphrase is not required for NCW wallets recovery' : ''}>
<TextField
id='passphrase'
type={recoverOnlyNCW ? 'text' : 'password'}
label='Mobile App Recovery Passphrase'
helpText='Set by the workspace owner during onboarding'
error={errors.passphrase?.message}
disabled={recoverMutation.isLoading || recoverOnlyNCW}
{...register('passphrase')}
sx={{
'& input[disabled]': {
backgroundColor: 'rgba(0, 0, 0, 0.12)',
},
}}
/>
</Tooltip>
)}
</Grid>
<Grid item xs={6}>
Expand All @@ -201,12 +209,15 @@ export const RecoveryForm = ({ verifyOnly }: Props) => {
label='Use auto-generated passphrase'
/>
</Grid>
<Grid item xs={6}>
<FormControlLabel
control={<Checkbox id='recoverOnlyNCW' {...register('recoverOnlyNCW')} />}
label='Recover only NCW wallet'
/>
</Grid>
{!verifyOnly && (
<Grid item xs={6}>
<FormControlLabel
control={<Checkbox id='recoverOnlyNCW' {...register('recoverOnlyNCW')} />}
label='Recover Non-Custodial Wallets (Embedded) only'
/>
</Grid>
)}

<Grid item xs={6}>
<UploadWell
label='Auto-generated passphrase private key'
Expand Down
2 changes: 1 addition & 1 deletion apps/recovery-utility/renderer/pages/ncw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const NCW = () => {
</Grid>
<Grid item>
<Typography paragraph variant='body1' textAlign='center'>
You need to perform partial recovery before before being able to get you end user wallet key shares.
You need to perform partial recovery before before being able to get your end user wallet key shares.
</Typography>
</Grid>
<Grid item>
Expand Down