Skip to content

Commit

Permalink
Misc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sug0 committed Nov 29, 2024
1 parent 57dd521 commit 0cf7093
Showing 1 changed file with 5 additions and 38 deletions.
43 changes: 5 additions & 38 deletions crates/ibc/src/context/pfm_mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -92,9 +93,9 @@ impl<C: IbcCommonContext + Debug, Params> Debug
for PfmTransferModule<C, Params>
{
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()
}
}

Expand Down Expand Up @@ -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<PrefixedDenom, Self::Error> {
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<T> ModuleWrapper for PacketForwardMiddleware<T>
Expand Down

0 comments on commit 0cf7093

Please sign in to comment.