You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.4 KiB
89 lines
2.4 KiB
4 years ago
|
import React, { Component } from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import AccountModalContainer from '../account-modal-container';
|
||
4 years ago
|
import getAccountLink from '../../../../helpers/utils/account-link';
|
||
4 years ago
|
import QrView from '../../../ui/qr-code';
|
||
|
import EditableLabel from '../../../ui/editable-label';
|
||
|
import Button from '../../../ui/button';
|
||
6 years ago
|
|
||
|
export default class AccountDetailsModal extends Component {
|
||
|
static propTypes = {
|
||
|
selectedIdentity: PropTypes.object,
|
||
4 years ago
|
chainId: PropTypes.string,
|
||
6 years ago
|
showExportPrivateKeyModal: PropTypes.func,
|
||
|
setAccountLabel: PropTypes.func,
|
||
|
keyrings: PropTypes.array,
|
||
|
rpcPrefs: PropTypes.object,
|
||
4 years ago
|
};
|
||
6 years ago
|
|
||
|
static contextTypes = {
|
||
|
t: PropTypes.func,
|
||
4 years ago
|
};
|
||
6 years ago
|
|
||
4 years ago
|
render() {
|
||
6 years ago
|
const {
|
||
|
selectedIdentity,
|
||
4 years ago
|
chainId,
|
||
6 years ago
|
showExportPrivateKeyModal,
|
||
|
setAccountLabel,
|
||
|
keyrings,
|
||
|
rpcPrefs,
|
||
4 years ago
|
} = this.props;
|
||
|
const { name, address } = selectedIdentity;
|
||
6 years ago
|
|
||
|
const keyring = keyrings.find((kr) => {
|
||
4 years ago
|
return kr.accounts.includes(address);
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
let exportPrivateKeyFeatureEnabled = true;
|
||
6 years ago
|
// This feature is disabled for hardware wallets
|
||
4 years ago
|
if (keyring?.type?.search('Hardware') !== -1) {
|
||
4 years ago
|
exportPrivateKeyFeatureEnabled = false;
|
||
6 years ago
|
}
|
||
|
|
||
|
return (
|
||
4 years ago
|
<AccountModalContainer className="account-details-modal">
|
||
6 years ago
|
<EditableLabel
|
||
4 years ago
|
className="account-details-modal__name"
|
||
6 years ago
|
defaultValue={name}
|
||
5 years ago
|
onSubmit={(label) => setAccountLabel(address, label)}
|
||
6 years ago
|
/>
|
||
|
|
||
|
<QrView
|
||
|
Qr={{
|
||
|
data: address,
|
||
|
}}
|
||
|
/>
|
||
|
|
||
4 years ago
|
<div className="account-details-modal__divider" />
|
||
6 years ago
|
|
||
|
<Button
|
||
|
type="secondary"
|
||
4 years ago
|
className="account-details-modal__button"
|
||
6 years ago
|
onClick={() => {
|
||
4 years ago
|
global.platform.openTab({
|
||
4 years ago
|
url: getAccountLink(address, chainId, rpcPrefs),
|
||
4 years ago
|
});
|
||
6 years ago
|
}}
|
||
|
>
|
||
|
{rpcPrefs.blockExplorerUrl
|
||
4 years ago
|
? this.context.t('blockExplorerView', [
|
||
|
rpcPrefs.blockExplorerUrl.match(/^https?:\/\/(.+)/u)[1],
|
||
|
])
|
||
|
: this.context.t('viewOnEtherscan')}
|
||
6 years ago
|
</Button>
|
||
|
|
||
4 years ago
|
{exportPrivateKeyFeatureEnabled ? (
|
||
|
<Button
|
||
|
type="secondary"
|
||
|
className="account-details-modal__button"
|
||
|
onClick={() => showExportPrivateKeyModal()}
|
||
|
>
|
||
|
{this.context.t('exportPrivateKey')}
|
||
|
</Button>
|
||
|
) : null}
|
||
6 years ago
|
</AccountModalContainer>
|
||
4 years ago
|
);
|
||
6 years ago
|
}
|
||
|
}
|