2020-06-12 19:04:40 +02:00
|
|
|
import React from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import { useDispatch, useSelector } from 'react-redux'
|
|
|
|
import { useHistory } from 'react-router-dom'
|
2020-11-19 19:49:45 +01:00
|
|
|
import { createTokenTrackerLink } from '@metamask/etherscan-link'
|
2020-06-12 19:04:40 +02:00
|
|
|
|
|
|
|
import TransactionList from '../../../components/app/transaction-list'
|
|
|
|
import { TokenOverview } from '../../../components/app/wallet-overview'
|
2020-11-19 05:29:42 +01:00
|
|
|
import {
|
|
|
|
getCurrentNetworkId,
|
|
|
|
getSelectedIdentity,
|
|
|
|
} from '../../../selectors/selectors'
|
2020-06-12 19:04:40 +02:00
|
|
|
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 }) {
|
2020-06-12 19:04:40 +02:00
|
|
|
const dispatch = useDispatch()
|
2020-11-19 05:29:42 +01:00
|
|
|
const network = useSelector(getCurrentNetworkId)
|
2020-11-19 02:27:29 +01:00
|
|
|
const selectedIdentity = useSelector(getSelectedIdentity)
|
|
|
|
const selectedAccountName = selectedIdentity.name
|
|
|
|
const selectedAddress = selectedIdentity.address
|
2020-06-12 19:04:40 +02:00
|
|
|
const history = useHistory()
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<AssetNavigation
|
|
|
|
accountName={selectedAccountName}
|
|
|
|
assetName={token.symbol}
|
|
|
|
onBack={() => history.push(DEFAULT_ROUTE)}
|
2020-11-03 00:41:28 +01:00
|
|
|
optionsButton={
|
2020-06-12 19:04:40 +02:00
|
|
|
<TokenOptions
|
2020-11-03 00:41:28 +01:00
|
|
|
onRemove={() =>
|
|
|
|
dispatch(showModal({ name: 'HIDE_TOKEN_CONFIRMATION', token }))
|
|
|
|
}
|
2020-06-12 19:04:40 +02:00
|
|
|
onViewEtherscan={() => {
|
2020-11-19 19:49:45 +01:00
|
|
|
const url = createTokenTrackerLink(
|
2020-11-19 05:29:42 +01:00
|
|
|
token.address,
|
|
|
|
network,
|
|
|
|
selectedAddress,
|
|
|
|
)
|
2020-06-12 19:04:40 +02:00
|
|
|
global.platform.openTab({ url })
|
|
|
|
}}
|
|
|
|
tokenSymbol={token.symbol}
|
|
|
|
/>
|
2020-11-03 00:41:28 +01:00
|
|
|
}
|
2020-06-12 19:04:40 +02: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,
|
|
|
|
}
|