feat(group-treasury): implement propose_withdraw (#122)#209
Open
Kayce10 wants to merge 1 commit into
Open
Conversation
- Add WithdrawProposal, ProposalStatus, ProposalCreatedEvent types to storage.rs - Add ProposalCount and WithdrawProposal(u32) DataKey variants - Implement propose_withdraw: validates member, amount > 0, sufficient balance, increments ProposalCount, stores proposal with Pending status and expires_at, auto-adds proposer approval, emits ProposalCreatedEvent, returns proposal ID - Add get_withdraw_proposal helper - Add 5 tests covering all acceptance criteria
|
@Kayce10 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! 🚀 |
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
propose_withdraw(env, proposer, to, token, amount, ttl_ledgers) → u32onGroupTreasuryContractas specified in issue #122.Changes
storage.rsProposalStatusenum (Pending,Approved,Rejected,Executed)WithdrawProposalstruct withid,proposer,to,token,amount,approvals,status,expires_atProposalCreatedEventstructDataKey::ProposalCountandDataKey::WithdrawProposal(u32)lib.rspropose_withdraw: verifies proposer is a member,amount > 0, sufficient treasury balance; incrementsProposalCount; stores proposal withstatus = Pendingandexpires_at = ledger.sequence() + ttl_ledgers; auto-adds proposer approval (approvals = 1); emitsProposalCreatedEvent; returns new proposal IDget_withdraw_proposalhelperTests
5 new tests covering all acceptance criteria:
test_propose_withdraw_returns_correct_id— returned ID matches stored proposal's idtest_propose_withdraw_ids_increment— IDs auto-increment correctlytest_propose_withdraw_proposal_fields— all proposal fields set correctly, proposer approval auto-addedtest_propose_withdraw_non_member_panics— non-member call panicstest_propose_withdraw_insufficient_funds_panics— insufficient balance panics with "insufficient funds"All 23 tests pass.
Closes #122