@@ -56,7 +56,7 @@ import Data.Word (Word64)
5656import GHC.Stack (HasCallStack )
5757import qualified GHC.Stack as GHC
5858import qualified Network.HTTP.Simple as HTTP
59- import RIO (Exception (.. ), RIO , throwM )
59+ import RIO (Exception (.. ), MonadThrow , throwM )
6060import qualified System.Directory as System
6161import System.FilePath.Posix (takeDirectory , (</>) )
6262
@@ -74,9 +74,11 @@ import qualified Hedgehog.Extras.Stock.Time as DTC
7474-- | Returns JSON encoded hashes of the era, as well as the hard fork configuration toggle.
7575createConfigJson :: ()
7676 => HasCallStack
77+ => MonadIO m
78+ => MonadThrow m
7779 => TmpAbsolutePath
7880 -> ShelleyBasedEra era -- ^ The era used for generating the hard fork configuration toggle
79- -> RIO env (KeyMap Aeson. Value )
81+ -> m (KeyMap Aeson. Value )
8082createConfigJson (TmpAbsolutePath tempAbsPath) sbe = GHC. withFrozenCallStack $ do
8183 byronGenesisHash <- getByronGenesisHash $ tempAbsPath </> " byron-genesis.json"
8284 shelleyGenesisHash <- getHash ShelleyEra " ShelleyGenesisHash"
@@ -91,7 +93,7 @@ createConfigJson (TmpAbsolutePath tempAbsPath) sbe = GHC.withFrozenCallStack $ d
9193 , Defaults. defaultYamlHardforkViaConfig sbe
9294 ]
9395 where
94- getHash :: CardanoEra a -> Text. Text -> RIO env (KeyMap Value )
96+ getHash :: MonadIO m => CardanoEra a -> Text. Text -> m (KeyMap Value )
9597 getHash e = getShelleyGenesisHash (tempAbsPath </> Defaults. defaultGenesisFilepath e)
9698
9799createConfigJsonNoHash :: ()
@@ -102,8 +104,10 @@ createConfigJsonNoHash = Defaults.defaultYamlHardforkViaConfig
102104-- Generate hashes for genesis.json files
103105
104106getByronGenesisHash
105- :: FilePath
106- -> RIO env (KeyMap Aeson. Value )
107+ :: MonadIO m
108+ => MonadThrow m
109+ => FilePath
110+ -> m (KeyMap Aeson. Value )
107111getByronGenesisHash path = do
108112 e <- runExceptT $ readGenesisData path
109113 case e of
@@ -113,9 +117,10 @@ getByronGenesisHash path = do
113117 pure . singleton " ByronGenesisHash" $ toJSON genesisHash'
114118
115119getShelleyGenesisHash
116- :: FilePath
120+ :: MonadIO m
121+ => FilePath
117122 -> Text
118- -> RIO env (KeyMap Aeson. Value )
123+ -> m (KeyMap Aeson. Value )
119124getShelleyGenesisHash path key = do
120125 content <- liftIO $ BS. readFile path
121126 let genesisHash = Crypto. hashWith id content :: Crypto. Hash Crypto. Blake2b_256 BS. ByteString
@@ -128,10 +133,11 @@ startTimeOffsetSeconds = if OS.isWin32 then 90 else 15
128133
129134-- | A start time and 'ShelleyGenesis' value that are fit to pass to 'cardanoTestnet'
130135getDefaultShelleyGenesis :: ()
136+ => MonadIO m
131137 => AnyShelleyBasedEra
132138 -> Word64 -- ^ The max supply
133139 -> GenesisOptions
134- -> RIO env ShelleyGenesis
140+ -> m ShelleyGenesis
135141getDefaultShelleyGenesis asbe maxSupply opts = do
136142 currentTime <- liftIO DTC. getCurrentTime
137143 let startTime = DTC. addUTCTime startTimeOffsetSeconds currentTime
@@ -140,8 +146,9 @@ getDefaultShelleyGenesis asbe maxSupply opts = do
140146-- | An 'AlonzoGenesis' value that is fit to pass to 'cardanoTestnet'
141147getDefaultAlonzoGenesis :: ()
142148 => HasCallStack
149+ => MonadThrow m
143150 => ShelleyBasedEra era
144- -> RIO e AlonzoGenesis
151+ -> m AlonzoGenesis
145152getDefaultAlonzoGenesis sbe =
146153 case Defaults. defaultAlonzoGenesis sbe of
147154 Right genesis -> return genesis
@@ -161,19 +168,22 @@ numSeededUTxOKeys = 3
161168-- for logging purposes. No reason for the annotations
162169-- to be littered within the functions
163170createSPOGenesisAndFiles
164- :: CardanoTestnetOptions -- ^ The options to use
171+ :: MonadIO m
172+ => HasCallStack
173+ => MonadThrow m
174+ => CardanoTestnetOptions -- ^ The options to use
165175 -> GenesisOptions
166176 -> TestnetOnChainParams
167177 -> TmpAbsolutePath
168- -> RIO env FilePath -- ^ Shelley genesis directory
178+ -> m FilePath -- ^ Shelley genesis directory
169179createSPOGenesisAndFiles
170180 testnetOptions genesisOptions@ GenesisOptions {genesisTestnetMagic}
171181 onChainParams
172182 (TmpAbsolutePath tempAbsPath) = GHC. withFrozenCallStack $ do
173183 AnyShelleyBasedEra sbe <- pure cardanoNodeEra
174184
175185 let genesisShelleyDirAbs = takeDirectory inputGenesisShelleyFp
176- -- error "here 1"
186+
177187 genesisShelleyDir <- liftIO $ System. createDirectoryIfMissing True genesisShelleyDirAbs >> pure genesisShelleyDirAbs
178188 let -- At least there should be a delegator per DRep
179189 -- otherwise some won't be representing anybody
@@ -310,9 +320,11 @@ instance Exception BlockfrostParamsError where
310320-- into a unified, consistent set of Genesis files
311321resolveOnChainParams :: ()
312322 => HasCallStack
323+ => MonadIO m
324+ => MonadThrow m
313325 => TestnetOnChainParams
314326 -> (AlonzoGenesis , ConwayGenesis , ShelleyGenesis )
315- -> RIO env (AlonzoGenesis , ConwayGenesis , ShelleyGenesis )
327+ -> m (AlonzoGenesis , ConwayGenesis , ShelleyGenesis )
316328resolveOnChainParams onChainParams geneses = case onChainParams of
317329
318330 DefaultParams -> pure geneses
0 commit comments