clockwork_network/instructions/
snapshot_pause.rs1use {
2 crate::state::*,
3 anchor_lang::{prelude::*},
4 clockwork_crank::state::{Queue, SEED_QUEUE},
5};
6
7#[derive(Accounts)]
8pub struct SnapshotPause<'info> {
9 #[account(mut)]
10 pub admin: Signer<'info>,
11
12 #[account(seeds = [SEED_AUTHORITY], bump)]
13 pub authority: Account<'info, Authority>,
14
15 #[account(address = clockwork_crank::ID)]
16 pub clockwork_program: Program<'info, clockwork_crank::program::ClockworkCrank>,
17
18 #[account(seeds = [SEED_CONFIG], bump, has_one = admin)]
19 pub config: Account<'info, Config>,
20
21 #[account(
22 seeds = [
23 SEED_QUEUE,
24 authority.key().as_ref(),
25 "snapshot".as_bytes()
26 ],
27 seeds::program = clockwork_crank::ID,
28 bump,
29 )]
30 pub snapshot_queue: Account<'info, Queue>,
31}
32
33pub fn handler(ctx: Context<SnapshotPause>) -> Result<()> {
34 let authority = &ctx.accounts.authority;
36 let clockwork_program = &ctx.accounts.clockwork_program;
37 let snapshot_queue = &ctx.accounts.snapshot_queue;
38
39 let bump = *ctx.bumps.get("authority").unwrap();
41 clockwork_crank::cpi::queue_pause(
42 CpiContext::new_with_signer(
43 clockwork_program.to_account_info(),
44 clockwork_crank::cpi::accounts::QueuePause {
45 authority: authority.to_account_info(),
46 queue: snapshot_queue.to_account_info(),
47 },
48 &[&[SEED_AUTHORITY, &[bump]]]
49 ),
50 )?;
51
52 Ok(())
53}