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

Disambiguate DRep being a key or a script in certificate descriptions #1007

Merged
merged 2 commits into from
Jan 8, 2025
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
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"
}
Loading