Skip to main content

komple_framework_metadata_module/
msg.rs

1use crate::state::{Config, MetaInfo, Metadata, Trait};
2use cosmwasm_schema::{cw_serde, QueryResponses};
3use komple_framework_types::modules::metadata::Metadata as MetadataType;
4use komple_framework_types::shared::query::ResponseWrapper;
5
6/// Message to be sent along the `RegisterMsg` for instantiation.
7#[cw_serde]
8pub struct InstantiateMsg {
9    pub metadata_type: MetadataType,
10}
11
12#[cw_serde]
13pub enum ExecuteMsg {
14    /// Admin message.
15    ///
16    /// Add token metadata information.
17    AddMetadata {
18        meta_info: MetaInfo,
19        attributes: Vec<Trait>,
20    },
21    /// Admin message.
22    ///
23    /// Link a token id to a metadata id.
24    /// If metadata id is `None`, then the token id will be used as metadata id.
25    LinkMetadata {
26        token_id: u32,
27        metadata_id: Option<u32>,
28    },
29    /// Admin message.
30    ///
31    /// Unlink metadata from a token id.
32    UnlinkMetadata { token_id: u32 },
33    /// Admin message.
34    ///
35    /// Update the meta info for a metadata.
36    /// Can be called for raw metadata id and linked metadata id.
37    UpdateMetaInfo {
38        raw_metadata: bool,
39        id: u32,
40        meta_info: MetaInfo,
41    },
42    /// Admin message.
43    ///
44    /// Add an attribute for a metadata.
45    /// Can be called for raw metadata id and linked metadata id.
46    AddAttribute {
47        raw_metadata: bool,
48        id: u32,
49        attribute: Trait,
50    },
51    /// Admin message.
52    ///
53    /// Update an attribute for a metadata.
54    /// Can be called for raw metadata id and linked metadata id.
55    UpdateAttribute {
56        raw_metadata: bool,
57        id: u32,
58        attribute: Trait,
59    },
60    /// Admin message.
61    ///
62    /// Remove a trait from a metadata's attributes.
63    /// Can be called for raw metadata id and linked metadata id.
64    RemoveAttribute {
65        raw_metadata: bool,
66        id: u32,
67        trait_type: String,
68    },
69    /// Admin message.
70    ///
71    /// Update the operators of this contract.
72    UpdateOperators { addrs: Vec<String> },
73}
74
75#[cw_serde]
76#[derive(QueryResponses)]
77pub enum QueryMsg {
78    /// Get the contract's config.
79    #[returns(ResponseWrapper<Config>)]
80    Config {},
81    /// Get a metadata with given raw metadata id.
82    #[returns(ResponseWrapper<Metadata>)]
83    RawMetadata { metadata_id: u32 },
84    /// Get a metadata with given token id.
85    #[returns(ResponseWrapper<MetadataResponse>)]
86    Metadata { token_id: u32 },
87    /// List all the raw metadata with pagination.
88    #[returns(ResponseWrapper<Vec<MetadataResponse>>)]
89    RawMetadatas {
90        start_after: Option<u32>,
91        limit: Option<u8>,
92    },
93    /// List all the linked metadata with pagination.
94    #[returns(ResponseWrapper<Vec<MetadataResponse>>)]
95    Metadatas {
96        start_after: Option<u32>,
97        limit: Option<u8>,
98    },
99    /// Get the operators of this contract.
100    #[returns(ResponseWrapper<Vec<String>>)]
101    Operators {},
102}
103
104#[cw_serde]
105pub struct MetadataResponse {
106    pub metadata: Metadata,
107    pub metadata_id: u32,
108}
109
110#[cw_serde]
111pub struct MigrateMsg {}