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

[ADP-3344] Implement REST-like IO interface for Deposit Wallet #4769

Merged
merged 4 commits into from
Sep 10, 2024

Conversation

HeinrichApfelmus
Copy link
Contributor

This pull requests implements a REST-like IO interface for the Deposit Wallet. This interface corresponds more closely to an HTTP interface.

Essentially, the main difference between Cardano.Wallet.Deposit.IO and Cardano.Wallet.Deposit.REST is that the latter postpones the need to initialize the wallet. Instead of working with a WalletInstance, the latter module now works with a WalletResource, which is roughly a TVar (Maybe WalletInstance). This mutable variable starts with Nothing and the function putWallet can be used to initialize the wallet, putting a Just in the mutable variable.

In turn, a module Cardano.Wallet.Deposit.IO.Resource implements a data type Resource that encapsulate the idea of TVar (Maybe WalletInstance) and is (reasonably) safe to use in a concurrent environment.

Comments

  • Not implemented yet: withWalletResource inspects the database directory and loads a wallet if necessary.

Issue Number

ADP-3344

@HeinrichApfelmus HeinrichApfelmus self-assigned this Sep 4, 2024
@paolino paolino force-pushed the HeinrichApfelmus/ADP-3344/interface-rest branch 3 times, most recently from ae3a5b0 to cbc4689 Compare September 5, 2024 14:34
@paolino paolino added the Deposit label Sep 5, 2024
@paolino paolino force-pushed the HeinrichApfelmus/ADP-3344/interface-rest branch 8 times, most recently from 2825954 to 33aec0f Compare September 9, 2024 08:14
@paolino paolino marked this pull request as ready for review September 9, 2024 08:51
Copy link
Contributor

@paweljakubas paweljakubas left a comment

Choose a reason for hiding this comment

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

Nice work!

@paolino paolino added this pull request to the merge queue Sep 9, 2024
github-merge-queue bot pushed a commit that referenced this pull request Sep 9, 2024
This pull requests implements a REST-like `IO` interface for the Deposit
Wallet. This interface corresponds more closely to an HTTP interface.

Essentially, the main difference between `Cardano.Wallet.Deposit.IO` and
`Cardano.Wallet.Deposit.REST` is that the latter postpones the need to
initialize the wallet. Instead of working with a `WalletInstance`, the
latter module now works with a `WalletResource`, which is roughly a
`TVar (Maybe WalletInstance)`. This mutable variable starts with
`Nothing` and the function `putWallet` can be used to initialize the
wallet, putting a `Just` in the mutable variable.

In turn, a module `Cardano.Wallet.Deposit.IO.Resource` implements a data
type `Resource` that encapsulate the idea of `TVar (Maybe
WalletInstance)` and is (reasonably) safe to use in a concurrent
environment.

### Comments

* Not implemented yet: `withWalletResource` inspects the database
directory and loads a wallet if necessary.

### Issue Number

ADP-3344
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 9, 2024
@paolino paolino added this pull request to the merge queue Sep 9, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 9, 2024
@paolino paolino force-pushed the HeinrichApfelmus/ADP-3344/interface-rest branch 2 times, most recently from 0b30e73 to 5f29dce Compare September 10, 2024 09:36
@paolino paolino force-pushed the HeinrichApfelmus/ADP-3344/interface-rest branch from 5f29dce to a3874e9 Compare September 10, 2024 09:57
@paolino paolino force-pushed the HeinrichApfelmus/ADP-3344/interface-rest branch from a3874e9 to 19cecf8 Compare September 10, 2024 10:22
@paolino paolino added this pull request to the merge queue Sep 10, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 10, 2024
@HeinrichApfelmus
Copy link
Contributor Author

Looks good to me as well, thank you! 👍

The error type e is probably not worth tracking in the type system, hence my preference for putting this stuff under the rug in SomeException. However, distinguishing between Vanished and FailedToInitialize is indeed useful information for a user who tries to start the wallet. In any case, having an e parameter is alright.

@paolino paolino force-pushed the HeinrichApfelmus/ADP-3344/interface-rest branch from 19cecf8 to 053d8b1 Compare September 10, 2024 13:11
@paolino paolino added this pull request to the merge queue Sep 10, 2024
Merged via the queue into master with commit 5847239 Sep 10, 2024
25 checks passed
@paolino paolino deleted the HeinrichApfelmus/ADP-3344/interface-rest branch September 10, 2024 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants