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

Better devX for attested messages in app contracts #55

Merged
merged 2 commits into from
Jun 18, 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
14 changes: 13 additions & 1 deletion cosmwasm/packages/quartz-cw/src/handler/execute/attested.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -71,3 +72,14 @@ where
Handler::handle(attestation, deps, env, info)
}
}

impl<T> Handler for AttestedMsgSansHandler<T> {
fn handle(
self,
_deps: DepsMut<'_>,
_env: &Env,
_info: &MessageInfo,
) -> Result<Response, Error> {
Ok(Response::default())
}
}
33 changes: 33 additions & 0 deletions cosmwasm/packages/quartz-cw/src/msg/execute/attested.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,36 @@ impl Attestation for MockAttestation {
unimplemented!("MockAttestation handler is a noop")
}
}

#[derive(Clone, Debug, PartialEq)]
pub struct AttestedMsgSansHandler<T>(pub T);

#[cw_serde]
pub struct RawAttestedMsgSansHandler<T>(pub T);

impl<T> HasDomainType for RawAttestedMsgSansHandler<T> {
type DomainType = AttestedMsgSansHandler<T>;
}

impl<T> HasUserData for AttestedMsgSansHandler<T>
where
T: HasUserData,
{
fn user_data(&self) -> UserData {
self.0.user_data()
}
}

impl<T> TryFrom<RawAttestedMsgSansHandler<T>> for AttestedMsgSansHandler<T> {
type Error = StdError;

fn try_from(value: RawAttestedMsgSansHandler<T>) -> Result<Self, Self::Error> {
Ok(Self(value.0))
}
}

impl<T> From<AttestedMsgSansHandler<T>> for RawAttestedMsgSansHandler<T> {
fn from(value: AttestedMsgSansHandler<T>) -> Self {
Self(value.0)
}
}
2 changes: 1 addition & 1 deletion utils/mtcs-intent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading