Skip to content

Commit

Permalink
Disambiguate DRep being a key or a script in certificate descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed Jan 8, 2025
1 parent 0067de6 commit 61ff2f8
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
Expand Down Expand Up @@ -123,7 +124,7 @@ runGovernanceDRepRegistrationCertificateCmd
makeDrepRegistrationCertificate
req
(pcaAnchor <$> mAnchor)
description = Just @TextEnvelopeDescr "DRep Key Registration Certificate"
description = Just $ hashSourceToDescription drepHashSource "Registration Certificate"

firstExceptT RegistrationWriteFileError
. newExceptT
Expand All @@ -145,11 +146,10 @@ runGovernanceDRepRetirementCertificateCmd
conwayEraOnwardsConstraints w $ do
drepCredential <- modifyError GovernanceCmdKeyReadError $ readDRepCredential drepHashSource
makeDrepUnregistrationCertificate (DRepUnregistrationRequirements w drepCredential deposit)
& writeFileTextEnvelope outFile (Just genKeyDelegCertDesc)
& writeFileTextEnvelope
outFile
(Just $ hashSourceToDescription drepHashSource "Retirement Certificate")
& modifyError GovernanceCmdTextEnvWriteError . newExceptT
where
genKeyDelegCertDesc :: TextEnvelopeDescr
genKeyDelegCertDesc = "DRep Retirement Certificate"

runGovernanceDRepUpdateCertificateCmd
:: ()
Expand All @@ -172,7 +172,10 @@ runGovernanceDRepUpdateCertificateCmd
(DRepUpdateRequirements w drepCredential)
(pcaAnchor <$> mAnchor)
firstExceptT GovernanceCmdTextEnvWriteError . newExceptT $
writeFileTextEnvelope outFile (Just "DRep Update Certificate") updateCertificate
writeFileTextEnvelope
outFile
(Just $ hashSourceToDescription drepHashSource "Update Certificate")
updateCertificate

runGovernanceDRepMetadataHashCmd
:: ()
Expand Down Expand Up @@ -211,3 +214,12 @@ runGovernanceDRepMetadataHashCmd
fetchURLToGovernanceCmdError
:: ExceptT FetchURLError IO ByteString -> ExceptT GovernanceCmdError IO ByteString
fetchURLToGovernanceCmdError = withExceptT GovernanceCmdFetchURLError

hashSourceToDescription :: DRepHashSource -> TextEnvelopeDescr -> TextEnvelopeDescr
hashSourceToDescription source what =
( case source of
DRepHashSourceScript _ -> "DRep Script"
DRepHashSourceVerificationKey _ -> "DRep Key"
)
<> " "
<> what

0 comments on commit 61ff2f8

Please sign in to comment.