From 85651fbd96229a4a5f309210071fd1614cdaaebd Mon Sep 17 00:00:00 2001 From: John Ky Date: Fri, 31 Mar 2023 22:23:37 +1100 Subject: [PATCH] Remove unused error constructors --- .../src/Cardano/CLI/Shelley/Run/Query.hs | 29 ++----------------- .../Cardano/CLI/Shelley/Run/Transaction.hs | 11 ------- 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs index bb309fbecd9..e1d15db352a 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs @@ -96,7 +96,6 @@ import qualified Ouroboros.Consensus.HardFork.History as Consensus import qualified Ouroboros.Consensus.HardFork.History.Qry as Qry import qualified Ouroboros.Consensus.Protocol.Abstract as Consensus import qualified Ouroboros.Consensus.Protocol.Praos.Common as Consensus -import qualified Ouroboros.Network.Protocol.LocalStateQuery.Type as LocalStateQuery import Control.Monad (forM, forM_, join) import Control.Monad.IO.Class (MonadIO) @@ -124,7 +123,6 @@ data ShelleyQueryCmdError | ShelleyQueryCmdAcquireFailure !AcquiringFailure | ShelleyQueryCmdEraConsensusModeMismatch !AnyConsensusMode !AnyCardanoEra | ShelleyQueryCmdByronEra - | ShelleyQueryCmdPoolIdError (Hash StakePoolKey) | ShelleyQueryCmdEraMismatch !EraMismatch | ShelleyQueryCmdUnsupportedMode !AnyConsensusMode | ShelleyQueryCmdPastHorizon !Qry.PastHorizonException @@ -133,13 +131,8 @@ data ShelleyQueryCmdError | ShelleyQueryCmdLeaderShipError !LeadershipError | ShelleyQueryCmdTextEnvelopeReadError !(FileError TextEnvelopeError) | ShelleyQueryCmdTextReadError !(FileError InputDecodeError) - | ShelleyQueryCmdColdKeyReadFileError !(FileError InputDecodeError) | ShelleyQueryCmdOpCertCounterReadError !(FileError TextEnvelopeError) | ShelleyQueryCmdProtocolStateDecodeFailure !(LBS.ByteString, DecoderError) - | ShelleyQueryCmdSlotToUtcError Text - | ShelleyQueryCmdNodeUnknownStakePool - FilePath - -- ^ Operational certificate of the unknown stake pool. | ShelleyQueryCmdPoolStateDecodeError DecoderError | ShelleyQueryCmdStakeSnapshotDecodeError DecoderError | ShelleyQueryCmdUnsupportedNtcVersion !UnsupportedNtcVersionError @@ -155,7 +148,6 @@ renderShelleyQueryCmdError err = ShelleyQueryCmdHelpersError helpersErr -> renderHelpersError helpersErr ShelleyQueryCmdAcquireFailure acquireFail -> Text.pack $ show acquireFail ShelleyQueryCmdByronEra -> "This query cannot be used for the Byron era" - ShelleyQueryCmdPoolIdError poolId -> "The pool id does not exist: " <> textShow poolId ShelleyQueryCmdEraConsensusModeMismatch (AnyConsensusMode cMode) (AnyCardanoEra era) -> "Consensus mode and era mismatch. Consensus mode: " <> textShow cMode <> " Era: " <> textShow era @@ -168,16 +160,10 @@ renderShelleyQueryCmdError err = ShelleyQueryCmdGenesisReadError err' -> Text.pack $ displayError err' ShelleyQueryCmdLeaderShipError e -> Text.pack $ displayError e ShelleyQueryCmdTextEnvelopeReadError e -> Text.pack $ displayError e - ShelleyQueryCmdSlotToUtcError e -> "Failed to convert slot to UTC time: " <> e ShelleyQueryCmdTextReadError e -> Text.pack $ displayError e - ShelleyQueryCmdColdKeyReadFileError e -> Text.pack $ displayError e ShelleyQueryCmdOpCertCounterReadError e -> Text.pack $ displayError e ShelleyQueryCmdProtocolStateDecodeFailure (_, decErr) -> "Failed to decode the protocol state: " <> toStrict (toLazyText $ build decErr) - ShelleyQueryCmdNodeUnknownStakePool nodeOpCert -> - Text.pack $ "The stake pool associated with: " <> nodeOpCert <> " was not found. Ensure the correct KES key has been " <> - "specified and that the stake pool is registered. If you have submitted a stake pool registration certificate " <> - "in the current epoch, you must wait until the following epoch for the registration to take place." ShelleyQueryCmdPoolStateDecodeError decoderError -> "Failed to decode PoolState. Error: " <> Text.pack (show decoderError) ShelleyQueryCmdStakeSnapshotDecodeError decoderError -> @@ -848,28 +834,17 @@ runQueryStakeAddressInfo (AnyConsensusModeParams cModeParams) -- ------------------------------------------------------------------------------------------------- -- | An error that can occur while querying a node's local state. -data ShelleyQueryCmdLocalStateQueryError - = AcquireFailureError !LocalStateQuery.AcquireFailure - | EraMismatchError !EraMismatch +newtype ShelleyQueryCmdLocalStateQueryError + = EraMismatchError EraMismatch -- ^ A query from a certain era was applied to a ledger from a different -- era. - | ByronProtocolNotSupportedError - -- ^ The query does not support the Byron protocol. - | ShelleyProtocolEraMismatch - -- ^ The Shelley protocol only supports the Shelley era. deriving (Eq, Show) renderLocalStateQueryError :: ShelleyQueryCmdLocalStateQueryError -> Text renderLocalStateQueryError lsqErr = case lsqErr of - AcquireFailureError err -> "Local state query acquire failure: " <> textShow err EraMismatchError err -> "A query from a certain era was applied to a ledger from a different era: " <> textShow err - ByronProtocolNotSupportedError -> - "The attempted local state query does not support the Byron protocol." - ShelleyProtocolEraMismatch -> - "The Shelley protocol mode can only be used with the Shelley era, " - <> "i.e. with --shelley-mode use --shelley-era flag" writeStakeAddressInfo :: Maybe OutputFile diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs index c621b059d16..ac5f3ecf220 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs @@ -68,7 +68,6 @@ data ShelleyTxCmdError | ShelleyTxCmdScriptFileError (FileError ScriptDecodeError) | ShelleyTxCmdReadTextViewFileError !(FileError TextEnvelopeError) | ShelleyTxCmdReadWitnessSigningDataError !ReadWitnessSigningDataError - | ShelleyTxCmdRequiredSignerByronKeyError !SigningKeyFile | ShelleyTxCmdWriteFileError !(FileError ()) | ShelleyTxCmdEraConsensusModeMismatch !(Maybe FilePath) @@ -83,8 +82,6 @@ data ShelleyTxCmdError | ShelleyTxCmdTxBodyError !TxBodyError | ShelleyTxCmdNotImplemented !Text | ShelleyTxCmdWitnessEraMismatch !AnyCardanoEra !AnyCardanoEra !WitnessFile - | ShelleyTxCmdScriptLanguageNotSupportedInEra !AnyScriptLanguage !AnyCardanoEra - | ShelleyTxCmdReferenceScriptsNotSupportedInEra !AnyCardanoEra | ShelleyTxCmdPolicyIdsMissing ![PolicyId] | ShelleyTxCmdPolicyIdsExcess ![PolicyId] | ShelleyTxCmdUnsupportedMode !AnyConsensusMode @@ -133,8 +130,6 @@ renderShelleyTxCmdError err = ShelleyTxCmdScriptFileError fileErr -> Text.pack (displayError fileErr) ShelleyTxCmdReadWitnessSigningDataError witSignDataErr -> renderReadWitnessSigningDataError witSignDataErr - ShelleyTxCmdRequiredSignerByronKeyError (SigningKeyFile fp) -> - "Byron key witness was used as a required signer: " <> textShow fp ShelleyTxCmdWriteFileError fileErr -> Text.pack (displayError fileErr) ShelleyTxCmdSocketEnvError envSockErr -> renderEnvSocketError envSockErr ShelleyTxCmdTxSubmitError res -> "Error while submitting tx: " <> res @@ -167,10 +162,6 @@ renderShelleyTxCmdError err = "The transaction is for the " <> renderEra era <> " era, but the " <> "witness in " <> textShow file <> " is for the " <> renderEra era' <> " era." - ShelleyTxCmdScriptLanguageNotSupportedInEra (AnyScriptLanguage lang) era -> - "The script language " <> textShow lang <> " is not supported in the " <> - renderEra era <> " era." - ShelleyTxCmdEraConsensusModeMismatch fp mode era -> "Submitting " <> renderEra era <> " era transaction (" <> textShow fp <> ") is not supported in the " <> renderMode mode <> " consensus mode." @@ -207,8 +198,6 @@ renderShelleyTxCmdError err = [ "Execution units not available in the protocol parameters. This is " , "likely due to not being in the Alonzo era" ] - ShelleyTxCmdReferenceScriptsNotSupportedInEra (AnyCardanoEra era) -> - "TxCmd: Reference scripts not supported in era: " <> textShow era ShelleyTxCmdTxEraCastErr (EraCastError value fromEra toEra) -> "Unable to cast era from " <> textShow fromEra <> " to " <> textShow toEra <> " the value " <> textShow value ShelleyTxCmdQueryConvenienceError e ->