Skip to content

Commit

Permalink
Mnemonic fixes (#1714)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Sinclair <[email protected]>
  • Loading branch information
greg-schrammel and DanielSinclair authored Sep 26, 2024
1 parent 45d6754 commit 17752eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ const ImportWalletViaSeed = () => {
const handleSeedChange = useCallback(
(e: { target: { value: string } }, index: number) => {
const newSecrets = [...secrets] as string[];
newSecrets[index] = e.target.value;
newSecrets[index] = e.target.value.trim().toLowerCase();
setSecrets(newSecrets);
setImportWalletSecrets(newSecrets);
},
Expand Down Expand Up @@ -269,7 +269,7 @@ const ImportWalletViaSeed = () => {
const handlePaste = useCallback((e: React.ClipboardEvent) => {
const dataToBePasted = e.clipboardData.getData('text').trim();
e.preventDefault();
const words = dataToBePasted.split(' ');
const words = dataToBePasted.trim().toLowerCase().split(' ');
if (words.length === 12 || words.length === 24) {
setSecrets(words);
} else {
Expand Down
18 changes: 5 additions & 13 deletions src/entries/popup/components/SeedVerifyQuiz/SeedVerifyQuiz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,11 @@ export function SeedVerifyQuiz({

const handleSelect = useCallback(
({ word, index }: { word: string; index: number }) => {
const alreadySelected = selectedWords.find(
(selectedWord) =>
selectedWord.index === index && selectedWord.word === word,
const selectedIndex = selectedWords.findIndex(
(selectedWord) => selectedWord.index === index,
);
if (alreadySelected) {
const selectedWordIndex = selectedWords.findIndex(
(selectedWord) =>
selectedWord.index === index && selectedWord.word === word,
);
selectedWords.splice(selectedWordIndex, 1);
if (selectedIndex !== -1) {
selectedWords.splice(selectedIndex, 1);
setSelectedWords([...selectedWords]);
} else if (selectedWords.length < 3) {
selectedWords.push({ word, index });
Expand All @@ -182,11 +177,8 @@ export function SeedVerifyQuiz({
const seedWords = seed.split(' ');
if (
seedWords[3] === selectedWords[0]?.word &&
selectedWords[0].index === 3 &&
seedWords[7] === selectedWords[1]?.word &&
selectedWords[1].index === 7 &&
seedWords[11] === selectedWords[2]?.word &&
selectedWords[2].index === 11
seedWords[11] === selectedWords[2]?.word
) {
setValidated(true);
playSound('CorrectSeedQuiz');
Expand Down

0 comments on commit 17752eb

Please sign in to comment.