Refactor isTokenTransfer
This commit is contained in:
parent
910bd5c9a2
commit
09db7d7321
|
@ -48,3 +48,5 @@ export const isAddressAToken = async (tokenAddress: string) => {
|
||||||
|
|
||||||
return call !== '0x'
|
return call !== '0x'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const isTokenTransfer = async (data: string, value: number) => data.substring(0, 10) === '0xa9059cbb' && value === 0
|
||||||
|
|
|
@ -13,7 +13,7 @@ import { getWeb3 } from '~/logic/wallets/getWeb3'
|
||||||
import { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
|
import { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
|
||||||
import { addTransactions } from './addTransactions'
|
import { addTransactions } from './addTransactions'
|
||||||
import { getHumanFriendlyToken } from '~/logic/tokens/store/actions/fetchTokens'
|
import { getHumanFriendlyToken } from '~/logic/tokens/store/actions/fetchTokens'
|
||||||
import { isAddressAToken } from '~/logic/tokens/utils/tokenHelpers'
|
import { isTokenTransfer } from '~/logic/tokens/utils/tokenHelpers'
|
||||||
import { TX_TYPE_EXECUTION } from '~/logic/safe/transactions/send'
|
import { TX_TYPE_EXECUTION } from '~/logic/safe/transactions/send'
|
||||||
import { decodeParamsFromSafeMethod } from '~/logic/contracts/methodIds'
|
import { decodeParamsFromSafeMethod } from '~/logic/contracts/methodIds'
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ export const buildTransactionFrom = async (
|
||||||
const modifySettingsTx = tx.to === safeAddress && Number(tx.value) === 0 && !!tx.data
|
const modifySettingsTx = tx.to === safeAddress && Number(tx.value) === 0 && !!tx.data
|
||||||
const cancellationTx = tx.to === safeAddress && Number(tx.value) === 0 && !tx.data
|
const cancellationTx = tx.to === safeAddress && Number(tx.value) === 0 && !tx.data
|
||||||
const customTx = tx.to !== safeAddress && !!tx.data
|
const customTx = tx.to !== safeAddress && !!tx.data
|
||||||
const isTokenTransfer = await isAddressAToken(tx.to)
|
const isSendTokenTx = await isTokenTransfer(tx.data, tx.value)
|
||||||
|
|
||||||
let executionTxHash
|
let executionTxHash
|
||||||
const executionTx = confirmations.find((conf) => conf.type === TX_TYPE_EXECUTION)
|
const executionTx = confirmations.find((conf) => conf.type === TX_TYPE_EXECUTION)
|
||||||
|
@ -71,7 +71,7 @@ export const buildTransactionFrom = async (
|
||||||
|
|
||||||
let symbol = 'ETH'
|
let symbol = 'ETH'
|
||||||
let decodedParams
|
let decodedParams
|
||||||
if (isTokenTransfer) {
|
if (isSendTokenTx) {
|
||||||
const tokenContract = await getHumanFriendlyToken()
|
const tokenContract = await getHumanFriendlyToken()
|
||||||
const tokenInstance = await tokenContract.at(tx.to)
|
const tokenInstance = await tokenContract.at(tx.to)
|
||||||
symbol = await tokenInstance.symbol()
|
symbol = await tokenInstance.symbol()
|
||||||
|
|
Loading…
Reference in New Issue