From 1fbbee9c086285284e1f8949a1b0f6f60fbc2a25 Mon Sep 17 00:00:00 2001 From: John Ky Date: Fri, 17 Nov 2023 21:21:03 +1100 Subject: [PATCH] Upgrade to cardano-api-8.32.0.0 --- cabal.project | 7 +++- cardano-cli/app/cardano-cli.hs | 2 +- .../src/Cardano/CLI/Byron/Delegation.hs | 1 - cardano-cli/src/Cardano/CLI/Byron/Genesis.hs | 1 - cardano-cli/src/Cardano/CLI/Byron/Key.hs | 2 -- cardano-cli/src/Cardano/CLI/Byron/Tx.hs | 1 - .../src/Cardano/CLI/Byron/UpdateProposal.hs | 1 - cardano-cli/src/Cardano/CLI/Byron/Vote.hs | 2 -- .../src/Cardano/CLI/EraBased/Run/Query.hs | 6 ++-- cardano-cli/src/Cardano/CLI/Helpers.hs | 1 - cardano-cli/src/Cardano/CLI/Pretty.hs | 22 ++++-------- cardano-cli/src/Cardano/CLI/Read.hs | 34 +++++++++---------- cardano-cli/src/Cardano/CLI/Run/Ping.hs | 1 - .../CLI/Types/Errors/AddressCmdError.hs | 6 ++-- .../CLI/Types/Errors/DelegationError.hs | 7 ++-- .../CLI/Types/Errors/GenesisCmdError.hs | 8 ++--- .../Types/Errors/GovernanceActionsError.hs | 6 ++-- .../CLI/Types/Errors/GovernanceCmdError.hs | 14 ++++---- .../Types/Errors/GovernanceCommitteeError.hs | 9 +++-- .../CLI/Types/Errors/GovernanceQueryError.hs | 4 +-- .../Types/Errors/GovernanceVoteCmdError.hs | 4 +-- .../CLI/Types/Errors/ItnKeyConversionError.hs | 1 - .../Cardano/CLI/Types/Errors/KeyCmdError.hs | 9 +++-- .../Cardano/CLI/Types/Errors/NodeCmdError.hs | 8 ++--- .../CLI/Types/Errors/ProtocolParamsError.hs | 3 +- .../Cardano/CLI/Types/Errors/QueryCmdError.hs | 15 ++++---- .../Errors/QueryCmdLocalStateQueryError.hs | 2 -- .../CLI/Types/Errors/RegistrationError.hs | 6 ++-- .../CLI/Types/Errors/StakeAddressCmdError.hs | 8 ++--- .../CLI/Types/Errors/StakeCredentialError.hs | 7 ++-- .../CLI/Types/Errors/StakePoolCmdError.hs | 7 ++-- .../CLI/Types/Errors/TextViewFileError.hs | 2 +- .../Cardano/CLI/Types/Errors/TxCmdError.hs | 11 +++--- cardano-cli/src/Cardano/CLI/Types/Key.hs | 4 +-- .../Golden/EraBased/Governance/VerifyPoll.hs | 2 +- .../Test/Cardano/CLI/Util.hs | 4 +-- 36 files changed, 99 insertions(+), 129 deletions(-) diff --git a/cabal.project b/cabal.project index 3e5b12ba2c..5005577255 100644 --- a/cabal.project +++ b/cabal.project @@ -18,7 +18,6 @@ index-state: packages: cardano-cli - ../cardano-api/cardano-api package cardano-cli ghc-options: -Werror @@ -44,3 +43,9 @@ write-ghc-environment-files: always -- IMPORTANT -- Do NOT add more source-repository-package stanzas here unless they are strictly -- temporary! Please read the section in CONTRIBUTING about updating dependencies. + +source-repository-package + type: git + location: https://github.com/input-output-hk/cardano-api + tag: b406ef1e24a3da86b53a2f51384d47672ff7ab18 + subdir: cardano-api diff --git a/cardano-cli/app/cardano-cli.hs b/cardano-cli/app/cardano-cli.hs index 3e42e4cfc1..b43ed34cce 100644 --- a/cardano-cli/app/cardano-cli.hs +++ b/cardano-cli/app/cardano-cli.hs @@ -33,4 +33,4 @@ main = toplevelExceptionHandler $ do #endif co <- Opt.customExecParser pref (opts envCli) - orDie (prettyToStrictText . renderClientCommandError) $ runClientCommand co + orDie (prettyToText . renderClientCommandError) $ runClientCommand co diff --git a/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs b/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs index 6e9f7c23df..44577e42ae 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs @@ -36,7 +36,6 @@ import Data.ByteString (ByteString) import qualified Data.ByteString.Lazy as LB import Data.Text (Text) import Formatting (Format, sformat) -import Prettyprinter data ByronDelegationError = CertificateValidationErrors !FilePath ![Text] diff --git a/cardano-cli/src/Cardano/CLI/Byron/Genesis.hs b/cardano-cli/src/Cardano/CLI/Byron/Genesis.hs index ff0e79345a..8ef60131b6 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Genesis.hs @@ -44,7 +44,6 @@ import Data.Text.Lazy (toStrict) import Data.Text.Lazy.Builder (toLazyText) import Data.Time (UTCTime) import Formatting.Buildable -import Prettyprinter import System.Directory (createDirectory, doesPathExist) data ByronGenesisError diff --git a/cardano-cli/src/Cardano/CLI/Byron/Key.hs b/cardano-cli/src/Cardano/CLI/Byron/Key.hs index c2884d2e6a..6bf0df5b7b 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Key.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Key.hs @@ -33,8 +33,6 @@ import Data.String (IsString, fromString) import Data.Text (Text) import qualified Data.Text as T import Formatting (build, sformat, (%)) -import Prettyprinter - data ByronKeyFailure = ReadSigningKeyFailure !FilePath !Text diff --git a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs index cc3f50c3c1..9ca0d274b2 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs @@ -58,7 +58,6 @@ import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.IO as Text import Formatting (sformat, (%)) -import Prettyprinter data ByronTxError = TxDeserialisationFailed !FilePath !Binary.DecoderError diff --git a/cardano-cli/src/Cardano/CLI/Byron/UpdateProposal.hs b/cardano-cli/src/Cardano/CLI/Byron/UpdateProposal.hs index 565d7c2032..c96450721e 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/UpdateProposal.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/UpdateProposal.hs @@ -33,7 +33,6 @@ import Data.Bifunctor (Bifunctor (..)) import qualified Data.ByteString as BS import Data.Text (Text) import qualified Data.Text as Text -import Prettyprinter data ByronUpdateProposalError = ByronReadUpdateProposalFileFailure !FilePath !Text diff --git a/cardano-cli/src/Cardano/CLI/Byron/Vote.hs b/cardano-cli/src/Cardano/CLI/Byron/Vote.hs index 670c534084..17d56e1683 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Vote.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Vote.hs @@ -31,8 +31,6 @@ import Control.Tracer (stdoutTracer, traceWith) import Data.Bifunctor (first) import qualified Data.ByteString as BS import Data.Text (Text) -import Prettyprinter - data ByronVoteError = ByronVoteDecodingError !FilePath diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs index 710a948158..8be97115a0 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs @@ -261,7 +261,7 @@ runQueryTipCmd } mLocalState <- hushM (first QueryCmdAcquireFailure eLocalState) $ \e -> - liftIO . LT.hPutStrLn IO.stderr $ prettyToText $ "Warning: Local state unavailable: " <> renderQueryCmdError e + liftIO . LT.hPutStrLn IO.stderr $ prettyToLazyText $ "Warning: Local state unavailable: " <> renderQueryCmdError e chainTip <- pure (mLocalState >>= O.mChainTip) -- The chain tip is unavailable via local state query because we are connecting with an older @@ -277,7 +277,7 @@ runQueryTipCmd localStateOutput <- forM mLocalState $ \localState -> do case slotToEpoch tipSlotNo (O.eraHistory localState) of Left e -> do - liftIO . LT.hPutStrLn IO.stderr $ prettyToText $ + liftIO . LT.hPutStrLn IO.stderr $ prettyToLazyText $ "Warning: Epoch unavailable: " <> renderQueryCmdError (QueryCmdPastHorizon e) return $ O.QueryTipLocalStateOutput { O.localStateChainTip = chainTip @@ -299,7 +299,7 @@ runQueryTipCmd return $ flip (percentage tolerance) nowSeconds tipTimeResult mSyncProgress <- hushM syncProgressResult $ \e -> do - liftIO . LT.hPutStrLn IO.stderr $ prettyToText $ "Warning: Sync progress unavailable: " <> renderQueryCmdError e + liftIO . LT.hPutStrLn IO.stderr $ prettyToLazyText $ "Warning: Sync progress unavailable: " <> renderQueryCmdError e return $ O.QueryTipLocalStateOutput { O.localStateChainTip = chainTip diff --git a/cardano-cli/src/Cardano/CLI/Helpers.hs b/cardano-cli/src/Cardano/CLI/Helpers.hs index b193a1a581..02473017d6 100644 --- a/cardano-cli/src/Cardano/CLI/Helpers.hs +++ b/cardano-cli/src/Cardano/CLI/Helpers.hs @@ -42,7 +42,6 @@ import Data.Functor (void) import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.IO as Text -import Prettyprinter import qualified System.Console.ANSI as ANSI import System.Console.ANSI import qualified System.Directory as IO diff --git a/cardano-cli/src/Cardano/CLI/Pretty.hs b/cardano-cli/src/Cardano/CLI/Pretty.hs index 19a306f990..d9a5fa98e1 100644 --- a/cardano-cli/src/Cardano/CLI/Pretty.hs +++ b/cardano-cli/src/Cardano/CLI/Pretty.hs @@ -1,25 +1,20 @@ module Cardano.CLI.Pretty - ( Ann, - putLn, - hPutLn, - prettyToStrictText, + ( module Pretty + , putLn + , hPutLn ) where -import Cardano.Api.Pretty (prettyToText) +import Cardano.Api.Pretty +import qualified Cardano.Api.Pretty as Pretty import qualified Control.Concurrent.QSem as IO import Control.Exception (bracket_) import Control.Monad.IO.Class (MonadIO, liftIO) -import Data.Text (Text) -import qualified Data.Text.Lazy as TextLazy import qualified Data.Text.Lazy.IO as TextLazy -import Prettyprinter import Prettyprinter.Render.Terminal import qualified System.IO as IO import qualified System.IO.Unsafe as IO -type Ann = AnsiStyle - sem :: IO.QSem sem = IO.unsafePerformIO $ IO.newQSem 1 {-# NOINLINE sem #-} @@ -28,10 +23,7 @@ consoleBracket :: IO a -> IO a consoleBracket = bracket_ (IO.waitQSem sem) (IO.signalQSem sem) putLn :: MonadIO m => Doc AnsiStyle -> m () -putLn = liftIO . consoleBracket . TextLazy.putStrLn . prettyToText +putLn = liftIO . consoleBracket . TextLazy.putStrLn . prettyToLazyText hPutLn :: MonadIO m => IO.Handle -> Doc AnsiStyle -> m () -hPutLn h = liftIO . consoleBracket . TextLazy.hPutStr h . prettyToText - -prettyToStrictText :: Doc AnsiStyle -> Text -prettyToStrictText = TextLazy.toStrict . prettyToText +hPutLn h = liftIO . consoleBracket . TextLazy.hPutStr h . prettyToLazyText diff --git a/cardano-cli/src/Cardano/CLI/Read.hs b/cardano-cli/src/Cardano/CLI/Read.hs index 5223808346..d160a9111e 100644 --- a/cardano-cli/src/Cardano/CLI/Read.hs +++ b/cardano-cli/src/Cardano/CLI/Read.hs @@ -146,10 +146,8 @@ import Data.Word import GHC.IO.Handle (hClose, hIsSeekable) import GHC.IO.Handle.FD (openFileBlocking) import qualified Options.Applicative as Opt -import Prettyprinter import System.IO (IOMode (ReadMode)) - -- Metadata data MetadataError @@ -164,7 +162,7 @@ data MetadataError renderMetadataError :: MetadataError -> Doc ann renderMetadataError = \case MetadataErrorFile fileErr -> - pretty fileErr + prettyError fileErr MetadataErrorJsonParseError fp jsonErr -> "Invalid JSON format in file: " <> pshow fp <> "\nJSON parse error: " <> pretty jsonErr @@ -234,7 +232,7 @@ data ScriptWitnessError renderScriptWitnessError :: ScriptWitnessError -> Doc ann renderScriptWitnessError = \case ScriptWitnessErrorFile err -> - pretty err + prettyError err ScriptWitnessErrorScriptLanguageNotSupportedInEra (AnyScriptLanguage lang) anyEra -> "The script language " <> pshow lang <> " is not supported in the " <> pretty (renderEra anyEra) <> " era." @@ -392,7 +390,7 @@ data ScriptDataError = renderScriptDataError :: ScriptDataError -> Doc ann renderScriptDataError = \case ScriptDataErrorFile err -> - pretty err + prettyError err ScriptDataErrorJsonParse fp jsonErr-> "Invalid JSON format in file: " <> pshow fp <> "\nJSON parse error: " <> pretty jsonErr ScriptDataErrorConversion fp sDataJsonErr-> @@ -520,10 +518,10 @@ instance Error CddlError where prettyError = \case CddlErrorTextEnv textEnvErr cddlErr -> "Failed to decode neither the cli's serialisation format nor the ledger's " <> - "CDDL serialisation format. TextEnvelope error: " <> pretty textEnvErr <> "\n" <> - "TextEnvelopeCddl error: " <> pretty cddlErr + "CDDL serialisation format. TextEnvelope error: " <> prettyError textEnvErr <> "\n" <> + "TextEnvelopeCddl error: " <> prettyError cddlErr CddlIOError e -> - pretty e + prettyError e acceptTxCDDLSerialisation :: FileOrPipe @@ -581,11 +579,13 @@ data CddlWitnessError deriving Show instance Error CddlWitnessError where - prettyError (CddlWitnessErrorTextEnv teErr cddlErr) = - "Failed to decode neither the cli's serialisation format nor the ledger's \ - \CDDL serialisation format. TextEnvelope error: " <> pretty teErr <> "\n" <> - "TextEnvelopeCddl error: " <> pretty cddlErr - prettyError (CddlWitnessIOError fileE) = pretty fileE + prettyError = \case + CddlWitnessErrorTextEnv teErr cddlErr -> + "Failed to decode neither the cli's serialisation format nor the ledger's \ + \CDDL serialisation format. TextEnvelope error: " <> prettyError teErr <> "\n" <> + "TextEnvelopeCddl error: " <> prettyError cddlErr + CddlWitnessIOError fileE -> + prettyError fileE -- TODO: This is a stop gap to avoid modifying the TextEnvelope @@ -689,9 +689,9 @@ data ReadWitnessSigningDataError renderReadWitnessSigningDataError :: ReadWitnessSigningDataError -> Doc ann renderReadWitnessSigningDataError = \case ReadWitnessSigningDataSigningKeyDecodeError fileErr -> - "Error reading signing key: " <> pretty fileErr + "Error reading signing key: " <> prettyError fileErr ReadWitnessSigningDataScriptError fileErr -> - "Error reading script: " <> pretty fileErr + "Error reading script: " <> prettyError fileErr ReadWitnessSigningDataSigningKeyAndAddressMismatch -> "Only a Byron signing key may be accompanied by a Byron address." @@ -746,7 +746,7 @@ data RequiredSignerError instance Error RequiredSignerError where prettyError = \case RequiredSignerErrorFile e -> - pretty e + prettyError e RequiredSignerErrorByronKey (File byronSkeyfile) -> "Byron witnesses cannot be used for required signers: " <> pretty byronSkeyfile @@ -786,7 +786,7 @@ data VoteError instance Error VoteError where prettyError = \case VoteErrorFile e -> - pretty e + prettyError e VoteErrorTextNotUnicode e -> "Vote text file not UTF8-encoded: " <> pretty (displayException e) diff --git a/cardano-cli/src/Cardano/CLI/Run/Ping.hs b/cardano-cli/src/Cardano/CLI/Run/Ping.hs index a4cc67b70b..b466f82ea8 100644 --- a/cardano-cli/src/Cardano/CLI/Run/Ping.hs +++ b/cardano-cli/src/Cardano/CLI/Run/Ping.hs @@ -32,7 +32,6 @@ import Data.Word (Word32) import Network.Socket (AddrInfo) import qualified Network.Socket as Socket import qualified Options.Applicative as Opt -import Prettyprinter import qualified Prettyprinter as PP import qualified System.Exit as IO import qualified System.IO as IO diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/AddressCmdError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/AddressCmdError.hs index 3e6055dcb5..06bd8dd80d 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/AddressCmdError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/AddressCmdError.hs @@ -33,12 +33,12 @@ renderAddressCmdError = \case AddressCmdAddressInfoError addrInfoErr -> prettyError addrInfoErr AddressCmdReadKeyFileError fileErr -> - pretty fileErr + prettyError fileErr AddressCmdVerificationKeyTextOrFileError vkTextOrFileErr -> renderVerificationKeyTextOrFileError vkTextOrFileErr AddressCmdReadScriptFileError fileErr -> - pretty fileErr + prettyError fileErr AddressCmdWriteFileError fileErr -> - pretty fileErr + prettyError fileErr AddressCmdExpectedPaymentVerificationKey someAddress -> "Expected payment verification key but got: " <> pretty (renderSomeAddressVerificationKey someAddress) diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/DelegationError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/DelegationError.hs index 65a54bf6e9..f6b7fca1f7 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/DelegationError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/DelegationError.hs @@ -11,7 +11,6 @@ import Cardano.Api import Cardano.CLI.Types.Errors.StakeCredentialError import GHC.Generics (Generic) -import Prettyprinter data DelegationError = DelegationReadError !(FileError InputDecodeError) @@ -23,10 +22,10 @@ data DelegationError instance Error DelegationError where prettyError = \case DelegationReadError e -> - "Cannot read delegation target: " <> pretty e + "Cannot read delegation target: " <> prettyError e DelegationStakeCredentialError e -> "Cannot get stake credential: " <> prettyError e DelegationCertificateWriteFileError e -> - "Cannot write certificate: " <> pretty e + "Cannot write certificate: " <> prettyError e DelegationDRepReadError e -> - "Cannot read DRep key: " <> pretty e + "Cannot read DRep key: " <> prettyError e diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/GenesisCmdError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/GenesisCmdError.hs index 5779fedfca..9e24d357f5 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/GenesisCmdError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/GenesisCmdError.hs @@ -46,9 +46,9 @@ instance Error GenesisCmdError where GenesisCmdAesonDecodeError fp decErr -> "Error while decoding Shelley genesis at: " <> pretty fp <> " Error: " <> pretty decErr GenesisCmdGenesisFileError fe -> - pretty fe + prettyError fe GenesisCmdFileError fe -> - pretty fe + prettyError fe GenesisCmdMismatchedGenesisKeyFiles gfiles dfiles vfiles -> "Mismatch between the files found:\n" <> "Genesis key file indexes: " <> pshow gfiles <> "\n" @@ -61,7 +61,7 @@ instance Error GenesisCmdError where "The genesis keys files are expected to have a unique numeric index but these do not:\n" <> vsep (fmap pretty files) GenesisCmdTextEnvReadFileError fileErr -> - pretty fileErr + prettyError fileErr GenesisCmdUnexpectedAddressVerificationKey (File file) expect got -> mconcat [ "Unexpected address verification key type in file ", pretty file @@ -87,7 +87,7 @@ instance Error GenesisCmdError where "Error while decoding Shelley genesis at: " <> pretty fp <> " Error: " <> pretty e GenesisCmdGenesisFileReadError e -> - pretty e + prettyError e GenesisCmdByronError e -> pshow e GenesisCmdStakePoolRelayFileError fp e -> "Error occurred while reading the stake pool relay specification file: " <> pretty fp <> diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceActionsError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceActionsError.hs index cd12c11766..3a0feafd13 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceActionsError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceActionsError.hs @@ -25,11 +25,11 @@ instance Error GovernanceActionsError where GovernanceActionsCmdConstitutionError e -> "Cannot read constitution: " <> pshow e -- TODO Conway render this properly GovernanceActionsCmdReadFileError e -> - "Cannot read file: " <> pretty e + "Cannot read file: " <> prettyError e GovernanceActionsCmdReadTextEnvelopeFileError e -> - "Cannot read text envelope file: " <> pretty e + "Cannot read text envelope file: " <> prettyError e GovernanceActionsCmdWriteFileError e -> - "Cannot write file: " <> pretty e + "Cannot write file: " <> prettyError e GovernanceActionsValueUpdateProtocolParametersNotFound (AnyShelleyBasedEra expectedShelleyEra) -> mconcat [ "Protocol parameters update value for " <> pshow (toCardanoEra expectedShelleyEra) diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceCmdError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceCmdError.hs index ab93281b1f..cce1d5492d 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceCmdError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceCmdError.hs @@ -65,9 +65,9 @@ instance Error GovernanceCmdError where VotingCredentialDecodeGovCmdEror decoderError -> "Could not decode voting credential: " <> renderDecoderError decoderError WriteFileError fileError -> - pretty fileError + prettyError fileError ReadFileError fileError -> - pretty fileError + prettyError fileError GovernanceCmdConstitutionError e -> "Constitution error " <> pshow e -- TODO Conway render this properly GovernanceCmdHashError e -> @@ -75,15 +75,15 @@ instance Error GovernanceCmdError where GovernanceCmdProposalError e -> "Proposal error " <> pshow e -- TODO Conway render this properly GovernanceCmdTextEnvReadError fileError -> - "Cannot read text envelope: " <> pretty fileError + "Cannot read text envelope: " <> prettyError fileError GovernanceCmdCddlError cddlError -> "Reading transaction CDDL file error: " <> prettyError cddlError GovernanceCmdKeyReadError fileError -> - "Cannot read key: " <> pretty fileError + "Cannot read key: " <> prettyError fileError GovernanceCmdCostModelReadError fileError -> - "Cannot read cost model: " <> pretty fileError + "Cannot read cost model: " <> prettyError fileError GovernanceCmdTextEnvWriteError fileError -> - pretty fileError + prettyError fileError GovernanceCmdEmptyUpdateProposalError -> "Empty update proposals are not allowed." GovernanceCmdMIRCertificateKeyRewardMistmach fp nStakeVerKeys nRewards -> @@ -109,7 +109,7 @@ instance Error GovernanceCmdError where GovernanceCmdVerifyPollError pollError -> pretty $ renderGovernancePollError pollError GovernanceCmdWriteFileError fileError -> - "Cannot write file: " <> pretty fileError + "Cannot write file: " <> prettyError fileError GovernanceCmdDRepMetadataValidationError e -> "DRep metadata validation error: " <> prettyError e GovernanceCmdMIRCertNotSupportedInConway -> diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceCommitteeError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceCommitteeError.hs index e09cf88c65..d2a1b0b2f9 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceCommitteeError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceCommitteeError.hs @@ -5,7 +5,6 @@ module Cardano.CLI.Types.Errors.GovernanceCommitteeError ) where import Cardano.Api -import Cardano.Api.Pretty data GovernanceCommitteeError = GovernanceCommitteeCmdKeyDecodeError InputDecodeError @@ -20,10 +19,10 @@ instance Error GovernanceCommitteeError where GovernanceCommitteeCmdKeyDecodeError e -> "Cannot decode key: " <> prettyError e GovernanceCommitteeCmdKeyReadError e -> - "Cannot read key: " <> pretty e + "Cannot read key: " <> prettyError e GovernanceCommitteeCmdWriteFileError e -> - "Cannot write file: " <> pretty e + "Cannot write file: " <> prettyError e GovernanceCommitteeCmdTextEnvReadFileError e -> - "Cannot read text envelope file: " <> pretty e + "Cannot read text envelope file: " <> prettyError e GovernanceCommitteeCmdTextEnvWriteError e -> - "Cannot write text envelope file: " <> pretty e + "Cannot write text envelope file: " <> prettyError e diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceQueryError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceQueryError.hs index 1d8bc2b6ed..eaae47d401 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceQueryError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceQueryError.hs @@ -20,7 +20,7 @@ data GovernanceQueryError instance Error GovernanceQueryError where prettyError = \case GovernanceQueryWriteFileError err -> - pretty err + prettyError err GovernanceQueryAcqireFailureError err -> pshow err GovernanceQueryUnsupportedNtcVersion (UnsupportedNtcVersionError minNtcVersion ntcVersion) -> @@ -32,4 +32,4 @@ instance Error GovernanceQueryError where GovernanceQueryEraMismatch err -> "A query from a certain era was applied to a ledger from a different era: " <> pshow err GovernanceQueryDRepKeyError err -> - "Error reading delegation representative key: " <> pretty err + "Error reading delegation representative key: " <> prettyError err diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceVoteCmdError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceVoteCmdError.hs index 843269ae63..2cca84fe12 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceVoteCmdError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceVoteCmdError.hs @@ -24,13 +24,13 @@ data GovernanceVoteCmdError instance Error GovernanceVoteCmdError where prettyError = \case GovernanceVoteCmdReadVerificationKeyError e -> - "Cannot read verification key: " <> pretty e + "Cannot read verification key: " <> prettyError e GovernanceVoteCmdReadVoteFileError e -> "Cannot read vote file: " <> prettyError e GovernanceVoteCmdCredentialDecodeError e -> "Cannot decode voting credential: " <> renderDecoderError e GovernanceVoteCmdWriteError e -> - "Cannot write vote: " <> pretty e + "Cannot write vote: " <> prettyError e GovernanceVoteCmdReadVoteTextError e -> "Cannot read vote text: " <> prettyError e where diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/ItnKeyConversionError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/ItnKeyConversionError.hs index 53c96fdcc1..62a8c221ba 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/ItnKeyConversionError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/ItnKeyConversionError.hs @@ -15,7 +15,6 @@ import Cardano.Api.Pretty import Control.Exception (Exception (..), IOException) import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as BSC -import Prettyprinter -- | An error that can occur while converting an Incentivized Testnet (ITN) -- key. diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/KeyCmdError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/KeyCmdError.hs index 8169d41f05..3b498c1c9a 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/KeyCmdError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/KeyCmdError.hs @@ -17,7 +17,6 @@ import Cardano.CLI.Types.Errors.ItnKeyConversionError import Cardano.CLI.Types.Key import Data.Text (Text) -import Prettyprinter data KeyCmdError = KeyCmdReadFileError !(FileError TextEnvelopeError) @@ -41,11 +40,11 @@ renderKeyCmdError :: KeyCmdError -> Doc ann renderKeyCmdError err = case err of KeyCmdReadFileError fileErr -> - pretty fileErr + prettyError fileErr KeyCmdReadKeyFileError fileErr -> - pretty fileErr + prettyError fileErr KeyCmdWriteFileError fileErr -> - pretty fileErr + prettyError fileErr KeyCmdByronKeyFailure e -> Byron.renderByronKeyFailure e KeyCmdByronKeyParseError errTxt -> @@ -55,7 +54,7 @@ renderKeyCmdError err = KeyCmdWrongKeyTypeError -> "Please use a signing key file when converting ITN BIP32 or Extended keys" KeyCmdCardanoAddressSigningKeyFileError fileErr -> - pretty fileErr + prettyError fileErr KeyCmdNonLegacyKey fp -> "Signing key at: " <> pretty fp <> " is not a legacy Byron signing key and should not need to be converted." KeyCmdVerificationKeyReadError e -> diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/NodeCmdError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/NodeCmdError.hs index f2c2c75b0e..08ac21b308 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/NodeCmdError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/NodeCmdError.hs @@ -9,8 +9,6 @@ module Cardano.CLI.Types.Errors.NodeCmdError import Cardano.Api import Cardano.Api.Pretty -import Prettyprinter - {- HLINT ignore "Reduce duplication" -} data NodeCmdError @@ -31,10 +29,10 @@ renderNodeCmdError = \case "Error creating VRF signing key file. Target path: " <> pshow targetPath <> " Temporary path: " <> pshow tempPath NodeCmdReadFileError fileErr -> - pretty fileErr + prettyError fileErr NodeCmdReadKeyFileError fileErr -> - pretty fileErr + prettyError fileErr NodeCmdWriteFileError fileErr -> - pretty fileErr + prettyError fileErr NodeCmdOperationalCertificateIssueError issueErr -> prettyError issueErr diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/ProtocolParamsError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/ProtocolParamsError.hs index 0b667de873..91490aef6c 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/ProtocolParamsError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/ProtocolParamsError.hs @@ -13,7 +13,6 @@ import Cardano.Api import Cardano.Api.Pretty import Data.Text (Text) -import Prettyprinter data ProtocolParamsError = ProtocolParamsErrorFile (FileError ()) @@ -22,6 +21,6 @@ data ProtocolParamsError renderProtocolParamsError :: ProtocolParamsError -> Doc ann renderProtocolParamsError = \case ProtocolParamsErrorFile fileErr -> - pretty fileErr + prettyError fileErr ProtocolParamsErrorJSON fp jsonErr -> "Error while decoding the protocol parameters at: " <> pshow fp <> " Error: " <> pshow jsonErr diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/QueryCmdError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/QueryCmdError.hs index ad9b2bba3a..a46e3353c7 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/QueryCmdError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/QueryCmdError.hs @@ -27,7 +27,6 @@ import qualified Ouroboros.Consensus.HardFork.History.Qry as Qry import qualified Data.ByteString.Lazy.Char8 as LBS import Data.Text.Lazy.Builder (toLazyText) import Formatting.Buildable (build) -import Prettyprinter {- HLINT ignore "Move brackets to avoid $" -} {- HLINT ignore "Redundant flip" -} @@ -62,7 +61,7 @@ renderQueryCmdError = \case QueryCmdLocalStateQueryError lsqErr -> renderLocalStateQueryError lsqErr QueryCmdWriteFileError fileErr -> - pretty fileErr + prettyError fileErr QueryCmdHelpersError helpersErr -> renderHelpersError helpersErr QueryCmdAcquireFailure acquireFail -> @@ -81,11 +80,11 @@ renderQueryCmdError = \case QueryCmdLeaderShipError e -> prettyError e QueryCmdTextEnvelopeReadError e -> - pretty e + prettyError e QueryCmdTextReadError e -> - pretty e + prettyError e QueryCmdOpCertCounterReadError e -> - pretty e + prettyError e QueryCmdProtocolStateDecodeFailure (_, decErr) -> "Failed to decode the protocol state: " <> pretty (toLazyText $ build decErr) QueryCmdPoolStateDecodeError decoderError -> @@ -101,8 +100,8 @@ renderQueryCmdError = \case QueryCmdConvenienceError qce -> pretty $ renderQueryConvenienceError qce QueryCmdDRepKeyError e -> - "Error reading delegation representative key: " <> pretty e + "Error reading delegation representative key: " <> prettyError e QueryCmdCommitteeColdKeyError e -> - "Error reading committee cold key: " <> pretty e + "Error reading committee cold key: " <> prettyError e QueryCmdCommitteeHotKeyError e -> - "Error reading committee hot key: " <> pretty e + "Error reading committee hot key: " <> prettyError e diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/QueryCmdLocalStateQueryError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/QueryCmdLocalStateQueryError.hs index c9369ec1c0..47b2f271c8 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/QueryCmdLocalStateQueryError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/QueryCmdLocalStateQueryError.hs @@ -9,8 +9,6 @@ import Cardano.Api.Pretty import Ouroboros.Consensus.Cardano.Block (EraMismatch (..)) -import Prettyprinter - -- | An error that can occur while querying a node's local state. newtype QueryCmdLocalStateQueryError = EraMismatchError EraMismatch diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/RegistrationError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/RegistrationError.hs index e95dbc4b1d..1336f3e1a7 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/RegistrationError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/RegistrationError.hs @@ -9,8 +9,6 @@ import Cardano.Api import Cardano.CLI.Types.Errors.StakeAddressRegistrationError import Cardano.CLI.Types.Errors.StakeCredentialError -import Prettyprinter - data RegistrationError = RegistrationReadError !(FileError InputDecodeError) | RegistrationWriteFileError !(FileError ()) @@ -21,9 +19,9 @@ data RegistrationError instance Error RegistrationError where prettyError = \case RegistrationReadError e -> - "Cannot read registration certificate: " <> pretty e + "Cannot read registration certificate: " <> prettyError e RegistrationWriteFileError e -> - "Cannot write registration certificate: " <> pretty e + "Cannot write registration certificate: " <> prettyError e RegistrationStakeCredentialError e -> "Cannot read stake credential: " <> prettyError e RegistrationStakeError e -> diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/StakeAddressCmdError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/StakeAddressCmdError.hs index 5bdc536053..077cd19007 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/StakeAddressCmdError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/StakeAddressCmdError.hs @@ -11,8 +11,6 @@ import Cardano.CLI.Types.Errors.ScriptDecodeError import Cardano.CLI.Types.Errors.StakeAddressRegistrationError import Cardano.CLI.Types.Errors.StakeCredentialError -import Prettyprinter - data StakeAddressCmdError = StakeAddressCmdReadKeyFileError !(FileError InputDecodeError) | StakeAddressCmdReadScriptFileError !(FileError ScriptDecodeError) @@ -24,9 +22,9 @@ data StakeAddressCmdError instance Error StakeAddressCmdError where prettyError = \case - StakeAddressCmdReadKeyFileError e -> pretty e - StakeAddressCmdReadScriptFileError e -> pretty e + StakeAddressCmdReadKeyFileError e -> prettyError e + StakeAddressCmdReadScriptFileError e -> prettyError e StakeAddressCmdStakeCredentialError e -> prettyError e - StakeAddressCmdWriteFileError e -> pretty e + StakeAddressCmdWriteFileError e -> prettyError e StakeAddressCmdDelegationError e -> prettyError e StakeAddressCmdRegistrationError e -> prettyError e diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/StakeCredentialError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/StakeCredentialError.hs index 4073437694..83e0db13ed 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/StakeCredentialError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/StakeCredentialError.hs @@ -5,7 +5,6 @@ module Cardano.CLI.Types.Errors.StakeCredentialError ) where import Cardano.Api -import Cardano.Api.Pretty import Cardano.CLI.Types.Errors.ScriptDecodeError @@ -16,5 +15,7 @@ data StakeCredentialError instance Error StakeCredentialError where prettyError = \case - StakeCredentialScriptDecodeError e -> pretty e - StakeCredentialInputDecodeError e -> pretty e + StakeCredentialScriptDecodeError e -> + prettyError e + StakeCredentialInputDecodeError e -> + prettyError e diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/StakePoolCmdError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/StakePoolCmdError.hs index 929a8098ad..b10526f92f 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/StakePoolCmdError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/StakePoolCmdError.hs @@ -9,7 +9,6 @@ module Cardano.CLI.Types.Errors.StakePoolCmdError ) where import Cardano.Api -import Cardano.Api.Pretty import Prettyprinter @@ -25,8 +24,8 @@ renderStakePoolCmdError = \case StakePoolCmdMetadataValidationError validationErr -> "Error validating stake pool metadata: " <> prettyError validationErr StakePoolCmdReadFileError fileErr -> - pretty fileErr + prettyError fileErr StakePoolCmdReadKeyFileError fileErr -> - pretty fileErr + prettyError fileErr StakePoolCmdWriteFileError fileErr -> - pretty fileErr + prettyError fileErr diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/TextViewFileError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/TextViewFileError.hs index bb2a897c3d..caba8b44b0 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/TextViewFileError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/TextViewFileError.hs @@ -20,6 +20,6 @@ data TextViewFileError renderTextViewFileError :: TextViewFileError -> Doc ann renderTextViewFileError = \case TextViewReadFileError fileErr -> - pretty fileErr + prettyError fileErr TextViewCBORPrettyPrintError hlprsErr -> "Error pretty printing CBOR: " <> renderHelpersError hlprsErr diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/TxCmdError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/TxCmdError.hs index 6f81906c9d..975be200ca 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/TxCmdError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/TxCmdError.hs @@ -27,7 +27,6 @@ import qualified Cardano.Prelude as List import Ouroboros.Consensus.Cardano.Block (EraMismatch (..)) import Data.Text (Text) -import Prettyprinter {- HLINT ignore "Use let" -} @@ -93,13 +92,13 @@ renderTxCmdError = \case TxCmdConstitutionError constErr -> pshow constErr TxCmdReadTextViewFileError fileErr -> - pretty fileErr + prettyError fileErr TxCmdScriptFileError fileErr -> - pretty fileErr + prettyError fileErr TxCmdReadWitnessSigningDataError witSignDataErr -> renderReadWitnessSigningDataError witSignDataErr TxCmdWriteFileError fileErr -> - pretty fileErr + prettyError fileErr TxCmdTxSubmitError res -> "Error while submitting tx: " <> pretty res TxCmdTxSubmitErrorEraMismatch EraMismatch{ledgerEraName, otherEraName} -> @@ -155,8 +154,8 @@ renderTxCmdError = \case TxCmdTextEnvCddlError textEnvErr cddlErr -> mconcat [ "Failed to decode neither the cli's serialisation format nor the ledger's " - , "CDDL serialisation format. TextEnvelope error: " <> pretty textEnvErr <> "\n" - , "TextEnvelopeCddl error: " <> pretty cddlErr + , "CDDL serialisation format. TextEnvelope error: " <> prettyError textEnvErr <> "\n" + , "TextEnvelopeCddl error: " <> prettyError cddlErr ] TxCmdTxExecUnitsErr err' -> prettyError err' diff --git a/cardano-cli/src/Cardano/CLI/Types/Key.hs b/cardano-cli/src/Cardano/CLI/Types/Key.hs index 5370eac99c..97784b22e5 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Key.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Key.hs @@ -63,8 +63,6 @@ import Data.Function import qualified Data.List.NonEmpty as NE import Data.Text (Text) import qualified Data.Text.Encoding as Text -import Prettyprinter - ------------------------------------------------------------------------------ -- Verification key deserialisation @@ -233,7 +231,7 @@ renderVerificationKeyTextOrFileError :: VerificationKeyTextOrFileError -> Doc an renderVerificationKeyTextOrFileError vkTextOrFileErr = case vkTextOrFileErr of VerificationKeyTextError err -> renderInputDecodeError err - VerificationKeyFileError err -> pretty err + VerificationKeyFileError err -> prettyError err -- | Deserialise a verification key from text or a verification key file. -- If a filepath is provided, the file can either be formatted as Bech32, hex, diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs index 29046775d7..0d3d476e06 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs @@ -36,7 +36,7 @@ hprop_golden_governanceVerifyPoll = propertyOnce $ do liftIO (readVerificationKeyOrTextEnvFile AsStakePoolKey goldenVkFile) >>= \case Left e -> - H.failWith Nothing $ prettyToString $ pretty e + H.failWith Nothing $ prettyToString $ prettyError e Right vk -> do let expected = prettyPrintJSON $ serialiseToRawBytesHexText <$> [verificationKeyHash vk] H.assert $ expected `BSC.isInfixOf` stdout diff --git a/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Util.hs b/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Util.hs index 531b21eb67..5a55cdfe26 100644 --- a/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Util.hs +++ b/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Util.hs @@ -135,7 +135,7 @@ checkTextEnvelopeFormat tve reference created = GHC.withFrozenCallStack $ do createdTextEnvelope <- handleTextEnvelope eCreatedTextEnvelope typeTitleEquivalence refTextEnvelope createdTextEnvelope - where + where handleTextEnvelope :: MonadTest m => Either (FileError TextEnvelopeError) TextEnvelope -> m TextEnvelope @@ -143,7 +143,7 @@ checkTextEnvelopeFormat tve reference created = GHC.withFrozenCallStack $ do Right refTextEnvelope -> return refTextEnvelope Left fileErr -> - failWithCustom GHC.callStack Nothing . (prettyToString . pretty) $ fileErr + failWithCustom GHC.callStack Nothing . (prettyToString . prettyError) $ fileErr typeTitleEquivalence :: (MonadTest m, HasCallStack) => TextEnvelope -> TextEnvelope -> m () typeTitleEquivalence (TextEnvelope refType refTitle _)