mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-01 21:57:06 +01:00
0306422bbf
Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: David Walsh <davidwalsh83@gmail.com> Co-authored-by: Howard Braham <howrad@gmail.com> * change js to tsx * update to typescript * add labels to circle animation * add willHide prop to hold to reveal modal * add test * convert to design system * fix lint * fix type * bump coverage * rename * remove comments * remove ts comment and add fix exhuastive dep check * update coverage * add hide modal test * use banneralert * update label * remove unused * fix text * update aria label messages * change exportAccountAndGetPrivateKey to be async * fix lint * update coverage target * update coverage * update input component * update coverage * update coverage * fix blank line * use && * move plainKey to under !privateKeyInput * update hold modal to display srp and private key message * fix styling * fix lint and test * fix unused locales * remove redundent check * update storybook * fix text alignment * fix lint * update snapshot * fix test * update coverage * fix merge conflict * refactor * fix variant * update snapshot * fix test after merge * fix test after merge conflict * fix label text * update to use label component
82 lines
2.1 KiB
JavaScript
82 lines
2.1 KiB
JavaScript
import copyToClipboard from 'copy-to-clipboard';
|
|
import { stripHexPrefix } from 'ethereumjs-util';
|
|
import React, { useContext } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import Box from '../../../ui/box';
|
|
import { useI18nContext } from '../../../../hooks/useI18nContext';
|
|
import {
|
|
MetaMetricsEventCategory,
|
|
MetaMetricsEventName,
|
|
MetaMetricsEventKeyType,
|
|
} from '../../../../../shared/constants/metametrics';
|
|
import { MetaMetricsContext } from '../../../../contexts/metametrics';
|
|
import {
|
|
BLOCK_SIZES,
|
|
BorderStyle,
|
|
BorderColor,
|
|
BorderRadius,
|
|
AlignItems,
|
|
DISPLAY,
|
|
Color,
|
|
FLEX_DIRECTION,
|
|
TextVariant,
|
|
} from '../../../../helpers/constants/design-system';
|
|
import { Label } from '../../../component-library';
|
|
|
|
const PrivateKeyDisplay = ({ privateKey }) => {
|
|
const trackEvent = useContext(MetaMetricsContext);
|
|
const t = useI18nContext();
|
|
const plainKey = stripHexPrefix(privateKey);
|
|
|
|
return (
|
|
<Box
|
|
width={BLOCK_SIZES.FULL}
|
|
flexDirection={FLEX_DIRECTION.COLUMN}
|
|
display={DISPLAY.FLEX}
|
|
alignItems={AlignItems.flexStart}
|
|
paddingLeft={4}
|
|
paddingRight={4}
|
|
>
|
|
<Label
|
|
color={Color.textDefault}
|
|
marginBottom={2}
|
|
variant={TextVariant.bodySm}
|
|
>
|
|
{t('copyPrivateKey')}
|
|
</Label>
|
|
<Box
|
|
className="export-private-key-modal__private-key-display"
|
|
width={BLOCK_SIZES.FULL}
|
|
borderStyle={BorderStyle.solid}
|
|
borderColor={BorderColor.borderDefault}
|
|
borderRadius={BorderRadius.XS}
|
|
borderWidth={1}
|
|
padding={[2, 3, 2]}
|
|
color={Color.errorDefault}
|
|
onClick={() => {
|
|
copyToClipboard(plainKey);
|
|
trackEvent(
|
|
{
|
|
category: MetaMetricsEventCategory.Keys,
|
|
event: MetaMetricsEventName.KeyExportCopied,
|
|
properties: {
|
|
key_type: MetaMetricsEventKeyType.Pkey,
|
|
copy_method: 'clipboard',
|
|
},
|
|
},
|
|
{},
|
|
);
|
|
}}
|
|
>
|
|
{plainKey}
|
|
</Box>
|
|
</Box>
|
|
);
|
|
};
|
|
|
|
PrivateKeyDisplay.propTypes = {
|
|
privateKey: PropTypes.string.isRequired,
|
|
};
|
|
|
|
export default PrivateKeyDisplay;
|