Skip to content

Commit 99f2974

Browse files
authored
Better devX for attested messages in app contracts (#55)
1 parent 3509edf commit 99f2974

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

cosmwasm/packages/quartz-cw/src/handler/execute/attested.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use crate::{
55
error::Error,
66
handler::Handler,
77
msg::execute::attested::{
8-
Attestation, Attested, EpidAttestation, HasUserData, MockAttestation,
8+
Attestation, Attested, AttestedMsgSansHandler, EpidAttestation, HasUserData,
9+
MockAttestation,
910
},
1011
state::CONFIG,
1112
};
@@ -71,3 +72,14 @@ where
7172
Handler::handle(attestation, deps, env, info)
7273
}
7374
}
75+
76+
impl<T> Handler for AttestedMsgSansHandler<T> {
77+
fn handle(
78+
self,
79+
_deps: DepsMut<'_>,
80+
_env: &Env,
81+
_info: &MessageInfo,
82+
) -> Result<Response, Error> {
83+
Ok(Response::default())
84+
}
85+
}

cosmwasm/packages/quartz-cw/src/msg/execute/attested.rs

+33
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,36 @@ impl Attestation for MockAttestation {
171171
unimplemented!("MockAttestation handler is a noop")
172172
}
173173
}
174+
175+
#[derive(Clone, Debug, PartialEq)]
176+
pub struct AttestedMsgSansHandler<T>(pub T);
177+
178+
#[cw_serde]
179+
pub struct RawAttestedMsgSansHandler<T>(pub T);
180+
181+
impl<T> HasDomainType for RawAttestedMsgSansHandler<T> {
182+
type DomainType = AttestedMsgSansHandler<T>;
183+
}
184+
185+
impl<T> HasUserData for AttestedMsgSansHandler<T>
186+
where
187+
T: HasUserData,
188+
{
189+
fn user_data(&self) -> UserData {
190+
self.0.user_data()
191+
}
192+
}
193+
194+
impl<T> TryFrom<RawAttestedMsgSansHandler<T>> for AttestedMsgSansHandler<T> {
195+
type Error = StdError;
196+
197+
fn try_from(value: RawAttestedMsgSansHandler<T>) -> Result<Self, Self::Error> {
198+
Ok(Self(value.0))
199+
}
200+
}
201+
202+
impl<T> From<AttestedMsgSansHandler<T>> for RawAttestedMsgSansHandler<T> {
203+
fn from(value: AttestedMsgSansHandler<T>) -> Self {
204+
Self(value.0)
205+
}
206+
}

utils/mtcs-intent/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ clap.workspace = true
1616
ecies.workspace = true
1717
hex.workspace = true
1818
k256.workspace = true
19-
rand.workspace = true
19+
rand = { workspace = true, default-features = true }
2020
serde.workspace = true
2121
serde_json.workspace = true
2222
sha2.workspace = true

0 commit comments

Comments
 (0)