Skip to content

Commit

Permalink
[Cosmos]: Test Stride messages
Browse files Browse the repository at this point in the history
  • Loading branch information
satoshiotomakan committed Nov 13, 2023
1 parent 3542500 commit b31e4b1
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 306 deletions.
6 changes: 3 additions & 3 deletions rust/tw_cosmos_sdk/src/modules/tx_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,15 +585,15 @@ where
}

pub fn stride_redeem_msg_from_proto(
coin: &dyn CoinContext,
_coin: &dyn CoinContext,
redeem: &Proto::mod_Message::MsgStrideLiquidStakingRedeem<'_>,
) -> SigningResult<CosmosMessageBox> {
use crate::transaction::message::stride_message::StrideLiquidRedeemMessage;

let msg = StrideLiquidRedeemMessage {
creator: Address::from_str_with_coin(coin, &redeem.creator)?,
creator: redeem.creator.to_string(),
amount: U256::from_str(&redeem.amount)?,
receiver: Address::from_str_with_coin(coin, &redeem.receiver)?,
receiver: redeem.receiver.to_string(),
host_zone: redeem.host_zone.to_string(),
};
Ok(msg.into_boxed())
Expand Down
12 changes: 6 additions & 6 deletions rust/tw_cosmos_sdk/src/transaction/message/stride_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ impl<Address: CosmosAddress> CosmosMessage for StrideLiquidStakeMessage<Address>
}
}

pub struct StrideLiquidRedeemMessage<Address: CosmosAddress> {
pub creator: Address,
pub struct StrideLiquidRedeemMessage {
pub creator: String,
pub amount: U256,
pub receiver: Address,
pub receiver: String,
pub host_zone: String,
}

impl<Address: CosmosAddress> CosmosMessage for StrideLiquidRedeemMessage<Address> {
impl CosmosMessage for StrideLiquidRedeemMessage {
fn to_proto(&self) -> SigningResult<ProtobufMessage> {
let proto_msg = stride::stakeibc::MsgRedeemStake {
creator: self.creator.to_string(),
creator: self.creator.clone(),
amount: self.amount.to_string(),
receiver: self.receiver.to_string(),
receiver: self.receiver.clone(),
host_zone: self.host_zone.clone(),
};
Ok(to_any(&proto_msg))
Expand Down
2 changes: 1 addition & 1 deletion rust/tw_cosmos_sdk/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod message;
use message::CosmosMessageBox;

/// At this moment, TW only supports the Direct signing mode.
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy)]
pub enum SignMode {
Direct,
}
Expand Down
Loading

0 comments on commit b31e4b1

Please sign in to comment.