Skip to content

Commit

Permalink
Test CosmosMsg::Custom
Browse files Browse the repository at this point in the history
Plus remove reflect_test.go which will never be used that way because we never allow CustomMsg
  • Loading branch information
assafmo committed Jul 13, 2022
1 parent f541956 commit 6ce26f9
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 464 deletions.
23 changes: 8 additions & 15 deletions cosmwasm/enclaves/shared/cosmwasm-v010-types/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub struct ContractResult {
#[serde(rename_all = "snake_case")]
// This should be in correlation with cosmwasm-std/init_handle's CosmosMsg
// See https://github.com/serde-rs/serde/issues/1296 why we cannot add De-Serialize trait bounds to T
pub enum CosmosMsg<T = CustomMsg>
pub enum CosmosMsg<T = Empty>
where
T: Clone + fmt::Debug + PartialEq,
{
Expand All @@ -154,21 +154,14 @@ where
Gov(GovMsg),
}

/// Added this here for reflect tests....
/// An empty struct that serves as a placeholder in different places,
/// such as contracts that don't set a custom message.
///
/// It is designed to be expressable in correct JSON and JSON Schema but
/// contains no meaningful data. Previously we used enums without cases,
/// but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[serde(rename_all = "snake_case")]
/// CustomMsg is an override of CosmosMsg::Custom to show this works and can be extended in the contract
pub enum CustomMsg {
Debug(String),
Raw(Binary),
Empty {},
}

impl Into<CosmosMsg<CustomMsg>> for CustomMsg {
fn into(self) -> CosmosMsg<CustomMsg> {
CosmosMsg::Custom(self)
}
}
pub struct Empty {}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[serde(rename_all = "snake_case")]
Expand Down
Loading

0 comments on commit 6ce26f9

Please sign in to comment.