File tree 1 file changed +15
-1
lines changed
contracts/programs/contract-reader-interface/src
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ pub mod contract_reader_interface {
15
15
account. idx = test_idx;
16
16
account. bump = ctx. bumps . data ;
17
17
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
+
18
22
Ok ( ( ) )
19
23
}
20
24
@@ -89,7 +93,7 @@ pub mod contract_reader_interface {
89
93
}
90
94
91
95
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 ( ) ?;
93
97
94
98
test_struct_account. idx = test_idx;
95
99
test_struct_account. bump = ctx. bumps . test_struct ;
@@ -150,6 +154,16 @@ pub struct Initialize<'info> {
150
154
bump) ]
151
155
pub data : Account < ' info , DataAccount > ,
152
156
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
+
153
167
pub system_program : Program < ' info , System > ,
154
168
}
155
169
You can’t perform that action at this time.
0 commit comments