provwasm_tutorial/
state.rs1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use cosmwasm_std::{Addr, Decimal, Storage};
5use cosmwasm_storage::{singleton, singleton_read, ReadonlySingleton, Singleton};
6
7pub static CONFIG_KEY: &[u8] = b"config";
8
9#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
11pub struct State {
12 pub purchase_denom: String,
14 pub merchant_address: Addr,
16 pub fee_collection_address: Addr,
18 pub fee_percent: Decimal,
20}
21
22pub fn config(storage: &mut dyn Storage) -> Singleton<State> {
23 singleton(storage, CONFIG_KEY)
24}
25
26pub fn config_read(storage: &dyn Storage) -> ReadonlySingleton<State> {
27 singleton_read(storage, CONFIG_KEY)
28}