Skip to main content

hmip721/
msg.rs

1#![allow(clippy::large_enum_variant)]
2use hermit_toolkit_permit::Permit;
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6use cosmwasm_std::{Binary, Coin, HumanAddr};
7
8use crate::expiration::Expiration;
9use crate::mint_run::{MintRunInfo, SerialNumber};
10use crate::royalties::{DisplayRoyaltyInfo, RoyaltyInfo};
11use crate::token::{Extension, Metadata};
12
13/// Instantiation message
14#[derive(Serialize, Deserialize, JsonSchema)]
15pub struct InitMsg {
16    /// name of token contract
17    pub name: String,
18    /// token contract symbol
19    pub symbol: String,
20    /// optional admin address, env.message.sender if missing
21    pub admin: Option<HumanAddr>,
22    /// entropy used for prng seed
23    pub entropy: String,
24    /// optional royalty information to use as default when RoyaltyInfo is not provided to a
25    /// minting function
26    pub royalty_info: Option<RoyaltyInfo>,
27    /// optional privacy configuration for the contract
28    pub config: Option<InitConfig>,
29    /// optional callback message to execute after instantiation.  This will
30    /// most often be used to have the token contract provide its address to a
31    /// contract that instantiated it, but it could be used to execute any
32    /// contract
33    pub post_init_callback: Option<PostInitCallback>,
34}
35
36/// This type represents optional configuration values.
37/// All values are optional and have defaults which are more private by default,
38/// but can be overridden if necessary
39#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
40pub struct InitConfig {
41    /// indicates whether the token IDs and the number of tokens controlled by the contract are
42    /// public.  If the token supply is private, only minters can view the token IDs and
43    /// number of tokens controlled by the contract
44    /// default: False
45    pub public_token_supply: Option<bool>,
46    /// indicates whether token ownership is public or private.  A user can still change whether the
47    /// ownership of their tokens is public or private
48    /// default: False
49    pub public_owner: Option<bool>,
50    /// indicates whether sealed metadata should be enabled.  If sealed metadata is enabled, the
51    /// private metadata is not viewable by anyone, not even the owner, until the owner calls the
52    /// Reveal function.  When Reveal is called, the sealed metadata is irreversibly moved to the
53    /// public metadata (as default).  if unwrapped_metadata_is_private is set to true, it will
54    /// remain as private metadata, but the owner will now be able to see it.  Anyone will be able
55    /// to query the token to know that it has been unwrapped.  This simulates buying/selling a
56    /// wrapped card that no one knows which card it is until it is unwrapped. If sealed metadata
57    /// is not enabled, all tokens are considered unwrapped
58    /// default:  False
59    pub enable_sealed_metadata: Option<bool>,
60    /// indicates if the Reveal function should keep the sealed metadata private after unwrapping
61    /// This config value is ignored if sealed metadata is not enabled
62    /// default: False
63    pub unwrapped_metadata_is_private: Option<bool>,
64    /// indicates whether a minter is permitted to update a token's metadata
65    /// default: True
66    pub minter_may_update_metadata: Option<bool>,
67    /// indicates whether the owner of a token is permitted to update a token's metadata
68    /// default: False
69    pub owner_may_update_metadata: Option<bool>,
70    /// Indicates whether burn functionality should be enabled
71    /// default: False
72    pub enable_burn: Option<bool>,
73}
74
75impl Default for InitConfig {
76    fn default() -> Self {
77        InitConfig {
78            public_token_supply: Some(false),
79            public_owner: Some(false),
80            enable_sealed_metadata: Some(false),
81            unwrapped_metadata_is_private: Some(false),
82            minter_may_update_metadata: Some(true),
83            owner_may_update_metadata: Some(false),
84            enable_burn: Some(false),
85        }
86    }
87}
88
89/// info needed to perform a callback message after instantiation
90#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
91pub struct PostInitCallback {
92    /// the callback message to execute
93    pub msg: Binary,
94    /// address of the contract to execute
95    pub contract_address: HumanAddr,
96    /// code hash of the contract to execute
97    pub code_hash: String,
98    /// list of native Coin to send with the callback message
99    pub send: Vec<Coin>,
100}
101
102#[derive(Serialize, Deserialize, JsonSchema)]
103#[serde(rename_all = "snake_case")]
104pub enum HandleMsg {
105    /// mint new token
106    MintNft {
107        /// optional token id. if omitted, use current token index
108        token_id: Option<String>,
109        /// optional owner address. if omitted, owned by the message sender
110        owner: Option<HumanAddr>,
111        /// optional public metadata that can be seen by everyone
112        public_metadata: Option<Metadata>,
113        /// optional private metadata that can only be seen by the owner and whitelist
114        private_metadata: Option<Metadata>,
115        /// optional serial number for this token
116        serial_number: Option<SerialNumber>,
117        /// optional royalty information for this token.  This will be ignored if the token is
118        /// non-transferable
119        royalty_info: Option<RoyaltyInfo>,
120        /// optionally true if the token is transferable.  Defaults to true if omitted
121        transferable: Option<bool>,
122        /// optional memo for the tx
123        memo: Option<String>,
124        /// optional message length padding
125        padding: Option<String>,
126    },
127    /// Mint multiple tokens
128    BatchMintNft {
129        /// list of mint operations to perform
130        mints: Vec<Mint>,
131        /// optional message length padding
132        padding: Option<String>,
133    },
134    /// create a mint run of clones that will have MintRunInfos showing they are serialized
135    /// copies in the same mint run with the specified quantity.  Mint_run_id can be used to
136    /// track mint run numbers in subsequent MintNftClones calls.  So, if provided, the first
137    /// MintNftClones call will have mint run number 1, the next time MintNftClones is called
138    /// with the same mint_run_id, those clones will have mint run number 2, etc...  If no
139    /// mint_run_id is specified, the clones will not have any mint run number assigned to their
140    /// MintRunInfos.  Because this mints to a single address, there is no option to specify
141    /// that the clones are non-transferable as there is no foreseen reason for someone to have
142    /// multiple copies of an nft that they can never send to others
143    MintNftClones {
144        /// optional mint run ID
145        mint_run_id: Option<String>,
146        /// number of clones to mint
147        quantity: u32,
148        /// optional owner address. if omitted, owned by the message sender
149        owner: Option<HumanAddr>,
150        /// optional public metadata that can be seen by everyone
151        public_metadata: Option<Metadata>,
152        /// optional private metadata that can only be seen by the owner and whitelist
153        private_metadata: Option<Metadata>,
154        /// optional royalty information for these tokens
155        royalty_info: Option<RoyaltyInfo>,
156        /// optional memo for the mint txs
157        memo: Option<String>,
158        /// optional message length padding
159        padding: Option<String>,
160    },
161    /// set the public and/or private metadata.  This can be called by either the token owner or
162    /// a valid minter if they have been given this power by the appropriate config values
163    SetMetadata {
164        /// id of the token whose metadata should be updated
165        token_id: String,
166        /// the optional new public metadata
167        public_metadata: Option<Metadata>,
168        /// the optional new private metadata
169        private_metadata: Option<Metadata>,
170        /// optional message length padding
171        padding: Option<String>,
172    },
173    /// set royalty information.  If no token ID is provided, this royalty info will become the default
174    /// RoyaltyInfo for any new tokens minted on the contract.  If a token ID is provided, this can only
175    /// be called by the token creator and only when the creator is the current owner.  Royalties can not
176    /// be set on a token that is not transferable, because they can never be sold
177    SetRoyaltyInfo {
178        /// optional id of the token whose royalty information should be updated.  If not provided,
179        /// this updates the default royalty information for any new tokens minted on the contract
180        token_id: Option<String>,
181        /// the new royalty information.  If None, existing royalty information will be deleted.  It should
182        /// be noted, that if deleting a token's royalty information while the contract has a default royalty
183        /// info set up will give the token the default royalty information
184        royalty_info: Option<RoyaltyInfo>,
185        /// optional message length padding
186        padding: Option<String>,
187    },
188    /// Reveal the private metadata of a sealed token and mark the token as having been unwrapped
189    Reveal {
190        /// id of the token to unwrap
191        token_id: String,
192        /// optional message length padding
193        padding: Option<String>,
194    },
195    /// if a contract was instantiated to make ownership public by default, this will allow
196    /// an address to make the ownership of their tokens private.  The address can still use
197    /// SetGlobalApproval to make ownership public either inventory-wide or for a specific token
198    MakeOwnershipPrivate {
199        /// optional message length padding
200        padding: Option<String>,
201    },
202    /// add/remove approval(s) that whitelist everyone (makes public)
203    SetGlobalApproval {
204        /// optional token id to apply approval/revocation to
205        token_id: Option<String>,
206        /// optional permission level for viewing the owner
207        view_owner: Option<AccessLevel>,
208        /// optional permission level for viewing private metadata
209        view_private_metadata: Option<AccessLevel>,
210        /// optional expiration
211        expires: Option<Expiration>,
212        /// optional message length padding
213        padding: Option<String>,
214    },
215    /// add/remove approval(s) for a specific address on the token(s) you own.  Any permissions
216    /// that are omitted will keep the current permission setting for that whitelist address
217    SetWhitelistedApproval {
218        /// address being granted/revoked permission
219        address: HumanAddr,
220        /// optional token id to apply approval/revocation to
221        token_id: Option<String>,
222        /// optional permission level for viewing the owner
223        view_owner: Option<AccessLevel>,
224        /// optional permission level for viewing private metadata
225        view_private_metadata: Option<AccessLevel>,
226        /// optional permission level for transferring
227        transfer: Option<AccessLevel>,
228        /// optional expiration
229        expires: Option<Expiration>,
230        /// optional message length padding
231        padding: Option<String>,
232    },
233    /// gives the spender permission to transfer the specified token.  If you are the owner
234    /// of the token, you can use SetWhitelistedApproval to accomplish the same thing.  If
235    /// you are an operator, you can only use Approve
236    Approve {
237        /// address being granted the permission
238        spender: HumanAddr,
239        /// id of the token that the spender can transfer
240        token_id: String,
241        /// optional expiration for this approval
242        expires: Option<Expiration>,
243        /// optional message length padding
244        padding: Option<String>,
245    },
246    /// revokes the spender's permission to transfer the specified token.  If you are the owner
247    /// of the token, you can use SetWhitelistedApproval to accomplish the same thing.  If you
248    /// are an operator, you can only use Revoke, but you can not revoke the transfer approval
249    /// of another operator
250    Revoke {
251        /// address whose permission is revoked
252        spender: HumanAddr,
253        /// id of the token that the spender can no longer transfer
254        token_id: String,
255        /// optional message length padding
256        padding: Option<String>,
257    },
258    /// provided for cw721 compliance, but can be done with SetWhitelistedApproval...
259    /// gives the operator permission to transfer all of the message sender's tokens
260    ApproveAll {
261        /// address being granted permission to transfer
262        operator: HumanAddr,
263        /// optional expiration for this approval
264        expires: Option<Expiration>,
265        /// optional message length padding
266        padding: Option<String>,
267    },
268    /// provided for cw721 compliance, but can be done with SetWhitelistedApproval...
269    /// revokes the operator's permission to transfer any of the message sender's tokens
270    RevokeAll {
271        /// address whose permissions are revoked
272        operator: HumanAddr,
273        /// optional message length padding
274        padding: Option<String>,
275    },
276    /// transfer a token if it is transferable
277    TransferNft {
278        /// recipient of the transfer
279        recipient: HumanAddr,
280        /// id of the token to transfer
281        token_id: String,
282        /// optional memo for the tx
283        memo: Option<String>,
284        /// optional message length padding
285        padding: Option<String>,
286    },
287    /// transfer many tokens and fails if any are non-transferable
288    BatchTransferNft {
289        /// list of transfers to perform
290        transfers: Vec<Transfer>,
291        /// optional message length padding
292        padding: Option<String>,
293    },
294    /// send a token if it is transferable and call the receiving contract's (Batch)ReceiveNft
295    SendNft {
296        /// address to send the token to
297        contract: HumanAddr,
298        /// optional code hash and BatchReceiveNft implementation status of the recipient contract
299        receiver_info: Option<ReceiverInfo>,
300        /// id of the token to send
301        token_id: String,
302        /// optional message to send with the (Batch)RecieveNft callback
303        msg: Option<Binary>,
304        /// optional memo for the tx
305        memo: Option<String>,
306        /// optional message length padding
307        padding: Option<String>,
308    },
309    /// send many tokens and call the receiving contracts' (Batch)ReceiveNft.  Fails if any tokens are
310    /// non-transferable
311    BatchSendNft {
312        /// list of sends to perform
313        sends: Vec<Send>,
314        /// optional message length padding
315        padding: Option<String>,
316    },
317    /// burn a token.  This can be always be done on a non-transferable token, regardless of whether burn
318    /// has been enabled on the contract.  An owner should always have a way to get rid of a token they do
319    /// not want, and burning is the only way to do that if the token is non-transferable
320    BurnNft {
321        /// token to burn
322        token_id: String,
323        /// optional memo for the tx
324        memo: Option<String>,
325        /// optional message length padding
326        padding: Option<String>,
327    },
328    /// burn many tokens.  This can be always be done on a non-transferable token, regardless of whether burn
329    /// has been enabled on the contract.  An owner should always have a way to get rid of a token they do
330    /// not want, and burning is the only way to do that if the token is non-transferable
331    BatchBurnNft {
332        /// list of burns to perform
333        burns: Vec<Burn>,
334        /// optional message length padding
335        padding: Option<String>,
336    },
337    /// register that the message sending contract implements ReceiveNft and possibly
338    /// BatchReceiveNft.  If a contract implements BatchReceiveNft, SendNft will always
339    /// call BatchReceiveNft even if there is only one token transferred (the token_ids
340    /// Vec will only contain one ID)
341    RegisterReceiveNft {
342        /// receving contract's code hash
343        code_hash: String,
344        /// optionally true if the contract also implements BatchReceiveNft.  Defaults
345        /// to false if not specified
346        also_implements_batch_receive_nft: Option<bool>,
347        /// optional message length padding
348        padding: Option<String>,
349    },
350    /// create a viewing key
351    CreateViewingKey {
352        /// entropy String used in random key generation
353        entropy: String,
354        /// optional message length padding
355        padding: Option<String>,
356    },
357    /// set viewing key
358    SetViewingKey {
359        /// desired viewing key
360        key: String,
361        /// optional message length padding
362        padding: Option<String>,
363    },
364    /// add addresses with minting authority
365    AddMinters {
366        /// list of addresses that can now mint
367        minters: Vec<HumanAddr>,
368        /// optional message length padding
369        padding: Option<String>,
370    },
371    /// revoke minting authority from addresses
372    RemoveMinters {
373        /// list of addresses no longer allowed to mint
374        minters: Vec<HumanAddr>,
375        /// optional message length padding
376        padding: Option<String>,
377    },
378    /// define list of addresses with minting authority
379    SetMinters {
380        /// list of addresses with minting authority
381        minters: Vec<HumanAddr>,
382        /// optional message length padding
383        padding: Option<String>,
384    },
385    /// change address with administrative power
386    ChangeAdmin {
387        /// address with admin authority
388        address: HumanAddr,
389        /// optional message length padding
390        padding: Option<String>,
391    },
392    /// set contract status level to determine which functions are allowed.  StopTransactions
393    /// status prevent mints, burns, sends, and transfers, but allows all other functions
394    SetContractStatus {
395        /// status level
396        level: ContractStatus,
397        /// optional message length padding
398        padding: Option<String>,
399    },
400    /// disallow the use of a permit
401    RevokePermit {
402        /// name of the permit that is no longer valid
403        permit_name: String,
404        /// optional message length padding
405        padding: Option<String>,
406    },
407}
408
409/// permission access level
410#[derive(Serialize, Deserialize, JsonSchema, Debug)]
411#[serde(rename_all = "snake_case")]
412pub enum AccessLevel {
413    /// approve permission only for the specified token
414    ApproveToken,
415    /// grant permission for all tokens
416    All,
417    /// revoke permission only for the specified token
418    RevokeToken,
419    /// remove all permissions for this address
420    None,
421}
422
423/// token mint info used when doing a BatchMint
424#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
425pub struct Mint {
426    /// optional token id, if omitted, use current token index
427    pub token_id: Option<String>,
428    /// optional owner address, owned by the minter otherwise
429    pub owner: Option<HumanAddr>,
430    /// optional public metadata that can be seen by everyone
431    pub public_metadata: Option<Metadata>,
432    /// optional private metadata that can only be seen by owner and whitelist
433    pub private_metadata: Option<Metadata>,
434    /// optional serial number for this token
435    pub serial_number: Option<SerialNumber>,
436    /// optional royalty information for this token.  This will be ignored if the token is
437    /// non-transferable
438    pub royalty_info: Option<RoyaltyInfo>,
439    /// optionally true if the token is transferable.  Defaults to true if omitted
440    pub transferable: Option<bool>,
441    /// optional memo for the tx
442    pub memo: Option<String>,
443}
444
445/// token burn info used when doing a BatchBurnNft
446#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
447pub struct Burn {
448    /// tokens being burnt
449    pub token_ids: Vec<String>,
450    /// optional memo for the tx
451    pub memo: Option<String>,
452}
453
454/// token transfer info used when doing a BatchTransferNft
455#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
456pub struct Transfer {
457    /// recipient of the transferred tokens
458    pub recipient: HumanAddr,
459    /// tokens being transferred
460    pub token_ids: Vec<String>,
461    /// optional memo for the tx
462    pub memo: Option<String>,
463}
464
465/// send token info used when doing a BatchSendNft
466#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
467pub struct Send {
468    /// recipient of the sent tokens
469    pub contract: HumanAddr,
470    /// optional code hash and BatchReceiveNft implementation status of the recipient contract
471    pub receiver_info: Option<ReceiverInfo>,
472    /// tokens being sent
473    pub token_ids: Vec<String>,
474    /// optional message to send with the (Batch)RecieveNft callback
475    pub msg: Option<Binary>,
476    /// optional memo for the tx
477    pub memo: Option<String>,
478}
479
480#[derive(Serialize, Deserialize, JsonSchema, Debug)]
481#[serde(rename_all = "snake_case")]
482pub enum HandleAnswer {
483    /// MintNft will also display the minted token's ID in the log attributes under the
484    /// key `minted` in case minting was done as a callback message
485    MintNft {
486        token_id: String,
487    },
488    /// BatchMintNft will also display the minted tokens' IDs in the log attributes under the
489    /// key `minted` in case minting was done as a callback message
490    BatchMintNft {
491        token_ids: Vec<String>,
492    },
493    /// Displays the token ids of the first minted NFT and the last minted NFT.  Because these
494    /// are serialized clones, the ids of all the tokens minted in between should be easily
495    /// inferred.  MintNftClones will also display the minted tokens' IDs in the log attributes
496    /// under the keys `first_minted` and `last_minted` in case minting was done as a callback message
497    MintNftClones {
498        /// token id of the first minted clone
499        first_minted: String,
500        /// token id of the last minted clone
501        last_minted: String,
502    },
503    SetMetadata {
504        status: ResponseStatus,
505    },
506    SetRoyaltyInfo {
507        status: ResponseStatus,
508    },
509    MakeOwnershipPrivate {
510        status: ResponseStatus,
511    },
512    Reveal {
513        status: ResponseStatus,
514    },
515    Approve {
516        status: ResponseStatus,
517    },
518    Revoke {
519        status: ResponseStatus,
520    },
521    ApproveAll {
522        status: ResponseStatus,
523    },
524    RevokeAll {
525        status: ResponseStatus,
526    },
527    SetGlobalApproval {
528        status: ResponseStatus,
529    },
530    SetWhitelistedApproval {
531        status: ResponseStatus,
532    },
533    TransferNft {
534        status: ResponseStatus,
535    },
536    BatchTransferNft {
537        status: ResponseStatus,
538    },
539    SendNft {
540        status: ResponseStatus,
541    },
542    BatchSendNft {
543        status: ResponseStatus,
544    },
545    BurnNft {
546        status: ResponseStatus,
547    },
548    BatchBurnNft {
549        status: ResponseStatus,
550    },
551    RegisterReceiveNft {
552        status: ResponseStatus,
553    },
554    /// response from both setting and creating a viewing key
555    ViewingKey {
556        key: String,
557    },
558    AddMinters {
559        status: ResponseStatus,
560    },
561    RemoveMinters {
562        status: ResponseStatus,
563    },
564    SetMinters {
565        status: ResponseStatus,
566    },
567    ChangeAdmin {
568        status: ResponseStatus,
569    },
570    SetContractStatus {
571        status: ResponseStatus,
572    },
573    RevokePermit {
574        status: ResponseStatus,
575    },
576}
577
578/// the address and viewing key making an authenticated query request
579#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
580pub struct ViewerInfo {
581    /// querying address
582    pub address: HumanAddr,
583    /// authentication key string
584    pub viewing_key: String,
585}
586
587/// a recipient contract's code hash and whether it implements BatchReceiveNft
588#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
589pub struct ReceiverInfo {
590    /// recipient's code hash
591    pub recipient_code_hash: String,
592    /// true if the contract also implements BacthReceiveNft.  Defaults to false
593    /// if not specified
594    pub also_implements_batch_receive_nft: Option<bool>,
595}
596
597/// tx type and specifics
598#[derive(Serialize, Deserialize, JsonSchema, Clone, PartialEq, Debug)]
599#[serde(rename_all = "snake_case")]
600pub enum TxAction {
601    /// transferred token ownership
602    Transfer {
603        /// previous owner
604        from: HumanAddr,
605        /// optional sender if not owner
606        sender: Option<HumanAddr>,
607        /// new owner
608        recipient: HumanAddr,
609    },
610    /// minted new token
611    Mint {
612        /// minter's address
613        minter: HumanAddr,
614        /// token's first owner
615        recipient: HumanAddr,
616    },
617    /// burned a token
618    Burn {
619        /// previous owner
620        owner: HumanAddr,
621        /// burner's address if not owner
622        burner: Option<HumanAddr>,
623    },
624}
625
626/// tx for display
627#[derive(Serialize, Deserialize, JsonSchema, Clone, PartialEq, Debug)]
628#[serde(rename_all = "snake_case")]
629pub struct Tx {
630    /// tx id
631    pub tx_id: u64,
632    /// the block containing this tx
633    pub block_height: u64,
634    /// the time (in seconds since 01/01/1970) of the block containing this tx
635    pub block_time: u64,
636    /// token id
637    pub token_id: String,
638    /// tx type and specifics
639    pub action: TxAction,
640    /// optional memo
641    pub memo: Option<String>,
642}
643
644#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
645#[serde(rename_all = "snake_case")]
646pub enum QueryMsg {
647    /// display the contract's name and symbol
648    ContractInfo {},
649    /// display the contract's configuration
650    ContractConfig {},
651    /// display the list of authorized minters
652    Minters {},
653    /// display the number of tokens controlled by the contract.  The token supply must
654    /// either be public, or the querier must be an authenticated minter
655    NumTokens {
656        /// optional address and key requesting to view the number of tokens
657        viewer: Option<ViewerInfo>,
658    },
659    /// display an optionally paginated list of all the tokens controlled by the contract.
660    /// The token supply must either be public, or the querier must be an authenticated
661    /// minter
662    AllTokens {
663        /// optional address and key requesting to view the list of tokens
664        viewer: Option<ViewerInfo>,
665        /// paginate by providing the last token_id received in the previous query
666        start_after: Option<String>,
667        /// optional number of token ids to display
668        limit: Option<u32>,
669    },
670    /// display the owner of the specified token if authorized to view it.  If the requester
671    /// is also the token's owner, the response will also include a list of any addresses
672    /// that can transfer this token.  The transfer approval list is for CW721 compliance,
673    /// but the NftDossier query will be more complete by showing viewing approvals as well
674    OwnerOf {
675        token_id: String,
676        /// optional address and key requesting to view the token owner
677        viewer: Option<ViewerInfo>,
678        /// optionally include expired Approvals in the response list.  If ommitted or
679        /// false, expired Approvals will be filtered out of the response
680        include_expired: Option<bool>,
681    },
682    /// displays the public metadata of a token
683    NftInfo { token_id: String },
684    /// displays all the information contained in the OwnerOf and NftInfo queries
685    AllNftInfo {
686        token_id: String,
687        /// optional address and key requesting to view the token owner
688        viewer: Option<ViewerInfo>,
689        /// optionally include expired Approvals in the response list.  If ommitted or
690        /// false, expired Approvals will be filtered out of the response
691        include_expired: Option<bool>,
692    },
693    /// displays the private metadata if permitted to view it
694    PrivateMetadata {
695        token_id: String,
696        /// optional address and key requesting to view the private metadata
697        viewer: Option<ViewerInfo>,
698    },
699    /// displays all the information about a token that the viewer has permission to
700    /// see.  This may include the owner, the public metadata, the private metadata, royalty
701    /// information, mint run information, whether the token is unwrapped, whether the token is
702    /// transferable, and the token and inventory approvals
703    NftDossier {
704        token_id: String,
705        /// optional address and key requesting to view the token information
706        viewer: Option<ViewerInfo>,
707        /// optionally include expired Approvals in the response list.  If ommitted or
708        /// false, expired Approvals will be filtered out of the response
709        include_expired: Option<bool>,
710    },
711    /// displays all the information about multiple tokens that the viewer has permission to
712    /// see.  This may include the owner, the public metadata, the private metadata, royalty
713    /// information, mint run information, whether the token is unwrapped, whether the token is
714    /// transferable, and the token and inventory approvals
715    BatchNftDossier {
716        token_ids: Vec<String>,
717        /// optional address and key requesting to view the token information
718        viewer: Option<ViewerInfo>,
719        /// optionally include expired Approvals in the response list.  If ommitted or
720        /// false, expired Approvals will be filtered out of the response
721        include_expired: Option<bool>,
722    },
723    /// list all the approvals in place for a specified token if given the owner's viewing
724    /// key
725    TokenApprovals {
726        token_id: String,
727        /// the token owner's viewing key
728        viewing_key: String,
729        /// optionally include expired Approvals in the response list.  If ommitted or
730        /// false, expired Approvals will be filtered out of the response
731        include_expired: Option<bool>,
732    },
733    /// list all the inventory-wide approvals in place for the specified address if given the
734    /// the correct viewing key for the address
735    InventoryApprovals {
736        address: HumanAddr,
737        /// the viewing key
738        viewing_key: String,
739        /// optionally include expired Approvals in the response list.  If ommitted or
740        /// false, expired Approvals will be filtered out of the response
741        include_expired: Option<bool>,
742    },
743    /// displays a list of all the CW721-style operators (any address that was granted
744    /// approval to transfer all of the owner's tokens).  This query is provided to maintain
745    /// CW721 compliance, however, approvals are private on secret network, so only the
746    /// owner's viewing key will authorize the ability to see the list of operators
747    ApprovedForAll {
748        owner: HumanAddr,
749        /// optional viewing key to authenticate this query.  It is "optional" only in the
750        /// sense that a CW721 query does not have this field.  However, not providing the
751        /// key will always result in an empty list
752        viewing_key: Option<String>,
753        /// optionally include expired Approvals in the response list.  If ommitted or
754        /// false, expired Approvals will be filtered out of the response
755        include_expired: Option<bool>,
756    },
757    /// displays a list of all the tokens belonging to the input owner in which the viewer
758    /// has view_owner permission
759    Tokens {
760        owner: HumanAddr,
761        /// optional address of the querier if different from the owner
762        viewer: Option<HumanAddr>,
763        /// optional viewing key
764        viewing_key: Option<String>,
765        /// paginate by providing the last token_id received in the previous query
766        start_after: Option<String>,
767        /// optional number of token ids to display
768        limit: Option<u32>,
769    },
770    /// displays the number of tokens that the querier has permission to see the owner and that
771    /// belong to the specified address
772    NumTokensOfOwner {
773        owner: HumanAddr,
774        /// optional address of the querier if different from the owner
775        viewer: Option<HumanAddr>,
776        /// optional viewing key
777        viewing_key: Option<String>,
778    },
779    /// display if a token is unwrapped
780    IsUnwrapped { token_id: String },
781    /// display if a token is transferable
782    IsTransferable { token_id: String },
783    /// display that this contract implements non-transferable tokens
784    ImplementsNonTransferableTokens {},
785    /// display that this contract implements the use of the `token_subtype` metadata extension field
786    ImplementsTokenSubtype {},
787    /// verify that the specified address has approval to transfer every listed token.  
788    /// A token will count as unapproved if it is non-transferable
789    VerifyTransferApproval {
790        /// list of tokens to verify approval for
791        token_ids: Vec<String>,
792        /// address that has approval
793        address: HumanAddr,
794        /// viewing key
795        viewing_key: String,
796    },
797    /// display the transaction history for the specified address in reverse
798    /// chronological order
799    TransactionHistory {
800        address: HumanAddr,
801        /// viewing key
802        viewing_key: String,
803        /// optional page to display
804        page: Option<u32>,
805        /// optional number of transactions per page
806        page_size: Option<u32>,
807    },
808    /// display the code hash a contract has registered with the token contract and whether
809    /// the contract implements BatchReceivenft
810    RegisteredCodeHash {
811        /// the contract whose receive registration info you want to view
812        contract: HumanAddr,
813    },
814    /// display the royalty information of a token if a token ID is specified, or display the
815    /// contract's default royalty information in no token ID is provided
816    RoyaltyInfo {
817        /// optional ID of the token whose royalty information should be displayed.  If not
818        /// provided, display the contract's default royalty information
819        token_id: Option<String>,
820        /// optional address and key requesting to view the royalty information
821        viewer: Option<ViewerInfo>,
822    },
823    /// display the contract's creator
824    ContractCreator {},
825    /// perform queries by passing permits instead of viewing keys
826    WithPermit {
827        /// permit used to verify querier identity
828        permit: Permit,
829        /// query to perform
830        query: QueryWithPermit,
831    },
832}
833
834/// SNIP721 Approval
835#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
836pub struct Snip721Approval {
837    /// whitelisted address
838    pub address: HumanAddr,
839    /// optional expiration if the address has view owner permission
840    pub view_owner_expiration: Option<Expiration>,
841    /// optional expiration if the address has view private metadata permission
842    pub view_private_metadata_expiration: Option<Expiration>,
843    /// optional expiration if the address has transfer permission
844    pub transfer_expiration: Option<Expiration>,
845}
846
847/// CW721 Approval
848#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
849pub struct Cw721Approval {
850    /// address that can transfer the token
851    pub spender: HumanAddr,
852    /// expiration of this approval
853    pub expires: Expiration,
854}
855
856/// response of CW721 OwnerOf
857#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
858pub struct Cw721OwnerOfResponse {
859    /// Owner of the token if permitted to view it
860    pub owner: Option<HumanAddr>,
861    /// list of addresses approved to transfer this token
862    pub approvals: Vec<Cw721Approval>,
863}
864
865/// the token id and nft dossier info of a single token response in a batch query
866#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
867pub struct BatchNftDossierElement {
868    pub token_id: String,
869    pub owner: Option<HumanAddr>,
870    pub public_metadata: Option<Metadata>,
871    pub private_metadata: Option<Metadata>,
872    pub display_private_metadata_error: Option<String>,
873    pub royalty_info: Option<DisplayRoyaltyInfo>,
874    pub mint_run_info: Option<MintRunInfo>,
875    /// true if this token is transferable
876    pub transferable: bool,
877    /// true if this token is unwrapped (returns true if the contract does not have selaed metadata enabled)
878    pub unwrapped: bool,
879    pub owner_is_public: bool,
880    pub public_ownership_expiration: Option<Expiration>,
881    pub private_metadata_is_public: bool,
882    pub private_metadata_is_public_expiration: Option<Expiration>,
883    pub token_approvals: Option<Vec<Snip721Approval>>,
884    pub inventory_approvals: Option<Vec<Snip721Approval>>,
885}
886
887#[derive(Serialize, Deserialize, JsonSchema, Debug)]
888#[serde(rename_all = "snake_case")]
889pub enum QueryAnswer {
890    ContractInfo {
891        name: String,
892        symbol: String,
893    },
894    ContractConfig {
895        token_supply_is_public: bool,
896        owner_is_public: bool,
897        sealed_metadata_is_enabled: bool,
898        unwrapped_metadata_is_private: bool,
899        minter_may_update_metadata: bool,
900        owner_may_update_metadata: bool,
901        burn_is_enabled: bool,
902    },
903    Minters {
904        minters: Vec<HumanAddr>,
905    },
906    NumTokens {
907        count: u32,
908    },
909    TokenList {
910        tokens: Vec<String>,
911    },
912    OwnerOf {
913        owner: HumanAddr,
914        approvals: Vec<Cw721Approval>,
915    },
916    TokenApprovals {
917        owner_is_public: bool,
918        public_ownership_expiration: Option<Expiration>,
919        private_metadata_is_public: bool,
920        private_metadata_is_public_expiration: Option<Expiration>,
921        token_approvals: Vec<Snip721Approval>,
922    },
923    InventoryApprovals {
924        owner_is_public: bool,
925        public_ownership_expiration: Option<Expiration>,
926        private_metadata_is_public: bool,
927        private_metadata_is_public_expiration: Option<Expiration>,
928        inventory_approvals: Vec<Snip721Approval>,
929    },
930    NftInfo {
931        token_uri: Option<String>,
932        extension: Option<Extension>,
933    },
934    PrivateMetadata {
935        token_uri: Option<String>,
936        extension: Option<Extension>,
937    },
938    AllNftInfo {
939        access: Cw721OwnerOfResponse,
940        info: Option<Metadata>,
941    },
942    NftDossier {
943        owner: Option<HumanAddr>,
944        public_metadata: Option<Metadata>,
945        private_metadata: Option<Metadata>,
946        display_private_metadata_error: Option<String>,
947        royalty_info: Option<DisplayRoyaltyInfo>,
948        mint_run_info: Option<MintRunInfo>,
949        transferable: bool,
950        unwrapped: bool,
951        owner_is_public: bool,
952        public_ownership_expiration: Option<Expiration>,
953        private_metadata_is_public: bool,
954        private_metadata_is_public_expiration: Option<Expiration>,
955        token_approvals: Option<Vec<Snip721Approval>>,
956        inventory_approvals: Option<Vec<Snip721Approval>>,
957    },
958    BatchNftDossier {
959        nft_dossiers: Vec<BatchNftDossierElement>,
960    },
961    ApprovedForAll {
962        operators: Vec<Cw721Approval>,
963    },
964    IsUnwrapped {
965        token_is_unwrapped: bool,
966    },
967    IsTransferable {
968        token_is_transferable: bool,
969    },
970    ImplementsNonTransferableTokens {
971        is_enabled: bool,
972    },
973    ImplementsTokenSubtype {
974        is_enabled: bool,
975    },
976    VerifyTransferApproval {
977        approved_for_all: bool,
978        first_unapproved_token: Option<String>,
979    },
980    TransactionHistory {
981        /// total transaction count
982        total: u64,
983        txs: Vec<Tx>,
984    },
985    RegisteredCodeHash {
986        code_hash: Option<String>,
987        also_implements_batch_receive_nft: bool,
988    },
989    RoyaltyInfo {
990        royalty_info: Option<DisplayRoyaltyInfo>,
991    },
992    ContractCreator {
993        creator: Option<HumanAddr>,
994    },
995}
996
997#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
998#[serde(rename_all = "snake_case")]
999pub enum ResponseStatus {
1000    Success,
1001    Failure,
1002}
1003
1004#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
1005#[serde(rename_all = "snake_case")]
1006pub enum ContractStatus {
1007    Normal,
1008    StopTransactions,
1009    StopAll,
1010}
1011
1012impl ContractStatus {
1013    /// Returns u8 representation of the ContractStatus
1014    pub fn to_u8(&self) -> u8 {
1015        match self {
1016            ContractStatus::Normal => 0,
1017            ContractStatus::StopTransactions => 1,
1018            ContractStatus::StopAll => 2,
1019        }
1020    }
1021}
1022
1023/// queries using permits instead of viewing keys
1024#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
1025#[serde(rename_all = "snake_case")]
1026pub enum QueryWithPermit {
1027    /// display the royalty information of a token if a token ID is specified, or display the
1028    /// contract's default royalty information in no token ID is provided
1029    RoyaltyInfo {
1030        /// optional ID of the token whose royalty information should be displayed.  If not
1031        /// provided, display the contract's default royalty information
1032        token_id: Option<String>,
1033    },
1034    /// displays the private metadata if permitted to view it
1035    PrivateMetadata { token_id: String },
1036    /// displays all the information about a token that the viewer has permission to
1037    /// see.  This may include the owner, the public metadata, the private metadata, royalty
1038    /// information, mint run information, whether the token is unwrapped, whether the token is
1039    /// transferable, and the token and inventory approvals
1040    NftDossier {
1041        token_id: String,
1042        /// optionally include expired Approvals in the response list.  If ommitted or
1043        /// false, expired Approvals will be filtered out of the response
1044        include_expired: Option<bool>,
1045    },
1046    /// displays all the information about multiple tokens that the viewer has permission to
1047    /// see.  This may include the owner, the public metadata, the private metadata, royalty
1048    /// information, mint run information, whether the token is unwrapped, whether the token is
1049    /// transferable, and the token and inventory approvals
1050    BatchNftDossier {
1051        token_ids: Vec<String>,
1052        /// optionally include expired Approvals in the response list.  If ommitted or
1053        /// false, expired Approvals will be filtered out of the response
1054        include_expired: Option<bool>,
1055    },
1056    /// display the owner of the specified token if authorized to view it.  If the requester
1057    /// is also the token's owner, the response will also include a list of any addresses
1058    /// that can transfer this token.  The transfer approval list is for CW721 compliance,
1059    /// but the NftDossier query will be more complete by showing viewing approvals as well
1060    OwnerOf {
1061        token_id: String,
1062        /// optionally include expired Approvals in the response list.  If ommitted or
1063        /// false, expired Approvals will be filtered out of the response
1064        include_expired: Option<bool>,
1065    },
1066    /// displays all the information contained in the OwnerOf and NftInfo queries
1067    AllNftInfo {
1068        token_id: String,
1069        /// optionally include expired Approvals in the response list.  If ommitted or
1070        /// false, expired Approvals will be filtered out of the response
1071        include_expired: Option<bool>,
1072    },
1073    /// list all the inventory-wide approvals in place for the permit creator
1074    InventoryApprovals {
1075        /// optionally include expired Approvals in the response list.  If ommitted or
1076        /// false, expired Approvals will be filtered out of the response
1077        include_expired: Option<bool>,
1078    },
1079    /// verify that the permit creator has approval to transfer every listed token.  
1080    /// A token will count as unapproved if it is non-transferable
1081    VerifyTransferApproval {
1082        /// list of tokens to verify approval for
1083        token_ids: Vec<String>,
1084    },
1085    /// display the transaction history for the permit creator in reverse
1086    /// chronological order
1087    TransactionHistory {
1088        /// optional page to display
1089        page: Option<u32>,
1090        /// optional number of transactions per page
1091        page_size: Option<u32>,
1092    },
1093    /// display the number of tokens controlled by the contract.  The token supply must
1094    /// either be public, or the querier must be an authenticated minter
1095    NumTokens {},
1096    /// display an optionally paginated list of all the tokens controlled by the contract.
1097    /// The token supply must either be public, or the querier must be an authenticated
1098    /// minter
1099    AllTokens {
1100        /// paginate by providing the last token_id received in the previous query
1101        start_after: Option<String>,
1102        /// optional number of token ids to display
1103        limit: Option<u32>,
1104    },
1105    /// list all the approvals in place for a specified token if given the owner's permit
1106    TokenApprovals {
1107        token_id: String,
1108        /// optionally include expired Approvals in the response list.  If ommitted or
1109        /// false, expired Approvals will be filtered out of the response
1110        include_expired: Option<bool>,
1111    },
1112    /// displays a list of all the CW721-style operators (any address that was granted
1113    /// approval to transfer all of the owner's tokens).  This query is provided to maintain
1114    /// CW721 compliance
1115    ApprovedForAll {
1116        /// optionally include expired Approvals in the response list.  If ommitted or
1117        /// false, expired Approvals will be filtered out of the response
1118        include_expired: Option<bool>,
1119    },
1120    /// displays a list of all the tokens belonging to the input owner in which the permit
1121    /// creator has view_owner permission
1122    Tokens {
1123        owner: HumanAddr,
1124        /// paginate by providing the last token_id received in the previous query
1125        start_after: Option<String>,
1126        /// optional number of token ids to display
1127        limit: Option<u32>,
1128    },
1129    /// displays the number of tokens that the querier has permission to see the owner and that
1130    /// belong to the specified address
1131    NumTokensOfOwner { owner: HumanAddr },
1132}