Skip to content

Commit

Permalink
Update Account::find_identity() to return IdentityState.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-renaud committed Sep 29, 2021
1 parent b4a0deb commit 1156f38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions identity-account/src/account/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,14 @@ impl Account {
self.index.read().await.tags()
}

/// Finds and returns the state snapshot for the identity specified by given `key`.
pub async fn find_identity<K: IdentityKey>(&self, key: K) -> Result<Option<IdentitySnapshot>> {
/// Finds and returns the identity state for the identity specified by given `key`.
pub async fn find_identity<K: IdentityKey>(&self, key: K) -> Result<Option<IdentityState>> {
match self.resolve_id(&key).await {
Some(identity) => self.load_snapshot(identity).await.map(Some),
Some(identity) => self
.load_snapshot(identity)
.await
.map(IdentitySnapshot::into_identity)
.map(Some),
None => Ok(None),
}
}
Expand Down
4 changes: 2 additions & 2 deletions identity-account/src/tests/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ async fn test_create_identity_from_private_key() -> Result<()> {
let ident2 = account.find_identity(identity).await.unwrap().unwrap();

// The same private key should result in the same did
assert_eq!(ident.identity().did(), ident2.identity().did());
assert_eq!(ident.identity().authentication()?, ident2.identity().authentication()?);
assert_eq!(ident.did(), ident2.did());
assert_eq!(ident.authentication()?, ident2.authentication()?);

Ok(())
}
Expand Down

0 comments on commit 1156f38

Please sign in to comment.