Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a1d74e2
refactor: Simplify admin module in Predictify Hybrid contract by remo…
1nonlypiece Jul 7, 2025
3c83d32
refactor: Remove unused imports in config module of Predictify Hybrid…
1nonlypiece Jul 7, 2025
c728eec
refactor: Remove unused import from disputes module in Predictify Hyb…
1nonlypiece Jul 7, 2025
1d284fa
refactor: Remove unused parameters and variables in extension fees ha…
1nonlypiece Jul 7, 2025
d306663
refactor: Remove unused import from fees module in Predictify Hybrid …
1nonlypiece Jul 7, 2025
56e6d64
refactor: Remove unused imports from various modules in Predictify Hy…
1nonlypiece Jul 7, 2025
51ec865
refactor: Update parameter naming and remove unused parameters in mar…
1nonlypiece Jul 7, 2025
068d333
refactor: Remove unused import from resolution module in Predictify H…
1nonlypiece Jul 7, 2025
7238bbf
refactor: Remove unused parameters from oracle and market resolution …
1nonlypiece Jul 7, 2025
15891a9
refactor: Remove unused parameters in to_string method of ReflectorAs…
1nonlypiece Jul 7, 2025
919eb46
refactor: Remove unused import from validation module in Predictify H…
1nonlypiece Jul 7, 2025
d35ee59
refactor: Remove unused variables and update parameter naming in voti…
1nonlypiece Jul 7, 2025
f7690d3
refactor: Remove unused test function from resolution module in Predi…
1nonlypiece Jul 7, 2025
d6550ed
refactor: Remove unused parameters from error logging functions in Pr…
1nonlypiece Jul 7, 2025
da935a1
refactor: Remove unused parameter from validate function in OracleCon…
1nonlypiece Jul 7, 2025
553b389
refactor: Remove unused parameter from validate_vote_parameters and v…
1nonlypiece Jul 7, 2025
4123943
refactor: Remove unused parameter from clear_old_events function in P…
1nonlypiece Jul 7, 2025
d14b7de
refactor: Remove unused parameter from string_to_address function in …
1nonlypiece Jul 7, 2025
a9f4d1f
refactor: Remove unused parameters from admin functions in Predictify…
1nonlypiece Jul 7, 2025
1c874f8
refactor: Simplify get_dispute_votes function in Predictify Hybrid co…
1nonlypiece Jul 7, 2025
7e28d72
refactor: Remove unused import from resolution module in Predictify H…
1nonlypiece Jul 7, 2025
f32253e
refactor: Remove unused parameter from validate_market_for_resolution…
1nonlypiece Jul 7, 2025
b9a38e4
refactor: Update validate_market_for_resolution function in Predictif…
1nonlypiece Jul 7, 2025
8e85043
refactor: Remove unused parameter from validate function in MarketExt…
1nonlypiece Jul 7, 2025
9eac21e
refactor: Remove unused environment parameter from validate_market_fo…
1nonlypiece Jul 7, 2025
57bc7b1
refactor: Remove unused parameters from store_dispute_threshold and c…
1nonlypiece Jul 7, 2025
a707535
refactor: Remove unused variable from admin tests in Predictify Hybri…
1nonlypiece Jul 7, 2025
7b5cb2f
refactor: Remove unused parameters from dispute-related functions in …
1nonlypiece Jul 7, 2025
8f423ab
refactor: Remove unused parameters from fee recording functions in Pr…
1nonlypiece Jul 7, 2025
d84281e
refactor: Update get_dispute_votes function in Predictify Hybrid cont…
1nonlypiece Jul 7, 2025
f0e6d4c
refactor: Remove unused oracle_result parameter from resolution metho…
1nonlypiece Jul 7, 2025
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
30 changes: 14 additions & 16 deletions contracts/predictify-hybrid/src/admin.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use soroban_sdk::{contracttype, symbol_short, vec, Address, Env, Map, String, Symbol, Vec};
use soroban_sdk::{contracttype, vec, Address, Env, Map, String, Symbol, Vec};
use alloc::string::ToString;
use alloc::format;

