From 99f2974869f51caea4c116b845a0e4e0f95d5dd3 Mon Sep 17 00:00:00 2001 From: Shoaib Ahmed Date: Tue, 18 Jun 2024 13:15:32 -0700 Subject: [PATCH] Better devX for attested messages in app contracts (#55) --- .../quartz-cw/src/handler/execute/attested.rs | 14 +++++++- .../quartz-cw/src/msg/execute/attested.rs | 33 +++++++++++++++++++ utils/mtcs-intent/Cargo.toml | 2 +- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/cosmwasm/packages/quartz-cw/src/handler/execute/attested.rs b/cosmwasm/packages/quartz-cw/src/handler/execute/attested.rs index f49d1aa..db6ee07 100644 --- a/cosmwasm/packages/quartz-cw/src/handler/execute/attested.rs +++ b/cosmwasm/packages/quartz-cw/src/handler/execute/attested.rs @@ -5,7 +5,8 @@ use crate::{ error::Error, handler::Handler, msg::execute::attested::{ - Attestation, Attested, EpidAttestation, HasUserData, MockAttestation, + Attestation, Attested, AttestedMsgSansHandler, EpidAttestation, HasUserData, + MockAttestation, }, state::CONFIG, }; @@ -71,3 +72,14 @@ where Handler::handle(attestation, deps, env, info) } } + +impl Handler for AttestedMsgSansHandler { + fn handle( + self, + _deps: DepsMut<'_>, + _env: &Env, + _info: &MessageInfo, + ) -> Result { + Ok(Response::default()) + } +} diff --git a/cosmwasm/packages/quartz-cw/src/msg/execute/attested.rs b/cosmwasm/packages/quartz-cw/src/msg/execute/attested.rs index 125abf6..b102ff3 100644 --- a/cosmwasm/packages/quartz-cw/src/msg/execute/attested.rs +++ b/cosmwasm/packages/quartz-cw/src/msg/execute/attested.rs @@ -171,3 +171,36 @@ impl Attestation for MockAttestation { unimplemented!("MockAttestation handler is a noop") } } + +#[derive(Clone, Debug, PartialEq)] +pub struct AttestedMsgSansHandler(pub T); + +#[cw_serde] +pub struct RawAttestedMsgSansHandler(pub T); + +impl HasDomainType for RawAttestedMsgSansHandler { + type DomainType = AttestedMsgSansHandler; +} + +impl HasUserData for AttestedMsgSansHandler +where + T: HasUserData, +{ + fn user_data(&self) -> UserData { + self.0.user_data() + } +} + +impl TryFrom> for AttestedMsgSansHandler { + type Error = StdError; + + fn try_from(value: RawAttestedMsgSansHandler) -> Result { + Ok(Self(value.0)) + } +} + +impl From> for RawAttestedMsgSansHandler { + fn from(value: AttestedMsgSansHandler) -> Self { + Self(value.0) + } +} diff --git a/utils/mtcs-intent/Cargo.toml b/utils/mtcs-intent/Cargo.toml index ef3dd91..161838e 100644 --- a/utils/mtcs-intent/Cargo.toml +++ b/utils/mtcs-intent/Cargo.toml @@ -16,7 +16,7 @@ clap.workspace = true ecies.workspace = true hex.workspace = true k256.workspace = true -rand.workspace = true +rand = { workspace = true, default-features = true } serde.workspace = true serde_json.workspace = true sha2.workspace = true