Skip to content
Merged
Show file tree
Hide file tree
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
31 changes: 31 additions & 0 deletions clients/rust-legacy/tests/confidential_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3367,6 +3367,37 @@ async fn confidential_transfer_apply_pending_balance_frozen_account() {
);
}

#[tokio::test]
async fn fail_initialize_non_transferable_confidential_mint_without_mint_burn() {
let authority = Keypair::new();
let auto_approve_new_accounts = true;
let auditor_elgamal_keypair = ElGamalKeypair::new_rand();
let auditor_elgamal_pubkey = (*auditor_elgamal_keypair.pubkey()).into();

let mut context = TestContext::new().await;
let err = context
.init_token_with_mint(vec![
ExtensionInitializationParams::NonTransferable,
ExtensionInitializationParams::ConfidentialTransferMint {
authority: Some(authority.pubkey()),
auto_approve_new_accounts,
auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey),
},
])
.await
.unwrap_err();

assert_eq!(
err,
TokenClientError::Client(Box::new(TransportError::TransactionError(
TransactionError::InstructionError(
3,
InstructionError::Custom(TokenError::InvalidExtensionCombination as u32)
)
)))
);
}

#[cfg(test)]
mod unit_tests {

Expand Down
6 changes: 6 additions & 0 deletions interface/src/extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,7 @@ impl ExtensionType {
let mut confidential_mint_burn = false;
let mut interest_bearing = false;
let mut scaled_ui_amount = false;
let mut non_transferable = false;

for extension_type in mint_extension_types {
match extension_type {
Expand All @@ -1339,6 +1340,7 @@ impl ExtensionType {
ExtensionType::ConfidentialMintBurn => confidential_mint_burn = true,
ExtensionType::InterestBearingConfig => interest_bearing = true,
ExtensionType::ScaledUiAmount => scaled_ui_amount = true,
ExtensionType::NonTransferable => non_transferable = true,
_ => (),
}
}
Expand All @@ -1360,6 +1362,10 @@ impl ExtensionType {
return Err(TokenError::InvalidExtensionCombination);
}

if non_transferable && confidential_transfer_mint && !confidential_mint_burn {
return Err(TokenError::InvalidExtensionCombination);
}

Ok(())
}
}
Expand Down