Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion programs/compressed-token/program/src/ctoken/create_ata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use borsh::BorshDeserialize;
use light_account_checks::AccountIterator;
use light_program_profiler::profile;
use light_token_interface::instructions::create_associated_token_account::CreateAssociatedTokenAccountInstructionData;
use pinocchio::{account_info::AccountInfo, instruction::Seed};
use pinocchio::{account_info::AccountInfo, instruction::Seed, pubkey::pubkey_eq};
use spl_pod::solana_msg::msg;

use crate::{
Expand Down Expand Up @@ -67,6 +67,18 @@ fn process_create_associated_token_account_with_mode<const IDEMPOTENT: bool>(
if IDEMPOTENT {
validate_ata_derivation(associated_token_account, owner_bytes, mint_bytes, bump)?;
if associated_token_account.is_owned_by(&crate::LIGHT_CPI_SIGNER.program_id) {
// Verify stored mint and owner match the requested values
let ctoken = light_token_interface::state::Token::from_account_info_checked(
associated_token_account,
)?;
if !pubkey_eq(ctoken.mint.array_ref(), mint_bytes) {
msg!("Idempotent ATA: mint mismatch");
return Err(anchor_compressed_token::ErrorCode::MintMismatch.into());
}
if !pubkey_eq(ctoken.owner.array_ref(), owner_bytes) {
msg!("Idempotent ATA: owner mismatch");
return Err(anchor_compressed_token::ErrorCode::OwnerMismatch.into());
}
return Ok(());
}
}
Expand Down