From 0cf709328415cf33f310f92f4258280d14d4b7bc Mon Sep 17 00:00:00 2001 From: Tiago Carvalho Date: Fri, 29 Nov 2024 14:06:48 +0000 Subject: [PATCH] Misc changes --- crates/ibc/src/context/pfm_mod.rs | 43 ++++--------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/crates/ibc/src/context/pfm_mod.rs b/crates/ibc/src/context/pfm_mod.rs index 2e67bd2d0b5..e747a9d74c0 100644 --- a/crates/ibc/src/context/pfm_mod.rs +++ b/crates/ibc/src/context/pfm_mod.rs @@ -1,4 +1,5 @@ -//! Implementation of Packet Forward Middleware for our IBC modules. +//! Implementation of Packet Forward Middleware on top of the ICS-20 +//! [`TransferModule`]. use std::cell::RefCell; use std::collections::BTreeSet; @@ -44,7 +45,7 @@ use crate::{ TokenTransferContext, }; -const MIDDLEWARES_SUBKEY: &str = "middlewarez"; +const MIDDLEWARES_SUBKEY: &str = "middleware"; const PFM_SUBKEY: &str = "pfm"; /// Get the Namada storage key associated to the provided `InFlightPacketKey`. @@ -92,9 +93,9 @@ impl Debug for PfmTransferModule { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - f.debug_struct("PfmTransferModule") + f.debug_struct(stringify!(PfmTransferModule)) .field("transfer_module", &self.transfer_module) - .finish() + .finish_non_exhaustive() } } @@ -503,40 +504,6 @@ where let key = get_inflight_packet_key(key); ctx.storage_mut().delete(&key).map_err(Error::Storage) } - - fn get_denom_for_this_chain( - &self, - this_chain_port: &PortId, - this_chain_chan: &ChannelId, - source_port: &PortId, - source_chan: &ChannelId, - source_denom: &PrefixedDenom, - ) -> Result { - let mut new_denom = source_denom.clone(); - // We will see this prefix on the asset if it is Namada native - let native_prefix = - TracePrefix::new(source_port.clone(), source_chan.clone()); - if source_denom.trace_path.starts_with(&native_prefix) { - // this asset originated from this chain; unwind - new_denom.trace_path.remove_prefix(&native_prefix); - } else { - // this asset originated from a foreign chain; add a new hop - new_denom.trace_path.add_prefix(TracePrefix::new( - this_chain_port.clone(), - this_chain_chan.clone(), - )); - } - tracing::debug!( - ?new_denom, - ?this_chain_port, - ?this_chain_chan, - ?source_port, - ?source_chan, - ?source_denom, - "PFM get_denom_for_this_chain" - ); - Ok(new_denom) - } } impl ModuleWrapper for PacketForwardMiddleware