cronos_network/state/
authority.rs1use {
2 crate::pda::PDA,
3 anchor_lang::{prelude::*, AnchorDeserialize},
4 std::convert::TryFrom,
5};
6
7pub const SEED_AUTHORITY: &[u8] = b"authority";
8
9#[account]
14#[derive(Debug)]
15pub struct Authority {
16 pub manager: Pubkey,
17}
18
19impl Authority {
20 pub fn pda() -> PDA {
21 Pubkey::find_program_address(&[SEED_AUTHORITY], &crate::ID)
22 }
23}
24
25impl TryFrom<Vec<u8>> for Authority {
26 type Error = Error;
27 fn try_from(data: Vec<u8>) -> std::result::Result<Self, Self::Error> {
28 Authority::try_deserialize(&mut data.as_slice())
29 }
30}
31
32pub trait AuthorityAccount {
37 fn new(&mut self, manager: Pubkey) -> Result<()>;
38}
39
40impl AuthorityAccount for Account<'_, Authority> {
41 fn new(&mut self, manager: Pubkey) -> Result<()> {
42 self.manager = manager;
43 Ok(())
44 }
45}