lib.rs 967 B

1234567891011121314151617181920212223242526272829303132
  1. mod instructions;
  2. mod state;
  3. use {
  4. borsh::BorshDeserialize,
  5. solana_program::{
  6. account_info::AccountInfo,
  7. declare_id,
  8. entrypoint,
  9. entrypoint::ProgramResult,
  10. pubkey::Pubkey,
  11. },
  12. };
  13. use crate::instructions::*;
  14. declare_id!("8avNGHVXDwsELJaWMSoUZ44CirQd4zyU9Ez4ZmP4jNjZ");
  15. entrypoint!(process_instruction);
  16. pub fn process_instruction(
  17. program_id: &Pubkey,
  18. accounts: &[AccountInfo],
  19. instruction_data: &[u8],
  20. ) -> ProgramResult {
  21. let instruction = CarRentalServiceInstruction::try_from_slice(instruction_data)?;
  22. match instruction {
  23. CarRentalServiceInstruction::AddCar(car) => add_car(program_id, accounts, car),
  24. CarRentalServiceInstruction::BookRental(order) => book_rental(program_id, accounts, order),
  25. CarRentalServiceInstruction::PickUpCar => pick_up_car(program_id, accounts),
  26. CarRentalServiceInstruction::ReturnCar => return_car(program_id, accounts),
  27. }
  28. }