From 62b8bd8a5f04300e347c24c313f4bd9825f8b80d Mon Sep 17 00:00:00 2001 From: RadoslavDimchev Date: Sun, 8 Oct 2023 10:59:04 +0300 Subject: [PATCH] feat: remove generated mnemonic state --- .../KeyGeneration/RecoveryPhrase.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pages/ValidatorOnboarding/KeyGeneration/RecoveryPhrase.tsx b/src/pages/ValidatorOnboarding/KeyGeneration/RecoveryPhrase.tsx index ab5dbda4..a253a059 100644 --- a/src/pages/ValidatorOnboarding/KeyGeneration/RecoveryPhrase.tsx +++ b/src/pages/ValidatorOnboarding/KeyGeneration/RecoveryPhrase.tsx @@ -4,6 +4,10 @@ import { CloseCircleIcon } from '@status-im/icons' import { useEffect, useState } from 'react' import { generateMnemonic } from 'web-bip39' import wordlist from 'web-bip39/wordlists/english' +import { useDispatch, useSelector } from 'react-redux' + +import { RootState } from '../../../redux/store' +import { setGeneratedMnemonic } from '../../../redux/ValidatorOnboarding/KeyGeneration/slice' type RecoveryPhraseProps = { isKeystoreFiles: boolean @@ -11,7 +15,8 @@ type RecoveryPhraseProps = { const RecoveryPhrase = ({ isKeystoreFiles }: RecoveryPhraseProps) => { const [isReveal, setIsReveal] = useState(false) - const [generatedMnemonic, setGeneratedMnemonic] = useState('') + const { generatedMnemonic } = useSelector((state: RootState) => state.keyGeneration) + const dispatch = useDispatch() useEffect(() => { getMnemonic() @@ -19,7 +24,7 @@ const RecoveryPhrase = ({ isKeystoreFiles }: RecoveryPhraseProps) => { const getMnemonic = async () => { const mnemonic = await generateMnemonic(wordlist, 256) - setGeneratedMnemonic(mnemonic) + dispatch(setGeneratedMnemonic(mnemonic.split(' '))) } const revealHandler = () => { @@ -45,7 +50,7 @@ const RecoveryPhrase = ({ isKeystoreFiles }: RecoveryPhraseProps) => { gap: '5px 0px', }} > - {generatedMnemonic.split(' ').map((word, index) => ( + {generatedMnemonic.map((word, index) => ( {word}