use crate::error::DexError;
use crate::processor::Processor;
use num_traits::FromPrimitive;
use solana_program::{
account_info::AccountInfo, decode_error::DecodeError, entrypoint::ProgramResult, msg,
program_error::PrintProgramError, pubkey::Pubkey,
};
#[cfg(not(feature = "no-entrypoint"))]
use solana_program::entrypoint;
#[cfg(not(feature = "no-entrypoint"))]
entrypoint!(process_instruction);
pub fn process_instruction(
program_id: &Pubkey,
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> ProgramResult {
msg!("Entrypoint");
if let Err(error) = Processor::process_instruction(program_id, accounts, instruction_data) {
error.print::<DexError>();
return Err(error);
}
Ok(())
}
impl PrintProgramError for DexError {
fn print<E>(&self)
where
E: 'static + std::error::Error + DecodeError<E> + PrintProgramError + FromPrimitive,
{
msg!("Error: {}", self)
}
}