-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor basewallet and corresponding consumers #843
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
use std::collections::HashMap; | ||
use std::thread; | ||
|
||
use async_trait::async_trait; | ||
|
@@ -52,13 +53,15 @@ impl BaseWallet for IndySdkWallet { | |
xtype: &str, | ||
id: &str, | ||
value: &str, | ||
tags_json: Option<&str>, | ||
tags: Option<HashMap<String, String>>, | ||
) -> VcxCoreResult<()> { | ||
let res = tags.map(|x| serde_json::to_string(&x)).transpose()?.to_owned(); | ||
let tags_json = res.as_deref(); | ||
indy::wallet::add_wallet_record(self.wallet_handle, xtype, id, value, tags_json).await | ||
} | ||
|
||
async fn get_wallet_record(&self, xtype: &str, id: &str, options_json: &str) -> VcxCoreResult<String> { | ||
indy::wallet::get_wallet_record(self.wallet_handle, xtype, id, options_json).await | ||
async fn get_wallet_record(&self, xtype: &str, id: &str, options: &str) -> VcxCoreResult<String> { | ||
indy::wallet::get_wallet_record(self.wallet_handle, xtype, id, options).await | ||
} | ||
|
||
async fn delete_wallet_record(&self, xtype: &str, id: &str) -> VcxCoreResult<()> { | ||
|
@@ -69,12 +72,19 @@ impl BaseWallet for IndySdkWallet { | |
indy::wallet::update_wallet_record_value(self.wallet_handle, xtype, id, value).await | ||
} | ||
|
||
async fn update_wallet_record_tags(&self, xtype: &str, id: &str, tags_json: &str) -> VcxCoreResult<()> { | ||
indy::wallet::update_wallet_record_tags(self.wallet_handle, xtype, id, tags_json).await | ||
async fn update_wallet_record_tags( | ||
&self, | ||
xtype: &str, | ||
id: &str, | ||
tags: HashMap<String, String>, | ||
) -> VcxCoreResult<()> { | ||
let tags_json = serde_json::to_string(&tags)?; | ||
indy::wallet::update_wallet_record_tags(self.wallet_handle, xtype, id, &tags_json).await | ||
} | ||
|
||
async fn add_wallet_record_tags(&self, xtype: &str, id: &str, tags_json: &str) -> VcxCoreResult<()> { | ||
indy::wallet::add_wallet_record_tags(self.wallet_handle, xtype, id, tags_json).await | ||
async fn add_wallet_record_tags(&self, xtype: &str, id: &str, tags: HashMap<String, String>) -> VcxCoreResult<()> { | ||
let tags_json = serde_json::to_string(&tags)?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We serialize hashamp to string, just to deserialize it inside subsequent There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are taking the typed parameters and then converting them back to JSON before passing them to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are you intending to say that we should only have hashmap as the parameter type and not &str? |
||
indy::wallet::add_wallet_record_tags(self.wallet_handle, xtype, id, &tags_json).await | ||
} | ||
|
||
async fn delete_wallet_record_tags(&self, xtype: &str, id: &str, tag_names: &str) -> VcxCoreResult<()> { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
options
could actually be well typed, but its type depends on what kind of options the underlying implementation accepts.This is slightly more advanced, but we could use associated types here. You would defined something like
Then in particular implementation of the trait, for example in
impl IndySdkWallet
, you would inject the actual types. And of course, you would have to create those types (you can find out what the option objects should look like if you dig intolibvdrtools
code)So not a hard requirement, but if you could do this it would be really great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright!