-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.rs
37 lines (31 loc) · 879 Bytes
/
lib.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
30
31
32
33
34
35
36
37
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint,
entrypoint::ProgramResult,
msg,
pubkey::Pubkey,
};
entrypoint!(process_instruction);
pub fn process_instruction(
_program_id: &Pubkey,
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> ProgramResult {
let mut accounts_iter = accounts.iter();
let _signer = next_account_info(&mut accounts_iter)?;
let counter = next_account_info(&mut accounts_iter)?;
match instruction_data[0] {
0 => {
msg!("Initialize Account");
counter.data.borrow_mut()[0] = 1;
}
1 => {
msg!("Increase Account");
counter.data.borrow_mut()[0] += 1;
}
_ => {
return Err(solana_program::program_error::ProgramError::InvalidInstructionData);
}
}
Ok(())
}