1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00
metamask-extension/ui/components/app/account-menu/keyring-label.js
Mark Stacey d6b49ae383
Refactor KeyringTypes constant (#17490)
The `HardwareKeyringTypes` constant has been renamed to `KeyringTypes`
and moved to a separate constants module, to reflect that it contains
more than just hardware wallet keyring types. This corrects a mistake
made recently during a TypeScript conversion.
2023-03-21 12:13:22 -02:30

47 lines
1.1 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { useI18nContext } from '../../../hooks/useI18nContext';
import { HardwareKeyringNames } from '../../../../shared/constants/hardware-wallets';
import { KeyringType } from '../../../../shared/constants/keyring';
export default function KeyRingLabel({ keyring }) {
const t = useI18nContext();
let label = null;
// Keyring value might take a while to get a value
if (!keyring) {
return null;
}
const { type } = keyring;
switch (type) {
case KeyringType.qr:
label = HardwareKeyringNames.qr;
break;
case KeyringType.imported:
label = t('imported');
break;
case KeyringType.trezor:
label = HardwareKeyringNames.trezor;
break;
case KeyringType.ledger:
label = HardwareKeyringNames.ledger;
break;
case KeyringType.lattice:
label = HardwareKeyringNames.lattice;
break;
default:
return null;
}
return (
<>{label ? <div className="keyring-label allcaps">{label}</div> : null}</>
);
}
KeyRingLabel.propTypes = {
keyring: PropTypes.object,
};