From 692e72c93c87f7c984fbeed64c260e1397bc0b00 Mon Sep 17 00:00:00 2001 From: gluax <16431709+gluax@users.noreply.github.com> Date: Wed, 3 Jul 2024 11:22:24 -0600 Subject: [PATCH] feat: batch post results --- src/msgs/data_requests/sudo/mod.rs | 20 +++++++++++++++++-- .../sudo/{post_result.rs => post_results.rs} | 6 ++---- src/msgs/data_requests/sudo_tests.rs | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) rename src/msgs/data_requests/sudo/{post_result.rs => post_results.rs} (69%) diff --git a/src/msgs/data_requests/sudo/mod.rs b/src/msgs/data_requests/sudo/mod.rs index 910d575..1e5b16d 100644 --- a/src/msgs/data_requests/sudo/mod.rs +++ b/src/msgs/data_requests/sudo/mod.rs @@ -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 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 for super::SudoMsg { diff --git a/src/msgs/data_requests/sudo/post_result.rs b/src/msgs/data_requests/sudo/post_results.rs similarity index 69% rename from src/msgs/data_requests/sudo/post_result.rs rename to src/msgs/data_requests/sudo/post_results.rs index 554ff2b..1f4ffc4 100644 --- a/src/msgs/data_requests/sudo/post_result.rs +++ b/src/msgs/data_requests/sudo/post_results.rs @@ -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, } impl From for crate::msgs::SudoMsg { fn from(value: Sudo) -> Self { - super::SudoMsg::PostDataResult(value).into() + super::SudoMsg::PostDataResults(value).into() } } diff --git a/src/msgs/data_requests/sudo_tests.rs b/src/msgs/data_requests/sudo_tests.rs index 7748b43..d5ed9b5 100644 --- a/src/msgs/data_requests/sudo_tests.rs +++ b/src/msgs/data_requests/sudo_tests.rs @@ -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,