cw3_fixed_multisig/
state.rs

1use cosmwasm_schema::cw_serde;
2use cosmwasm_std::{Addr, StdResult, Storage};
3
4use cw3::{Ballot, Proposal};
5use cw_storage_plus::{Item, Map};
6use cw_utils::{Duration, Threshold};
7
8#[cw_serde]
9pub struct Config {
10    pub threshold: Threshold,
11    pub total_weight: u64,
12    pub max_voting_period: Duration,
13}
14
15// unique items
16pub const CONFIG: Item<Config> = Item::new("config");
17pub const PROPOSAL_COUNT: Item<u64> = Item::new("proposal_count");
18
19// multiple-item map
20pub const BALLOTS: Map<(u64, &Addr), Ballot> = Map::new("votes");
21pub const PROPOSALS: Map<u64, Proposal> = Map::new("proposals");
22
23// multiple-item maps
24pub const VOTERS: Map<&Addr, u64> = Map::new("voters");
25
26pub fn next_id(store: &mut dyn Storage) -> StdResult<u64> {
27    let id: u64 = PROPOSAL_COUNT.may_load(store)?.unwrap_or_default() + 1;
28    PROPOSAL_COUNT.save(store, &id)?;
29    Ok(id)
30}