Skip to content

Commit

Permalink
Fix various clippy and compilation warnings (#442)
Browse files Browse the repository at this point in the history
In my previous commit I’ve introduced a new build warning.  Motivation for
this commit was to fix it and while I’m at it address some other issues as
well.  However, turns out there’s too many warnings I care to deal with so
this addresses only some of the warnings.
  • Loading branch information
mina86 authored Nov 28, 2023
1 parent f1b4b27 commit 698146a
Show file tree
Hide file tree
Showing 23 changed files with 106 additions and 113 deletions.
4 changes: 2 additions & 2 deletions contracts/pallet-ibc/docs/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct IbcModule<T: Config>(PhantomData<T>);

impl<T: Config> Default for IbcModule<T> {
fn default() -> Self {
Self(PhantomData::default())
Self(PhantomData)
}
}

Expand Down Expand Up @@ -214,7 +214,7 @@ impl<T: Config + Send + Sync> Module for IbcModule<T> {
pub struct WeightHandler<T: Config>(PhantomData<T>);
impl<T: Config> Default for WeightHandler<T> {
fn default() -> Self {
Self(PhantomData::default())
Self(PhantomData)
}
}

Expand Down
22 changes: 11 additions & 11 deletions contracts/pallet-ibc/ping/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pub struct IbcModule<T: Config>(PhantomData<T>);

impl<T: Config> Default for IbcModule<T> {
fn default() -> Self {
Self(PhantomData::default())
Self(PhantomData)
}
}

Expand Down Expand Up @@ -305,48 +305,48 @@ impl<T: Config + Send + Sync> Module for IbcModule<T> {
pub struct WeightHandler<T: Config>(PhantomData<T>);
impl<T: Config> Default for WeightHandler<T> {
fn default() -> Self {
Self(PhantomData::default())
Self(PhantomData)
}
}

impl<T: Config> CallbackWeight for WeightHandler<T> {
fn on_chan_open_init(&self) -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn on_chan_open_try(&self) -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn on_chan_open_ack(&self, _port_id: &PortId, _channel_id: &ChannelId) -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn on_chan_open_confirm(&self, _port_id: &PortId, _channel_id: &ChannelId) -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn on_chan_close_init(&self, _port_id: &PortId, _channel_id: &ChannelId) -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn on_chan_close_confirm(&self, _port_id: &PortId, _channel_id: &ChannelId) -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn on_recv_packet(&self, _packet: &Packet) -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn on_acknowledgement_packet(
&self,
_packet: &Packet,
_acknowledgement: &Acknowledgement,
) -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn on_timeout_packet(&self, _packet: &Packet) -> Weight {
Weight::from_ref_time(0)
Weight::default()
}
}
3 changes: 1 addition & 2 deletions contracts/pallet-ibc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ where
let cs_state = consensus_heights
.into_iter()
.filter(|prev_height| prev_height < &height)
.rev()
.next()
.next_back()
.and_then(|prev_height| self.consensus_state(client_id, prev_height).ok());
Ok(cs_state)
}
Expand Down
45 changes: 22 additions & 23 deletions contracts/pallet-ibc/src/ics20/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub struct IbcModule<T: Config>(PhantomData<T>);

impl<T: Config> Default for IbcModule<T> {
fn default() -> Self {
Self(PhantomData::default())
Self(PhantomData)
}
}

Expand Down Expand Up @@ -468,7 +468,7 @@ pub struct WeightHandler<T: Config>(PhantomData<T>);

impl<T: Config> Default for WeightHandler<T> {
fn default() -> Self {
Self(PhantomData::default())
Self(PhantomData)
}
}

Expand Down Expand Up @@ -640,27 +640,26 @@ pub enum MemoType {
impl Forward {
pub fn get_memo(&self) -> Result<MemoType, Ics20Error> {
if self.substrate.unwrap_or_default() {
let xcm = MemoXcm { receiver: self.receiver.clone(), para_id: self.para_id.clone() };
let xcm = MemoXcm { receiver: self.receiver.clone(), para_id: self.para_id };
return Ok(MemoType::XCM(xcm))
}
let ibc =
MemoIbc {
receiver: self.receiver.clone(),
port: self
.port
.clone()
.ok_or(Ics20Error::implementation_specific("Failed to get port".to_string()))?,
channel: self.channel.clone().ok_or(Ics20Error::implementation_specific(
"Failed to get channel".to_string(),
))?,
timeout: self.timeout.clone().ok_or(Ics20Error::implementation_specific(
"Failed to get timeout".to_string(),
))?,
retries: self.retries.clone().ok_or(Ics20Error::implementation_specific(
"Failed to get retries".to_string(),
))?,
};
return Ok(MemoType::IBC(ibc))
Ok(MemoType::IBC(MemoIbc {
receiver: self.receiver.clone(),
port: self
.port
.clone()
.ok_or(Ics20Error::implementation_specific("Failed to get port".to_string()))?,
channel: self
.channel
.clone()
.ok_or(Ics20Error::implementation_specific("Failed to get channel".to_string()))?,
timeout: self
.timeout
.ok_or(Ics20Error::implementation_specific("Failed to get timeout".to_string()))?,
retries: self
.retries
.ok_or(Ics20Error::implementation_specific("Failed to get retries".to_string()))?,
}))
}
}

Expand Down Expand Up @@ -800,7 +799,7 @@ where
to: account_to.clone(),
para_id: memo_forward.para_id,
amount,
asset_id: asset_id.clone().into(),
asset_id: asset_id.clone(),
});
Ics20Error::implementation_specific(
"Faield to execute SubstrateMultihopXcmHandler::transfer_xcm.".to_string(),
Expand All @@ -812,7 +811,7 @@ where
to: account_to.clone(),
para_id: memo_forward.para_id,
amount,
asset_id: asset_id.clone().into(),
asset_id: asset_id.clone(),
});

