sablier_network_program/jobs/take_snapshot/
job.rs1use anchor_lang::{
2 prelude::*,
3 solana_program::{instruction::Instruction, system_program},
4 InstructionData,
5};
6use sablier_utils::thread::{ThreadResponse, PAYER_PUBKEY};
7
8use crate::state::*;
9
10#[derive(Accounts)]
11pub struct TakeSnapshotJob<'info> {
12 #[account(address = Config::pubkey())]
13 pub config: AccountLoader<'info, Config>,
14
15 #[account(
16 address = Registry::pubkey(),
17 constraint = registry.locked
18 )]
19 pub registry: Account<'info, Registry>,
20
21 #[account(address = config.load()?.epoch_thread)]
22 pub thread: Signer<'info>,
23}
24
25pub fn handler(ctx: Context<TakeSnapshotJob>) -> Result<ThreadResponse> {
26 let config = &ctx.accounts.config;
28 let registry = &ctx.accounts.registry;
29 let thread = &ctx.accounts.thread;
30
31 Ok(ThreadResponse {
32 dynamic_instruction: Some(
33 Instruction {
34 program_id: crate::ID,
35 accounts: crate::accounts::TakeSnapshotCreateSnapshot {
36 config: config.key(),
37 payer: PAYER_PUBKEY,
38 registry: registry.key(),
39 snapshot: Snapshot::pubkey(registry.current_epoch + 1),
40 system_program: system_program::ID,
41 thread: thread.key(),
42 }
43 .to_account_metas(Some(true)),
44 data: crate::instruction::TakeSnapshotCreateSnapshot {}.data(),
45 }
46 .into(),
47 ),
48 close_to: None,
49 trigger: None,
50 })
51}