|
| 1 | +#[cfg(feature = "zk-ops")] |
| 2 | +use { |
| 3 | + crate::{ |
| 4 | + check_auditor_ciphertext, |
| 5 | + extension::confidential_mint_burn::verify_proof::{verify_burn_proof, verify_mint_proof}, |
| 6 | + }, |
| 7 | + spl_token_confidential_transfer_ciphertext_arithmetic as ciphertext_arithmetic, |
| 8 | +}; |
1 | 9 | use { |
2 | | - crate::processor::Processor, |
| 10 | + crate::{extension::cpi_guard::in_cpi, processor::Processor}, |
3 | 11 | solana_account_info::{next_account_info, AccountInfo}, |
4 | 12 | solana_msg::msg, |
5 | 13 | solana_program_error::{ProgramError, ProgramResult}, |
|
26 | 34 | ConfidentialMintBurn, |
27 | 35 | }, |
28 | 36 | confidential_transfer::{ConfidentialTransferAccount, ConfidentialTransferMint}, |
| 37 | + cpi_guard::CpiGuard, |
29 | 38 | pausable::PausableConfig, |
30 | 39 | BaseStateWithExtensions, BaseStateWithExtensionsMut, PodStateWithExtensionsMut, |
31 | 40 | }, |
|
34 | 43 | }, |
35 | 44 | spl_token_confidential_transfer_proof_extraction::instruction::verify_and_extract_context, |
36 | 45 | }; |
37 | | -#[cfg(feature = "zk-ops")] |
38 | | -use { |
39 | | - crate::{ |
40 | | - check_auditor_ciphertext, |
41 | | - extension::confidential_mint_burn::verify_proof::{verify_burn_proof, verify_mint_proof}, |
42 | | - }, |
43 | | - spl_token_confidential_transfer_ciphertext_arithmetic as ciphertext_arithmetic, |
44 | | -}; |
45 | 46 |
|
46 | 47 | /// Processes an [`InitializeMint`] instruction. |
47 | 48 | fn process_initialize_mint(accounts: &[AccountInfo], data: &InitializeMintData) -> ProgramResult { |
@@ -337,6 +338,17 @@ fn process_confidential_burn( |
337 | 338 | account_info_iter.as_slice(), |
338 | 339 | )?; |
339 | 340 |
|
| 341 | + if let Ok(cpi_guard) = token_account.get_extension::<CpiGuard>() { |
| 342 | + // Blocks all cases where the authority has signed if CPI Guard is |
| 343 | + // enabled, including: |
| 344 | + // * the account is delegated to the owner |
| 345 | + // * the account owner is the permanent delegate |
| 346 | + if *authority_info.key == token_account.base.owner && cpi_guard.lock_cpi.into() && in_cpi() |
| 347 | + { |
| 348 | + return Err(TokenError::CpiGuardBurnBlocked.into()); |
| 349 | + } |
| 350 | + } |
| 351 | + |
340 | 352 | if token_account.base.is_frozen() { |
341 | 353 | return Err(TokenError::AccountFrozen.into()); |
342 | 354 | } |
|
0 commit comments