Skip to content

Commit 9b2f02d

Browse files
committed
disallow non-transferable and confidential transfer to be initialized without confidential mint burn
1 parent bfa4bb8 commit 9b2f02d

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

clients/rust-legacy/tests/confidential_transfer.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3367,6 +3367,37 @@ async fn confidential_transfer_apply_pending_balance_frozen_account() {
33673367
);
33683368
}
33693369

3370+
#[tokio::test]
3371+
async fn fail_initialize_non_transferable_confidential_mint_without_mint_burn() {
3372+
let authority = Keypair::new();
3373+
let auto_approve_new_accounts = true;
3374+
let auditor_elgamal_keypair = ElGamalKeypair::new_rand();
3375+
let auditor_elgamal_pubkey = (*auditor_elgamal_keypair.pubkey()).into();
3376+
3377+
let mut context = TestContext::new().await;
3378+
let err = context
3379+
.init_token_with_mint(vec![
3380+
ExtensionInitializationParams::NonTransferable,
3381+
ExtensionInitializationParams::ConfidentialTransferMint {
3382+
authority: Some(authority.pubkey()),
3383+
auto_approve_new_accounts,
3384+
auditor_elgamal_pubkey: Some(auditor_elgamal_pubkey),
3385+
},
3386+
])
3387+
.await
3388+
.unwrap_err();
3389+
3390+
assert_eq!(
3391+
err,
3392+
TokenClientError::Client(Box::new(TransportError::TransactionError(
3393+
TransactionError::InstructionError(
3394+
3,
3395+
InstructionError::Custom(TokenError::InvalidExtensionCombination as u32)
3396+
)
3397+
)))
3398+
);
3399+
}
3400+
33703401
#[cfg(test)]
33713402
mod unit_tests {
33723403

interface/src/extension/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,7 @@ impl ExtensionType {
13281328
let mut confidential_mint_burn = false;
13291329
let mut interest_bearing = false;
13301330
let mut scaled_ui_amount = false;
1331+
let mut non_transferable = false;
13311332

13321333
for extension_type in mint_extension_types {
13331334
match extension_type {
@@ -1339,6 +1340,7 @@ impl ExtensionType {
13391340
ExtensionType::ConfidentialMintBurn => confidential_mint_burn = true,
13401341
ExtensionType::InterestBearingConfig => interest_bearing = true,
13411342
ExtensionType::ScaledUiAmount => scaled_ui_amount = true,
1343+
ExtensionType::NonTransferable => non_transferable = true,
13421344
_ => (),
13431345
}
13441346
}
@@ -1360,6 +1362,10 @@ impl ExtensionType {
13601362
return Err(TokenError::InvalidExtensionCombination);
13611363
}
13621364

1365+
if non_transferable && confidential_transfer_mint && !confidential_mint_burn {
1366+
return Err(TokenError::InvalidExtensionCombination);
1367+
}
1368+
13631369
Ok(())
13641370
}
13651371
}

0 commit comments

Comments
 (0)