From dc92b56f184100a24aaf53c3e93619514159f938 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 20 Mar 2018 09:07:23 -0230 Subject: Identify token transactions by method names token data, and not just whether they've been add via metamask. --- ui/app/components/pending-tx/index.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'ui/app/components/pending-tx/index.js') diff --git a/ui/app/components/pending-tx/index.js b/ui/app/components/pending-tx/index.js index f4f6afb8f..9676e9c86 100644 --- a/ui/app/components/pending-tx/index.js +++ b/ui/app/components/pending-tx/index.js @@ -63,14 +63,17 @@ PendingTx.prototype.componentWillMount = async function () { isFetching: false, }) } + const tokenData = txParams && abiDecoder.decodeMethod(txParams.data) + const { name: tokenMethodName } = tokenData || {} + const isTokenTransaction = ['transfer', 'approve', 'transferFrom'] + .find(possibleName => tokenMethodName === possibleName) - try { + if (isTokenTransaction) { const token = util.getContractAtAddress(txParams.to) const results = await Promise.all([ token.symbol(), token.decimals(), ]) - const [ symbol, decimals ] = results if (symbol[0] && decimals[0]) { @@ -83,11 +86,14 @@ PendingTx.prototype.componentWillMount = async function () { }) } else { this.setState({ - transactionType: TX_TYPES.SEND_ETHER, + transactionType: TX_TYPES.SEND_TOKEN, + tokenAddress: txParams.to, + tokenSymbol: null, + tokenDecimals: null, isFetching: false, }) } - } catch (e) { + } else { this.setState({ transactionType: TX_TYPES.SEND_ETHER, isFetching: false, -- cgit v1.2.3