Skip to main content

komple_framework_mint_module/
msg.rs

1use crate::state::{CollectionInfo, Config};
2use cosmwasm_schema::{cw_serde, QueryResponses};
3use cosmwasm_std::Binary;
4use cw20::Cw20ReceiveMsg;
5use komple_framework_token_module::{
6    msg::{MetadataInfo, TokenInfo},
7    state::CollectionConfig,
8};
9use komple_framework_types::shared::execute::SharedExecuteMsg;
10use komple_framework_types::shared::query::ResponseWrapper;
11
12#[cw_serde]
13pub struct CollectionFundInfo {
14    pub is_native: bool,
15    pub denom: String,
16    pub cw20_address: Option<String>,
17}
18
19#[cw_serde]
20pub enum ExecuteMsg {
21    /// Admin and public message.
22    ///
23    /// Create a new collection.
24    /// This can be executed by both admin and users based on configuration.
25    CreateCollection {
26        code_id: u64,
27        collection_info: CollectionInfo,
28        collection_config: CollectionConfig,
29        token_info: TokenInfo,
30        metadata_info: MetadataInfo,
31        fund_info: CollectionFundInfo,
32        linked_collections: Option<Vec<u32>>,
33    },
34    /// Admin message.
35    ///
36    /// Update the configuration for public collection creation.
37    /// If set to true, users can create collections.
38    UpdatePublicCollectionCreation {
39        public_collection_creation: bool,
40    },
41    /// Admin message.
42    ///
43    /// Update the configuration for collection mint lock.
44    UpdateCollectionMintLock {
45        collection_id: u32,
46        lock: bool,
47    },
48    /// Public message.
49    ///
50    /// Mint a new token on a collection.
51    /// Additional metadata id can be provided to link to a certain metadata.
52    Mint {
53        collection_id: u32,
54        metadata_id: Option<u32>,
55    },
56    /// Admin message.
57    ///
58    /// Same as `Mint` message but only executable by admin.
59    AdminMint {
60        collection_id: u32,
61        recipient: String,
62        metadata_id: Option<u32>,
63    },
64    /// Admin message.
65    ///
66    /// Same as `Mint` message but can be used with permissions.
67    PermissionMint {
68        permission_msg: Binary,
69        mint_msg: MintMsg,
70    },
71    /// Admin message.
72    ///
73    /// Update the operators of this contract.
74    UpdateOperators {
75        addrs: Vec<String>,
76    },
77    /// Admin message.
78    ///
79    /// Update the linked collections of a collection.
80    UpdateLinkedCollections {
81        collection_id: u32,
82        linked_collections: Vec<u32>,
83    },
84    /// Admin message.
85    ///
86    /// Update the status of a collection. Whitelist or blacklist.
87    UpdateCollectionStatus {
88        collection_id: u32,
89        is_blacklist: bool,
90    },
91    /// Hub message.
92    ///
93    /// Lock the execute entry point.
94    /// Can only be called by the hub module.
95    LockExecute {},
96    /// Admin message.
97    ///
98    /// Update addresses that can create collections.
99    UpdateCreators {
100        addrs: Vec<String>,
101    },
102    Receive(Cw20ReceiveMsg),
103}
104
105impl From<ExecuteMsg> for SharedExecuteMsg {
106    fn from(msg: ExecuteMsg) -> Self {
107        match msg {
108            ExecuteMsg::LockExecute {} => SharedExecuteMsg::LockExecute {},
109            _ => unreachable!("Cannot convert {:?} to SharedExecuteMessage", msg),
110        }
111    }
112}
113
114#[cw_serde]
115pub enum ReceiveMsg {
116    Mint {
117        collection_id: u32,
118        metadata_id: Option<u32>,
119    },
120}
121
122#[cw_serde]
123#[derive(QueryResponses)]
124pub enum QueryMsg {
125    /// Get the contract's config.
126    #[returns(ResponseWrapper<Config>)]
127    Config {},
128    /// Resolve the collection address for a collection id.
129    #[returns(ResponseWrapper<String>)]
130    CollectionAddress { collection_id: u32 },
131    /// Get the collection info for a collection id.
132    #[returns(ResponseWrapper<CollectionInfo>)]
133    CollectionInfo { collection_id: u32 },
134    /// Get the operators of this contract.
135    #[returns(ResponseWrapper<Vec<String>>)]
136    Operators {},
137    /// Get the linked collections of a collection.
138    #[returns(ResponseWrapper<Vec<u32>>)]
139    LinkedCollections { collection_id: u32 },
140    /// List the collections with pagination.
141    #[returns(ResponseWrapper<Vec<CollectionsResponse>>)]
142    Collections {
143        blacklist: bool,
144        start_after: Option<u32>,
145        limit: Option<u8>,
146    },
147    /// Get the creators of this contract.
148    #[returns(ResponseWrapper<Vec<String>>)]
149    Creators {},
150    /// Get the mint lock for collection
151    #[returns(ResponseWrapper<bool>)]
152    MintLock { collection_id: u32 },
153}
154
155/// Message used to mint new tokens on a collection.
156#[cw_serde]
157pub struct MintMsg {
158    pub collection_id: u32,
159    pub recipient: String,
160    pub metadata_id: Option<u32>,
161}
162
163#[cw_serde]
164pub struct MigrateMsg {}
165
166#[cw_serde]
167pub struct CollectionsResponse {
168    pub collection_id: u32,
169    pub address: String,
170}