Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ exports[`ChoosePassword render matches snapshot 1`] = `
"paddingVertical": 0,
}
}
submitBehavior="submit"
testID="create-password-first-input-field"
value=""
/>
Expand Down
17 changes: 16 additions & 1 deletion app/components/Views/ChoosePassword/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ import Routes from '../../../constants/navigation/Routes';
import { withMetricsAwareness } from '../../hooks/useMetrics';
import fox from '../../../animations/Searching_Fox.json';
import LottieView from 'lottie-react-native';
import { uint8ArrayToMnemonic } from '../../../util/mnemonic';
import { wordlist } from '@metamask/scure-bip39/dist/wordlists/english';

const createStyles = (colors) =>
StyleSheet.create({
Expand Down Expand Up @@ -351,6 +353,14 @@ class ChoosePassword extends PureComponent {
this.setState(() => ({ isSelected: !isSelected }));
};

tryExportSeedPhrase = async (password) => {
const { KeyringController } = Engine.context;
const uint8ArrayMnemonic = await KeyringController.exportSeedPhrase(
password,
);
return uint8ArrayToMnemonic(uint8ArrayMnemonic, wordlist).split(' ');
};

onPressCreate = async () => {
const { loading, isSelected, password, confirmPassword } = this.state;
const passwordsMatch = password !== '' && password === confirmPassword;
Expand Down Expand Up @@ -439,7 +449,10 @@ class ChoosePassword extends PureComponent {
});
}
} else {
this.props.navigation.replace('AccountBackupStep1');
const seedPhrase = await this.tryExportSeedPhrase(password);
this.props.navigation.replace('AccountBackupStep1', {
seedPhrase,
});
}
this.track(MetaMetricsEvents.WALLET_CREATED, {
biometrics_enabled: Boolean(this.state.biometryType),
Expand Down Expand Up @@ -749,6 +762,7 @@ class ChoosePassword extends PureComponent {
placeholderTextColor={colors.text.muted}
testID={ChoosePasswordSelectorsIDs.NEW_PASSWORD_INPUT_ID}
onSubmitEditing={this.jumpToConfirmPassword}
submitBehavior="submit"
autoComplete="new-password"
returnKeyType="next"
autoCapitalize="none"
Expand Down Expand Up @@ -809,6 +823,7 @@ class ChoosePassword extends PureComponent {
{strings('choose_password.confirm_password')}
</Label>
<TextField
ref={this.confirmPasswordInput}
placeholder={strings('import_from_seed.re_enter_password')}
value={confirmPassword}
onChangeText={this.setConfirmPassword}
Expand Down
4 changes: 3 additions & 1 deletion app/components/Views/ChoosePassword/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,9 @@ describe('ChoosePassword', () => {
await new Promise((resolve) => setTimeout(resolve, 100));
});

expect(mockNavigation.replace).toHaveBeenCalledWith('AccountBackupStep1');
expect(mockNavigation.replace).toHaveBeenCalledWith('AccountBackupStep1', {
seedPhrase: expect.any(Array),
});

// // Clean up mock
mockNewWalletAndKeychain.mockRestore();
Expand Down
25 changes: 17 additions & 8 deletions app/components/Views/ManualBackupStep1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ const ManualBackupStep1 = ({

const steps = MANUAL_BACKUP_STEPS;

const seedPhrase = route?.params?.seedPhrase;

const headerLeft = useCallback(
() => (
<TouchableOpacity onPress={() => navigation.goBack()}>
Expand Down Expand Up @@ -146,8 +148,13 @@ const ManualBackupStep1 = ({
}
};

getSeedphrase();
setWords(route.params?.words ?? []);
if (seedPhrase) {
setWords(seedPhrase);
} else {
getSeedphrase();
setWords(route.params?.words ?? []);
}

setReady(true);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Expand Down Expand Up @@ -232,9 +239,6 @@ const ManualBackupStep1 = ({
<KeyboardAwareScrollView style={baseStyles.flexGrow} enableOnAndroid>
<View style={styles.confirmPasswordWrapper}>
<View style={[styles.content, styles.passwordRequiredContent]}>
<Text variant={TextVariant.DisplayMD} color={TextColor.Default}>
{strings('manual_backup_step_1.confirm_password')}
</Text>
<View style={styles.text}>
<Label variant={TextVariant.BodyMD} color={TextColor.Default}>
{strings('manual_backup_step_1.before_continiuing')}
Expand Down Expand Up @@ -359,9 +363,14 @@ const ManualBackupStep1 = ({
return ready ? (
<SafeAreaView style={styles.mainWrapper}>
<View style={[styles.container]}>
<Text variant={TextVariant.BodyMD} color={TextColor.Alternative}>
Step 2 of 3
</Text>
{seedPhrase && (
<Text variant={TextVariant.BodyMD} color={TextColor.Alternative}>
{strings('choose_password.steps', {
currentStep: 2,
totalSteps: 3,
})}
</Text>
)}
{view === SEED_PHRASE
? renderSeedphraseView()
: renderConfirmPassword()}
Expand Down
1 change: 1 addition & 0 deletions app/components/Views/ManualBackupStep1/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ describe('ManualBackupStep1', () => {
words: mockWords,
backupFlow: true,
settingsBackup: true,
seedPhrase: mockWords,
},
};

Expand Down
3 changes: 1 addition & 2 deletions app/components/Views/ManualBackupStep1/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ export const createStyles = (colors: any) =>
alignItems: 'flex-start',
},
text: {
marginBottom: 10,
marginTop: 20,
marginBottom: 8,
justifyContent: 'center',
},
buttonWrapper: {
Expand Down
2 changes: 2 additions & 0 deletions app/components/Views/ManualBackupStep2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ const ManualBackupStep2 = ({
type: 'success',
onClose: () => goNext(),
onPrimaryButtonPress: () => goNext(),
closeOnPrimaryButtonPress: true,
},
});
} else {
Expand All @@ -456,6 +457,7 @@ const ManualBackupStep2 = ({
type: 'error',
onClose: () => generateMissingWords(),
onPrimaryButtonPress: () => generateMissingWords(),
closeOnPrimaryButtonPress: true,
},
});
}
Expand Down
3 changes: 3 additions & 0 deletions app/components/Views/ManualBackupStep2/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ describe('ManualBackupStep2', () => {
type: 'success',
onClose: expect.any(Function),
onPrimaryButtonPress: expect.any(Function),
closeOnPrimaryButtonPress: true,
},
});

Expand Down Expand Up @@ -284,6 +285,7 @@ describe('ManualBackupStep2', () => {
type: 'error',
onClose: expect.any(Function),
onPrimaryButtonPress: expect.any(Function),
closeOnPrimaryButtonPress: true,
},
});

Expand Down Expand Up @@ -352,6 +354,7 @@ describe('ManualBackupStep2', () => {
type: 'success',
onClose: expect.any(Function),
onPrimaryButtonPress: expect.any(Function),
closeOnPrimaryButtonPress: true,
},
});

Expand Down
2 changes: 1 addition & 1 deletion locales/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2929,7 +2929,7 @@
"watching": "Make sure no one is watching your screen.",
"view": "View",
"confirm_password": "Confirm your password",
"before_continiuing": "Before continuing we need you to confirm your password",
"before_continiuing": "Enter password to continue",
"enter_current_password": "Enter your current password",
"confirm": "Confirm",
"got_it": "Got it",
Expand Down
Loading