-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reason for stack violation warnings inside anchor macro generation #63
Comments
The match arms's variables were causing overload when too many extensions were iterated through. This is why, when fewer extensions were passed the warning wasn't occurring. The following minimalistic change immediately fixed that warning for e in extensions {
match e {
::anchor_spl::token_interface::spl_token_2022::extension::ExtensionType::GroupPointer => {
::anchor_spl::token_interface::group_pointer_initialize(
anchor_lang::context::CpiContext::new(
token_program.to_account_info(),
::anchor_spl::token_interface::GroupPointerInitialize {
token_program_id: token_program.to_account_info(),
mint: mint.to_account_info(),
},
),
Option::<anchor_lang::prelude::Pubkey>::None,
Option::<anchor_lang::prelude::Pubkey>::None,
)?;
}
::anchor_spl::token_interface::spl_token_2022::extension::ExtensionType::GroupMemberPointer => {
::anchor_spl::token_interface::group_member_pointer_initialize(
anchor_lang::context::CpiContext::new(
token_program.to_account_info(),
::anchor_spl::token_interface::GroupMemberPointerInitialize {
token_program_id: token_program.to_account_info(),
mint: mint.to_account_info(),
},
),
Option::<anchor_lang::prelude::Pubkey>::Some(manager.key()),
Option::<anchor_lang::prelude::Pubkey>::None,
)?;
}
::anchor_spl::token_interface::spl_token_2022::extension::ExtensionType::MetadataPointer => {
::anchor_spl::token_interface::metadata_pointer_initialize(
anchor_lang::context::CpiContext::new(
token_program.to_account_info(),
::anchor_spl::token_interface::MetadataPointerInitialize {
token_program_id: token_program.to_account_info(),
mint: mint.to_account_info(),
},
),
Option::<
anchor_lang::prelude::Pubkey,
>::Some(authority.key()),
Option::<anchor_lang::prelude::Pubkey>::Some(mint.key()),
)?;
}
::anchor_spl::token_interface::spl_token_2022::extension::ExtensionType::MintCloseAuthority => {
::anchor_spl::token_interface::mint_close_authority_initialize(
anchor_lang::context::CpiContext::new(
token_program.to_account_info(),
::anchor_spl::token_interface::MintCloseAuthorityInitialize {
token_program_id: token_program.to_account_info(),
mint: mint.to_account_info(),
},
),
Option::<
&anchor_lang::prelude::Pubkey,
>::Some(&manager.key()),
)?;
}
::anchor_spl::token_interface::spl_token_2022::extension::ExtensionType::TransferHook => {
::anchor_spl::token_interface::transfer_hook_initialize(
anchor_lang::context::CpiContext::new(
token_program.to_account_info(),
::anchor_spl::token_interface::TransferHookInitialize {
token_program_id: token_program.to_account_info(),
mint: mint.to_account_info(),
},
),
Option::<
anchor_lang::prelude::Pubkey,
>::Some(authority.key()),
Option::<anchor_lang::prelude::Pubkey>::None,
)?;
}
::anchor_spl::token_interface::spl_token_2022::extension::ExtensionType::NonTransferable => {
::anchor_spl::token_interface::non_transferable_mint_initialize(
anchor_lang::context::CpiContext::new(
token_program.to_account_info(),
::anchor_spl::token_interface::NonTransferableMintInitialize {
token_program_id: token_program.to_account_info(),
mint: mint.to_account_info(),
},
),
)?;
}
::anchor_spl::token_interface::spl_token_2022::extension::ExtensionType::PermanentDelegate => {
::anchor_spl::token_interface::permanent_delegate_initialize(
anchor_lang::context::CpiContext::new(
token_program.to_account_info(),
::anchor_spl::token_interface::PermanentDelegateInitialize {
token_program_id: token_program.to_account_info(),
mint: mint.to_account_info(),
},
),
Option::<
&anchor_lang::prelude::Pubkey,
>::Some(
&args
.permanent_delegate
.unwrap_or_else(|| manager.key())
.key(),
)
.unwrap(),
)?;
}
_ => {}
}
} We just need to find the macro generation part in anchor-spl to update towards the latest fix and that should probably remove the warning. |
resolved by We are still waiting for the next release of anchor to make use of it in WNS. |
The anchor token extensions macro inside the
Accounts
struct was triggering the token extensions stack violations warnings after fiddling with the expanded code usingcargo expand
The following code creates the "too many large-sized variables" warning
The text was updated successfully, but these errors were encountered: