sol_cerberus/instructions/
delete_app.rs

1use crate::state::app::{App, AppChanged};
2use crate::utils::app::allowed_authority;
3use crate::utils::utc_now;
4use crate::Errors;
5use anchor_lang::prelude::*;
6
7#[derive(Accounts)]
8pub struct DeleteApp<'info> {
9    #[account(mut)]
10    pub authority: Signer<'info>,
11    #[account(
12        mut,
13        close = collector,
14        constraint = allowed_authority(&authority.key(), &app.authority)  @ Errors::Unauthorized,
15        seeds = [b"app".as_ref(), app.id.key().as_ref()], 
16        bump = app.bump,
17    )]
18    pub app: Account<'info, App>,
19    /// CHECK: collector of the funds
20    #[account(mut)]
21    collector: AccountInfo<'info>,
22}
23
24pub fn delete_app(ctx: Context<DeleteApp>) -> Result<()> {
25    emit!(AppChanged {
26        time: utc_now(),
27        app_id: ctx.accounts.app.id,
28        authority: ctx.accounts.app.authority,
29    });
30    Ok(())
31}