Move utils/quartz-proto to core/quartz-proto Fix Cargo.toml paths Add default working-directory for cosmwasm CI jobs Fix default working-directory Rename .cargo/config -> config.toml Update working-directory Update cosmwasm workflows Update rust.yml paths Add aliases to cargo config.toml Test working-directory Update cosmwasm CI jobs Use --manifest-path Use dtolnay/rust-toolchain action Fix workflow Remove --locked SSH agent SSH agent for schema Remove unused SSH key Exclude cw-tee-mtcs from rust CI jobs Clippy fix cargo fmt Add CONTRIBUTING.md Update README.md
57 lines
1.1 KiB
Rust
57 lines
1.1 KiB
Rust
use cosmwasm_schema::cw_serde;
|
|
use cosmwasm_std::{HexBinary, StdError};
|
|
|
|
use crate::{
|
|
msg::{execute::attested::HasUserData, HasDomainType},
|
|
state::{Nonce, UserData},
|
|
};
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
pub struct SessionCreate {
|
|
nonce: Nonce,
|
|
}
|
|
|
|
impl SessionCreate {
|
|
pub fn new(nonce: Nonce) -> Self {
|
|
Self { nonce }
|
|
}
|
|
|
|
pub fn into_nonce(self) -> Nonce {
|
|
self.nonce
|
|
}
|
|
}
|
|
|
|
#[cw_serde]
|
|
pub struct RawSessionCreate {
|
|
nonce: HexBinary,
|
|
}
|
|
|
|
impl TryFrom<RawSessionCreate> for SessionCreate {
|
|
type Error = StdError;
|
|
|
|
fn try_from(value: RawSessionCreate) -> Result<Self, Self::Error> {
|
|
let nonce = value.nonce.to_array()?;
|
|
Ok(Self { nonce })
|
|
}
|
|
}
|
|
|
|
impl From<SessionCreate> for RawSessionCreate {
|
|
fn from(value: SessionCreate) -> Self {
|
|
Self {
|
|
nonce: value.nonce.into(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl HasDomainType for RawSessionCreate {
|
|
type DomainType = SessionCreate;
|
|
}
|
|
|
|
impl HasUserData for SessionCreate {
|
|
fn user_data(&self) -> UserData {
|
|
let mut user_data = [0u8; 64];
|
|
user_data[0..32].copy_from_slice(&self.nonce);
|
|
user_data
|
|
}
|
|
}
|