-
Notifications
You must be signed in to change notification settings - Fork 93
/
update_operation_account.rs
41 lines (37 loc) · 1.21 KB
/
update_operation_account.rs
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
38
39
40
41
use crate::error::ErrorCode;
use crate::states::*;
use anchor_lang::prelude::*;
#[derive(Accounts)]
pub struct UpdateOperationAccount<'info> {
/// Address to be set as operation account owner.
#[account(
address = crate::admin::id() @ ErrorCode::NotApproved
)]
pub owner: Signer<'info>,
/// Initialize operation state account to store operation owner address and white list mint.
#[account(
mut,
seeds = [
OPERATION_SEED.as_bytes(),
],
bump,
)]
pub operation_state: AccountLoader<'info, OperationState>,
pub system_program: Program<'info, System>,
}
pub fn update_operation_account(
ctx: Context<UpdateOperationAccount>,
param: u8,
keys: Vec<Pubkey>,
) -> Result<()> {
let mut operation_state = ctx.accounts.operation_state.load_mut()?;
let match_param = Some(param);
match match_param {
Some(0) => operation_state.update_operation_owner(keys),
Some(1) => operation_state.remove_operation_owner(keys),
Some(2) => operation_state.update_whitelist_mint(keys),
Some(3) => operation_state.remove_whitelist_mint(keys),
_ => return err!(ErrorCode::InvalidUpdateConfigFlag),
}
Ok(())
}