feat: change words to mnemonic
This commit is contained in:
parent
550761a485
commit
d22838d945
|
@ -15,13 +15,13 @@ type ContinueButton = {
|
|||
}
|
||||
|
||||
const ContinueButton = ({ continueHandler, activeStep, subStepValidatorSetup }: ContinueButton) => {
|
||||
const { isCopyPastedPhrase, isRightPhrase, words, validWords, isConfirmPhraseStage } =
|
||||
const { isCopyPastedPhrase, isRightPhrase, mnemonic, validWords, isConfirmPhraseStage } =
|
||||
useSelector((state: RootState) => state.keyGeneration)
|
||||
const dispatch = useDispatch()
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(setIsRightPhrase(words.every(word => word !== '')))
|
||||
}, [words])
|
||||
dispatch(setIsRightPhrase(mnemonic.every(word => word !== '')))
|
||||
}, [mnemonic])
|
||||
|
||||
const isDisabled = () => {
|
||||
if (
|
||||
|
|
|
@ -18,7 +18,7 @@ type AutocompleteInputProps = {
|
|||
const AutocompleteInput = ({ index }: AutocompleteInputProps) => {
|
||||
const [suggestions, setSuggestions] = useState<string[]>([])
|
||||
const [isFocused, setIsFocused] = useState(false)
|
||||
const word = useSelector((state: RootState) => state.keyGeneration.words[index])
|
||||
const word = useSelector((state: RootState) => state.keyGeneration.mnemonic[index])
|
||||
const isValidWord = useSelector((state: RootState) => state.keyGeneration.validWords[index])
|
||||
const validWords = useSelector((state: RootState) => state.keyGeneration.validWords)
|
||||
const dispatch = useDispatch()
|
||||
|
|
|
@ -27,7 +27,7 @@ import './layoutGradient.css'
|
|||
const ValidatorOnboarding = () => {
|
||||
const [activeStep, setActiveStep] = useState(0)
|
||||
const [subStepValidatorSetup, setSubStepValidatorSetup] = useState(0)
|
||||
const { isCopyPastedPhrase, words, isConfirmPhraseStage, generatedMnemonic } = useSelector(
|
||||
const { isCopyPastedPhrase, mnemonic, isConfirmPhraseStage, generatedMnemonic } = useSelector(
|
||||
(state: RootState) => state.keyGeneration,
|
||||
)
|
||||
const navigate = useNavigate()
|
||||
|
@ -41,7 +41,7 @@ const ValidatorOnboarding = () => {
|
|||
if (activeStep === 4 && isConfirmPhraseStage === false) {
|
||||
return dispatch(setIsConfirmPhraseStage(true))
|
||||
} else if (activeStep === 4 && isConfirmPhraseStage === true) {
|
||||
const newValidWords = words.map((w, index) => generatedMnemonic[index] === w)
|
||||
const newValidWords = mnemonic.map((w, index) => generatedMnemonic[index] === w)
|
||||
dispatch(setValidWords(newValidWords))
|
||||
|
||||
if (newValidWords.some(w => w === false)) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
|
||||
|
||||
type KeyGenerationState = {
|
||||
words: string[]
|
||||
mnemonic: string[]
|
||||
isCopyPastedPhrase: boolean
|
||||
isRightPhrase: boolean
|
||||
validWords: boolean[]
|
||||
|
@ -15,7 +15,7 @@ type wordProps = {
|
|||
}
|
||||
|
||||
const initialState: KeyGenerationState = {
|
||||
words: Array(24).fill(''),
|
||||
mnemonic: Array(24).fill(''),
|
||||
isCopyPastedPhrase: false,
|
||||
isRightPhrase: false,
|
||||
validWords: Array(24).fill(true),
|
||||
|
@ -28,12 +28,12 @@ const keyGenerationSlice = createSlice({
|
|||
initialState,
|
||||
reducers: {
|
||||
setWord: (state, action: PayloadAction<wordProps>) => {
|
||||
const newWords = [...state.words]
|
||||
newWords[action.payload.index] = action.payload.word
|
||||
return { ...state, words: newWords }
|
||||
const newMnemonic = [...state.mnemonic]
|
||||
newMnemonic[action.payload.index] = action.payload.word
|
||||
return { ...state, mnemonic: newMnemonic }
|
||||
},
|
||||
setMnemonic: (state, action: PayloadAction<string[]>) => {
|
||||
state.words = action.payload
|
||||
state.mnemonic = action.payload
|
||||
},
|
||||
setIsCopyPastedPhrase: (state, action: PayloadAction<boolean>) => {
|
||||
state.isCopyPastedPhrase = action.payload
|
||||
|
|
Loading…
Reference in New Issue