Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contracts/predictify-hybrid/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use alloc::format;
use soroban_sdk::{contracttype, Address, Env, Map, String, Symbol, Vec};
// use alloc::string::ToString; // Unused import

use crate::config::{ConfigManager, ConfigUtils, ContractConfig, Environment};
use crate::config::{ConfigManager, ConfigUtils, ConfigValidator, ContractConfig, Environment};
use crate::err::Error;
use crate::events::EventEmitter;
use crate::extensions::ExtensionManager;
Expand Down Expand Up @@ -353,7 +353,7 @@ impl AdminInitializer {
Environment::Mainnet => ConfigManager::get_mainnet_config(env),
Environment::Custom => ConfigManager::get_development_config(env),
};
ConfigManager::validate_config(env, &config)?;
ConfigValidator::validate_contract_config(&config)?;

// Initialize basic admin setup
AdminInitializer::initialize(env, admin)?;
Expand Down
6 changes: 2 additions & 4 deletions contracts/predictify-hybrid/src/bets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2442,10 +2442,8 @@ mod tests {
stats.outcome_totals.set(outcome.clone(), 1);
BetStorage::store_market_bet_stats(&env, &market_id, &stats).unwrap();

assert_eq!(
BetManager::prepare_market_bet_stats(&env, &market_id, &outcome, 1),
Err(Error::Overflow)
);
let result = BetManager::prepare_market_bet_stats(&env, &market_id, &outcome, 1);
assert!(matches!(result, Err(Error::Overflow)), "expected Overflow error, got {:?}", result);

let stored = BetStorage::get_market_bet_stats(&env, &market_id);
assert_eq!(stored.total_amount_locked, i128::MAX);
Expand Down
8 changes: 8 additions & 0 deletions contracts/predictify-hybrid/src/err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ pub enum Error {
NoPendingTreasuryUpdate = 690,
/// A pending treasury update already exists.
PendingTreasuryUpdateExists = 691,
/// Claims are not allowed after 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.
ClaimsRejectedAfterSettlement = 692,
}

// ===== ERROR CATEGORIZATION AND RECOVERY SYSTEM =====
Expand Down Expand Up @@ -742,6 +746,9 @@ impl ErrorHandler {
Error::MarketAlreadyRestored => {
"Market is already restored. Cannot restore a market that is not archived."
}
Error::ClaimsRejectedAfterSettlement => {
"Claims are not allowed after the market has reached a terminal settlement state. Claims are only permitted while the market is in the Resolved state."
}
_ => "An error occurred. Please verify your parameters and try again.",
};
String::from_str(env, msg)
Expand Down Expand Up @@ -877,6 +884,7 @@ impl ErrorHandler {
| Error::CannotRestoreFromState
| Error::MarketAlreadyArchived
| Error::MarketAlreadyRestored => RecoveryStrategy::Abort,
Error::ClaimsRejectedAfterSettlement => RecoveryStrategy::Abort,
Error::FeeExceedsMax => RecoveryStrategy::Retry,
Error::BetExceedsCap => RecoveryStrategy::NoRecovery,
Error::OperationWouldExceedBudget => RecoveryStrategy::NoRecovery,
Expand Down
3 changes: 3 additions & 0 deletions contracts/predictify-hybrid/src/event_topic_compat_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

use soroban_sdk::{symbol_short, testutils::Events, Env, Symbol, Vec};

extern crate alloc;
use alloc::format;

use crate::event_topic_compat::{
EventCompatBridge, EventNonceGuard, EventTopicRegistry, TOPIC_ALIASES, TOPIC_REGISTRY,
};
Expand Down
8 changes: 8 additions & 0 deletions contracts/predictify-hybrid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1822,6 +1822,14 @@ impl PredictifyHybrid {
panic_with_error!(env, Error::MarketNotFound);
});

// Reject claims after terminal settlement state.
// Claims are only permitted while the market is in the Resolved state.
// Terminal states (Closed, Cancelled, Archived, Restored) indicate the market
// has reached finality and no further claim operations are allowed.
if market.state != MarketState::Resolved {
panic_with_error!(env, Error::ClaimsRejectedAfterSettlement);
}

// Check if user has claimed already (redundant safety check; nonce validation should prevent)
if market
.claimed
Expand Down
2 changes: 2 additions & 0 deletions contracts/predictify-hybrid/src/markets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2983,6 +2983,8 @@ impl MarketStateLogic {
};
if allowed {
Ok(())
} else if function == "claim" {
Err(Error::ClaimsRejectedAfterSettlement)
} else {
Err(Error::MarketClosed)
}
Expand Down
Loading
Loading