From 8876469166bfcde8d12e6b332bc303335288758c Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Wed, 18 Nov 2020 15:11:20 -0300 Subject: [PATCH] (Fix) - Adds operation call check on isTokenTransfer (#1613) * Adds operation call check on isTokenTransfer * Add comment in unclear if Co-authored-by: Fernando Co-authored-by: nicolas Co-authored-by: Daniel Sanchez --- src/logic/tokens/utils/tokenHelpers.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/logic/tokens/utils/tokenHelpers.ts b/src/logic/tokens/utils/tokenHelpers.ts index fbf6dfe1..c490819d 100644 --- a/src/logic/tokens/utils/tokenHelpers.ts +++ b/src/logic/tokens/utils/tokenHelpers.ts @@ -9,6 +9,7 @@ import { ALTERNATIVE_TOKEN_ABI } from 'src/logic/tokens/utils/alternativeAbi' import { web3ReadOnly as web3 } from 'src/logic/wallets/getWeb3' import { isEmptyData } from 'src/logic/safe/store/actions/transactions/utils/transactionHelpers' import { TxServiceModel } from 'src/logic/safe/store/actions/transactions/fetchTransactions/loadOutgoingTransactions' +import { CALL } from 'src/logic/safe/transactions' export const getEthAsToken = (balance: string | number): Token => { const { nativeCoin } = getNetworkInfo() @@ -33,7 +34,13 @@ export const isAddressAToken = async (tokenAddress: string): Promise => } export const isTokenTransfer = (tx: TxServiceModel): boolean => { - return !isEmptyData(tx.data) && tx.data?.substring(0, 10) === '0xa9059cbb' && Number(tx.value) === 0 + return ( + !isEmptyData(tx.data) && + // Check if contains 'transfer' method code + tx.data?.substring(0, 10) === '0xa9059cbb' && + Number(tx.value) === 0 && + tx.operation === CALL + ) } export const getERC20DecimalsAndSymbol = async (