use crate::errors::Error;
use crate::events::{EventEmitter, AdminActionEvent, AdminRoleEvent, AdminPermissionEvent, MarketClosedEvent, MarketFinalizedEvent, AdminInitializedEvent, ConfigInitializedEvent};
use crate::markets::{MarketStateManager, MarketValidator};
use crate::markets::MarketStateManager;
use crate::fees::{FeeManager, FeeConfig};
use crate::config::{ConfigManager, ContractConfig, Environment, ConfigUtils};
use crate::resolution::MarketResolutionManager;
use crate::extensions::ExtensionManager;
use crate::types::*;
use crate::events::EventEmitter;

/// Admin management system for Predictify Hybrid contract
///
Expand Down Expand Up @@ -304,7 +302,7 @@ impl AdminRoleManager {
}

/// Get admin role
pub fn get_admin_role(env: &Env, admin: &Address) -> Result<AdminRole, Error> {
pub fn get_admin_role(env: &Env, _admin: &Address) -> Result<AdminRole, Error> {
let key = Symbol::new(env, "admin_role");
let assignment: AdminRoleAssignment = env
.storage()
Expand All @@ -321,7 +319,7 @@ impl AdminRoleManager {

/// Check if admin has permission
pub fn has_permission(
env: &Env,
_env: &Env,
role: &AdminRole,
permission: &AdminPermission,
) -> Result<bool, Error> {
Expand Down Expand Up @@ -421,7 +419,7 @@ impl AdminFunctions {
AdminAccessControl::validate_admin_for_action(env, admin, "close_market")?;

// Get market
let market = MarketStateManager::get_market(env, market_id)?;
let _market = MarketStateManager::get_market(env, market_id)?;

// Close market
MarketStateManager::remove_market(env, market_id);
Expand All @@ -448,7 +446,7 @@ impl AdminFunctions {
AdminAccessControl::validate_admin_for_action(env, admin, "finalize_market")?;

// Finalize market using resolution manager
let resolution = MarketResolutionManager::finalize_market(env, admin, market_id, outcome)?;
let _resolution = MarketResolutionManager::finalize_market(env, admin, market_id, outcome)?;

// Emit market finalized event
EventEmitter::emit_market_finalized(env, market_id, admin, outcome);
Expand Down Expand Up @@ -551,7 +549,7 @@ pub struct AdminValidator;

impl AdminValidator {
/// Validate admin address
pub fn validate_admin_address(env: &Env, admin: &Address) -> Result<(), Error> {
pub fn validate_admin_address(_env: &Env, admin: &Address) -> Result<(), Error> {
// Check if address is valid
if admin.to_string().is_empty() {
return Err(Error::InvalidInput);
Expand Down Expand Up @@ -650,7 +648,7 @@ impl AdminActionLogger {
}

/// Get admin actions
pub fn get_admin_actions(env: &Env, limit: u32) -> Result<Vec<AdminAction>, Error> {
pub fn get_admin_actions(env: &Env, _limit: u32) -> Result<Vec<AdminAction>, Error> {
// For now, return empty vector since we don't have a way to iterate over storage
// In a real implementation, you would store actions in a more sophisticated way
Ok(Vec::new(env))
Expand All @@ -659,8 +657,8 @@ impl AdminActionLogger {
/// Get admin actions for specific admin
pub fn get_admin_actions_for_admin(
env: &Env,
admin: &Address,
limit: u32,
_admin: &Address,
_limit: u32,
) -> Result<Vec<AdminAction>, Error> {
// For now, return empty vector
Ok(Vec::new(env))
Expand All @@ -672,7 +670,7 @@ impl AdminActionLogger {
/// Admin analytics
impl AdminAnalytics {
/// Calculate admin analytics
pub fn calculate_admin_analytics(env: &Env) -> Result<AdminAnalytics, Error> {
pub fn calculate_admin_analytics(_env: &Env) -> Result<AdminAnalytics, Error> {
// For now, return default analytics since we don't store complex types
Ok(AdminAnalytics::default())
}
Expand Down Expand Up @@ -827,7 +825,7 @@ impl Default for AdminAnalytics {
#[cfg(test)]
mod tests {
use super::*;
use soroban_sdk::testutils::{Address as _, Ledger, LedgerInfo};
use soroban_sdk::testutils::{Address as _,};

#[test]
fn test_admin_initializer_initialize() {
Expand Down Expand Up @@ -888,7 +886,7 @@ mod tests {
fn test_admin_functions_close_market() {
let env = Env::default();
let admin = Address::generate(&env);
let market_id = Symbol::new(&env, "test_market");
let _market_id = Symbol::new(&env, "test_market");

// Initialize admin
AdminInitializer::initialize(&env, &admin).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion contracts/predictify-hybrid/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use soroban_sdk::{contracttype, symbol_short, vec, Address, Env, Map, String, Symbol, Vec};
use soroban_sdk::{contracttype, Address, Env, String, Symbol};

use crate::errors::Error;

Expand Down
39 changes: 19 additions & 20 deletions contracts/predictify-hybrid/src/disputes.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
errors::Error,
markets::{MarketStateManager, MarketValidator},
markets::{MarketStateManager},
types::Market,
voting::{VotingUtils, DISPUTE_EXTENSION_HOURS, MIN_DISPUTE_STAKE},
};
Expand Down Expand Up @@ -339,8 +339,8 @@ impl DisputeManager {
}

/// Get dispute votes
pub fn get_dispute_votes(env: &Env, dispute_id: Symbol) -> Result<Vec<DisputeVote>, Error> {
DisputeUtils::get_dispute_votes(env, &dispute_id)
pub fn get_dispute_votes(env: &Env, _dispute_id: &Symbol) -> Result<Vec<DisputeVote>, Error> {
DisputeUtils::get_dispute_votes(env, _dispute_id)
}

/// Validate dispute resolution conditions
Expand Down Expand Up @@ -377,7 +377,7 @@ impl DisputeValidator {
}

/// Validate market state for resolution
pub fn validate_market_for_resolution(env: &Env, market: &Market) -> Result<(), Error> {
pub fn validate_market_for_resolution(_env: &Env, market: &Market) -> Result<(), Error> {
// Check if market is already resolved
if market.winning_outcome.is_some() {
return Err(Error::MarketAlreadyResolved);
Expand Down Expand Up @@ -408,7 +408,7 @@ impl DisputeValidator {

/// Validate dispute parameters
pub fn validate_dispute_parameters(
env: &Env,
_env: &Env,
user: &Address,
market: &Market,
stake: i128,
Expand Down Expand Up @@ -447,7 +447,7 @@ impl DisputeValidator {
/// Validate dispute voting conditions
pub fn validate_dispute_voting_conditions(
env: &Env,
market_id: &Symbol,
_market_id: &Symbol,
dispute_id: &Symbol,
) -> Result<(), Error> {
// Check if dispute exists and is active
Expand Down Expand Up @@ -566,7 +566,7 @@ impl DisputeUtils {
}

/// Extend market for dispute period
pub fn extend_market_for_dispute(market: &mut Market, env: &Env) -> Result<(), Error> {
pub fn extend_market_for_dispute(market: &mut Market, _env: &Env) -> Result<(), Error> {
let extension_seconds = (DISPUTE_EXTENSION_HOURS as u64) * 3600;
market.end_time += extension_seconds;
Ok(())
Expand Down Expand Up @@ -685,7 +685,7 @@ impl DisputeUtils {
}

/// Get dispute voting data
pub fn get_dispute_voting(env: &Env, dispute_id: &Symbol) -> Result<DisputeVoting, Error> {
pub fn get_dispute_voting(env: &Env, _dispute_id: &Symbol) -> Result<DisputeVoting, Error> {
let key = symbol_short!("dispute_v");
env.storage()
.persistent()
Expand All @@ -694,23 +694,23 @@ impl DisputeUtils {
}

/// Store dispute voting data
pub fn store_dispute_voting(env: &Env, dispute_id: &Symbol, voting: &DisputeVoting) -> Result<(), Error> {
pub fn store_dispute_voting(env: &Env, _dispute_id: &Symbol, voting: &DisputeVoting) -> Result<(), Error> {
let key = symbol_short!("dispute_v");
env.storage().persistent().set(&key, voting);
Ok(())
}

/// Store dispute vote
pub fn store_dispute_vote(env: &Env, dispute_id: &Symbol, vote: &DisputeVote) -> Result<(), Error> {
pub fn store_dispute_vote(env: &Env, _dispute_id: &Symbol, vote: &DisputeVote) -> Result<(), Error> {
let key = symbol_short!("vote");
env.storage().persistent().set(&key, vote);
Ok(())
}

/// Get dispute votes
pub fn get_dispute_votes(env: &Env, dispute_id: &Symbol) -> Result<Vec<DisputeVote>, Error> {
pub fn get_dispute_votes(env: &Env, _dispute_id: &Symbol) -> Result<Vec<DisputeVote>, Error> {
// This is a simplified implementation - in a real system you'd need to track all votes
let mut votes = Vec::new(env);
let votes = Vec::new(env);

// For now, return empty vector - in practice you'd iterate through stored votes
Ok(votes)
Expand Down Expand Up @@ -752,7 +752,7 @@ impl DisputeUtils {
/// Store dispute fee distribution
pub fn store_dispute_fee_distribution(
env: &Env,
dispute_id: &Symbol,
_dispute_id: &Symbol,
distribution: &DisputeFeeDistribution,
) -> Result<(), Error> {
let key = symbol_short!("dispute_f");
Expand Down Expand Up @@ -780,7 +780,7 @@ impl DisputeUtils {
/// Store dispute escalation
pub fn store_dispute_escalation(
env: &Env,
dispute_id: &Symbol,
_dispute_id: &Symbol,
escalation: &DisputeEscalation,
) -> Result<(), Error> {
let key = symbol_short!("dispute_e");
Expand All @@ -789,13 +789,13 @@ impl DisputeUtils {
}

/// Get dispute escalation
pub fn get_dispute_escalation(env: &Env, dispute_id: &Symbol) -> Option<DisputeEscalation> {
pub fn get_dispute_escalation(env: &Env, _dispute_id: &Symbol) -> Option<DisputeEscalation> {
let key = symbol_short!("dispute_e");
env.storage().persistent().get(&key)
}

/// Emit dispute vote event
pub fn emit_dispute_vote_event(env: &Env, dispute_id: &Symbol, user: &Address, vote: bool, stake: i128) {
pub fn emit_dispute_vote_event(env: &Env, _dispute_id: &Symbol, user: &Address, vote: bool, stake: i128) {
// In a real implementation, this would emit an event
// For now, we'll just store it in persistent storage
let event_key = symbol_short!("vote_evt");
Expand All @@ -804,7 +804,7 @@ impl DisputeUtils {
}

/// Emit fee distribution event
pub fn emit_fee_distribution_event(env: &Env, dispute_id: &Symbol, distribution: &DisputeFeeDistribution) {
pub fn emit_fee_distribution_event(env: &Env, _dispute_id: &Symbol, distribution: &DisputeFeeDistribution) {
// In a real implementation, this would emit an event
// For now, we'll just store it in persistent storage
let event_key = symbol_short!("fee_event");
Expand All @@ -814,7 +814,7 @@ impl DisputeUtils {
/// Emit dispute escalation event
pub fn emit_dispute_escalation_event(
env: &Env,
dispute_id: &Symbol,
_dispute_id: &Symbol,
user: &Address,
escalation: &DisputeEscalation,
) {
Expand Down Expand Up @@ -926,7 +926,7 @@ impl DisputeAnalytics {
}

/// Get top disputers by stake amount
pub fn get_top_disputers(env: &Env, market: &Market, limit: usize) -> Vec<(Address, i128)> {
pub fn get_top_disputers(env: &Env, market: &Market, _limit: usize) -> Vec<(Address, i128)> {
let mut disputers: Vec<(Address, i128)> = Vec::new(env);

for (user, stake) in market.dispute_stakes.iter() {
Expand Down Expand Up @@ -958,7 +958,6 @@ impl DisputeAnalytics {
#[cfg(test)]
pub mod testing {
use super::*;
use soroban_sdk::testutils::Address as _;

/// Create a test dispute
pub fn create_test_dispute(
Expand Down
6 changes: 3 additions & 3 deletions contracts/predictify-hybrid/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,17 +511,17 @@ pub mod debug {
use super::*;

/// Log error with context for debugging
pub fn log_error(env: &Env, error: Error, context: &ErrorContext) {
pub fn log_error(env: &Env, error: Error, _context: &ErrorContext) {
// In a real implementation, this would log to a debug storage or event
// For now, we'll just use the panic mechanism
// Note: In no_std environment, we can't use format! macro
// This is a placeholder - in a real implementation you might want to
// store this in a debug log or emit an event
let _ = (env, error, context); // Suppress unused variable warning
let _ = (env, error); // Suppress unused variable warning
}

/// Create a detailed error report
pub fn create_error_report(env: &Env, error: Error, context: &ErrorContext) -> String {
pub fn create_error_report(env: &Env, error: Error, _context: &ErrorContext) -> String {
// In no_std environment, we can't use format! macro
// For now, return a simple error message
String::from_str(env, &error.message())
Expand Down
2 changes: 1 addition & 1 deletion contracts/predictify-hybrid/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ impl EventLogger {
}

/// Clear old events (cleanup utility)
pub fn clear_old_events(env: &Env, older_than_timestamp: u64) {
pub fn clear_old_events(env: &Env, _older_than_timestamp: u64) {
let event_types = vec![
env,
symbol_short!("mkt_crt"),
Expand Down
6 changes: 3 additions & 3 deletions contracts/predictify-hybrid/src/extensions.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use soroban_sdk::{contracttype, symbol_short, token, vec, Address, Env, Map, String, Symbol, Vec};
use soroban_sdk::{contracttype, symbol_short, vec, Address, Env, String, Symbol, Vec};

use crate::errors::Error;
use crate::types::*;
Expand Down Expand Up @@ -187,13 +187,13 @@ impl ExtensionUtils {
/// Handle extension fees
pub fn handle_extension_fees(
env: &Env,
market_id: &Symbol,
_market_id: &Symbol,
additional_days: u32,
) -> Result<i128, Error> {
let fee_amount = ExtensionManager::calculate_extension_fee(additional_days);

// Get token client for fee collection
let token_client = MarketUtils::get_token_client(env)?;
let _token_client = MarketUtils::get_token_client(env)?;

// Transfer fees from admin to contract
// Note: In a real implementation, you would need to handle the actual token transfer
Expand Down
8 changes: 4 additions & 4 deletions contracts/predictify-hybrid/src/fees.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use soroban_sdk::{contracttype, symbol_short, token, vec, Address, Env, Map, String, Symbol, Vec};
use soroban_sdk::{contracttype, symbol_short, vec, Address, Env, Map, String, Symbol, Vec};

use crate::errors::Error;
use crate::markets::{MarketStateManager, MarketUtils};
Expand Down Expand Up @@ -498,7 +498,7 @@ impl FeeTracker {
/// Record creation fee
pub fn record_creation_fee(
env: &Env,
admin: &Address,
_admin: &Address,
amount: i128,
) -> Result<(), Error> {
// Record creation fee in analytics
Expand All @@ -519,8 +519,8 @@ impl FeeTracker {
/// Record configuration change
pub fn record_config_change(
env: &Env,
admin: &Address,
config: &FeeConfig,
_admin: &Address,
_config: &FeeConfig,
) -> Result<(), Error> {
// Store configuration change timestamp
let config_key = symbol_short!("cfg_time");
Expand Down
Loading
Loading