Faster lookup of bip39 words

This commit is contained in:
benthecarman
2024-01-13 01:36:07 +00:00
committed by benthecarman
parent 24a4ea5a4d
commit ae7c03114e
2 changed files with 4 additions and 4 deletions

View File

@@ -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) {

View File

@@ -1,4 +1,4 @@
export const WORDS_EN = [
export const WORDS_EN: Set<string> = new Set([
"abandon",
"ability",
"able",
@@ -2047,4 +2047,4 @@ export const WORDS_EN = [
"zero",
"zone",
"zoo"
];
]);