Skip to content

Commit

Permalink
Misc refactors in pretty printing and replacing unnecessary function
Browse files Browse the repository at this point in the history
definitions
  • Loading branch information
Jimbo4350 committed Nov 26, 2024
1 parent 308ce97 commit 965b466
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 25 deletions.
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
6 changes: 3 additions & 3 deletions cardano-cli/src/Cardano/CLI/Types/Errors/ScriptDecodeError.hs
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

0 comments on commit 965b466

Please sign in to comment.