Skip to content

Commit

Permalink
Support cosmos redelegate transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
gemcoder21 committed Jan 17, 2024
1 parent efaf43c commit 6f16094
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions blockchain/src/cosmos/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use sha2::{Digest, Sha256};

const MESSAGE_DELEGATE: &str = "/cosmos.staking.v1beta1.MsgDelegate";
const MESSAGE_UNDELEGATE: &str = "/cosmos.staking.v1beta1.MsgUndelegate";
const MESSAGE_REDELEGATE: &str = "/cosmos.staking.v1beta1.MsgBeginRedelegate";
const MESSAGE_SEND_BETA: &str = "/cosmos.bank.v1beta1.MsgSend";
const MESSAGE_REWARD_BETA: &str = "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward";
const MESSAGE_SEND: &str = "/types.MsgSend"; // thorchain
Expand All @@ -21,6 +22,7 @@ const MESSAGES: &[&str] = &[
MESSAGE_SEND_BETA,
MESSAGE_DELEGATE,
MESSAGE_UNDELEGATE,
MESSAGE_REDELEGATE,
MESSAGE_REWARD_BETA,
];

Expand Down Expand Up @@ -164,6 +166,15 @@ impl CosmosClient {
from_address = message.delegator_address;
to_address = message.validator_address;
}
MESSAGE_REDELEGATE => {
let message: cosmos_sdk_proto::cosmos::staking::v1beta1::MsgBeginRedelegate =
cosmos_sdk_proto::prost::Message::decode(&*message.value).ok()?;

transaction_type = TransactionType::StakeRedelegate;
value = message.amount?.amount.clone();
from_address = message.delegator_address;
to_address = message.validator_dst_address;
}
MESSAGE_REWARD_BETA => {
let message: cosmos_sdk_proto::cosmos::distribution::v1beta1::MsgWithdrawDelegatorReward =
cosmos_sdk_proto::prost::Message::decode(&*message.value).ok()?;
Expand Down

0 comments on commit 6f16094

Please sign in to comment.