use thiserror::Error;
#[derive(Debug, Error)]
pub enum StarkzapError {
#[error("RPC provider error: {0}")]
Provider(#[from] starknet::providers::ProviderError),
#[error("Account error: {0}")]
Account(String),
#[error("Signer error: {0}")]
Signer(String),
#[error("Cartridge session error: {0}")]
Cartridge(String),
#[error("Invalid private key: must be a 0x-prefixed hex felt")]
InvalidPrivateKey,
#[error("Invalid address: {0}")]
InvalidAddress(String),
#[error(
"Signer address is unavailable and could not be derived from the selected account preset"
)]
MissingSignerAddress,
#[error("Signer public key is unavailable")]
MissingPublicKey,
#[error("Configured address {provided} does not match preset-derived address {expected}")]
AddressMismatch { provided: String, expected: String },
#[error("Transaction rejected: {reason}")]
TransactionRejected { reason: String },
#[error("Transaction reverted: {reason}")]
TransactionReverted { reason: String },
#[error("Transaction wait timed out after {attempts} attempts")]
WaitTimeout { attempts: u32 },
#[error("Amount parse error: '{input}' is not a valid decimal string")]
AmountParse { input: String },
#[error("Amount overflow: value exceeds u128::MAX")]
AmountOverflow,
#[error("Unknown token: {symbol}")]
UnknownToken { symbol: String },
#[error("Paymaster request failed ({status}): {body}")]
PaymasterRequest { status: u16, body: String },
#[error("Paymaster response missing field: {field}")]
PaymasterMalformed { field: String },
#[error("Paymaster feature is not supported by the configured backend: {feature}")]
PaymasterUnsupported { feature: String },
#[error("Paymaster validation failed: {reason}")]
PaymasterValidation { reason: String },
#[cfg(feature = "privy")]
#[error("Privy API error ({status}): {body}")]
PrivyApi { status: u16, body: String },
#[cfg(feature = "privy")]
#[error("Privy signing failed: {0}")]
PrivySigning(String),
#[error("Staking error: {0}")]
Staking(String),
#[error("No pools found for staker: {address}")]
NoPoolsFound { address: String },
#[error("Account deploy failed: {0}")]
DeployFailed(String),
#[error("Account is not deployed and deploy was not requested")]
NotDeployed,
#[error("HTTP error: {0}")]
Http(#[from] reqwest::Error),
#[error("Serialization error: {0}")]
Serialize(#[from] serde_json::Error),
#[error("Hex decode error: {0}")]
HexDecode(#[from] hex::FromHexError),
#[error("{0}")]
Other(String),
}
pub type Result<T> = std::result::Result<T, StarkzapError>;