Repository navigation
Treasury grants milestones - #1263
Open
carterdev-001 wants to merge 12 commits into
Open
carterdev-001 wants to merge 12 commits into
carterdev-001 wants to merge 12 commits into
Conversation
- 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>
Member
✅ PR Ready for ReviewDue 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:
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 |
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.
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