cycles-quartz/bisenzone-cw-mvp/contracts/cw-tee-mtcs/src/error.rs

44 lines
874 B
Rust
Raw Normal View History

2023-11-29 21:13:20 +00:00
use cosmwasm_std::StdError;
2023-12-05 17:03:43 +00:00
use hex::FromHexError;
use k256::ecdsa::Error as K256Error;
2023-11-29 21:13:20 +00:00
use thiserror::Error;
#[derive(Error, Debug)]
pub enum ContractError {
#[error("{0}")]
Std(#[from] StdError),
#[error("Unauthorized")]
Unauthorized,
2023-11-29 22:09:57 +00:00
#[error("Invalid pubkey")]
2023-12-05 17:03:43 +00:00
InvalidPubKey(PublicKeyError),
2023-11-29 22:09:57 +00:00
}
2023-12-05 17:03:43 +00:00
#[derive(Error, Debug)]
pub enum PublicKeyError {
#[error("Not Secp256K1")]
K256(K256Error),
#[error("Invalid hex")]
Hex(FromHexError),
}
impl<T: Into<PublicKeyError>> From<T> for ContractError {
fn from(e: T) -> Self {
let e = e.into();
2023-11-29 22:09:57 +00:00
Self::InvalidPubKey(e)
}
2023-11-29 21:13:20 +00:00
}
2023-12-05 17:03:43 +00:00
impl From<K256Error> for PublicKeyError {
fn from(e: K256Error) -> Self {
PublicKeyError::K256(e)
}
}
impl From<FromHexError> for PublicKeyError {
fn from(e: FromHexError) -> Self {
PublicKeyError::Hex(e)
}
}