diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/DRep.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/DRep.hs index a1d3064a5..f4713ce06 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/DRep.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/DRep.hs @@ -66,7 +66,7 @@ data GovernanceDRepRetirementCertificateCmdArgs era data GovernanceDRepUpdateCertificateCmdArgs era = GovernanceDRepUpdateCertificateCmdArgs { eon :: !(ConwayEraOnwards era) - , drepVkeyHashSource :: !(VerificationKeyOrHashOrFile DRepKey) + , drepHashSource :: !DRepHashSource , mAnchor :: !(Maybe (L.Anchor (L.EraCrypto (ShelleyLedgerEra era)))) , outFile :: !(File () Out) } diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs index 0c8db9154..6eb5530fc 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs @@ -164,7 +164,7 @@ pUpdateCertificateCmd era = do ( fmap GovernanceDRepUpdateCertificateCmd $ conwayEraOnwardsConstraints w $ GovernanceDRepUpdateCertificateCmdArgs w - <$> pDRepVerificationKeyOrHashOrFile + <$> pDRepHashSource <*> pDRepMetadata <*> pOutputFile ) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs index 0c5f546c5..005c08c36 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs @@ -16,8 +16,6 @@ module Cardano.CLI.EraBased.Run.Governance.DRep where import Cardano.Api -import Cardano.Api.Ledger (Credential (KeyHashObj)) -import Cardano.Api.Shelley import qualified Cardano.CLI.EraBased.Commands.Governance.DRep as Cmd import qualified Cardano.CLI.EraBased.Run.Key as Key @@ -147,17 +145,15 @@ runGovernanceDRepUpdateCertificateCmd runGovernanceDRepUpdateCertificateCmd Cmd.GovernanceDRepUpdateCertificateCmdArgs { eon = w - , drepVkeyHashSource + , drepHashSource , mAnchor , outFile } = conwayEraOnwardsConstraints w $ do - DRepKeyHash drepKeyHash <- - firstExceptT GovernanceCmdKeyReadError $ - readVerificationKeyOrHashOrFile AsDRepKey drepVkeyHashSource - makeDrepUpdateCertificate (DRepUpdateRequirements w (KeyHashObj drepKeyHash)) mAnchor - & writeFileTextEnvelope outFile (Just "DRep Update Certificate") - & firstExceptT GovernanceCmdTextEnvWriteError . newExceptT + drepCredential <- modifyError GovernanceCmdKeyReadError $ readDRepCredential drepHashSource + let updateCertificate = makeDrepUpdateCertificate (DRepUpdateRequirements w drepCredential) mAnchor + firstExceptT GovernanceCmdTextEnvWriteError . newExceptT $ + writeFileTextEnvelope outFile (Just "DRep Update Certificate") updateCertificate runGovernanceDRepMetadataHashCmd :: () diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/DRep.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/DRep.hs index 8c82b6536..41e9482fe 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/DRep.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/DRep.hs @@ -296,6 +296,23 @@ hprop_golden_governance_drep_update_certificate_vkey_file = propertyOnce . H.mod ] H.diffFileVsGoldenFile outFile goldenFile + +-- | Execute me with: +-- @cabal test cardano-cli-golden --test-options '-p "/golden governance drep update certificate script hash/"'@ +hprop_golden_governance_drep_update_certificate_script_hash :: Property +hprop_golden_governance_drep_update_certificate_script_hash = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do + goldenFile <- H.note "test/cardano-cli-golden/files/golden/governance/drep/drep_update_certificate_script_hash.json" + outFile <- H.noteTempFile tempDir "drep-upd-cert.txt" + + void $ execCardanoCLI + [ "conway", "governance", "drep", "update-certificate" + , "--drep-script-hash", "8f33600845940d65bdbc7ea7a247a7997aa8558649128fa82c4c0468" + , "--drep-metadata-url", "https://raw.githubusercontent.com/cardano-foundation/CIPs/master/CIP-0119/examples/drep.jsonld" + , "--drep-metadata-hash", "fecc1773db89b45557d82e07719c275f6877a6cadfd2469f4dc5a7df5b38b4a4" + , "--out-file", outFile + ] + + H.diffFileVsGoldenFile outFile goldenFile -- | Execute me with: -- @cabal test cardano-cli-golden --test-options '-p "/golden verification key drep/"'@ diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_update_certificate_script_hash.json b/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_update_certificate_script_hash.json new file mode 100644 index 000000000..878010671 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_update_certificate_script_hash.json @@ -0,0 +1,5 @@ +{ + "type": "CertificateConway", + "description": "DRep Update Certificate", + "cborHex": "83128201581c8f33600845940d65bdbc7ea7a247a7997aa8558649128fa82c4c046882785e68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f63617264616e6f2d666f756e646174696f6e2f434950732f6d61737465722f4349502d303131392f6578616d706c65732f647265702e6a736f6e6c645820fecc1773db89b45557d82e07719c275f6877a6cadfd2469f4dc5a7df5b38b4a4" +} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli index a8f8ca908..c85e2a761 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -7003,7 +7003,8 @@ Usage: cardano-cli conway governance drep retirement-certificate Create a DRep retirement certificate. Usage: cardano-cli conway governance drep update-certificate - ( --drep-verification-key STRING + ( --drep-script-hash HASH + | --drep-verification-key STRING | --drep-verification-key-file FILE | --drep-key-hash HASH ) diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_drep_update-certificate.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_drep_update-certificate.cli index 28d8ef7c5..ffa0c98d6 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_drep_update-certificate.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_drep_update-certificate.cli @@ -1,5 +1,6 @@ Usage: cardano-cli conway governance drep update-certificate - ( --drep-verification-key STRING + ( --drep-script-hash HASH + | --drep-verification-key STRING | --drep-verification-key-file FILE | --drep-key-hash HASH ) @@ -10,6 +11,8 @@ Usage: cardano-cli conway governance drep update-certificate Create a DRep update certificate. Available options: + --drep-script-hash HASH DRep script hash (hex-encoded). Obtain it with + "cardano-cli hash script ...". --drep-verification-key STRING DRep verification key (Bech32 or hex-encoded). --drep-verification-key-file FILE