diff --git a/tools/test-framework/src/relayer/transfer.rs b/tools/test-framework/src/relayer/transfer.rs index 4e0002b521..d4ac86aff0 100644 --- a/tools/test-framework/src/relayer/transfer.rs +++ b/tools/test-framework/src/relayer/transfer.rs @@ -8,8 +8,9 @@ use core::time::Duration; use ibc::signer::Signer; use ibc::timestamp::Timestamp; use ibc::Height; +use ibc_proto::google::protobuf::Any; use ibc_relayer::chain::cosmos::types::config::TxConfig; -use ibc_relayer::transfer::build_transfer_message; +use ibc_relayer::transfer::build_transfer_message as raw_build_transfer_message; use crate::error::{handle_generic_error, Error}; use crate::ibc::denom::Denom; @@ -18,6 +19,30 @@ use crate::types::id::{TaggedChannelIdRef, TaggedPortIdRef}; use crate::types::tagged::*; use crate::types::wallet::{Wallet, WalletAddress}; +pub fn build_transfer_message( + port_id: &TaggedPortIdRef<'_, SrcChain, DstChain>, + channel_id: &TaggedChannelIdRef<'_, SrcChain, DstChain>, + sender: &MonoTagged, + recipient: &MonoTagged, + denom: &MonoTagged, + amount: u64, +) -> Result { + let timeout_timestamp = Timestamp::now() + .add(Duration::from_secs(60)) + .map_err(handle_generic_error)?; + + Ok(raw_build_transfer_message( + (*port_id.value()).clone(), + **channel_id.value(), + amount.into(), + denom.value().to_string(), + Signer::new(sender.value().address.0.clone()), + Signer::new(recipient.value().0.clone()), + Height::zero(), + timeout_timestamp, + )) +} + /** Perform a simplified version of IBC token transfer for testing purpose. @@ -44,20 +69,7 @@ pub async fn ibc_token_transfer( denom: &MonoTagged, amount: u64, ) -> Result<(), Error> { - let timeout_timestamp = Timestamp::now() - .add(Duration::from_secs(60)) - .map_err(handle_generic_error)?; - - let message = build_transfer_message( - (*port_id.value()).clone(), - **channel_id.value(), - amount.into(), - denom.value().to_string(), - Signer::new(sender.value().address.0.clone()), - Signer::new(recipient.value().0.clone()), - Height::zero(), - timeout_timestamp, - ); + let message = build_transfer_message(port_id, channel_id, sender, recipient, denom, amount)?; simple_send_tx(tx_config.value(), &sender.value().key, vec![message]).await?;