1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

Create function for hardware keyring checking (#12457)

This commit is contained in:
David Walsh 2021-10-27 18:54:18 -05:00 committed by GitHub
parent 0880093f40
commit 6e928c661e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import QrView from '../../../ui/qr-code';
import EditableLabel from '../../../ui/editable-label'; import EditableLabel from '../../../ui/editable-label';
import Button from '../../../ui/button'; import Button from '../../../ui/button';
import { getURLHostName } from '../../../../helpers/utils/util'; import { getURLHostName } from '../../../../helpers/utils/util';
import { isHardwareKeyring } from '../../../../helpers/utils/hardware';
export default class AccountDetailsModal extends Component { export default class AccountDetailsModal extends Component {
static propTypes = { static propTypes = {
@ -40,7 +41,7 @@ export default class AccountDetailsModal extends Component {
let exportPrivateKeyFeatureEnabled = true; let exportPrivateKeyFeatureEnabled = true;
// This feature is disabled for hardware wallets // This feature is disabled for hardware wallets
if (keyring?.type?.search('Hardware') !== -1) { if (isHardwareKeyring(keyring?.type)) {
exportPrivateKeyFeatureEnabled = false; exportPrivateKeyFeatureEnabled = false;
} }

View File

@ -34,6 +34,7 @@ import BuyIcon from '../../ui/icon/overview-buy-icon.component';
import SendIcon from '../../ui/icon/overview-send-icon.component'; import SendIcon from '../../ui/icon/overview-send-icon.component';
import { setSwapsFromToken } from '../../../ducks/swaps/swaps'; import { setSwapsFromToken } from '../../../ducks/swaps/swaps';
import IconButton from '../../ui/icon-button'; import IconButton from '../../ui/icon-button';
import { isHardwareKeyring } from '../../../helpers/utils/hardware';
import WalletOverview from './wallet-overview'; import WalletOverview from './wallet-overview';
const EthOverview = ({ className }) => { const EthOverview = ({ className }) => {
@ -55,7 +56,7 @@ const EthOverview = ({ className }) => {
}); });
const history = useHistory(); const history = useHistory();
const keyring = useSelector(getCurrentKeyring); const keyring = useSelector(getCurrentKeyring);
const usingHardwareWallet = keyring.type.search('Hardware') !== -1; const usingHardwareWallet = isHardwareKeyring(keyring.type);
const balanceIsCached = useSelector(isBalanceCached); const balanceIsCached = useSelector(isBalanceCached);
const showFiat = useSelector(getShouldShowFiat); const showFiat = useSelector(getShouldShowFiat);
const selectedAccount = useSelector(getSelectedAccount); const selectedAccount = useSelector(getSelectedAccount);

View File

@ -7,6 +7,7 @@ import Identicon from '../../ui/identicon';
import Tooltip from '../../ui/tooltip'; import Tooltip from '../../ui/tooltip';
import CurrencyDisplay from '../../ui/currency-display'; import CurrencyDisplay from '../../ui/currency-display';
import { I18nContext } from '../../../contexts/i18n'; import { I18nContext } from '../../../contexts/i18n';
import { isHardwareKeyring } from '../../../helpers/utils/hardware';
import { import {
SEND_ROUTE, SEND_ROUTE,
BUILD_QUOTE_ROUTE, BUILD_QUOTE_ROUTE,
@ -42,7 +43,7 @@ const TokenOverview = ({ className, token }) => {
}); });
const history = useHistory(); const history = useHistory();
const keyring = useSelector(getCurrentKeyring); const keyring = useSelector(getCurrentKeyring);
const usingHardwareWallet = keyring.type.search('Hardware') !== -1; const usingHardwareWallet = isHardwareKeyring(keyring.type);
const { tokensWithBalances } = useTokenTracker([token]); const { tokensWithBalances } = useTokenTracker([token]);
const balanceToRender = tokensWithBalances[0]?.string; const balanceToRender = tokensWithBalances[0]?.string;
const balance = tokensWithBalances[0]?.balance; const balance = tokensWithBalances[0]?.balance;

View File

@ -0,0 +1,3 @@
export function isHardwareKeyring(keyringType = '') {
return keyringType.includes('Hardware');
}