Skip to content

feat: Escrow Milestone Tracking and State Management#65

Merged
soomtochukwu merged 3 commits into
DXmakers:mainfrom
Cyberking99:feature/milestone-tracking-state-management
Mar 29, 2026
Merged

feat: Escrow Milestone Tracking and State Management#65
soomtochukwu merged 3 commits into
DXmakers:mainfrom
Cyberking99:feature/milestone-tracking-state-management

Conversation

@Cyberking99
Copy link
Copy Markdown
Contributor

This PR introduces robust internal state management for the escrow contract, supporting fragmented payout structures through multiple sequentially unlockable milestones with specific amounts.

Key Changes

  • Enhanced Storage Schema:
    • Introduced Milestone and MilestoneStatus (Pending, Released) structures.
    • Upgraded EscrowJob to use a Vec<Milestone>, allowing for flexible project configurations where each milestone can have a unique payout amount.
  • Improved Lifecycle Management:
    • create_job: New entry point to initialize a job in the Setup phase.
    • add_milestone: Allows clients to define specific milestone amounts (flat amounts) during setup.
    • Validated deposit: Ensures the sum of all milestones matches the total deposit exactly before funding the project.
  • State Machine Refinement:
    • Meticulously tracked transitions: Setup -> Funded -> WorkInProgress -> Completed (or Disputed).
    • Added WorkInProgress state to better reflect the job's lifecycle after the first milestone release.
  • Granular Retrieval:
    • Added a public get_milestone_status function to retrieve the current status of all milestones for any given Job ID.
  • Updated Test Suite:
    • Overhauled existing tests to align with the new API.
    • Added test_variable_milestone_amounts to verify complex project structures (e.g., a 20%, 30%, 50% split).

Verification Results

All tests passed successfully (cargo test):

  • test_happy_path_lifecycle
  • test_variable_milestone_amounts
  • test_dispute_50_50_split
  • test_refund
  • test_exhaustive_release_funds_path
  • Security/Edge cases: test_double_init, test_deposit_with_wrong_total_panics, test_unauthorized_release, test_raise_dispute_by_client_locks_funds.

Closes #14

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Mar 29, 2026

@Cyberking99 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

@Cyberking99
Copy link
Copy Markdown
Contributor Author

Kindly review @soomtochukwu

@soomtochukwu soomtochukwu merged commit 64ffa9d into DXmakers:main Mar 29, 2026
8 checks 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.

Issue 3: Escrow Contract - Milestone Tracking and State Management

2 participants