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, 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 = () => ({ export const styles = () => ({
txDataContainer: { txDataContainer: {
padding: `${lg} ${md}`, padding: `${lg} ${md}`,
@ -30,7 +44,7 @@ type Props = {
} }
const TxDescription = ({ tx, classes }: Props) => { const TxDescription = ({ tx, classes }: Props) => {
const description = '' const { recipient, value } = getTxData(tx)
return ( return (
<Block className={classes.txDataContainer}> <Block className={classes.txDataContainer}>
@ -38,15 +52,15 @@ const TxDescription = ({ tx, classes }: Props) => {
<Bold> <Bold>
Send Send
{' '} {' '}
{fromWei(toBN(tx.value), 'ether')} {value}
{' '} {' '}
{tx.symbol} {tx.symbol}
{' '} {' '}
to: to:
</Bold> </Bold>
<br /> <br />
<a href={getEtherScanLink(tx.recipient, 'rinkeby')} target="_blank" rel="noopener noreferrer"> <a href={getEtherScanLink(recipient, 'rinkeby')} target="_blank" rel="noopener noreferrer">
{shortVersionOf(tx.recipient, 4)} {shortVersionOf(recipient, 4)}
<OpenInNew style={openIconStyle} /> <OpenInNew style={openIconStyle} />
</a> </a>
</Paragraph> </Paragraph>

View File

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