Skip to content

Commit

Permalink
refactor: cleanup passphrase and hidden impl to use tari_utils (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
willyrgf authored Feb 7, 2024
1 parent 8787f19 commit d5eb3b5
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 141 deletions.
139 changes: 139 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions mfm_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ zeroize = "1.7.0"
serde_json = "1.0.108"
serde_derive = "1.0.193"
anyhow = "1.0.75"
tari_utilities = "0.7.0"
23 changes: 19 additions & 4 deletions mfm_core/src/config/authentication/wallet.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
use serde_derive::{Deserialize, Serialize};
use serde::{Deserialize, Serialize};
use tari_utilities::SafePassword;

use crate::password::{deserialize_safe_password, SafePassword};

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Wallet {
#[serde(deserialize_with = "deserialize_safe_password")]
pub private_key: SafePassword,
pub not_encrypted: bool,
pub env_password: Option<String>,
}

impl PartialEq for Wallet {
fn eq(&self, other: &Self) -> bool {
self.not_encrypted == other.not_encrypted && self.env_password == other.env_password
}
}

impl Eq for Wallet {}

fn deserialize_safe_password<'de, D>(deserializer: D) -> Result<SafePassword, D::Error>
where
D: serde::Deserializer<'de>,
{
let password: String = Deserialize::deserialize(deserializer)?;
Ok(SafePassword::from(password))
}
72 changes: 0 additions & 72 deletions mfm_core/src/hidden/mod.rs

This file was deleted.

3 changes: 0 additions & 3 deletions mfm_core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
pub mod config;
pub mod contexts;
pub mod hidden;
pub mod password;
pub mod states;
pub mod tasks;
61 changes: 0 additions & 61 deletions mfm_core/src/password/mod.rs

This file was deleted.

1 change: 0 additions & 1 deletion mfm_core/src/tasks/mod.rs

This file was deleted.

0 comments on commit d5eb3b5

Please sign in to comment.