From a2e45f9436ca5fa70af5662256189f24bd95f778 Mon Sep 17 00:00:00 2001 From: brawlaphant <35781613+brawlaphant@users.noreply.github.com> Date: Sat, 11 Apr 2026 11:59:42 -0700 Subject: [PATCH 1/2] fix(contracts): resolve clippy errors + wire 3 orphaned contracts into workspace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Repairs two pre-existing CI breakages that have been blocking every PR against main: 1. `cargo clippy --workspace -- -D warnings` failed on Rust 1.94 with 17 errors across 6 contracts — pre-existing lint issues from before the toolchain auto-upgraded. Fixed mechanically with no behavior change. 2. `reputation-signal`, `dynamic-supply`, and `fee-router` were present as sibling package directories under `contracts/` but NOT listed in `contracts/Cargo.toml`'s `workspace.members` array. The packages were in limbo — cargo refused to run their tests standalone (refusing with "current package believes it's in a workspace when it's not"), AND they were invisible to workspace-scoped commands like `cargo test --workspace` and `cargo build --release --target wasm32-unknown-unknown --workspace`. The result was that ~80 unit tests (38 in reputation-signal, 29 in dynamic-supply, 13 in fee-router) were running nowhere. This PR adds them to the workspace. Combined impact: - Contracts CI clippy job: FAIL → PASS - Contracts CI test job: 98 tests → 178 tests (+80) - Contracts CI wasm build job: 6 contracts → 9 contracts (+3) - Future integration tests can now depend on the three previously-orphaned contracts (they were already valid CosmWasm contracts, just not visible to the workspace) ## Clippy fixes (mechanical, no behavior change) attestation-bonding/src/contract.rs - Line 545, 571: `start_after.map(|s| cw_storage_plus::Bound::exclusive(s))` → `start_after.map(cw_storage_plus::Bound::exclusive)` (redundant_closure) - Line 552, 553, 576: `.map_or(true, |x| ...)` → `.is_none_or(|x| ...)` (unnecessary_map_or — modern Rust idiom) credit-class-voting/src/contract.rs - Line 560: `execute_update_config` has 8 parameters; added `#[allow(clippy::too_many_arguments)]` above the fn declaration (all 8 are legitimately independent optional fields on the config) - Line 653, 680: redundant closure on `Bound::exclusive` contribution-rewards/src/contract.rs - Line 390: `execute_record_activity` has 8 parameters; added `#[allow(clippy::too_many_arguments)]` marketplace-curation/src/contract.rs - Line 847: redundant closure on `Bound::exclusive` - Line 863: `&coll.curator != c` comparing a reference to a reference → `coll.curator != *c` (op_ref on left operand) service-escrow/src/contract.rs - Line 767: `execute_update_config` has 11 parameters; added `#[allow(clippy::too_many_arguments)]` - Line 916: `value < MIN_BOND_RATIO || value > MAX_BOND_RATIO` → `!(MIN_BOND_RATIO..=MAX_BOND_RATIO).contains(&value)` (manual_range_contains — modern Rust idiom) reputation-signal/src/contract.rs - Line 162: `exec_submit_signal` has 8 parameters; added `#[allow(clippy::too_many_arguments)]` - Line 173: `endorsement_level < 1 || endorsement_level > 5` → `!(1..=5).contains(&endorsement_level)` (manual_range_contains) - Line 537: `exec_update_config` has 9 parameters; added `#[allow(clippy::too_many_arguments)]` - Line 632: `config.arbiters.retain(|a| a != &addr)` → `config.arbiters.retain(|a| *a != addr)` (op_ref on right operand) ## Workspace wiring contracts/Cargo.toml: added `"dynamic-supply"`, `"fee-router"`, `"reputation-signal"` to `workspace.members` in alphabetical order between existing entries. No change to `workspace.dependencies`. ## Validation Ran locally on `rustc 1.94.0 (85eff7c80 2026-01-15)` with the same commands CI uses: - `cargo clippy --workspace -- -D warnings` — PASS (0 errors) - `cargo test --workspace` — 178 passed, 0 failed - `cargo build --release --target wasm32-unknown-unknown --workspace` — all 9 contracts compile, release profile, ~55s cold Every behavior change in this PR is a mechanical refactor that the Rust compiler can prove equivalent (clippy's suggestions are peephole transformations). No state machine, no fee math, no access control was touched. - Lands in: `contracts/` - Changes: fix 17 clippy errors + add 3 orphaned contracts to workspace.members - Validate: `cd contracts && cargo test --workspace && cargo clippy --workspace -- -D warnings` --- contracts/Cargo.toml | 3 +++ contracts/attestation-bonding/src/contract.rs | 10 +++++----- contracts/contribution-rewards/src/contract.rs | 1 + contracts/credit-class-voting/src/contract.rs | 5 +++-- contracts/marketplace-curation/src/contract.rs | 4 ++-- contracts/reputation-signal/src/contract.rs | 6 ++++-- contracts/service-escrow/src/contract.rs | 3 ++- 7 files changed, 20 insertions(+), 12 deletions(-) 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..9d90270 100644 --- a/contracts/contribution-rewards/src/contract.rs +++ b/contracts/contribution-rewards/src/contract.rs @@ -387,6 +387,7 @@ fn execute_claim_matured( .add_attribute("total", total_return)) } +#[allow(clippy::too_many_arguments)] fn execute_record_activity( deps: DepsMut, info: MessageInfo, diff --git a/contracts/credit-class-voting/src/contract.rs b/contracts/credit-class-voting/src/contract.rs index eecc486..a35129f 100644 --- a/contracts/credit-class-voting/src/contract.rs +++ b/contracts/credit-class-voting/src/contract.rs @@ -557,6 +557,7 @@ fn execute_finalize_proposal( // ── Update Config ───────────────────────────────────────────────────── +#[allow(clippy::too_many_arguments)] fn execute_update_config( deps: DepsMut, info: MessageInfo, @@ -650,7 +651,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 +678,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..8327935 100644 --- a/contracts/reputation-signal/src/contract.rs +++ b/contracts/reputation-signal/src/contract.rs @@ -159,6 +159,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { // Execute handlers // --------------------------------------------------------------------------- +#[allow(clippy::too_many_arguments)] fn exec_submit_signal( deps: DepsMut, env: Env, @@ -170,7 +171,7 @@ fn exec_submit_signal( evidence: Evidence, ) -> Result { // 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, }); @@ -534,6 +535,7 @@ fn exec_invalidate_signal( .add_attribute("rationale", &rationale)) } +#[allow(clippy::too_many_arguments)] fn exec_update_config( deps: DepsMut, info: MessageInfo, @@ -629,7 +631,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..4656f0d 100644 --- a/contracts/service-escrow/src/contract.rs +++ b/contracts/service-escrow/src/contract.rs @@ -764,6 +764,7 @@ fn execute_cancel( Ok(resp) } +#[allow(clippy::too_many_arguments)] fn execute_update_config( deps: DepsMut, info: MessageInfo, arbiter_dao: Option, community_pool: Option, @@ -913,7 +914,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(()) From aee1a7a5c0f844ad0dc631b511573f002d5d40e0 Mon Sep 17 00:00:00 2001 From: brawlaphant Date: Sat, 11 Apr 2026 14:25:39 -0700 Subject: [PATCH 2/2] refactor(contracts): replace too_many_arguments allows with parameter structs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses Gemini review feedback on PR #90 — instead of suppressing clippy::too_many_arguments at five sites, group each function's parameters into a dedicated struct that mirrors the corresponding ExecuteMsg variant. The dispatch blocks forward the destructured fields into the struct in one move, so there is no change in behavior, the tests still pass, and clippy --workspace -- -D warnings stays clean. Sites refactored: * contribution-rewards execute_record_activity → RecordActivityParams * credit-class-voting execute_update_config → UpdateConfigParams * reputation-signal exec_submit_signal → SubmitSignalParams * reputation-signal exec_update_config → UpdateConfigParams * service-escrow execute_update_config → UpdateConfigParams Test suites for all four contracts unchanged and passing (10 + 19 + 38 + 37 = 104 tests). Co-Authored-By: Claude Opus 4.6 (1M context) --- .../contribution-rewards/src/contract.rs | 50 ++++++----- contracts/credit-class-voting/src/contract.rs | 46 ++++++---- contracts/reputation-signal/src/contract.rs | 86 ++++++++++++------- contracts/service-escrow/src/contract.rs | 58 +++++++++---- 4 files changed, 149 insertions(+), 91 deletions(-) diff --git a/contracts/contribution-rewards/src/contract.rs b/contracts/contribution-rewards/src/contract.rs index 9d90270..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, @@ -387,16 +401,10 @@ fn execute_claim_matured( .add_attribute("total", total_return)) } -#[allow(clippy::too_many_arguments)] 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)?; @@ -409,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 a35129f..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, + }, ), } } @@ -557,16 +571,10 @@ fn execute_finalize_proposal( // ── Update Config ───────────────────────────────────────────────────── -#[allow(clippy::too_many_arguments)] 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)?; @@ -576,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)?); } diff --git a/contracts/reputation-signal/src/contract.rs b/contracts/reputation-signal/src/contract.rs index 8327935..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, @@ -159,17 +183,20 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { // Execute handlers // --------------------------------------------------------------------------- -#[allow(clippy::too_many_arguments)] 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 !(1..=5).contains(&endorsement_level) { return Err(ContractError::InvalidEndorsementLevel { @@ -535,17 +562,10 @@ fn exec_invalidate_signal( .add_attribute("rationale", &rationale)) } -#[allow(clippy::too_many_arguments)] 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)?; @@ -553,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; } diff --git a/contracts/service-escrow/src/contract.rs b/contracts/service-escrow/src/contract.rs index 4656f0d..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, + }, ), } } @@ -764,13 +789,10 @@ fn execute_cancel( Ok(resp) } -#[allow(clippy::too_many_arguments)] 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)?; @@ -780,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)?;