-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathprocessor.rs
More file actions
33 lines (28 loc) · 997 Bytes
/
processor.rs
File metadata and controls
33 lines (28 loc) · 997 Bytes
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
use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, msg, pubkey::Pubkey};
use crate::functions::{create_pda, write_pda};
use crate::instruction::Instruction;
pub struct Processor;
impl Processor {
pub fn process_program_call(
program_id: &Pubkey,
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> ProgramResult {
// turns bytecode into instrucion which contains function to invoke
let instruction = Instruction::unpack(instruction_data)?;
msg!("[processor] Received instruction struct: {:?}", instruction);
match instruction {
Instruction::PdaCreate {
seed,
bump,
account_size,
} => {
create_pda(program_id, seed, bump, account_size, accounts)?;
}
Instruction::PdaWrite { seed } => {
write_pda(program_id, seed, accounts)?;
}
}
Ok(())
}
}