add descriptions for eth/erc20 transfers

This commit is contained in:
mmv 2019-07-10 17:31:45 +04:00
parent 5a2d6bba91
commit 51048a42a5
2 changed files with 22 additions and 6 deletions

View File

@ -18,6 +18,20 @@ const openIconStyle = {
color: secondary,
}
const getTxData = (tx: Transaction) => {
const txData = {}
if (tx.isTokenTransfer && tx.decodedParams) {
txData.recipient = tx.decodedParams.recipient
txData.value = fromWei(toBN(tx.decodedParams.value), 'ether')
} else if (Number(tx.value) > 0) {
txData.recipient = tx.recipient
txData.value = fromWei(toBN(tx.value), 'ether')
}
return txData
}
export const styles = () => ({
txDataContainer: {
padding: `${lg} ${md}`,
@ -30,7 +44,7 @@ type Props = {
}
const TxDescription = ({ tx, classes }: Props) => {
const description = ''
const { recipient, value } = getTxData(tx)
return (
<Block className={classes.txDataContainer}>
@ -38,15 +52,15 @@ const TxDescription = ({ tx, classes }: Props) => {
<Bold>
Send
{' '}
{fromWei(toBN(tx.value), 'ether')}
{value}
{' '}
{tx.symbol}
{' '}
to:
to:
</Bold>
<br />
<a href={getEtherScanLink(tx.recipient, 'rinkeby')} target="_blank" rel="noopener noreferrer">
{shortVersionOf(tx.recipient, 4)}
<a href={getEtherScanLink(recipient, 'rinkeby')} target="_blank" rel="noopener noreferrer">
{shortVersionOf(recipient, 4)}
<OpenInNew style={openIconStyle} />
</a>
</Paragraph>

View File

@ -1,5 +1,7 @@
// @flow
import { md, lg, connected, error } from '~/theme/variables'
import {
md, lg, connected, error,
} from '~/theme/variables'
export const styles = () => ({
txDataContainer: {