archid_marketplace/
msg.rs

1use crate::state::{Config, SwapType};
2use cosmwasm_std::{Addr, Uint128};
3use cw20::Expiration;
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6
7#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
8pub struct InstantiateMsg {
9    pub admin: Addr,
10    pub cw721: Addr,
11}
12
13#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
14#[serde(rename_all = "snake_case")]
15pub enum ExecuteMsg {
16    Create(SwapMsg),
17    Finish(SwapMsg),
18    Cancel(CancelMsg),
19    Update(UpdateMsg),
20    UpdateConfig { config: Config },
21}
22#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
23#[serde(rename_all = "snake_case")]
24pub struct CancelMsg {
25    pub id: String,
26}
27#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
28pub struct UpdateMsg {
29    pub id: String,
30    pub expires: Expiration,
31    pub price: Uint128,
32}
33#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
34pub struct SwapMsg {
35    pub id: String,
36    pub payment_token: Option<Addr>, // Optional cw20 address; if `None` create swap for `aarch`
37    pub token_id: String,
38    pub expires: Expiration,
39    pub price: Uint128,
40    pub swap_type: SwapType,
41}
42
43#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
44#[serde(rename_all = "snake_case")]
45pub enum QueryMsg {
46    /// Get all swaps (enumerable)
47    /// Return type: ListResponse
48    List {
49        start_after: Option<String>,
50        limit: Option<u32>,
51    },
52    // Count total `SwapType::Offer` or `SwapType::Sale`
53    GetTotal {
54        swap_type: SwapType,
55    },
56    /// Get all swaps of type `SwapType::Offer`
57    GetOffers {
58        page: Option<u32>,
59        limit: Option<u32>,
60    },
61    /// Get all swaps of type `SwapType::Sale`
62    GetListings {
63        page: Option<u32>,
64        limit: Option<u32>,
65    },
66    /// Get all listings for a token of type `Swap::Sale` and `Swap::Offer`
67    /// or both (`None`)
68    ListingsOfToken {
69        token_id: String,
70        swap_type: Option<SwapType>,
71        page: Option<u32>,
72        limit: Option<u32>,
73    },
74    /// Show all swaps created by a specific address
75    /// Defaults to SwapType::Sale if no `swap_type`
76    SwapsOf {
77        address: Addr,
78        swap_type: Option<SwapType>,
79        page: Option<u32>,
80        limit: Option<u32>,
81    },
82    /// Show all swaps of a given price range
83    SwapsByPrice {
84        min: Option<Uint128>,
85        max: Option<Uint128>,
86        swap_type: Option<SwapType>,
87        page: Option<u32>,
88        limit: Option<u32>,
89    },
90    /// Show all swaps of a given denom (contract address)
91    /// Defaults to ARCH if no contract is sent
92    SwapsByDenom {
93        payment_token: Option<Addr>,
94        swap_type: Option<SwapType>,
95        page: Option<u32>,
96        limit: Option<u32>,
97    },
98    /// Show all cw20 swaps, or all ARCH swaps
99    SwapsByPaymentType {
100        cw20: bool,
101        swap_type: Option<SwapType>,
102        page: Option<u32>,
103        limit: Option<u32>,
104    },
105
106    /// Returns the details of the named swap, error if not created.
107    /// Return type: DetailsResponse.
108    Details {
109        id: String,
110    },
111}
112
113#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
114#[serde(rename_all = "snake_case")]
115pub struct MigrateMsg {}
116
117// List swaps
118#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
119pub struct ListResponse {
120    pub swaps: Vec<String>,
121}
122
123// Get details about a swap
124#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
125pub struct DetailsResponse {
126    pub creator: Addr,
127    pub contract: Addr,
128    pub payment_token: Option<Addr>,
129    pub token_id: String,
130    pub expires: Expiration,
131    pub price: Uint128,
132    pub swap_type: SwapType,
133}