Say I have an account in Program A, and I know it looks like this:
#[account(zero_copy)]
pub struct SomeAcc {
pub some_num: u32,
}
Now in my Program B, I copy and paste this struct exactly into my new codebase. Let's say I have no access to Program A's source code other than that I know this struct. Now I want to access a SomeAcc
created from Program A in Program B
#[derive(Accounts)]
pub struct GetSomeAcc<'info> {
#[account()]
pub acc: AccountLoader<'info, SomeAcc>,
}
pub fn handler(ctx: Context<GetSomeAcc>) -> Result<()> {
let acc = ctx.accounts.acc.load()?;
msg!("acc val {:?}", acc.some_num);
}
This will give me AccountOwnedByWrongProgram
, because Program A created that account. So how can I tell AccountLoader to ignore the program ownership check and try to deserialize anyways?