From 02e09cbc49d395fbd90c9eac8755f66ee037a997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Fri, 13 Dec 2019 17:35:28 +0100 Subject: [PATCH] Fix incomming transactions fetching (#346) --- .../safe/store/actions/fetchTransactions.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/routes/safe/store/actions/fetchTransactions.js b/src/routes/safe/store/actions/fetchTransactions.js index 57253b78..722ecdb9 100644 --- a/src/routes/safe/store/actions/fetchTransactions.js +++ b/src/routes/safe/store/actions/fetchTransactions.js @@ -20,9 +20,6 @@ import { isTokenTransfer } from '~/logic/tokens/utils/tokenHelpers' import { decodeParamsFromSafeMethod } from '~/logic/contracts/methodIds' import { ALTERNATIVE_TOKEN_ABI } from '~/logic/tokens/utils/alternativeAbi' import { ZERO_ADDRESS } from '~/logic/wallets/ethAddresses' -import enqueueSnackbar from '~/logic/notifications/store/actions/enqueueSnackbar' -import { enhanceSnackbarForAction, SUCCESS } from '~/logic/notifications' -import { getIncomingTxAmount } from '~/routes/safe/components/Transactions/TxsTable/columns' let web3 @@ -238,7 +235,7 @@ export const loadSafeTransactions = async (safeAddress: string) => { transactions = transactions.concat(response.data.results) } } catch (err) { - console.error(`Requests for transactions for ${safeAddress} failed with 404`, err) + console.error(`Requests for outgoing transactions for ${safeAddress} failed with 404`, err) } const txsRecord = await Promise.all( @@ -249,9 +246,17 @@ export const loadSafeTransactions = async (safeAddress: string) => { } export const loadSafeIncomingTransactions = async (safeAddress: string) => { - const url = buildIncomingTxServiceUrl(safeAddress) - const response = await axios.get(url) - const incomingTransactions: IncomingTxServiceModel[] = response.data.results + let incomingTransactions: IncomingTxServiceModel[] = [] + try { + const url = buildIncomingTxServiceUrl(safeAddress) + const response = await axios.get(url) + if (response.data.count > 0) { + incomingTransactions = response.data.results + } + } catch (err) { + console.error(`Requests for incomming transactions for ${safeAddress} failed with 404`, err) + } + const incomingTxsRecord = await Promise.all(incomingTransactions.map(buildIncomingTransactionFrom)) return Map().set(safeAddress, List(incomingTxsRecord))