base_minter/
state.rs

1use cosmwasm_std::{Addr, Empty, StdResult, Storage};
2use cw_storage_plus::Item;
3use sg4::{MinterConfig, Status};
4
5pub type Config = MinterConfig<Empty>;
6
7/// Initial configuration of the minter
8pub const CONFIG: Item<Config> = Item::new("config");
9
10/// This is saved after handling a reply in instantiation. Therefore it's not in `Config`.
11pub const COLLECTION_ADDRESS: Item<Addr> = Item::new("collection_address");
12
13/// Holds the status of the minter. Can be changed with on-chain governance proposals.
14pub const STATUS: Item<Status> = Item::new("status");
15
16/// This keeps track of the token index for the token_ids
17pub const TOKEN_INDEX: Item<u64> = Item::new("token_index");
18
19pub fn increment_token_index(store: &mut dyn Storage) -> StdResult<u64> {
20    let val = TOKEN_INDEX.may_load(store)?.unwrap_or_default() + 1;
21    TOKEN_INDEX.save(store, &val)?;
22    Ok(val)
23}