From 36832470b57fa9bf228a195497b382b5508daa18 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Wed, 6 Jan 2021 10:43:21 +0100 Subject: [PATCH] Display derive errors (#4326) --- packages/page-accounts/src/modals/Derive.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/page-accounts/src/modals/Derive.tsx b/packages/page-accounts/src/modals/Derive.tsx index 1b4cdecb40..c7cce325fd 100644 --- a/packages/page-accounts/src/modals/Derive.tsx +++ b/packages/page-accounts/src/modals/Derive.tsx @@ -33,6 +33,10 @@ interface LockState { } function deriveValidate (suri: string, pairType: KeypairType): string | null { + if (suri.includes('///')) { + return 'Password paths are not supported on keys derived from others'; + } + try { const { path } = keyExtractPath(suri); @@ -41,6 +45,8 @@ function deriveValidate (suri: string, pairType: KeypairType): string | null { return 'Soft derivation paths are not allowed on ed25519'; } } catch (error) { + console.error(error); + return (error as Error).message; } @@ -216,11 +222,14 @@ function Derive ({ className = '', from, onClose }: Props): React.ReactElement { {sourceStatic} ('You can set a custom derivation path for this account using the following syntax "//////". The "/" and "//" may be repeated and mixed`. The "///password" is optional and should only occur once.')} + help={t('You can set a custom derivation path for this account using the following syntax "//////". The "/" and "//" may be repeated and mixed`.')} label={t('derivation path')} onChange={setSuri} placeholder={t('//hard/soft')} /> + {deriveError && ( +
{deriveError}
+ )} ('Name given to this account. You can edit it. To use the account to validate or nominate, it is a good practice to append the function of the account in the name, e.g "name_you_want - stash".')}