cw3_flex_multisig/
state.rs1use cosmwasm_schema::cw_serde;
2use cosmwasm_std::{Addr, QuerierWrapper};
3use cw3::DepositInfo;
4use cw4::Cw4Contract;
5use cw_storage_plus::Item;
6use cw_utils::{Duration, Threshold};
7
8use crate::error::ContractError;
9
10#[cw_serde]
12pub enum Executor {
13 Member,
15 Only(Addr),
17}
18
19#[cw_serde]
20pub struct Config {
21 pub threshold: Threshold,
22 pub max_voting_period: Duration,
23 pub group_addr: Cw4Contract,
25 pub executor: Option<Executor>,
28 pub proposal_deposit: Option<DepositInfo>,
30}
31
32impl Config {
33 pub fn authorize(&self, querier: &QuerierWrapper, sender: &Addr) -> Result<(), ContractError> {
38 if let Some(executor) = &self.executor {
39 match executor {
40 Executor::Member => {
41 self.group_addr
42 .is_member(querier, sender, None)?
43 .ok_or(ContractError::Unauthorized {})?;
44 }
45 Executor::Only(addr) => {
46 if addr != sender {
47 return Err(ContractError::Unauthorized {});
48 }
49 }
50 }
51 }
52 Ok(())
53 }
54}
55
56pub const CONFIG: Item<Config> = Item::new("config");