|
@@ -11,6 +11,7 @@ import { AddressRow, Button, Input, InputAddress, Modal, Password, StatusContext
|
|
|
import { useApi, useDebounce, useToggle } from '@polkadot/react-hooks';
|
|
|
import keyring from '@polkadot/ui-keyring';
|
|
|
import { keyExtractPath } from '@polkadot/util-crypto';
|
|
|
+import { isPasswordValid } from '@polkadot/joy-utils/functions/accounts';
|
|
|
|
|
|
import { useTranslation } from '../../translate';
|
|
|
import { downloadAccount } from './Create';
|
|
@@ -83,9 +84,9 @@ function Derive ({ className = '', from, onClose }: Props): React.ReactElement {
|
|
|
const [isConfirmationOpen, toggleConfirmation] = useToggle();
|
|
|
const [{ isLocked, lockedError }, setIsLocked] = useState<LockState>({ isLocked: source.isLocked, lockedError: null });
|
|
|
const [{ isNameValid, name }, setName] = useState({ isNameValid: false, name: '' });
|
|
|
- const [{ isPassValid, password }, setPassword] = useState({ isPassValid: false, password: '' });
|
|
|
- const [{ isPass2Valid, password2 }, setPassword2] = useState({ isPass2Valid: false, password2: '' });
|
|
|
- const [{ isRootValid, rootPass }, setRootPass] = useState({ isRootValid: false, rootPass: '' });
|
|
|
+ const [{ isPassValid, password }, setPassword] = useState({ isPassValid: true, password: '' });
|
|
|
+ const [{ isPass2Valid, password2 }, setPassword2] = useState({ isPass2Valid: true, password2: '' });
|
|
|
+ const [{ isRootValid, rootPass }, setRootPass] = useState({ isRootValid: true, rootPass: '' });
|
|
|
const [suri, setSuri] = useState('');
|
|
|
const debouncedSuri = useDebounce(suri);
|
|
|
const isValid = !!address && !deriveError && isNameValid && isPassValid && isPass2Valid;
|
|
@@ -115,18 +116,18 @@ function Derive ({ className = '', from, onClose }: Props): React.ReactElement {
|
|
|
);
|
|
|
|
|
|
const _onChangePass = useCallback(
|
|
|
- (password: string) => setPassword({ isPassValid: keyring.isPassValid(password), password }),
|
|
|
+ (password: string) => setPassword({ isPassValid: isPasswordValid(password), password }),
|
|
|
[]
|
|
|
);
|
|
|
|
|
|
const _onChangePass2 = useCallback(
|
|
|
- (password2: string) => setPassword2({ isPass2Valid: keyring.isPassValid(password2) && (password2 === password), password2 }),
|
|
|
+ (password2: string) => setPassword2({ isPass2Valid: isPasswordValid(password2) && (password2 === password), password2 }),
|
|
|
[password]
|
|
|
);
|
|
|
|
|
|
const _onChangeRootPass = useCallback(
|
|
|
(rootPass: string): void => {
|
|
|
- setRootPass({ isRootValid: !!rootPass, rootPass });
|
|
|
+ setRootPass({ isRootValid: isPasswordValid(rootPass), rootPass });
|
|
|
setIsLocked(({ isLocked }) => ({ isLocked, lockedError: null }));
|
|
|
},
|
|
|
[]
|