komple_framework_marketplace_module/
msg.rs

1use crate::state::{Config, FixedListing};
2use cosmwasm_schema::{cw_serde, QueryResponses};
3use cosmwasm_std::Uint128;
4use cw20::Cw20ReceiveMsg;
5use komple_framework_types::modules::marketplace::Listing;
6use komple_framework_types::shared::execute::SharedExecuteMsg;
7use komple_framework_types::shared::query::ResponseWrapper;
8
9/// Message to be sent along the ```RegisterMsg``` for instantiation.
10#[cw_serde]
11pub struct InstantiateMsg {
12    pub fund_info: MarketplaceFundInfo,
13}
14
15#[cw_serde]
16pub struct MarketplaceFundInfo {
17    pub is_native: bool,
18    pub denom: String,
19    pub cw20_address: Option<String>,
20}
21
22#[cw_serde]
23pub enum ExecuteMsg {
24    /// Admin message.
25    ///
26    /// Update the lock for buying.
27    /// This applies for the normal buy operation.
28    UpdateBuyLock {
29        lock: bool,
30    },
31    /// Public message.
32    ///
33    /// List a new token for fixed amount sale.
34    /// Every token created under parent hub
35    /// can be listed for sale.
36    ListFixedToken {
37        collection_id: u32,
38        token_id: u32,
39        price: Uint128,
40    },
41    /// Public message.
42    ///
43    /// Remove a token from fixed amount sale.
44    DelistFixedToken {
45        collection_id: u32,
46        token_id: u32,
47    },
48    /// Public message.
49    ///
50    /// Update the price of a listed token based on listing type.
51    UpdatePrice {
52        listing_type: Listing,
53        collection_id: u32,
54        token_id: u32,
55        price: Uint128,
56    },
57    /// Public message.
58    ///
59    /// Buy a token that is listed on the marketplace.
60    Buy {
61        listing_type: Listing,
62        collection_id: u32,
63        token_id: u32,
64    },
65    /// Admin message.
66    ///
67    /// Same as ```Buy``` message but can be used with permissions.
68    PermissionBuy {
69        listing_type: Listing,
70        collection_id: u32,
71        token_id: u32,
72        buyer: String,
73    },
74    /// Admin message.
75    ///
76    /// Update the operators of this contract.
77    UpdateOperators {
78        addrs: Vec<String>,
79    },
80    /// Hub message.
81    ///
82    /// Lock the execute entry point.
83    /// Can only be called by the hub module.
84    LockExecute {},
85    Receive(Cw20ReceiveMsg),
86}
87
88impl From<ExecuteMsg> for SharedExecuteMsg {
89    fn from(msg: ExecuteMsg) -> Self {
90        match msg {
91            ExecuteMsg::LockExecute {} => SharedExecuteMsg::LockExecute {},
92            _ => unreachable!("Cannot convert {:?} to SharedExecuteMessage", msg),
93        }
94    }
95}
96
97#[cw_serde]
98pub enum ReceiveMsg {
99    Buy {
100        listing_type: Listing,
101        collection_id: u32,
102        token_id: u32,
103    },
104}
105
106#[cw_serde]
107#[derive(QueryResponses)]
108pub enum QueryMsg {
109    /// Get the contract's config.
110    #[returns(ResponseWrapper<Config>)]
111    Config {},
112    /// Get the fixed listing for a given collection and token id.
113    #[returns(ResponseWrapper<FixedListing>)]
114    FixedListing { collection_id: u32, token_id: u32 },
115    /// Get the list of fixed token listings under a collection with pagination.
116    #[returns(ResponseWrapper<Vec<FixedListing>>)]
117    FixedListings {
118        collection_id: u32,
119        start_after: Option<u32>,
120        limit: Option<u32>,
121    },
122    /// Get the operators of this contract.
123    #[returns(ResponseWrapper<Vec<String>>)]
124    Operators {},
125}
126
127#[cw_serde]
128pub struct MigrateMsg {}