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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use {
    anchor_lang::prelude::*,
    crate::state::*,
};

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

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

    #[account(
        mut,
        seeds = [
            SEED_POINTER,
            index.key().as_ref(),
            pointer.name.as_bytes(),
        ],
        bump = pointer.bump,
        close = owner
    )]
    pub pointer: Account<'info, Pointer>,

    #[account(
        mut,
        seeds = [
            SEED_PROOF,
            index.key().as_ref(),
            pointer.value.as_ref(),
        ],
        bump = proof.bump,
        close = owner
    )]
    pub proof: Account<'info, Proof>,
}

pub fn handler(ctx: Context<DeletePointer>) -> ProgramResult {
    // Get accounts.
    let index = &mut ctx.accounts.index;

    // Decrement index counter.
    index.count -= 1;
    
    return Ok(());
}