cw721_base/msg.rs
1use cosmwasm_schema::{cw_serde, QueryResponses};
2use cosmwasm_std::Binary;
3use cw721::Expiration;
4use cw_ownable::{cw_ownable_execute, cw_ownable_query};
5use schemars::JsonSchema;
6
7#[cw_serde]
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#[cw_ownable_execute]
24#[cw_serde]
25pub enum ExecuteMsg<T, E> {
26 /// Transfer is a base message to move a token to another account without triggering actions
27 TransferNft { recipient: String, token_id: String },
28 /// Send is a base message to transfer a token to a contract and trigger an action
29 /// on the receiving contract.
30 SendNft {
31 contract: String,
32 token_id: String,
33 msg: Binary,
34 },
35 /// Allows operator to transfer / send the token from the owner's account.
36 /// If expiration is set, then this allowance has a time/height limit
37 Approve {
38 spender: String,
39 token_id: String,
40 expires: Option<Expiration>,
41 },
42 /// Remove previously granted Approval
43 Revoke { spender: String, token_id: String },
44 /// Allows operator to transfer / send any token from the owner's account.
45 /// If expiration is set, then this allowance has a time/height limit
46 ApproveAll {
47 operator: String,
48 expires: Option<Expiration>,
49 },
50 /// Remove previously granted ApproveAll permission
51 RevokeAll { operator: String },
52
53 /// Mint a new NFT, can only be called by the contract minter
54 Mint {
55 /// Unique ID of the NFT
56 token_id: String,
57 /// The owner of the newly minter NFT
58 owner: String,
59 /// Universal resource identifier for this NFT
60 /// Should point to a JSON file that conforms to the ERC721
61 /// Metadata JSON Schema
62 token_uri: Option<String>,
63 /// Any custom extension used by this contract
64 extension: T,
65 },
66
67 /// Burn an NFT the sender has access to
68 Burn { token_id: String },
69
70 /// Extension msg
71 Extension { msg: E },
72}
73
74#[cw_ownable_query]
75#[cw_serde]
76#[derive(QueryResponses)]
77pub enum QueryMsg<Q: JsonSchema> {
78 /// Return the owner of the given token, error if token does not exist
79 #[returns(cw721::OwnerOfResponse)]
80 OwnerOf {
81 token_id: String,
82 /// unset or false will filter out expired approvals, you must set to true to see them
83 include_expired: Option<bool>,
84 },
85 /// Return operator that can access all of the owner's tokens.
86 #[returns(cw721::ApprovalResponse)]
87 Approval {
88 token_id: String,
89 spender: String,
90 include_expired: Option<bool>,
91 },
92 /// Return approvals that a token has
93 #[returns(cw721::ApprovalsResponse)]
94 Approvals {
95 token_id: String,
96 include_expired: Option<bool>,
97 },
98 /// Return approval of a given operator for all tokens of an owner, error if not set
99 #[returns(cw721::OperatorResponse)]
100 Operator {
101 owner: String,
102 operator: String,
103 include_expired: Option<bool>,
104 },
105 /// List all operators that can access all of the owner's tokens
106 #[returns(cw721::OperatorsResponse)]
107 AllOperators {
108 owner: String,
109 /// unset or false will filter out expired items, you must set to true to see them
110 include_expired: Option<bool>,
111 start_after: Option<String>,
112 limit: Option<u32>,
113 },
114 /// Total number of tokens issued
115 #[returns(cw721::NumTokensResponse)]
116 NumTokens {},
117
118 /// With MetaData Extension.
119 /// Returns top-level metadata about the contract
120 #[returns(cw721::ContractInfoResponse)]
121 ContractInfo {},
122 /// With MetaData Extension.
123 /// Returns metadata about one particular token, based on *ERC721 Metadata JSON Schema*
124 /// but directly from the contract
125 #[returns(cw721::NftInfoResponse<Q>)]
126 NftInfo { token_id: String },
127 /// With MetaData Extension.
128 /// Returns the result of both `NftInfo` and `OwnerOf` as one query as an optimization
129 /// for clients
130 #[returns(cw721::AllNftInfoResponse<Q>)]
131 AllNftInfo {
132 token_id: String,
133 /// unset or false will filter out expired approvals, you must set to true to see them
134 include_expired: Option<bool>,
135 },
136
137 /// With Enumerable extension.
138 /// Returns all tokens owned by the given address, [] if unset.
139 #[returns(cw721::TokensResponse)]
140 Tokens {
141 owner: String,
142 start_after: Option<String>,
143 limit: Option<u32>,
144 },
145 /// With Enumerable extension.
146 /// Requires pagination. Lists all token_ids controlled by the contract.
147 #[returns(cw721::TokensResponse)]
148 AllTokens {
149 start_after: Option<String>,
150 limit: Option<u32>,
151 },
152
153 /// Return the minter
154 #[returns(MinterResponse)]
155 Minter {},
156
157 /// Extension query
158 #[returns(())]
159 Extension { msg: Q },
160}
161
162/// Shows who can mint these tokens
163#[cw_serde]
164pub struct MinterResponse {
165 pub minter: Option<String>,
166}