Feat/status#189
Merged
Merged
Conversation
|
@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! 🚀 |
ayshadogo
approved these changes
May 29, 2026
Contributor
ayshadogo
left a comment
There was a problem hiding this comment.
Thank you for the contribution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 donationsGoalReached- Goal reached, still accepting donations until deadlineEnded- Deadline passed or campaign concludedCancelled- Campaign cancelled by creator (terminal state)MilestoneStatus - 3 states with explicit transitions:
Locked- Milestone condition not yet metUnlocked- Target amount reached, awaiting releaseReleased- 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 allowedInvalidMilestoneTransition- Milestone status transition not allowedCampaignNotActive- Campaign must be Active to accept donationsCampaignEnded- Campaign end_time has passedGoalNotReached- Cannot transition to GoalReached before reaching goal3. Implemented State Transition Validators in lib.rs
validate_campaign_transition()enforces:validate_milestone_transition()enforces:4. Enhanced Error Handling
panic_with_error()function handles all 10+ error codes with descriptive symbolsAll status enums implement
#[contracttype]for Soroban serialization, and invalid transitions will panic with descriptive error codes as required.Made changes.
closes #171