whisky/builder/
data.rs

1use crate::*;
2
3#[derive(Clone, Debug)]
4pub enum WData {
5    JSON(String),
6    CBOR(String),
7}
8
9impl WData {
10    pub fn to_cbor(&self) -> Result<String, WError> {
11        match self {
12            WData::CBOR(data) => Ok(data.clone()),
13            WData::JSON(data) => {
14                let data_cbor =
15                    &csl::PlutusData::from_json(data, csl::PlutusDatumSchema::DetailedSchema)
16                        .map_err(WError::from_err("WData - to_cbor"))?
17                        .to_hex();
18                Ok(data_cbor.clone())
19            }
20        }
21    }
22}
23
24#[derive(Clone, Debug)]
25pub struct WRedeemer {
26    pub data: WData,
27    pub ex_units: Budget,
28}
29
30#[derive(Clone, Debug)]
31pub struct WDatum {
32    pub type_: String,
33    pub data: WData,
34}