feat: generate mnemonic and set it to state

This commit is contained in:
RadoslavDimchev 2023-10-04 23:47:18 +03:00
parent 46f297e060
commit f296becfc8
1 changed files with 12 additions and 1 deletions

View File

@ -1,7 +1,9 @@
import { Stack, XStack, YStack } from 'tamagui' import { Stack, XStack, YStack } from 'tamagui'
import { Button, InformationBox, Text } from '@status-im/components' import { Button, InformationBox, Text } from '@status-im/components'
import { CloseCircleIcon } from '@status-im/icons' import { CloseCircleIcon } from '@status-im/icons'
import { useState } from 'react' import { useEffect, useState } from 'react'
import { generateMnemonic } from 'web-bip39'
import wordlist from 'web-bip39/wordlists/english'
type RecoveryPhraseProps = { type RecoveryPhraseProps = {
isKeystoreFiles: boolean isKeystoreFiles: boolean
@ -9,6 +11,15 @@ type RecoveryPhraseProps = {
const RecoveryPhrase = ({ isKeystoreFiles }: RecoveryPhraseProps) => { const RecoveryPhrase = ({ isKeystoreFiles }: RecoveryPhraseProps) => {
const [isReveal, setIsReveal] = useState(false) const [isReveal, setIsReveal] = useState(false)
const [generatedMnemonic, setGeneratedMnemonic] = useState('')
useEffect(() => {
const getMnemonic = async () => {
const mnemonic = await generateMnemonic(wordlist, 256)
setGeneratedMnemonic(mnemonic)
}
getMnemonic()
}, [])
const revealHandler = () => { const revealHandler = () => {
setIsReveal(state => !state) setIsReveal(state => !state)