processor.rs 797 B

12345678910111213141516171819202122232425
  1. use borsh::{BorshDeserialize, BorshSerialize};
  2. use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey};
  3. use crate::instructions::{
  4. create_new_account::create_new_account,
  5. init_rent_vault::{init_rent_vault, InitRentVaultArgs},
  6. };
  7. #[derive(BorshSerialize, BorshDeserialize)]
  8. pub enum MyInstruction {
  9. InitRentVault(InitRentVaultArgs),
  10. CreateNewAccount,
  11. }
  12. pub fn process_instruction(
  13. program_id: &Pubkey,
  14. accounts: &[AccountInfo],
  15. input: &[u8],
  16. ) -> ProgramResult {
  17. let instruction = MyInstruction::try_from_slice(input)?;
  18. match instruction {
  19. MyInstruction::InitRentVault(args) => init_rent_vault(program_id, accounts, args),
  20. MyInstruction::CreateNewAccount => create_new_account(program_id, accounts),
  21. }
  22. }