mirror of
https://github.com/status-im/safe-react.git
synced 2025-01-23 08:08:56 +00:00
WA-232 Do not update redux if error is raised fetching balance or safe information
This commit is contained in:
parent
afe7d4fc2f
commit
d7193dcc9a
@ -55,15 +55,23 @@ export const fetchBalances = (safeAddress: string) => async (dispatch: ReduxDisp
|
||||
}
|
||||
|
||||
const json = await response.json()
|
||||
return Promise.all(json.map(async (item: BalanceProps) => {
|
||||
const funds = await calculateBalanceOf(item.address, safeAddress, item.decimals)
|
||||
return makeBalance({ ...item, funds })
|
||||
})).then((balancesRecords) => {
|
||||
|
||||
try {
|
||||
const balancesRecords = await Promise.all(json.map(async (item: BalanceProps) => {
|
||||
const funds = await calculateBalanceOf(item.address, safeAddress, item.decimals)
|
||||
return makeBalance({ ...item, funds })
|
||||
}))
|
||||
|
||||
const balances: Map<string, Balance> = Map().withMutations((map) => {
|
||||
balancesRecords.forEach(record => map.set(record.get('symbol'), record))
|
||||
map.set('ETH', ethBalance)
|
||||
})
|
||||
|
||||
return dispatch(addBalances(safeAddress, balances))
|
||||
})
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line
|
||||
console.log("Error fetching token balances...")
|
||||
|
||||
return Promise.resolve()
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,14 @@ export const buildSafe = async (storedSafe: Object) => {
|
||||
}
|
||||
|
||||
export default (safe: Safe) => async (dispatch: ReduxDispatch<GlobalState>) => {
|
||||
const safeRecord = await buildSafe(safe.toJSON())
|
||||
try {
|
||||
const safeRecord = await buildSafe(safe.toJSON())
|
||||
|
||||
return dispatch(updateSafe(safeRecord))
|
||||
return dispatch(updateSafe(safeRecord))
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line
|
||||
console.log("Error while updating safe information")
|
||||
|
||||
return Promise.resolve()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user