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

feat: allow for lazy wallet initialization #331

Conversation

TimoGlastra
Copy link
Contributor

  • remove agent closeAndDeleteWallet as it was only used for tests. They now inject the wallet to close and delete
  • make walletConfig and walletCredentials optional in InitConfig
  • user can now manually initiale the wallet
  • If agent is initialized and wallet is not yet initialized and no walletConfig and walletCredentials are available an error will be thrown

@TimoGlastra TimoGlastra requested a review from a team as a code owner June 24, 2021 16:32
@TimoGlastra TimoGlastra linked an issue Jun 24, 2021 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented Jun 24, 2021

Codecov Report

Merging #331 (c2406ee) into main (ee81d01) will decrease coverage by 0.44%.
The diff coverage is 66.98%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #331      +/-   ##
==========================================
- Coverage   88.21%   87.77%   -0.45%     
==========================================
  Files         220      224       +4     
  Lines        4039     4113      +74     
  Branches      475      489      +14     
==========================================
+ Hits         3563     3610      +47     
- Misses        476      503      +27     
Impacted Files Coverage Δ
src/types.ts 100.00% <ø> (ø)
src/wallet/error/WalletDuplicateError.ts 50.00% <50.00%> (ø)
src/wallet/IndyWallet.ts 74.82% <58.97%> (-12.39%) ⬇️
src/agent/Agent.ts 97.50% <92.30%> (-1.15%) ⬇️
src/wallet/error/WalletError.ts 100.00% <100.00%> (ø)
src/wallet/error/WalletNotFoundError.ts 100.00% <100.00%> (ø)
src/wallet/error/index.ts 100.00% <100.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ee81d01...c2406ee. Read the comment docs.

Copy link
Contributor

@jakubkoci jakubkoci left a comment

Choose a reason for hiding this comment

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

I think it's good to have some "init" kind of method simplifying a lot of stuff for a developer. On the other hand, it would be good to provide some sort of flexibility out of the box (which we don't have to address in this PR of course).

src/wallet/IndyWallet.ts Outdated Show resolved Hide resolved
src/wallet/IndyWallet.ts Outdated Show resolved Hide resolved
src/wallet/IndyWallet.ts Outdated Show resolved Hide resolved
src/wallet/Wallet.test.ts Outdated Show resolved Hide resolved
src/wallet/IndyWallet.ts Outdated Show resolved Hide resolved
src/wallet/IndyWallet.ts Outdated Show resolved Hide resolved
src/wallet/IndyWallet.ts Outdated Show resolved Hide resolved
masterSecretId: string
walletConfig: WalletConfig
walletCredentials: WalletCredentials
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm note sure if this type has right cohesion. It seems these attributes are kind of unrealated, at least from the first point of view 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It contains related to an open wallet. I agree with your point, but would like to solve that in a separate PR.

I think we can make the wallet a bit more straightforward by splitsing the functionality in two parts:

  • A "controller" or something that does the following
    • create
    • open
    • delete
    • close
  • A wallet that does the actual wallet stuff. You need an open wallet to use it.

This will make it easier to handle multiple wallets I think and separates the lifecycle of a wallet from the usage of the wallet

I'd like to do that in a future PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, good idea 👍

@TimoGlastra TimoGlastra force-pushed the feat/lazy-wallet-initialization branch from fdf1d12 to c2406ee Compare July 5, 2021 16:03
@TimoGlastra
Copy link
Contributor Author

@jakubkoci made updates based on your feedback

@TimoGlastra TimoGlastra merged commit 46918a1 into openwallet-foundation:main Jul 7, 2021
@TimoGlastra TimoGlastra deleted the feat/lazy-wallet-initialization branch July 7, 2021 14:00
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.

Need strategy for updating settings after constructing agent class
3 participants