Skip to content

Commit

Permalink
Faster lookup of bip39 words
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Jan 13, 2024
1 parent 24a4ea5 commit ae7c031
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/routes/settings/Restore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const initialValues: SeedWordsForm = {
};

function validateWord(word?: string): boolean {
// return word?.trim() === "bacon";
return WORDS_EN.includes(word?.trim() ?? "");
const trimmed = word?.trim();
return trimmed ? WORDS_EN.has(trimmed) : false;
}

function SeedTextField(props: TextFieldProps) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/words.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const WORDS_EN = [
export const WORDS_EN: Set<string> = new Set([
"abandon",
"ability",
"able",
Expand Down Expand Up @@ -2047,4 +2047,4 @@ export const WORDS_EN = [
"zero",
"zone",
"zoo"
];
]);

0 comments on commit ae7c031

Please sign in to comment.