Feature/better eth address addition (#4032)

* update labels for eth private key

* updated copy button

* lint

* Apply suggestions from code review

Co-authored-by: Jaco Greeff <jacogr@gmail.com>

* typo

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
This commit is contained in:
Antoine Estienne 2020-11-16 15:19:08 +01:00 committed by GitHub
parent 6317eeb507
commit c004f07c53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 12 deletions

View File

@ -204,8 +204,8 @@ function Create ({ className = '', onClose, onStatusChange, seed: propsSeed, typ
: []
).concat(
{ text: t<string>('Mnemonic'), value: 'bip' },
{ text: t<string>('Raw seed'), value: 'raw' }
), [isDevelopment, t]);
isEthereum ? { text: t<string>('Private Key'), value: 'raw' } : { text: t<string>('Raw seed'), value: 'raw' }
), [isEthereum, isDevelopment, t]);
const _onChangeDerive = useCallback(
(newDerivePath: string) => setAddress(updateAddress(seed, newDerivePath, seedType, pairType)),
@ -295,7 +295,9 @@ function Create ({ className = '', onClose, onStatusChange, seed: propsSeed, typ
<Modal.Columns>
<Modal.Column>
<TextArea
help={t<string>('The private key for your account is derived from this seed. This seed must be kept secret as anyone in its possession has access to the funds of this account. If you validate, use the seed of the session account as the "--key" parameter of your node.')}
help={isEthereum
? t<string>("Your ethereum key pair is derived from your private key. Don't divulge this key.")
: t<string>('The private key for your account is derived from this seed. This seed must be kept secret as anyone in its possession has access to the funds of this account. If you validate, use the seed of the session account as the "--key" parameter of your node.')}
isAction
isError={!isSeedValid}
isReadOnly={seedType === 'dev'}
@ -304,7 +306,9 @@ function Create ({ className = '', onClose, onStatusChange, seed: propsSeed, typ
? t<string>('mnemonic seed')
: seedType === 'dev'
? t<string>('development seed')
: t<string>('seed (hex or string)')
: isEthereum
? t<string>('ethereum private key')
: t<string>('seed (hex or string)')
}
onChange={_onChangeSeed}
seed={seed}
@ -316,9 +320,9 @@ function Create ({ className = '', onClose, onStatusChange, seed: propsSeed, typ
onChange={_selectSeedType}
options={seedOpt}
/>
<CopyButton
< CopyButton
className='copyMoved'
isMnemonic
type={seedType === 'bip' ? t<string>('mnemonic') : seedType === 'raw' ? isEthereum ? t<string>('private key') : 'seed' : t<string>('raw seed')}
value={seed}
/>
</TextArea>

View File

@ -15,27 +15,27 @@ interface Props {
children?: React.ReactNode;
className?: string;
icon?: IconName;
isAddress?: boolean;
type?: string;
isMnemonic?: boolean;
value: string;
}
const NOOP = () => undefined;
function CopyButton ({ children, className, icon = 'copy', isAddress = false, isMnemonic = false, value }: Props): React.ReactElement<Props> {
function CopyButton ({ children, className, icon = 'copy', type, value }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { queueAction } = useContext(StatusContext);
const _onCopy = useCallback(
(): void => {
(isAddress || isMnemonic) && queueAction && queueAction({
account: isAddress ? value : undefined,
(type !== 'other') && queueAction && queueAction({
account: type !== 'mnemonic' ? value : undefined,
action: t<string>('clipboard'),
message: t<string>(`${isAddress ? 'address' : 'mnemonic'} copied`),
message: t<string>('{{type}} copied', { replace: { type: type || t<string>('other') } }),
status: 'queued'
});
},
[isAddress, isMnemonic, queueAction, t, value]
[type, queueAction, t, value]
);
return (