fix: execute decodeParams for all sendTokenTxs

This commit is contained in:
fernandomg 2020-04-23 12:47:19 -03:00
parent c887c71b05
commit cdcdd07b23
1 changed files with 19 additions and 17 deletions

View File

@ -133,24 +133,26 @@ export const buildTransactionFrom = async (
let symbol = txTokenSymbol || 'ETH' let symbol = txTokenSymbol || 'ETH'
let decimals = txTokenDecimals || 18 let decimals = txTokenDecimals || 18
let decodedParams let decodedParams
if (isSendTokenTx && (txTokenSymbol === null || txTokenDecimals === null)) { if (isSendTokenTx) {
try { if (txTokenSymbol === null || txTokenDecimals === null) {
const [tokenSymbol, tokenDecimals] = await Promise.all( try {
generateBatchRequests({ const [tokenSymbol, tokenDecimals] = await Promise.all(
abi: ALTERNATIVE_TOKEN_ABI, generateBatchRequests({
address: tx.to, abi: ALTERNATIVE_TOKEN_ABI,
methods: ['symbol', 'decimals'], address: tx.to,
}), methods: ['symbol', 'decimals'],
) }),
)
symbol = tokenSymbol symbol = tokenSymbol
decimals = tokenDecimals decimals = tokenDecimals
} catch (e) { } catch (e) {
// some contracts may implement the same methods as in ERC20 standard // some contracts may implement the same methods as in ERC20 standard
// we may falsely treat them as tokens, so in case we get any errors when getting token info // we may falsely treat them as tokens, so in case we get any errors when getting token info
// we fallback to displaying custom transaction // we fallback to displaying custom transaction
isSendTokenTx = false isSendTokenTx = false
customTx = true customTx = true
}
} }
const params = web3.eth.abi.decodeParameters(['address', 'uint256'], tx.data.slice(10)) const params = web3.eth.abi.decodeParameters(['address', 'uint256'], tx.data.slice(10))