return Ok(())
Expand Down
1 change: 0 additions & 1 deletion contracts/pallet-ibc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
overflowing_literals,
path_statements,
patterns_in_fns_without_body,
private_in_public,
unconditional_recursion,
unused_allocation,
unused_comparisons,
Expand Down
2 changes: 1 addition & 1 deletion contracts/pallet-ibc/src/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(crate) struct Context<T: Config> {

impl<T: Config + Send + Sync> Default for Context<T> {
fn default() -> Self {
Self { _pd: PhantomData::default(), router: IbcRouter::default() }
Self { _pd: PhantomData, router: IbcRouter::default() }
}
}

Expand Down
54 changes: 27 additions & 27 deletions contracts/pallet-ibc/src/weight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,111 +46,111 @@ pub trait WeightInfo {

impl WeightInfo for () {
fn create_client() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn conn_open_init() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn update_tendermint_client(i: u32) -> Weight {
Weight::from_ref_time(3 * i as u64 * WEIGHT_REF_TIME_PER_MILLIS)
Weight::from_parts(3 * i as u64 * WEIGHT_REF_TIME_PER_MILLIS, 0)
}

fn conn_try_open_tendermint() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn conn_open_ack_tendermint() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn conn_open_confirm_tendermint() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn channel_open_init() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn channel_open_try_tendermint() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn channel_open_ack_tendermint() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn channel_open_confirm_tendermint() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn channel_close_init() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn channel_close_confirm_tendermint() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn recv_packet_tendermint(_i: u32) -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn ack_packet_tendermint(_i: u32, _j: u32) -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn timeout_packet_tendermint(_i: u32) -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn transfer() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn on_chan_open_init() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn on_chan_open_try() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn on_recv_packet() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn on_chan_open_ack() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn on_chan_open_confirm() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn on_chan_close_init() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn on_chan_close_confirm() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn on_acknowledgement_packet() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn on_timeout_packet() -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn update_grandpa_client(_i: u32, _j: u32) -> Weight {
Weight::from_ref_time(0)
Weight::default()
}

fn packet_cleanup(_i: u32) -> Weight {
Weight::from_ref_time(0)
Weight::default()
}
}

Expand Down
6 changes: 3 additions & 3 deletions hyperspace/core/src/substrate/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use self::parachain_subxt::api::{
};
use super::{unimplemented, DummyBeefyAuthoritySet};
use crate::{
define_any_wrapper, define_beefy_authority_set, define_event_record, define_events,
define_head_data, define_ibc_event_wrapper, define_id, define_para_lifecycle,
define_runtime_call, define_runtime_event, define_runtime_storage, define_runtime_transactions,
define_any_wrapper, define_event_record, define_events, define_head_data,
define_ibc_event_wrapper, define_id, define_para_lifecycle, define_runtime_call,
define_runtime_event, define_runtime_storage, define_runtime_transactions,
define_send_ping_params, define_transfer_params,
};
use async_trait::async_trait;
Expand Down
Loading

0 comments on commit 698146a

Please sign in to comment.