utils.rs 508 B

1234567891011121314151617
  1. use crate::error::EscrowError;
  2. use solana_program::{program_error::ProgramError, pubkey::Pubkey};
  3. pub fn assert_is_associated_token_account(
  4. token_address: &Pubkey,
  5. owner: &Pubkey,
  6. mint: &Pubkey,
  7. ) -> Result<(), ProgramError> {
  8. let associated_token_account_address =
  9. &spl_associated_token_account::get_associated_token_address(owner, mint);
  10. if token_address != associated_token_account_address {
  11. return Err(EscrowError::TokenAccountMismatch.into());
  12. }
  13. Ok(())
  14. }