1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use serde_aux::prelude::*;
use serde_with::formats::Flexible;
use serde_with::TimestampNanoSeconds;

use crate::AssetAmounts;

/*

*** Balance Scheme ***
{
	"coins": AssetAmounts,
	"date": "1710779252869332524",
	"height": "15166269"
}

*/

#[serde_with::serde_as]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct Balance {
	coins: AssetAmounts,

	#[serde_as(as = "TimestampNanoSeconds<String, Flexible>")]
	date: DateTime<Utc>,

	#[serde(deserialize_with = "deserialize_number_from_string")]
	height: u64,
}

impl Balance {
	#[must_use]
	pub const fn get_coins(&self) -> &AssetAmounts {
		&self.coins
	}

	#[must_use]
	pub const fn get_date(&self) -> &DateTime<Utc> {
		&self.date
	}

	#[must_use]
	pub const fn get_height(&self) -> &u64 {
		&self.height
	}
}