I'm using Anchor 0.28.0 and want to use this new feature that lets you specify which token program to use.
It looks very practical because it's used almost the same way as standard SPL accounts but I'm getting an error Error: Signature verification failed
when trying to send my transaction.
Investigating further, it seems to be caused by the Token account that cannot be created. My CPI context is defined like so:
#[derive(Accounts)]
pub struct CreateMetadata<'info> {
#[account(mut)]
pub payer: Signer<'info>,
#[account(mut)]
pub creator: Signer<'info>,
#[account(
seeds = [
AUTHORITIES_SEED.as_ref(),
authorities_group.id.as_ref()
],
bump
)]
pub authorities_group: Account<'info, AuthoritiesGroup>,
#[account(
init,
payer = payer,
mint::authority = authorities_group,
mint::decimals = 0,
mint::token_program = token_program,
)]
pub mint: InterfaceAccount<'info, Mint>,
#[account(
init_if_needed,
payer = payer,
token::mint = mint,
token::authority = authorities_group,
token::token_program = token_program,
)]
pub token_account: InterfaceAccount<'info, TokenAccount>,
#[account(
init,
payer = payer,
space = Metadata::LEN,
seeds = [
METADATA_SEED.as_ref(),
mint.key().as_ref()
],
bump
)]
pub metadata: Account<'info, Metadata>,
pub token_program: Interface<'info, TokenInterface>,
pub system_program: Program<'info, System>,
}
Everything works fine if I simply delete the token_account
. I followed what was described in the PR to write that code but it seems like token account creation is not well supported yet.
I made sure that the associated token account was created using the correct token program as shown below:
getAssociatedTokenAddressSync(
mintKeypair.publicKey,
holder.publicKey,
true,
TOKEN_2022_PROGRAM_ID
)
Trying to create the token account before the instruction does not work because I need to mint to exist but it's created by the instruction.
Are there known solutions for this?