-
Notifications
You must be signed in to change notification settings - Fork 217
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
Integrate Jörmungandr backend with CLI. #483
Conversation
exe/wallet/Main.hs
Outdated
let jormungandr = Jormungandr.mkJormungandrLayer mgr url | ||
let nl = Jormungandr.mkNetworkLayer jormungandr | ||
waitForConnection nl defaultRetryPolicy | ||
block0 <- unsafeRunExceptT $ getBlock jormungandr (coerce block0H) |
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.
FYI, we can retrieve block0H
ourselves
{-# LANGUAGE OverloadedStrings #-}
import Cardano.Wallet.Jormungandr.Network
import Cardano.Wallet.Primitive.Types
import Cardano.Wallet.Unsafe
import Data.Coerce
( coerce )
main :: IO ()
main = do
mgr <- newManager defaultManagerSettings
let j = mkJormungandrLayer mgr (BaseUrl Http "localhost" 8081 "/api")
let absentParent = Hash "\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL"
[block0H] <- unsafeRunExceptT $ getDescendantIds j absentParent 1
block0 <- unsafeRunExceptT $ getBlock j (coerce block0H)
print block0
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.
Yes and no. We do want the user to provide it such that we can verify they match!
e8f7b4c
to
6f5b1d9
Compare
6f5b1d9
to
fda06ae
Compare
490cd3c
to
388a257
Compare
bb38651
to
929c639
Compare
…ent backends. 1. cardano-wallet-http-bridge 2. cardano-wallet-jormungandr
ed017f7
to
96e491d
Compare
<> cliOptionsGeneric | ||
cliExamples = unlines $ filter (not . null) $ lines $ mempty | ||
<> cliExamplesSpecific | ||
<> cliExamplesGeneric |
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.
🤔 I think we're loosing the benefits of using docopt
in a first place. I understand the need for removing duplication between both files yet I am not sure we are taking it to the right direction :/ .. It's probably the right time to switch to optparse-applicative
for the CLI.
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.
I think we're loosing the benefits of using docopt in a first place. I understand the need for removing duplication between both files yet I am not sure we are taking it to the right direction :/ .. It's probably the right time to switch to optparse-applicative for the CLI.
I completely agree. Looking forward to trying a different direction with optparse-applicative
here.
The rationale here is to make it a bit easier to read by outlining the different steps in the initialization process and the creation of each layer.
e9c983b
to
44ed2a7
Compare
Issue Number
#357
Overview
This PR forks our wallet CLI into two separate executables:
cardano-wallet
built with the
cardano-wallet-http-bridge
backendcardano-wallet-jormungandr
built with the
cardano-wallet-jormungandr
backendParts common to both executables are located within the
cardano-wallet-cli
library.Usage Examples
Launching with HTTP bridge backend
stack exec cardano-wallet -- launch
Launching with Jörmungandr backend
stack exec cardano-wallet-jormungandr -- launch \ --backend-port=8081 \ --genesis-hash=dba597bee5f0987efbf56f6bd7f44c38158a7770d0cb28a26b5eca40613a7ebd \ --genesis-block=lib/jormungandr/test/data/jormungandr/block0.bin \ --node-config=lib/jormungandr/test/data/jormungandr/config.yaml \ --node-secret=lib/jormungandr/test/data/jormungandr/secret.yaml
Work not tackled by this PR
There is a small amount of code duplication between both executables (the
execServe
functions inexe/wallet/http-bridge/Main.hs
andexe/wallet/jormungandr/Main.hs
are very similar). Ideally, we should reduce this duplication (probably suitable for a future PR).