Skip to content

Commit

Permalink
Merge pull request #1007 from IntersectMBO/smelc/correct-registration…
Browse files Browse the repository at this point in the history
…-certificate-description

Disambiguate DRep being a key or a script in certificate descriptions
  • Loading branch information
smelc authored Jan 8, 2025
2 parents 0067de6 + 63a77dc commit 75e6fc2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "CertificateConway",
"description": "DRep Key Registration Certificate",
"description": "DRep Script Registration Certificate",
"cborHex": "84108201581c0000000000000000000000000000000000000000000000000000000300826964756d6d792d75726c582052e69500a92d80f2126c836a4903dc582006709f004cf7a28ed648f732dff8d2"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "CertificateConway",
"description": "DRep Retirement Certificate",
"description": "DRep Key Retirement Certificate",
"cborHex": "83118200581ceb09d5556a8bce421074e394d02c79ced96741657b4cf7ca8995294d1a000f4240"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "CertificateConway",
"description": "DRep Update Certificate",
"description": "DRep Key Update Certificate",
"cborHex": "83128200581ceb09d5556a8bce421074e394d02c79ced96741657b4cf7ca8995294d826964756d6d792d75726c582052e69500a92d80f2126c836a4903dc582006709f004cf7a28ed648f732dff8d2"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "CertificateConway",
"description": "DRep Update Certificate",
"description": "DRep Script Update Certificate",
"cborHex": "83128201581c8f33600845940d65bdbc7ea7a247a7997aa8558649128fa82c4c046882785e68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f63617264616e6f2d666f756e646174696f6e2f434950732f6d61737465722f4349502d303131392f6578616d706c65732f647265702e6a736f6e6c645820fecc1773db89b45557d82e07719c275f6877a6cadfd2469f4dc5a7df5b38b4a4"
}

0 comments on commit 75e6fc2

Please sign in to comment.