According to the Anchor Book bump constraint can be specified for a PDA, so Anchor doesn't need to search for it:
#[derive(Accounts)]
pub struct ChangeUserName<'info> {
pub user: Signer<'info>,
#[account(mut, seeds = [b"user-stats", user.key().as_ref()], bump = user_stats.bump)]
pub user_stats: Account<'info, UserStats>,
}
But when I try to use the same approach with AccountLoader:
#[derive(Accounts)]
pub struct ChangeUserName<'info> {
pub user: Signer<'info>,
#[account(mut, seeds = [b"user-stats", user.key().as_ref()], bump = user_stats.bump)]
pub user_stats: AccountLoader<'info, UserStats>,
}
I get an error:
error[E0609]: no field
bump
on type `anchor_lang::prelude::AccountLoader<'_, UserStats>
Is that a limitation of Anchor or there is a way to fix that code?