burn_checked.rs 668 B

12345678910111213141516171819
  1. use pinocchio::{account_info::AccountInfo, program_error::ProgramError, ProgramResult};
  2. use super::shared;
  3. #[inline(always)]
  4. pub fn process_burn_checked(accounts: &[AccountInfo], instruction_data: &[u8]) -> ProgramResult {
  5. // expected u64 (8) + u8 (1)
  6. let (amount, decimals) = if instruction_data.len() == 9 {
  7. let (amount, decimals) = instruction_data.split_at(core::mem::size_of::<u64>());
  8. (
  9. u64::from_le_bytes(amount.try_into().unwrap()),
  10. decimals.first().copied(),
  11. )
  12. } else {
  13. return Err(ProgramError::InvalidInstructionData);
  14. };
  15. shared::burn::process_burn(accounts, amount, decimals)
  16. }