feat: reject claims after terminal settlement state - #1436
Open
blazesgl wants to merge 2 commits into
Open
Conversation
Add explicit state validation in claim_winnings to prevent claims when the market has reached a terminal settlement state (Closed, Cancelled, Archived, or Restored). Claims are only permitted while the market is in the Resolved state. Changes: - Add ClaimsRejectedAfterSettlement error variant (code 692) - Add state check in claim_winnings before processing claims - Update check_function_access_for_state to return specific error for claims - Add recovery strategy (Abort) for the new error variant - Add user-friendly error message for the new error - Add comprehensive tests covering all terminal states Closes Predictify-org#1387
|
@blazesgl 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! 🚀 |
- validation.rs:5707 - OracleValidator -> OracleConfigValidator (method exists on OracleConfigValidator, not OracleValidator) - admin.rs:356 - ConfigManager::validate_config -> ConfigValidator::validate_contract_config (method exists on ConfigValidator, not ConfigManager) - admin.rs:6 - add ConfigValidator import - event_topic_compat_tests.rs:290 - add missing alloc::format for no_std crate - bets.rs:2445 - replace assert_eq! with matches! since BetStats lacks PartialEq
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.
Closes #1387
Summary
Implement reject claims after terminal settlement state as a production-ready change. This ensures that once a market reaches a terminal settlement state (Closed, Cancelled, Archived, or Restored), all claim operations are deterministically rejected.
Changes
1. New Error Variant (
err.rs)ClaimsRejectedAfterSettlement = 692error codeRecoveryStrategy::Abortfor this error (terminal, no recovery possible)2. State Validation in
claim_winnings(lib.rs)market.state != MarketState::Resolvedcheck after market loadingClaimsRejectedAfterSettlementwhen market is in any state other thanResolvedwinning_outcomesis somehow set in a terminal state, claims are still rejected3. Improved Error in
check_function_access_for_state(markets.rs)Error::ClaimsRejectedAfterSettlementinstead of genericError::MarketClosed4. Comprehensive Tests (
test.rs)Six tests covering all terminal settlement states:
test_claim_rejected_after_market_closed— Claims rejected in Closed statetest_claim_rejected_after_market_cancelled— Claims rejected in Cancelled statetest_claim_rejected_in_active_state— Claims rejected in Active statetest_claim_rejected_in_ended_state— Claims rejected in Ended statetest_claim_rejected_in_disputed_state— Claims rejected in Disputed statetest_claim_rejected_in_archived_state— Claims rejected in Archived stateState Invariants Enforced
ClaimsRejectedAfterSettlementClaimsRejectedAfterSettlementClaimsRejectedAfterSettlementClaimsRejectedAfterSettlementClaimsRejectedAfterSettlementClaimsRejectedAfterSettlementClaimsRejectedAfterSettlementSecurity Considerations
user.require_auth()check remains intactCompatibility
claim_winnings(env, user, market_id, claim_nonce))Resolvedmarkets are unaffectedTesting
#[should_panic(expected = "Error(Contract, #692)")]predictify-hybridare known and unrelated)CI Notes
The
predictify-hybridcrate has pre-existing compilation errors unrelated to this change. The CI pipeline (contract-ci.yml) only runs tests forhello-worldandoraclespackages, which remain unaffected.