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
12 changes: 6 additions & 6 deletions contracts/predictify-hybrid/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl AdminInitializer {
admin.clone(),
Map::new(env),
None,
);;
);

Ok(())
}
Expand Down Expand Up @@ -637,7 +637,7 @@ impl ContractPauseManager {
admin.clone(),
Map::new(env),
None,
);;
);
Ok(())
}

Expand All @@ -654,7 +654,7 @@ impl ContractPauseManager {
admin.clone(),
Map::new(env),
None,
);;
);
Ok(())
}

Expand Down Expand Up @@ -688,7 +688,7 @@ impl ContractPauseManager {
current_admin.clone(),
Map::new(env),
None,
);;
);
Ok(())
}
}
Expand Down Expand Up @@ -1014,7 +1014,7 @@ impl AdminRoleManager {
assigned_by.clone(),
Map::new(env),
None,
);;
);

Ok(())
}
Expand Down Expand Up @@ -2345,7 +2345,7 @@ impl AdminFunctions {
AdminAccessControl::validate_admin_for_action(env, admin, "update_fees")?;

// Queue fee configuration with governance time-lock
FeeManager::update_fee_config(env, admin.clone(), new_config.clone(), eta)?;
FeeManager::update_fee_config(env, admin.clone(), new_config.clone())?;

// Log admin action
let mut params = Map::new(env);
Expand Down
6 changes: 4 additions & 2 deletions contracts/predictify-hybrid/src/admin_auth_audit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ impl TestSetup {
fn test_upgrade_contract_requires_persistent_primary_admin() {
let setup = TestSetup::uninitialized();
let wasm_hash = BytesN::from_array(&setup.env, &[7; 32]);
let predecessor = BytesN::from_array(&setup.env, &[0; 32]);

let result = setup
.client()
.try_upgrade_contract(&setup.admin, &wasm_hash);
.try_upgrade_contract(&setup.admin, &wasm_hash, &predecessor);

assert_eq!(result, Err(Ok(Error::AdminNotSet)));
}
Expand All @@ -53,6 +54,7 @@ fn test_upgrade_contract_rejects_legacy_instance_admin_bypass() {
let setup = TestSetup::initialized();
let attacker = Address::generate(&setup.env);
let wasm_hash = BytesN::from_array(&setup.env, &[9; 32]);
let predecessor = BytesN::from_array(&setup.env, &[0; 32]);

setup.env.as_contract(&setup.contract_id, || {
setup
Expand All @@ -62,7 +64,7 @@ fn test_upgrade_contract_rejects_legacy_instance_admin_bypass() {
.set(&Symbol::new(&setup.env, "admin"), &attacker);
});

let result = setup.client().try_upgrade_contract(&attacker, &wasm_hash);
let result = setup.client().try_upgrade_contract(&attacker, &wasm_hash, &predecessor);

assert_eq!(result, Err(Ok(Error::Unauthorized)));
}
Expand Down
1 change: 1 addition & 0 deletions contracts/predictify-hybrid/src/audit_trail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub enum AuditAction {

// Resolution & Disputes
MarketResolved,
MarketForceResolved,
DisputeCreated,
DisputeResolved,
OracleVerificationOverride,
Expand Down
3 changes: 2 additions & 1 deletion contracts/predictify-hybrid/src/bets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ impl BetManager {
) -> Result<Bet, Error> {
let scope = guard_scope_place_bet();
ReentrancyGuard::with_guard(env, &scope, || {
Self::place_bet_inner(env, user, market_id, outcome, amount)
Self::place_bet_inner(env, user, market_id, outcome, amount, max_fee_bps)
})
}

Expand All @@ -302,6 +302,7 @@ impl BetManager {
market_id: Symbol,
outcome: String,
amount: i128,
max_fee_bps: Option<u32>,
) -> Result<Bet, Error> {
crate::circuit_breaker::CircuitBreaker::require_write_allowed(env, "betting")?;
// Require authentication from the user
Expand Down
5 changes: 5 additions & 0 deletions contracts/predictify-hybrid/src/circuit_breaker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,7 @@ mod tests {
recovery_timeout: 300,
half_open_max_requests: 3,
auto_recovery_enabled: true,
half_open_quota: HalfOpenQuota { calls_per_minute: 3, evaluation_window_s: 60 },
};
assert_eq!(config.max_error_rate, 10);
assert_eq!(config.half_open_max_requests, 3);
Expand Down Expand Up @@ -1318,6 +1319,7 @@ mod tests {
recovery_timeout: 600,
half_open_max_requests: 5,
auto_recovery_enabled: true,
half_open_quota: HalfOpenQuota { calls_per_minute: 3, evaluation_window_s: 60 },
};
let result = CircuitBreaker::validate_config(&config);
assert!(result.is_ok());
Expand All @@ -1338,6 +1340,7 @@ mod tests {
error_count: 0,
pause_scope: PauseScope::BettingOnly,
allow_withdrawals: false,
half_open_since: 0,
};
assert_eq!(state.state, BreakerState::Closed);
state.state = BreakerState::Open;
Expand All @@ -1358,6 +1361,7 @@ mod tests {
error_count: 0,
pause_scope: PauseScope::BettingOnly,
allow_withdrawals: false,
half_open_since: 0,
};
assert_eq!(state.failure_count, 0);
state.failure_count += 1;
Expand Down Expand Up @@ -1387,6 +1391,7 @@ mod tests {
error_count: 0,
pause_scope: PauseScope::BettingOnly,
allow_withdrawals: true,
half_open_since: 0,
};
assert!(state.allow_withdrawals);
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/predictify-hybrid/src/disputes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ impl DisputeManager {
user.clone(),
Map::new(env),
None,
);;
);

Ok(())
}
Expand Down Expand Up @@ -1122,7 +1122,7 @@ impl DisputeManager {
admin.clone(),
Map::new(env),
None,
);;
);

Ok(resolution)
}
Expand Down
Loading