1234567891011121314151617181920212223242526272829303132 |
- 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 {
- name: String,
- height: u32,
- }
|