predict-sdk 0.1.0

Rust SDK for Predict.fun prediction market - order building, EIP-712 signing, and real-time WebSocket data
Documentation
use thiserror::Error;

#[derive(Debug, Error)]
pub enum Error {
    #[error("Invalid chain ID: {0}")]
    InvalidChainId(u64),

    #[error("Invalid quantity: {0}")]
    InvalidQuantity(String),

    #[error("Invalid price: {0}")]
    InvalidPrice(String),

    #[error("Invalid order data: {0}")]
    InvalidOrderData(String),

    #[error("EIP-712 signing error: {0}")]
    SigningError(String),

    #[error("Contract interaction error: {0}")]
    ContractError(String),

    #[error("HTTP request error: {0}")]
    HttpError(#[from] reqwest::Error),

    #[error("API error: {0}")]
    ApiError(String),

    #[error("Configuration error: {0}")]
    ConfigError(String),

    #[error("JSON serialization error: {0}")]
    JsonError(#[from] serde_json::Error),

    #[error("Alloy error: {0}")]
    AlloyError(String),

    #[error("{0}")]
    Other(String),
}

impl From<alloy::contract::Error> for Error {
    fn from(err: alloy::contract::Error) -> Self {
        Error::AlloyError(err.to_string())
    }
}

pub type Result<T> = std::result::Result<T, Error>;