1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use {
    anchor_lang::prelude::*,
    crate::state::*,
};

#[derive(Accounts)]
pub struct DeleteIndex<'info> {
    #[account(
        mut, 
        seeds = [
            SEED_INDEX, 
            index.owner.key().as_ref(), 
            index.namespace.as_ref()
        ],
        bump = index.bump, 
        has_one = owner,
        close = owner,
        constraint = index.count == 0
    )]
    pub index: Account<'info, Index>,

    #[account(mut)]
    pub owner: Signer<'info>,
}

pub fn handler(_ctx: Context<DeleteIndex>) -> ProgramResult {
    return Ok(());
}