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
use {
crate::{
extension::{BaseState, BaseStateWithExtensions, Extension, ExtensionType},
pod::*,
},
bytemuck::{Pod, Zeroable},
solana_program::pubkey::Pubkey,
};
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct PermanentDelegate {
pub delegate: OptionalNonZeroPubkey,
}
impl Extension for PermanentDelegate {
const TYPE: ExtensionType = ExtensionType::PermanentDelegate;
}
pub fn get_permanent_delegate<S: BaseState, BSE: BaseStateWithExtensions<S>>(
state: &BSE,
) -> Option<Pubkey> {
state
.get_extension::<PermanentDelegate>()
.ok()
.and_then(|e| Option::<Pubkey>::from(e.delegate))
}