fix bug related to missing pledges on first time load
This commit is contained in:
parent
c5cd136e17
commit
c918c456ed
|
@ -57,7 +57,7 @@ function SimpleCard(props) {
|
|||
<Typography variant="h5" className={classes.cardTitle}>
|
||||
{title}
|
||||
</Typography>
|
||||
{!!transfers &&
|
||||
{!!transfers && !!pledges.length &&
|
||||
Object.entries(getDepositWithdrawTotals({ transfers, pledges, vaultEvents }))
|
||||
.map(token => {
|
||||
const [name, amounts] = token
|
||||
|
|
|
@ -42,14 +42,22 @@ export const getPledgesWaitingCommit = createSelector(
|
|||
|
||||
const formatAndSumDepositWithdraws = (deposits, pledges, withdraws) => {
|
||||
const tokens = {}
|
||||
let incomplete = false
|
||||
deposits.forEach(deposit => {
|
||||
const { amount, to } = deposit.returnValues
|
||||
const { token } = pledges.find(p => Number(p.pledgeId) === Number(to))
|
||||
const pledge = pledges.find(p => Number(p.pledgeId) === Number(to))
|
||||
if (!pledge) {
|
||||
incomplete = true
|
||||
return
|
||||
}
|
||||
const { token } = pledge
|
||||
const tokenName = getTokenLabel(token)
|
||||
if (tokens[tokenName]) tokens[tokenName]['deposits'] = BigInt(tokens[tokenName]['deposits']) + BigInt(amount)
|
||||
else tokens[tokenName] = { 'deposits': BigInt(amount) }
|
||||
})
|
||||
|
||||
if (incomplete) return {}
|
||||
|
||||
withdraws
|
||||
.filter(w => !isNaN(Number(w.returnValues.ref.slice(2))))
|
||||
.forEach(withdraw => {
|
||||
|
|
Loading…
Reference in New Issue