(Fix) - Adds operation call check on isTokenTransfer (#1613)

* Adds operation call check on isTokenTransfer

* Add comment in unclear if

Co-authored-by: Fernando <fernando.greco@gmail.com>
Co-authored-by: nicolas <nicosampler@users.noreply.github.com>
Co-authored-by: Daniel Sanchez <daniel.sanchez@gnosis.pm>
This commit is contained in:
Agustin Pane 2020-11-18 15:11:20 -03:00 committed by GitHub
parent 3f6a8ee3f8
commit 8876469166
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import { ALTERNATIVE_TOKEN_ABI } from 'src/logic/tokens/utils/alternativeAbi'
import { web3ReadOnly as web3 } from 'src/logic/wallets/getWeb3' import { web3ReadOnly as web3 } from 'src/logic/wallets/getWeb3'
import { isEmptyData } from 'src/logic/safe/store/actions/transactions/utils/transactionHelpers' import { isEmptyData } from 'src/logic/safe/store/actions/transactions/utils/transactionHelpers'
import { TxServiceModel } from 'src/logic/safe/store/actions/transactions/fetchTransactions/loadOutgoingTransactions' 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 => { export const getEthAsToken = (balance: string | number): Token => {
const { nativeCoin } = getNetworkInfo() const { nativeCoin } = getNetworkInfo()
@ -33,7 +34,13 @@ export const isAddressAToken = async (tokenAddress: string): Promise<boolean> =>
} }
export const isTokenTransfer = (tx: TxServiceModel): boolean => { 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 ( export const getERC20DecimalsAndSymbol = async (