diff --git a/contracts/interchain-gov/src/handlers/execute.rs b/contracts/interchain-gov/src/handlers/execute.rs index 70abbd0..4c85e2d 100644 --- a/contracts/interchain-gov/src/handlers/execute.rs +++ b/contracts/interchain-gov/src/handlers/execute.rs @@ -1,20 +1,16 @@ use abstract_adapter::objects::chain_name::ChainName; use abstract_adapter::objects::module::ModuleInfo; -use abstract_adapter::sdk::{AbstractSdkResult, Execution, IbcInterface, TransferInterface}; +use abstract_adapter::sdk::{AbstractSdkResult, IbcInterface}; use abstract_adapter::std::ibc::CallbackInfo; use abstract_adapter::std::AbstractResult; use abstract_adapter::traits::AbstractResponse; use abstract_adapter::traits::ModuleIdentification; use base64::Engine; use cosmwasm_std::{ - coins, to_json_binary, CosmosMsg, DepsMut, Env, MessageInfo, Order, StdResult, Storage, SubMsg, - WasmQuery, + to_json_binary, CosmosMsg, DepsMut, Env, MessageInfo, Order, StdResult, Storage, WasmQuery, }; use ibc_sync_state::DataState; -use neutron_query::gov::create_gov_proposal_keys; -use neutron_query::icq::IcqInterface; -use neutron_query::QueryType; use crate::ibc_callbacks::{FINALIZE_CALLBACK_ID, PROPOSE_CALLBACK_ID, REGISTER_VOTE_ID}; use crate::msg::InterchainGovQueryMsg; @@ -22,8 +18,8 @@ use crate::msg::{InterchainGovIbcCallbackMsg, InterchainGovIbcMsg}; use crate::state::{ Governance, GovernanceVote, Members, Proposal, ProposalAction, ProposalId, ProposalMsg, ProposalOutcome, TallyResult, Vote, ALLOW_JOINING_GOV, FINALIZED_PROPOSALS, GOV_VOTE_QUERIES, - MEMBERS, MEMBERS_STATE_SYNC, PENDING_REPLIES, PROPOSAL_STATE_SYNC, - TEMP_REMOTE_GOV_MODULE_ADDRS, VOTE, VOTE_RESULTS, + MEMBERS, MEMBERS_STATE_SYNC, PROPOSAL_STATE_SYNC, TEMP_REMOTE_GOV_MODULE_ADDRS, VOTE, + VOTE_RESULTS, }; use crate::{ contract::{AdapterResult, InterchainGov}, @@ -197,7 +193,7 @@ fn execute_prop( let ibc_client = app.ibc_client(deps.as_ref()); let exec_msg = InterchainGovIbcMsg::ProposalResult { prop_hash: prop_id.clone(), - outcome: outcome, + outcome, }; let mut msgs = vec![]; let target_module = this_module(&app)?; @@ -218,11 +214,11 @@ fn execute_prop( Some(callback.clone()), )?); } - return Ok(app + Ok(app .response("propose_members") .add_messages(msgs) .add_messages(new_member_msgs) - .add_attribute("prop_id", prop_id)); + .add_attribute("prop_id", prop_id)) } /// Reach out to external members and request their local vote results @@ -232,7 +228,7 @@ fn request_vote_results( app: InterchainGov, prop_id: ProposalId, ) -> AdapterResult { - let (prop, state) = load_proposal(deps.storage, &prop_id)?; + let (prop, _state) = load_proposal(deps.storage, &prop_id)?; // We can only tally upon expiration if !prop.expiration.is_expired(&env.block) { @@ -304,7 +300,7 @@ fn request_vote_results( /// REuest external members actual governance vote details fn request_gov_vote_details( deps: DepsMut, - env: Env, + _env: Env, app: InterchainGov, prop_id: ProposalId, ) -> AdapterResult { @@ -385,9 +381,9 @@ fn request_gov_vote_details( } fn check_existing_votes AdapterResult<()>>( - deps: &DepsMut, - prop_id: &ProposalId, - has_all_votes_handler: E, + _deps: &DepsMut, + _prop_id: &ProposalId, + _has_all_votes_handler: E, ) -> AdapterResult<()> { // First, make sure that all votes are in by checking whether we have vote results diff --git a/contracts/interchain-gov/src/handlers/query.rs b/contracts/interchain-gov/src/handlers/query.rs index f675837..2e6e2f5 100644 --- a/contracts/interchain-gov/src/handlers/query.rs +++ b/contracts/interchain-gov/src/handlers/query.rs @@ -8,7 +8,7 @@ use abstract_adapter::objects::chain_name::ChainName; use crate::msg::{ MembersResponse, ProposalResponse, ProposalsResponse, VoteResponse, VoteResultsResponse, }; -use crate::state::{GovernanceVote, ProposalId, MEMBERS, VOTE, VOTE_RESULTS}; +use crate::state::{GovernanceVote, ProposalId, VOTE, VOTE_RESULTS}; use cosmwasm_std::{to_json_binary, Binary, Deps, Env, Order, StdResult}; use ibc_sync_state::DataState; @@ -47,7 +47,7 @@ fn query_proposals(deps: Deps, proposal_ids: Vec) -> AdapterResult StdResult StdResult { +fn query_vote_results( + deps: Deps, + _env: Env, + prop_id: ProposalId, +) -> StdResult { let results = VOTE_RESULTS .prefix(prop_id.clone()) .range(deps.storage, None, None, Order::Ascending) diff --git a/contracts/interchain-gov/src/handlers/sudo.rs b/contracts/interchain-gov/src/handlers/sudo.rs index 626a1ec..39b6d95 100644 --- a/contracts/interchain-gov/src/handlers/sudo.rs +++ b/contracts/interchain-gov/src/handlers/sudo.rs @@ -1,25 +1,19 @@ use abstract_adapter::sdk::AbstractResponse; -use cosmwasm_schema::cw_serde; -use cosmwasm_std::{ - to_json_binary, Binary, DepsMut, Env, MessageInfo, Order, StdError, StdResult, Storage, Uint128, -}; -use cw_storage_plus::Item; + +use cosmwasm_std::{Binary, DepsMut, Env, StdError, Storage}; + use neutron_query::icq::IcqInterface; -use serde::de::DeserializeOwned; -use serde::Serialize; use crate::msg::InterchainGovSudoMsg; -use crate::state::{StorageKey, TallyResult, GOV_VOTE_QUERIES, PENDING_QUERIES}; +use crate::state::{TallyResult, GOV_VOTE_QUERIES, PENDING_QUERIES}; use crate::{ contract::{AdapterResult, InterchainGov}, - msg::InterchainGovInstantiateMsg, - state::{Members, MEMBERS}, InterchainGovError, }; pub fn sudo_handler( deps: DepsMut, - env: Env, + _env: Env, app: InterchainGov, msg: InterchainGovSudoMsg, ) -> AdapterResult { @@ -53,7 +47,7 @@ pub fn sudo_handler( // check the first proposal let prop = gov_props.proposals.first(); - if let Some(prop) = prop.clone() { + if let Some(prop) = prop { if prop.final_tally_result.is_none() { return Err(StdError::generic_err("No final tally result found").into()); }; diff --git a/contracts/interchain-gov/src/ibc_callbacks/vote_result.rs b/contracts/interchain-gov/src/ibc_callbacks/vote_result.rs index 77399c6..01799a2 100644 --- a/contracts/interchain-gov/src/ibc_callbacks/vote_result.rs +++ b/contracts/interchain-gov/src/ibc_callbacks/vote_result.rs @@ -1,6 +1,6 @@ use abstract_adapter::sdk::AbstractResponse; use abstract_adapter::std::ibc::{CallbackResult, IbcResponseMsg}; -use cosmwasm_std::{from_json, to_json_string, DepsMut, Env, MessageInfo, QueryRequest, WasmQuery}; +use cosmwasm_std::{from_json, DepsMut, Env, MessageInfo, QueryRequest, WasmQuery}; use crate::contract::{AdapterResult, InterchainGov}; use crate::msg::{InterchainGovQueryMsg, QueryMsg, VoteResponse}; @@ -12,7 +12,7 @@ use crate::InterchainGovError; pub fn vote_result_callback( deps: DepsMut, _env: Env, - info: MessageInfo, + _info: MessageInfo, app: InterchainGov, ibc_msg: IbcResponseMsg, ) -> AdapterResult { @@ -29,7 +29,10 @@ pub fn vote_result_callback( // Retrieve the prop id from the original message let prop_id = match query { QueryRequest::Wasm(wasm) => match wasm { - WasmQuery::Smart { contract_addr, msg } => { + WasmQuery::Smart { + contract_addr: _, + msg, + } => { let msg: QueryMsg = from_json(msg)?; match msg { QueryMsg::Module(InterchainGovQueryMsg::Vote { prop_id }) => prop_id, @@ -57,7 +60,7 @@ pub fn vote_result_callback( |prev_res| -> Result, InterchainGovError> { match prev_res { Some(prev) => match prev { - Some(prev) => Err(InterchainGovError::ExistingVoteResult { + Some(_prev) => Err(InterchainGovError::ExistingVoteResult { prop_id: prop_id.clone(), chain: chain.clone(), }), @@ -78,8 +81,8 @@ pub fn vote_result_callback( )?; } CallbackResult::Execute { - initiator_msg, - result, + initiator_msg: _, + result: _, } => { unreachable!("vote_result Execute callback") } diff --git a/contracts/interchain-gov/src/replies/icq.rs b/contracts/interchain-gov/src/replies/icq.rs index b501747..b9275fc 100644 --- a/contracts/interchain-gov/src/replies/icq.rs +++ b/contracts/interchain-gov/src/replies/icq.rs @@ -1,10 +1,8 @@ use crate::contract::{AdapterResult, InterchainGov}; use crate::state::{PENDING_QUERIES, PENDING_REPLIES}; -use crate::InterchainGovError; + use abstract_adapter::sdk::AbstractResponse; -use cosmwasm_std::{ - from_json, DepsMut, Env, Reply, StdError, StdResult, SubMsgResponse, SubMsgResult, -}; +use cosmwasm_std::{from_json, DepsMut, Env, Reply, StdError, StdResult, SubMsgResult}; use neutron_query::neutron_sdk::bindings::msg::MsgRegisterInterchainQueryResponse; pub fn icq_reply(deps: DepsMut, _env: Env, app: InterchainGov, reply: Reply) -> AdapterResult { diff --git a/contracts/interchain-gov/src/state.rs b/contracts/interchain-gov/src/state.rs index f502999..cb8b947 100644 --- a/contracts/interchain-gov/src/state.rs +++ b/contracts/interchain-gov/src/state.rs @@ -3,7 +3,7 @@ use std::fmt::Display; use abstract_adapter::objects::chain_name::ChainName; use base64::Engine; use cosmwasm_schema::cw_serde; -use cosmwasm_std::{Addr, Binary, Decimal, Env, Uint128}; +use cosmwasm_std::{Addr, Decimal, Env, Uint128}; use cw_storage_plus::{Item, Map}; use cw_utils::Expiration; use dao_voting::threshold::{PercentageThreshold, Threshold}; @@ -25,7 +25,7 @@ pub type Key = String; // pub const PROPOSAL_STATE: Map<(ProposalId, ChainName), DataState> = Map::new("prop_state"); -pub const MEMBERS_KEY: &'static str = "members"; +pub const MEMBERS_KEY: &str = "members"; pub const MEMBERS: Item = Item::new(MEMBERS_KEY); pub const MEMBERS_STATE_SYNC: MembersSyncState = MembersSyncState::new(); pub const OUTSTANDING_ACKS: Item> = Item::new("acks"); @@ -96,7 +96,7 @@ pub mod members_sync_state { env: &Env, ) -> SyncStateResult { let mut members = self.load_members(storage)?; - members.members.retain(|m| m != &ChainName::new(&env)); + members.members.retain(|m| m != &ChainName::new(env)); Ok(members) } @@ -170,7 +170,7 @@ pub mod members_sync_state { (members, true) } else { let members: Result = match self.load_state_change(storage)? { - StateChange::Proposal(members) => Ok(from_json(&members)?), + StateChange::Proposal(members) => Ok(from_json(members)?), _ => Err(SyncStateError::DataNotFinalized { key: MEMBERS_KEY.to_string(), state: "Backup".to_string(), diff --git a/contracts/interchain-gov/tests/integration.rs b/contracts/interchain-gov/tests/integration.rs index 88cae99..98f3610 100644 --- a/contracts/interchain-gov/tests/integration.rs +++ b/contracts/interchain-gov/tests/integration.rs @@ -1,5 +1,3 @@ -use std::str::FromStr; - use abstract_adapter::objects::chain_name::ChainName; use ibc_sync_state::DataState; use interchain_gov::{ @@ -10,7 +8,7 @@ use interchain_gov::{ }; use abstract_adapter::std::manager::ExecuteMsgFns; -use abstract_adapter::std::{adapter, adapter::AdapterRequestMsg, objects::namespace::Namespace}; +use abstract_adapter::std::{adapter, objects::namespace::Namespace}; use abstract_client::{AbstractClient, Account, Application, Environment, Publisher}; use abstract_cw_orch_polytone::Polytone; // Use prelude to get all the necessary imports @@ -22,7 +20,7 @@ use cw_orch::{anyhow, prelude::*}; use speculoos::prelude::*; use abstract_interchain_tests::setup::ibc_connect_polytone_and_abstract; -use cw_orch::mock::cw_multi_test::AppResponse; + use cw_orch::tokio::runtime::Runtime; use cw_utils::Expiration; use interchain_gov::state::{ProposalAction, ProposalId, ProposalMsg}; @@ -358,7 +356,7 @@ mod query_vote_results { prop_id: prop_id.clone(), })?; - let analysis = interchain.wait_ibc(A_CHAIN_ID, res)?; + let _analysis = interchain.wait_ibc(A_CHAIN_ID, res)?; let vote_results = a_gov.vote_results(prop_id.clone())?; println!("Vote results: {:?}", vote_results); @@ -428,8 +426,8 @@ fn starship_test() -> anyhow::Result<()> { b_env.enable_ibc()?; ibc_connect_polytone_and_abstract(&interchain, A_CHAIN_ID, B_CHAIN_ID)?; - let a_gov = a_env.gov.clone(); - let b_gov = b_env.gov.clone(); + let _a_gov = a_env.gov.clone(); + let _b_gov = b_env.gov.clone(); a_env.execute_gov(InterchainGovExecuteMsg::TestAddMembers { members: vec![b_env.chain_name()].into(), @@ -448,7 +446,7 @@ fn starship_test() -> anyhow::Result<()> { // Finalize a proposal let res = a_env.finalize_proposal(prop_id.clone())?; - let analysis = interchain.wait_ibc(A_CHAIN_ID, res)?; + let _analysis = interchain.wait_ibc(A_CHAIN_ID, res)?; a_env.assert_prop_state(prop_id.clone(), None)?; b_env.assert_prop_state(prop_id, None)?; diff --git a/packages/ibc-sync-state/src/item.rs b/packages/ibc-sync-state/src/item.rs index aac68dc..0aef92b 100644 --- a/packages/ibc-sync-state/src/item.rs +++ b/packages/ibc-sync-state/src/item.rs @@ -103,14 +103,14 @@ impl ItemStateSyncController { ) -> SyncStateResult<()> { let key = key.into(); // remove any of the states - if let Some(change) = self + if let Some(_change) = self .state_status_map .may_load(storage, (key.clone(), DataState::Initiated.to_num()))? { self.state_status_map .remove(storage, (key.clone(), DataState::Initiated.to_num())); - return Ok(()); - } else if let Some(change) = self + Ok(()) + } else if let Some(_change) = self .state_status_map .may_load(storage, (key.clone(), DataState::Proposed.to_num()))? { diff --git a/packages/ibc-sync-state/src/map.rs b/packages/ibc-sync-state/src/map.rs index bff3b59..36969b6 100644 --- a/packages/ibc-sync-state/src/map.rs +++ b/packages/ibc-sync-state/src/map.rs @@ -201,11 +201,7 @@ where self.state_status_map.save( storage, - ( - self.storage_key(), - key.into(), - DataState::Initiated.to_num(), - ), + (self.storage_key(), key, DataState::Initiated.to_num()), &StateChange::Proposal(to_json_binary(&initiated_value)?), )?; self.outstanding_acks.save(storage, &outstanding_acks)?; @@ -236,7 +232,7 @@ where (value, true) } else { let value: Result = match self.load_state_change(storage, k.clone())? { - StateChange::Proposal(value) => Ok(from_json(&value)?), + StateChange::Proposal(value) => Ok(from_json(value)?), _ => Err(SyncStateError::DataNotFinalized { key: k.to_string(), state: "Backup".to_string(),