1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-01 21:57:06 +01:00
metamask-extension/ui/pages/asset/components/native-asset.js

71 lines
2.4 KiB
JavaScript
Raw Normal View History

import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import { useHistory } from 'react-router-dom';
import { getAccountLink } from '@metamask/etherscan-link';
import TransactionList from '../../../components/app/transaction-list';
import { EthOverview } from '../../../components/app/wallet-overview';
import {
getSelectedIdentity,
getCurrentChainId,
getRpcPrefsForCurrentProvider,
getSelectedAddress,
getIsCustomNetwork,
} from '../../../selectors/selectors';
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes';
import { getURLHostName } from '../../../helpers/utils/util';
import { MetaMetricsContext } from '../../../contexts/metametrics';
import { MetaMetricsEventCategory } from '../../../../shared/constants/metametrics';
import AssetNavigation from './asset-navigation';
import AssetOptions from './asset-options';
2020-11-03 00:41:28 +01:00
export default function NativeAsset({ nativeCurrency }) {
const selectedAccountName = useSelector(
(state) => getSelectedIdentity(state).name,
);
const chainId = useSelector(getCurrentChainId);
const rpcPrefs = useSelector(getRpcPrefsForCurrentProvider);
const address = useSelector(getSelectedAddress);
const history = useHistory();
const accountLink = getAccountLink(address, chainId, rpcPrefs);
const trackEvent = useContext(MetaMetricsContext);
const isCustomNetwork = useSelector(getIsCustomNetwork);
return (
<>
<AssetNavigation
accountName={selectedAccountName}
assetName={nativeCurrency}
onBack={() => history.push(DEFAULT_ROUTE)}
optionsButton={
<AssetOptions
isNativeAsset
onClickBlockExplorer={() => {
trackEvent({
event: 'Clicked Block Explorer Link',
category: MetaMetricsEventCategory.Navigation,
properties: {
link_type: 'Account Tracker',
action: 'Asset Options',
block_explorer_domain: getURLHostName(accountLink),
},
});
global.platform.openTab({
url: accountLink,
});
}}
isCustomNetwork={isCustomNetwork}
/>
}
/>
<EthOverview className="asset__overview" showAddress={false} />
<TransactionList hideTokenTransactions />
</>
);
}
NativeAsset.propTypes = {
nativeCurrency: PropTypes.string.isRequired,
};