Skip to content

Commit

Permalink
fix(wallet-setup): mnemonic validation
Browse files Browse the repository at this point in the history
  • Loading branch information
banklesss committed Apr 29, 2024
1 parent d5f33ff commit 15bdb41
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,29 @@ export const RestoreWalletScreen = () => {

const onSelect = (index: number, word: string) => {
const newWords = [...mnemonicSelectedWords]
setMnemonicSelectedWords(newWords)
setSuggestedWords([])
newWords[index] = word
setSuggestedWords([])
setMnemonicSelectedWords(newWords)
mnenonicRefs[index].current?.selectWord(isEmptyString(word) ? '' : word)

const mnemonicWordsComplete = newWords.every(Boolean)
const isValid: boolean = mnemonicWordsComplete ? validateMnemonic(newWords.join(' ')) : false

console.log('isValid', isValid)
console.log('mnemonicWordsComplete', mnemonicWordsComplete)

if (mnemonicWordsComplete && isValid) {
Keyboard.dismiss()
setIsValidPhrase(true)
setMnemonic(mnemonicSelectedWords.join(' '))
setMnemonic(newWords.join(' '))
track.restoreWalletEnterPhraseStepStatus({recovery_prhase_status: true})

return
}

if (mnemonicWordsComplete && !isValid) {
setIsValidPhrase(false)
setMnemonic(mnemonicSelectedWords.join(' '))
setMnemonic(newWords.join(' '))
track.restoreWalletEnterPhraseStepStatus({recovery_prhase_status: false})

return
Expand Down

0 comments on commit 15bdb41

Please sign in to comment.