etopay_sdk/types/
users.rs1use super::newtypes::{EncryptedPassword, EncryptionSalt};
2use crate::{
3 tx_version::VersionedWalletTransaction,
4 types::viviswap::ViviswapState,
5 wallet_manager::{WalletManager, WalletManagerImpl},
6};
7use etopay_wallet::{MnemonicDerivationOption, types::WalletTxInfo};
8use serde::{Deserialize, Serialize};
9
10#[derive(Debug, Deserialize, Serialize, Clone)]
12#[cfg_attr(test, derive(PartialEq))]
13pub struct UserEntity {
14 pub user_id: Option<String>,
16 pub username: String,
18 pub encrypted_password: Option<EncryptedPassword>,
20 pub salt: EncryptionSalt,
22 pub is_kyc_verified: bool,
24 pub kyc_type: KycType,
26 pub viviswap_state: Option<ViviswapState>,
28
29 pub local_share: Option<String>,
31
32 pub wallet_transactions: Vec<WalletTxInfo>,
34
35 #[serde(default)]
37 pub wallet_transactions_versioned: Vec<VersionedWalletTransaction>,
38}
39
40#[derive(Debug)]
42pub struct ActiveUser {
43 pub username: String,
45
46 pub wallet_manager: Box<dyn WalletManager + Send + Sync + 'static>,
48
49 pub mnemonic_derivation_options: MnemonicDerivationOption,
51}
52
53impl From<UserEntity> for ActiveUser {
54 fn from(entity: UserEntity) -> Self {
55 ActiveUser {
56 wallet_manager: Box::new(WalletManagerImpl::new(&entity.username)),
57 username: entity.username,
58 mnemonic_derivation_options: Default::default(),
59 }
60 }
61}
62
63#[derive(Debug, Eq, PartialEq, Deserialize, Serialize, Clone)]
65pub enum KycType {
66 Undefined,
68
69 #[cfg(feature = "postident")]
71 Postident,
72
73 #[cfg(feature = "viviswap-kyc")]
75 Viviswap,
76}