Skip to main content

blockfrost_openapi/models/
asset_metadata.rs

1use crate::models;
2use serde::{Deserialize, Serialize};
3
4/// AssetMetadata : Off-chain metadata fetched from GitHub based on network. Mainnet: https://github.com/cardano-foundation/cardano-token-registry/ Testnet: https://github.com/input-output-hk/metadata-registry-testnet/ 
5#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
6pub struct AssetMetadata {
7    /// Asset name
8    #[serde(rename = "name")]
9    pub name: String,
10    /// Asset description
11    #[serde(rename = "description")]
12    pub description: String,
13    #[serde(rename = "ticker", deserialize_with = "Option::deserialize")]
14    pub ticker: Option<String>,
15    /// Asset website
16    #[serde(rename = "url", deserialize_with = "Option::deserialize")]
17    pub url: Option<String>,
18    /// Base64 encoded logo of the asset
19    #[serde(rename = "logo", deserialize_with = "Option::deserialize")]
20    pub logo: Option<String>,
21    /// Number of decimal places of the asset unit
22    #[serde(rename = "decimals", deserialize_with = "Option::deserialize")]
23    pub decimals: Option<i32>,
24}
25
26impl AssetMetadata {
27    /// Off-chain metadata fetched from GitHub based on network. Mainnet: https://github.com/cardano-foundation/cardano-token-registry/ Testnet: https://github.com/input-output-hk/metadata-registry-testnet/ 
28    pub fn new(name: String, description: String, ticker: Option<String>, url: Option<String>, logo: Option<String>, decimals: Option<i32>) -> AssetMetadata {
29        AssetMetadata {
30            name,
31            description,
32            ticker,
33            url,
34            logo,
35            decimals,
36        }
37    }
38}
39