use anchor_lang::prelude::*;
use crate::{
states::{
feature::{ActionDisabledFlag, DomainDisabledFlag},
Store,
},
utils::internal,
};
#[derive(Accounts)]
pub struct ToggleFeature<'info> {
pub authority: Signer<'info>,
#[account(mut)]
pub store: AccountLoader<'info, Store>,
}
pub(crate) fn unchecked_toggle_feature(
ctx: Context<ToggleFeature>,
domain: DomainDisabledFlag,
action: ActionDisabledFlag,
enable: bool,
) -> Result<()> {
ctx.accounts
.store
.load_mut()?
.set_feature_disabled(domain, action, !enable);
Ok(())
}
impl<'info> internal::Authentication<'info> for ToggleFeature<'info> {
fn authority(&self) -> &Signer<'info> {
&self.authority
}
fn store(&self) -> &AccountLoader<'info, Store> {
&self.store
}
}