terp721/
lib.rs

1use cosmwasm_schema::cw_serde;
2use cosmwasm_std::{Addr, Binary, Decimal, Timestamp};
3use cw_ownable::cw_ownable_execute;
4use cw_utils::Expiration;
5
6#[cw_ownable_execute]
7#[cw_serde]
8pub enum ExecuteMsg<T, E> {
9    /// Transfer is a base message to move a token to another account without triggering actions
10    TransferNft {
11        recipient: String,
12        token_id: String,
13    },
14    /// Send is a base message to transfer a token to a contract and trigger an action
15    /// on the receiving contract.
16    SendNft {
17        contract: String,
18        token_id: String,
19        msg: Binary,
20    },
21    /// Allows operator to transfer / send the token from the owner's account.
22    /// If expiration is set, then this allowance has a time/height limit
23    Approve {
24        spender: String,
25        token_id: String,
26        expires: Option<Expiration>,
27    },
28    /// Remove previously granted Approval
29    Revoke {
30        spender: String,
31        token_id: String,
32    },
33    /// Allows operator to transfer / send any token from the owner's account.
34    /// If expiration is set, then this allowance has a time/height limit
35    ApproveAll {
36        operator: String,
37        expires: Option<Expiration>,
38    },
39    /// Remove previously granted ApproveAll permission
40    RevokeAll {
41        operator: String,
42    },
43    /// Mint a new NFT, can only be called by the contract minter
44    Mint {
45        /// Unique ID of the NFT
46        token_id: String,
47        /// The owner of the newly minter NFT
48        owner: String,
49        /// Universal resource identifier for this NFT
50        /// Should point to a JSON file that conforms to the ERC721
51        /// Metadata JSON Schema
52        token_uri: Option<String>,
53        /// Any custom extension used by this contract
54        extension: T,
55    },
56    /// Burn an NFT the sender has access to
57    Burn {
58        token_id: String,
59    },
60    /// Extension msg
61    Extension {
62        msg: E,
63    },
64    /// Update specific collection info fields
65    UpdateCollectionInfo {
66        collection_info: UpdateCollectionInfoMsg<ResidualInfoResponse>,
67    },
68    /// Called by the minter to update trading start time
69    UpdateStartTradingTime(Option<Timestamp>),
70    // Freeze collection info from further updates
71    FreezeCollectionInfo,
72}
73
74#[cw_serde]
75pub struct CollectionInfo<T> {
76    pub creator: String,
77    pub description: String,
78    pub image: String,
79    pub external_link: Option<String>,
80    pub explicit_content: Option<bool>,
81    pub start_trading_time: Option<Timestamp>,
82    pub residual_info: Option<T>,
83}
84
85#[cw_serde]
86pub struct UpdateCollectionInfoMsg<T> {
87    pub description: Option<String>,
88    pub image: Option<String>,
89    pub external_link: Option<Option<String>>,
90    pub explicit_content: Option<bool>,
91    pub residual_info: Option<Option<T>>,
92}
93
94#[cw_serde]
95pub struct ResidualInfo {
96    pub payment_address: Addr,
97    pub share: Decimal,
98}
99
100// allows easy conversion from ResidualInfo to ResidualInfoResponse
101impl ResidualInfo {
102    pub fn to_response(&self) -> ResidualInfoResponse {
103        ResidualInfoResponse {
104            payment_address: self.payment_address.to_string(),
105            share: self.share,
106        }
107    }
108}
109
110#[cw_serde]
111pub struct ResidualInfoResponse {
112    pub payment_address: String,
113    pub share: Decimal,
114}
115
116#[cw_serde]
117pub struct InstantiateMsg {
118    pub name: String,
119    pub symbol: String,
120    pub minter: String,
121    pub collection_info: CollectionInfo<ResidualInfoResponse>,
122}