antegen_thread_program/instructions/
thread_toggle.rs

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