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
use anchor_lang::{prelude::*, solana_program::instruction::Instruction, InstructionData};
use clockwork_utils::thread::ThreadResponse;
use crate::state::*;
#[derive(Accounts)]
pub struct DeleteSnapshotJob<'info> {
#[account(address = Config::pubkey())]
pub config: Account<'info, Config>,
#[account(
address = Registry::pubkey(),
constraint = !registry.locked
)]
pub registry: Account<'info, Registry>,
#[account(address = config.epoch_thread)]
pub thread: Signer<'info>,
}
pub fn handler(ctx: Context<DeleteSnapshotJob>) -> Result<ThreadResponse> {
let config = &ctx.accounts.config;
let registry = &ctx.accounts.registry;
let thread = &mut ctx.accounts.thread;
Ok(ThreadResponse {
dynamic_instruction: Some(
Instruction {
program_id: crate::ID,
accounts: crate::accounts::DeleteSnapshotProcessSnapshot {
config: config.key(),
registry: registry.key(),
snapshot: Snapshot::pubkey(registry.current_epoch.checked_sub(1).unwrap()),
thread: thread.key(),
}
.to_account_metas(Some(true)),
data: crate::instruction::DeleteSnapshotProcessSnapshot {}.data(),
}
.into(),
),
close_to: None,
trigger: None,
})
}