0

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?

0

1 Answer 1

0

The pubkey property in the struct was causing the issue. The account data doesn't have that property.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.