2020-10-16 10:38:12 -07:00
|
|
|
//! Program entrypoint
|
|
|
|
|
|
|
|
use crate::{error::Error, processor::Processor};
|
2020-10-22 21:44:27 -07:00
|
|
|
use solana_program::{
|
2020-10-16 10:38:12 -07:00
|
|
|
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult,
|
|
|
|
program_error::PrintProgramError, pubkey::Pubkey,
|
|
|
|
};
|
|
|
|
|
|
|
|
entrypoint!(process_instruction);
|
|
|
|
fn process_instruction<'a>(
|
|
|
|
program_id: &Pubkey,
|
|
|
|
accounts: &'a [AccountInfo<'a>],
|
|
|
|
instruction_data: &[u8],
|
|
|
|
) -> ProgramResult {
|
|
|
|
if let Err(error) = Processor::process(program_id, accounts, instruction_data) {
|
|
|
|
// catch the error so we can print it
|
|
|
|
error.print::<Error>();
|
|
|
|
return Err(error);
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|