You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[MEDIUM] — recalculateCampaignStats never decrements raisedAmount after a refund, permanently inflating the campaign total #8
Severity: Medium Type: Bug Scope: Campaigns, Donations Labels:bug, help wanted, Official Campaign
Description
CampaignsService.recalculateCampaignStats (src/campaigns/campaigns.service.ts, lines ~270–286) sets raisedAmount = sum(donations where status = 'CONFIRMED'). It is invoked from createDonation after each successful confirmation.
The Donation.status enum supports REFUNDED (prisma/schema.prisma); when a refund flow lands, the underlying row flips from CONFIRMED to REFUNDED and is excluded from the aggregation. However, no caller ever re-runs recalculateCampaignStats on refund, so Campaign.raisedAmount continues to include the refunded value. Sequential refunds will monotonically grow the discrepancy between on-chain balance and recorded total.
Recommendation
After any state transition that flips a donation out of CONFIRMED (REFUNDED, FAILED), re-call recalculateCampaignStats from the same code path.
Add a Prisma $transaction that updates the status and the campaign aggregate atomically.
Add a regression test that issues a refund and asserts Campaign.raisedAmount decreases by exactly the refunded amount.
Hi maintainer, I would love to work on this issue. I have studied the details of the issue description and I understood the requirements. I shall deliver with qualitative feedback and promptly.
🏆 @iyanumajekodunmi756: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (681 total points). Track your full progress on GrantFox.
Activity
iyanumajekodunmi756 commentedon Jun 20, 2026
Hi maintainer, I would love to work on this issue. I have studied the details of the issue description and I understood the requirements. I shall deliver with qualitative feedback and promptly.
grantfox-oss commentedon Jun 20, 2026
🦊 GrantFox — @iyanumajekodunmi756 has been assigned to this issue as part of the Official Campaign campaign!
Next steps:
Closes #8)Good luck! Track your progress on GrantFox.
fix: recalculateCampaignStats now decrements raisedAmount after refund (
grantfox-oss commentedon Jun 23, 2026
🎉 This issue has been marked as completed on GrantFox as part of the Official Campaign campaign!
@iyanumajekodunmi756's PR #37 was approved and merged by @Alqku.
🏆 @iyanumajekodunmi756: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (681 total points). Track your full progress on GrantFox.
👏 Great work, @iyanumajekodunmi756! Keep contributing to OrbitChainLabs.