pub use light_compressed_token_sdk::error::{Result, TokenSdkError};
use solana_program_error::ProgramError;
use thiserror::Error;
pub type LightTokenResult<T> = std::result::Result<T, LightTokenError>;
#[derive(Debug, Error)]
pub enum LightTokenError {
#[error("SPL interface required for this operation")]
SplInterfaceRequired,
#[error("Incomplete SPL interface configuration")]
IncompleteSplInterface,
#[error("Use regular SPL transfer for this operation")]
UseRegularSplTransfer,
#[error("Cannot determine account type")]
CannotDetermineAccountType,
#[error("Missing mint account")]
MissingMintAccount,
#[error("Missing SPL token program")]
MissingSplTokenProgram,
#[error("Missing SPL interface PDA")]
MissingSplInterfacePda,
#[error("Missing SPL interface PDA bump")]
MissingSplInterfacePdaBump,
#[error("SPL token program mismatch between source and destination")]
SplTokenProgramMismatch,
#[error("Invalid account data")]
InvalidAccountData,
#[error("Serialization error")]
SerializationError,
#[error("Missing CPI context account")]
MissingCpiContext,
#[error("Missing CPI authority account")]
MissingCpiAuthority,
#[error("Missing output queue account")]
MissingOutputQueue,
#[error("Missing state merkle tree account")]
MissingStateMerkleTree,
#[error("Missing address merkle tree account")]
MissingAddressMerkleTree,
#[error("Missing light system program")]
MissingLightSystemProgram,
#[error("Missing registered program PDA")]
MissingRegisteredProgramPda,
#[error("Missing account compression authority")]
MissingAccountCompressionAuthority,
#[error("Missing account compression program")]
MissingAccountCompressionProgram,
#[error("Missing system program")]
MissingSystemProgram,
}
impl From<LightTokenError> for ProgramError {
fn from(e: LightTokenError) -> Self {
ProgramError::Custom(e.into())
}
}
impl From<LightTokenError> for u32 {
fn from(e: LightTokenError) -> Self {
match e {
LightTokenError::SplInterfaceRequired => 17500,
LightTokenError::IncompleteSplInterface => 17501,
LightTokenError::UseRegularSplTransfer => 17502,
LightTokenError::CannotDetermineAccountType => 17503,
LightTokenError::MissingMintAccount => 17504,
LightTokenError::MissingSplTokenProgram => 17505,
LightTokenError::MissingSplInterfacePda => 17506,
LightTokenError::MissingSplInterfacePdaBump => 17507,
LightTokenError::SplTokenProgramMismatch => 17508,
LightTokenError::InvalidAccountData => 17509,
LightTokenError::SerializationError => 17510,
LightTokenError::MissingCpiContext => 17511,
LightTokenError::MissingCpiAuthority => 17512,
LightTokenError::MissingOutputQueue => 17513,
LightTokenError::MissingStateMerkleTree => 17514,
LightTokenError::MissingAddressMerkleTree => 17515,
LightTokenError::MissingLightSystemProgram => 17516,
LightTokenError::MissingRegisteredProgramPda => 17517,
LightTokenError::MissingAccountCompressionAuthority => 17518,
LightTokenError::MissingAccountCompressionProgram => 17519,
LightTokenError::MissingSystemProgram => 17520,
}
}
}