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

Misc refactors in pretty printing and replacing unnecessary functions #980

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 6 additions & 15 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1226,12 +1226,12 @@ getAllReferenceInputs
votingProceduresAndMaybeScriptWits
propProceduresAnMaybeScriptWits
readOnlyRefIns = do
let txinsWitByRefInputs = [getReferenceInput sWit | (_, Just sWit) <- txins]
mintingRefInputs = map getReferenceInput mintWitnesses
certsWitByRefInputs = [getReferenceInput sWit | (_, Just sWit) <- certFiles]
withdrawalsWitByRefInputs = [getReferenceInput sWit | (_, _, Just sWit) <- withdrawals]
votesWitByRefInputs = [getReferenceInput sWit | (_, Just sWit) <- votingProceduresAndMaybeScriptWits]
propsWitByRefInputs = [getReferenceInput sWit | (_, Just sWit) <- propProceduresAnMaybeScriptWits]
let txinsWitByRefInputs = [getScriptWitnessReferenceInput sWit | (_, Just sWit) <- txins]
mintingRefInputs = map getScriptWitnessReferenceInput mintWitnesses
certsWitByRefInputs = [getScriptWitnessReferenceInput sWit | (_, Just sWit) <- certFiles]
withdrawalsWitByRefInputs = [getScriptWitnessReferenceInput sWit | (_, _, Just sWit) <- withdrawals]
votesWitByRefInputs = [getScriptWitnessReferenceInput sWit | (_, Just sWit) <- votingProceduresAndMaybeScriptWits]
propsWitByRefInputs = [getScriptWitnessReferenceInput sWit | (_, Just sWit) <- propProceduresAnMaybeScriptWits]

concatMap
catMaybes
Expand All @@ -1243,15 +1243,6 @@ getAllReferenceInputs
, propsWitByRefInputs
, map Just readOnlyRefIns
]
where
getReferenceInput
:: ScriptWitness witctx era -> Maybe TxIn
getReferenceInput sWit =
case sWit of
PlutusScriptWitness _ _ (PReferenceScript refIn) _ _ _ -> Just refIn
PlutusScriptWitness _ _ PScript{} _ _ _ -> Nothing
SimpleScriptWitness _ (SReferenceScript refIn) -> Just refIn
SimpleScriptWitness _ SScript{} -> Nothing

toAddressInAnyEra
:: CardanoEra era
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ instance Error PlutusScriptDecodeError where
prettyError err
PlutusScriptDecodeErrorVersionMismatch version (AnyPlutusScriptVersion v) ->
"Version mismatch in code: script version that was read"
<> pretty version
<> " but tried to decode script version: "
<> pshow v
<+> pretty version
<+> " but tried to decode script version: "
<+> pshow v
8 changes: 4 additions & 4 deletions cardano-cli/src/Cardano/CLI/Types/Errors/ScriptDataError.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ renderScriptDataError = \case
ScriptDataErrorFile err ->
prettyError err
ScriptDataErrorJsonParse fp jsonErr ->
"Invalid JSON format in file: " <> pshow fp <> "\nJSON parse error: " <> pretty jsonErr
"Invalid JSON format in file:" <+> pshow fp <> "\nJSON parse error:" <+> pretty jsonErr
ScriptDataErrorConversion fp sDataJsonErr ->
"Error reading metadata at: " <> pshow fp <> "\n" <> prettyError sDataJsonErr
"Error reading metadata at:" <+> pshow fp <> "\n" <> prettyError sDataJsonErr
ScriptDataErrorValidation fp sDataRangeErr ->
"Error validating script data at: " <> pshow fp <> ":\n" <> prettyError sDataRangeErr
"Error validating script data at:" <+> pshow fp <> ":\n" <> prettyError sDataRangeErr
ScriptDataErrorMetadataDecode fp decoderErr ->
"Error decoding CBOR metadata at: " <> pshow fp <> " Error: " <> pshow decoderErr
"Error decoding CBOR metadata at:" <+> pshow fp <+> "Error:" <+> pshow decoderErr
ScriptDataErrorJsonBytes e ->
prettyError e
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ data ScriptDecodeError
instance Error ScriptDecodeError where
prettyError = \case
ScriptDecodeTextEnvelopeError err ->
"Error decoding script: " <> prettyError err
"Error decoding script:" <+> prettyError err
ScriptDecodeSimpleScriptError err ->
"Syntax error in script: " <> prettyError err
"Syntax error in script:" <+> prettyError err
ScriptDecodeUnknownPlutusScriptVersion version ->
"Unknown Plutus script version: " <> pshow version
"Unknown Plutus script version:" <+> pshow version
Loading