sablier_thread_program/instructions/
thread_delete.rsuse {
crate::{constants::*, state::*},
anchor_lang::prelude::*,
};
#[derive(Accounts)]
pub struct ThreadDelete<'info> {
#[account(
constraint = authority.key().eq(&thread.authority) || authority.key().eq(&thread.key())
)]
pub authority: Signer<'info>,
#[account(mut)]
pub close_to: SystemAccount<'info>,
#[account(
mut,
seeds = [
SEED_THREAD,
thread.authority.as_ref(),
thread.id.as_slice(),
thread.domain.as_ref().unwrap_or(&Vec::new()).as_slice()
],
bump = thread.bump,
)]
pub thread: Account<'info, Thread>,
}
pub fn handler(ctx: Context<ThreadDelete>) -> Result<()> {
let thread = &ctx.accounts.thread;
let close_to = &ctx.accounts.close_to;
let thread_lamports = thread.get_lamports();
thread.sub_lamports(thread_lamports)?;
close_to.add_lamports(thread_lamports)?;
Ok(())
}