whisky_common/data/primitives/
integer.rs

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