1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use crate::GroupAuthority;
use anchor_lang::{prelude::*, solana_program::pubkey::Pubkey};

#[derive(Accounts)]
pub struct UpdateGroupAuthority<'info> {
    pub authority: Signer<'info>,
    #[account(
        mut,
       constraint = group_authority.authority == *authority.key,
    )]
    pub group_authority: Account<'info, GroupAuthority>,
}

pub fn set_group_authority(
    group_authority: &mut Account<'_, GroupAuthority>,
    authority: Pubkey,
    seed: Option<Pubkey>,
) -> Result<()> {
    group_authority.authority = authority;
    if let Some(seed) = seed {
        group_authority.seed = seed;
    }
    Ok(())
}