Skip to content

Commit

Permalink
Upgrade to cardano-api-8.32.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Nov 17, 2023
1 parent 13466c0 commit 1fbbee9
Show file tree
Hide file tree
Showing 36 changed files with 99 additions and 129 deletions.
7 changes: 6 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ index-state:

packages:
cardano-cli
../cardano-api/cardano-api

package cardano-cli
ghc-options: -Werror
Expand All @@ -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
2 changes: 1 addition & 1 deletion cardano-cli/app/cardano-cli.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ main = toplevelExceptionHandler $ do
#endif
co <- Opt.customExecParser pref (opts envCli)

orDie (prettyToStrictText . renderClientCommandError) $ runClientCommand co
orDie (prettyToText . renderClientCommandError) $ runClientCommand co
1 change: 0 additions & 1 deletion cardano-cli/src/Cardano/CLI/Byron/Delegation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion cardano-cli/src/Cardano/CLI/Byron/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions cardano-cli/src/Cardano/CLI/Byron/Key.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion cardano-cli/src/Cardano/CLI/Byron/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion cardano-cli/src/Cardano/CLI/Byron/UpdateProposal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions cardano-cli/src/Cardano/CLI/Byron/Vote.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion cardano-cli/src/Cardano/CLI/Helpers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 7 additions & 15 deletions cardano-cli/src/Cardano/CLI/Pretty.hs
Original file line number Diff line number Diff line change
@@ -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 #-}
Expand All @@ -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
34 changes: 17 additions & 17 deletions cardano-cli/src/Cardano/CLI/Read.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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->
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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."

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion cardano-cli/src/Cardano/CLI/Run/Ping.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions cardano-cli/src/Cardano/CLI/Types/Errors/AddressCmdError.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
7 changes: 3 additions & 4 deletions cardano-cli/src/Cardano/CLI/Types/Errors/DelegationError.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Cardano.Api
import Cardano.CLI.Types.Errors.StakeCredentialError

import GHC.Generics (Generic)
import Prettyprinter

data DelegationError
= DelegationReadError !(FileError InputDecodeError)
Expand All @@ -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
8 changes: 4 additions & 4 deletions cardano-cli/src/Cardano/CLI/Types/Errors/GenesisCmdError.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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 <>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceCmdError.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,25 @@ 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 ->
"Hash error " <> prettyError e
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 ->
Expand All @@ -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 ->
Expand Down
Loading

0 comments on commit 1fbbee9

Please sign in to comment.