From ae7c03114e8381a0416679740b99dcf8dd64b2c8 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Sat, 13 Jan 2024 01:36:07 +0000 Subject: [PATCH] Faster lookup of bip39 words --- src/routes/settings/Restore.tsx | 4 ++-- src/utils/words.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/routes/settings/Restore.tsx b/src/routes/settings/Restore.tsx index 371d5df..43c626c 100644 --- a/src/routes/settings/Restore.tsx +++ b/src/routes/settings/Restore.tsx @@ -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) { diff --git a/src/utils/words.ts b/src/utils/words.ts index aedba3e..544ff59 100644 --- a/src/utils/words.ts +++ b/src/utils/words.ts @@ -1,4 +1,4 @@ -export const WORDS_EN = [ +export const WORDS_EN: Set = new Set([ "abandon", "ability", "able", @@ -2047,4 +2047,4 @@ export const WORDS_EN = [ "zero", "zone", "zoo" -]; +]);