@@ -303,12 +303,6 @@ pub mod let_me_buy {
303303 StoreErrorCode :: InvalidAuthority
304304 ) ;
305305
306- // Probably not necessary to delete all products before deleting the bar
307- // require!(
308- // ctx.accounts.receipts.products.is_empty(),
309- // ShotErrorCode::BarNotEmpty
310- // );
311-
312306 // Close the account and send rent to authority
313307 let authority = ctx. accounts . authority . to_account_info ( ) ;
314308 let receipts = ctx. accounts . receipts . to_account_info ( ) ;
@@ -320,6 +314,11 @@ pub mod let_me_buy {
320314
321315 Ok ( ( ) )
322316 }
317+
318+ pub fn realloc_store ( ctx : Context < ReallocStore > , store_name : String ) -> Result < ( ) > {
319+ msg ! ( "Reallocating store account to new size" ) ;
320+ Ok ( ( ) )
321+ }
323322}
324323
325324#[ account]
@@ -474,6 +473,31 @@ pub struct DeleteStore<'info> {
474473 pub authority : Signer < ' info > ,
475474}
476475
476+ #[ derive( Accounts ) ]
477+ #[ instruction( store_name: String ) ]
478+ pub struct ReallocStore < ' info > {
479+ #[ account(
480+ mut ,
481+ seeds = [ b"receipts" , store_name. as_bytes( ) ] ,
482+ bump,
483+ realloc = 8 + // discriminator
484+ 4 + ( 32 * 20 ) + // receipts vec (4 for length + 20 * size of Receipt)
485+ 8 + // total_purchases
486+ 4 + 32 + // store_name string
487+ 32 + // authority
488+ 4 + ( 32 * 20 ) + // products vec
489+ 4 + 32 + // telegram_channel_id string
490+ 1 + // bump
491+ 4 + 128 , // details string
492+ realloc:: payer = authority,
493+ realloc:: zero = true
494+ ) ]
495+ pub receipts : Box < Account < ' info , Receipts > > ,
496+ #[ account( mut ) ]
497+ pub authority : Signer < ' info > ,
498+ pub system_program : Program < ' info , System > ,
499+ }
500+
477501#[ derive( AnchorSerialize , AnchorDeserialize , Clone , Default , InitSpace ) ]
478502pub struct Products {
479503 pub price : u64 ,
0 commit comments