My anchor program "A", expect to use data from a anchor program name "B".
Let's say program_b (which I don't have code, just know it's address) has declare PDA account data struct:
#[account]
#[derive(InitSpace)]
pub struct FeeData {
pub fee: u64,
}
and I got this account address that pass into program_a.
And in program_a, related code is:
...
#[account]
#[derive(InitSpace)]
pub struct FeeData { // mock after the struct on program_b
pub fee: u64,
}
#[derive(Accounts)]
pub struct Initialize<'info> {
...
/// CHECK: no check purposely
pub fee_from_prog_b: Account<'info, FeeData>,
...
}
But, once invode instruction on program_a, I got error:
Error Code: AccountDiscriminatorMismatch. Error Number: 3002. Error Message: 8 byte discriminator did not match what was expected.'
I know there is account discriminator and why this error raise. After search in the forumn, I got this one: How to Deserialize Anchor Accounts from Other Programs in Accounts Struct but I don't like this way to make it work.
Edit: I would like an #account attribute way, or hand coding to read that out(but I don't know how to).
So, I'm looking for a better solution to this requirement.
Thanks in advance.