1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use cosmwasm_std::{Binary, Decimal};
5use cw721::Expiration;
6
7use crate::{state::{CollectionInfo, Approval, TokenInfo, ModelInfo}, ContractError};
8
9#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
10pub struct InstantiateMsg {
11 pub name: String,
12 pub symbol: String,
13 pub minter: String,
14 pub collection_info: CollectionInfo<RoyaltyInfoResponse>,
15}
16
17#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
18#[serde(rename_all = "snake_case")]
19pub enum ExecuteMsg<T> {
20 TransferNft { recipient: String, token_id: String },
21 SendNft {
22 contract: String,
23 token_id: String,
24 msg: Binary,
25 },
26 Approve {
27 spender: String,
28 token_id: String,
29 expires: Option<Expiration>,
30 },
31 Revoke { spender: String, token_id: String },
32
33 ApproveAll {
34 operator: String,
35 expires: Option<Expiration>,
36 },
37
38 RevokeAll { operator: String },
39
40 Mint(MintMsg<T>),
41
42 CreateShoeModel(CreateShoeModelMsg<T>),
43
44 Burn { token_id: String },
45
46 ModifyCollectionInfo {description: Option<String>, image: Option<String>, external_link: Option<String>, royalty_info: Option<RoyaltyInfoResponse> }
47}
48
49#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
50pub struct MintMsg<T> {
51 pub token_id: String,
52 pub owner: String,
53 pub model_id: String,
54 pub size: String,
55 pub extension: T,
56}
57
58#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
59pub struct CreateShoeModelMsg<T> {
60 pub model_id: String,
61 pub owner: String,
62 pub model_uri: String,
63 pub extension: T,
64}
65
66#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
67#[serde(rename_all = "snake_case")]
68pub enum QueryMsg {
69 OwnerOf {
70 token_id: String,
71 include_expired: Option<bool>,
72 },
73
74 Approval {
75 token_id: String,
76 spender: String,
77 include_expired: Option<bool>,
78 },
79
80 Approvals {
81 token_id: String,
82 include_expired: Option<bool>,
83 },
84
85 AllOperators {
86 owner: String,
87 include_expired: Option<bool>,
88 start_after: Option<String>,
89 limit: Option<u32>,
90 },
91
92 NumTokens {},
93
94 NumModels {},
95
96 ContractInfo {},
97
98 NftInfo {
99 token_id: String,
100 },
101
102 AllNftInfo {
103 token_id: String,
104 include_expired: Option<bool>,
105 },
106
107 ModelInfo {
108 model_id: String,
109 },
110
111 Tokens {
112 owner: String,
113 start_after: Option<String>,
114 limit: Option<u32>,
115 },
116
117 AllTokens {
118 start_after: Option<String>,
119 limit: Option<u32>,
120 },
121
122 AllTokensInfo {
123 start_after: Option<String>,
124 limit: Option<u32>,
125 },
126
127 AllModels {
128 start_after: Option<String>,
129 limit: Option<u32>,
130 },
131
132 AllModelsInfo {
133 start_after: Option<String>,
134 limit: Option<u32>,
135 },
136
137 Minter {},
138
139 CollectionInfo {},
140}
141
142#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
143pub struct MinterResponse {
144 pub minter: String,
145}
146
147#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
148pub struct CollectionInfoResponse {
149 pub creator: String,
150 pub description: String,
151 pub image: String,
152 pub external_link: Option<String>,
153 pub royalty_info: Option<RoyaltyInfoResponse>,
154}
155
156#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
157pub struct RoyaltyInfoResponse {
158 pub payment_address: String,
159 pub share: Decimal,
160}
161
162impl RoyaltyInfoResponse {
163 pub fn share_validate(&self) -> Result<Decimal, ContractError> {
164 if self.share > Decimal::percent(20) {
165 return Err(ContractError::InvalidRoyalities {});
166 }
167
168 Ok(self.share)
169 }
170}
171
172
173#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
174pub struct OwnerOfResponse {
175 pub owner: String,
176 pub approvals: Vec<Approval>,
177}
178
179#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
180pub struct ApprovalResponse {
181 pub approval: Approval,
182}
183
184#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
185pub struct ApprovalsResponse {
186 pub approvals: Vec<Approval>,
187}
188
189#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
190pub struct OperatorsResponse {
191 pub operators: Vec<Approval>,
192}
193
194#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
195pub struct NumTokensResponse {
196 pub count: u64,
197}
198
199#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
200pub struct NumModelsResponse {
201 pub count: u64,
202}
203
204#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
205pub struct ContractInfoResponse {
206 pub name: String,
207 pub symbol: String,
208}
209
210#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
211pub struct AllNftInfoResponse<T> {
212 pub access: OwnerOfResponse,
213 pub info: NftInfoResponse<T>,
214}
215
216#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
217pub struct NftInfoResponse<T> {
218 pub model_id: String,
219 pub token_uri: String,
220 pub size: String,
221 pub extension: T,
222}
223
224#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
225pub struct ModelInfoResponse<T> {
226 pub owner: String,
227 pub model_uri: String,
228 pub extension: T,
229}
230
231#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
232pub struct TokensResponse {
233 pub tokens: Vec<String>,
234}
235
236#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
237pub struct ModelsResponse {
238 pub models: Vec<String>,
239}
240
241#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
242pub struct AllNftsResponse<T> {
243 pub all_tokens_info: Vec<TokenInfo<T>>,
244}
245
246#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
247pub struct AllModelsResponse<T> {
248 pub all_models_info: Vec<ModelInfo<T>>,
249}