From c887c71b05df409213e6b3825e320a0e88f2d15c Mon Sep 17 00:00:00 2001 From: fernandomg Date: Thu, 23 Apr 2020 12:45:37 -0300 Subject: [PATCH 1/3] fix: batchRequest params order --- src/routes/safe/store/actions/fetchTransactions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/safe/store/actions/fetchTransactions.js b/src/routes/safe/store/actions/fetchTransactions.js index df08296f..d8808b4e 100644 --- a/src/routes/safe/store/actions/fetchTransactions.js +++ b/src/routes/safe/store/actions/fetchTransactions.js @@ -339,7 +339,7 @@ export const loadSafeTransactions = async (safeAddress: string, getState: GetSta const txsWithData = await batchRequestTxsData(transactions) // In case that the etags don't match, we parse the new transactions and save them to the cache const txsRecord: Array> = await Promise.all( - txsWithData.map(([tx: TxServiceModel, decimals, symbol, name, code]) => + txsWithData.map(([tx: TxServiceModel, decimals, code, symbol, name]) => buildTransactionFrom(safeAddress, tx, knownTokens, decimals, symbol, name, code), ), ) From cdcdd07b234d1af472f97220bc96652bedfbb2ec Mon Sep 17 00:00:00 2001 From: fernandomg Date: Thu, 23 Apr 2020 12:47:19 -0300 Subject: [PATCH 2/3] fix: execute decodeParams for all sendTokenTxs --- .../safe/store/actions/fetchTransactions.js | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/routes/safe/store/actions/fetchTransactions.js b/src/routes/safe/store/actions/fetchTransactions.js index d8808b4e..c9ef0d11 100644 --- a/src/routes/safe/store/actions/fetchTransactions.js +++ b/src/routes/safe/store/actions/fetchTransactions.js @@ -133,24 +133,26 @@ export const buildTransactionFrom = async ( let symbol = txTokenSymbol || 'ETH' let decimals = txTokenDecimals || 18 let decodedParams - if (isSendTokenTx && (txTokenSymbol === null || txTokenDecimals === null)) { - try { - const [tokenSymbol, tokenDecimals] = await Promise.all( - generateBatchRequests({ - abi: ALTERNATIVE_TOKEN_ABI, - address: tx.to, - methods: ['symbol', 'decimals'], - }), - ) + if (isSendTokenTx) { + if (txTokenSymbol === null || txTokenDecimals === null) { + try { + const [tokenSymbol, tokenDecimals] = await Promise.all( + generateBatchRequests({ + abi: ALTERNATIVE_TOKEN_ABI, + address: tx.to, + methods: ['symbol', 'decimals'], + }), + ) - symbol = tokenSymbol - decimals = tokenDecimals - } catch (e) { - // 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 fallback to displaying custom transaction - isSendTokenTx = false - customTx = true + symbol = tokenSymbol + decimals = tokenDecimals + } catch (e) { + // 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 fallback to displaying custom transaction + isSendTokenTx = false + customTx = true + } } const params = web3.eth.abi.decodeParameters(['address', 'uint256'], tx.data.slice(10)) From 55eee73ea735c11a445f3d717797bfd10ca9f94e Mon Sep 17 00:00:00 2001 From: fernandomg Date: Thu, 23 Apr 2020 12:48:19 -0300 Subject: [PATCH 3/3] fix: proper amount display for tx in TxTable --- src/routes/safe/components/Transactions/TxsTable/columns.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/safe/components/Transactions/TxsTable/columns.js b/src/routes/safe/components/Transactions/TxsTable/columns.js index 80b576ad..b0741c5c 100644 --- a/src/routes/safe/components/Transactions/TxsTable/columns.js +++ b/src/routes/safe/components/Transactions/TxsTable/columns.js @@ -46,7 +46,7 @@ export const getTxAmount = (tx: Transaction) => { if (tx.isTokenTransfer && tx.decodedParams) { const tokenDecimals = tx.decimals.toNumber ? tx.decimals.toNumber() : tx.decimals - txAmount = `${new BigNumber(tx.decodedParams.value).div(10 ** tokenDecimals).toString()} ${tx.symbol}` + txAmount = `${new BigNumber(tx.decodedParams.value).div(10 ** tokenDecimals).toFixed()} ${tx.symbol}` } else if (Number(tx.value) > 0) { txAmount = `${fromWei(toBN(tx.value), 'ether')} ${tx.symbol}` }