Skip to content
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: use BaseWallet instead of a specific wallet type #1122

Merged
merged 1 commit into from
Mar 11, 2024
Merged

Conversation

xprazak2
Copy link
Contributor

@xprazak2 xprazak2 commented Feb 6, 2024

Replaces the direct usage of IndySdkWallet with BaseWallet trait.

@codecov-commenter
Copy link

codecov-commenter commented Feb 6, 2024

Codecov Report

Attention: Patch coverage is 0% with 327 lines in your changes are missing coverage. Please review.

Project coverage is 0.05%. Comparing base (274f776) to head (3b94256).
Report is 3 commits behind head on main.

Files Patch % Lines
...ies_vcx_core/src/wallet/indy/indy_wallet_config.rs 0.00% 98 Missing ⚠️
...ies/misc/wallet_migrator/src/vdrtools2credx/mod.rs 0.00% 38 Missing ⚠️
aries/aries_vcx_core/src/wallet/indy/mod.rs 0.00% 28 Missing ⚠️
...ies_vcx_core/src/wallet/indy/indy_import_config.rs 0.00% 27 Missing ⚠️
aries/misc/test_utils/src/mock_wallet.rs 0.00% 18 Missing ⚠️
...es/aries_vcx_core/src/wallet/base_wallet/record.rs 0.00% 17 Missing ⚠️
...ies_vcx_core/src/wallet/indy/indy_wallet_record.rs 0.00% 15 Missing ⚠️
.../aries_vcx_core/src/wallet/agency_client_wallet.rs 0.00% 12 Missing ⚠️
...s/aries_vcx_core/src/wallet/indy/partial_record.rs 0.00% 11 Missing ⚠️
...aries_vcx_core/src/wallet/indy/all_indy_records.rs 0.00% 10 Missing ⚠️
... and 13 more
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #1122      +/-   ##
========================================
- Coverage   0.05%   0.05%   -0.01%     
========================================
  Files        499     506       +7     
  Lines      25018   25477     +459     
  Branches    4520    4635     +115     
========================================
  Hits          13      13              
- Misses     25005   25464     +459     
Flag Coverage Δ
unittests-aries-vcx 0.05% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

aries/aries_vcx_core/src/wallet/base_wallet/did_wallet.rs Outdated Show resolved Hide resolved

async fn unpack_message(&self, msg: &[u8]) -> VcxCoreResult<UnpackMessageOutput>;
async fn all(&self) -> VcxCoreResult<Box<dyn AllRecords + Send>>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why custom trait instead of simply implementing an iterator? Why on BaseWallet instead of RecordWallet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I need a custom abstraction for how different wallet implementations fetch all records. vdrtools wallet provides WalletIterator which does not conform to std::iter::Iterator nor to std::async_iter::AsyncIterator.

Moved to RecordWallet.

Copy link
Contributor

@mirgee mirgee Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked why it's implemented on BaseWallet instead of RecordWallet, I am not arguing for moving it (or not).

Also, I still don't understand why a new, wallet specific, trait was created instead of just implementing an iterator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RecordWallet operates only on records, so it was implemented in BaseWallet because it fetches both records and keys. Even though keys are "key records" since everything is stored in the same table. Indy wallet fetches everything with a single method while askar has separate methods for keys and records.

Instead of just implementing an iterator, a wallet specific trait was created because
getting all records for indy gives me WalletIterator which is async and I do not see a way how to implement a sync trait using async function.

I could implement async iterator but that requires bringing in additional dependency.

aries/aries_vcx_core/src/wallet/base_wallet/record.rs Outdated Show resolved Hide resolved
aries/aries_vcx_core/src/wallet/indy/mod.rs Show resolved Hide resolved
aries/aries_vcx_core/src/wallet/indy/mod.rs Outdated Show resolved Hide resolved
aries/aries_vcx_core/src/wallet/indy/wallet_credentials.rs Outdated Show resolved Hide resolved
aries/aries_vcx_core/src/wallet/indy/wallet_config.rs Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IndyTags don't need to be pub(crate)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xprazak2 if this is still true, let's mininize the visibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I make them private, how can they be used in indy_record_wallet.rs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, but I think what I meant when posting this comment 3 weeks ago was just that the (crate) modifier was unnecessary as the module is private anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

@xprazak2
Copy link
Contributor Author

Things that will need to be addressed in the future:

  • close/delete wallet
  • import/export wallet

Copy link
Contributor

@Patrik-Stas Patrik-Stas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a review, I am mostly concerned about usage of trait objects

aries/agents/rust/mediator/src/aries_agent/mod.rs Outdated Show resolved Hide resolved
aries/aries_vcx_core/src/wallet/base_wallet/mod.rs Outdated Show resolved Hide resolved
aries/aries_vcx_core/src/wallet/base_wallet/did_wallet.rs Outdated Show resolved Hide resolved
aries/aries_vcx_core/src/wallet/indy/wallet_config.rs Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xprazak2 if this is still true, let's mininize the visibility.

aries/aries_vcx_core/src/wallet/indy/mod.rs Show resolved Hide resolved


Signed-off-by: Ondrej Prazak <ondrej.prazak@absa.africa>
@xprazak2
Copy link
Contributor Author

xprazak2 commented Mar 6, 2024

The dynamic dispatch is no longer used.

Copy link
Contributor

@Patrik-Stas Patrik-Stas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✅ Great job @xprazak2 this is good improvement

@Patrik-Stas Patrik-Stas merged commit 5a72612 into main Mar 11, 2024
39 checks passed
@Patrik-Stas Patrik-Stas deleted the gaw branch March 11, 2024 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants