whisky_common/data/primitives/
byte_string.rs

1use serde_json::{json, Value};
2
3use crate::data::PlutusDataJson;
4
5#[derive(Clone, Debug)]
6pub struct ByteString {
7    pub bytes: String,
8}
9
10impl ByteString {
11    pub fn new(bytes: &str) -> Self {
12        ByteString {
13            bytes: bytes.to_string(),
14        }
15    }
16}
17
18impl PlutusDataJson for ByteString {
19    fn to_json(&self) -> Value {
20        byte_string(&self.bytes)
21    }
22}
23
24pub fn byte_string(bytes: &str) -> Value {
25    json!({ "bytes": bytes })
26}
27
28pub fn builtin_byte_string(bytes: &str) -> Value {
29    json!({ "bytes": bytes })
30}