processor.rs 834 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. use {
  2. borsh::{
  3. BorshDeserialize,
  4. BorshSerialize,
  5. },
  6. solana_program::{
  7. account_info::AccountInfo,
  8. entrypoint::ProgramResult,
  9. pubkey::Pubkey,
  10. },
  11. };
  12. use crate::instructions::{
  13. create::{
  14. CreateTokenArgs,
  15. create_token,
  16. },
  17. mint::mint_to,
  18. };
  19. #[derive(BorshSerialize, BorshDeserialize, Debug)]
  20. enum SplMinterIntstruction {
  21. Create(CreateTokenArgs),
  22. Mint,
  23. }
  24. pub fn process_instruction(
  25. _program_id: &Pubkey,
  26. accounts: &[AccountInfo],
  27. instruction_data: &[u8],
  28. ) -> ProgramResult {
  29. let instruction = SplMinterIntstruction::try_from_slice(instruction_data)?;
  30. match instruction {
  31. SplMinterIntstruction::Create(args) => create_token(accounts, args),
  32. SplMinterIntstruction::Mint => mint_to(accounts),
  33. }
  34. }