1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use cosmwasm_schema::cw_serde;
use cosmwasm_std::Addr;
use cw_storage_plus::{Item, Map};
use komple_framework_types::modules::metadata::{
    Metadata as MetadataType, DYNAMIC_LINKED_METADATA_NAMESPACE, LINKED_METADATA_NAMESPACE,
    METADATA_ID_NAMESPACE, METADATA_NAMESPACE,
};
use komple_framework_types::shared::{
    CONFIG_NAMESPACE, OPERATORS_NAMESPACE, PARENT_ADDR_NAMESPACE,
};

#[cw_serde]
pub struct Config {
    pub admin: Addr,
    pub metadata_type: MetadataType,
}
pub const CONFIG: Item<Config> = Item::new(CONFIG_NAMESPACE);

// pub const METADATA_LOCK: Map<&str, bool> = Map::new("metadata_lock");

/// Address of the token contract.
pub const COLLECTION_ADDR: Item<Addr> = Item::new(PARENT_ADDR_NAMESPACE);

#[cw_serde]
pub struct Trait {
    // pub display_type: Option<String>,
    pub trait_type: String,
    pub value: String,
}
#[cw_serde]
pub struct MetaInfo {
    pub image: Option<String>,
    pub external_url: Option<String>,
    pub description: Option<String>,
    pub animation_url: Option<String>,
    pub youtube_url: Option<String>,
}
#[cw_serde]
pub struct Metadata {
    pub meta_info: MetaInfo,
    pub attributes: Vec<Trait>,
}
/// Raw metadata values that is saved to storage.
/// `AddMetadata` message can be used to add items to this map.
pub const METADATA: Map<u32, Metadata> = Map::new(METADATA_NAMESPACE);

/// ID used to identify a single raw metadata.
pub const METADATA_ID: Item<u32> = Item::new(METADATA_ID_NAMESPACE);

/// Linked metadata values that is saved to storage.
/// `LinkMetadata` message can be used to add items to this map.
///
/// Raw metadata ids are mapped to token ids.
/// Only works for `Standard` and `Shared` metadata types.
pub const LINKED_METADATA: Map<u32, u32> = Map::new(LINKED_METADATA_NAMESPACE);

/// Linked metadata values that is saved to storage.
/// `LinkMetadata` message can be used to add items to this map.
///
/// Whole metadata objects are mapped to token ids.
/// Only works for `Dynamic` metadata type.
pub const DYNAMIC_LINKED_METADATA: Map<u32, Metadata> = Map::new(DYNAMIC_LINKED_METADATA_NAMESPACE);

/// Operators of this contract.
pub const OPERATORS: Item<Vec<Addr>> = Item::new(OPERATORS_NAMESPACE);