diff --git a/crates/overflow-receive/src/lib.rs b/crates/overflow-receive/src/lib.rs index df70d32..f344fd9 100644 --- a/crates/overflow-receive/src/lib.rs +++ b/crates/overflow-receive/src/lib.rs @@ -100,14 +100,14 @@ pub trait OverflowRecvContext { /// Mint coins. fn mint_coins_execute( &mut self, - receiver: &Signer, + receiver: &::AccountId, coin: &Coin, ) -> Result<(), Self::Error>; /// Unescrow coins. fn unescrow_coins_execute( &mut self, - receiver: &Signer, + receiver: &::AccountId, port: &PortId, channel: &ChannelId, coin: &Coin, @@ -163,9 +163,9 @@ where let (override_amount, remainder_amount) = match transfer_pkt .token .amount - .checked_sub(*orm_metadata.target_amount()) + .checked_sub((*orm_metadata.target_amount()).into()) { - Some(amt) if *amt != [0u64, 0, 0, 0] => (*orm_metadata.target_amount(), amt), + Some(amt) if *amt != [0u64, 0, 0, 0] => ((*orm_metadata.target_amount()).into(), amt), Some(_ /* = 0 */) => return Err(MiddlewareError::ForwardToNextMiddleware), None => { return Err(MiddlewareError::Message(format!( diff --git a/crates/overflow-receive/src/msg.rs b/crates/overflow-receive/src/msg.rs index 3e81bbd..9d080b4 100644 --- a/crates/overflow-receive/src/msg.rs +++ b/crates/overflow-receive/src/msg.rs @@ -1,4 +1,5 @@ use alloc::string::String; +use core::fmt::Display; use ibc_app_transfer_types::Amount; use ibc_primitives::Signer; @@ -6,6 +7,12 @@ use ibc_primitives::Signer; /// Metadata included in ICS-20 packet memos, /// related with the overflow receive middleware. pub trait PacketMetadata { + /// Account identifier. + type AccountId: Display + Into; + + /// Amount type. + type Amount: Copy + Display + Into; + /// Determine if the value `msg` is a valid `PacketMetadata`. fn is_overflow_receive_msg(msg: &serde_json::Map) -> bool; @@ -16,9 +23,9 @@ pub trait PacketMetadata { /// Account that shall receive the funds in case of an /// overflow. - fn overflow_receiver(&self) -> &Signer; + fn overflow_receiver(&self) -> &Self::AccountId; /// The target amount that the original receiver will /// receive. - fn target_amount(&self) -> &Amount; + fn target_amount(&self) -> &Self::Amount; } diff --git a/crates/overflow-receive/src/tests/utils.rs b/crates/overflow-receive/src/tests/utils.rs index 38e7d42..3468e1c 100644 --- a/crates/overflow-receive/src/tests/utils.rs +++ b/crates/overflow-receive/src/tests/utils.rs @@ -46,6 +46,9 @@ pub struct OverflowReceiveMetadata { } impl msg::PacketMetadata for OrmPacketMetadata { + type AccountId = Signer; + type Amount = Amount; + fn is_overflow_receive_msg(msg: &serde_json::Map) -> bool { msg.contains_key("overflow_receive") }