Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: batch post results #12

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/msgs/data_requests/sudo/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
use super::*;

pub mod post_result;
pub mod post_results;

#[cfg_attr(feature = "cosmwasm", cw_serde)]
#[cfg_attr(not(feature = "cosmwasm"), derive(serde::Serialize))]
#[cfg_attr(not(feature = "cosmwasm"), serde(rename_all = "snake_case"))]
pub struct PostResult {
pub dr_id: String,
pub result: DataResult,
pub exit_code: u8,
}

impl From<PostResult> for crate::msgs::SudoMsg {
fn from(value: PostResult) -> Self {
SudoMsg::PostDataResult(value).into()
}
}

#[cfg_attr(feature = "cosmwasm", cw_serde)]
#[cfg_attr(not(feature = "cosmwasm"), derive(serde::Serialize))]
#[cfg_attr(not(feature = "cosmwasm"), serde(rename_all = "snake_case"))]
pub enum SudoMsg {
PostDataResult(post_result::Sudo),
PostDataResult(PostResult),
PostDataResults(post_results::Sudo),
}

impl From<SudoMsg> for super::SudoMsg {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ use super::*;
#[cfg_attr(not(feature = "cosmwasm"), derive(serde::Serialize))]
#[cfg_attr(not(feature = "cosmwasm"), serde(rename_all = "snake_case"))]
pub struct Sudo {
pub dr_id: String,
pub result: DataResult,
pub exit_code: u8,
pub results: Vec<PostResult>,
}

impl From<Sudo> for crate::msgs::SudoMsg {
fn from(value: Sudo) -> Self {
super::SudoMsg::PostDataResult(value).into()
super::SudoMsg::PostDataResults(value).into()
}
}
2 changes: 1 addition & 1 deletion src/msgs/data_requests/sudo_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn json_post_result() {
"exit_code": 0,
}
});
let msg: SudoMsg = post_result::Sudo {
let msg: SudoMsg = PostResult {
dr_id: "dr_id".to_string(),
result,
exit_code: 0,
Expand Down