miclockwork_thread_program/instructions/
thread_instruction_remove.rs

1use {crate::state::*, anchor_lang::prelude::*};
2
3/// Accounts required by the `thread_instruction_remove` instruction.
4#[derive(Accounts)]
5#[instruction(index: u64)]
6pub struct ThreadInstructionRemove<'info> {
7    /// The authority (owner) of the thread.
8    #[account()]
9    pub authority: Signer<'info>,
10
11    /// The thread to be edited.
12    #[account(
13        mut,
14        seeds = [
15            SEED_THREAD,
16            thread.authority.as_ref(),
17            thread.id.as_slice(),
18        ],
19        bump = thread.bump,
20        has_one = authority
21    )]
22    pub thread: Account<'info, Thread>,
23}
24
25pub fn handler(ctx: Context<ThreadInstructionRemove>, index: u64) -> Result<()> {
26    // Get accounts
27    let thread = &mut ctx.accounts.thread;
28
29    // Pause the thread
30    thread.instructions.remove(index as usize);
31
32    Ok(())
33}