sablier_thread_program/instructions/
thread_instruction_remove.rs

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