diff --git a/packages/page-accounts/src/modals/Create.tsx b/packages/page-accounts/src/modals/Create.tsx index a8f64f1c6e..3a5e6ba3bf 100644 --- a/packages/page-accounts/src/modals/Create.tsx +++ b/packages/page-accounts/src/modals/Create.tsx @@ -64,17 +64,17 @@ function deriveValidate (seed: string, seedType: SeedType, derivePath: string, p // show a warning in case the password contains an unintended / character if (password?.includes('/')) { - result = { warning: 'Your password contains at least one "/" character. Disregard this warning if it is intended.' }; + result = { warning: 'WARNING_SLASH_PASSWORD' }; } // we don't allow soft for ed25519 if (pairType === 'ed25519' && path.some(({ isSoft }): boolean => isSoft)) { - return { ...result, error: 'Soft derivation paths are not allowed on ed25519' }; + return { ...result, error: 'SOFT_NOT_ALLOWED' }; } // we don't allow password for hex seed if (seedType === 'raw' && password) { - return { ...result, error: 'Password are ignored for hex seed' }; + return { ...result, error: 'PASSWORD_IGNORED' }; } return result; @@ -189,6 +189,11 @@ function Create ({ className = '', onClose, onStatusChange, seed: propsSeed, typ const [{ isNameValid, name }, setName] = useState({ isNameValid: false, name: '' }); const [{ isPasswordValid, password }, setPassword] = useState({ isPasswordValid: false, password: '' }); const isValid = !!address && !deriveValidation?.error && isNameValid && isPasswordValid && isSeedValid; + const errorIndex: Record = useMemo(() => ({ + PASSWORD_IGNORED: t('Password are ignored for hex seed'), + SOFT_NOT_ALLOWED: t('Soft derivation paths are not allowed on ed25519'), + WARNING_SLASH_PASSWORD: t('Your password contains at least one "/" character. Disregard this warning if it is intended.') + }), [t]); const seedOpt = useMemo(() => ( isDevelopment @@ -381,10 +386,10 @@ function Create ({ className = '', onClose, onStatusChange, seed: propsSeed, typ value={derivePath} /> {deriveValidation?.error && ( -
{deriveValidation.error}
+
{errorIndex[deriveValidation.error] || deriveValidation.error}
)} {deriveValidation?.warning && ( -
{deriveValidation.warning}
+
{errorIndex[deriveValidation.warning]}
)}