bs721_base/
msg.rs

1use cosmwasm_schema::{cw_serde, QueryResponses};
2use cosmwasm_std::Binary;
3use bs721::Expiration;
4use schemars::JsonSchema;
5
6#[cw_serde]
7pub struct InstantiateMsg {
8    /// Name of the NFT contract
9    pub name: String,
10    /// Symbol of the NFT contract
11    pub symbol: String,
12    /// Uri, optional uri to get more information about the NFT
13    pub uri: Option<String>,
14
15    /// The minter is the only one who can create new NFTs.
16    /// This is designed for a base NFT that is controlled by an external program
17    /// or contract. You will likely replace this with custom logic in custom NFTs
18    pub minter: String,
19}
20
21/// This is like Bs721ExecuteMsg but we add a Mint command for an owner
22/// to make this stand-alone. You will likely want to remove mint and
23/// use other control logic in any contract that inherits this.
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(MintMsg<T>),
55
56    /// Burn an NFT the sender has access to
57    Burn { token_id: String },
58
59    /// Extension msg
60    Extension { msg: E },
61}
62
63#[cw_serde]
64pub struct MintMsg<T> {
65    /// Unique ID of the NFT
66    pub token_id: String,
67    /// The owner of the newly minted NFT
68    pub owner: String,
69    /// Universal resource identifier for this NFT
70    /// Should point to a JSON file that conforms to the ERC721
71    /// Metadata JSON Schema
72    pub token_uri: Option<String>,
73    /// Seller fee basis points, 0-10000
74    /// 0 means no fee, 100 means 1%, 10000 means 100%
75    /// This is the fee paid by the buyer to the original creator
76    pub seller_fee_bps: Option<u16>,
77    /// Payment address, is the address that will receive the payment
78    pub payment_addr: Option<String>,
79    /// Any custom extension used by this contract
80    pub extension: T,
81}
82
83#[cw_serde]
84#[derive(QueryResponses)]
85pub enum QueryMsg<Q: JsonSchema> {
86    /// Return the owner of the given token, error if token does not exist
87    #[returns(bs721::OwnerOfResponse)]
88    OwnerOf {
89        token_id: String,
90        /// unset or false will filter out expired approvals, you must set to true to see them
91        include_expired: Option<bool>,
92    },
93    /// Return operator that can access all of the owner's tokens.
94    #[returns(bs721::ApprovalResponse)]
95    Approval {
96        token_id: String,
97        spender: String,
98        include_expired: Option<bool>,
99    },
100    /// Return approvals that a token has
101    #[returns(bs721::ApprovalsResponse)]
102    Approvals {
103        token_id: String,
104        include_expired: Option<bool>,
105    },
106    /// List all operators that can access all of the owner's tokens
107    #[returns(bs721::OperatorsResponse)]
108    AllOperators {
109        owner: String,
110        /// unset or false will filter out expired items, you must set to true to see them
111        include_expired: Option<bool>,
112        start_after: Option<String>,
113        limit: Option<u32>,
114    },
115    /// Total number of tokens issued
116    #[returns(bs721::NumTokensResponse)]
117    NumTokens {},
118
119    /// With MetaData Extension.
120    /// Returns top-level metadata about the contract
121    #[returns(bs721::ContractInfoResponse)]
122    ContractInfo {},
123    /// With MetaData Extension.
124    /// Returns metadata about one particular token, based on *ERC721 Metadata JSON Schema*
125    /// but directly from the contract
126    #[returns(bs721::NftInfoResponse<Q>)]
127    NftInfo { token_id: String },
128    /// With MetaData Extension.
129    /// Returns the result of both `NftInfo` and `OwnerOf` as one query as an optimization
130    /// for clients
131    #[returns(bs721::AllNftInfoResponse<Q>)]
132    AllNftInfo {
133        token_id: String,
134        /// unset or false will filter out expired approvals, you must set to true to see them
135        include_expired: Option<bool>,
136    },
137
138    /// With Enumerable extension.
139    /// Returns all tokens owned by the given address, [] if unset.
140    #[returns(bs721::TokensResponse)]
141    Tokens {
142        owner: String,
143        start_after: Option<String>,
144        limit: Option<u32>,
145    },
146    /// With Enumerable extension.
147    /// Requires pagination. Lists all token_ids controlled by the contract.
148    #[returns(bs721::TokensResponse)]
149    AllTokens {
150        start_after: Option<String>,
151        limit: Option<u32>,
152    },
153
154    /// Return the minter
155    #[returns(MinterResponse)]
156    Minter {},
157
158    /// Extension query
159    #[returns(())]
160    Extension { msg: Q },
161}
162
163/// Shows who can mint these tokens
164#[cw_serde]
165pub struct MinterResponse {
166    pub minter: String,
167}