Skip to content

Commit

Permalink
Use real new newBootEnv in Cardano.Wallet.Application
Browse files Browse the repository at this point in the history
  • Loading branch information
Anviking committed Nov 25, 2024
1 parent 6b6f048 commit 6988f8a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
module Cardano.Wallet.Deposit.REST.Start
( loadDepositWalletFromDisk
, newFakeBootEnv
, newBootEnv
, mockFundTheWallet
)
where
Expand All @@ -16,6 +17,12 @@ import Cardano.Wallet.Deposit.IO
import Cardano.Wallet.Deposit.IO.Network.Mock
( newNetworkEnvMock
)
import Cardano.Wallet.Deposit.IO.Network.NodeToClient
( CardanoBlock
, NetworkLayer
, StandardCrypto
, fromNetworkLayer
)
import Cardano.Wallet.Deposit.IO.Network.Type
( NetworkEnv
, mapBlock
Expand Down Expand Up @@ -130,3 +137,23 @@ newFakeBootEnv genesisFile = do
genesisData'
. mapBlock Read.EraValue
<$> newNetworkEnvMock

newBootEnv
:: Maybe FilePath
-> NetworkLayer IO (CardanoBlock StandardCrypto)
-> IO (WalletBootEnv IO)
newBootEnv genesisFile nl = do
eGenesisData <- runExceptT $ case genesisFile of
Nothing -> ExceptT $ pure $ Right Read.mockGenesisDataMainnet
Just file -> fst <$> Byron.readGenesisData file
print genesisFile
print eGenesisData
print $ Read.getNetworkId <$> eGenesisData
case eGenesisData of
Left e -> error $ show e
Right genesisData' ->
return $ WalletBootEnv
(show >$< stdoutTracer)
genesisData'
(fromNetworkLayer nl)

20 changes: 10 additions & 10 deletions lib/exe/lib/Cardano/Wallet/Application.hs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ import Cardano.Wallet.Deposit.REST
)
import Cardano.Wallet.Deposit.REST.Start
( loadDepositWalletFromDisk
, newFakeBootEnv
, newBootEnv
)
import Cardano.Wallet.Flavor
( CredFromOf
Expand Down Expand Up @@ -383,7 +383,7 @@ serveWallet
eDepositUiSocket <- bindDepositUiSocket
eDepositSocket <- bindDepositSocket
eShelleySocket <- bindApiSocket
fakeBootEnv <- lift $ newFakeBootEnv depositByronGenesisFile
bootEnv <- lift $ newBootEnv depositByronGenesisFile netLayer
callCC $ \exit -> do
case eShelleyUiSocket of
Left err -> do
Expand Down Expand Up @@ -431,7 +431,7 @@ serveWallet
>$< applicationTracer
)
databaseDir'
fakeBootEnv
bootEnv
resource
ui <- Ui.withUILayer 1 resource
REST.onResourceChange
Expand All @@ -444,7 +444,7 @@ serveWallet
let uiService =
startDepositUiServer
ui
fakeBootEnv
bootEnv
databaseDir'
socket
sNetwork
Expand Down Expand Up @@ -475,15 +475,15 @@ serveWallet
>$< applicationTracer
)
databaseDir'
fakeBootEnv
bootEnv
resource
pure (databaseDir', resource)
Just (databaseDir', w) ->
pure (databaseDir', w)
let depositService =
startDepositServer
resource
fakeBootEnv
bootEnv
databaseDir'
socket
ContT $ \k ->
Expand Down Expand Up @@ -624,7 +624,7 @@ serveWallet
-> IO ()
startDepositServer
resource
fakeBootEnv
bootEnv
databaseDir'
socket =
do
Expand All @@ -635,7 +635,7 @@ serveWallet
$ Deposit.server
(DepositApplicationLog >$< applicationTracer)
databaseDir'
fakeBootEnv
bootEnv
resource
start
serverSettings
Expand All @@ -657,7 +657,7 @@ serveWallet
-> IO ()
startDepositUiServer
ui
fakeBootEnv
bootEnv
databaseDir'
socket
_proxy
Expand All @@ -670,7 +670,7 @@ serveWallet
$ DepositUi.serveUI
(DepositUIApplicationLog >$< applicationTracer)
ui
fakeBootEnv
bootEnv
databaseDir'
(PageConfig "" "Deposit Cardano Wallet")
_proxy
Expand Down

0 comments on commit 6988f8a

Please sign in to comment.