Skip to content

Issue 123#205

Open
samieazubike wants to merge 2 commits into
codebestia:mainfrom
samieazubike:issue-123
Open

Issue 123#205
samieazubike wants to merge 2 commits into
codebestia:mainfrom
samieazubike:issue-123

Conversation

@samieazubike

Copy link
Copy Markdown

Description

Implements approve_withdraw and reject_withdraw on GroupTreasuryContract, adding the multisig voting layer (issue #123).

Contract changes

  • storage.rs:
    • New DataKey::Vote(u32, Address) — per-voter record keyed by (proposal_id, voter), the mechanism that blocks double-voting (the WithdrawProposal struct only carried approvals/rejections counters).
    • New events: WithdrawVoteCastEvent, ProposalApprovedEvent, ProposalRejectedEvent.
  • lib.rs:
    • approve_withdraw(env, approver, proposal_id) — records the vote, increments approvals, and transitions the proposal to Passed (approved) + emits ProposalApprovedEvent once approvals >= threshold.
    • reject_withdraw(env, rejecter, proposal_id) — increments rejections, and transitions to Rejected + emits ProposalRejectedEvent once the blocking minority (members - threshold + 1) is reached.
    • get_proposal(env, proposal_id) — read-only view of a proposal.
    • require_votable(...) — shared guard: require_auth → member check → load proposal → ensure Active, not expired, not already voted.

Notes

Security

  • require_auth on every vote; member-only voting; one vote per address per proposal (dedicated storage key, not a counter re-tally); no voting on non-pending or expired proposals; counters bounded by member count under overflow-checks = true. No token movement occurs here, so there is no reentrancy surface.

Tests — 11 new tests covering every acceptance criterion plus edges (threshold transition, below-threshold, double-vote panic, vote-switch panic, non-member panic, non-pending panic, expired panic, blocking-minority rejection, unknown-proposal panic, missing-auth panic).

  • cargo test -p group_treasury → 31 passed, 0 failed
  • cargo clippy clean on new code; cargo build --release (no_std wasm) compiles.

Closes #123

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Other

Checklist

  • I have read the contributing guidelines
  • I have tested my changes locally
  • My code follows the project's coding standards

@drips-wave

drips-wave Bot commented Jun 25, 2026

Copy link
Copy Markdown

@samieazubike 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 approve_withdraw and reject_withdraw

1 participant