Skip to content

Commit a1d9915

Browse files
committed
program: Properly gate zk-ops feature
#### Problem The program currently doesn't build if the zk-ops feature is disabled. #### Summary of changes Fix gating on the imports confidential-mint-burn and confidential-transfer functions on the `zk-ops` feature.
1 parent 1c1a20c commit a1d9915

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

program/src/extension/confidential_mint_burn/processor.rs

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
#[cfg(feature = "zk-ops")]
2-
use spl_token_confidential_transfer_ciphertext_arithmetic as ciphertext_arithmetic;
32
use {
43
crate::{
5-
check_auditor_ciphertext, check_program_account,
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+
};
9+
use {
10+
crate::{
11+
check_program_account,
612
error::TokenError,
713
extension::{
814
confidential_mint_burn::{
@@ -11,7 +17,6 @@ use {
1117
MintInstructionData, RotateSupplyElGamalPubkeyData,
1218
UpdateDecryptableSupplyData,
1319
},
14-
verify_proof::{verify_burn_proof, verify_mint_proof},
1520
ConfidentialMintBurn,
1621
},
1722
confidential_transfer::{ConfidentialTransferAccount, ConfidentialTransferMint},
@@ -418,6 +423,7 @@ fn process_confidential_burn(
418423
}
419424

420425
/// Processes a [`ApplyPendingBurn`] instruction.
426+
#[cfg(feature = "zk-ops")]
421427
fn process_apply_pending_burn(program_id: &Pubkey, accounts: &[AccountInfo]) -> ProgramResult {
422428
let account_info_iter = &mut accounts.iter();
423429
let mint_info = next_account_info(account_info_iter)?;
@@ -467,8 +473,13 @@ pub(crate) fn process_instruction(
467473
}
468474
ConfidentialMintBurnInstruction::RotateSupplyElGamalPubkey => {
469475
msg!("ConfidentialMintBurnInstruction::RotateSupplyElGamal");
470-
let data = decode_instruction_data::<RotateSupplyElGamalPubkeyData>(input)?;
471-
process_rotate_supply_elgamal_pubkey(program_id, accounts, data)
476+
#[cfg(feature = "zk-ops")]
477+
{
478+
let data = decode_instruction_data::<RotateSupplyElGamalPubkeyData>(input)?;
479+
process_rotate_supply_elgamal_pubkey(program_id, accounts, data)
480+
}
481+
#[cfg(not(feature = "zk-ops"))]
482+
Err(ProgramError::InvalidInstructionData)
472483
}
473484
ConfidentialMintBurnInstruction::UpdateDecryptableSupply => {
474485
msg!("ConfidentialMintBurnInstruction::UpdateDecryptableSupply");
@@ -477,17 +488,32 @@ pub(crate) fn process_instruction(
477488
}
478489
ConfidentialMintBurnInstruction::Mint => {
479490
msg!("ConfidentialMintBurnInstruction::ConfidentialMint");
480-
let data = decode_instruction_data::<MintInstructionData>(input)?;
481-
process_confidential_mint(program_id, accounts, data)
491+
#[cfg(feature = "zk-ops")]
492+
{
493+
let data = decode_instruction_data::<MintInstructionData>(input)?;
494+
process_confidential_mint(program_id, accounts, data)
495+
}
496+
#[cfg(not(feature = "zk-ops"))]
497+
Err(ProgramError::InvalidInstructionData)
482498
}
483499
ConfidentialMintBurnInstruction::Burn => {
484500
msg!("ConfidentialMintBurnInstruction::ConfidentialBurn");
485-
let data = decode_instruction_data::<BurnInstructionData>(input)?;
486-
process_confidential_burn(program_id, accounts, data)
501+
#[cfg(feature = "zk-ops")]
502+
{
503+
let data = decode_instruction_data::<BurnInstructionData>(input)?;
504+
process_confidential_burn(program_id, accounts, data)
505+
}
506+
#[cfg(not(feature = "zk-ops"))]
507+
Err(ProgramError::InvalidInstructionData)
487508
}
488509
ConfidentialMintBurnInstruction::ApplyPendingBurn => {
489510
msg!("ConfidentialMintBurnInstruction::ApplyPendingBurn");
490-
process_apply_pending_burn(program_id, accounts)
511+
#[cfg(feature = "zk-ops")]
512+
{
513+
process_apply_pending_burn(program_id, accounts)
514+
}
515+
#[cfg(not(feature = "zk-ops"))]
516+
Err(ProgramError::InvalidInstructionData)
491517
}
492518
}
493519
}

program/src/extension/confidential_transfer/processor.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// Remove feature once zk ops syscalls are enabled on all networks
22
#[cfg(feature = "zk-ops")]
33
use {
4+
crate::check_auditor_ciphertext,
45
crate::extension::confidential_mint_burn::ConfidentialMintBurn,
56
crate::extension::non_transferable::NonTransferableAccount,
67
spl_token_confidential_transfer_ciphertext_arithmetic as ciphertext_arithmetic,
78
};
89
use {
910
crate::{
10-
check_auditor_ciphertext, check_elgamal_registry_program_account, check_program_account,
11+
check_elgamal_registry_program_account, check_program_account,
1112
error::TokenError,
1213
extension::{
1314
confidential_transfer::{instruction::*, verify_proof::*, *},

0 commit comments

Comments
 (0)