use thiserror::Error;
#[derive(Error, Debug)]
pub enum QuantusError {
#[error("Wallet error: {0}")]
Wallet(#[from] WalletError),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[error("TOML error: {0}")]
TomlDe(#[from] toml::de::Error),
#[error("TOML serialization error: {0}")]
TomlSer(#[from] toml::ser::Error),
#[error("SubXT error: {0}")]
Subxt(#[from] Box<subxt::Error>),
#[error("Error: {0}")]
Generic(String),
#[error("Network error: {0}")]
NetworkError(String),
#[error("Insufficient balance: available {available}, required {required}")]
InsufficientBalance { available: u128, required: u128 },
}
#[derive(Error, Debug)]
pub enum WalletError {
#[error("Wallet not found")]
NotFound,
#[error("Wallet already exists")]
AlreadyExists,
#[error("Invalid mnemonic phrase")]
InvalidMnemonic,
#[error("Mnemonic phrase is not available for this wallet")]
MnemonicNotAvailable,
#[error("Invalid password")]
InvalidPassword,
#[error("Key generation failed")]
KeyGeneration,
#[error("Encryption failed: {0}")]
Encryption(String),
#[error("Decryption failed. Check your password.")]
Decryption,
}
pub type Result<T> = std::result::Result<T, QuantusError>;
impl From<subxt::Error> for QuantusError {
fn from(err: subxt::Error) -> Self {
QuantusError::Subxt(Box::new(err))
}
}