Skip to content

feat: add batch_approve_milestones to crowdfund_vault#981

Open
Mayorlay wants to merge 2 commits into
Pulsefy:mainfrom
Mayorlay:feat/batch-milestone-decisions
Open

feat: add batch_approve_milestones to crowdfund_vault#981
Mayorlay wants to merge 2 commits into
Pulsefy:mainfrom
Mayorlay:feat/batch-milestone-decisions

Conversation

@Mayorlay

Copy link
Copy Markdown

Adds batch_approve_milestones to the crowdfund_vault Soroban contract, allowing maintainers to
approve multiple project milestones in a single transaction instead of one call per milestone.

Changes

src/errors.rs

  • BatchTooLarge (32) — batch exceeds the 10-item cap
  • EmptyBatch (33) — zero-item batch rejected upfront

src/events.rs

  • BatchMilestoneDecision — input contracttype with project_id + milestone_id
  • BatchMilestoneProcessedEvent — summary event emitted once per batch with approved_count

src/lib.rs

  • batch_approve_milestones(env, admin, decisions) — new admin-only entry point
    • Guards: auth, paused, empty batch, oversized batch (max 10)
    • Per-item: skips missing projects and already-approved milestones silently
    • Emits existing MilestoneApprovedEvent per approved item (identifies each milestone ID)
    • Emits BatchMilestoneProcessedEvent summary with total approved count
    • Returns approved_count: u32

src/test.rs

  • 6 new tests: approves_all, skips_missing_project, skips_already_approved, empty_batch_fails,
    oversized_batch_fails, non_admin_fails, paused_fails

Acceptance criteria

┌──────────────────────────────────────────┬───────────────┐
│ Criterion │ How satisfied │
├──────────────────────────────────────────┼───────────────────────────────────┤
│ Contract accepts a bounded batch payload │ BatchTooLarge guard at > 10 items │
├──────────────────────────────────────────┼────────────────────────────────────────────────┤
│ Per-item outcomes are deterministic │ Missing/already-approved items are always │
│ │ skipped; no partial-fail rollback │
├──────────────────────────────────────────┼────────────────────────────────────────────────┤
├───────────────────────────────────┼──────────────────────────────────────────────────────┤
│ Events identify processed │ MilestoneApprovedEvent { project_id, milestone_id } │
│ milestone IDs │ fired per approved item │
├─────────────────────────────────┼────────────────────────────────────────────────────────┤
│ Guards prevent oversized or │ EmptyBatch, BatchTooLarge, Unauthorized, │
│ inconsistent batches │ ContractPaused all checked before mutations │
└─────────────────────────────────┴────────────────────────────────────────────────────────┘

Testing

All existing tests remain unmodified. Run new tests with:

cargo test -p crowdfund_vault -- batch_approve_milestones

Closes #869

- Accept up to 10 milestone decisions per call (BatchTooLarge/EmptyBatch guards)
- Per-item MilestoneApprovedEvent identifies each processed milestone ID
- Summary BatchMilestoneProcessedEvent emitted once per batch
- Skips missing projects and already-approved milestones deterministically
- Add BatchMilestoneDecision contracttype and BatchMilestoneProcessedEvent
- 6 new tests covering happy path and all guard conditions
@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

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

@Cedarich

Copy link
Copy Markdown
Contributor

@Mayorlay please fix workfow

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.

Contracts: Bulk milestone approval/rejection admin flow

2 participants