Skip to content

Treasury grants milestones - #1263

Open
carterdev-001 wants to merge 12 commits into
accesslayerorg:mainfrom
carterdev-001:treasury-grants-milestones
Open

carterdev-001 wants to merge 12 commits into
accesslayerorg:mainfrom
carterdev-001:treasury-grants-milestones

Conversation

@carterdev-001

Copy link
Copy Markdown

Summary

Implements treasury grants with milestone-based releases as specified in issue #1254.

Changes

  • create_grant(admin, recipient, total, milestones, require_sequential): Creates a new grant with milestones. Validates that sum of milestone amounts equals grant total. Funds are reserved from treasury balance at creation.

  • submit_milestone(recipient, grant_id, index, evidence_hash): Allows recipient to submit evidence for a milestone. Supports optional sequential submission enforcement.

  • approve_milestone(reviewer, grant_id, index): Releases milestone funds to recipient. Requires configured reviewer role.

  • reject_milestone(reviewer, grant_id, index, reason_hash): Marks milestone as rejected with reason. Milestone can be resubmitted.

  • cancel_grant(admin, grant_id): Cancels grant and returns unreleased funds to treasury.

  • grant_status(grant_id): View function returning grant details including all milestone states and released total.

  • Events: grant_created, milestone_submitted, milestone_approved, milestone_rejected, grant_cancelled

  • Tests: Comprehensive unit tests covering approval, rejection, cancellation, sequential/non-sequential submission, and edge cases.

Closes #1254

carterdev-001 and others added 12 commits November 22, 2026 21:25
- Add create_grant(admin, recipient, total, milestones, require_sequential) storing milestone amounts and description hashes
- Add submit_milestone(recipient, grant_id, index, evidence_hash) marking a milestone as submitted
- Add approve_milestone(reviewer, grant_id, index) releasing the milestone amount to the recipient with reviewer role requirement
- Add reject_milestone(reviewer, grant_id, index, reason_hash) returning milestone to pending with reason
- Add cancel_grant(admin, grant_id) returning unreleased funds to treasury
- Add grant_status(grant_id) view listing milestone states and released total
- Emit grant_created, milestone_submitted, milestone_approved, milestone_rejected, and grant_cancelled events
- Add sequential milestone submission option
- Add comprehensive unit tests covering approval, rejection, cancellation, and sequential submission

Closes accesslayerorg#1254
- Add panic_with_error import
- Fix usize/u32 conversions for soroban_sdk Vec indexing
- Fix BytesN creation using from_array instead of default()
- Add Events trait import for env.events().all()
- Add lifetime to TreasuryContractClient in test helper
- Fix move errors by cloning values before moving
- Fix events test to properly access tuple fields from env.events().all()
- Fix unused variable warnings
- Add Val import for events test
- Remove unused Val import, add IntoVal import for .into_val() calls
- Fix test_non_sequential_submission: use reviewer instead of _reviewer
- Fix test_submit_milestone_wrong_recipient: use _reviewer since unused
- Use .into_val(&env) to convert topic Val to Symbol/u32 before comparison
- Follow pattern used in other contracts (launch-auction, creator-keys)
- e.1 is already Vec<soroban_sdk::Val>, no conversion needed
- Add env.mock_all_auths() before calling set_reviewer_role to satisfy admin.require_auth()
…ror assertions

- Replace #[should_panic] with try_ method calls checking Err(Ok(TreasuryError::Variant))
- Add create_test_env_empty() for tests needing clean treasury state
- Fix test_events_emitted: use grant with unreleased funds for cancellation test
- Fix test_original_treasury_functions_still_work: use empty env to avoid initial 10000 balance
- Use Error::from(TreasuryError::Variant) for try_ assertions
- Functions using panic_with_error! return Result<Result<T, ConversionError>, Result<Error, InvokeError>>
- Contract errors are converted to soroban_sdk::Error via From trait
- test_events_emitted: Re-fund treasury before creating second grant (first grant depleted balance)
- test_original_treasury_functions_still_work: Use create_test_env with funded treasury instead of empty env
- Removed unused create_test_env_empty helper
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Chucks1093

Copy link
Copy Markdown
Member

✅ PR Ready for Review

Due to a recent malware incident affecting our repositories, all PRs are required to pass automated security checks before being reviewed for merging.

This PR has passed all automated checks:

  • ✅ Security scan — no malicious code detected
  • ✅ No merge conflicts
  • ✅ CI checks passed

Next step: Please share this PR link in our Telegram group so a maintainer can review and merge it: https://t.me/c/accesslayerorg/8514

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.

Build treasury grants contract with milestone-based releases

3 participants