-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
If we have
src/lib.rs
use anchor_lang::prelude::*;
mod instructions;
use instructions::*;
declare_id!("74RTgw29JdNDxj3yCpg45y9iVjs2JmGGBNkbafSTeNv9");
#[program]
pub mod dupe_name_mre {
use super::*;
pub fn func_one(ctx: Context<FuncOne>) -> Result<()> {
Ok(())
}
pub fn func_two(ctx: Context<FuncTwo>) -> Result<()> {
Ok(())
}
}
src/instructions.rs
use anchor_lang::prelude::*;
// Check being done in line 7
#[derive(Accounts)]
pub struct FuncOne<'info> {
#[account(mut)]
/// CHECK: This account is checked!
pub my_account: UncheckedAccount<'info>,
}
// Missing check in line 14
#[derive(Accounts)]
pub struct FuncTwo<'info> {
#[account(mut)]
pub my_account: UncheckedAccount<'info>,
}
the error message gives
= help: message: Safety checks failed:
/programs/dupe-name-mre/src/instructions.rs:7:0
Struct field "my_account" is unsafe, but is not documented.
Please add a `/// CHECK:` doc comment explaining why no checks through types are necessary.
This is incorrect, as we do have the check in line 7, the place where it's missing is line 14. Since the two accounts have the same name though, it appears as though anchor only picks the first occurence, even if that's not where the error is.
Metadata
Metadata
Assignees
Labels
No labels