Skip to content

feat: implement propose_withdraw on GroupTreasuryContract (#122)#274

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

feat: implement propose_withdraw on GroupTreasuryContract (#122)#274
Kayce10 wants to merge 1 commit into
codebestia:mainfrom
Kayce10:feature/122-propose-withdraw

Conversation

@Kayce10

@Kayce10 Kayce10 commented Jun 28, 2026

Copy link
Copy Markdown

Closes #122


Summary

Implements propose_withdraw on GroupTreasuryContract as specified in issue #122.

Changes

  • storage.rs: Added WithdrawProposalStatus, WithdrawProposal, ProposalCreatedEvent types and DataKey::ProposalCount / DataKey::WithdrawProposal(u32) variants
  • lib.rs: Implemented propose_withdraw(env, proposer, to, token, amount, ttl_ledgers) -> u32
    • Verifies proposer is a member (panics otherwise)
    • Validates amount > 0
    • Checks sufficient treasury balance (panics "insufficient funds")
    • Increments ProposalCount, stores WithdrawProposal with Pending status
    • Sets expires_at = ledger().sequence() + ttl_ledgers
    • Auto-adds proposer's approval
    • Emits ProposalCreatedEvent
    • Returns new proposal ID
    • Added get_withdraw_proposal read helper
  • test.rs: Added tests covering all acceptance criteria

Acceptance Criteria

  • Non-member call panics
  • Insufficient treasury balance panics with "insufficient funds"
  • Returned ID matches the stored proposal's id

…#122)

- Add ProposalCreatedEvent to storage.rs
- Implement propose_withdraw(env, proposer, to, token, amount, ttl_ledgers) -> u32
  - Verifies proposer is a member (panics 'proposer is not a member')
  - Validates amount > 0
  - Checks sufficient treasury balance (panics 'insufficient funds')
  - Reads ProposalCount for new ID, increments it
  - Creates WithdrawProposal with Active status, approvals=1 (proposer auto-approved)
  - Records proposer's Vote entry to prevent double-voting
  - Sets expires_at = ledger().timestamp() + ttl_ledgers * 5
  - Emits ProposalCreatedEvent
  - Returns new proposal ID
- Add tests: non-member panic, insufficient funds, ID matches stored proposal,
  auto-approval, ID increments
@Kayce10 Kayce10 force-pushed the feature/122-propose-withdraw branch from 389374c to bb44df4 Compare June 28, 2026 21:54
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