feat: add different ways to paste mnemonic
This commit is contained in:
parent
d97967423c
commit
92e5bdf89c
|
@ -20,21 +20,17 @@ const AutocompleteInput = ({ index }: AutocompleteInputProps) => {
|
||||||
|
|
||||||
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const value = e.target.value
|
const value = e.target.value
|
||||||
|
const mnemonic = value.trim().split(' ')
|
||||||
|
const mnemonicLength = mnemonic.length
|
||||||
|
|
||||||
if (value.split(' ').length > 1) {
|
if (mnemonicLength === 1) {
|
||||||
const mnemonic = value.trim().split(' ')
|
dispatch(setWord({ index, word: value }))
|
||||||
|
} else if (mnemonicLength === 24) {
|
||||||
if (mnemonic.length < 24) {
|
|
||||||
for (let i = 0; i < 24; i++) {
|
|
||||||
if (!mnemonic[i]) {
|
|
||||||
mnemonic.push('')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatch(setMnemonic(mnemonic))
|
dispatch(setMnemonic(mnemonic))
|
||||||
} else {
|
} else {
|
||||||
dispatch(setWord({ index, word: value }))
|
for (let i = index; i < mnemonicLength + index; i++) {
|
||||||
|
dispatch(setWord({ index: i, word: mnemonic.shift() || '' }))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue