From 924f49425eec0930fc971289b3413d607db66f69 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Mon, 1 Jul 2019 14:48:36 +0400 Subject: [PATCH] show status and tx hash in tx description --- .../component/ProviderDetails/UserDetails.jsx | 2 +- src/logic/wallets/ethAddresses.js | 3 +-- src/logic/wallets/getWeb3.js | 2 +- src/routes/opening/component/index.jsx | 4 ++-- .../TxsTable/ExpandedTx/index.jsx | 21 +++++++++++++++++-- .../safe/store/actions/fetchTransactions.js | 9 ++++++++ src/routes/safe/store/models/transaction.js | 2 ++ 7 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/components/Header/component/ProviderDetails/UserDetails.jsx b/src/components/Header/component/ProviderDetails/UserDetails.jsx index 4304541d..4220fb28 100644 --- a/src/components/Header/component/ProviderDetails/UserDetails.jsx +++ b/src/components/Header/component/ProviderDetails/UserDetails.jsx @@ -3,11 +3,11 @@ import * as React from 'react' import classNames from 'classnames' import OpenInNew from '@material-ui/icons/OpenInNew' import { withStyles } from '@material-ui/core/styles' +import Dot from '@material-ui/icons/FiberManualRecord' import Paragraph from '~/components/layout/Paragraph' import Link from '~/components/layout/Link' import Button from '~/components/layout/Button' import Identicon from '~/components/Identicon' -import Dot from '@material-ui/icons/FiberManualRecord' import Hairline from '~/components/layout/Hairline' import Img from '~/components/layout/Img' import Row from '~/components/layout/Row' diff --git a/src/logic/wallets/ethAddresses.js b/src/logic/wallets/ethAddresses.js index fa527d07..34c0a9bc 100644 --- a/src/logic/wallets/ethAddresses.js +++ b/src/logic/wallets/ethAddresses.js @@ -14,8 +14,7 @@ export const sameAddress = (firstAddress: string, secondAddress: string): boolea } export const shortVersionOf = (address: string, cut: number) => { - const initial = cut const final = 42 - cut - return `${address.substring(0, initial)}...${address.substring(final)}` + return `${address.substring(0, cut)}...${address.substring(final)}` } diff --git a/src/logic/wallets/getWeb3.js b/src/logic/wallets/getWeb3.js index 390f6b43..6fc0f611 100644 --- a/src/logic/wallets/getWeb3.js +++ b/src/logic/wallets/getWeb3.js @@ -32,7 +32,7 @@ export const ETHEREUM_NETWORK_IDS = { 42: ETHEREUM_NETWORK.KOVAN, } -export const openTxInEtherScan = (tx: string, network: string) => `https://${network}.etherscan.io/tx/${tx}` +export const openTxInEtherScan = (txHash: string, network: string) => `https://${network}.etherscan.io/tx/${txHash}` export const getEtherScanLink = (address: string, network: string) => `https://${network}.etherscan.io/address/${address}` diff --git a/src/routes/opening/component/index.jsx b/src/routes/opening/component/index.jsx index 3c239471..37963a12 100644 --- a/src/routes/opening/component/index.jsx +++ b/src/routes/opening/component/index.jsx @@ -1,10 +1,10 @@ // @flow import * as React from 'react' -import Block from '~/components/layout/Block' import OpenInNew from '@material-ui/icons/OpenInNew' -import Paragraph from '~/components/layout/Paragraph' import LinearProgress from '@material-ui/core/LinearProgress' import { withStyles } from '@material-ui/core/styles' +import Block from '~/components/layout/Block' +import Paragraph from '~/components/layout/Paragraph' import Img from '~/components/layout/Img' import Page from '~/components/layout/Page' import { openTxInEtherScan } from '~/logic/wallets/getWeb3' diff --git a/src/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/index.jsx b/src/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/index.jsx index 1c5b9e71..a73910db 100644 --- a/src/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/index.jsx +++ b/src/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/index.jsx @@ -1,7 +1,9 @@ // @flow import React, { useState } from 'react' +import { List } from 'immutable' import { withStyles } from '@material-ui/core/styles' import Tabs from '@material-ui/core/Tabs' +import OpenInNew from '@material-ui/icons/OpenInNew' import Tab from '@material-ui/core/Tab' import Row from '~/components/layout/Row' import Block from '~/components/layout/Block' @@ -11,8 +13,11 @@ import Paragraph from '~/components/layout/Paragraph' import Hairline from '~/components/layout/Hairline' import { type Transaction } from '~/routes/safe/store/models/transaction' import { type Owner } from '~/routes/safe/store/models/owner' +import { openTxInEtherScan } from '~/logic/wallets/getWeb3' +import { shortVersionOf } from '~/logic/wallets/ethAddresses' import { styles } from './style' import { formatDate } from '../columns' +import { secondary } from '~/theme/variables' type Props = { classes: Object, @@ -21,6 +26,11 @@ type Props = { owners: List, } +const openIconStyle = { + height: '13px', + color: secondary, +} + const ExpandedTx = ({ classes, tx, threshold, owners, }: Props) => { @@ -39,11 +49,18 @@ const ExpandedTx = ({ TX hash: - n/a + {tx.executionTxHash ? ( + + {shortVersionOf(tx.executionTxHash, 4)} + + + ) : ( + 'n/a' + )} TX status: - n/a + {tx.executionTxHash ? 'Success' : 'Awaiting confirmations'} TX created: diff --git a/src/routes/safe/store/actions/fetchTransactions.js b/src/routes/safe/store/actions/fetchTransactions.js index 0a0858c2..4b239bba 100644 --- a/src/routes/safe/store/actions/fetchTransactions.js +++ b/src/routes/safe/store/actions/fetchTransactions.js @@ -13,6 +13,7 @@ import { EMPTY_DATA } from '~/logic/wallets/ethTransactions' import { addTransactions } from './addTransactions' import { getHumanFriendlyToken } from '~/logic/tokens/store/actions/fetchTokens' import { isAddressAToken } from '~/logic/tokens/utils/tokenHelpers' +import { TX_TYPE_EXECUTION } from '~/logic/safe/transactions/send' type ConfirmationServiceModel = { owner: string, @@ -49,6 +50,13 @@ const buildTransactionFrom = async (safeAddress: string, tx: TxServiceModel, saf ) const isToken = await isAddressAToken(tx.to) + let executionTxHash + const executionTx = confirmations.find(conf => conf.type === TX_TYPE_EXECUTION) + + if (executionTx) { + executionTxHash = executionTx.hash + } + let symbol = 'ETH' if (isToken) { const tokenContract = await getHumanFriendlyToken() @@ -67,6 +75,7 @@ const buildTransactionFrom = async (safeAddress: string, tx: TxServiceModel, saf isExecuted: tx.isExecuted, submissionDate: tx.submissionDate, executionDate: tx.executionDate, + executionTxHash, }) } diff --git a/src/routes/safe/store/models/transaction.js b/src/routes/safe/store/models/transaction.js index ccb84dd3..d2e225b4 100644 --- a/src/routes/safe/store/models/transaction.js +++ b/src/routes/safe/store/models/transaction.js @@ -14,6 +14,7 @@ export type TransactionProps = { submissionDate: Date, executionDate: Date, symbol: string, + executionTxHash?: string, } export const makeTransaction: RecordFactory = Record({ @@ -27,6 +28,7 @@ export const makeTransaction: RecordFactory = Record({ submissionDate: '', executionDate: '', symbol: '', + executionTxHash: undefined, }) export type Transaction = RecordOf