-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Entities linked to Factor Source (#302)
* WIP * WIP * key mapping solution * using accessibility * rename to linkedTo * WIP * rename to integrity * WIP * missing tests * version bump * changes after feedback * bump again * implemented containsDataForKey in the AndroidStorageDriver for the Android SargonOS * updated Fakes in unit tests * changes after feedback --------- Co-authored-by: giannis.tsepas <giannis.tsepas@rdx.works>
- Loading branch information
1 parent
56c6e58
commit 51c15f1
Showing
54 changed files
with
1,265 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...ffi/src/profile/v100/entities_linked_to_factor_source/entities_linked_to_factor_source.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use crate::prelude::*; | ||
use sargon::EntitiesLinkedToFactorSource as InternalEntitiesLinkedToFactorSource; | ||
|
||
/// This is the result of checking what entities are controlled by a given `FactorSource`. | ||
#[derive(Clone, PartialEq, InternalConversion, uniffi::Record)] | ||
pub struct EntitiesLinkedToFactorSource { | ||
/// The integrity of the factor source. | ||
pub integrity: FactorSourceIntegrity, | ||
|
||
/// The visible accounts linked to the factor source. | ||
pub accounts: Vec<Account>, | ||
|
||
/// The hidden accounts linked to the factor source. | ||
pub hidden_accounts: Vec<Account>, | ||
|
||
/// The visible personas linked to the factor source. | ||
pub personas: Vec<Persona>, | ||
|
||
/// The hidden personas linked to the factor source. | ||
pub hidden_personas: Vec<Persona>, | ||
} |
15 changes: 15 additions & 0 deletions
15
crates/sargon-uniffi/src/profile/v100/entities_linked_to_factor_source/integrity/device.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use crate::prelude::*; | ||
use sargon::DeviceFactorSourceIntegrity as InternalDeviceFactorSourceIntegrity; | ||
|
||
/// A struct representing the integrity of a device factor source. | ||
#[derive(Clone, PartialEq, Eq, InternalConversion, uniffi::Record)] | ||
pub struct DeviceFactorSourceIntegrity { | ||
/// The factor source that is linked to the entities. | ||
pub factor_source: DeviceFactorSource, | ||
|
||
/// Whether the mnemonic of the factor source is present in secure storage. | ||
pub is_mnemonic_present_in_secure_storage: bool, | ||
|
||
/// Whether the mnemonic of the factor source is marked as backed up. | ||
pub is_mnemonic_marked_as_backed_up: bool, | ||
} |
10 changes: 10 additions & 0 deletions
10
...es/sargon-uniffi/src/profile/v100/entities_linked_to_factor_source/integrity/integrity.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use crate::prelude::*; | ||
use sargon::FactorSourceIntegrity as InternalFactorSourceIntegrity; | ||
|
||
/// An enum representing the integrity of a factor source. | ||
#[derive(Clone, PartialEq, InternalConversion, uniffi::Enum)] | ||
pub enum FactorSourceIntegrity { | ||
Device(DeviceFactorSourceIntegrity), | ||
|
||
Ledger(LedgerHardwareWalletFactorSource), | ||
} |
5 changes: 5 additions & 0 deletions
5
crates/sargon-uniffi/src/profile/v100/entities_linked_to_factor_source/integrity/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod device; | ||
mod integrity; | ||
|
||
pub use device::*; | ||
pub use integrity::*; |
7 changes: 7 additions & 0 deletions
7
crates/sargon-uniffi/src/profile/v100/entities_linked_to_factor_source/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
mod entities_linked_to_factor_source; | ||
mod integrity; | ||
mod profile_to_check; | ||
|
||
pub use entities_linked_to_factor_source::*; | ||
pub use integrity::*; | ||
pub use profile_to_check::*; |
14 changes: 14 additions & 0 deletions
14
crates/sargon-uniffi/src/profile/v100/entities_linked_to_factor_source/profile_to_check.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use crate::prelude::*; | ||
use sargon::ProfileToCheck as InternalProfileToCheck; | ||
|
||
/// The Profile to which we want to check the entities linked to a factor source. | ||
#[derive(Clone, PartialEq, InternalConversion, uniffi::Enum)] | ||
#[allow(clippy::large_enum_variant)] | ||
pub enum ProfileToCheck { | ||
/// We should check against the current Profile. | ||
Current, | ||
|
||
/// We should check against a specific Profile. | ||
/// Useful when we are in the Import Mnenmonics flow. | ||
Specific(Profile), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
crates/sargon-uniffi/src/system/sargon_os/sargon_os_entities_linked_to_factor_source.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use crate::prelude::*; | ||
|
||
#[uniffi::export] | ||
impl SargonOS { | ||
/// Returns the entities linked to a given `FactorSource`, either on the current `Profile` or a specific one. | ||
pub async fn entities_linked_to_factor_source( | ||
&self, | ||
factor_source: FactorSource, | ||
profile_to_check: ProfileToCheck, | ||
) -> Result<EntitiesLinkedToFactorSource> { | ||
self.wrapped | ||
.entities_linked_to_factor_source( | ||
factor_source.into_internal(), | ||
profile_to_check.into_internal(), | ||
) | ||
.await | ||
.into_result() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.