Skip to content

Feat/status#189

Merged
ayshadogo merged 3 commits into
Dfunder:mainfrom
nafsonig:feat/status
May 29, 2026
Merged

Feat/status#189
ayshadogo merged 3 commits into
Dfunder:mainfrom
nafsonig:feat/status

Conversation

@nafsonig
Copy link
Copy Markdown
Contributor

I've successfully implemented explicit status enums and state transition validation for the campaign contract. Here's what was done:

1. Updated Status Enums in types.rs

CampaignStatus - 4 states with explicit transitions:

  • Active - Campaign accepting donations
  • GoalReached - Goal reached, still accepting donations until deadline
  • Ended - Deadline passed or campaign concluded
  • Cancelled - Campaign cancelled by creator (terminal state)

MilestoneStatus - 3 states with explicit transitions:

  • Locked - Milestone condition not yet met
  • Unlocked - Target amount reached, awaiting release
  • Released - Funds released to beneficiary (terminal state)

2. Added Comprehensive Error Codes in types.rs

New error variants for state transition validation:

  • InvalidCampaignTransition - Campaign status transition not allowed
  • InvalidMilestoneTransition - Milestone status transition not allowed
  • CampaignNotActive - Campaign must be Active to accept donations
  • CampaignEnded - Campaign end_time has passed
  • GoalNotReached - Cannot transition to GoalReached before reaching goal

3. Implemented State Transition Validators in lib.rs

validate_campaign_transition() enforces:

Active → GoalReached, Ended, or Cancelled ✓
GoalReached → Ended or Cancelled ✓
Ended → Cancelled only ✓
Cancelled → terminal (no transitions) ✓

validate_milestone_transition() enforces:

Locked → Unlocked or Released ✓
Unlocked → Released only ✓
Released → terminal (no transitions) ✓
Prevents backwards transitions (Unlocked → Locked) ✓

4. Enhanced Error Handling

  • panic_with_error() function handles all 10+ error codes with descriptive symbols
  • Each invalid transition panics with specific, auditable error message
  • Transitions are explicit and auditable on-chain

All status enums implement #[contracttype] for Soroban serialization, and invalid transitions will panic with descriptive error codes as required.

Made changes.

closes #171

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 28, 2026

@nafsonig Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Copy link
Copy Markdown
Contributor

@ayshadogo ayshadogo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution

@ayshadogo ayshadogo merged commit 3fbbcb2 into Dfunder:main May 29, 2026
1 check failed
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.

Define CampaignStatus and MilestoneStatus enums

2 participants