sg_whitelist/
state.rs

1use cosmwasm_schema::cw_serde;
2use cosmwasm_std::{Addr, Coin, Timestamp};
3use cw_storage_plus::{Item, Map};
4
5#[cw_serde]
6pub struct Config {
7    pub start_time: Timestamp,
8    pub end_time: Timestamp,
9    pub num_members: u32,
10    pub mint_price: Coin,
11    pub per_address_limit: u32,
12    pub member_limit: u32,
13}
14
15#[cw_serde]
16pub struct AdminList {
17    pub admins: Vec<Addr>,
18    pub mutable: bool,
19}
20
21impl AdminList {
22    pub fn is_admin(&self, addr: impl AsRef<str>) -> bool {
23        let addr = addr.as_ref();
24        self.admins.iter().any(|a| a.as_ref() == addr)
25    }
26
27    pub fn can_modify(&self, addr: &str) -> bool {
28        self.mutable && self.is_admin(addr)
29    }
30}
31
32pub const ADMIN_LIST: Item<AdminList> = Item::new("admin_list");
33
34pub const CONFIG: Item<Config> = Item::new("config");
35pub const WHITELIST: Map<Addr, bool> = Map::new("wl");