coal_guilds_api/state/
mod.rs

1mod config;
2mod guild;
3mod invite;
4mod member;
5
6pub use config::*;
7pub use guild::*;
8pub use invite::*;
9pub use member::*;
10
11use steel::*;
12
13use crate::consts::{GUILD, CONFIG, INVITE, MEMBER};
14
15#[repr(u8)]
16#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
17pub enum GuildsAccount {
18    Config = 100,
19    Guild = 101,
20    Member = 102,
21    Invite = 103,
22}
23
24/// Fetch the PDA of the config account.
25pub fn config_pda() -> (Pubkey, u8) {
26    Pubkey::find_program_address(&[CONFIG], &crate::id())
27}
28
29/// Fetch the PDA of the boost account.
30pub fn guild_pda(authority: Pubkey) -> (Pubkey, u8) {
31    Pubkey::find_program_address(&[GUILD, authority.as_ref()], &crate::id())
32}
33
34/// Fetch the PDA of the stake account.
35pub fn member_pda(member: Pubkey) -> (Pubkey, u8) {
36    Pubkey::find_program_address(&[MEMBER, member.as_ref()], &crate::id())
37}
38
39/// Fetch the PDA of the stake account.
40pub fn invite_pda(guild: Pubkey, member: Pubkey) -> (Pubkey, u8) {
41    Pubkey::find_program_address(&[INVITE, guild.as_ref(), member.as_ref()], &crate::id())
42}