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

Encrypted Wallet - restore #420

Merged
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
6 changes: 3 additions & 3 deletions app/screens/WalletNavigator/WalletNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,23 @@ export function WalletNavigator (): JSX.Element {
name='PinCreation'
component={PinCreation}
options={{
headerTitle: translate('screens/WalletNavigator', 'Secure Your Wallet'),
headerTitle: translate('screens/WalletNavigator', 'Create a passcode'),
headerBackTitleVisible: false
}}
/>
<WalletStack.Screen
name='PinConfirmation'
component={PinConfirmation}
options={{
headerTitle: translate('screens/WalletNavigator', 'Secure Your Wallet'),
headerTitle: translate('screens/WalletNavigator', 'Verify passcode'),
headerBackTitleVisible: false
}}
/>
<WalletStack.Screen
name='EnrollBiometric'
component={EnrollBiometric}
options={{
headerTitle: translate('screens/WalletNavigator', 'Wallet Created')
headerTitle: translate('screens/WalletNavigator', 'Secure your wallet')
}}
/>
</WalletStack.Navigator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export function PinCreation ({ route }: Props): JSX.Element {
const [newPin, setNewPin] = useState('')

return (
<ScrollView style={tailwind('w-full flex-1 flex-col bg-white')}>
<ScrollView
testID='screen_create_pin'
style={tailwind('w-full flex-1 flex-col bg-white')}
>
<CreateWalletStepIndicator
current={3}
steps={[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import { validateMnemonicSentence } from '@defichain/jellyfish-wallet-mnemonic'
import { NavigationProp, useNavigation } from '@react-navigation/native'
import * as React from 'react'
import { createRef, useEffect, useState } from 'react'
import { Controller, useForm } from 'react-hook-form'
import { Alert, TextInput } from 'react-native'
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'
import { MnemonicUnprotected } from '../../../../api/wallet/provider/mnemonic_unprotected'
import { Text, View } from '../../../../components'
import { Button } from '../../../../components/Button'
import { SectionTitle } from '../../../../components/SectionTitle'
import { useNetworkContext } from '../../../../contexts/NetworkContext'
import { useWalletPersistenceContext } from '../../../../contexts/WalletPersistenceContext'
import { tailwind } from '../../../../tailwind'
import { translate } from '../../../../translations'
import LoadingScreen from '../../../LoadingNavigator/LoadingScreen'
import { WalletParamList } from '../../WalletNavigator'

export function RestoreMnemonicWallet (): JSX.Element {
const { network } = useNetworkContext()
const { setWallet } = useWalletPersistenceContext()
const navigation = useNavigation<NavigationProp<WalletParamList>>()
const { control, formState: { isValid }, getValues } = useForm({ mode: 'onChange' })
const [recoveryWords] = useState<number[]>(Array.from(Array(24), (v, i) => i + 1))
const [isSubmitting, setIsSubmitting] = useState(false)
Expand All @@ -38,7 +36,9 @@ export function RestoreMnemonicWallet (): JSX.Element {
const words = Object.values(getValues())
if (isValid && validateMnemonicSentence(words)) {
setIsSubmitting(false)
await setWallet(MnemonicUnprotected.toData(words, network))
navigation.navigate('PinCreation', {
words, pinLength: 6
})
} else {
setIsSubmitting(false)
Alert.alert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ context('wallet/createmnemonic', () => {
})
cy.getByTestID('recover_wallet_button').should('not.have.attr', 'disabled')
cy.getByTestID('recover_wallet_button').click().wait(2000)
cy.getByTestID('balances_list').should('exist')
cy.getByTestID('screen_create_pin').should('exist')
})
})
2 changes: 1 addition & 1 deletion cypress/integration/functional/onboarding/restore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ context('wallet/recover', () => {
it('should be able to submit form', function () {
cy.getByTestID('recover_wallet_button').should('not.have.attr', 'disabled')
cy.getByTestID('recover_wallet_button').click().wait(2000)
cy.getByTestID('balances_list').should('exist')
cy.getByTestID('screen_create_pin').should('exist')
})
})