Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tw-1045/improve UI import seed phrase #996

Merged
merged 28 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
97d42a8
fix add asset validation
Boltman92 Sep 1, 2023
9fe7134
improve regex validation
Boltman92 Sep 7, 2023
c71fa04
feat: implement seed phrase word spelling check
Boltman92 Sep 13, 2023
3a23c40
implement new ui and autocomplete for seed phrase import
Boltman92 Sep 17, 2023
f4b71dc
fix error message for invalid seed phrase length
Boltman92 Sep 18, 2023
d6cd31d
fix merge conflicts
Boltman92 Sep 18, 2023
ceedec2
delete useless dependencies and setTimeout
Boltman92 Sep 18, 2023
e678119
refactoring after review
Boltman92 Sep 19, 2023
5c41368
fix after review
Boltman92 Sep 25, 2023
8a84658
fix styles module import
Boltman92 Sep 26, 2023
c00e285
refactoring after test failed
Boltman92 Oct 1, 2023
e0a2d38
Merge branch 'development' into tw-1045/improve-ui-import-seed-phrase
lendihop Oct 10, 2023
f999a6c
seed length input fixed
lendihop Oct 10, 2023
928d38a
fixed validation
lendihop Oct 10, 2023
23b2abd
add keyboard accessibility
lendihop Oct 11, 2023
5d4d584
review changes
lendihop Oct 11, 2023
bd3d811
fixed:
lendihop Oct 15, 2023
4557a9b
fix Validation error ‘Make sure the words spelled correctly’ doesn’t…
lendihop Oct 15, 2023
a1a45bf
fix Error message ‘Make sure the words spelled correctly’ disappears …
lendihop Oct 15, 2023
4463ea3
fix Error message ‘Make sure the words spelled correctly’ disappears …
lendihop Oct 15, 2023
9cbeb29
fix If some words were revealed, and after then paste seed phrase, re…
lendihop Oct 15, 2023
7cf1225
validation fix
lendihop Oct 15, 2023
c0ddcad
debounce validation
lendihop Oct 16, 2023
17ace2d
rm assertion
lendihop Oct 16, 2023
4d9d93b
review fixes
lendihop Oct 16, 2023
bb2ee60
fix Dropdown lists are sometimes left for revealing words after click…
lendihop Oct 17, 2023
5a14b29
blur fix
lendihop Oct 17, 2023
072f09f
uncomment
lendihop Oct 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions public/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,15 @@
"message": "Inclusion of at least one special character, e.g., ! @ # ? ] - (optional, recommended)."
},
"mnemonicWordsAmountConstraint": {
"message": "12, 15, 18, 21 or 24 words in English"
lendihop marked this conversation as resolved.
Show resolved Hide resolved
"message": "Seed phrase must contain $number$ words",
"placeholders": {
"number": {
"content": "$1"
}
}
},
"mnemonicWordsError": {
"message": "Make sure the words spelled correctly"
},
"seedInputNumberOfWords": {
"message": "My Seed phrase is $count$ words",
Expand Down Expand Up @@ -1406,7 +1414,7 @@
"message": "The elliptical curve that the account will use."
},
"seedPhrase": {
"message": "Seed Phrase"
"message": "Seed phrase"
Boltman92 marked this conversation as resolved.
Show resolved Hide resolved
},
"pathForHDAccounts": {
"message": "for HD acccounts. This is the thing you use to recover all your accounts from your seed phrase.",
Expand Down
12 changes: 10 additions & 2 deletions public/_locales/en_GB/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,15 @@
"message": "At least 1 uppercase letter"
},
"mnemonicWordsAmountConstraint": {
"message": "12, 15, 18, 21 or 24 words in English"
"message": "Seed phrase must contain $number$ words",
"placeholders": {
"number": {
"content": "$1"
}
}
},
"mnemonicWordsError": {
"message": "Make sure the words spelled correctly"
},
"mnemonicSpacingConstraint": {
"message": "Each word separated with a single space"
Expand Down Expand Up @@ -1088,7 +1096,7 @@
"message": "Derivation path"
},
"seedPhrase": {
"message": "Seed Phrase"
"message": "Seed phrase"
},
"pathForHDAccounts": {
"message": "for HD acccounts. This is the thing you use to recover all your accounts from your seed phrase.",
Expand Down
2 changes: 1 addition & 1 deletion src/app/atoms/ImportTabSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type ImportTabSwitcherProps = {

const ImportTabSwitcher: React.FC<ImportTabSwitcherProps> = ({ className, tabs, activeTabSlug, urlPrefix }) => (
<div className={classNames('w-full', className)} style={{ borderBottomWidth: 1, fontSize: 17 }}>
<div className={classNames('flex items-center justify-around')}>
<div className={classNames('flex items-center justify-between px-25')}>
{tabs.map(({ slug, i18nKey }) => {
const active = slug === activeTabSlug;

Expand Down
9 changes: 7 additions & 2 deletions src/app/pages/ImportAccount/ByFundraiserForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { t } from 'lib/i18n';
import { useTempleClient } from 'lib/temple/front';
import { delay } from 'lib/utils';

import { defaultNumberOfWords } from './constants';
import { ImportAccountSelectors, ImportAccountFormType } from './selectors';

interface ByFundraiserFormData {
Expand All @@ -27,6 +28,8 @@ export const ByFundraiserForm: FC = () => {
const [seedPhrase, setSeedPhrase] = useState('');
const [seedError, setSeedError] = useState('');

const [numberOfWords, setNumberOfWords] = useState(defaultNumberOfWords);

const onSubmit = useCallback<(data: ByFundraiserFormData) => void>(
async data => {
if (formState.isSubmitting) return;
Expand All @@ -48,10 +51,10 @@ export const ByFundraiserForm: FC = () => {
setError(err.message);
}
} else if (seedError === '') {
setSeedError(t('mnemonicWordsAmountConstraint'));
setSeedError(t('mnemonicWordsAmountConstraint', [numberOfWords]) as string);
}
},
[seedPhrase, importFundraiserAccount, formState.isSubmitting, setError, seedError, formAnalytics]
[seedPhrase, importFundraiserAccount, formState.isSubmitting, setError, seedError, formAnalytics, numberOfWords]
);

const resetSeedPhrase = useCallback(() => void setSeedPhrase(''), []);
Expand Down Expand Up @@ -90,6 +93,8 @@ export const ByFundraiserForm: FC = () => {
setSeedError={setSeedError}
onChange={setSeedPhrase}
reset={resetSeedPhrase}
numberOfWords={numberOfWords}
setNumberOfWords={setNumberOfWords}
testID={ImportAccountSelectors.fundraiserSeedPhraseInput}
/>

Expand Down
18 changes: 16 additions & 2 deletions src/app/pages/ImportAccount/ByMnemonicForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { TID, T, t } from 'lib/i18n';
import { useTempleClient, validateDerivationPath } from 'lib/temple/front';
import { delay } from 'lib/utils';

import { defaultNumberOfWords } from './constants';
import { ImportAccountSelectors, ImportAccountFormType } from './selectors';

interface DerivationPath {
Expand Down Expand Up @@ -43,6 +44,8 @@ export const ByMnemonicForm: FC = () => {
const [seedPhrase, setSeedPhrase] = useState('');
const [seedError, setSeedError] = useState('');

const [numberOfWords, setNumberOfWords] = useState(defaultNumberOfWords);

const { register, handleSubmit, errors, formState, reset } = useForm<ByMnemonicFormData>({
defaultValues: {
customDerivationPath: DEFAULT_DERIVATION_PATH,
Expand Down Expand Up @@ -78,10 +81,19 @@ export const ByMnemonicForm: FC = () => {
setError(err.message);
}
} else if (seedError === '') {
setSeedError(t('mnemonicWordsAmountConstraint'));
setSeedError(t('mnemonicWordsAmountConstraint', [numberOfWords]) as string);
}
},
[seedPhrase, seedError, formState.isSubmitting, setError, importMnemonicAccount, derivationPath, formAnalytics]
[
seedPhrase,
seedError,
formState.isSubmitting,
setError,
importMnemonicAccount,
derivationPath,
formAnalytics,
numberOfWords
]
);

return (
Expand All @@ -97,6 +109,8 @@ export const ByMnemonicForm: FC = () => {
onChange={setSeedPhrase}
reset={reset}
testID={ImportAccountSelectors.mnemonicWordInput}
numberOfWords={numberOfWords}
setNumberOfWords={setNumberOfWords}
/>
</div>

Expand Down
Loading