1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-04 23:14:56 +01:00
metamask-extension/ui/pages/asset/components/native-asset.js
2021-06-06 12:45:27 -02:30

59 lines
1.8 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { useSelector, useDispatch } from 'react-redux';
import { useHistory } from 'react-router-dom';
import TransactionList from '../../../components/app/transaction-list';
import { EthOverview } from '../../../components/app/wallet-overview';
import {
getSelectedIdentity,
getCurrentChainId,
getRpcPrefsForCurrentProvider,
getSelectedAddress,
} from '../../../selectors/selectors';
import { showModal } from '../../../store/actions';
import getAccountLink from '../../../helpers/utils/account-link';
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes';
import AssetNavigation from './asset-navigation';
import AssetOptions from './asset-options';
export default function NativeAsset({ nativeCurrency }) {
const selectedAccountName = useSelector(
(state) => getSelectedIdentity(state).name,
);
const dispatch = useDispatch();
const chainId = useSelector(getCurrentChainId);
const rpcPrefs = useSelector(getRpcPrefsForCurrentProvider);
const address = useSelector(getSelectedAddress);
const history = useHistory();
return (
<>
<AssetNavigation
accountName={selectedAccountName}
assetName={nativeCurrency}
onBack={() => history.push(DEFAULT_ROUTE)}
optionsButton={
<AssetOptions
isNativeAsset
onViewEtherscan={() => {
global.platform.openTab({
url: getAccountLink(address, chainId, rpcPrefs),
});
}}
onViewAccountDetails={() => {
dispatch(showModal({ name: 'ACCOUNT_DETAILS' }));
}}
/>
}
/>
<EthOverview className="asset__overview" />
<TransactionList hideTokenTransactions />
</>
);
}
NativeAsset.propTypes = {
nativeCurrency: PropTypes.string.isRequired,
};