diff --git a/src/contract.rs b/src/contract.rs index 86ba3e68..151d401b 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -1,8 +1,5 @@ //! This module handles the execution logic of the contract. -// Clippy pedantic is disabled for `entry_point` functions since they require a certain signature. -#![allow(clippy::pedantic)] - use cosmwasm_std::entry_point; use cosmwasm_std::{to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult}; @@ -16,6 +13,7 @@ use crate::types::ContractError; /// Instantiates the contract. #[entry_point] +#[allow(clippy::pedantic)] pub fn instantiate( deps: DepsMut, env: Env, @@ -55,6 +53,7 @@ pub fn instantiate( /// Handles the execution of the contract. #[entry_point] +#[allow(clippy::pedantic)] pub fn execute( deps: DepsMut, env: Env, @@ -84,6 +83,7 @@ pub fn execute( /// Handles the query of the contract. #[entry_point] +#[allow(clippy::pedantic)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::GetContractState {} => to_json_binary(&query::state(deps)?), @@ -95,6 +95,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { /// Migrate contract if version is lower than current version #[entry_point] +#[allow(clippy::pedantic)] pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { migrate::validate_semver(deps.as_ref())?; @@ -108,9 +109,13 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result StdResult { @@ -210,7 +221,7 @@ mod query { } mod migrate { - use super::*; + use super::{ContractError, Deps, CONTRACT_NAME, CONTRACT_VERSION}; pub fn validate_semver(deps: Deps) -> Result<(), ContractError> { let prev_cw2_version = cw2::get_contract_version(deps.storage)?; @@ -225,7 +236,7 @@ mod migrate { let prev_version: semver::Version = prev_cw2_version.version.parse()?; if prev_version >= version { return Err(ContractError::InvalidMigrationVersion { - expected: format!("> {}", prev_version), + expected: format!("> {prev_version}"), actual: CONTRACT_VERSION.to_string(), }); } @@ -306,7 +317,7 @@ mod tests { // Ensure the contract admin can send custom messages let custom_msg_str = r#"{"@type": "/cosmos.bank.v1beta1.MsgSend", "from_address": "cosmos15ulrf36d4wdtrtqzkgaan9ylwuhs7k7qz753uk", "to_address": "cosmos15ulrf36d4wdtrtqzkgaan9ylwuhs7k7qz753uk", "amount": [{"denom": "stake", "amount": "5000"}]}"#; - let messages_str = format!(r#"{{"messages": [{}]}}"#, custom_msg_str); + let messages_str = format!(r#"{{"messages": [{custom_msg_str}]}}"#); let base64_json_messages = base64::encode(messages_str.as_bytes()); let messages = Binary::from_base64(&base64_json_messages).unwrap(); @@ -428,10 +439,7 @@ mod tests { let res = migrate(deps.as_mut(), mock_env(), MigrateMsg {}); assert_eq!( res.unwrap_err().to_string(), - format!( - "invalid migration version: expected > 100.0.0, got {}", - CONTRACT_VERSION - ) + format!("invalid migration version: expected > 100.0.0, got {CONTRACT_VERSION}") ); } } diff --git a/src/ibc/handshake.rs b/src/ibc/handshake.rs index f13d8953..4dc86638 100644 --- a/src/ibc/handshake.rs +++ b/src/ibc/handshake.rs @@ -1,8 +1,5 @@ //! This module contains the entry points for the IBC handshake. -// Clippy pedantic is disabled for `entry_point` functions since they require a certain signature. -#![allow(clippy::pedantic)] - use cosmwasm_std::entry_point; use cosmwasm_std::{ DepsMut, Env, Ibc3ChannelOpenResponse, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, @@ -18,6 +15,7 @@ use crate::types::{ /// Handles the `OpenInit` and `OpenTry` parts of the IBC handshake. /// In this application, we only handle `OpenInit` messages since we are the ICA controller #[entry_point] +#[allow(clippy::pedantic)] pub fn ibc_channel_open( deps: DepsMut, _env: Env, @@ -32,6 +30,7 @@ pub fn ibc_channel_open( /// Handles the `OpenAck` and `OpenConfirm` parts of the IBC handshake. /// In this application, we only handle `OpenAck` messages since we are the ICA controller #[entry_point] +#[allow(clippy::pedantic)] pub fn ibc_channel_connect( deps: DepsMut, _env: Env, @@ -48,6 +47,7 @@ pub fn ibc_channel_connect( /// Handles the `ChanCloseInit` and `ChanCloseConfirm` for the IBC module. #[entry_point] +#[allow(clippy::pedantic)] pub fn ibc_channel_close( deps: DepsMut, _env: Env, @@ -62,9 +62,14 @@ pub fn ibc_channel_close( mod ibc_channel_open { use crate::types::callbacks::IcaControllerCallbackMsg; - use super::*; + use super::{ + ChannelState, ContractError, DepsMut, Ibc3ChannelOpenResponse, IbcBasicResponse, + IbcChannel, IbcChannelOpenResponse, IbcOrder, IcaMetadata, CHANNEL_STATE, HOST_PORT_ID, + STATE, + }; /// Handles the `OpenInit` part of the IBC handshake. + #[allow(clippy::needless_pass_by_value)] pub fn init( deps: DepsMut, channel: IbcChannel, @@ -121,6 +126,7 @@ mod ibc_channel_open { } /// Handles the `OpenAck` part of the IBC handshake. + #[allow(clippy::needless_pass_by_value)] pub fn on_acknowledgement( deps: DepsMut, mut channel: IbcChannel, @@ -182,8 +188,10 @@ mod ibc_channel_open { } mod ibc_channel_close { - use super::*; + use super::{ContractError, DepsMut, IbcBasicResponse, IbcChannel, CHANNEL_STATE}; + /// Handles the `ChanCloseConfirm` for the IBC module. + #[allow(clippy::needless_pass_by_value)] pub fn confirm(deps: DepsMut, channel: IbcChannel) -> Result { // Validate that this is the stored channel let mut channel_state = CHANNEL_STATE.load(deps.storage)?; diff --git a/src/ibc/relay.rs b/src/ibc/relay.rs index dccf5bc7..6708af28 100644 --- a/src/ibc/relay.rs +++ b/src/ibc/relay.rs @@ -3,9 +3,6 @@ //! - The IBC packet timeout. //! - The IBC packet receive. -// Clippy pedantic is disabled for `entry_point` functions since they require a certain signature. -#![allow(clippy::pedantic)] - use cosmwasm_std::entry_point; use cosmwasm_std::{ from_json, DepsMut, Env, IbcBasicResponse, IbcPacketAckMsg, IbcPacketReceiveMsg, @@ -21,6 +18,7 @@ use super::types::{events, packet::acknowledgement::Data as AcknowledgementData} /// Implements the IBC module's `OnAcknowledgementPacket` handler. #[entry_point] +#[allow(clippy::pedantic)] pub fn ibc_packet_ack( deps: DepsMut, _env: Env, @@ -39,6 +37,7 @@ pub fn ibc_packet_ack( /// Implements the IBC module's `OnTimeoutPacket` handler. #[entry_point] +#[allow(clippy::pedantic)] pub fn ibc_packet_timeout( deps: DepsMut, _env: Env, @@ -58,6 +57,7 @@ pub fn ibc_packet_timeout( /// Handles the `PacketReceive` for the IBC module. #[entry_point] +#[allow(clippy::pedantic)] pub fn ibc_packet_receive( _deps: DepsMut, _env: Env, @@ -76,10 +76,11 @@ mod ibc_packet_ack { state::{CALLBACK_COUNTER, STATE}, }; - use super::*; + use super::{events, AcknowledgementData, ContractError, DepsMut, IbcBasicResponse}; /// Handles the successful acknowledgement of an ica packet. This means that the /// transaction was successfully executed on the host chain. + #[allow(clippy::needless_pass_by_value)] pub fn success( deps: DepsMut, packet: IbcPacket, @@ -113,6 +114,7 @@ mod ibc_packet_ack { /// Handles the unsuccessful acknowledgement of an ica packet. This means that the /// transaction failed to execute on the host chain. + #[allow(clippy::needless_pass_by_value)] pub fn error( deps: DepsMut, packet: IbcPacket, @@ -150,9 +152,10 @@ mod ibc_packet_timeout { use crate::types::{callbacks::IcaControllerCallbackMsg, state::STATE}; - use super::*; + use super::{ContractError, DepsMut, IbcBasicResponse, CALLBACK_COUNTER}; /// Handles the timeout callbacks. + #[allow(clippy::needless_pass_by_value)] pub fn callback( deps: DepsMut, packet: IbcPacket, diff --git a/src/types/state.rs b/src/types/state.rs index 8968c4d2..0d903766 100644 --- a/src/types/state.rs +++ b/src/types/state.rs @@ -23,10 +23,12 @@ pub const CALLBACK_COUNTER: Item = Item::new("callback_counter" mod contract { use crate::ibc::types::metadata::TxEncoding; + use cosmwasm_schema::schemars::JsonSchema; + use super::{cw_serde, Addr, ContractError}; /// State is the state of the contract. - #[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq)] + #[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[allow(clippy::derive_partial_eq_without_eq)] pub struct State { /// The Interchain Account (ICA) info needed to send packets.