mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
1304ec7af5
We want to convert NetworkController to TypeScript in order to be able to compare differences in the controller between in this repo and the core repo. To do this, however, we need to convert the dependencies of the controller to TypeScript. As a part of this effort, this commit converts `shared/constants/metametrics` to TypeScript. Note that simple objects have been largely replaced with enums. There are some cases where I even split up some of these objects into multiple enums. Co-authored-by: Mark Stacey <markjstacey@gmail.com>
76 lines
2.6 KiB
JavaScript
76 lines
2.6 KiB
JavaScript
import React, { useContext } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { useSelector, useDispatch } 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 { showModal } from '../../../store/actions';
|
|
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';
|
|
|
|
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();
|
|
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,
|
|
});
|
|
}}
|
|
onViewAccountDetails={() => {
|
|
dispatch(showModal({ name: 'ACCOUNT_DETAILS' }));
|
|
}}
|
|
isCustomNetwork={isCustomNetwork}
|
|
/>
|
|
}
|
|
/>
|
|
<EthOverview className="asset__overview" />
|
|
<TransactionList hideTokenTransactions />
|
|
</>
|
|
);
|
|
}
|
|
|
|
NativeAsset.propTypes = {
|
|
nativeCurrency: PropTypes.string.isRequired,
|
|
};
|