1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/components/app/account-menu/keyring-label.js
Albert Olivé b5184db620
[MMI] Added code fencing in keyring-label component (#17993)
* Added code fencing in keyring-label component

* Updated tests
2023-03-30 09:42:59 +02:00

57 lines
1.3 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:
label = null;
}
///: BEGIN:ONLY_INCLUDE_IN(mmi)
if (type.startsWith('Custody') && /JSONRPC/u.test(type)) {
label = type.split(' - ')[1];
return null;
}
///: END:ONLY_INCLUDE_IN
if (label === null) {
return label;
}
return (
<>{label ? <div className="keyring-label allcaps">{label}</div> : null}</>
);
}
KeyRingLabel.propTypes = {
keyring: PropTypes.object,
};