I have this piece of code, it skips the first 8 bytes of the account data as that's the descriminator
pub struct CustomProgramAccountStruct {
pub pubkey: Pubkey,
pub authority: Pubkey,
pub token: Pubkey,
}
fn handle_account(
&self,
account_info: &AccountInfo,
) -> Result<Box<dyn ParseResult + 'static>, CustomError> {
let account_data = if let Some(account_info) = account_info.data() {
account_info.iter().collect::<Vec<_>>()
} else {
return Err(CustomError::DeserializationError);
};
let account_type = match account_data.len() {
300 => {
let account: CustomProgramAccountStruct = try_from_slice_unchecked(&account_data[8..])?;
CustomProgramAccount::Account(account)
}
_ => {
return Err(CustomError::InvalidDataLength);
}
};
Ok(Box::new(account_type))
}
But the problem is when I check the saved data in database, I see token
is saved in authority
column and token
column has an public key entirely different. Can anyone help me with this please?