You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.1 KiB
66 lines
2.1 KiB
4 years ago
|
import React from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import { useDispatch, useSelector } from 'react-redux';
|
||
|
import { useHistory } from 'react-router-dom';
|
||
4 years ago
|
import { createTokenTrackerLinkForChain } from '@metamask/etherscan-link';
|
||
5 years ago
|
|
||
4 years ago
|
import TransactionList from '../../../components/app/transaction-list';
|
||
|
import { TokenOverview } from '../../../components/app/wallet-overview';
|
||
4 years ago
|
import {
|
||
4 years ago
|
getCurrentChainId,
|
||
4 years ago
|
getSelectedIdentity,
|
||
4 years ago
|
} from '../../../selectors/selectors';
|
||
|
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes';
|
||
|
import { showModal } from '../../../store/actions';
|
||
5 years ago
|
|
||
4 years ago
|
import AssetNavigation from './asset-navigation';
|
||
4 years ago
|
import AssetOptions from './asset-options';
|
||
5 years ago
|
|
||
4 years ago
|
export default function TokenAsset({ token }) {
|
||
4 years ago
|
const dispatch = useDispatch();
|
||
4 years ago
|
const chainId = useSelector(getCurrentChainId);
|
||
4 years ago
|
const selectedIdentity = useSelector(getSelectedIdentity);
|
||
|
const selectedAccountName = selectedIdentity.name;
|
||
|
const selectedAddress = selectedIdentity.address;
|
||
|
const history = useHistory();
|
||
5 years ago
|
|
||
|
return (
|
||
|
<>
|
||
|
<AssetNavigation
|
||
|
accountName={selectedAccountName}
|
||
|
assetName={token.symbol}
|
||
|
onBack={() => history.push(DEFAULT_ROUTE)}
|
||
4 years ago
|
optionsButton={
|
||
4 years ago
|
<AssetOptions
|
||
4 years ago
|
onRemove={() =>
|
||
|
dispatch(showModal({ name: 'HIDE_TOKEN_CONFIRMATION', token }))
|
||
|
}
|
||
5 years ago
|
onViewEtherscan={() => {
|
||
4 years ago
|
const url = createTokenTrackerLinkForChain(
|
||
4 years ago
|
token.address,
|
||
4 years ago
|
chainId,
|
||
4 years ago
|
selectedAddress,
|
||
4 years ago
|
);
|
||
|
global.platform.openTab({ url });
|
||
5 years ago
|
}}
|
||
4 years ago
|
onViewAccountDetails={() => {
|
||
|
dispatch(showModal({ name: 'ACCOUNT_DETAILS' }));
|
||
|
}}
|
||
5 years ago
|
tokenSymbol={token.symbol}
|
||
|
/>
|
||
4 years ago
|
}
|
||
5 years ago
|
/>
|
||
|
<TokenOverview className="asset__overview" token={token} />
|
||
|
<TransactionList tokenAddress={token.address} />
|
||
|
</>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
|
|
||
|
TokenAsset.propTypes = {
|
||
|
token: PropTypes.shape({
|
||
|
address: PropTypes.string.isRequired,
|
||
|
decimals: PropTypes.number,
|
||
|
symbol: PropTypes.string,
|
||
|
}).isRequired,
|
||
4 years ago
|
};
|