Add automatic removal for missed contributions#149
Open
TUPM96 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds configurable tracking of consecutive missed contributions, enabling admin-recorded misses that can remove defaulting members and adjust round completion behavior.
Changes:
- Add
max_consecutive_missesto groups and track per-round misses viaRoundInfo.misses. - Persist and expose consecutive-miss counters (
MemberMisses) plus admin APIs to configure and record misses. - Add tests for miss configuration, member removal on miss, and miss reset on successful contribution.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| contracts/sorosave/src/types.rs | Extends persisted contract types (SavingsGroup, RoundInfo, DataKey) for miss tracking. |
| contracts/sorosave/src/storage.rs | Adds persistent storage helpers for consecutive miss counters. |
| contracts/sorosave/src/contribution.rs | Implements miss recording/removal logic and resets counters on contribution. |
| contracts/sorosave/src/group.rs | Defaults and admin setter for max_consecutive_misses; initializes misses map in rounds. |
| contracts/sorosave/src/lib.rs | Exposes new contract entrypoints to configure/query/record misses. |
| contracts/sorosave/src/payout.rs | Initializes misses for newly created rounds during payout advancement. |
| contracts/sorosave/src/errors.rs | Adds DeadlineNotReached error for miss-recording gating. |
| contracts/sorosave/src/test.rs | Adds tests covering miss configuration, removal/redistribution, and miss reset behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+65
to
66
| MemberMisses(u64, Address), | ||
| Dispute(u64), |
Comment on lines
28
to
32
| pub total_rounds: u32, | ||
| pub status: GroupStatus, | ||
| pub created_at: u64, | ||
| pub max_consecutive_misses: u32, | ||
| } |
Comment on lines
38
to
44
| pub round_number: u32, | ||
| pub recipient: Address, | ||
| pub contributions: Map<Address, bool>, | ||
| pub misses: Map<Address, bool>, | ||
| pub total_contributed: i128, | ||
| pub is_complete: bool, | ||
| pub deadline: u64, |
Comment on lines
+110
to
+114
| let result = env.storage().persistent().get(&key).unwrap_or(0); | ||
| if result > 0 { | ||
| extend_persistent_ttl(env, &key); | ||
| } | ||
| result |
| admin.require_auth(); | ||
|
|
||
| if max_misses == 0 { | ||
| return Err(ContractError::InvalidAmount); |
Comment on lines
+116
to
+118
| if env.ledger().timestamp() < round_info.deadline { | ||
| return Err(ContractError::DeadlineNotReached); | ||
| } |
| @@ -1,8 +1,8 @@ | |||
| use soroban_sdk::{Address, Env}; | |||
| use soroban_sdk::{Address, Env, Vec}; | |||
|
|
|||
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
max_consecutive_missesto each savings group with admin/protocol-admin configurationValidation
cargo fmt --checkcargo test --package sorosave(12 passed)cargo clippy --package sorosave --all-targets -- -D warningsgit diff --checkFixes #64