forked from solana-developers/program-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
32 lines (27 loc) · 918 Bytes
/
lib.rs
File metadata and controls
32 lines (27 loc) · 918 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
use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::{
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, msg, pubkey::Pubkey,
};
entrypoint!(process_instruction);
fn process_instruction(
_program_id: &Pubkey,
_accounts: &[AccountInfo],
instruction_data: &[u8],
) -> ProgramResult {
// Attempt to serialize the BPF format to our struct
// using Borsh
//
let instruction_data_object = InstructionData::try_from_slice(instruction_data)?;
msg!("Welcome to the park, {}!", instruction_data_object.name);
if instruction_data_object.height > 5 {
msg!("You are tall enough to ride this ride. Congratulations.");
} else {
msg!("You are NOT tall enough to ride this ride. Sorry mate.");
};
Ok(())
}
#[derive(BorshSerialize, BorshDeserialize, Debug)]
pub struct InstructionData {
pub name: String,
pub height: u32,
}