Skip to content

Commit

Permalink
refactor: change to enum var so on contract side code is the same
Browse files Browse the repository at this point in the history
  • Loading branch information
gluax committed Oct 1, 2024
1 parent 3afe6b5 commit 8becdd7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/msgs/data_requests/sudo/expire_data_requests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#[cfg_attr(feature = "cosmwasm", cosmwasm_schema::cw_serde)]
#[cfg_attr(not(feature = "cosmwasm"), derive(serde::Serialize, Debug, PartialEq))]
#[cfg_attr(not(feature = "cosmwasm"), serde(rename_all = "snake_case"))]
pub struct Sudo {}

impl From<Sudo> for crate::msgs::SudoMsg {
fn from(value: Sudo) -> Self {
super::SudoMsg::ExpireDataRequests(value).into()
}
}
3 changes: 2 additions & 1 deletion src/msgs/data_requests/sudo/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::*;

pub mod expire_data_requests;
pub mod post_results;

#[cfg_attr(feature = "cosmwasm", cw_serde)]
Expand All @@ -23,7 +24,7 @@ impl From<PostResult> for crate::msgs::SudoMsg {
pub enum SudoMsg {
PostDataResult(PostResult),
PostDataResults(post_results::Sudo),
ExpireDataRequests,
ExpireDataRequests(expire_data_requests::Sudo),
}

impl From<SudoMsg> for super::SudoMsg {
Expand Down
4 changes: 2 additions & 2 deletions src/msgs/data_requests/sudo_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ fn json_post_result() {

#[test]
fn json_remove_timed_out_data_requests() {
let expected_json = json!("expire_data_requests");
let msg: SudoMsg = data_requests::sudo::SudoMsg::ExpireDataRequests.into();
let expected_json = json!({"expire_data_requests": {}});
let msg: SudoMsg = expire_data_requests::Sudo {}.into();
#[cfg(not(feature = "cosmwasm"))]
assert_json_ser(msg, expected_json);
#[cfg(feature = "cosmwasm")]
Expand Down

0 comments on commit 8becdd7

Please sign in to comment.