coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.36k stars 1.25k forks source link

Use bump with init_if_needed #2996

Open leemurus opened 1 month ago

leemurus commented 1 month ago

Is it possible to implement logic to use bump optimization when account exists?

Example:

#[account(
    init_if_needed,
    payer=signer,
    space=8 + Battle::INIT_SPACE,
    seeds=[
        BATTLE_SEED.as_bytes(),
        &pda_prg_state.battle_number.to_be_bytes(),
    ],
    bump = battle.bump,
)]
pub battle: Account<'info, Battle>,
acheroncrypto commented 1 month ago

I don't think this is possible currently, but it would be great to support this behavior.