-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement fetching all records for askar
Signed-off-by: Ondrej Prazak <ondrej.prazak@absa.africa>
- Loading branch information
Ondrej Prazak
committed
Feb 28, 2024
1 parent
ed3c8c7
commit ea4a137
Showing
16 changed files
with
379 additions
and
237 deletions.
There are no files selected for viewing
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
31 changes: 31 additions & 0 deletions
31
aries/aries_vcx_core/src/wallet/askar/all_askar_records.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,31 @@ | ||
use async_trait::async_trait; | ||
|
||
use crate::{ | ||
errors::error::VcxCoreResult, | ||
wallet::base_wallet::record::{AllRecords, PartialRecord}, | ||
}; | ||
|
||
pub struct AllAskarRecords { | ||
iterator: std::vec::IntoIter<PartialRecord>, | ||
total_count: Option<usize>, | ||
} | ||
|
||
impl AllAskarRecords { | ||
pub fn new(iterator: std::vec::IntoIter<PartialRecord>, total_count: Option<usize>) -> Self { | ||
Self { | ||
iterator, | ||
total_count, | ||
} | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl AllRecords for AllAskarRecords { | ||
fn total_count(&self) -> VcxCoreResult<Option<usize>> { | ||
Ok(self.total_count) | ||
} | ||
|
||
async fn next(&mut self) -> VcxCoreResult<Option<PartialRecord>> { | ||
Ok(self.iterator.next()) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
pub struct KeyValue { | ||
verkey: String, | ||
signkey: String, | ||
} | ||
|
||
impl KeyValue { | ||
pub fn new(signkey: String, verkey: String) -> Self { | ||
Self { signkey, verkey } | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use crate::{ | ||
errors::error::VcxCoreResult, | ||
wallet::{ | ||
askar::askar_utils::{local_key_to_bs58_private_key, local_key_to_bs58_public_key}, | ||
base_wallet::{record::PartialRecord, record_category::RecordCategory}, | ||
}, | ||
}; | ||
|
||
use super::{askar_utils::value_from_entry, key_value::KeyValue}; | ||
|
||
impl PartialRecord { | ||
pub fn from_askar_entry(entry: aries_askar::entry::Entry) -> VcxCoreResult<Self> { | ||
Ok(Self::builder() | ||
.name(entry.name.clone()) | ||
.category(Some(entry.category.clone())) | ||
.value(Some(value_from_entry(entry.clone())?)) | ||
.tags(Some(entry.tags.into())) | ||
.build()) | ||
} | ||
|
||
pub fn from_askar_key_entry(key_entry: aries_askar::kms::KeyEntry) -> VcxCoreResult<Self> { | ||
let local_key = key_entry.load_local_key()?; | ||
let name = key_entry.name(); | ||
let tags = key_entry.tags_as_slice(); | ||
|
||
let value = KeyValue::new( | ||
local_key_to_bs58_private_key(&local_key)?, | ||
local_key_to_bs58_public_key(&local_key)?, | ||
); | ||
|
||
let value = serde_json::to_string(&value)?; | ||
|
||
Ok(Self::builder() | ||
.name(name.into()) | ||
.category(Some(RecordCategory::Key.to_string())) | ||
.value(Some(value)) | ||
.tags(Some(tags.to_vec().into())) | ||
.build()) | ||
} | ||
} |
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 was deleted.
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
Oops, something went wrong.