Skip to content
Merged
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
2 changes: 1 addition & 1 deletion contracts/predictify-hybrid/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,7 @@ impl MultisigManager {
}

if env.ledger().timestamp() > action.expires_at {
return Err(Error::DisputeVoteExpired);
return Err(Error::DisputeError);
}

if action.approvals.contains(admin) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/predictify-hybrid/src/bets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ impl BetManager {
let winning_outcomes = market.winning_outcomes.ok_or(Error::MarketNotResolved)?;
let mut winning_total = 0;
for outcome in winning_outcomes.iter() {
winning_total += stats.outcome_totals.get(outcome.clone()).unwrap_or(0);
winning_total += stats.outcome_totals.get(outcome).unwrap_or(0);
}
if winning_total == 0 {
return Ok(0);
Expand Down
12 changes: 6 additions & 6 deletions contracts/predictify-hybrid/src/circuit_breaker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl CircuitBreaker {
env.storage()
.instance()
.get(&Symbol::new(env, Self::CONFIG_KEY))
.ok_or(Error::CBNotInitialized)
.ok_or(Error::CBError)
}

/// Update circuit breaker configuration
Expand Down Expand Up @@ -196,7 +196,7 @@ impl CircuitBreaker {
env.storage()
.instance()
.get(&Symbol::new(env, Self::STATE_KEY))
.ok_or(Error::CBNotInitialized)
.ok_or(Error::CBError)
}

/// Update circuit breaker state
Expand All @@ -219,7 +219,7 @@ impl CircuitBreaker {

// Check if already paused
if state.state == BreakerState::Open {
return Err(Error::CBAlreadyOpen);
return Err(Error::CBError);
}

// Update state
Expand Down Expand Up @@ -365,7 +365,7 @@ impl CircuitBreaker {

// Check if circuit breaker is open
if state.state != BreakerState::Open && state.state != BreakerState::HalfOpen {
return Err(Error::CBNotOpen);
return Err(Error::CBError);
}

// Reset state
Expand Down Expand Up @@ -494,7 +494,7 @@ impl CircuitBreaker {
env.storage()
.instance()
.get(&Symbol::new(env, Self::EVENTS_KEY))
.ok_or(Error::CBNotInitialized)
.ok_or(Error::CBError)
}

// ===== STATUS AND MONITORING =====
Expand Down Expand Up @@ -715,7 +715,7 @@ impl CircuitBreakerUtils {
{
// Check if operation should be allowed
if !Self::should_allow_operation(env)? {
return Err(Error::CBOpen);
return Err(Error::CBError);
}

// Execute operation
Expand Down
32 changes: 16 additions & 16 deletions contracts/predictify-hybrid/src/disputes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@ impl DisputeManager {
// Validate timeout hours
if timeout_hours == 0 || timeout_hours > 720 {
// Max 30 days
return Err(Error::InvalidTimeoutHours);
return Err(Error::TimeoutError);
}

// Create timeout configuration
Expand Down Expand Up @@ -1846,7 +1846,7 @@ impl DisputeManager {
// Validate additional hours
if additional_hours == 0 || additional_hours > 168 {
// Max 7 days extension
return Err(Error::InvalidTimeoutHours);
return Err(Error::TimeoutError);
}

// Get current timeout
Expand Down Expand Up @@ -1986,12 +1986,12 @@ impl DisputeValidator {
// Check if voting period is active
let current_time = env.ledger().timestamp();
if current_time < voting_data.voting_start || current_time > voting_data.voting_end {
return Err(Error::DisputeVoteExpired);
return Err(Error::DisputeError);
}

// Check if voting is still active
if !matches!(voting_data.status, DisputeVotingStatus::Active) {
return Err(Error::DisputeVoteDenied);
return Err(Error::DisputeError);
}

Ok(())
Expand All @@ -2007,7 +2007,7 @@ impl DisputeValidator {

for vote in votes.iter() {
if vote.user == *user {
return Err(Error::DisputeAlreadyVoted);
return Err(Error::DisputeError);
}
}

Expand All @@ -2017,7 +2017,7 @@ impl DisputeValidator {
/// Validate voting is completed
pub fn validate_voting_completed(voting_data: &DisputeVoting) -> Result<(), Error> {
if !matches!(voting_data.status, DisputeVotingStatus::Completed) {
return Err(Error::DisputeCondNotMet);
return Err(Error::DisputeError);
}

Ok(())
Expand All @@ -2032,13 +2032,13 @@ impl DisputeValidator {
let voting_data = DisputeUtils::get_dispute_voting(env, dispute_id)?;

if !matches!(voting_data.status, DisputeVotingStatus::Completed) {
return Err(Error::DisputeCondNotMet);
return Err(Error::DisputeError);
}

// Check if fees haven't been distributed yet
let fee_distribution = DisputeUtils::get_dispute_fee_distribution(env, dispute_id)?;
if fee_distribution.fees_distributed {
return Err(Error::DisputeFeeFailed);
return Err(Error::DisputeError);
}

Ok(true)
Expand All @@ -2062,13 +2062,13 @@ impl DisputeValidator {
}

if !has_participated {
return Err(Error::DisputeNoEscalate);
return Err(Error::DisputeError);
}

// Check if escalation already exists
let escalation = DisputeUtils::get_dispute_escalation(env, dispute_id);
if escalation.is_some() {
return Err(Error::DisputeNoEscalate);
return Err(Error::DisputeError);
}

Ok(())
Expand All @@ -2077,12 +2077,12 @@ impl DisputeValidator {
/// Validate dispute timeout parameters
pub fn validate_dispute_timeout_parameters(timeout_hours: u32) -> Result<(), Error> {
if timeout_hours == 0 {
return Err(Error::InvalidTimeoutHours);
return Err(Error::TimeoutError);
}

if timeout_hours > 720 {
// Max 30 days
return Err(Error::InvalidTimeoutHours);
return Err(Error::TimeoutError);
}

Ok(())
Expand All @@ -2093,12 +2093,12 @@ impl DisputeValidator {
additional_hours: u32,
) -> Result<(), Error> {
if additional_hours == 0 {
return Err(Error::InvalidTimeoutHours);
return Err(Error::TimeoutError);
}

if additional_hours > 168 {
// Max 7 days extension
return Err(Error::InvalidTimeoutHours);
return Err(Error::TimeoutError);
}

Ok(())
Expand Down Expand Up @@ -2459,7 +2459,7 @@ impl DisputeUtils {
env.storage()
.persistent()
.get(&key)
.ok_or(Error::TimeoutNotSet)
.ok_or(Error::TimeoutError)
}

/// Check if dispute timeout exists
Expand Down Expand Up @@ -2764,7 +2764,7 @@ pub mod testing {
/// Validate timeout structure
pub fn validate_timeout_structure(timeout: &DisputeTimeout) -> Result<(), Error> {
if timeout.timeout_hours == 0 {
return Err(Error::InvalidTimeoutHours);
return Err(Error::TimeoutError);
}

if timeout.expires_at <= timeout.created_at {
Expand Down
6 changes: 3 additions & 3 deletions contracts/predictify-hybrid/src/edge_cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ impl EdgeCaseHandler {
if config.max_single_user_percentage < 0
|| config.max_single_user_percentage > 10000
{
return Err(Error::ThresholdTooHigh);
return Err(Error::InvalidThreshold);
}
}
EdgeCaseScenario::LowParticipation => {
Expand Down Expand Up @@ -517,7 +517,7 @@ impl EdgeCaseHandler {
/// Validate edge case configuration.
fn validate_edge_case_config(_env: &Env, config: &EdgeCaseConfig) -> Result<(), Error> {
if config.min_total_stake < 0 {
return Err(Error::ThresholdBelowMin);
return Err(Error::InvalidThreshold);
}

if config.min_participation_rate < 0 || config.min_participation_rate > 10000 {
Expand All @@ -533,7 +533,7 @@ impl EdgeCaseHandler {
}

if config.max_single_user_percentage < 0 || config.max_single_user_percentage > 10000 {
return Err(Error::ThresholdTooHigh);
return Err(Error::InvalidThreshold);
}

Ok(())
Expand Down
Loading
Loading