Skip to content

Commit

Permalink
fix claimrewardsamount reducer. get all (#548)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bitcoinera authored Mar 31, 2020
1 parent 509ab7d commit 64ea9c6
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions lib/reducers/cosmosV2-reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,25 @@ function claimRewardsAmountReducer(transaction, reducers, stakingDenom) {
}
]
}
return reducers.rewardCoinReducer(
transaction.events
.find(event => event.type === `transfer`)
.attributes.find(attribute => attribute.key === `amount`).value,
stakingDenom
const allClaimedRewards = transaction.events
.find(event => event.type === `transfer`)
.attributes.filter(attribute => attribute.key === `amount`)
.map(amount => amount.value)
.map(rewardValue => reducers.rewardCoinReducer(rewardValue))
const aggregatedClaimRewardsObject = allClaimedRewards.reduce(
(all, rewards) => {
rewards.forEach(reward => {
all = {
...all,
[reward.denom]: reward.amount.plus(all[reward.denom] || 0)
}
})
return all
},
{}
)
const claimedRewardsDenomArray = Object.entries(aggregatedClaimRewardsObject)
return claimedRewardsDenomArray.map(([denom, amount]) => ({ denom, amount }))
}

function submitProposalDetailsReducer(message, reducers) {
Expand Down

0 comments on commit 64ea9c6

Please sign in to comment.