Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of multiline literals #4889

Merged
merged 4 commits into from
Feb 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions cardano-api/src/Cardano/Api/ProtocolParameters.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1790,15 +1790,17 @@ data ProtocolParametersError =
deriving Show

instance Error ProtocolParametersError where
displayError (PParamsErrorMissingMinUTxoValue (AnyCardanoEra era)) =
"The " <> show era <> " protocol parameters value is missing the following \
\field: MinUTxoValue. Did you intend to use a " <> show era <> " protocol \
\ parameters value?"
displayError PParamsErrorMissingAlonzoProtocolParameter =
"The Alonzo era protocol parameters in use is missing one or more of the \
\following fields: UTxOCostPerWord, CostModels, Prices, MaxTxExUnits, \
\MaxBlockExUnits, MaxValueSize, CollateralPercent, MaxCollateralInputs. Did \
\you intend to use an Alonzo era protocol parameters value?"
displayError (PParamsErrorMissingMinUTxoValue (AnyCardanoEra era)) = mconcat
[ "The " <> show era <> " protocol parameters value is missing the following "
, "field: MinUTxoValue. Did you intend to use a " <> show era <> " protocol "
, " parameters value?"
]
displayError PParamsErrorMissingAlonzoProtocolParameter = mconcat
[ "The Alonzo era protocol parameters in use is missing one or more of the "
, "following fields: UTxOCostPerWord, CostModels, Prices, MaxTxExUnits, "
, "MaxBlockExUnits, MaxValueSize, CollateralPercent, MaxCollateralInputs. Did "
, "you intend to use an Alonzo era protocol parameters value?"
]

checkProtocolParameters
:: forall era. IsCardanoEra era
Expand Down
26 changes: 14 additions & 12 deletions cardano-api/src/Cardano/Api/SerialiseBech32.hs
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,17 @@ instance Error Bech32DecodeError where
<> ", but it was expected to be "
<> List.intercalate " or " (map show (Set.toList permitted))

Bech32DataPartToBytesError _dataPart ->
"There was an error in extracting the bytes from the data part of the \
\Bech32-encoded string."

Bech32DeserialiseFromBytesError _bytes ->
"There was an error in deserialising the data part of the \
\Bech32-encoded string into a value of the expected type."

Bech32WrongPrefix actual expected ->
"Mismatch in the Bech32 prefix: the actual prefix is " <> show actual
<> ", but the prefix for this payload value should be " <> show expected

Bech32DataPartToBytesError _dataPart -> mconcat
[ "There was an error in extracting the bytes from the data part of the "
, "Bech32-encoded string."
]

Bech32DeserialiseFromBytesError _bytes -> mconcat
[ "There was an error in deserialising the data part of the "
, "Bech32-encoded string into a value of the expected type."
]

Bech32WrongPrefix actual expected -> mconcat
[ "Mismatch in the Bech32 prefix: the actual prefix is " <> show actual
, ", but the prefix for this payload value should be " <> show expected
]
42 changes: 24 additions & 18 deletions cardano-api/src/Cardano/Api/TxBody.hs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ import qualified Cardano.Crypto.Hashing as Byron

import qualified Cardano.Ledger.Address as Shelley
import qualified Cardano.Ledger.AuxiliaryData as Ledger
import Cardano.Ledger.Babbage.TxBody (BabbageEraTxBody (..),
BabbageTxBody (BabbageTxBody), BabbageTxOut (BabbageTxOut))
import Cardano.Ledger.BaseTypes (StrictMaybe (..), maybeToStrictMaybe)
import qualified Cardano.Ledger.Block as Ledger
import qualified Cardano.Ledger.Coin as Ledger
Expand All @@ -214,8 +216,6 @@ import Cardano.Ledger.Crypto (StandardCrypto)
import qualified Cardano.Ledger.Era as CC
import qualified Cardano.Ledger.Keys as Shelley
import qualified Cardano.Ledger.SafeHash as SafeHash
import Cardano.Ledger.Babbage.TxBody (BabbageEraTxBody (..),
BabbageTxBody (BabbageTxBody), BabbageTxOut (BabbageTxOut))
import qualified Cardano.Ledger.TxIn as Ledger
import Cardano.Ledger.Val (isZero)

Expand All @@ -226,23 +226,23 @@ import qualified Cardano.Ledger.Shelley.Metadata as Shelley
import qualified Cardano.Ledger.Shelley.Tx as Shelley
import qualified Cardano.Ledger.Shelley.TxBody as Shelley

