cw721_archid/msg.rs
1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use cosmwasm_std::Binary;
5use cw721_updatable::Expiration;
6
7#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
8pub struct InstantiateMsg {
9 /// Name of the NFT contract
10 pub name: String,
11 /// Symbol of the NFT contract
12 pub symbol: String,
13
14 /// The minter is the only one who can create new NFTs.
15 /// This is designed for a base NFT that is controlled by an external program
16 /// or contract. You will likely replace this with custom logic in custom NFTs
17 pub minter: String,
18}
19
20/// This is like Cw721ExecuteMsg but we add a Mint command for an owner
21/// to make this stand-alone. You will likely want to remove mint and
22/// use other control logic in any contract that inherits this.
23#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
24#[serde(rename_all = "snake_case")]
25pub enum ExecuteMsg<T, E> {
26 /// Transfer is a base message to move a token to another account without triggering actions
27 TransferNft {
28 recipient: String,
29 token_id: String
30 },
31
32 /// Send is a base message to transfer a token to a contract and trigger an action
33 /// on the receiving contract.
34 SendNft {
35 contract: String,
36 token_id: String,
37 msg: Binary,
38 },
39
40 /// Allows operator to transfer / send the token from the owner's account.
41 /// If expiration is set, then this allowance has a time/height limit
42 Approve {
43 spender: String,
44 token_id: String,
45 expires: Option<Expiration>,
46 },
47
48 /// Remove previously granted Approval
49 Revoke {
50 spender: String,
51 token_id: String
52 },
53
54 /// Allows operator to transfer / send any token from the owner's account.
55 /// If expiration is set, then this allowance has a time/height limit
56 ApproveAll {
57 operator: String,
58 expires: Option<Expiration>,
59 },
60 /// Remove previously granted ApproveAll permission
61 RevokeAll { operator: String },
62
63 /// Mint a new NFT, can only be called by the contract minter
64 Mint(MintMsg<T>),
65
66 /// Burn an NFT, only admin can do this
67 Burn { token_id: String },
68
69 /// Extension msg
70 Extension { msg: E },
71
72 /// Update extension metadata
73 UpdateMetadata(UpdateMetadataMsg<T>),
74}
75
76#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
77pub struct MintMsg<T> {
78 /// Unique ID of the NFT
79 pub token_id: String,
80 /// The owner of the newly minter NFT
81 pub owner: String,
82 /// Universal resource identifier for this NFT
83 /// Should point to a JSON file that conforms to the ERC721
84 /// Metadata JSON Schema
85 pub token_uri: Option<String>,
86 /// Any custom extension used by this contract
87 pub extension: T,
88}
89
90#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
91pub struct UpdateMetadataMsg<T> {
92 /// Unique ID of the NFT
93 pub token_id: String,
94 /// Any custom extension used by this contract
95 pub extension: T,
96}
97
98#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
99#[serde(rename_all = "snake_case")]
100pub enum QueryMsg<Q> {
101 /// Return the owner of the given token, error if token does not exist
102 /// Return type: OwnerOfResponse
103 OwnerOf {
104 token_id: String,
105 /// unset or false will filter out expired approvals, you must set to true to see them
106 include_expired: Option<bool>,
107 },
108 /// Return operator that can access all of the owner's tokens.
109 /// Return type: `ApprovalResponse`
110 Approval {
111 token_id: String,
112 spender: String,
113 include_expired: Option<bool>,
114 },
115 /// Return approvals that a token has
116 /// Return type: `ApprovalsResponse`
117 Approvals {
118 token_id: String,
119 include_expired: Option<bool>,
120 },
121 /// List all operators that can access all of the owner's tokens
122 /// Return type: `OperatorsResponse`
123 AllOperators {
124 owner: String,
125 /// unset or false will filter out expired items, you must set to true to see them
126 include_expired: Option<bool>,
127 start_after: Option<String>,
128 limit: Option<u32>,
129 },
130 /// Total number of tokens issued
131 NumTokens {},
132
133 /// With MetaData Extension.
134 /// Returns top-level metadata about the contract: `ContractInfoResponse`
135 ContractInfo {},
136 /// With MetaData Extension.
137 /// Returns metadata about one particular token, based on *ERC721 Metadata JSON Schema*
138 /// but directly from the contract: `NftInfoResponse`
139 NftInfo {
140 token_id: String,
141 },
142 /// With MetaData Extension.
143 /// Returns the result of both `NftInfo` and `OwnerOf` as one query as an optimization
144 /// for clients: `AllNftInfo`
145 AllNftInfo {
146 token_id: String,
147 /// unset or false will filter out expired approvals, you must set to true to see them
148 include_expired: Option<bool>,
149 },
150
151 /// With Enumerable extension.
152 /// Returns all tokens owned by the given address, [] if unset.
153 /// Return type: TokensResponse.
154 Tokens {
155 owner: String,
156 start_after: Option<String>,
157 limit: Option<u32>,
158 },
159 /// With Enumerable extension.
160 /// Requires pagination. Lists all token_ids controlled by the contract.
161 /// Return type: TokensResponse.
162 AllTokens {
163 start_after: Option<String>,
164 limit: Option<u32>,
165 },
166
167 // Return the minter
168 Minter {},
169
170 /// Extension query
171 Extension {
172 msg: Q,
173 },
174}
175
176/// Shows who can mint these tokens
177#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
178pub struct MinterResponse {
179 pub minter: String,
180}