Skip to content

Commit 6d7b607

Browse files
Vladimir GrigoryanVladimir Grigoryan
authored andcommitted
KEEP-66, validation of import seed phrase
1 parent 19fa9c9 commit 6d7b607

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

src/ui/components/pages/import/ImportSeedMultichain.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ import Background from '../../../services/Background';
1919
import { CHAIN_IDS } from '../../../../constants';
2020
import { NetworkName } from 'networks/types';
2121
import { Button, ErrorMessage, Input } from '../../ui';
22+
import { useTranslation } from 'react-i18next';
2223
import * as styles from './import.module.css';
2324

2425
export function ImportSeedMultichain() {
2526
const navigate = useNavigate();
2627
const dispatch = usePopupDispatch();
2728
const accounts = usePopupSelector(state => state.accounts);
29+
const { t } = useTranslation();
2830
const [seed, setSeed] = useState('');
2931
const [addressWaves, setAddressWaves] = useState('');
3032
const [addressEvm, setAddressEvm] = useState('');
@@ -72,6 +74,8 @@ export function ImportSeedMultichain() {
7274
checkDuplicates();
7375
}, [addressWaves, addressEvm, accounts]);
7476

77+
const SEED_MIN_LENGTH = 24;
78+
7579
async function handleSeedChange(value: string) {
7680
const normalizedSeed = value.trim().replace(/\s+/g, ' ');
7781
setSeed(normalizedSeed);
@@ -83,9 +87,12 @@ export function ImportSeedMultichain() {
8387
nameRef.current = '';
8488
addressWavesRef.current = '';
8589
addressEvmRef.current = '';
86-
if (!normalizedSeed) return;
87-
if (normalizedSeed.length < 12) {
88-
setError('Seed phrase too short');
90+
if (!normalizedSeed) {
91+
setError(t('importSeed.requiredError'));
92+
return;
93+
}
94+
if (normalizedSeed.length < SEED_MIN_LENGTH) {
95+
setError(t('importSeed.seedLengthError', { minLength: SEED_MIN_LENGTH }));
8996
return;
9097
}
9198
try {
@@ -116,8 +123,12 @@ export function ImportSeedMultichain() {
116123
function handleImport(e: React.FormEvent) {
117124
e.preventDefault();
118125

119-
// All validation (including duplicate check) is handled by useEffect
120-
// Just check if there's any error
126+
if (!seed) {
127+
setShowValidationError(true);
128+
setError(t('importSeed.requiredError'));
129+
return;
130+
}
131+
121132
if (!addressWaves || !addressEvm || error) {
122133
setShowValidationError(true);
123134
setError(error || 'Enter valid seed');

src/ui/components/pages/import/importSeed.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
import { InlineButton } from '../../ui/buttons/inlineButton';
3232
import * as styles from '../importSeed.module.css';
3333

34-
const SEED_MIN_LENGTH = 24;
34+
const SEED_MIN_LENGTH = 15;
3535
const ENCODED_SEED_MIN_LENGTH = 16;
3636

3737
const SEED_TAB_INDEX = 0;

0 commit comments

Comments
 (0)