2022-01-25 18:48:41 +01:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
2023-03-21 15:43:22 +01:00
|
|
|
import { HardwareKeyringNames } from '../../../../shared/constants/hardware-wallets';
|
|
|
|
import { KeyringType } from '../../../../shared/constants/keyring';
|
2022-01-25 18:48:41 +01:00
|
|
|
|
|
|
|
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) {
|
2023-03-21 15:43:22 +01:00
|
|
|
case KeyringType.qr:
|
2023-01-20 16:14:40 +01:00
|
|
|
label = HardwareKeyringNames.qr;
|
2022-01-25 18:48:41 +01:00
|
|
|
break;
|
2023-03-21 15:43:22 +01:00
|
|
|
case KeyringType.imported:
|
2022-01-25 18:48:41 +01:00
|
|
|
label = t('imported');
|
|
|
|
break;
|
2023-03-21 15:43:22 +01:00
|
|
|
case KeyringType.trezor:
|
2023-01-20 16:14:40 +01:00
|
|
|
label = HardwareKeyringNames.trezor;
|
2022-01-25 18:48:41 +01:00
|
|
|
break;
|
2023-03-21 15:43:22 +01:00
|
|
|
case KeyringType.ledger:
|
2023-01-20 16:14:40 +01:00
|
|
|
label = HardwareKeyringNames.ledger;
|
2022-01-25 18:48:41 +01:00
|
|
|
break;
|
2023-03-21 15:43:22 +01:00
|
|
|
case KeyringType.lattice:
|
2023-01-20 16:14:40 +01:00
|
|
|
label = HardwareKeyringNames.lattice;
|
2022-01-25 18:48:41 +01:00
|
|
|
break;
|
|
|
|
default:
|
2023-03-30 09:42:59 +02:00
|
|
|
label = null;
|
|
|
|
}
|
|
|
|
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
2023-03-30 09:42:59 +02:00
|
|
|
if (type.startsWith('Custody') && /JSONRPC/u.test(type)) {
|
|
|
|
label = type.split(' - ')[1];
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
|
|
|
|
if (label === null) {
|
|
|
|
return label;
|
2022-01-25 18:48:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>{label ? <div className="keyring-label allcaps">{label}</div> : null}</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
KeyRingLabel.propTypes = {
|
|
|
|
keyring: PropTypes.object,
|
|
|
|
};
|