sg721_base/
state.rs

1use cosmwasm_std::{Empty, Timestamp};
2use cw_storage_plus::Item;
3use serde::{de::DeserializeOwned, Serialize};
4use sg721::{CollectionInfo, RoyaltyInfo};
5use sg_std::StargazeMsgWrapper;
6use std::ops::Deref;
7
8type Parent<'a, T> = cw721_base::Cw721Contract<'a, T, StargazeMsgWrapper, Empty, Empty>;
9pub struct Sg721Contract<'a, T>
10where
11    T: Serialize + DeserializeOwned + Clone,
12{
13    pub parent: Parent<'a, T>,
14    pub collection_info: Item<'a, CollectionInfo<RoyaltyInfo>>,
15
16    /// Instantiate set to false by the minter, then true by creator to freeze collection info
17    pub frozen_collection_info: Item<'a, bool>,
18    pub royalty_updated_at: Item<'a, Timestamp>,
19}
20
21impl<'a, T> Default for Sg721Contract<'a, T>
22where
23    T: Serialize + DeserializeOwned + Clone,
24{
25    fn default() -> Self {
26        Sg721Contract {
27            parent: cw721_base::Cw721Contract::default(),
28            collection_info: Item::new("collection_info"),
29            frozen_collection_info: Item::new("frozen_collection_info"),
30            royalty_updated_at: Item::new("royalty_updated_at"),
31        }
32    }
33}
34
35impl<'a, T> Deref for Sg721Contract<'a, T>
36where
37    T: Serialize + DeserializeOwned + Clone,
38{
39    type Target = Parent<'a, T>;
40
41    fn deref(&self) -> &Self::Target {
42        &self.parent
43    }
44}