mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-27 04:46:10 +01:00
8becb57d9e
Co-authored-by: Danica Shen <zhaodanica@gmail.com>
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import classnames from 'classnames';
|
|
import { useSelector } from 'react-redux';
|
|
import { toChecksumHexAddress } from '../../../../shared/modules/hexstring-utils';
|
|
import { getSelectedIdentity } from '../../../selectors';
|
|
import { AddressCopyButton } from '../../multichain';
|
|
|
|
const WalletOverview = ({ balance, buttons, className, icon, loading }) => {
|
|
const selectedIdentity = useSelector(getSelectedIdentity);
|
|
const checksummedAddress = toChecksumHexAddress(selectedIdentity?.address);
|
|
return (
|
|
<div className={classnames('wallet-overview', className)}>
|
|
<div className="wallet-overview__balance">
|
|
{process.env.MULTICHAIN ? (
|
|
<AddressCopyButton address={checksummedAddress} shorten />
|
|
) : (
|
|
<>{loading ? null : icon}</>
|
|
)}
|
|
{balance}
|
|
</div>
|
|
<div className="wallet-overview__buttons">{buttons}</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
WalletOverview.propTypes = {
|
|
balance: PropTypes.element.isRequired,
|
|
buttons: PropTypes.element.isRequired,
|
|
className: PropTypes.string,
|
|
icon: PropTypes.element.isRequired,
|
|
loading: PropTypes.bool,
|
|
};
|
|
|
|
WalletOverview.defaultProps = {
|
|
className: undefined,
|
|
};
|
|
|
|
export default WalletOverview;
|