feat: add pasting entire mnemonic

This commit is contained in:
RadoslavDimchev 2023-09-01 14:15:14 +03:00
parent e8f55ba18d
commit 0ce5e3350a

View File

@ -3,7 +3,7 @@ import { useDispatch, useSelector } from 'react-redux'
import wordlist from 'web-bip39/wordlists/english'
import { RootState } from '../../../redux/store'
import { setWord } from '../../../redux/ValidatorOnboarding/KeyGeneration/slice'
import { setMnemonic, setWord } from '../../../redux/ValidatorOnboarding/KeyGeneration/slice'
type AutocompleteInputProps = {
index: number
@ -20,7 +20,22 @@ const AutocompleteInput = ({ index }: AutocompleteInputProps) => {
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const value = e.target.value
dispatch(setWord({ index, word: value }))
if (value.split(' ').length > 1) {
const mnemonic = value.trim().split(' ')
if (mnemonic.length < 24) {
for (let i = 0; i < 24; i++) {
if (!mnemonic[i]) {
mnemonic.push('')
}
}
}
dispatch(setMnemonic(mnemonic))
} else {
dispatch(setWord({ index, word: value }))
}
}
return (