Skip to content

Conversation

@anonfedora
Copy link

Pull Request: Implement Release Funds Logic for Campaign Milestones

🎯 Overview

This PR implements the fund release logic for campaign milestones, enabling the platform to release funds when milestones are approved. This is a core feature of the milestone-based funding system that ensures transparent and controlled fund disbursement.

🔗 Related Issue

Closes #10

✨ Changes Made

Core Implementation

  • Implemented release_funds function in contracts/boundless/src/logic/campaign.rs
    • Retrieves campaign and validates its existence
    • Validates campaign status (prevents release for Failed/Completed campaigns)
    • Locates and validates the target milestone
    • Checks milestone status to ensure it's Approved before release
    • Updates milestone status to Released
    • Persists the updated campaign state

Event System

  • Added FundsReleased event in contracts/boundless/src/datatypes.rs
    • Tracks campaign_id, milestone_id, amount, and releaser address
    • Ensures transparency in fund release operations

Validation Logic

The implementation includes comprehensive validation:

  • ✅ Campaign must exist (CampaignNotFound error)
  • ✅ Campaign cannot be Failed or Completed (InvalidOperation error)
  • ✅ Milestone must exist in campaign (MilestoneNotFound error)
  • ✅ Milestone status checks:
    • Approved → Can be released
    • Released → Already released (error)
    • Rejected → Cannot release (error)
    • Pending → Must be approved first (error)

Test Updates

  • Updated test imports to use correct WASM path (wasm32-unknown-unknown)
  • Ensured consistency across all test modules
  • Added necessary imports for milestone testing (EntityType, Milestone, MilestoneStatus)

📝 Technical Details

State Management

  • Uses persistent storage for campaign data
  • Properly clones and updates milestone vectors to maintain immutability
  • Stores updated campaign state after milestone status change

Error Handling

Follows existing error patterns with clear, actionable errors:

  • BoundlessError::CampaignNotFound
  • BoundlessError::MilestoneNotFound
  • BoundlessError::InvalidOperation

✅ Acceptance Criteria Met

  • release_funds function retrieves and validates campaign and milestone
  • Milestone status correctly updates to Released
  • FundsReleased event emitted with complete details
  • Comprehensive error handling throughout
  • Code follows existing contract patterns and conventions
  • All imports and dependencies properly configured

🧪 Testing Notes

The implementation maintains compatibility with the existing test suite and updates necessary test configurations for proper WASM compilation paths.

🔍 Code Quality

  • Follows Rust best practices and Soroban SDK conventions
  • Maintains consistency with existing codebase patterns
  • Includes detailed inline documentation for complex logic
  • Properly handles all edge cases with appropriate error messages

Ready for review! 🚀

@anonfedora
Copy link
Author

GM ser @0xdevcollins. merge conflicts have been resolved

@anonfedora
Copy link
Author

GM @0xdevcollins
I have fixed formatting issues, but the CI still fails based on formatting check
Screenshot 2025-10-05 at 10 29 10
Screenshot 2025-10-05 at 10 29 30

@0xdevcollins
Copy link
Collaborator

reviewing now

Copy link
Collaborator

@0xdevcollins 0xdevcollins left a comment

Choose a reason for hiding this comment

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

Handle the below @anonfedora
Also write test for your implementation

Comment on lines 11 to 13
soroban_sdk::contractimport!(
file = "../../target/wasm32-unknown-unknown/release/boundless.wasm"
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please revert this to "../../target/wasm32v1-none/release/boundless.wasm"); For Rust v1.84.0 or higher, you need wasm32v1-none target.

Comment on lines 11 to 13
soroban_sdk::contractimport!(
file = "../../target/wasm32-unknown-unknown/release/boundless.wasm"
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please revert this to "../../target/wasm32v1-none/release/boundless.wasm"); For Rust v1.84.0 or higher, you need wasm32v1-none target.

Comment on lines 10 to 12
soroban_sdk::contractimport!(
file = "../../target/wasm32-unknown-unknown/release/boundless.wasm"
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please revert this to "../../target/wasm32v1-none/release/boundless.wasm"); For Rust v1.84.0 or higher, you need wasm32v1-none target.

@anonfedora
Copy link
Author

fixed

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.

Implement Release Funds Logic for Campaign Milestones

2 participants