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