1

The Requester struct looks like this

#[account(zero_copy)]
pub struct Requester {
    pub authority: Pubkey,
    pub oracle: Pubkey,
    pub created_at: i64,
    pub count: u64,
    pub last_updated: i64,
    pub random: [u8; 64],
    pub pkt_id: [u8; 32],
    pub tls_id: [u8; 32],
    pub active_request: bool,
    pub uuid: u64,
    pub bump: u8,
}

and this is one of the use case

pub struct Initialize<'info> {
    #[account(
        init, 
        seeds = [b"r-seed".as_ref(), authority.key().as_ref(), &uuid.to_le_bytes()],
        bump,
        payer = authority,
        space = 8 + size_of::<Requester>()
    )]
    pub requester: Account<'info, Requester>,

but i get this error when i run anchor build

 the trait bound `Requester: anchor_lang::AccountSerialize` is not satisfied
   --> /home/icus/.cargo/registry/src/github.com-1ecc6299db9ec823/solrand-0.1.5/src/lib.rs:151:20
    |
151 |     pub requester: Account<'info, Requester>,
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `anchor_lang::AccountSerialize` is not implemented for `Requester`
 pub struct Account<'info, T: AccountSerialize + AccountDeserialize + Owner + Clone> {
    |                              ^^^^^^^^^^^^^^^^ required by this bound in `anchor_lang::prelude::Account`

Any help on how this can be solved will be appreciated.

1 Answer 1

4

The zero_copy macro doesn't derive AccountSerialize. It derives Pod, Zeroable, ZeroCopy, Discriminator, and AccountDeserialize. If you instead replace Account<'info, Requester> with AccountLoader<'info, Requester>, (docs here) which is intended to be used with ZeroCopy accounts, your program should work.

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.