-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use crate::prelude::*; | ||
|
||
async fn _account_recovery_scan( | ||
input: DeriveAndAnalyzeInputAccountRecoveryScan, | ||
) -> Result<DerivationAndAnalysisAccountRecoveryScan> { | ||
let input = DeriveAndAnalyzeInput::from(input); | ||
let analysis = derive_and_analyze(input).await?; | ||
DerivationAndAnalysisAccountRecoveryScan::try_from(analysis) | ||
} | ||
|
||
pub async fn account_recovery_scan( | ||
factor_sources: IndexSet<HDFactorSource>, | ||
gateway: Arc<dyn Gateway>, | ||
) -> Result<AccountRecoveryScanOutcome> { | ||
let analysis = _account_recovery_scan(DeriveAndAnalyzeInputAccountRecoveryScan::new( | ||
factor_sources, | ||
gateway, | ||
)) | ||
.await?; | ||
Ok(AccountRecoveryScanOutcome::from(analysis)) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use crate::prelude::*; | ||
|
||
pub struct DeriveAndAnalyzeInputAccountRecoveryScan { | ||
factor_sources: IndexSet<HDFactorSource>, | ||
gateway: Arc<dyn Gateway>, | ||
} | ||
impl DeriveAndAnalyzeInputAccountRecoveryScan { | ||
pub fn new(factor_sources: IndexSet<HDFactorSource>, gateway: Arc<dyn Gateway>) -> Self { | ||
Check warning on line 8 in src/recovery_securify_cache/account_recover_scan/derive_and_analyze_input_account_recovery_scan.rs Codecov / codecov/patchsrc/recovery_securify_cache/account_recover_scan/derive_and_analyze_input_account_recovery_scan.rs#L8
|
||
Self { | ||
factor_sources, | ||
gateway, | ||
} | ||
} | ||
} | ||
impl From<DeriveAndAnalyzeInputAccountRecoveryScan> for DeriveAndAnalyzeInput { | ||
fn from(value: DeriveAndAnalyzeInputAccountRecoveryScan) -> Self { | ||
Check warning on line 16 in src/recovery_securify_cache/account_recover_scan/derive_and_analyze_input_account_recovery_scan.rs Codecov / codecov/patchsrc/recovery_securify_cache/account_recover_scan/derive_and_analyze_input_account_recovery_scan.rs#L16
|
||
Self::new( | ||
value.factor_sources.clone(), | ||
value | ||
Check warning on line 19 in src/recovery_securify_cache/account_recover_scan/derive_and_analyze_input_account_recovery_scan.rs Codecov / codecov/patchsrc/recovery_securify_cache/account_recover_scan/derive_and_analyze_input_account_recovery_scan.rs#L18-L19
|
||
.factor_sources | ||
.into_iter() | ||
.map(|f| f.factor_source_id()) | ||
Check warning on line 22 in src/recovery_securify_cache/account_recover_scan/derive_and_analyze_input_account_recovery_scan.rs Codecov / codecov/patchsrc/recovery_securify_cache/account_recover_scan/derive_and_analyze_input_account_recovery_scan.rs#L22
|
||
.collect(), | ||
None, | ||
value.gateway, | ||
Check warning on line 25 in src/recovery_securify_cache/account_recover_scan/derive_and_analyze_input_account_recovery_scan.rs Codecov / codecov/patchsrc/recovery_securify_cache/account_recover_scan/derive_and_analyze_input_account_recovery_scan.rs#L24-L25
|
||
true, | ||
None, | ||
Check warning on line 27 in src/recovery_securify_cache/account_recover_scan/derive_and_analyze_input_account_recovery_scan.rs Codecov / codecov/patchsrc/recovery_securify_cache/account_recover_scan/derive_and_analyze_input_account_recovery_scan.rs#L27
|
||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
mod account_recovery_scan_outcome; | ||
mod account_recovery_scanning; | ||
mod derivation_and_analysis_account_recovery_scan; | ||
mod derive_and_analyze_input_account_recovery_scan; | ||
|
||
pub use account_recovery_scan_outcome::*; | ||
pub use account_recovery_scanning::*; | ||
pub use derivation_and_analysis_account_recovery_scan::*; | ||
pub use derive_and_analyze_input_account_recovery_scan::*; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#![allow(unused)] | ||
|
||
use crate::prelude::*; | ||
|
||
pub struct ProfileNextIndexAnalyzer {} | ||
|
||
pub struct DeriveAndAnalyzeInput { | ||
factor_sources: IndexSet<HDFactorSource>, | ||
ids_of_new_factor_sources: IndexSet<FactorSourceIDFromHash>, | ||
cache: Option<PreDerivedKeysCache>, | ||
gateway: Arc<dyn Gateway>, | ||
|
||
/// "Gateway required" | ||
is_onchain_analysis_required: bool, | ||
|
||
profile_next_index_analyzer: Option<ProfileNextIndexAnalyzer>, | ||
} | ||
|
||
impl DeriveAndAnalyzeInput { | ||
/// # Panics | ||
/// Panics if some IDs of `ids_of_new_factor_sources` are not found in `factor_sources` | ||
pub fn new( | ||
factor_sources: IndexSet<HDFactorSource>, | ||
ids_of_new_factor_sources: IndexSet<FactorSourceIDFromHash>, | ||
cache: Option<PreDerivedKeysCache>, | ||
gateway: Arc<dyn Gateway>, | ||
is_onchain_analysis_required: bool, | ||
profile_next_index_analyzer: Option<ProfileNextIndexAnalyzer>, | ||
) -> Self { | ||
assert!( | ||
ids_of_new_factor_sources | ||
.iter() | ||
.all(|id| factor_sources.iter().any(|f| f.factor_source_id() == *id)), | ||
"Discrepancy! Some IDs of new factor sources are not found in factor sources!" | ||
); | ||
|
||
Self { | ||
factor_sources, | ||
ids_of_new_factor_sources, | ||
cache, | ||
gateway, | ||
is_onchain_analysis_required, | ||
profile_next_index_analyzer, | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod input; | ||
mod output; | ||
|
||
pub use input::*; | ||
pub use output::*; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
mod derivation_and_analysis; | ||
mod probably_free_factor_instances; | ||
mod recovered_securified_entities; | ||
mod recovered_unsecurified_entities; | ||
mod securified_entity; | ||
mod unrecovered_securified_entities; | ||
mod unrecovered_securified_entity; | ||
mod unsecurified_entity; | ||
|
||
pub use derivation_and_analysis::*; | ||
pub use probably_free_factor_instances::*; | ||
pub use recovered_securified_entities::*; | ||
pub use recovered_unsecurified_entities::*; | ||
pub use securified_entity::*; | ||
pub use unrecovered_securified_entities::*; | ||
pub use unrecovered_securified_entity::*; | ||
pub use unsecurified_entity::*; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,9 @@ | ||
mod account_recover_scan; | ||
mod derivation_and_analysis; | ||
mod playground; | ||
mod derive_and_analyze; | ||
mod pre_derived_keys_cache; | ||
mod probably_free_factor_instances; | ||
mod recovered_securified_entities; | ||
mod recovered_unsecurified_entities; | ||
mod securified_entity; | ||
mod unrecovered_securified_entities; | ||
mod unrecovered_securified_entity; | ||
mod unsecurified_entity; | ||
|
||
pub use account_recover_scan::*; | ||
pub use derivation_and_analysis::*; | ||
pub use derive_and_analyze::*; | ||
pub use pre_derived_keys_cache::*; | ||
pub use probably_free_factor_instances::*; | ||
pub use recovered_securified_entities::*; | ||
pub use recovered_unsecurified_entities::*; | ||
pub use securified_entity::*; | ||
pub use unrecovered_securified_entities::*; | ||
pub use unrecovered_securified_entity::*; | ||
pub use unsecurified_entity::*; |