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
use crate::state::*;

use anchor_lang::prelude::*;
use solana_program::sysvar;

#[derive(Accounts)]
#[instruction()]
pub struct AdminResetHealth<'info> {
    #[account(
        mut, 
        address = config.admin
    )]
    pub admin: Signer<'info>,

    #[account(address = sysvar::clock::ID)]
    pub clock: Sysvar<'info, Clock>,

    #[account(
        seeds = [SEED_CONFIG],
        bump = config.bump,
    )]
    pub config: Account<'info, Config>,

    #[account(
        mut,
        seeds = [SEED_HEALTH],
        bump = health.bump,
    )]
    pub health: Account<'info, Health>,
}

pub fn handler(ctx: Context<AdminResetHealth>) -> Result<()> {
    let clock = &ctx.accounts.clock;
    let health = &mut ctx.accounts.health;

    health.reset(clock)
}