spl_name_service/
entrypoint.rs

1use {
2    crate::error::NameServiceError,
3    crate::processor::Processor,
4    num_traits::FromPrimitive,
5    solana_program::{
6        account_info::AccountInfo, decode_error::DecodeError, entrypoint,
7        entrypoint::ProgramResult, msg, program_error::PrintProgramError, pubkey::Pubkey,
8    },
9};
10
11entrypoint!(process_instruction);
12
13pub fn process_instruction(
14    program_id: &Pubkey,
15    accounts: &[AccountInfo],
16    instruction_data: &[u8],
17) -> ProgramResult {
18    msg!("Entrypoint");
19    if let Err(error) = Processor::process_instruction(program_id, accounts, instruction_data) {
20        // catch the error so we can print it
21        error.print::<NameServiceError>();
22        return Err(error);
23    }
24    Ok(())
25}
26
27impl PrintProgramError for NameServiceError {
28    fn print<E>(&self)
29    where
30        E: 'static + std::error::Error + DecodeError<E> + PrintProgramError + FromPrimitive,
31    {
32        match self {
33            NameServiceError::OutOfSpace => msg!("Error: Registry is out of space!"),
34        }
35    }
36}