Skip to content

feat: Allow campaign owners to cancel before funding completes#12

Merged
0xdevcollins merged 2 commits intomainfrom
feat/owner-cancel-campaign
Apr 4, 2026
Merged

feat: Allow campaign owners to cancel before funding completes#12
0xdevcollins merged 2 commits intomainfrom
feat/owner-cancel-campaign

Conversation

@0xdevcollins
Copy link
Copy Markdown
Contributor

Summary

  • Adds owner_cancel_campaign(campaign_id) — owner-authed cancel for Draft, Submitted, or Campaigning states
  • Returns InvalidState if campaign is Funded or beyond (milestones in progress)
  • Sets refund_progress = 0 so existing pledges are refundable via process_refund_batch()
  • Clears vote_session_id if cancelling from Submitted
  • Emits CampaignCancelledByOwner event (distinct from admin's CampaignCancelled)

Closes #6

Test plan

  • test_owner_cancel_in_draft — owner cancels in Draft status
  • test_owner_cancel_in_campaigning_with_refunds — owner cancels with existing pledges → refunds work
  • test_owner_cancel_after_funded_fails — cannot cancel after campaign is Funded
  • All 127 tests pass (22 unit + 57 integration + 48 other crates)

🤖 Generated with Claude Code

Creators had no way to cancel their own campaigns — only admin could.
Adds owner_cancel_campaign() allowing owners to cancel in Draft,
Submitted, or Campaigning states. Existing pledges become refundable
via process_refund_batch(). Cannot cancel after Funded.

Closes #6

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 4, 2026

Warning

Rate limit exceeded

@0xdevcollins has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minutes and 7 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 1 minutes and 7 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 30580ff2-20d4-41c2-8f3c-d45c8fffa7cc

📥 Commits

Reviewing files that changed from the base of the PR and between 2f7dcda and c1eed37.

📒 Files selected for processing (6)
  • contracts/crowdfund_registry/src/contract.rs
  • contracts/crowdfund_registry/src/events/mod.rs
  • contracts/crowdfund_registry/src/tests/mod.rs
  • contracts/crowdfund_registry/test_snapshots/tests/test_owner_cancel_after_funded_fails.1.json
  • contracts/crowdfund_registry/test_snapshots/tests/test_owner_cancel_in_campaigning_with_refunds.1.json
  • contracts/crowdfund_registry/test_snapshots/tests/test_owner_cancel_in_draft.1.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/owner-cancel-campaign

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@0xdevcollins 0xdevcollins merged commit bddf586 into main Apr 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow campaign owner to cancel pre-funded campaigns

1 participant