diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-08-07 16:57:46 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@gmail.com> | 2018-08-24 07:45:27 +0800 |
commit | 5dcd8ceb7bbaef33fef5588feceac17577679e74 (patch) | |
tree | a50c48dbdf3cc376bcdd03de64845aa5bed97b51 /ui | |
parent | 9adf0c4b60c863a820af7b20ff66a8b29f7bdbe7 (diff) | |
download | tangerine-wallet-browser-5dcd8ceb7bbaef33fef5588feceac17577679e74.tar tangerine-wallet-browser-5dcd8ceb7bbaef33fef5588feceac17577679e74.tar.gz tangerine-wallet-browser-5dcd8ceb7bbaef33fef5588feceac17577679e74.tar.bz2 tangerine-wallet-browser-5dcd8ceb7bbaef33fef5588feceac17577679e74.tar.lz tangerine-wallet-browser-5dcd8ceb7bbaef33fef5588feceac17577679e74.tar.xz tangerine-wallet-browser-5dcd8ceb7bbaef33fef5588feceac17577679e74.tar.zst tangerine-wallet-browser-5dcd8ceb7bbaef33fef5588feceac17577679e74.zip |
Fix e2e tests
Diffstat (limited to 'ui')
6 files changed, 30 insertions, 33 deletions
diff --git a/ui/app/components/transaction-action/transaction-action.component.js b/ui/app/components/transaction-action/transaction-action.component.js index b608615d0..9f447fe5c 100644 --- a/ui/app/components/transaction-action/transaction-action.component.js +++ b/ui/app/components/transaction-action/transaction-action.component.js @@ -28,9 +28,9 @@ export default class TransactionAction extends PureComponent { getTransactionAction () { const { transactionAction } = this.state const { transaction, methodData } = this.props - const { data, isFetching } = methodData + const { data, done } = methodData - if (isFetching || transactionAction) { + if (!done || transactionAction) { return } @@ -40,12 +40,12 @@ export default class TransactionAction extends PureComponent { } render () { - const { className } = this.props + const { className, methodData: { isFetching } } = this.props const { transactionAction } = this.state return ( <div className={className}> - { transactionAction || '--' } + { (!isFetching && transactionAction) || '--' } </div> ) } diff --git a/ui/app/components/transaction-list-item/transaction-list-item.component.js b/ui/app/components/transaction-list-item/transaction-list-item.component.js index 6e1abd0e4..a47f29023 100644 --- a/ui/app/components/transaction-list-item/transaction-list-item.component.js +++ b/ui/app/components/transaction-list-item/transaction-list-item.component.js @@ -3,11 +3,9 @@ import PropTypes from 'prop-types' import Identicon from '../identicon' import TransactionStatus from '../transaction-status' import TransactionAction from '../transaction-action' -import { formatDate } from '../../util' import prefixForNetwork from '../../../lib/etherscan-prefix-for-network' import { CONFIRM_TRANSACTION_ROUTE } from '../../routes' import { UNAPPROVED_STATUS, TOKEN_METHOD_TRANSFER } from '../../constants/transactions' -import { hexToDecimal } from '../../helpers/conversions.util' export default class TransactionListItem extends PureComponent { static propTypes = { @@ -19,6 +17,7 @@ export default class TransactionListItem extends PureComponent { showRetry: PropTypes.bool, retryTransaction: PropTypes.func, setSelectedToken: PropTypes.func, + nonceAndDate: PropTypes.string, } handleClick = () => { @@ -63,14 +62,9 @@ export default class TransactionListItem extends PureComponent { fiatDisplayValue, methodData, showRetry, + nonceAndDate, } = this.props const { txParams = {} } = transaction - const nonce = hexToDecimal(txParams.nonce) - - const nonceAndDateText = nonce - ? `#${nonce} - ${formatDate(transaction.time)}` - : formatDate(transaction.time) - const fiatDisplayText = `-${fiatDisplayValue}` const ethDisplayText = ethTransactionAmount && `-${ethTransactionAmount} ETH` @@ -92,9 +86,9 @@ export default class TransactionListItem extends PureComponent { /> <div className="transaction-list-item__nonce" - title={nonceAndDateText} + title={nonceAndDate} > - { nonceAndDateText } + { nonceAndDate } </div> <TransactionStatus className="transaction-list-item__status" diff --git a/ui/app/components/transaction-list-item/transaction-list-item.container.js b/ui/app/components/transaction-list-item/transaction-list-item.container.js index f482e2483..209ddb9f6 100644 --- a/ui/app/components/transaction-list-item/transaction-list-item.container.js +++ b/ui/app/components/transaction-list-item/transaction-list-item.container.js @@ -4,16 +4,16 @@ import { compose } from 'recompose' import withMethodData from '../../higher-order-components/with-method-data' import TransactionListItem from './transaction-list-item.component' import { setSelectedToken, retryTransaction } from '../../actions' -import { getEthFromWeiHex, getValueFromWeiHex } from '../../helpers/conversions.util' +import { getEthFromWeiHex, getValueFromWeiHex, hexToDecimal } from '../../helpers/conversions.util' import { getTokenData } from '../../helpers/transactions.util' import { formatCurrency } from '../../helpers/confirm-transaction/util' import { calcTokenAmount } from '../../token-util' -import { TOKEN_METHOD_TRANSFER } from '../../constants/transactions' +import { formatDate } from '../../util' const mapStateToProps = (state, ownProps) => { const { metamask } = state const { currentCurrency, conversionRate } = metamask - const { transaction: { txParams: { value, data } = {} } = {}, token } = ownProps + const { transaction: { txParams: { value, data, nonce } = {}, time } = {}, token } = ownProps let ethTransactionAmount, fiatDisplayValue @@ -22,13 +22,9 @@ const mapStateToProps = (state, ownProps) => { const tokenData = getTokenData(data) if (tokenData.params && tokenData.params.length === 2) { - const tokenDataName = tokenData.name || '' const tokenValue = tokenData.params[1].value - const tokenAmount = tokenDataName.toLowerCase() === TOKEN_METHOD_TRANSFER - ? calcTokenAmount(tokenValue, decimals) - : tokenValue - - fiatDisplayValue = `${tokenAmount} ${symbol}` + const tokenAmount = calcTokenAmount(tokenValue, decimals) + fiatDisplayValue = `${tokenAmount} ${symbol}` } } else { ethTransactionAmount = getEthFromWeiHex({ value, conversionRate }) @@ -39,9 +35,12 @@ const mapStateToProps = (state, ownProps) => { fiatDisplayValue = `${fiatFormattedAmount} ${currentCurrency.toUpperCase()}` } + const nonceAndDate = nonce ? `#${hexToDecimal(nonce)} - ${formatDate(time)}` : formatDate(time) + return { ethTransactionAmount, fiatDisplayValue, + nonceAndDate, } } diff --git a/ui/app/constants/transactions.js b/ui/app/constants/transactions.js index 1dc8944d3..da1d2e590 100644 --- a/ui/app/constants/transactions.js +++ b/ui/app/constants/transactions.js @@ -17,5 +17,6 @@ export const APPROVE_ACTION_KEY = 'approve' export const SEND_TOKEN_ACTION_KEY = 'outgoing' export const TRANSFER_FROM_ACTION_KEY = 'transferFrom' export const SIGNATURE_REQUEST_KEY = 'signatureRequest' +export const UNKNOWN_FUNCTION_KEY = 'unknownFunction' export const TRANSACTION_TYPE_SHAPESHIFT = 'shapeshift' diff --git a/ui/app/helpers/transactions.util.js b/ui/app/helpers/transactions.util.js index 8ded31bca..e890a0852 100644 --- a/ui/app/helpers/transactions.util.js +++ b/ui/app/helpers/transactions.util.js @@ -14,6 +14,7 @@ import { SEND_TOKEN_ACTION_KEY, TRANSFER_FROM_ACTION_KEY, SIGNATURE_REQUEST_KEY, + UNKNOWN_FUNCTION_KEY, } from '../constants/transactions' abiDecoder.addABI(abi) @@ -56,6 +57,10 @@ export function getTransactionActionKey (transaction, methodData) { const { name } = methodData const methodName = name && name.toLowerCase() + if (!methodName) { + return UNKNOWN_FUNCTION_KEY + } + switch (methodName) { case TOKEN_METHOD_TRANSFER: return SEND_TOKEN_ACTION_KEY diff --git a/ui/app/higher-order-components/with-method-data/with-method-data.component.js b/ui/app/higher-order-components/with-method-data/with-method-data.component.js index c05d33c20..fed7d9865 100644 --- a/ui/app/higher-order-components/with-method-data/with-method-data.component.js +++ b/ui/app/higher-order-components/with-method-data/with-method-data.component.js @@ -13,10 +13,8 @@ export default function withMethodData (WrappedComponent) { } state = { - methodData: { - data: {}, - }, - isFetching: false, + methodData: {}, + done: false, error: null, } @@ -29,24 +27,24 @@ export default function withMethodData (WrappedComponent) { const { txParams: { data = '' } = {} } = transaction if (data) { - this.setState({ isFetching: true }) - try { const methodData = await getMethodData(data) - this.setState({ methodData, isFetching: false }) + this.setState({ methodData, done: true }) } catch (error) { - this.setState({ isFetching: false, error }) + this.setState({ done: true, error }) } + } else { + this.setState({ done: true }) } } render () { - const { methodData, isFetching, error } = this.state + const { methodData, done, error } = this.state return ( <WrappedComponent { ...this.props } - methodData={{ data: methodData, isFetching, error }} + methodData={{ data: methodData, done, error }} /> ) } |