Skip to content

Commit

Permalink
feature gate extension logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhargavamacha committed Apr 9, 2024
1 parent 1419902 commit 72be8af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lang/syn/src/codegen/accounts/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ fn generate_constraint_init_group(
}

let mint_space = if extensions.is_empty() {
quote! { ::anchor_spl::spl_token::Mint::LEN }
quote! { ::anchor_spl::token::Mint::LEN }
} else {
quote! { ::anchor_spl::token_interface::find_mint_account_size(Some(&vec![#(#extensions),*]))? }
};
Expand Down Expand Up @@ -883,6 +883,7 @@ fn generate_constraint_init_group(
#create_account
}

#[cfg(feature = "token_2022_extensions")]
if let Some(extensions) = #extensions {
for e in extensions {
match e {
Expand Down
2 changes: 1 addition & 1 deletion spl/src/token_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use spl_token_2022::{
use std::ops::Deref;

pub use crate::token_2022::*;
#[cfg(feature = "token_2022_extensions")]
pub use crate::token_2022_extensions::*;

static IDS: [Pubkey; 2] = [spl_token::ID, spl_token_2022::ID];
Expand Down Expand Up @@ -77,7 +78,6 @@ impl anchor_lang::Ids for TokenInterface {
}
}


pub type ExtensionsVec = Vec<ExtensionType>;

pub fn find_mint_account_size(extensions: Option<&ExtensionsVec>) -> anchor_lang::Result<usize> {
Expand Down

0 comments on commit 72be8af

Please sign in to comment.