entrypoint.rs 605 B

123456789101112131415161718192021
  1. //! Program entrypoint
  2. use crate::{error::TokenError, processor::Processor};
  3. use solana_program::{
  4. account_info::AccountInfo, entrypoint, entrypoint::ProgramResult,
  5. program_error::PrintProgramError, pubkey::Pubkey,
  6. };
  7. entrypoint!(process_instruction);
  8. fn process_instruction(
  9. program_id: &Pubkey,
  10. accounts: &[AccountInfo],
  11. instruction_data: &[u8],
  12. ) -> ProgramResult {
  13. if let Err(error) = Processor::process(program_id, accounts, instruction_data) {
  14. // catch the error so we can print it
  15. error.print::<TokenError>();
  16. return Err(error);
  17. }
  18. Ok(())
  19. }