hermit_toolkit_hmip721/metadata.rs
1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4// The response of both NftINfo and PrivateMetadata queries are Metadata
5//
6
7/// token metadata
8#[derive(Serialize, Deserialize, JsonSchema, Clone, PartialEq, Debug, Default)]
9pub struct Metadata {
10 /// optional uri for off-chain metadata. This should be prefixed with `http://`, `https://`, `ipfs://`, or
11 /// `ar://`. Only use this if you are not using `extension`
12 pub token_uri: Option<String>,
13 /// optional on-chain metadata. Only use this if you are not using `token_uri`
14 pub extension: Option<Extension>,
15}
16
17/// metadata extension
18/// You can add any metadata fields you need here. These fields are based on
19/// https://docs.opensea.io/docs/metadata-standards and are the metadata fields that
20/// Stashh uses for robust NFT display. Urls should be prefixed with `http://`, `https://`, `ipfs://`, or
21/// `ar://`
22#[derive(Serialize, Deserialize, JsonSchema, Clone, PartialEq, Debug, Default)]
23pub struct Extension {
24 /// url to the image
25 pub image: Option<String>,
26 /// raw SVG image data (not recommended). Only use this if you're not including the image parameter
27 pub image_data: Option<String>,
28 /// url to allow users to view the item on your site
29 pub external_url: Option<String>,
30 /// item description
31 pub description: Option<String>,
32 /// name of the item
33 pub name: Option<String>,
34 /// item attributes
35 pub attributes: Option<Vec<Trait>>,
36 /// background color represented as a six-character hexadecimal without a pre-pended #
37 pub background_color: Option<String>,
38 /// url to a multimedia attachment
39 pub animation_url: Option<String>,
40 /// url to a YouTube video
41 pub youtube_url: Option<String>,
42 /// media files as specified on Stashh that allows for basic authenticatiion and decryption keys.
43 /// Most of the above is used for bridging public eth NFT metadata easily, whereas `media` will be used
44 /// when minting NFTs on Stashh
45 pub media: Option<Vec<MediaFile>>,
46 /// a select list of trait_types that are in the private metadata. This will only ever be used
47 /// in public metadata
48 pub protected_attributes: Option<Vec<String>>,
49}
50
51/// attribute trait
52#[derive(Serialize, Deserialize, JsonSchema, Clone, PartialEq, Debug, Default)]
53pub struct Trait {
54 /// indicates how a trait should be displayed
55 pub display_type: Option<String>,
56 /// name of the trait
57 pub trait_type: Option<String>,
58 /// trait value
59 pub value: String,
60 /// optional max value for numerical traits
61 pub max_value: Option<String>,
62}
63
64/// media file
65#[derive(Serialize, Deserialize, JsonSchema, Clone, PartialEq, Debug, Default)]
66pub struct MediaFile {
67 /// file type
68 /// Stashh currently uses: "image", "video", "audio", "text", "font", "application"
69 pub file_type: Option<String>,
70 /// file extension
71 pub extension: Option<String>,
72 /// authentication information
73 pub authentication: Option<Authentication>,
74 /// url to the file. Urls should be prefixed with `http://`, `https://`, `ipfs://`, or `ar://`
75 pub url: String,
76}
77
78/// media file authentication
79#[derive(Serialize, Deserialize, JsonSchema, Clone, PartialEq, Debug, Default)]
80pub struct Authentication {
81 /// either a decryption key for encrypted files or a password for basic authentication
82 pub key: Option<String>,
83 /// username used in basic authentication
84 pub user: Option<String>,
85}