cw721_basic/
msg.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use cosmwasm_std::Binary;
5use cw721::Expiration;
6
7#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, 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> {
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(MintMsg<T>),
55}
56
57#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
58pub struct MintMsg<T> {
59    /// Unique ID of the NFT
60    pub token_id: String,
61    /// The owner of the newly minter NFT
62    pub owner: String,
63    /// Universal resource identifier for this NFT
64    /// Should point to a JSON file that conforms to the ERC721
65    /// Metadata JSON Schema
66    pub token_uri: Option<String>,
67    /// Any custom extension used by this contract
68    pub extension: T,
69}
70
71#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
72#[serde(rename_all = "snake_case")]
73pub enum QueryMsg {
74    /// Return the owner of the given token, error if token does not exist
75    /// Return type: OwnerOfResponse
76    OwnerOf {
77        token_id: String,
78        /// unset or false will filter out expired approvals, you must set to true to see them
79        include_expired: Option<bool>,
80    },
81    /// List all operators that can access all of the owner's tokens
82    /// Return type: `ApprovedForAllResponse`
83    ApprovedForAll {
84        owner: String,
85        /// unset or false will filter out expired items, you must set to true to see them
86        include_expired: Option<bool>,
87        start_after: Option<String>,
88        limit: Option<u32>,
89    },
90    /// Total number of tokens issued
91    NumTokens {},
92
93    /// With MetaData Extension.
94    /// Returns top-level metadata about the contract: `ContractInfoResponse`
95    ContractInfo {},
96    /// With MetaData Extension.
97    /// Returns metadata about one particular token, based on *ERC721 Metadata JSON Schema*
98    /// but directly from the contract: `NftInfoResponse`
99    NftInfo {
100        token_id: String,
101    },
102    /// With MetaData Extension.
103    /// Returns the result of both `NftInfo` and `OwnerOf` as one query as an optimization
104    /// for clients: `AllNftInfo`
105    AllNftInfo {
106        token_id: String,
107        /// unset or false will filter out expired approvals, you must set to true to see them
108        include_expired: Option<bool>,
109    },
110
111    /// With Enumerable extension.
112    /// Returns all tokens owned by the given address, [] if unset.
113    /// Return type: TokensResponse.
114    Tokens {
115        owner: String,
116        start_after: Option<String>,
117        limit: Option<u32>,
118    },
119    /// With Enumerable extension.
120    /// Requires pagination. Lists all token_ids controlled by the contract.
121    /// Return type: TokensResponse.
122    AllTokens {
123        start_after: Option<String>,
124        limit: Option<u32>,
125    },
126
127    // Return the minter
128    Minter {},
129}
130
131/// Shows who can mint these tokens
132#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
133pub struct MinterResponse {
134    pub minter: String,
135}