Skip to content

Commit 9a416fa

Browse files
Add EraT and CardanoNodeT monad transformers to reduce argument passing.
1 parent 2f0f175 commit 9a416fa

File tree

6 files changed

+251
-190
lines changed

6 files changed

+251
-190
lines changed

hydra-chain-observer/src/Hydra/Ouroborus/ChainObserver.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import Hydra.Cardano.Api (
1414
ChainTip,
1515
ConsensusModeParams (..),
1616
EpochSlots (..),
17+
Era,
18+
IsShelleyBasedEra (shelleyBasedEra),
1719
LocalChainSyncClient (..),
1820
LocalNodeClientProtocols (..),
1921
LocalNodeConnectInfo (..),
@@ -26,7 +28,7 @@ import Hydra.Cardano.Api (
2628
getTxId,
2729
pattern Block,
2830
)
29-
import Hydra.Chain.CardanoClient (queryTip)
31+
import Hydra.Chain.CardanoClient (queryTip, runCardanoNode)
3032
import Hydra.ChainObserver.NodeClient (
3133
ChainObservation (..),
3234
ChainObserverLog (..),
@@ -54,7 +56,7 @@ ouroborusClient tracer nodeSocket networkId =
5456
{ follow = \startChainFrom observerHandler -> do
5557
traceWith tracer ConnectingToNode{nodeSocket, networkId}
5658
chainPoint <- case startChainFrom of
57-
Nothing -> queryTip (connectInfo nodeSocket networkId)
59+
Nothing -> runCardanoNode (connectInfo nodeSocket networkId) (shelleyBasedEra @Era) queryTip
5860
Just x -> pure x
5961
traceWith tracer StartObservingFrom{chainPoint}
6062
connectToLocalNode

hydra-cluster/src/Hydra/Generator.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Hydra.Prelude hiding (size)
55
import Test.Hydra.Prelude
66

77
import Cardano.Api.UTxO qualified as UTxO
8-
import CardanoClient (QueryPoint (QueryTip), localNodeConnectInfo, mkGenesisTx, queryUTxOFor)
8+
import CardanoClient (QueryPoint (QueryTip), localNodeConnectInfo, mkGenesisTx, queryUTxOFor, runCardanoNode)
99
import Control.Monad (foldM)
1010
import Data.Aeson (object, withObject, (.:), (.=))
1111
import Hydra.Chain.Backend (buildTransaction)
@@ -177,7 +177,9 @@ generateDemoUTxODataset ::
177177
IO Dataset
178178
generateDemoUTxODataset network nodeSocket faucetSk nClients nTxs = do
179179
-- Query available funds
180-
faucetUTxO <- queryUTxOFor (localNodeConnectInfo network nodeSocket) QueryTip faucetVk
180+
faucetUTxO <-
181+
runCardanoNode (localNodeConnectInfo network nodeSocket) shelleyBasedEra $
182+
queryUTxOFor QueryTip faucetVk
181183
let (Coin fundsAvailable) = UTxO.totalLovelace faucetUTxO
182184
-- Generate client datasets
183185
allPaymentKeys <- generate $ replicateM nClients genSigningKey

0 commit comments

Comments
 (0)