Skip to main content

ve3_shared/extensions/
cosmosmsg_ext.rs

1use cosmwasm_std::{CosmosMsg, StdError, StdResult};
2
3pub trait CosmosMsgExt {
4  fn to_specific<T>(self) -> StdResult<cosmwasm_std::CosmosMsg<T>>;
5}
6
7impl CosmosMsgExt for cosmwasm_std::CosmosMsg {
8  fn to_specific<T>(self) -> StdResult<cosmwasm_std::CosmosMsg<T>> {
9    match self {
10      cosmwasm_std::CosmosMsg::Bank(msg) => Ok(cosmwasm_std::CosmosMsg::Bank(msg)),
11      cosmwasm_std::CosmosMsg::Wasm(msg) => Ok(cosmwasm_std::CosmosMsg::Wasm(msg)),
12      // cosmwasm_std::CosmosMsg::Staking(msg) => Ok(cosmwasm_std::CosmosMsg::Staking(msg)),
13      // cosmwasm_std::CosmosMsg::Distribution(msg) => {
14      //     Ok(cosmwasm_std::CosmosMsg::Distribution(msg))
15      // },
16      cosmwasm_std::CosmosMsg::Ibc(msg) => Ok(cosmwasm_std::CosmosMsg::Ibc(msg)),
17      cosmwasm_std::CosmosMsg::Gov(msg) => Ok(cosmwasm_std::CosmosMsg::Gov(msg)),
18      Self::Stargate {
19        type_url,
20        value,
21      } => Ok(CosmosMsg::<T>::Stargate {
22        type_url,
23        value,
24      }),
25      _ => Err(StdError::generic_err("not supported")),
26    }
27  }
28}