Skip to main content

blockfrost_openapi/models/
dreps_inner_metadata.rs

1use crate::models;
2use serde::{Deserialize, Serialize};
3
4/// DrepsInnerMetadata : Off-chain metadata associated with the DRep's latest registration. `null` when the DRep has no registration anchor (e.g. special DReps such as `drep_always_abstain` / `drep_always_no_confidence`). When an anchor exists but the off-chain content could not be fetched or validated, `error` is populated and `json_metadata` / `bytes` are `null`. 
5#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
6pub struct DrepsInnerMetadata {
7    /// URL to the drep metadata
8    #[serde(rename = "url")]
9    pub url: String,
10    /// Hash of the metadata file
11    #[serde(rename = "hash")]
12    pub hash: String,
13    /// Content of the JSON metadata (validated CIP-119)
14    #[serde(rename = "json_metadata", deserialize_with = "Option::deserialize")]
15    pub json_metadata: Option<serde_json::Value>,
16    /// Content of the metadata (raw)
17    #[serde(rename = "bytes", deserialize_with = "Option::deserialize")]
18    pub bytes: Option<String>,
19    #[serde(rename = "error", skip_serializing_if = "Option::is_none")]
20    pub error: Option<Box<models::DrepsInnerMetadataError>>,
21}
22
23impl DrepsInnerMetadata {
24    /// Off-chain metadata associated with the DRep's latest registration. `null` when the DRep has no registration anchor (e.g. special DReps such as `drep_always_abstain` / `drep_always_no_confidence`). When an anchor exists but the off-chain content could not be fetched or validated, `error` is populated and `json_metadata` / `bytes` are `null`. 
25    pub fn new(url: String, hash: String, json_metadata: Option<serde_json::Value>, bytes: Option<String>) -> DrepsInnerMetadata {
26        DrepsInnerMetadata {
27            url,
28            hash,
29            json_metadata,
30            bytes,
31            error: None,
32        }
33    }
34}
35