Solana's Token 22 tutorial tells you how to upgrade to 2022, but most deployed programs need to support existing accounts that were made with the Token program.
Let's say we have an ix that makes a classic TokenAccount as a PDA, a very common implementation:
pub some_mint: Account<'info, Mint>,
#[account(
init,
// seeds, payer, mint, authority
)]
pub some_acc: Account<'info, TokenAccount>,
pub token_program: Program<'info, Token>,
Now we want to support mints made with Token2022, which should open a token2022 account instead. We might change this to:
#[account(
// validate owner = token2022
)]
pub some_mint: InterfaceAccount<'info, MintInterface>,
#[account(
// same as before...
owner = token22;
)]
pub some_acc: InterfaceAccount<'info, TokenAccountInterface>,
pub token_program: Program<'info, Token2022>,
But what if we want to make a Token account if Mint uses the regular Token program, or a Token22 account if Mint uses the Token22 program? Do we have to make two instructions?