-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprocessor.rs
29 lines (25 loc) · 903 Bytes
/
processor.rs
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
use borsh::BorshDeserialize;
use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey};
use crate::{
error::MyProgramError,
instruction::{create_my_account, create_my_pda_account, MyProgramInstruction},
};
pub struct Processor {}
impl Processor {
pub fn process_ix(
program_id: &Pubkey,
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> ProgramResult {
let instruction = MyProgramInstruction::try_from_slice(instruction_data)
.map_err(|_| MyProgramError::InvalidInstruction)?;
match instruction {
MyProgramInstruction::CreateAccount(data) => {
create_my_account(program_id, accounts, data)
}
MyProgramInstruction::CreatePDAAccount(data) => {
create_my_pda_account(program_id, accounts, data)
}
}
}
}