Unboxed-Software / solana-course

A complete course for learning Solana, including creating and transferring tokens, making NFTs, on-chain app development, and more.
https://solana.com/developers
Mozilla Public License 2.0
395 stars 134 forks source link

Fix Module 6, section 1, Program Architecture #347

Closed 0xk2 closed 5 months ago

0xk2 commented 5 months ago

Code in zero copy section is not working in anchor ^v0.27

Change from

#[account(zero_copy)]
pub struct SomeReallyBigDataStruct {
    pub really_big_data: [u128; 1024], // 16,384 bytes
}

pub struct ConceptZeroCopy<'info> {
    #[account(zero)]
    pub some_really_big_data: AccountLoader<'info, SomeReallyBigDataStruct>,
}

to

#[account(zero_copy(unsafe))]
pub struct SomeBigDataStruct {
    pub really_big_data: [u128; 1024], // 16,384 bytes
}  

#[derive(Accounts)]
pub struct SomeFunctionContext<'info> {
    #[account(zero)]
    pub some_really_big_data: AccountLoader<'info, SomeBigDataStruct>,
}

Also, add dependency in Cargo.toml

bytemuck="1.15.0"
CoachChuckFF commented 5 months ago

Fixed the issue, closing.

https://github.com/Unboxed-Software/solana-course/commit/6678e68b4d80a21b4b7c2a06f47766a6e7e62fc4