import qualified Cardano.Ledger.ShelleyMA.AuxiliaryData as Allegra
import Cardano.Ledger.Mary.Value (MaryValue)
import Cardano.Ledger.ShelleyMA.AuxiliaryData (MAAuxiliaryData (..))
import qualified Cardano.Ledger.ShelleyMA.AuxiliaryData as Allegra
import Cardano.Ledger.ShelleyMA.TxBody (MATxBody (..))
import qualified Cardano.Ledger.ShelleyMA.TxBody as Allegra
import qualified Cardano.Ledger.ShelleyMA.TxBody as Mary
import Cardano.Ledger.ShelleyMA.TxBody (MATxBody (..))
import Cardano.Ledger.Mary.Value (MaryValue)

import Cardano.Ledger.Alonzo.Data (AlonzoAuxiliaryData (AlonzoAuxiliaryData))
import qualified Cardano.Ledger.Alonzo.Data as Alonzo
import qualified Cardano.Ledger.Alonzo.Language as Alonzo
import qualified Cardano.Ledger.Alonzo.PParams as Alonzo
import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo
import qualified Cardano.Ledger.Alonzo.Tx as Alonzo
import qualified Cardano.Ledger.Alonzo.TxBody as Alonzo
import qualified Cardano.Ledger.Alonzo.TxWitness as Alonzo
import Cardano.Ledger.Alonzo.Data (AlonzoAuxiliaryData (AlonzoAuxiliaryData))
import qualified Cardano.Ledger.Alonzo.Data as Alonzo
import Cardano.Ledger.Alonzo.TxBody (AlonzoTxBody (AlonzoTxBody),
AlonzoTxOut (AlonzoTxOut))
import qualified Cardano.Ledger.Alonzo.TxBody as Alonzo
import qualified Cardano.Ledger.Alonzo.TxWitness as Alonzo

import qualified Cardano.Ledger.Babbage.PParams as Babbage
import qualified Cardano.Ledger.Babbage.TxBody as Babbage
Expand Down Expand Up @@ -1909,9 +1909,11 @@ deserialiseShelleyBasedTxBody era bs =
4 -> do
sValiditySupported <-
case txScriptValiditySupportedInShelleyBasedEra era of
Nothing -> fail $ "deserialiseShelleyBasedTxBody: Expected an era that supports the \
\script validity flag but got: "
<> show era
Nothing -> fail $ mconcat
[ "deserialiseShelleyBasedTxBody: Expected an era that supports the "
, "script validity flag but got: "
, show era
]
Just supported -> return supported

txbody <- fromCBOR
Expand All @@ -1928,16 +1930,20 @@ deserialiseShelleyBasedTxBody era bs =
6 -> do
sDataSupported <-
case scriptDataSupportedInEra (shelleyBasedToCardanoEra era) of
Nothing -> fail $ "deserialiseShelleyBasedTxBody: Expected an era that supports script\
\ data but got: "
<> show era
Nothing -> fail $ mconcat
[ "deserialiseShelleyBasedTxBody: Expected an era that supports script"
, " data but got: "
, show era
]
Just supported -> return supported

sValiditySupported <-
case txScriptValiditySupportedInShelleyBasedEra era of
Nothing -> fail $ "deserialiseShelleyBasedTxBody: Expected an era that supports the \
\script validity flag but got: "
<> show era
Nothing -> fail $ mconcat
[ "deserialiseShelleyBasedTxBody: Expected an era that supports the "
, "script validity flag but got: "
, show era
]
Just supported -> return supported

txbody <- fromCBOR
Expand Down
13 changes: 8 additions & 5 deletions cardano-cli/src/Cardano/CLI/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ command' c descr p =
opts :: ParserInfo ClientCommand
opts =
Opt.info (parseClientCommand <**> Opt.helper)
( Opt.fullDesc
<> Opt.header
"cardano-cli - utility to support a variety of key\
\ operations (genesis generation, migration,\
\ pretty-printing..) for different system generations."
( mconcat
[ Opt.fullDesc
, Opt.header $ mconcat
[ "cardano-cli - utility to support a variety of key"
, " operations (genesis generation, migration,"
, " pretty-printing..) for different system generations."
]
]
)

pref :: ParserPrefs
Expand Down
9 changes: 6 additions & 3 deletions cardano-cli/src/Cardano/CLI/Shelley/Output.hs
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,12 @@ instance FromJSON QueryTipLocalStateOutput where
mEra'
mEpoch'
mSyncProgress'
(_,_,_) -> fail "QueryTipLocalStateOutput was incorrectly JSON encoded.\
\ Expected slot, header hash and block number (ChainTip)\
\ or none (ChainTipAtGenesis)"
(_,_,_) ->
fail $ mconcat
[ "QueryTipLocalStateOutput was incorrectly JSON encoded."
, " Expected slot, header hash and block number (ChainTip)"
, " or none (ChainTipAtGenesis)"
]

data ScriptCostOutput =
ScriptCostOutput
Expand Down
Loading