processor.rs 748 B

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