From 175fa47720056601d5a2bd398b46a0ad047afcd1 Mon Sep 17 00:00:00 2001 From: Mateusz Galazyn Date: Tue, 2 Jul 2024 16:49:55 +0200 Subject: [PATCH] inital attempt --- .../src/Cardano/CLI/EraBased/Run/CreateTestnetData.hs | 3 ++- cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs | 2 +- .../src/Cardano/CLI/EraBased/Run/Governance/DRep.hs | 7 ++----- cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs | 7 ++++--- .../src/Cardano/CLI/Types/Errors/GovernanceCmdError.hs | 3 --- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/CreateTestnetData.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/CreateTestnetData.hs index 069a9fcd35..2453ead3de 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/CreateTestnetData.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/CreateTestnetData.hs @@ -195,7 +195,7 @@ runGenesisCreateTestNetDataCmd Cmd.GenesisCreateTestNetDataCmdArgs , numUtxoKeys , totalSupply , delegatedSupply - , relays + , relays , systemStart , outputDir } = do @@ -692,6 +692,7 @@ readAndDecodeGenesisFile fpath = runExceptT $ do lbs <- handleIOExceptT (GenesisCmdGenesisFileReadError . FileIOError fpath) $ LBS.readFile fpath firstExceptT (GenesisCmdGenesisFileDecodeError fpath . Text.pack) . hoistEither $ Aeson.eitherDecode' lbs + -- FIXME!!! -- @readRelays fp@ reads the relays specification from a file readRelays :: () diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs index b367cd00cc..c9ad55220e 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs @@ -401,7 +401,7 @@ runGenesisCreateCardanoCmd overrideShelleyGenesis t = t { sgNetworkMagic = unNetworkMagic (toNetworkMagic network) , sgNetworkId = toShelleyNetwork network - , sgActiveSlotsCoeff = fromMaybe (error $ "Could not convert from Rational: " ++ show slotCoeff) $ L.boundRational slotCoeff + , sgActiveSlotsCoeff = unsafeBoundedRational slotCoeff , sgSecurityParam = unBlockCount security , sgUpdateQuorum = fromIntegral $ ((numGenesisKeys `div` 3) * 2) + 1 , sgEpochLength = EpochSize $ floor $ (fromIntegral (unBlockCount security) * 10) / slotCoeff diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs index 743d1c8561..dd61fa9a9a 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs @@ -163,11 +163,8 @@ runGovernanceDRepMetadataHashCmd { metadataFile , mOutFile } = do - metadataBytes <- firstExceptT ReadFileError $ newExceptT (readByteStringFile metadataFile) - (_metadata, metadataHash) <- - firstExceptT GovernanceCmdDRepMetadataValidationError - . hoistEither - $ validateAndHashDRepMetadata metadataBytes + metadataBytes <- firstExceptT ReadFileError . newExceptT $ readByteStringFile metadataFile + let (_metadata, metadataHash) = hashDRepMetadata metadataBytes firstExceptT WriteFileError . newExceptT . writeByteStringOutput mOutFile diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs index cbc384bdc0..28c7dfa30f 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs @@ -173,8 +173,8 @@ runQueryProtocolParametersCmd AnyCardanoEra era <- firstExceptT QueryCmdAcquireFailure $ determineEra localNodeConnInfo sbe <- forEraInEon @ShelleyBasedEra era (left QueryCmdByronEra) pure let qInMode = QueryInEra $ QueryInShelleyBasedEra sbe Api.QueryProtocolParameters - pp <- firstExceptT QueryCmdConvenienceError - $ executeQueryAnyMode localNodeConnInfo qInMode + pp <- executeQueryAnyMode localNodeConnInfo qInMode + & modifyError QueryCmdConvenienceError writeProtocolParameters sbe mOutFile pp where writeProtocolParameters @@ -654,7 +654,8 @@ runQueryTxMempoolCmd localQuery <- case query of TxMempoolQueryTxExists tx -> do - AnyCardanoEra era <- modifyError QueryCmdAcquireFailure (determineEra localNodeConnInfo) + AnyCardanoEra era <- determineEra localNodeConnInfo + & modifyError QueryCmdAcquireFailure pure $ LocalTxMonitoringQueryTx $ TxIdInMode era tx TxMempoolQueryNextTx -> pure LocalTxMonitoringSendNextTx TxMempoolQueryInfo -> pure LocalTxMonitoringMempoolInformation diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceCmdError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceCmdError.hs index 6fa63a24ce..f12e984b4a 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceCmdError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceCmdError.hs @@ -50,7 +50,6 @@ data GovernanceCmdError | GovernanceCmdDecoderError !DecoderError | GovernanceCmdVerifyPollError !GovernancePollError | GovernanceCmdWriteFileError !(FileError ()) - | GovernanceCmdDRepMetadataValidationError !DRepMetadataValidationError -- Legacy - remove me after cardano-cli transitions to new era based structure | GovernanceCmdMIRCertNotSupportedInConway | GovernanceCmdGenesisDelegationNotSupportedInConway @@ -108,8 +107,6 @@ instance Error GovernanceCmdError where pretty $ renderGovernancePollError pollError GovernanceCmdWriteFileError fileError -> "Cannot write file: " <> prettyError fileError - GovernanceCmdDRepMetadataValidationError e -> - "DRep metadata validation error: " <> prettyError e GovernanceCmdMIRCertNotSupportedInConway -> "MIR certificates are not supported in Conway era onwards." GovernanceCmdGenesisDelegationNotSupportedInConway ->