diff --git a/contracts/Cargo.toml b/contracts/Cargo.toml index 13c72d7..018ca81 100644 --- a/contracts/Cargo.toml +++ b/contracts/Cargo.toml @@ -3,8 +3,11 @@ members = [ "attestation-bonding", "contribution-rewards", "credit-class-voting", + "dynamic-supply", + "fee-router", "integration-tests", "marketplace-curation", + "reputation-signal", "service-escrow", "validator-governance", ] diff --git a/contracts/attestation-bonding/src/contract.rs b/contracts/attestation-bonding/src/contract.rs index b11af31..cc37e3f 100644 --- a/contracts/attestation-bonding/src/contract.rs +++ b/contracts/attestation-bonding/src/contract.rs @@ -542,15 +542,15 @@ fn query_attestations( start_after: Option, limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_QUERY_LIMIT).min(MAX_QUERY_LIMIT) as usize; - let start = start_after.map(|s| cw_storage_plus::Bound::exclusive(s)); + let start = start_after.map(cw_storage_plus::Bound::exclusive); let attester_addr = attester.map(|a| deps.api.addr_validate(&a)).transpose()?; let attestations: Vec<_> = ATTESTATIONS .range(deps.storage, start, None, Order::Ascending) .filter_map(|item| item.ok()) .filter(|(_, a)| { - status.as_ref().map_or(true, |s| a.status == *s) - && attester_addr.as_ref().map_or(true, |addr| a.attester == *addr) + status.as_ref().is_none_or(|s| a.status == *s) + && attester_addr.as_ref().is_none_or(|addr| a.attester == *addr) }) .take(limit) .map(|(_, a)| a) @@ -568,12 +568,12 @@ fn query_challenges( deps: Deps, attestation_id: Option, start_after: Option, limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_QUERY_LIMIT).min(MAX_QUERY_LIMIT) as usize; - let start = start_after.map(|s| cw_storage_plus::Bound::exclusive(s)); + let start = start_after.map(cw_storage_plus::Bound::exclusive); let challenges: Vec<_> = CHALLENGES .range(deps.storage, start, None, Order::Ascending) .filter_map(|item| item.ok()) - .filter(|(_, c)| attestation_id.map_or(true, |aid| c.attestation_id == aid)) + .filter(|(_, c)| attestation_id.is_none_or(|aid| c.attestation_id == aid)) .take(limit) .map(|(_, c)| c) .collect(); diff --git a/contracts/contribution-rewards/src/contract.rs b/contracts/contribution-rewards/src/contract.rs index 5eeafa5..e6a53eb 100644 --- a/contracts/contribution-rewards/src/contract.rs +++ b/contracts/contribution-rewards/src/contract.rs @@ -22,6 +22,18 @@ const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); /// Seconds per month approximation (30.44 days) const SECONDS_PER_MONTH: u64 = 2_629_744; +/// Grouped parameters for `execute_record_activity`. Carries exactly the +/// fields of `ExecuteMsg::RecordActivity` so the dispatch block can forward +/// them in one move without tripping clippy's `too_many_arguments` lint. +struct RecordActivityParams { + participant: String, + credit_purchase_value: Uint128, + credit_retirement_value: Uint128, + platform_facilitation_value: Uint128, + governance_votes: u32, + proposal_credits: u32, +} + // ── Instantiate ──────────────────────────────────────────────────────── #[cfg_attr(not(feature = "library"), entry_point)] @@ -98,12 +110,14 @@ pub fn execute( } => execute_record_activity( deps, info, - participant, - credit_purchase_value, - credit_retirement_value, - platform_facilitation_value, - governance_votes, - proposal_credits, + RecordActivityParams { + participant, + credit_purchase_value, + credit_retirement_value, + platform_facilitation_value, + governance_votes, + proposal_credits, + }, ), ExecuteMsg::TriggerDistribution { community_pool_inflow, @@ -390,12 +404,7 @@ fn execute_claim_matured( fn execute_record_activity( deps: DepsMut, info: MessageInfo, - participant: String, - credit_purchase_value: Uint128, - credit_retirement_value: Uint128, - platform_facilitation_value: Uint128, - governance_votes: u32, - proposal_credits: u32, + params: RecordActivityParams, ) -> Result { let config = CONFIG.load(deps.storage)?; require_admin(&config, &info)?; @@ -408,30 +417,30 @@ fn execute_record_activity( }); } - let participant_addr = deps.api.addr_validate(&participant)?; + let participant_addr = deps.api.addr_validate(¶ms.participant)?; let period = state.current_period; // Load existing or create new let mut score = ACTIVITY_SCORES .may_load(deps.storage, (period, &participant_addr))? .unwrap_or(ActivityScore { - address: participant.clone(), + address: params.participant.clone(), period, ..Default::default() }); // Accumulate (additive within a period) - score.credit_purchase_value += credit_purchase_value; - score.credit_retirement_value += credit_retirement_value; - score.platform_facilitation_value += platform_facilitation_value; - score.governance_votes += governance_votes; - score.proposal_credits += proposal_credits; + score.credit_purchase_value += params.credit_purchase_value; + score.credit_retirement_value += params.credit_retirement_value; + score.platform_facilitation_value += params.platform_facilitation_value; + score.governance_votes += params.governance_votes; + score.proposal_credits += params.proposal_credits; ACTIVITY_SCORES.save(deps.storage, (period, &participant_addr), &score)?; Ok(Response::new() .add_attribute("action", "record_activity") - .add_attribute("participant", participant) + .add_attribute("participant", params.participant) .add_attribute("period", period.to_string())) } diff --git a/contracts/credit-class-voting/src/contract.rs b/contracts/credit-class-voting/src/contract.rs index eecc486..1c3f982 100644 --- a/contracts/credit-class-voting/src/contract.rs +++ b/contracts/credit-class-voting/src/contract.rs @@ -28,6 +28,18 @@ const DEFAULT_AGENT_REVIEW_TIMEOUT: u64 = 86_400; /// Default override window: 6 hours const DEFAULT_OVERRIDE_WINDOW: u64 = 21_600; +/// Grouped parameters for `execute_update_config`. Carries exactly the +/// fields of `ExecuteMsg::UpdateConfig` so the dispatch block can forward +/// them in one move without tripping clippy's `too_many_arguments` lint. +struct UpdateConfigParams { + registry_agent: Option, + deposit_amount: Option, + voting_period_seconds: Option, + agent_review_timeout_seconds: Option, + override_window_seconds: Option, + community_pool: Option, +} + /// Slash 20% of deposit on rejection const REJECT_SLASH_BPS: u128 = 2000; /// Slash 5% of deposit on expiry @@ -112,12 +124,14 @@ pub fn execute( } => execute_update_config( deps, info, - registry_agent, - deposit_amount, - voting_period_seconds, - agent_review_timeout_seconds, - override_window_seconds, - community_pool, + UpdateConfigParams { + registry_agent, + deposit_amount, + voting_period_seconds, + agent_review_timeout_seconds, + override_window_seconds, + community_pool, + }, ), } } @@ -560,12 +574,7 @@ fn execute_finalize_proposal( fn execute_update_config( deps: DepsMut, info: MessageInfo, - registry_agent: Option, - deposit_amount: Option, - voting_period_seconds: Option, - agent_review_timeout_seconds: Option, - override_window_seconds: Option, - community_pool: Option, + params: UpdateConfigParams, ) -> Result { let mut config = CONFIG.load(deps.storage)?; @@ -575,22 +584,22 @@ fn execute_update_config( }); } - if let Some(agent) = registry_agent { + if let Some(agent) = params.registry_agent { config.registry_agent = deps.api.addr_validate(&agent)?; } - if let Some(amount) = deposit_amount { + if let Some(amount) = params.deposit_amount { config.deposit_amount = amount; } - if let Some(seconds) = voting_period_seconds { + if let Some(seconds) = params.voting_period_seconds { config.voting_period_seconds = seconds; } - if let Some(seconds) = agent_review_timeout_seconds { + if let Some(seconds) = params.agent_review_timeout_seconds { config.agent_review_timeout_seconds = seconds; } - if let Some(seconds) = override_window_seconds { + if let Some(seconds) = params.override_window_seconds { config.override_window_seconds = seconds; } - if let Some(pool) = community_pool { + if let Some(pool) = params.community_pool { config.community_pool = Some(deps.api.addr_validate(&pool)?); } @@ -650,7 +659,7 @@ fn query_proposals( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_QUERY_LIMIT).min(MAX_QUERY_LIMIT) as usize; - let start = start_after.map(|s| cw_storage_plus::Bound::exclusive(s)); + let start = start_after.map(cw_storage_plus::Bound::exclusive); let proposals: Vec = PROPOSALS .range(deps.storage, start, None, Order::Ascending) @@ -677,7 +686,7 @@ fn query_proposals_by_admin( ) -> StdResult { let admin_addr = deps.api.addr_validate(&admin_address)?; let limit = limit.unwrap_or(DEFAULT_QUERY_LIMIT).min(MAX_QUERY_LIMIT) as usize; - let start = start_after.map(|s| cw_storage_plus::Bound::exclusive(s)); + let start = start_after.map(cw_storage_plus::Bound::exclusive); let proposals: Vec = PROPOSALS .range(deps.storage, start, None, Order::Ascending) diff --git a/contracts/marketplace-curation/src/contract.rs b/contracts/marketplace-curation/src/contract.rs index f1a0a4e..704365c 100644 --- a/contracts/marketplace-curation/src/contract.rs +++ b/contracts/marketplace-curation/src/contract.rs @@ -844,7 +844,7 @@ fn query_collections( limit: Option, ) -> StdResult { let limit = limit.unwrap_or(DEFAULT_QUERY_LIMIT).min(MAX_QUERY_LIMIT) as usize; - let start = start_after.map(|s| cw_storage_plus::Bound::exclusive(s)); + let start = start_after.map(cw_storage_plus::Bound::exclusive); let curator_addr = curator .map(|c| deps.api.addr_validate(&c)) @@ -860,7 +860,7 @@ fn query_collections( } } if let Some(ref c) = curator_addr { - if &coll.curator != c { + if coll.curator != *c { return None; } } diff --git a/contracts/reputation-signal/src/contract.rs b/contracts/reputation-signal/src/contract.rs index 7bd05d5..253c565 100644 --- a/contracts/reputation-signal/src/contract.rs +++ b/contracts/reputation-signal/src/contract.rs @@ -9,6 +9,26 @@ use crate::error::ContractError; use crate::msg::*; use crate::state::*; +/// Grouped parameters for `exec_submit_signal`. Mirrors `ExecuteMsg::SubmitSignal`. +struct SubmitSignalParams { + subject_type: SubjectType, + subject_id: String, + category: String, + endorsement_level: u8, + evidence: Evidence, +} + +/// Grouped parameters for `exec_update_config`. Mirrors `ExecuteMsg::UpdateConfig`. +struct UpdateConfigParams { + activation_delay_seconds: Option, + challenge_window_seconds: Option, + resolution_deadline_seconds: Option, + challenge_bond_denom: Option, + challenge_bond_amount: Option, + decay_half_life_seconds: Option, + default_min_stake: Option, +} + // --------------------------------------------------------------------------- // Entry points // --------------------------------------------------------------------------- @@ -62,11 +82,13 @@ pub fn execute( deps, env, info, - subject_type, - subject_id, - category, - endorsement_level, - evidence, + SubmitSignalParams { + subject_type, + subject_id, + category, + endorsement_level, + evidence, + }, ), ExecuteMsg::ActivateSignal { signal_id } => exec_activate_signal(deps, env, signal_id), ExecuteMsg::WithdrawSignal { signal_id } => { @@ -100,13 +122,15 @@ pub fn execute( } => exec_update_config( deps, info, - activation_delay_seconds, - challenge_window_seconds, - resolution_deadline_seconds, - challenge_bond_denom, - challenge_bond_amount, - decay_half_life_seconds, - default_min_stake, + UpdateConfigParams { + activation_delay_seconds, + challenge_window_seconds, + resolution_deadline_seconds, + challenge_bond_denom, + challenge_bond_amount, + decay_half_life_seconds, + default_min_stake, + }, ), ExecuteMsg::SetCategoryMinStake { category, @@ -163,14 +187,18 @@ fn exec_submit_signal( deps: DepsMut, env: Env, info: MessageInfo, - subject_type: SubjectType, - subject_id: String, - category: String, - endorsement_level: u8, - evidence: Evidence, + params: SubmitSignalParams, ) -> Result { + let SubmitSignalParams { + subject_type, + subject_id, + category, + endorsement_level, + evidence, + } = params; + // Validate endorsement level 1-5 - if endorsement_level < 1 || endorsement_level > 5 { + if !(1..=5).contains(&endorsement_level) { return Err(ContractError::InvalidEndorsementLevel { level: endorsement_level, }); @@ -537,13 +565,7 @@ fn exec_invalidate_signal( fn exec_update_config( deps: DepsMut, info: MessageInfo, - activation_delay_seconds: Option, - challenge_window_seconds: Option, - resolution_deadline_seconds: Option, - challenge_bond_denom: Option, - challenge_bond_amount: Option, - decay_half_life_seconds: Option, - default_min_stake: Option, + params: UpdateConfigParams, ) -> Result { let mut config = CONFIG.load(deps.storage)?; @@ -551,25 +573,25 @@ fn exec_update_config( return Err(ContractError::Unauthorized {}); } - if let Some(v) = activation_delay_seconds { + if let Some(v) = params.activation_delay_seconds { config.activation_delay_seconds = v; } - if let Some(v) = challenge_window_seconds { + if let Some(v) = params.challenge_window_seconds { config.challenge_window_seconds = v; } - if let Some(v) = resolution_deadline_seconds { + if let Some(v) = params.resolution_deadline_seconds { config.resolution_deadline_seconds = v; } - if let Some(v) = challenge_bond_denom { + if let Some(v) = params.challenge_bond_denom { config.challenge_bond_denom = v; } - if let Some(v) = challenge_bond_amount { + if let Some(v) = params.challenge_bond_amount { config.challenge_bond_amount = v; } - if let Some(v) = decay_half_life_seconds { + if let Some(v) = params.decay_half_life_seconds { config.decay_half_life_seconds = v; } - if let Some(v) = default_min_stake { + if let Some(v) = params.default_min_stake { config.default_min_stake = v; } @@ -629,7 +651,7 @@ fn exec_remove_arbiter( } let addr = deps.api.addr_validate(&address)?; - config.arbiters.retain(|a| a != &addr); + config.arbiters.retain(|a| *a != addr); CONFIG.save(deps.storage, &config)?; Ok(Response::new() diff --git a/contracts/service-escrow/src/contract.rs b/contracts/service-escrow/src/contract.rs index 5e67a7d..edae37a 100644 --- a/contracts/service-escrow/src/contract.rs +++ b/contracts/service-escrow/src/contract.rs @@ -30,6 +30,21 @@ const MAX_CANCEL_FEE: u64 = 1000; // 10% const MIN_ARBITER_FEE: u64 = 100; // 1% const MAX_ARBITER_FEE: u64 = 1500; // 15% +/// Grouped parameters for `execute_update_config`. Mirrors the optional +/// fields of `ExecuteMsg::UpdateConfig` so the dispatch block can forward +/// them in one move without tripping clippy's `too_many_arguments` lint. +struct UpdateConfigParams { + arbiter_dao: Option, + community_pool: Option, + provider_bond_ratio_bps: Option, + platform_fee_rate_bps: Option, + cancellation_fee_rate_bps: Option, + arbiter_fee_rate_bps: Option, + review_period_seconds: Option, + max_milestones: Option, + max_revisions: Option, +} + // ── Instantiate ──────────────────────────────────────────────────────── #[cfg_attr(not(feature = "library"), entry_point)] @@ -134,9 +149,19 @@ pub fn execute( max_milestones, max_revisions, } => execute_update_config( - deps, info, arbiter_dao, community_pool, provider_bond_ratio_bps, - platform_fee_rate_bps, cancellation_fee_rate_bps, arbiter_fee_rate_bps, - review_period_seconds, max_milestones, max_revisions, + deps, + info, + UpdateConfigParams { + arbiter_dao, + community_pool, + provider_bond_ratio_bps, + platform_fee_rate_bps, + cancellation_fee_rate_bps, + arbiter_fee_rate_bps, + review_period_seconds, + max_milestones, + max_revisions, + }, ), } } @@ -765,11 +790,9 @@ fn execute_cancel( } fn execute_update_config( - deps: DepsMut, info: MessageInfo, - arbiter_dao: Option, community_pool: Option, - provider_bond_ratio_bps: Option, platform_fee_rate_bps: Option, - cancellation_fee_rate_bps: Option, arbiter_fee_rate_bps: Option, - review_period_seconds: Option, max_milestones: Option, max_revisions: Option, + deps: DepsMut, + info: MessageInfo, + params: UpdateConfigParams, ) -> Result { let mut config = CONFIG.load(deps.storage)?; @@ -779,15 +802,15 @@ fn execute_update_config( }); } - if let Some(v) = arbiter_dao { config.arbiter_dao = deps.api.addr_validate(&v)?; } - if let Some(v) = community_pool { config.community_pool = deps.api.addr_validate(&v)?; } - if let Some(v) = provider_bond_ratio_bps { validate_bond_ratio(v)?; config.provider_bond_ratio_bps = v; } - if let Some(v) = platform_fee_rate_bps { validate_fee_rate(v, MIN_PLATFORM_FEE, MAX_PLATFORM_FEE, "platform")?; config.platform_fee_rate_bps = v; } - if let Some(v) = cancellation_fee_rate_bps { validate_fee_rate(v, MIN_CANCEL_FEE, MAX_CANCEL_FEE, "cancellation")?; config.cancellation_fee_rate_bps = v; } - if let Some(v) = arbiter_fee_rate_bps { validate_fee_rate(v, MIN_ARBITER_FEE, MAX_ARBITER_FEE, "arbiter")?; config.arbiter_fee_rate_bps = v; } - if let Some(v) = review_period_seconds { config.review_period_seconds = v; } - if let Some(v) = max_milestones { config.max_milestones = v; } - if let Some(v) = max_revisions { config.max_revisions = v; } + if let Some(v) = params.arbiter_dao { config.arbiter_dao = deps.api.addr_validate(&v)?; } + if let Some(v) = params.community_pool { config.community_pool = deps.api.addr_validate(&v)?; } + if let Some(v) = params.provider_bond_ratio_bps { validate_bond_ratio(v)?; config.provider_bond_ratio_bps = v; } + if let Some(v) = params.platform_fee_rate_bps { validate_fee_rate(v, MIN_PLATFORM_FEE, MAX_PLATFORM_FEE, "platform")?; config.platform_fee_rate_bps = v; } + if let Some(v) = params.cancellation_fee_rate_bps { validate_fee_rate(v, MIN_CANCEL_FEE, MAX_CANCEL_FEE, "cancellation")?; config.cancellation_fee_rate_bps = v; } + if let Some(v) = params.arbiter_fee_rate_bps { validate_fee_rate(v, MIN_ARBITER_FEE, MAX_ARBITER_FEE, "arbiter")?; config.arbiter_fee_rate_bps = v; } + if let Some(v) = params.review_period_seconds { config.review_period_seconds = v; } + if let Some(v) = params.max_milestones { config.max_milestones = v; } + if let Some(v) = params.max_revisions { config.max_revisions = v; } CONFIG.save(deps.storage, &config)?; @@ -913,7 +936,7 @@ fn remaining_escrow(agreement: &ServiceAgreement) -> Uint128 { } fn validate_bond_ratio(value: u64) -> Result<(), ContractError> { - if value < MIN_BOND_RATIO || value > MAX_BOND_RATIO { + if !(MIN_BOND_RATIO..=MAX_BOND_RATIO).contains(&value) { return Err(ContractError::BondRatioOutOfRange { value, min: MIN_BOND_RATIO, max: MAX_BOND_RATIO }); } Ok(())