1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use crate::instruction::OnchainMetadataInstructions;
use borsh::BorshDeserialize;
use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, msg, pubkey::Pubkey};

mod add_authority;
mod append_value;
mod close;
mod initialize;
mod remove_authority;
mod set_value;

use add_authority::*;
use append_value::*;
use close::*;
use initialize::*;
use remove_authority::*;
use set_value::*;

pub struct Processor;
impl Processor {
    pub fn process_instruction(
        _program_id: &Pubkey,
        accounts: &[AccountInfo],
        instruction_data: &[u8],
    ) -> ProgramResult {
        let instruction: OnchainMetadataInstructions =
            OnchainMetadataInstructions::try_from_slice(instruction_data)?;
        match instruction {
            OnchainMetadataInstructions::Initialize => {
                msg!("Instruction: Initialize");
                process_initialize(accounts)
            }
            OnchainMetadataInstructions::Close => {
                msg!("Instruction: Close");
                process_close(accounts)
            }
            OnchainMetadataInstructions::SetValue(args) => {
                msg!("Instruction: SetValue");
                process_set_value(accounts, args)
            }
            OnchainMetadataInstructions::AppendValue(args) => {
                msg!("Instruction: AppendValue");
                process_append_value(accounts, args)
            }
            OnchainMetadataInstructions::AddAuthority(args) => {
                msg!("Instruction: AddAuthority");
                process_add_authority(accounts, args)
            }
            OnchainMetadataInstructions::RemoveAuthority(args) => {
                msg!("Instruction: RemoveAuthority");
                process_remove_authority(accounts, args)
            }
        }
    }
}