Issue 123#205
Open
samieazubike wants to merge 2 commits into
Open
Conversation
…and implement related tests
… and rejection events
|
@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! 🚀 |
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.
Description
Implements
approve_withdrawandreject_withdrawonGroupTreasuryContract, adding the multisig voting layer (issue #123).Contract changes
storage.rs:DataKey::Vote(u32, Address)— per-voter record keyed by(proposal_id, voter), the mechanism that blocks double-voting (theWithdrawProposalstruct only carriedapprovals/rejectionscounters).WithdrawVoteCastEvent,ProposalApprovedEvent,ProposalRejectedEvent.lib.rs:approve_withdraw(env, approver, proposal_id)— records the vote, incrementsapprovals, and transitions the proposal toPassed(approved) + emitsProposalApprovedEventonceapprovals >= threshold.reject_withdraw(env, rejecter, proposal_id)— incrementsrejections, and transitions toRejected+ emitsProposalRejectedEventonce 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 → ensureActive, not expired, not already voted.Notes
Active, Approved =Passed(no enum churn, so Implementexecute_withdraw#124execute_withdrawcan build onPassed → Executed).propose_withdraw(Implementpropose_withdrawon Group Treasury contract #122) is not implemented yet, so tests seed proposals directly into storage via anenv.as_contracthelper.Security
require_authon 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 underoverflow-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 failedcargo clippyclean on new code;cargo build --release(no_std wasm) compiles.Closes #123
Type of change
Checklist