2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import classnames from 'classnames';
|
2023-04-13 19:37:33 +02:00
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
import { toChecksumHexAddress } from '../../../../shared/modules/hexstring-utils';
|
|
|
|
import { getSelectedIdentity } from '../../../selectors';
|
|
|
|
import { AddressCopyButton } from '../../multichain';
|
2023-05-04 16:15:37 +02:00
|
|
|
import Box from '../../ui/box/box';
|
2020-05-21 19:33:48 +02:00
|
|
|
|
2023-06-26 18:13:26 +02:00
|
|
|
const WalletOverview = ({
|
|
|
|
balance,
|
|
|
|
buttons,
|
|
|
|
className,
|
|
|
|
showAddress = false,
|
|
|
|
}) => {
|
2023-04-13 19:37:33 +02:00
|
|
|
const selectedIdentity = useSelector(getSelectedIdentity);
|
|
|
|
const checksummedAddress = toChecksumHexAddress(selectedIdentity?.address);
|
2020-05-21 19:33:48 +02:00
|
|
|
return (
|
2020-06-01 19:54:32 +02:00
|
|
|
<div className={classnames('wallet-overview', className)}>
|
2020-05-21 19:33:48 +02:00
|
|
|
<div className="wallet-overview__balance">
|
2023-06-26 18:13:26 +02:00
|
|
|
{showAddress ? (
|
|
|
|
<Box marginTop={2}>
|
|
|
|
<AddressCopyButton address={checksummedAddress} shorten />
|
|
|
|
</Box>
|
|
|
|
) : null}
|
2020-11-03 00:41:28 +01:00
|
|
|
{balance}
|
2020-05-21 19:33:48 +02:00
|
|
|
</div>
|
2020-11-03 00:41:28 +01:00
|
|
|
<div className="wallet-overview__buttons">{buttons}</div>
|
2020-05-21 19:33:48 +02:00
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
};
|
2020-05-21 19:33:48 +02:00
|
|
|
|
|
|
|
WalletOverview.propTypes = {
|
|
|
|
balance: PropTypes.element.isRequired,
|
|
|
|
buttons: PropTypes.element.isRequired,
|
2020-06-01 19:54:32 +02:00
|
|
|
className: PropTypes.string,
|
2023-06-26 18:13:26 +02:00
|
|
|
showAddress: PropTypes.bool,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-06-01 19:54:32 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
export default WalletOverview;
|