Skip to content

Commit 2b4bb86

Browse files
committed
WIP
1 parent 0dc7f66 commit 2b4bb86

File tree

1 file changed

+15
-1
lines changed
  • contracts/programs/contract-reader-interface/src

1 file changed

+15
-1
lines changed

contracts/programs/contract-reader-interface/src/lib.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ pub mod contract_reader_interface {
1515
account.idx = test_idx;
1616
account.bump = ctx.bumps.data;
1717

18+
let test_struct_account = &mut ctx.accounts.test_struct.load_init()?;
19+
test_struct_account.idx = test_idx;
20+
test_struct_account.bump = ctx.bumps.test_struct;
21+
1822
Ok(())
1923
}
2024

@@ -89,7 +93,7 @@ pub mod contract_reader_interface {
8993
}
9094

9195
pub fn store(ctx: Context<StoreTestStruct>, test_idx: u64, data: TestStructData) -> Result<()> {
92-
let test_struct_account = &mut ctx.accounts.test_struct.load_init()?;
96+
let test_struct_account = &mut ctx.accounts.test_struct.load_mut()?;
9397

9498
test_struct_account.idx = test_idx;
9599
test_struct_account.bump = ctx.bumps.test_struct;
@@ -150,6 +154,16 @@ pub struct Initialize<'info> {
150154
bump)]
151155
pub data: Account<'info, DataAccount>,
152156

157+
#[account(
158+
init_if_needed,
159+
payer = signer,
160+
space = size_of::<TestStruct>() + 8,
161+
seeds=[b"struct_data".as_ref(), test_idx.to_le_bytes().as_ref()],
162+
bump
163+
)]
164+
pub test_struct: AccountLoader<'info, TestStruct>,
165+
166+
153167
pub system_program: Program<'info, System>,
154168
}
155169

0 commit comments

Comments
 (0)