1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 19:10:22 +01:00
metamask-extension/ui/app/pages/asset/components/token-asset.js

59 lines
1.8 KiB
JavaScript
Raw Normal View History

import React from 'react'
import PropTypes from 'prop-types'
import { useDispatch, useSelector } from 'react-redux'
import { useHistory } from 'react-router-dom'
import { createAccountLink } from '@metamask/etherscan-link'
import TransactionList from '../../../components/app/transaction-list'
import { TokenOverview } from '../../../components/app/wallet-overview'
2020-11-03 00:41:28 +01:00
import {
getCurrentNetworkId,
getSelectedIdentity,
} from '../../../selectors/selectors'
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes'
import { showModal } from '../../../store/actions'
import AssetNavigation from './asset-navigation'
import TokenOptions from './token-options'
2020-11-03 00:41:28 +01:00
export default function TokenAsset({ token }) {
const dispatch = useDispatch()
const network = useSelector(getCurrentNetworkId)
2020-11-03 00:41:28 +01:00
const selectedAccountName = useSelector(
(state) => getSelectedIdentity(state).name,
)
const history = useHistory()
return (
<>
<AssetNavigation
accountName={selectedAccountName}
assetName={token.symbol}
onBack={() => history.push(DEFAULT_ROUTE)}
2020-11-03 00:41:28 +01:00
optionsButton={
<TokenOptions
2020-11-03 00:41:28 +01:00
onRemove={() =>
dispatch(showModal({ name: 'HIDE_TOKEN_CONFIRMATION', token }))
}
onViewEtherscan={() => {
const url = createAccountLink(token.address, network)
global.platform.openTab({ url })
}}
tokenSymbol={token.symbol}
/>
2020-11-03 00:41:28 +01:00
}
/>
<TokenOverview className="asset__overview" token={token} />
<TransactionList tokenAddress={token.address} />
</>
)
}
TokenAsset.propTypes = {
token: PropTypes.shape({
address: PropTypes.string.isRequired,
decimals: PropTypes.number,
symbol: PropTypes.string,
}).isRequired,
}