Refactor/issue 54 cancel index#329
Merged
hman38705 merged 4 commits intosolutions-plug:mainfrom Mar 27, 2026
Merged
Conversation
Closes solutions-plug#47 - Remove require_admin check from prune_market in markets.rs - Any user can now prune a resolved market after the 30-day grace period - Existing guards (Resolved status, grace period, all rewards claimed) remain intact - Add test_permissionless_prune_by_non_admin to verify non-admin can prune a 31-day-old resolved market
Closes solutions-plug#51 - In cancellation::withdraw_refund, detect when caller is the market creator - Transfer creation_deposit back and zero it on the market struct (prevents double-claim) - Emit deposit_refunded event for indexers - Creator's bet stakes (if any) are still refunded via the normal bettor path - Add test_creator_deposit_refunded_on_cancellation covering creator refund, simultaneous bettor refund, and idempotency of a second creator call
Closes solutions-plug#52 - Replace (cancel_votes * 10000) / total_votes with checked_mul/checked_div - Overflow maps to InsufficientVotingWeight (safe conservative fallback) - Add test_cancel_vote_threshold_no_overflow using i128::MAX / 5000 weight
… literal Closes solutions-plug#54 - Add pub const CANCEL_OUTCOME_INDEX: u32 = u32::MAX to types.rs - Import and use it in cancellation.rs (get_tally call) - Replace raw u32::MAX in test_cancellation.rs with crate::types::CANCEL_OUTCOME_INDEX
|
@Grace-CODE-D 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.
Title: refactor: define and use CANCEL_OUTCOME_INDEX constant instead of raw literal
Body:
Closes #161
Summary
u32::MAX was used as an undocumented sentinel for cancellation votes in two places. This replaces it with a named
constant, making the intent explicit and the value centrally maintainable.
Changes
types.rs
rust
/// Issue #54: Reserved sentinel index for cancellation votes, distinct from any valid outcome index.
pub const CANCEL_OUTCOME_INDEX: u32 = u32::MAX;
cancellation.rs
test_cancellation.rs
No behaviour change
The constant value is identical to the previous literal — this is a pure readability/maintainability refactor.