Skip to content

feat(group-treasury): implement propose_withdraw (#122)#209

Open
Kayce10 wants to merge 1 commit into
codebestia:mainfrom
Kayce10:feature/122-propose-withdraw
Open

feat(group-treasury): implement propose_withdraw (#122)#209
Kayce10 wants to merge 1 commit into
codebestia:mainfrom
Kayce10:feature/122-propose-withdraw

Conversation

@Kayce10

@Kayce10 Kayce10 commented Jun 25, 2026

Copy link
Copy Markdown

Summary

Implements propose_withdraw(env, proposer, to, token, amount, ttl_ledgers) → u32 on GroupTreasuryContract as specified in issue #122.

Changes

storage.rs

  • Added ProposalStatus enum (Pending, Approved, Rejected, Executed)
  • Added WithdrawProposal struct with id, proposer, to, token, amount, approvals, status, expires_at
  • Added ProposalCreatedEvent struct
  • Added DataKey::ProposalCount and DataKey::WithdrawProposal(u32)

lib.rs

  • Implemented propose_withdraw: verifies proposer is a member, amount > 0, sufficient treasury balance; increments ProposalCount; stores proposal with status = Pending and expires_at = ledger.sequence() + ttl_ledgers; auto-adds proposer approval (approvals = 1); emits ProposalCreatedEvent; returns new proposal ID
  • Added get_withdraw_proposal helper

Tests

5 new tests covering all acceptance criteria:

  • test_propose_withdraw_returns_correct_id — returned ID matches stored proposal's id
  • test_propose_withdraw_ids_increment — IDs auto-increment correctly
  • test_propose_withdraw_proposal_fields — all proposal fields set correctly, proposer approval auto-added
  • test_propose_withdraw_non_member_panics — non-member call panics
  • test_propose_withdraw_insufficient_funds_panics — insufficient balance panics with "insufficient funds"

All 23 tests pass.

Closes #122

- 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
@drips-wave

drips-wave Bot commented Jun 25, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

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.

Implement propose_withdraw on Group Treasury contract

1 participant