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}>
|
<Typography variant="h5" className={classes.cardTitle}>
|
||||||
{title}
|
{title}
|
||||||
</Typography>
|
</Typography>
|
||||||
{!!transfers &&
|
{!!transfers && !!pledges.length &&
|
||||||
Object.entries(getDepositWithdrawTotals({ transfers, pledges, vaultEvents }))
|
Object.entries(getDepositWithdrawTotals({ transfers, pledges, vaultEvents }))
|
||||||
.map(token => {
|
.map(token => {
|
||||||
const [name, amounts] = token
|
const [name, amounts] = token
|
||||||
|
|
|
@ -42,14 +42,22 @@ export const getPledgesWaitingCommit = createSelector(
|
||||||
|
|
||||||
const formatAndSumDepositWithdraws = (deposits, pledges, withdraws) => {
|
const formatAndSumDepositWithdraws = (deposits, pledges, withdraws) => {
|
||||||
const tokens = {}
|
const tokens = {}
|
||||||
|
let incomplete = false
|
||||||
deposits.forEach(deposit => {
|
deposits.forEach(deposit => {
|
||||||
const { amount, to } = deposit.returnValues
|
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)
|
const tokenName = getTokenLabel(token)
|
||||||
if (tokens[tokenName]) tokens[tokenName]['deposits'] = BigInt(tokens[tokenName]['deposits']) + BigInt(amount)
|
if (tokens[tokenName]) tokens[tokenName]['deposits'] = BigInt(tokens[tokenName]['deposits']) + BigInt(amount)
|
||||||
else tokens[tokenName] = { 'deposits': BigInt(amount) }
|
else tokens[tokenName] = { 'deposits': BigInt(amount) }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (incomplete) return {}
|
||||||
|
|
||||||
withdraws
|
withdraws
|
||||||
.filter(w => !isNaN(Number(w.returnValues.ref.slice(2))))
|
.filter(w => !isNaN(Number(w.returnValues.ref.slice(2))))
|
||||||
.forEach(withdraw => {
|
.forEach(withdraw => {
|
||||||
|
|
Loading…
Reference in New Issue