web3_domain_name_service/
processor.rs

1use {
2    crate::{
3        instruction::NameRegistryInstruction,
4    },
5    borsh::BorshDeserialize,
6    solana_program::{
7        account_info::{ AccountInfo},
8        entrypoint::ProgramResult,
9        msg,
10        program_error::ProgramError,
11        pubkey::Pubkey,
12    },
13};
14
15pub mod create;
16pub mod update;
17pub mod transfer;
18
19
20pub struct Processor {}
21
22impl Processor {
23
24
25    pub fn process_instruction(
26        program_id: &Pubkey,
27        accounts: &[AccountInfo],
28        instruction_data: &[u8],
29    ) -> ProgramResult {
30        msg!("Beginning processing");
31        msg!("instruction: {:?}", instruction_data);
32        let instruction = NameRegistryInstruction::try_from_slice(instruction_data)
33            .map_err(|_| ProgramError::InvalidInstructionData)?;
34        msg!("Instruction unpacked");
35
36        match instruction {
37            NameRegistryInstruction::Create {
38                hashed_name,
39                lamports,
40                custom_value
41            } => {
42                msg!("Instruction: Create");
43                create::process_create(program_id, accounts, hashed_name, lamports, custom_value)?;
44            }
45            NameRegistryInstruction::Update { offset, data } => {
46                msg!("Instruction: Update Data");
47                update::process_update(accounts, offset, data)?;
48            }
49            NameRegistryInstruction::Transfer { new_owner } => {
50                msg!("Instruction: Transfer Ownership");
51                transfer::process_transfer(accounts, new_owner)?;
52            }
53        }
54        Ok(())
55    }
56
57
58
59
60
61
62
63
64    
65
66
67
68    
69
70    
71}