trident-sdk 0.1.0

SDK for Trident protocol
Documentation
use crate::eips::eip712::EIP712Error;
use alloy_primitives::Address;
use tides_core_types::TidesChainId;
use trident_types::core::{FixedBytes32ConversionError, SpendIntent};

#[derive(thiserror::Error, Debug)]
pub enum Error {
    #[error("Invalid service")]
    InvalidService,
    #[error("Tonic transport: {0}")]
    TonicTransport(#[from] tonic::transport::Error),
    #[error("Grpc Client")]
    GrpcClient(#[from] tonic::Status),
    #[error("Unknown chain: {0}")]
    UnknownChain(TidesChainId),
    #[error("Unsupported chain type: {0}")]
    UnsupportedChainType(i32),
    #[error("Unsupported token: {0}")]
    UnsupportedToken(Address),
    #[error("Alloy contract error: {0}")]
    AlloyContract(#[from] alloy_contract::Error),
    #[error("Pending transaction error: {0}")]
    AlloyPendingTx(#[from] alloy_provider::PendingTransactionError),
    #[error("Alloy signer error: {0}")]
    AlloySigner(#[from] alloy_signer::Error),
    #[error("No destination token mapping from {0} on chain {1} to chain {2}")]
    NoDestinationTokenMapping(Address, TidesChainId, TidesChainId),
    #[error(
        "Ambiguous destination token mapping for {0} from chain {1} to chain {2}; specify destination token"
    )]
    AmbiguousDestinationTokenMapping(Address, TidesChainId, TidesChainId),
    #[error("FixedBytes32 conversion: {0}")]
    Fixed32Conversion(#[from] FixedBytes32ConversionError),
    #[error("Slice conversion: {0}")]
    SliceConversion(#[from] std::array::TryFromSliceError),
    #[error("Conversion error: {0}")]
    TokenConversion(String),
    #[error("Block height computation overflowed")]
    BlockHeightOverflow,
    #[error("Insufficient balance: need {0}, available {1}")]
    InsufficientBalance(alloy_primitives::U256, alloy_primitives::U256),
    #[error("Invalid U256 byte slice")]
    InvalidU256ByteSlice,
    #[error(transparent)]
    EvmDeliveryFailed(#[from] Box<EvmDeliveryFailed>),
    #[error("Random: {0}")]
    RandCore(#[from] rand_core::OsError),
    #[error("EIP712Error: {0}")]
    EIP712Error(#[from] EIP712Error),
}

#[derive(thiserror::Error, Debug)]
#[error("EVM delivery failed: {cause}")]
pub struct EvmDeliveryFailed {
    pub spend_intent: SpendIntent,
    pub attestation_payload: Vec<u8>,
    pub signature: Vec<u8>,
    #[source]
    pub cause: Box<Error>,
}