Skip to content

Commit

Permalink
Encrypted Wallet - restore (#420)
Browse files Browse the repository at this point in the history
* restore wallet followed with pin/biometric after input words

* minor update e2e
  • Loading branch information
ivan-zynesis authored Aug 5, 2021
1 parent b201af7 commit adf21af
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/screens/WalletNavigator/WalletNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export function WalletNavigator (): JSX.Element {
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={CREATE_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 @@ -59,6 +59,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')
})
})

0 comments on commit adf21af

Please sign in to comment.