1use serde::{Deserialize, Serialize};
2use uuid::Uuid;
3
4#[derive(Clone, Debug, Serialize, Deserialize)]
6pub struct Wallet {
7 pub id: Uuid,
9
10 pub email: String,
12
13 pub address: String,
15
16 pub balance: f64,
18
19 pub transaction_hashes: Vec<String>,
21}
22
23impl Wallet {
24 pub fn new(email: &str, address: &str) -> Self {
35 Wallet {
36 id: Uuid::new_v4(),
37 email: email.to_string(),
38 address: address.to_string(),
39 balance: 0.0,
40 transaction_hashes: vec![],
41 }
42 }
43}
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[test]
50 fn test_new_wallet() {
51 let email = "email".to_string();
52 let address = "0x 1234".to_string();
53 let wallet = Wallet::new(&email, &address);
54
55 assert_eq!(wallet.id.get_version(), Some(uuid::Version::Random));
56 assert_eq!(wallet.email, email);
57 assert_eq!(wallet.address, address);
58 assert_eq!(wallet.balance, 0.0);
59 assert!(wallet.transaction_hashes.is_empty());
60 }
61}