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
7 changes: 6 additions & 1 deletion program-libs/token-interface/src/token_2022_extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ use crate::state::ExtensionStructConfig;
/// Restricted extension types that require compression_only mode.
/// These extensions have special behaviors (pausable, permanent delegate, fees, hooks,
/// default frozen state) that are incompatible with standard compressed token transfers.
pub const RESTRICTED_EXTENSION_TYPES: [ExtensionType; 5] = [
pub const RESTRICTED_EXTENSION_TYPES: [ExtensionType; 6] = [
ExtensionType::Pausable,
ExtensionType::PermanentDelegate,
ExtensionType::TransferFeeConfig,
ExtensionType::TransferHook,
ExtensionType::DefaultAccountState,
ExtensionType::MintCloseAuthority,
];
Comment on lines 6 to 16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Stale doc comment — MintCloseAuthority not listed among restricted extensions.

The comment on lines 7–8 enumerates the restricted behaviors but omits MintCloseAuthority (mint close authority). Since you've added it to the array and is_restricted_extension, the comment should stay in sync.

📝 Suggested fix
 /// Restricted extension types that require compression_only mode.
-/// These extensions have special behaviors (pausable, permanent delegate, fees, hooks,
-/// default frozen state) that are incompatible with standard compressed token transfers.
+/// These extensions have special behaviors (pausable, permanent delegate, fees, hooks,
+/// default frozen state, mint close authority) that are incompatible with standard compressed token transfers.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// Restricted extension types that require compression_only mode.
/// These extensions have special behaviors (pausable, permanent delegate, fees, hooks,
/// default frozen state) that are incompatible with standard compressed token transfers.
pub const RESTRICTED_EXTENSION_TYPES: [ExtensionType; 5] = [
pub const RESTRICTED_EXTENSION_TYPES: [ExtensionType; 6] = [
ExtensionType::Pausable,
ExtensionType::PermanentDelegate,
ExtensionType::TransferFeeConfig,
ExtensionType::TransferHook,
ExtensionType::DefaultAccountState,
ExtensionType::MintCloseAuthority,
];
/// Restricted extension types that require compression_only mode.
/// These extensions have special behaviors (pausable, permanent delegate, fees, hooks,
/// default frozen state, mint close authority) that are incompatible with standard compressed token transfers.
pub const RESTRICTED_EXTENSION_TYPES: [ExtensionType; 6] = [
ExtensionType::Pausable,
ExtensionType::PermanentDelegate,
ExtensionType::TransferFeeConfig,
ExtensionType::TransferHook,
ExtensionType::DefaultAccountState,
ExtensionType::MintCloseAuthority,
];
🤖 Prompt for AI Agents
In `@program-libs/token-interface/src/token_2022_extensions.rs` around lines 6 -
16, Update the stale doc comment above RESTRICTED_EXTENSION_TYPES to include
"mint close authority" (ExtensionType::MintCloseAuthority) among the listed
restricted behaviors so the comment matches the array and
is_restricted_extension logic; revise the sentence that lists pausable,
permanent delegate, fees, hooks, default frozen state to also mention mint close
authority (or "mint close authority (mint close)") for clarity.


/// Allowed mint extension types for Token accounts.
Expand Down Expand Up @@ -53,6 +54,7 @@ pub const fn is_restricted_extension(ext: &ExtensionType) -> bool {
| ExtensionType::TransferFeeConfig
| ExtensionType::TransferHook
| ExtensionType::DefaultAccountState
| ExtensionType::MintCloseAuthority
)
}

Expand All @@ -71,6 +73,8 @@ pub struct MintExtensionFlags {
pub has_transfer_fee: bool,
/// Whether the mint has the TransferHook extension (with nil program_id)
pub has_transfer_hook: bool,
/// Whether the mint has the MintCloseAuthority extension
pub has_mint_close_authority: bool,
}

impl MintExtensionFlags {
Expand Down Expand Up @@ -152,5 +156,6 @@ impl MintExtensionFlags {
|| self.has_transfer_fee
|| self.has_transfer_hook
|| self.has_default_account_state
|| self.has_mint_close_authority
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! These tests verify that Light Token accounts cannot be created without compression_only
//! when the mint has restricted extensions (Pausable, PermanentDelegate, TransferFeeConfig,
//! TransferHook, DefaultAccountState).
//! TransferHook, DefaultAccountState, MintCloseAuthority).

use light_program_test::{
program_test::LightProgramTest, utils::assert::assert_rpc_error, ProgramTestConfig, Rpc,
Expand Down Expand Up @@ -96,6 +96,12 @@ async fn test_default_account_state_requires_compression_only() {
test_compression_only_required_for_extensions(&[ExtensionType::DefaultAccountState]).await;
}

#[tokio::test]
#[serial]
async fn test_mint_close_authority_requires_compression_only() {
test_compression_only_required_for_extensions(&[ExtensionType::MintCloseAuthority]).await;
}

#[tokio::test]
#[serial]
async fn test_multiple_restricted_requires_compression_only() {
Expand All @@ -104,6 +110,7 @@ async fn test_multiple_restricted_requires_compression_only() {
ExtensionType::PermanentDelegate,
ExtensionType::TransferFeeConfig,
ExtensionType::TransferHook,
ExtensionType::MintCloseAuthority,
])
.await;
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ pub fn has_mint_extensions(mint_account: &AccountInfo) -> Result<MintExtensionFl
let mut has_transfer_fee = false;
let mut has_transfer_hook = false;
let mut has_default_account_state = false;
let mut has_mint_close_authority = false;

for ext in &extension_types {
if !ALLOWED_EXTENSION_TYPES.contains(ext) {
Expand All @@ -202,6 +203,7 @@ pub fn has_mint_extensions(mint_account: &AccountInfo) -> Result<MintExtensionFl
ExtensionType::TransferFeeConfig => has_transfer_fee = true,
ExtensionType::TransferHook => has_transfer_hook = true,
ExtensionType::DefaultAccountState => has_default_account_state = true,
ExtensionType::MintCloseAuthority => has_mint_close_authority = true,
_ => {}
}
}
Expand All @@ -224,5 +226,6 @@ pub fn has_mint_extensions(mint_account: &AccountInfo) -> Result<MintExtensionFl
default_state_frozen: default_account_state_frozen,
has_transfer_fee,
has_transfer_hook,
has_mint_close_authority,
})
}