From 02d4cf657c79d94df60db83c8027219e77dd42db Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Tue, 23 Sep 2025 14:35:40 +0200 Subject: [PATCH 1/9] Propagate new api's experimental certificate type --- .../CLI/Compatible/StakeAddress/Run.hs | 7 +- .../CLI/EraBased/StakeAddress/Command.hs | 4 +- .../Cardano/CLI/EraBased/StakeAddress/Run.hs | 71 ++++++++++--------- .../Transaction/Internal/HashCheck.hs | 8 +-- .../Cardano/CLI/EraBased/Transaction/Run.hs | 28 ++++---- .../src/Cardano/CLI/Type/Error/TxCmdError.hs | 2 +- 6 files changed, 61 insertions(+), 59 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Run.hs b/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Run.hs index 0da6460c23..0aaba7c6cc 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Run.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Run.hs @@ -11,6 +11,7 @@ module Cardano.CLI.Compatible.StakeAddress.Run where import Cardano.Api +import Cardano.Api.Experimental qualified as Exp import Cardano.Api.Ledger qualified as L import Cardano.CLI.Compatible.Exception @@ -106,17 +107,17 @@ createStakeDelegationCertificate :: ShelleyBasedEra era -> StakeCredential -> Hash StakePoolKey - -> Certificate era + -> Exp.Certificate (ShelleyLedgerEra era) createStakeDelegationCertificate sbe stakeCredential stakePoolHash = do caseShelleyToBabbageOrConwayEraOnwards ( \w -> shelleyToBabbageEraConstraints w $ - ShelleyRelatedCertificate w $ + Exp.Certificate $ L.mkDelegStakeTxCert (toShelleyStakeCredential stakeCredential) (toLedgerHash stakePoolHash) ) ( \w -> conwayEraOnwardsConstraints w $ - ConwayCertificate w $ + Exp.Certificate $ L.mkDelegTxCert (toShelleyStakeCredential stakeCredential) (L.DelegStake (toLedgerHash stakePoolHash)) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Command.hs b/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Command.hs index 62a9eba0ac..c31e049ce6 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Command.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Command.hs @@ -42,13 +42,13 @@ data StakeAddressCmds era StakePoolKeyHashSource (File () Out) | StakeAddressStakeAndVoteDelegationCertificateCmd - (ConwayEraOnwards era) + (Exp.Era era) StakeIdentifier StakePoolKeyHashSource VoteDelegationTarget (File () Out) | StakeAddressVoteDelegationCertificateCmd - (ConwayEraOnwards era) + (Exp.Era era) StakeIdentifier VoteDelegationTarget (File () Out) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Run.hs b/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Run.hs index 99705417e1..38604b61cf 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Run.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Run.hs @@ -257,15 +257,15 @@ runStakeAddressStakeDelegationCertificateCmd era stakeVerifier poolVKeyOrHashOrF stakeCred <- getStakeCredentialFromIdentifier stakeVerifier - let certificate :: Certificate era = createStakeDelegationCertificate stakeCred poolStakeVKeyHash + let certificate :: Exp.Certificate (Exp.LedgerEra era) = createStakeDelegationCertificate stakeCred poolStakeVKeyHash fromEitherIOCli @(FileError ()) $ writeLazyByteStringFile outFp $ textEnvelopeToJSON (Just @TextEnvelopeDescr "Stake Delegation Certificate") certificate runStakeAddressStakeAndVoteDelegationCertificateCmd - :: () - => ConwayEraOnwards era + :: forall era e + . Exp.Era era -> StakeIdentifier -- ^ Delegator stake verification key, verification key file or script file. -> StakePoolKeyHashSource @@ -274,64 +274,67 @@ runStakeAddressStakeAndVoteDelegationCertificateCmd -- verification key hash. -> File () Out -> CIO e () -runStakeAddressStakeAndVoteDelegationCertificateCmd w stakeVerifier poolVKeyOrHashOrFile voteDelegationTarget outFp = - conwayEraOnwardsConstraints w $ do - StakePoolKeyHash poolStakeVKeyHash <- getHashFromStakePoolKeyHashSource poolVKeyOrHashOrFile +runStakeAddressStakeAndVoteDelegationCertificateCmd w stakeVerifier poolVKeyOrHashOrFile voteDelegationTarget outFp = do + StakePoolKeyHash poolStakeVKeyHash <- getHashFromStakePoolKeyHashSource poolVKeyOrHashOrFile - stakeCredential <- - getStakeCredentialFromIdentifier stakeVerifier + stakeCredential <- + getStakeCredentialFromIdentifier stakeVerifier - drep <- - readVoteDelegationTarget voteDelegationTarget + drep <- + readVoteDelegationTarget voteDelegationTarget - let delegatee = L.DelegStakeVote poolStakeVKeyHash drep + let delegatee = L.DelegStakeVote poolStakeVKeyHash drep - let certificate = - ConwayCertificate w $ - L.mkDelegTxCert (toShelleyStakeCredential stakeCredential) delegatee + certificate :: Exp.Certificate (Exp.LedgerEra era) <- + return $ + obtainCommonConstraints w $ + Exp.Certificate $ + L.mkDelegTxCert (toShelleyStakeCredential stakeCredential) delegatee - fromEitherIOCli @(FileError ()) $ - writeLazyByteStringFile outFp $ + fromEitherIOCli @(FileError ()) $ + writeLazyByteStringFile outFp $ + obtainCommonConstraints w $ textEnvelopeToJSON (Just @TextEnvelopeDescr "Stake and Vote Delegation Certificate") certificate runStakeAddressVoteDelegationCertificateCmd - :: () - => ConwayEraOnwards era + :: forall era e + . Exp.Era era -> StakeIdentifier -- ^ Delegatee stake pool verification key or verification key file or -> VoteDelegationTarget -- ^ Delegatee stake pool verification key or verification key file or verification key hash. -> File () Out -> CIO e () -runStakeAddressVoteDelegationCertificateCmd w stakeVerifier voteDelegationTarget outFp = - conwayEraOnwardsConstraints w $ do - stakeCredential <- - getStakeCredentialFromIdentifier stakeVerifier +runStakeAddressVoteDelegationCertificateCmd w stakeVerifier voteDelegationTarget outFp = do + stakeCredential <- + getStakeCredentialFromIdentifier stakeVerifier - drep <- - readVoteDelegationTarget voteDelegationTarget + drep <- + readVoteDelegationTarget voteDelegationTarget - let delegatee = L.DelegVote drep + let delegatee = L.DelegVote drep - let certificate = - ConwayCertificate w $ + let certificate :: Exp.Certificate (Exp.LedgerEra era) = + obtainCommonConstraints w $ + Exp.Certificate $ L.mkDelegTxCert (toShelleyStakeCredential stakeCredential) delegatee - fromEitherIOCli @(FileError ()) - $ writeLazyByteStringFile - outFp - $ textEnvelopeToJSON (Just @TextEnvelopeDescr "Vote Delegation Certificate") certificate + fromEitherIOCli @(FileError ()) + $ writeLazyByteStringFile + outFp + $ obtainCommonConstraints w + $ textEnvelopeToJSON (Just @TextEnvelopeDescr "Vote Delegation Certificate") certificate createStakeDelegationCertificate :: forall era . Exp.IsEra era => StakeCredential -> Hash StakePoolKey - -> Certificate era + -> Exp.Certificate (Exp.LedgerEra era) createStakeDelegationCertificate stakeCredential (StakePoolKeyHash poolStakeVKeyHash) = do let w = convert $ Exp.useEra @era - conwayEraOnwardsConstraints w $ - ConwayCertificate (convert Exp.useEra) $ + obtainCommonConstraints w $ + Exp.Certificate $ L.mkDelegTxCert (toShelleyStakeCredential stakeCredential) (L.DelegStake poolStakeVKeyHash) runStakeAddressDeregistrationCertificateCmd diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Transaction/Internal/HashCheck.hs b/cardano-cli/src/Cardano/CLI/EraBased/Transaction/Internal/HashCheck.hs index 0171703ce2..9f7dfd702f 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Transaction/Internal/HashCheck.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Transaction/Internal/HashCheck.hs @@ -15,11 +15,11 @@ import Cardano.Api , convert , except , firstExceptT - , getAnchorDataFromCertificate , getAnchorDataFromGovernanceAction , shelleyBasedEraConstraints , withExceptT ) +import Cardano.Api.Experimental (obtainCommonConstraints) import Cardano.Api.Experimental qualified as Exp import Cardano.Api.Ledger qualified as L @@ -43,13 +43,13 @@ checkAnchorMetadataHash anchor = -- | Find references to anchor data and check the hashes are valid -- and they match the linked data. checkCertificateHashes - :: Exp.IsEra era => Exp.Certificate (Exp.LedgerEra era) -> ExceptT TxCmdError IO () + :: forall era. Exp.IsEra era => Exp.Certificate (Exp.LedgerEra era) -> ExceptT TxCmdError IO () checkCertificateHashes cert = do mAnchor <- withExceptT TxCmdPoolMetadataHashError $ except $ - getAnchorDataFromCertificate $ - Exp.convertToOldApiCertificate Exp.useEra cert + obtainCommonConstraints (Exp.useEra @era) $ + Exp.getAnchorDataFromCertificate Exp.useEra cert maybe (return mempty) checkAnchorMetadataHash mAnchor -- | Find references to anchor data in voting procedures and check the hashes are valid diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Transaction/Run.hs b/cardano-cli/src/Cardano/CLI/EraBased/Transaction/Run.hs index f2129ac5ba..ee4374b93f 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Transaction/Run.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Transaction/Run.hs @@ -176,10 +176,9 @@ runTransactionBuildCmd certsAndMaybeScriptWits <- sequence [ (,mSwit) - <$> ( fmap (Exp.convertToNewCertificate Exp.useEra) $ - fromEitherIOCli @(FileError TextEnvelopeError) $ - shelleyBasedEraConstraints eon $ - readFileTextEnvelope (File certFile) + <$> ( fromEitherIOCli @(FileError TextEnvelopeError) $ + obtainCommonConstraints currentEra $ + readFileTextEnvelope (File certFile) ) | (CertificateFile certFile, mSwit) <- certFilesAndMaybeScriptWits ] @@ -464,10 +463,9 @@ runTransactionBuildEstimateCmd -- TODO change type certsAndMaybeScriptWits <- sequence $ [ (,mSwit) - <$> ( fmap (Exp.convertToNewCertificate Exp.useEra) $ - shelleyBasedEraConstraints sbe $ - fromEitherIOCli $ - readFileTextEnvelope (File certFile) + <$> ( obtainCommonConstraints currentEra $ + fromEitherIOCli $ + readFileTextEnvelope (File certFile) ) | (CertificateFile certFile, mSwit :: Exp.AnyWitness (Exp.LedgerEra era)) <- certFilesAndMaybeScriptWits @@ -671,11 +669,10 @@ runTransactionBuildRawCmd certsAndMaybeScriptWits <- sequence [ (,mSwit) - <$> fmap - (Exp.convertToNewCertificate Exp.useEra) - ( fromEitherIOCli $ - readFileTextEnvelope (File certFile) - ) + <$> ( obtainCommonConstraints eon $ + fromEitherIOCli $ + readFileTextEnvelope (File certFile) + ) | (CertificateFile certFile, mSwit) <- certFilesAndMaybeScriptWits ] txBody <- @@ -914,7 +911,8 @@ constructTxBodyContent & setTxProtocolParams (BuildTxWith $ LedgerProtocolParameters . toShelleyLedgerPParamsShim Exp.useEra <$> mPparams) & setTxWithdrawals (TxWithdrawals sbe $ map convertWithdrawals withdrawals) - & setTxCertificates (Exp.mkTxCertificates certsAndMaybeScriptWits) + & setTxCertificates + (Exp.mkTxCertificates $ obtainCommonConstraints (Exp.useEra @era) certsAndMaybeScriptWits) & setTxUpdateProposal txUpdateProposal & setTxMintValue validatedMintValue & setTxScriptValidity validatedTxScriptValidity @@ -1031,7 +1029,7 @@ runTxBuild testEquality era nodeEra & hoistMaybe (TxCmdTxNodeEraMismatchError $ NodeEraMismatchError era nodeEra) - let certsToQuery = map (Exp.convertToOldApiCertificate Exp.useEra) $ fst <$> certsAndMaybeScriptWits + let certsToQuery = obtainCommonConstraints (Exp.useEra @era) (fst <$> certsAndMaybeScriptWits) (txEraUtxo, pparams, eraHistory, systemStart, stakePools, stakeDelegDeposits, drepDelegDeposits, _) <- lift ( executeLocalStateQueryExpr localNodeConnInfo Consensus.VolatileTip $ diff --git a/cardano-cli/src/Cardano/CLI/Type/Error/TxCmdError.hs b/cardano-cli/src/Cardano/CLI/Type/Error/TxCmdError.hs index 58213cc08e..83f5662d9d 100644 --- a/cardano-cli/src/Cardano/CLI/Type/Error/TxCmdError.hs +++ b/cardano-cli/src/Cardano/CLI/Type/Error/TxCmdError.hs @@ -63,7 +63,7 @@ data TxCmdError | -- Validation errors forall era. TxCmdTxGovDuplicateVotes (TxGovDuplicateVotes era) | forall era. TxCmdFeeEstimationError (TxFeeEstimationError era) - | TxCmdPoolMetadataHashError AnchorDataFromCertificateError + | TxCmdPoolMetadataHashError Exp.AnchorDataFromCertificateError | TxCmdHashCheckError L.Url HashCheckError | TxCmdUnregisteredStakeAddress !(Set StakeCredential) | forall era. TxCmdAlonzoEraOnwardsRequired !(CardanoEra era) From e0df02e6f2a982f9c88d2b3f19a35a41bd364d0d Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Tue, 23 Sep 2025 14:34:29 +0200 Subject: [PATCH 2/9] Update friendly rendering of certificates --- .../Cardano/CLI/Compatible/Json/Friendly.hs | 331 +++++++++--------- 1 file changed, 169 insertions(+), 162 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs b/cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs index 3b00ce8e9b..f6cc2f78b9 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs @@ -1,4 +1,5 @@ {-# LANGUAGE DataKinds #-} +{-# LANGUAGE EmptyCase #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} @@ -613,176 +614,182 @@ friendlyCertificates sbe = \case TxCertificatesNone -> Null TxCertificates _ cs -> array $ map (friendlyCertificate sbe . fst) $ toList cs -friendlyCertificate :: ShelleyBasedEra era -> Certificate era -> Aeson.Value +friendlyCertificate :: ShelleyBasedEra era -> Exp.Certificate (ShelleyLedgerEra era) -> Aeson.Value friendlyCertificate sbe = shelleyBasedEraConstraints sbe $ object . (: []) . renderCertificate sbe -renderCertificate :: ShelleyBasedEra era -> Certificate era -> (Aeson.Key, Aeson.Value) -renderCertificate sbe = \case - ShelleyRelatedCertificate _ c -> - shelleyBasedEraConstraints sbe $ - case c of - L.ShelleyTxCertDelegCert (L.ShelleyRegCert cred) -> - "stake address registration" .= cred - L.ShelleyTxCertDelegCert (L.ShelleyUnRegCert cred) -> - "stake address deregistration" .= cred - L.ShelleyTxCertDelegCert (L.ShelleyDelegCert cred poolId) -> - "stake address delegation" - .= object - [ "credential" .= cred - , "pool" .= poolId - ] - L.ShelleyTxCertPool (L.RetirePool poolId retirementEpoch) -> - "stake pool retirement" - .= object - [ "pool" .= StakePoolKeyHash poolId - , "epoch" .= retirementEpoch - ] - L.ShelleyTxCertPool (L.RegPool poolParams) -> - "stake pool registration" .= poolParams - L.ShelleyTxCertGenesisDeleg (L.GenesisDelegCert genesisKeyHash delegateKeyHash vrfKeyHash) -> - "genesis key delegation" - .= object - [ "genesis key hash" .= genesisKeyHash - , "delegate key hash" .= delegateKeyHash - , "VRF key hash" .= vrfKeyHash - ] - L.ShelleyTxCertMir (L.MIRCert pot target) -> - "MIR" - .= object - [ "pot" .= friendlyMirPot pot - , friendlyMirTarget sbe target - ] - ConwayCertificate w@ConwayEraOnwardsConway (cert :: L.ConwayTxCert (ShelleyLedgerEra ConwayEra)) -> - conwayEraOnwardsConstraints w $ - case cert of - L.RegDRepTxCert credential coin mAnchor -> - "Drep registration certificate" - .= object - [ "deposit" .= coin - , "certificate" .= conwayToObject w credential - , "anchor" .= mAnchor - ] - L.UnRegDRepTxCert credential coin -> - "Drep unregistration certificate" - .= object - [ "refund" .= coin - , "certificate" .= conwayToObject w credential - ] - L.AuthCommitteeHotKeyTxCert coldCred hotCred - | L.ScriptHashObj sh <- coldCred -> - "Cold committee authorization" - .= object - ["script hash" .= sh] - | L.ScriptHashObj sh <- hotCred -> - "Hot committee authorization" - .= object - ["script hash" .= sh] - | L.KeyHashObj ck@L.KeyHash{} <- coldCred - , L.KeyHashObj hk@L.KeyHash{} <- hotCred -> - "Constitutional committee member hot key registration" - .= object - [ "cold key hash" .= ck - , "hot key hash" .= hk - ] - L.ResignCommitteeColdTxCert cred anchor -> case cred of - L.ScriptHashObj sh -> - "Cold committee resignation" - .= object - [ "script hash" .= sh - , "anchor" .= anchor - ] - L.KeyHashObj ck@L.KeyHash{} -> - "Constitutional committee cold key resignation" - .= object - [ "cold key hash" .= ck - ] - L.RegTxCert stakeCredential -> - "Stake address registration" - .= object - [ "stake credential" .= stakeCredential - ] - L.UnRegTxCert stakeCredential -> - "Stake address deregistration" - .= object - [ "stake credential" .= stakeCredential - ] - L.RegDepositTxCert stakeCredential deposit -> - "Stake address registration" - .= object - [ "stake credential" .= stakeCredential - , "deposit" .= deposit - ] - L.UnRegDepositTxCert stakeCredential refund -> - "Stake address deregistration" - .= object - [ "stake credential" .= stakeCredential - , "refund" .= refund - ] - L.DelegTxCert stakeCredential delegatee -> - "Stake address delegation" - .= object - [ "stake credential" .= stakeCredential - , "delegatee" .= delegateeJson sbe delegatee - ] - L.RegDepositDelegTxCert stakeCredential delegatee deposit -> - "Stake address registration and delegation" - .= object - [ "stake credential" .= stakeCredential - , "delegatee" .= delegateeJson sbe delegatee - , "deposit" .= deposit - ] - L.RegPoolTxCert poolParams -> - "Pool registration" +renderCertificate + :: ShelleyBasedEra era -> Exp.Certificate (ShelleyLedgerEra era) -> (Aeson.Key, Aeson.Value) +renderCertificate sbe (Exp.Certificate c) = + case sbe of + ShelleyBasedEraShelley -> renderShelleyCertificate sbe c + ShelleyBasedEraAllegra -> renderShelleyCertificate sbe c + ShelleyBasedEraMary -> renderShelleyCertificate sbe c + ShelleyBasedEraAlonzo -> renderShelleyCertificate sbe c + ShelleyBasedEraBabbage -> renderShelleyCertificate sbe c + ShelleyBasedEraConway -> renderConwayCertificate c + ShelleyBasedEraDijkstra -> error "renderCertificate: TODO Dijkstra era not supported" + +renderDrepCredential + :: () + => L.Credential 'L.DRepRole + -> Aeson.Value +renderDrepCredential = + object . \case + L.ScriptHashObj sHash -> ["scriptHash" .= sHash] + L.KeyHashObj keyHash -> ["keyHash" .= keyHash] + +delegateeJson + :: L.Delegatee + -> Aeson.Value +delegateeJson = + object . \case + L.DelegStake hk@L.KeyHash{} -> + [ "delegatee type" .= String "stake" + , "key hash" .= hk + ] + L.DelegVote drep -> do + ["delegatee type" .= String "vote", "DRep" .= drep] + L.DelegStakeVote kh drep -> + [ "delegatee type" .= String "stake vote" + , "key hash" .= kh + , "DRep" .= drep + ] + +renderShelleyCertificate + :: ShelleyBasedEra era -> Ledger.ShelleyTxCert (ShelleyLedgerEra era) -> (Aeson.Key, Aeson.Value) +renderShelleyCertificate sbe c = + case c of + L.ShelleyTxCertDelegCert (L.ShelleyRegCert cred) -> + "stake address registration" .= cred + L.ShelleyTxCertDelegCert (L.ShelleyUnRegCert cred) -> + "stake address deregistration" .= cred + L.ShelleyTxCertDelegCert (L.ShelleyDelegCert cred poolId) -> + "stake address delegation" + .= object + [ "credential" .= cred + , "pool" .= poolId + ] + L.ShelleyTxCertPool (L.RetirePool poolId retirementEpoch) -> + "stake pool retirement" + .= object + [ "pool" .= StakePoolKeyHash poolId + , "epoch" .= retirementEpoch + ] + L.ShelleyTxCertPool (L.RegPool poolParams) -> + "stake pool registration" .= poolParams + L.ShelleyTxCertGenesisDeleg (L.GenesisDelegCert genesisKeyHash delegateKeyHash vrfKeyHash) -> + "genesis key delegation" + .= object + [ "genesis key hash" .= genesisKeyHash + , "delegate key hash" .= delegateKeyHash + , "VRF key hash" .= vrfKeyHash + ] + L.ShelleyTxCertMir (L.MIRCert pot target) -> + "MIR" + .= object + [ "pot" .= friendlyMirPot pot + , friendlyMirTarget sbe target + ] + +renderConwayCertificate + :: Ledger.ConwayTxCert (ShelleyLedgerEra ConwayEra) -> (Aeson.Key, Aeson.Value) +renderConwayCertificate cert = + case cert of + L.RegDRepTxCert credential coin mAnchor -> + "Drep registration certificate" + .= object + [ "deposit" .= coin + , "certificate" .= renderDrepCredential credential + , "anchor" .= mAnchor + ] + L.UnRegDRepTxCert credential coin -> + "Drep unregistration certificate" + .= object + [ "refund" .= coin + , "certificate" .= renderDrepCredential credential + ] + L.AuthCommitteeHotKeyTxCert coldCred hotCred + | L.ScriptHashObj sh <- coldCred -> + "Cold committee authorization" .= object - [ "pool params" .= poolParams - ] - L.RetirePoolTxCert kh@L.KeyHash{} epoch -> - "Pool retirement" + ["script hash" .= sh] + | L.ScriptHashObj sh <- hotCred -> + "Hot committee authorization" .= object - [ "stake pool key hash" .= kh - , "epoch" .= epoch - ] - L.UpdateDRepTxCert drepCredential mbAnchor -> - "Drep certificate update" + ["script hash" .= sh] + | L.KeyHashObj ck@L.KeyHash{} <- coldCred + , L.KeyHashObj hk@L.KeyHash{} <- hotCred -> + "Constitutional committee member hot key registration" .= object - [ "Drep credential" .= drepCredential - , "anchor " .= mbAnchor + [ "cold key hash" .= ck + , "hot key hash" .= hk ] - -- TODO Dijkstra: What's missing here? - _ -> error "renderCertificate: TODO Dijkstra impossible" - ConwayCertificate ConwayEraOnwardsDijkstra _ -> - error "renderCertificate: TODO Dijkstra era not supported" - where - conwayToObject - :: () - => ConwayEraOnwards era - -> L.Credential 'L.DRepRole - -> Aeson.Value - conwayToObject w' = - conwayEraOnwardsConstraints w' $ - object . \case - L.ScriptHashObj sHash -> ["scriptHash" .= sHash] - L.KeyHashObj keyHash -> ["keyHash" .= keyHash] - - delegateeJson - :: ShelleyBasedEra era - -> L.Delegatee - -> Aeson.Value - delegateeJson _ = - object . \case - L.DelegStake hk@L.KeyHash{} -> - [ "delegatee type" .= String "stake" - , "key hash" .= hk - ] - L.DelegVote drep -> do - ["delegatee type" .= String "vote", "DRep" .= drep] - L.DelegStakeVote kh drep -> - [ "delegatee type" .= String "stake vote" - , "key hash" .= kh - , "DRep" .= drep - ] + L.ResignCommitteeColdTxCert cred anchor -> case cred of + L.ScriptHashObj sh -> + "Cold committee resignation" + .= object + [ "script hash" .= sh + , "anchor" .= anchor + ] + L.KeyHashObj ck@L.KeyHash{} -> + "Constitutional committee cold key resignation" + .= object + [ "cold key hash" .= ck + ] + L.RegTxCert stakeCredential -> + "Stake address registration" + .= object + [ "stake credential" .= stakeCredential + ] + L.UnRegTxCert stakeCredential -> + "Stake address deregistration" + .= object + [ "stake credential" .= stakeCredential + ] + L.RegDepositTxCert stakeCredential deposit -> + "Stake address registration" + .= object + [ "stake credential" .= stakeCredential + , "deposit" .= deposit + ] + L.UnRegDepositTxCert stakeCredential refund -> + "Stake address deregistration" + .= object + [ "stake credential" .= stakeCredential + , "refund" .= refund + ] + L.DelegTxCert stakeCredential delegatee -> + "Stake address delegation" + .= object + [ "stake credential" .= stakeCredential + , "delegatee" .= delegateeJson delegatee + ] + L.RegDepositDelegTxCert stakeCredential delegatee deposit -> + "Stake address registration and delegation" + .= object + [ "stake credential" .= stakeCredential + , "delegatee" .= delegateeJson delegatee + , "deposit" .= deposit + ] + L.RegPoolTxCert poolParams -> + "Pool registration" + .= object + [ "pool params" .= poolParams + ] + L.RetirePoolTxCert kh@L.KeyHash{} epoch -> + "Pool retirement" + .= object + [ "stake pool key hash" .= kh + , "epoch" .= epoch + ] + L.UpdateDRepTxCert drepCredential mbAnchor -> + "Drep certificate update" + .= object + [ "Drep credential" .= drepCredential + , "anchor " .= mbAnchor + ] friendlyMirTarget :: ShelleyBasedEra era -> L.MIRTarget -> Aeson.Pair From a277ee412d524f50682e41294dedd03626aa9311 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Mon, 17 Nov 2025 11:23:33 -0400 Subject: [PATCH 3/9] Certificate deprecation changes --- .../CLI/Compatible/Governance/Command.hs | 1 - .../CLI/Compatible/Governance/Option.hs | 15 +-- .../Cardano/CLI/Compatible/Governance/Run.hs | 6 +- .../Cardano/CLI/Compatible/Json/Friendly.hs | 1 + cardano-cli/src/Cardano/CLI/Compatible/Run.hs | 4 +- .../CLI/Compatible/StakeAddress/Command.hs | 2 +- .../CLI/Compatible/StakeAddress/Option.hs | 10 +- .../CLI/Compatible/StakeAddress/Run.hs | 62 +++++----- .../Cardano/CLI/Compatible/StakePool/Run.hs | 26 ++--- .../CLI/EraBased/Governance/Committee/Run.hs | 53 +++++---- .../CLI/EraBased/Governance/DRep/Run.hs | 33 ++++-- .../GenesisKeyDelegationCertificate/Run.hs | 17 +-- .../Cardano/CLI/EraBased/Governance/Run.hs | 17 +-- .../CLI/EraBased/StakeAddress/Command.hs | 10 +- .../CLI/EraBased/StakeAddress/Option.hs | 4 +- .../Cardano/CLI/EraBased/StakeAddress/Run.hs | 110 ++++++++---------- .../src/Cardano/CLI/EraBased/StakePool/Run.hs | 34 ++---- 17 files changed, 192 insertions(+), 213 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/Compatible/Governance/Command.hs b/cardano-cli/src/Cardano/CLI/Compatible/Governance/Command.hs index 5459322276..d03319b3de 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/Governance/Command.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/Governance/Command.hs @@ -36,7 +36,6 @@ data CompatibleGovernanceCmds era Coin (File () Out) | CompatibleGenesisKeyDelegationCertificate - (ShelleyToBabbageEra era) (VerificationKeyOrHashOrFile GenesisKey) (VerificationKeyOrHashOrFile GenesisDelegateKey) (VerificationKeyOrHashOrFile VrfKey) diff --git a/cardano-cli/src/Cardano/CLI/Compatible/Governance/Option.hs b/cardano-cli/src/Cardano/CLI/Compatible/Governance/Option.hs index 068625842e..e9dfa2105c 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/Governance/Option.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/Governance/Option.hs @@ -43,7 +43,7 @@ pCompatibleGovernanceCmds sbe = ] ) [ pCreateMirCertificatesCmds sbe - , pGovernanceGenesisKeyDelegationCertificate sbe + , pGovernanceGenesisKeyDelegationCertificate , fmap CreateCompatibleProtocolParametersUpdateCmd <$> pGovernanceActionCmds sbe ] ) @@ -119,19 +119,16 @@ pUpdateProtocolParametersPreConway shelleyToBab = <*> pProtocolParametersUpdateGenesisKeys pGovernanceGenesisKeyDelegationCertificate - :: () - => ShelleyBasedEra era - -> Maybe (Parser (CompatibleGovernanceCmds era)) -pGovernanceGenesisKeyDelegationCertificate sbe = do - w <- forShelleyBasedEraMaybeEon sbe + :: Maybe (Parser (CompatibleGovernanceCmds era)) +pGovernanceGenesisKeyDelegationCertificate = do pure $ Opt.hsubparser $ commandWithMetavar "create-genesis-key-delegation-certificate" $ - Opt.info (parser w) $ + Opt.info parser $ Opt.progDesc "Create a genesis key delegation certificate" where - parser w = - CompatibleGenesisKeyDelegationCertificate w + parser = + CompatibleGenesisKeyDelegationCertificate <$> pGenesisVerificationKeyOrHashOrFile <*> pGenesisDelegateVerificationKeyOrHashOrFile <*> pVrfVerificationKeyOrHashOrFile diff --git a/cardano-cli/src/Cardano/CLI/Compatible/Governance/Run.hs b/cardano-cli/src/Cardano/CLI/Compatible/Governance/Run.hs index 646e1457eb..206a983b45 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/Governance/Run.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/Governance/Run.hs @@ -25,13 +25,13 @@ import Cardano.CLI.Type.Error.GovernanceActionsError import Data.Typeable (Typeable) -runCompatibleGovernanceCmds :: Typeable era => CompatibleGovernanceCmds era -> CIO e () +runCompatibleGovernanceCmds :: CompatibleGovernanceCmds era -> CIO e () runCompatibleGovernanceCmds = \case CreateCompatibleProtocolParametersUpdateCmd cmd -> runCompatibleGovernanceActionCreateProtocolParametersUpdateCmd cmd LatestCompatibleGovernanceCmds cmd -> runGovernanceCmds cmd - CompatibleGenesisKeyDelegationCertificate sta genVk genDelegVk vrfVk out -> - runGovernanceGenesisKeyDelegationCertificate sta genVk genDelegVk vrfVk out + CompatibleGenesisKeyDelegationCertificate genVk genDelegVk vrfVk out -> + runGovernanceGenesisKeyDelegationCertificate genVk genDelegVk vrfVk out CompatibleCreateMirCertificateStakeAddressesCmd w mirpot vKeys rewards out -> runGovernanceMIRCertificatePayStakeAddrs w mirpot vKeys rewards out CompatibleCreateMirCertificateTransferToReservesCmd w ll oFp -> diff --git a/cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs b/cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs index f6cc2f78b9..284f478681 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs @@ -790,6 +790,7 @@ renderConwayCertificate cert = [ "Drep credential" .= drepCredential , "anchor " .= mbAnchor ] + _ -> "unsupported certificate" .= String (T.pack $ show cert) friendlyMirTarget :: ShelleyBasedEra era -> L.MIRTarget -> Aeson.Pair diff --git a/cardano-cli/src/Cardano/CLI/Compatible/Run.hs b/cardano-cli/src/Cardano/CLI/Compatible/Run.hs index af37f2b1f8..4f4d3304f9 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/Run.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/Run.hs @@ -15,12 +15,10 @@ import Cardano.CLI.Compatible.StakeAddress.Run import Cardano.CLI.Compatible.StakePool.Run import Cardano.CLI.Compatible.Transaction.Run -import Data.Typeable (Typeable) - runAnyCompatibleCommand :: AnyCompatibleCommand -> CIO e () runAnyCompatibleCommand (AnyCompatibleCommand cmd) = runCompatibleCommand cmd -runCompatibleCommand :: Typeable era => CompatibleCommand era -> CIO e () +runCompatibleCommand :: CompatibleCommand era -> CIO e () runCompatibleCommand = \case CompatibleTransactionCmds txCmd -> runCompatibleTransactionCmd txCmd diff --git a/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Command.hs b/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Command.hs index cccb5f708a..4a6eb761bc 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Command.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Command.hs @@ -21,7 +21,7 @@ data CompatibleStakeAddressCmds era = CompatibleStakeAddressRegistrationCertificateCmd (ShelleyBasedEra era) StakeIdentifier - (Maybe (Featured ConwayEraOnwards era Coin)) + (Maybe Coin) -- ^ Deposit required in conway era (File () Out) | CompatibleStakeAddressStakeDelegationCertificateCmd diff --git a/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Option.hs b/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Option.hs index 7830a857b4..3baa8ab37e 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Option.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Option.hs @@ -41,7 +41,15 @@ pStakeAddressRegistrationCertificateCmd sbe = do Opt.info ( CompatibleStakeAddressRegistrationCertificateCmd sbe <$> pStakeIdentifier Nothing - <*> pFeatured (toCardanoEra sbe) pKeyRegistDeposit + <*> ( case sbe of + ShelleyBasedEraShelley -> pure Nothing + ShelleyBasedEraAllegra -> pure Nothing + ShelleyBasedEraMary -> pure Nothing + ShelleyBasedEraAlonzo -> pure Nothing + ShelleyBasedEraBabbage -> pure Nothing + ShelleyBasedEraConway -> Just <$> pKeyRegistDeposit + ShelleyBasedEraDijkstra -> Just <$> pKeyRegistDeposit + ) <*> pOutputFile ) desc diff --git a/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Run.hs b/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Run.hs index 0aaba7c6cc..48a76ffda6 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Run.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Run.hs @@ -10,14 +10,14 @@ module Cardano.CLI.Compatible.StakeAddress.Run ) where -import Cardano.Api +import Cardano.Api hiding (makeStakeAddressRegistrationCertificate) +import Cardano.Api.Compatible.Certificate import Cardano.Api.Experimental qualified as Exp import Cardano.Api.Ledger qualified as L import Cardano.CLI.Compatible.Exception import Cardano.CLI.Compatible.StakeAddress.Command import Cardano.CLI.Read -import Cardano.CLI.Type.Error.StakeAddressRegistrationError import Cardano.CLI.Type.Key runCompatibleStakeAddressCmds @@ -36,20 +36,17 @@ runCompatibleStakeAddressCmds = \case runStakeAddressRegistrationCertificateCmd :: () - => ShelleyBasedEra era + => forall era e + . ShelleyBasedEra era -> StakeIdentifier - -> Maybe (Featured ConwayEraOnwards era Lovelace) + -> Maybe L.Coin -- ^ Deposit required in conway era -> File () Out -> CIO e () runStakeAddressRegistrationCertificateCmd sbe stakeIdentifier mDeposit oFp = do stakeCred <- getStakeCredentialFromIdentifier stakeIdentifier - - req <- createRegistrationCertRequirements sbe stakeCred mDeposit - - let regCert = makeStakeAddressRegistrationCertificate req - + regCert <- createRegCert sbe stakeCred mDeposit fromEitherIOCli @(FileError ()) $ writeLazyByteStringFile oFp @@ -59,26 +56,35 @@ runStakeAddressRegistrationCertificateCmd sbe stakeIdentifier mDeposit oFp = do regCertDesc :: TextEnvelopeDescr regCertDesc = "Stake Address Registration Certificate" -createRegistrationCertRequirements - :: () - => ShelleyBasedEra era - -> StakeCredential - -> Maybe (Featured ConwayEraOnwards era Lovelace) - -- ^ Deposit required in conway era - -> CIO e (StakeAddressRequirements era) -createRegistrationCertRequirements sbe stakeCred mDeposit = - caseShelleyToBabbageOrConwayEraOnwards - (\stb -> pure $ StakeAddrRegistrationPreConway stb stakeCred) - ( \ceo -> do - case mDeposit of + createRegCert + :: ShelleyBasedEra era + -> StakeCredential + -> Maybe L.Coin + -> CIO e (Exp.Certificate (ShelleyLedgerEra era)) + createRegCert sbe' sCred mDep = + case sbe' of + ShelleyBasedEraShelley -> + pure $ makeStakeAddressRegistrationCertificate sCred + ShelleyBasedEraAllegra -> + pure $ makeStakeAddressRegistrationCertificate sCred + ShelleyBasedEraMary -> + pure $ makeStakeAddressRegistrationCertificate sCred + ShelleyBasedEraAlonzo -> + pure $ makeStakeAddressRegistrationCertificate sCred + ShelleyBasedEraBabbage -> + pure $ makeStakeAddressRegistrationCertificate sCred + ShelleyBasedEraConway -> + case mDep of Nothing -> - -- This case is made impossible by the parser, that distinguishes between Conway - -- and pre-Conway. - throwCliError StakeAddressRegistrationDepositRequired - Just (Featured _ dep) -> - pure $ StakeAddrRegistrationConway ceo dep stakeCred - ) - sbe + throwCliError @String "Deposit required for stake address registration certificate in Conway era" + Just dep -> + pure $ makeStakeAddressRegistrationCertificate $ StakeCredentialAndDeposit sCred dep + ShelleyBasedEraDijkstra -> + case mDep of + Nothing -> + throwCliError @String "Deposit required for stake address registration certificate in Dijkstra era" + Just dep -> + pure $ makeStakeAddressRegistrationCertificate $ StakeCredentialAndDeposit sCred dep runStakeAddressStakeDelegationCertificateCmd :: () diff --git a/cardano-cli/src/Cardano/CLI/Compatible/StakePool/Run.hs b/cardano-cli/src/Cardano/CLI/Compatible/StakePool/Run.hs index bd1fa1a0b1..99d76dcd2a 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/StakePool/Run.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/StakePool/Run.hs @@ -2,14 +2,16 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} module Cardano.CLI.Compatible.StakePool.Run ( runCompatibleStakePoolCmds ) where -import Cardano.Api -import Cardano.Api.Ledger qualified as L +import Cardano.Api hiding (makeStakePoolRegistrationCertificate) +import Cardano.Api.Compatible.Certificate +import Cardano.Api.Experimental qualified as Exp import Cardano.CLI.Compatible.Exception import Cardano.CLI.Compatible.StakePool.Command @@ -36,7 +38,7 @@ runStakePoolRegistrationCertificateCmd -> CIO e () runStakePoolRegistrationCertificateCmd CompatibleStakePoolRegistrationCertificateCmdArgs - { sbe + { sbe = sbe :: ShelleyBasedEra era , poolVerificationKeyOrFile , vrfVerificationKeyOrFile , poolPledge @@ -83,10 +85,9 @@ runStakePoolRegistrationCertificateCmd } let ledgerStakePoolParams = toShelleyPoolParams stakePoolParams - req = - createStakePoolRegistrationRequirements sbe $ - shelleyBasedEraConstraints sbe ledgerStakePoolParams - registrationCert = makeStakePoolRegistrationCertificate req + registrationCert = + makeStakePoolRegistrationCertificate ledgerStakePoolParams + :: Exp.Certificate (ShelleyLedgerEra era) mapM_ (fromExceptTCli . carryHashChecks) mMetadata @@ -98,14 +99,3 @@ runStakePoolRegistrationCertificateCmd where registrationCertDesc :: TextEnvelopeDescr registrationCertDesc = "Stake Pool Registration Certificate" - -createStakePoolRegistrationRequirements - :: () - => ShelleyBasedEra era - -> L.PoolParams - -> StakePoolRegistrationRequirements era -createStakePoolRegistrationRequirements sbe pparams = - caseShelleyToBabbageOrConwayEraOnwards - (`StakePoolRegistrationRequirementsPreConway` pparams) - (`StakePoolRegistrationRequirementsConwayOnwards` pparams) - sbe diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Governance/Committee/Run.hs b/cardano-cli/src/Cardano/CLI/EraBased/Governance/Committee/Run.hs index 38f1432b22..fddb2bdbe4 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Governance/Committee/Run.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Governance/Committee/Run.hs @@ -3,6 +3,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} module Cardano.CLI.EraBased.Governance.Committee.Run @@ -12,8 +13,19 @@ module Cardano.CLI.EraBased.Governance.Committee.Run ) where -import Cardano.Api -import Cardano.Api.Experimental (obtainCommonConstraints) +import Cardano.Api hiding + ( Certificate + , makeCommitteeColdkeyResignationCertificate + , makeCommitteeHotKeyAuthorizationCertificate + ) +import Cardano.Api.Experimental + ( Certificate + , Era + , LedgerEra + , makeCommitteeColdkeyResignationCertificate + , makeCommitteeHotKeyAuthorizationCertificate + , obtainCommonConstraints + ) import Cardano.CLI.Compatible.Exception import Cardano.CLI.EraBased.Governance.Committee.Command @@ -134,26 +146,26 @@ runGovernanceCommitteeKeyHash . verificationKeyHash runGovernanceCommitteeCreateHotKeyAuthorizationCertificate - :: () - => Cmd.GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era + :: Cmd.GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era -> CIO e () runGovernanceCommitteeCreateHotKeyAuthorizationCertificate Cmd.GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs - { Cmd.era = eon + { Cmd.era = (eon :: Era era) , Cmd.vkeyColdKeySource , Cmd.vkeyHotKeySource , Cmd.outFile = oFp - } = - obtainCommonConstraints eon $ do - hotCred <- - readVerificationKeySource unCommitteeHotKeyHash vkeyHotKeySource - coldCred <- - readVerificationKeySource unCommitteeColdKeyHash vkeyColdKeySource - fromEitherIOCli @(FileError ()) $ - makeCommitteeHotKeyAuthorizationCertificate - (CommitteeHotKeyAuthorizationRequirements (convert eon) coldCred hotCred) - & textEnvelopeToJSON (Just genKeyDelegCertDesc) - & writeLazyByteStringFile oFp + } = obtainCommonConstraints eon $ do + hotCred <- + readVerificationKeySource unCommitteeHotKeyHash vkeyHotKeySource + coldCred <- + readVerificationKeySource unCommitteeColdKeyHash vkeyColdKeySource + let cert = + makeCommitteeHotKeyAuthorizationCertificate coldCred hotCred + :: Certificate (LedgerEra era) + fromEitherIOCli @(FileError ()) $ + cert + & textEnvelopeToJSON (Just genKeyDelegCertDesc) + & writeLazyByteStringFile oFp where genKeyDelegCertDesc :: TextEnvelopeDescr genKeyDelegCertDesc = "Constitutional Committee Hot Key Registration Certificate" @@ -164,7 +176,7 @@ runGovernanceCommitteeColdKeyResignationCertificate -> CIO e () runGovernanceCommitteeColdKeyResignationCertificate Cmd.GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs - { Cmd.era + { Cmd.era = era :: Era era , Cmd.vkeyColdKeySource , Cmd.anchor , Cmd.outFile @@ -176,10 +188,11 @@ runGovernanceCommitteeColdKeyResignationCertificate mapM_ (fromExceptTCli . carryHashChecks) anchor - + let cert = + makeCommitteeColdkeyResignationCertificate coldVKeyCred (pcaAnchor <$> anchor) + :: Certificate (LedgerEra era) fromEitherIOCli @(FileError ()) $ - makeCommitteeColdkeyResignationCertificate - (CommitteeColdkeyResignationRequirements (convert era) coldVKeyCred (pcaAnchor <$> anchor)) + cert & textEnvelopeToJSON (Just genKeyDelegCertDesc) & writeLazyByteStringFile outFile where diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Governance/DRep/Run.hs b/cardano-cli/src/Cardano/CLI/EraBased/Governance/DRep/Run.hs index fae38e9a90..aa57f90781 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Governance/DRep/Run.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Governance/DRep/Run.hs @@ -14,7 +14,12 @@ module Cardano.CLI.EraBased.Governance.DRep.Run ) where -import Cardano.Api +import Cardano.Api hiding + ( Certificate + , makeDrepRegistrationCertificate + , makeDrepUnregistrationCertificate + , makeDrepUpdateCertificate + ) import Cardano.Api.Experimental qualified as Exp import Cardano.Api.Ledger qualified as L @@ -119,7 +124,7 @@ runGovernanceDRepRegistrationCertificateCmd -> CIO e () runGovernanceDRepRegistrationCertificateCmd Cmd.GovernanceDRepRegistrationCertificateCmdArgs - { era = w + { era = w :: Exp.Era era , drepHashSource , deposit , mAnchor @@ -131,11 +136,12 @@ runGovernanceDRepRegistrationCertificateCmd (fromExceptTCli . carryHashChecks) mAnchor - let req = DRepRegistrationRequirements (convert w) drepCred deposit - registrationCert = - makeDrepRegistrationCertificate - req + let registrationCert = + Exp.makeDrepRegistrationCertificate + drepCred + deposit (pcaAnchor <$> mAnchor) + :: Exp.Certificate (Exp.LedgerEra era) description = Just $ hashSourceToDescription drepHashSource "Registration Certificate" fromEitherIOCli @(FileError ()) $ @@ -148,14 +154,16 @@ runGovernanceDRepRetirementCertificateCmd -> CIO e () runGovernanceDRepRetirementCertificateCmd Cmd.GovernanceDRepRetirementCertificateCmdArgs - { era = w + { era = w :: Exp.Era era , drepHashSource , deposit , outFile } = Exp.obtainCommonConstraints w $ do drepCredential <- readDRepCredential drepHashSource - makeDrepUnregistrationCertificate - (DRepUnregistrationRequirements (convert w) drepCredential deposit) + let cert = + Exp.makeDrepUnregistrationCertificate drepCredential deposit + :: Exp.Certificate (Exp.LedgerEra era) + cert & writeFileTextEnvelope outFile (Just $ hashSourceToDescription drepHashSource "Retirement Certificate") @@ -167,7 +175,7 @@ runGovernanceDRepUpdateCertificateCmd -> CIO e () runGovernanceDRepUpdateCertificateCmd Cmd.GovernanceDRepUpdateCertificateCmdArgs - { era = w + { era = w :: Exp.Era era , drepHashSource , mAnchor , outFile @@ -177,9 +185,10 @@ runGovernanceDRepUpdateCertificateCmd mAnchor drepCredential <- readDRepCredential drepHashSource let updateCertificate = - makeDrepUpdateCertificate - (DRepUpdateRequirements (convert w) drepCredential) + Exp.makeDrepUpdateCertificate + drepCredential (pcaAnchor <$> mAnchor) + :: Exp.Certificate (Exp.LedgerEra era) fromExceptTCli . newExceptT $ writeFileTextEnvelope outFile diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Governance/GenesisKeyDelegationCertificate/Run.hs b/cardano-cli/src/Cardano/CLI/EraBased/Governance/GenesisKeyDelegationCertificate/Run.hs index 84729891b5..890a207582 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Governance/GenesisKeyDelegationCertificate/Run.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Governance/GenesisKeyDelegationCertificate/Run.hs @@ -9,24 +9,19 @@ module Cardano.CLI.EraBased.Governance.GenesisKeyDelegationCertificate.Run ) where -import Cardano.Api +import Cardano.Api hiding (makeGenesisKeyDelegationCertificate) +import Cardano.Api.Compatible.Certificate import Cardano.CLI.Compatible.Exception import Cardano.CLI.Type.Key -import Data.Typeable (Typeable) - runGovernanceGenesisKeyDelegationCertificate - :: forall era e - . Typeable era - => ShelleyToBabbageEra era - -> VerificationKeyOrHashOrFile GenesisKey + :: VerificationKeyOrHashOrFile GenesisKey -> VerificationKeyOrHashOrFile GenesisDelegateKey -> VerificationKeyOrHashOrFile VrfKey -> File () Out -> CIO e () runGovernanceGenesisKeyDelegationCertificate - stb genVkOrHashOrFp genDelVkOrHashOrFp vrfVkOrHashOrFp @@ -38,13 +33,11 @@ runGovernanceGenesisKeyDelegationCertificate vrfVkHash <- readVerificationKeyOrHashOrFile vrfVkOrHashOrFp - let req = GenesisKeyDelegationRequirements stb genesisVkHash genesisDelVkHash vrfVkHash - genKeyDelegCert = makeGenesisKeyDelegationCertificate req + let genKeyDelegCert = makeGenesisKeyDelegationCertificate genesisVkHash genesisDelVkHash vrfVkHash fromEitherIOCli @(FileError ()) $ writeLazyByteStringFile oFp $ - shelleyBasedEraConstraints (convert stb) $ - textEnvelopeToJSON (Just genKeyDelegCertDesc) genKeyDelegCert + textEnvelopeToJSON (Just genKeyDelegCertDesc) genKeyDelegCert where genKeyDelegCertDesc :: TextEnvelopeDescr genKeyDelegCertDesc = "Genesis Key Delegation Certificate" diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Governance/Run.hs b/cardano-cli/src/Cardano/CLI/EraBased/Governance/Run.hs index 1547bd3700..0a296e45b7 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Governance/Run.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Governance/Run.hs @@ -15,7 +15,8 @@ module Cardano.CLI.EraBased.Governance.Run ) where -import Cardano.Api +import Cardano.Api hiding (makeMIRCertificate) +import Cardano.Api.Compatible.Certificate import Cardano.Api.Ledger qualified as L import Cardano.CLI.Compatible.Exception @@ -44,9 +45,7 @@ runGovernanceCmds = \case runGovernanceVoteCmds cmds runGovernanceMIRCertificatePayStakeAddrs - :: forall era e - . Typeable era - => ShelleyToBabbageEra era + :: ShelleyToBabbageEra era -> L.MIRPot -> [StakeAddress] -- ^ Stake addresses @@ -70,9 +69,7 @@ runGovernanceMIRCertificatePayStakeAddrs w mirPot sAddrs rwdAmts oFp = do | (scred, rwdAmt) <- zip sCreds rwdAmts ] let mirCert = - makeMIRCertificate $ - MirCertificateRequirements w mirPot $ - shelleyToBabbageEraConstraints w mirTarget + makeMIRCertificate mirPot mirTarget sbe = convert w fromEitherIOCli @(FileError ()) $ @@ -84,16 +81,14 @@ runGovernanceMIRCertificatePayStakeAddrs w mirPot sAddrs rwdAmts oFp = do mirCertDesc = "Move Instantaneous Rewards Certificate" runGovernanceCreateMirCertificateTransferToReservesCmd - :: forall era e - . Typeable era - => ShelleyToBabbageEra era + :: ShelleyToBabbageEra era -> Lovelace -> File () Out -> CIO e () runGovernanceCreateMirCertificateTransferToReservesCmd w ll oFp = do let mirTarget = L.SendToOppositePotMIR ll - let mirCert = makeMIRCertificate $ MirCertificateRequirements w L.TreasuryMIR mirTarget + let mirCert = makeMIRCertificate L.TreasuryMIR mirTarget sbe = convert w fromEitherIOCli @(FileError ()) $ diff --git a/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Command.hs b/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Command.hs index c31e049ce6..a2170e9a49 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Command.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Command.hs @@ -34,7 +34,7 @@ data StakeAddressCmds era | StakeAddressRegistrationCertificateCmd (Exp.Era era) StakeIdentifier - (Maybe (Featured ConwayEraOnwards era Coin)) + Coin (File () Out) | StakeAddressStakeDelegationCertificateCmd (Exp.Era era) @@ -55,22 +55,22 @@ data StakeAddressCmds era | StakeAddressDeregistrationCertificateCmd (Exp.Era era) StakeIdentifier - (Maybe (Featured ConwayEraOnwards era Coin)) + Coin (File () Out) | StakeAddressRegistrationAndDelegationCertificateCmd - (ConwayEraOnwards era) + (Exp.Era era) StakeIdentifier StakePoolKeyHashSource Coin (File () Out) | StakeAddressRegistrationAndVoteDelegationCertificateCmd - (ConwayEraOnwards era) + (Exp.Era era) StakeIdentifier VoteDelegationTarget Coin (File () Out) | StakeAddressRegistrationStakeAndVoteDelegationCertificateCmd - (ConwayEraOnwards era) + (Exp.Era era) StakeIdentifier StakePoolKeyHashSource VoteDelegationTarget diff --git a/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Option.hs b/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Option.hs index 603bdc44d9..f26ea8ad70 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Option.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Option.hs @@ -93,7 +93,7 @@ pStakeAddressRegistrationCertificateCmd = do Opt.info ( StakeAddressRegistrationCertificateCmd Exp.useEra <$> pStakeIdentifier Nothing - <*> pFeatured Exp.useEra pKeyRegistDeposit + <*> pKeyRegistDeposit <*> pOutputFile ) desc @@ -109,7 +109,7 @@ pStakeAddressDeregistrationCertificateCmd = $ Opt.info ( StakeAddressDeregistrationCertificateCmd Exp.useEra <$> pStakeIdentifier Nothing - <*> pFeatured Exp.useEra pKeyRegistDeposit + <*> pKeyRegistDeposit <*> pOutputFile ) $ Opt.progDesc "Create a stake address deregistration certificate" diff --git a/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Run.hs b/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Run.hs index 38604b61cf..3423dc6714 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Run.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/StakeAddress/Run.hs @@ -20,7 +20,7 @@ module Cardano.CLI.EraBased.StakeAddress.Run ) where -import Cardano.Api +import Cardano.Api hiding (makeStakeAddressRegistrationCertificate) import Cardano.Api.Experimental (obtainCommonConstraints) import Cardano.Api.Experimental qualified as Exp import Cardano.Api.Ledger qualified as L @@ -31,7 +31,6 @@ import Cardano.CLI.EraIndependent.Key.Run qualified as Key import Cardano.CLI.Orphan () import Cardano.CLI.Read import Cardano.CLI.Type.Common -import Cardano.CLI.Type.Error.StakeAddressRegistrationError import Cardano.CLI.Type.Governance import Cardano.CLI.Type.Key @@ -55,8 +54,7 @@ runStakeAddressCmds = \case StakeAddressBuildCmd stakeVerifier nw mOutputFp -> runStakeAddressBuildCmd stakeVerifier nw mOutputFp StakeAddressRegistrationCertificateCmd era stakeIdentifier mDeposit outputFp -> - Exp.obtainCommonConstraints era $ - runStakeAddressRegistrationCertificateCmd stakeIdentifier mDeposit outputFp + runStakeAddressRegistrationCertificateCmd era stakeIdentifier mDeposit outputFp StakeAddressStakeDelegationCertificateCmd era stakeIdentifier @@ -82,9 +80,8 @@ runStakeAddressCmds = \case outputFp StakeAddressVoteDelegationCertificateCmd w stakeIdentifier voteDelegationTarget outputFp -> runStakeAddressVoteDelegationCertificateCmd w stakeIdentifier voteDelegationTarget outputFp - StakeAddressDeregistrationCertificateCmd era stakeIdentifier mDeposit outputFp -> - obtainCommonConstraints era $ - runStakeAddressDeregistrationCertificateCmd stakeIdentifier mDeposit outputFp + StakeAddressDeregistrationCertificateCmd era stakeIdentifier deposit outputFp -> + runStakeAddressDeregistrationCertificateCmd era stakeIdentifier deposit outputFp StakeAddressRegistrationAndDelegationCertificateCmd w stakeIdentifier @@ -198,47 +195,30 @@ runStakeAddressBuildCmd stakeVerifier network mOutputFp = do runStakeAddressRegistrationCertificateCmd :: forall era e - . Exp.IsEra era - => StakeIdentifier - -> Maybe (Featured ConwayEraOnwards era Lovelace) + . Exp.Era era + -> StakeIdentifier + -> Lovelace -- ^ Deposit required in conway era -> File () Out -> CIO e () -runStakeAddressRegistrationCertificateCmd stakeIdentifier mDeposit oFp = do - let sbe = convert $ Exp.useEra @era +runStakeAddressRegistrationCertificateCmd era stakeIdentifier deposit oFp = do stakeCred <- - getStakeCredentialFromIdentifier stakeIdentifier + getStakeCredentialFromIdentifier + stakeIdentifier - req <- - fromEitherCli $ - createRegistrationCertRequirements stakeCred mDeposit - - let regCert = makeStakeAddressRegistrationCertificate req + let regCert = + obtainCommonConstraints era $ + Exp.makeStakeAddressRegistrationCertificate stakeCred deposit + :: Exp.Certificate (Exp.LedgerEra era) fromEitherIOCli @(FileError ()) $ writeLazyByteStringFile oFp $ - shelleyBasedEraConstraints sbe $ + obtainCommonConstraints era $ textEnvelopeToJSON (Just regCertDesc) regCert where regCertDesc :: TextEnvelopeDescr regCertDesc = "Stake Address Registration Certificate" -createRegistrationCertRequirements - :: Exp.IsEra era - => StakeCredential - -> Maybe (Featured ConwayEraOnwards era Lovelace) - -- ^ Deposit required in conway era - -> Either StakeAddressRegistrationError (StakeAddressRequirements era) -createRegistrationCertRequirements stakeCred mDeposit = - do - case mDeposit of - Nothing -> - -- This case is made impossible by the parser, that distinguishes between Conway - -- and pre-Conway. - throwError StakeAddressRegistrationDepositRequired - Just (Featured _ dep) -> - pure $ StakeAddrRegistrationConway (convert Exp.useEra) dep stakeCred - runStakeAddressStakeDelegationCertificateCmd :: forall era e . Exp.IsEra era @@ -339,42 +319,40 @@ createStakeDelegationCertificate stakeCredential (StakePoolKeyHash poolStakeVKey runStakeAddressDeregistrationCertificateCmd :: forall era e - . Exp.IsEra era - => StakeIdentifier - -> Maybe (Featured ConwayEraOnwards era Lovelace) + . Exp.Era era + -> StakeIdentifier + -> Lovelace -- ^ Deposit required in conway era -> File () Out -> CIO e () -runStakeAddressDeregistrationCertificateCmd stakeVerifier mDeposit oFp = do - let sbe = convert $ Exp.useEra @era +runStakeAddressDeregistrationCertificateCmd era stakeVerifier deposit oFp = do stakeCred <- getStakeCredentialFromIdentifier stakeVerifier - req <- - fromEitherCli $ - createRegistrationCertRequirements stakeCred mDeposit - - let deRegCert = makeStakeAddressUnregistrationCertificate req + let deRegCert = + obtainCommonConstraints era $ + Exp.makeStakeAddressUnregistrationCertificate stakeCred deposit + :: Exp.Certificate (Exp.LedgerEra era) fromEitherIOCli @(FileError ()) $ writeLazyByteStringFile oFp $ - shelleyBasedEraConstraints sbe $ + obtainCommonConstraints era $ textEnvelopeToJSON (Just deregCertDesc) deRegCert where deregCertDesc :: TextEnvelopeDescr deregCertDesc = "Stake Address Deregistration Certificate" runStakeAddressRegistrationAndDelegationCertificateCmd - :: () - => ConwayEraOnwards era + :: forall era e + . Exp.Era era -> StakeIdentifier -> StakePoolKeyHashSource -- ^ Delegatee stake pool verification key or verification key file or id -> Lovelace -> File () Out -> CIO e () -runStakeAddressRegistrationAndDelegationCertificateCmd w stakeVerifier poolVKeyOrHashOrFile deposit outFp = - conwayEraOnwardsConstraints w $ do +runStakeAddressRegistrationAndDelegationCertificateCmd era stakeVerifier poolVKeyOrHashOrFile deposit outFp = + do StakePoolKeyHash poolStakeVKeyHash <- getHashFromStakePoolKeyHashSource poolVKeyOrHashOrFile stakeCred <- @@ -382,24 +360,28 @@ runStakeAddressRegistrationAndDelegationCertificateCmd w stakeVerifier poolVKeyO let delegatee = L.DelegStake poolStakeVKeyHash - let certificate = makeStakeAddressAndDRepDelegationCertificate w stakeCred delegatee deposit + let certificate = + obtainCommonConstraints era $ + Exp.makeStakeAddressAndDRepDelegationCertificate stakeCred delegatee deposit + :: Exp.Certificate (Exp.LedgerEra era) fromEitherIOCli @(FileError ()) $ writeLazyByteStringFile outFp $ - textEnvelopeToJSON - (Just @TextEnvelopeDescr "Stake address registration and stake delegation certificate") - certificate + obtainCommonConstraints era $ + textEnvelopeToJSON + (Just @TextEnvelopeDescr "Stake address registration and stake delegation certificate") + certificate runStakeAddressRegistrationAndVoteDelegationCertificateCmd - :: () - => ConwayEraOnwards era + :: forall era e + . Exp.Era era -> StakeIdentifier -> VoteDelegationTarget -> Lovelace -> File () Out -> CIO e () runStakeAddressRegistrationAndVoteDelegationCertificateCmd w stakeVerifier voteDelegationTarget keydeposit outFp = - conwayEraOnwardsConstraints w $ do + obtainCommonConstraints w $ do stakeCred <- getStakeCredentialFromIdentifier stakeVerifier @@ -408,7 +390,9 @@ runStakeAddressRegistrationAndVoteDelegationCertificateCmd w stakeVerifier voteD let delegatee = L.DelegVote drep - let certificate = makeStakeAddressAndDRepDelegationCertificate w stakeCred delegatee keydeposit + let certificate = + Exp.makeStakeAddressAndDRepDelegationCertificate stakeCred delegatee keydeposit + :: Exp.Certificate (Exp.LedgerEra era) fromEitherIOCli @(FileError ()) $ writeLazyByteStringFile outFp $ @@ -417,8 +401,8 @@ runStakeAddressRegistrationAndVoteDelegationCertificateCmd w stakeVerifier voteD certificate runStakeAddressRegistrationStakeAndVoteDelegationCertificateCmd - :: () - => ConwayEraOnwards era + :: forall era e + . Exp.Era era -> StakeIdentifier -> StakePoolKeyHashSource -> VoteDelegationTarget @@ -426,7 +410,7 @@ runStakeAddressRegistrationStakeAndVoteDelegationCertificateCmd -> File () Out -> CIO e () runStakeAddressRegistrationStakeAndVoteDelegationCertificateCmd w stakeVerifier poolVKeyOrHashOrFile voteDelegationTarget keydeposit outFp = - conwayEraOnwardsConstraints w $ do + obtainCommonConstraints w $ do StakePoolKeyHash poolStakeVKeyHash <- getHashFromStakePoolKeyHashSource poolVKeyOrHashOrFile stakeCred <- @@ -437,7 +421,9 @@ runStakeAddressRegistrationStakeAndVoteDelegationCertificateCmd w stakeVerifier let delegatee = L.DelegStakeVote poolStakeVKeyHash drep - let certificate = makeStakeAddressAndDRepDelegationCertificate w stakeCred delegatee keydeposit + let certificate = + Exp.makeStakeAddressAndDRepDelegationCertificate stakeCred delegatee keydeposit + :: Exp.Certificate (Exp.LedgerEra era) fromEitherIOCli @(FileError ()) $ writeLazyByteStringFile outFp $ diff --git a/cardano-cli/src/Cardano/CLI/EraBased/StakePool/Run.hs b/cardano-cli/src/Cardano/CLI/EraBased/StakePool/Run.hs index df24db8909..b75dc982de 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/StakePool/Run.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/StakePool/Run.hs @@ -16,7 +16,11 @@ module Cardano.CLI.EraBased.StakePool.Run ) where -import Cardano.Api +import Cardano.Api hiding + ( Certificate + , makeStakePoolRegistrationCertificate + , makeStakePoolRetirementCertificate + ) import Cardano.Api.Experimental import Cardano.Api.Ledger qualified as L @@ -116,10 +120,7 @@ runStakePoolRegistrationCertificateCmd } let ledgerStakePoolParams = toShelleyPoolParams stakePoolParams - req = - createStakePoolRegistrationRequirements ledgerStakePoolParams - :: StakePoolRegistrationRequirements era - registrationCert = makeStakePoolRegistrationCertificate req + registrationCert = makeStakePoolRegistrationCertificate ledgerStakePoolParams :: Certificate (LedgerEra era) mapM_ (fromExceptTCli . carryHashChecks) mMetadata fromEitherIOCli @(FileError ()) $ @@ -129,18 +130,9 @@ runStakePoolRegistrationCertificateCmd registrationCertDesc :: TextEnvelopeDescr registrationCertDesc = "Stake Pool Registration Certificate" -createStakePoolRegistrationRequirements - :: forall era - . IsEra era - => L.PoolParams - -> StakePoolRegistrationRequirements era -createStakePoolRegistrationRequirements = - StakePoolRegistrationRequirementsConwayOnwards (convert useEra) - runStakePoolDeregistrationCertificateCmd :: forall era e - . IsEra era - => StakePoolDeregistrationCertificateCmdArgs era + . StakePoolDeregistrationCertificateCmdArgs era -> CIO e () runStakePoolDeregistrationCertificateCmd Cmd.StakePoolDeregistrationCertificateCmdArgs @@ -154,8 +146,8 @@ runStakePoolDeregistrationCertificateCmd stakePoolVerKey <- getVerificationKeyFromStakePoolVerificationKeySource poolVerificationKeyOrFile let stakePoolId' = anyStakePoolVerificationKeyHash stakePoolVerKey - req :: StakePoolRetirementRequirements era = createStakePoolRetirementRequirements stakePoolId' retireEpoch - retireCert = makeStakePoolRetirementCertificate req + retireCert = + makeStakePoolRetirementCertificate stakePoolId' retireEpoch :: Certificate (ShelleyLedgerEra era) fromEitherIOCli @(FileError ()) $ writeLazyByteStringFile outFile $ @@ -164,14 +156,6 @@ runStakePoolDeregistrationCertificateCmd retireCertDesc :: TextEnvelopeDescr retireCertDesc = "Stake Pool Retirement Certificate" -createStakePoolRetirementRequirements - :: IsEra era - => PoolId - -> L.EpochNo - -> StakePoolRetirementRequirements era -createStakePoolRetirementRequirements = - StakePoolRetirementRequirementsConwayOnwards (convert useEra) - runStakePoolIdCmd :: () => StakePoolIdCmdArgs era From 14f4f6393cc0eff19436da5743173776b4c4bb39 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Tue, 18 Nov 2025 15:33:00 -0400 Subject: [PATCH 4/9] Bump CHaP index and bump to cardano-api-10.20.0.0 --- cabal.project | 2 +- cardano-cli/cardano-cli.cabal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cabal.project b/cabal.project index 021dda39f5..7264a54f37 100644 --- a/cabal.project +++ b/cabal.project @@ -14,7 +14,7 @@ repository cardano-haskell-packages -- you need to run if you change them index-state: , hackage.haskell.org 2025-11-05T09:40:54Z - , cardano-haskell-packages 2025-11-05T10:16:35Z + , cardano-haskell-packages 2025-11-18T18:44:49Z packages: cardano-cli diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 522c502acb..88b5addfb6 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -241,7 +241,7 @@ library binary, bytestring, canonical-json, - cardano-api ^>=10.19.1, + cardano-api ^>= 10.20, cardano-binary, cardano-crypto, cardano-crypto-class ^>=2.2, From adde48387dbb944e2cc480e8de70dc43e7ff949c Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Wed, 19 Nov 2025 08:49:03 -0400 Subject: [PATCH 5/9] Bump nix flake --- cardano-cli/cardano-cli.cabal | 2 +- flake.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 88b5addfb6..406806e7b8 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -241,7 +241,7 @@ library binary, bytestring, canonical-json, - cardano-api ^>= 10.20, + cardano-api ^>=10.20, cardano-binary, cardano-crypto, cardano-crypto-class ^>=2.2, diff --git a/flake.lock b/flake.lock index ff42c2c5f4..67ceb4e40d 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1762339046, - "narHash": "sha256-Bjp3l29xTW7K0gjkN/IHxV5f75LCJ2IaSgmKYykPpU0=", + "lastModified": 1763493280, + "narHash": "sha256-YeNs/lYuuel8c6W52pRrjx3h6tHO8899imCA7pghLTM=", "owner": "intersectmbo", "repo": "cardano-haskell-packages", - "rev": "6a6a2f326d6884a37311d2f21ea510b9a7e549bd", + "rev": "8a623ee338469a5631052b88fc7af7b540895a43", "type": "github" }, "original": { From 270acc01d3442500635933627dde41e391636898 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Wed, 19 Nov 2025 09:44:49 -0400 Subject: [PATCH 6/9] Use legacyComparison --- .../CLI/Compatible/StakeAddress/Run.hs | 37 ++++++++++++------- .../Certificates/GenesisKeyDelegation.hs | 1 - .../Test/Cardano/CLI/Util.hs | 14 +++++-- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Run.hs b/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Run.hs index 48a76ffda6..1e96698c05 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Run.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/StakeAddress/Run.hs @@ -115,20 +115,29 @@ createStakeDelegationCertificate -> Hash StakePoolKey -> Exp.Certificate (ShelleyLedgerEra era) createStakeDelegationCertificate sbe stakeCredential stakePoolHash = do - caseShelleyToBabbageOrConwayEraOnwards - ( \w -> - shelleyToBabbageEraConstraints w $ - Exp.Certificate $ - L.mkDelegStakeTxCert (toShelleyStakeCredential stakeCredential) (toLedgerHash stakePoolHash) - ) - ( \w -> - conwayEraOnwardsConstraints w $ - Exp.Certificate $ - L.mkDelegTxCert - (toShelleyStakeCredential stakeCredential) - (L.DelegStake (toLedgerHash stakePoolHash)) - ) - sbe + case sbe of + ShelleyBasedEraShelley -> + shelleyToBabbage stakeCredential stakePoolHash + ShelleyBasedEraAllegra -> + shelleyToBabbage stakeCredential stakePoolHash + ShelleyBasedEraMary -> + shelleyToBabbage stakeCredential stakePoolHash + ShelleyBasedEraAlonzo -> + shelleyToBabbage stakeCredential stakePoolHash + ShelleyBasedEraBabbage -> + shelleyToBabbage stakeCredential stakePoolHash + ShelleyBasedEraConway -> + conwayOnwards stakeCredential stakePoolHash + ShelleyBasedEraDijkstra -> + conwayOnwards stakeCredential stakePoolHash where + shelleyToBabbage scred sPoolHash = + Exp.Certificate $ + L.mkDelegStakeTxCert (toShelleyStakeCredential scred) (toLedgerHash sPoolHash) + conwayOnwards scred sPoolHash = + Exp.Certificate $ + L.mkDelegTxCert + (toShelleyStakeCredential scred) + (L.DelegStake (toLedgerHash sPoolHash)) toLedgerHash :: Hash StakePoolKey -> L.KeyHash L.StakePool toLedgerHash (StakePoolKeyHash poolStakeVKeyHash) = poolStakeVKeyHash diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegation.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegation.hs index 001f75a5c1..2824bf46e0 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegation.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegation.hs @@ -106,7 +106,6 @@ hprop_golden_shelleyGenesisKeyDelegationCertificate = ] H.assertFilesExist [genesisKeyDelegCertFilePath] - let certificateType = cardanoEraConstraints era $ textEnvelopeTypeInEra era AsCertificate checkTextEnvelopeFormat diff --git a/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Util.hs b/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Util.hs index 353af66941..c0f2cd4194 100644 --- a/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Util.hs +++ b/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Util.hs @@ -28,7 +28,7 @@ import Cardano.Api import Cardano.CLI.Read -import Control.Monad (when) +import Control.Monad import Control.Monad.Catch hiding (bracket_) import Control.Monad.Morph (hoist) import Control.Monad.Trans.Resource (ResourceT, runResourceT) @@ -200,8 +200,16 @@ checkTextEnvelopeFormat tve reference created = GHC.withFrozenCallStack $ do typeTitleEquivalence (TextEnvelope refType refTitle _) (TextEnvelope createdType createdTitle _) = GHC.withFrozenCallStack $ do - equivalence refType createdType - equivalence refTitle createdTitle + case expectTextEnvelopeOfType refType createdType of + Right () -> equivalence refTitle createdTitle + Left typeErr -> + failWithCustom GHC.callStack Nothing . (docToString . prettyError) $ typeErr + +-- TODO: Expose from cardano-api +expectTextEnvelopeOfType :: TextEnvelopeType -> TextEnvelopeType -> Either TextEnvelopeError () +expectTextEnvelopeOfType expectedType actualType = + unless (expectedType `legacyComparison` actualType) $ + Left (TextEnvelopeTypeError [expectedType] actualType) checkTxCddlFormat :: (MonadTest m, MonadIO m, HasCallStack) From 18ce549be229f3944bbd4243eb364b681c9e79b6 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Wed, 19 Nov 2025 15:43:23 -0400 Subject: [PATCH 7/9] Replace checkTextEnvelopeFormat with diffFileVsGoldenFile --- .../Test/Golden/Governance/Committee.hs | 4 ++-- .../Certificates/GenesisKeyDelegation.hs | 18 ++---------------- .../Test/Cardano/CLI/Util.hs | 15 +++++++++------ 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Committee.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Committee.hs index 809de13151..0e07786d71 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Committee.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Committee.hs @@ -116,7 +116,7 @@ hprop_golden_governance_CommitteeCreateHotKeyAuthorizationCertificate = ] assertHasMappings - [ ("type", "CertificateConway") + [ ("type", "Certificate") , ("description", "Constitutional Committee Hot Key Registration Certificate") ] certFile @@ -156,7 +156,7 @@ hprop_golden_governance_CommitteeCreateColdKeyResignationCertificate = ] assertHasMappings - [ ("type", "CertificateConway") + [ ("type", "Certificate") , ("description", "Constitutional Committee Cold Key Resignation Certificate") ] certFile diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegation.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegation.hs index 2824bf46e0..5228c7c981 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegation.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegation.hs @@ -2,26 +2,16 @@ module Test.Golden.Shelley.TextEnvelope.Certificates.GenesisKeyDelegation where -import Cardano.Api - ( AsType (..) - , CardanoEra (..) - , cardanoEraConstraints - , textEnvelopeTypeInEra - ) - import Control.Monad (void) import Test.Cardano.CLI.Util import Hedgehog (Property) -import Hedgehog.Extras.Test.Base qualified as H -import Hedgehog.Extras.Test.File qualified as H +import Hedgehog.Extras qualified as H hprop_golden_shelleyGenesisKeyDelegationCertificate :: Property hprop_golden_shelleyGenesisKeyDelegationCertificate = watchdogProp . propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do - let era = BabbageEra - -- Reference certificate referenceCertificateFilePath <- noteInputFile $ @@ -106,9 +96,5 @@ hprop_golden_shelleyGenesisKeyDelegationCertificate = ] H.assertFilesExist [genesisKeyDelegCertFilePath] - let certificateType = cardanoEraConstraints era $ textEnvelopeTypeInEra era AsCertificate - checkTextEnvelopeFormat - certificateType - referenceCertificateFilePath - genesisKeyDelegCertFilePath + H.diffFileVsGoldenFile genesisKeyDelegCertFilePath referenceCertificateFilePath diff --git a/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Util.hs b/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Util.hs index c0f2cd4194..a5200706db 100644 --- a/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Util.hs +++ b/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Util.hs @@ -175,7 +175,9 @@ checkTextEnvelopeFormat :: (MonadTest m, MonadIO m, HasCallStack) => TextEnvelopeType -> FilePath + -- ^ On-disk reference/golden file -> FilePath + -- ^ Newly created file -> m () checkTextEnvelopeFormat tve reference created = GHC.withFrozenCallStack $ do eRefTextEnvelope <- H.evalIO $ readTextEnvelopeOfTypeFromFile tve reference @@ -195,21 +197,22 @@ checkTextEnvelopeFormat tve reference created = GHC.withFrozenCallStack $ do return refTextEnvelope Left fileErr -> failWithCustom GHC.callStack Nothing . (docToString . prettyError) $ fileErr - + -- NB: The created type is what is defined in the particulr `HasTextEnvelope` instance. typeTitleEquivalence :: (MonadTest m, HasCallStack) => TextEnvelope -> TextEnvelope -> m () typeTitleEquivalence - (TextEnvelope refType refTitle _) + (TextEnvelope onDiskRefType refTitle _) (TextEnvelope createdType createdTitle _) = GHC.withFrozenCallStack $ do - case expectTextEnvelopeOfType refType createdType of + case expectTextEnvelopeOfType createdType onDiskRefType of Right () -> equivalence refTitle createdTitle Left typeErr -> failWithCustom GHC.callStack Nothing . (docToString . prettyError) $ typeErr -- TODO: Expose from cardano-api expectTextEnvelopeOfType :: TextEnvelopeType -> TextEnvelopeType -> Either TextEnvelopeError () -expectTextEnvelopeOfType expectedType actualType = - unless (expectedType `legacyComparison` actualType) $ - Left (TextEnvelopeTypeError [expectedType] actualType) +expectTextEnvelopeOfType createdType onDiskRefType = + unless (createdType == onDiskRefType) $ + unless (createdType `legacyComparison` onDiskRefType) $ + Left (TextEnvelopeTypeError [createdType] onDiskRefType) checkTxCddlFormat :: (MonadTest m, MonadIO m, HasCallStack) From 885979663c13d122c1c2c377c2aa3af567172396 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Wed, 19 Nov 2025 15:45:49 -0400 Subject: [PATCH 8/9] Update golden files as we are using the new Certificate type --- cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs | 1 - .../golden/governance/drep/drep_registration_certificate.json | 2 +- .../governance/drep/drep_registration_certificate_script.json | 2 +- .../files/golden/governance/drep/drep_retirement_cert | 2 +- .../files/golden/governance/drep/drep_update_certificate.json | 2 +- .../governance/drep/drep_update_certificate_script_hash.json | 2 +- .../golden/governance/stakeaddress/alwaysAbstainDeleg.cert | 2 +- .../golden/governance/stakeaddress/noConfidenceDeleg.cert | 2 +- .../governance/stakeaddress/poolAndAlwaysAbstainDeleg.cert | 2 +- .../golden/governance/stakeaddress/poolAndDrepVkeyDeleg.cert | 2 +- .../governance/stakeaddress/poolAndNoConfidenceDeleg.cert | 2 +- .../stakeaddress/registerAddressDelegateToDrep.cert | 2 +- .../stakeaddress/registerAddressDelegateToPool.cert | 2 +- .../stakeaddress/registerAddressDelegateToPoolAndDrep.cert | 2 +- .../cardano-cli-golden/files/golden/shelley/dereg-cert-1.json | 2 +- .../cardano-cli-golden/files/golden/shelley/dereg-cert-2.json | 2 +- .../files/golden/shelley/reg-certificate-extended.json | 2 +- .../files/golden/shelley/reg-certificate.json | 2 +- .../files/golden/shelley/stake-address/reg-certificate-1.json | 2 +- .../files/golden/shelley/stake-address/reg-certificate-2.json | 2 +- .../golden/shelley/stake-address/script-reg-certificate.json | 2 +- .../shelley/certificates/genesis_key_delegation_certificate | 4 ++-- 22 files changed, 22 insertions(+), 23 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs b/cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs index 284f478681..0e75e77648 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs @@ -1,5 +1,4 @@ {-# LANGUAGE DataKinds #-} -{-# LANGUAGE EmptyCase #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_registration_certificate.json b/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_registration_certificate.json index f3c6fd0b4e..a952b4c81b 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_registration_certificate.json +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_registration_certificate.json @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "DRep Key Registration Certificate", "cborHex": "84108200581ceb09d5556a8bce421074e394d02c79ced96741657b4cf7ca8995294d00826964756d6d792d75726c582052e69500a92d80f2126c836a4903dc582006709f004cf7a28ed648f732dff8d2" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_registration_certificate_script.json b/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_registration_certificate_script.json index 011be4033a..0dbf0c9866 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_registration_certificate_script.json +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_registration_certificate_script.json @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "DRep Script Registration Certificate", "cborHex": "84108201581c0000000000000000000000000000000000000000000000000000000300826964756d6d792d75726c582052e69500a92d80f2126c836a4903dc582006709f004cf7a28ed648f732dff8d2" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_retirement_cert b/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_retirement_cert index a98aaf5eb0..2d638493fa 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_retirement_cert +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_retirement_cert @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "DRep Key Retirement Certificate", "cborHex": "83118200581ceb09d5556a8bce421074e394d02c79ced96741657b4cf7ca8995294d1a000f4240" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_update_certificate.json b/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_update_certificate.json index 52d437d2b9..e3f50eadcd 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_update_certificate.json +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/drep/drep_update_certificate.json @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "DRep Key Update Certificate", "cborHex": "83128200581ceb09d5556a8bce421074e394d02c79ced96741657b4cf7ca8995294d826964756d6d792d75726c582052e69500a92d80f2126c836a4903dc582006709f004cf7a28ed648f732dff8d2" } 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 index e76d48dd00..121023a131 100644 --- 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 @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "DRep Script Update Certificate", "cborHex": "83128201581c8f33600845940d65bdbc7ea7a247a7997aa8558649128fa82c4c046882785e68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f63617264616e6f2d666f756e646174696f6e2f434950732f6d61737465722f4349502d303131392f6578616d706c65732f647265702e6a736f6e6c645820fecc1773db89b45557d82e07719c275f6877a6cadfd2469f4dc5a7df5b38b4a4" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/alwaysAbstainDeleg.cert b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/alwaysAbstainDeleg.cert index 5a3e763092..350a091e68 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/alwaysAbstainDeleg.cert +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/alwaysAbstainDeleg.cert @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "Vote Delegation Certificate", "cborHex": "83098200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab018102" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/noConfidenceDeleg.cert b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/noConfidenceDeleg.cert index ec66a28ef3..751e6538f2 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/noConfidenceDeleg.cert +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/noConfidenceDeleg.cert @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "Vote Delegation Certificate", "cborHex": "83098200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab018103" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndAlwaysAbstainDeleg.cert b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndAlwaysAbstainDeleg.cert index 26ebf5c581..eb25c3a88a 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndAlwaysAbstainDeleg.cert +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndAlwaysAbstainDeleg.cert @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "Stake and Vote Delegation Certificate", "cborHex": "840a8200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab01581cc27cf021914a2b3bcb286d3d741979083422378c577fe757702b69888102" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndDrepVkeyDeleg.cert b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndDrepVkeyDeleg.cert index 6662aef102..9df5cf2e19 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndDrepVkeyDeleg.cert +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndDrepVkeyDeleg.cert @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "Stake and Vote Delegation Certificate", "cborHex": "840a8200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab01581cc27cf021914a2b3bcb286d3d741979083422378c577fe757702b69888200581ce68f9ee70599cb93d9f60678f9c6463c01938c27d9820c7bf93887a5" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndNoConfidenceDeleg.cert b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndNoConfidenceDeleg.cert index 7ee0df9837..1a9f57f09f 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndNoConfidenceDeleg.cert +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/poolAndNoConfidenceDeleg.cert @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "Stake and Vote Delegation Certificate", "cborHex": "840a8200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab01581cc27cf021914a2b3bcb286d3d741979083422378c577fe757702b69888103" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/registerAddressDelegateToDrep.cert b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/registerAddressDelegateToDrep.cert index 275ab3510a..cc8c698f36 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/registerAddressDelegateToDrep.cert +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/registerAddressDelegateToDrep.cert @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "Stake address registration and vote delegation certificate", "cborHex": "840c8200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab018200581ce68f9ee70599cb93d9f60678f9c6463c01938c27d9820c7bf93887a51a001e8480" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/registerAddressDelegateToPool.cert b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/registerAddressDelegateToPool.cert index 09313ce10b..f351f339ed 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/registerAddressDelegateToPool.cert +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/registerAddressDelegateToPool.cert @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "Stake address registration and stake delegation certificate", "cborHex": "840b8200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab01581cc27cf021914a2b3bcb286d3d741979083422378c577fe757702b69881a001e8480" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/registerAddressDelegateToPoolAndDrep.cert b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/registerAddressDelegateToPoolAndDrep.cert index 3de4e57e93..f0886f38cc 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/registerAddressDelegateToPoolAndDrep.cert +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/stakeaddress/registerAddressDelegateToPoolAndDrep.cert @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "Stake address registration and vote delegation certificate", "cborHex": "850d8200581cef1785cf18928f8353c90e76b7a8fc60855472d31a0ea1c1c774ab01581cc27cf021914a2b3bcb286d3d741979083422378c577fe757702b69888200581ce68f9ee70599cb93d9f60678f9c6463c01938c27d9820c7bf93887a51a001e8480" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/dereg-cert-1.json b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/dereg-cert-1.json index 09cfe220fd..d1782c1ff0 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/dereg-cert-1.json +++ b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/dereg-cert-1.json @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "Stake Address Deregistration Certificate", "cborHex": "83088200581c81b4245f84593f63c0ff2296930254f77a0690fa9de5f969cac27cb01a001e8480" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/dereg-cert-2.json b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/dereg-cert-2.json index 56cd892fe6..4ddd7f42dd 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/dereg-cert-2.json +++ b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/dereg-cert-2.json @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "Stake Address Deregistration Certificate", "cborHex": "83088201581cb9ff787a6dedf9ebe602a26352803778805428c7521b99ec7542aa011a001e8480" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/reg-certificate-extended.json b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/reg-certificate-extended.json index 41ab9c47b8..e1468257c5 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/reg-certificate-extended.json +++ b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/reg-certificate-extended.json @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "Stake Pool Registration Certificate", "cborHex": "8a03581c1ae194ffedb008b77bfb8ec39b1514dbeb99ceccd66448181295142258206aa5f600f54659d456dc2628997df23d98f8f85681edd3e6f4a9340cb06b8db70000d81e820001581de0749440f878a5ba2ac3ab03dbdec6ae3ad5c89f06fc9c031611947803d9010281581c749440f878a5ba2ac3ab03dbdec6ae3ad5c89f06fc9c03161194780380f6" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/reg-certificate.json b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/reg-certificate.json index 5954a112cc..a165f34765 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/reg-certificate.json +++ b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/reg-certificate.json @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "Stake Pool Registration Certificate", "cborHex": "8a03581c4124a0c2ba8a7ba05824b3df23f706a1c8b3239446ab16709ae85aa158206aa5f600f54659d456dc2628997df23d98f8f85681edd3e6f4a9340cb06b8db70000d81e820001581de0749440f878a5ba2ac3ab03dbdec6ae3ad5c89f06fc9c031611947803d9010281581c749440f878a5ba2ac3ab03dbdec6ae3ad5c89f06fc9c03161194780380f6" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/stake-address/reg-certificate-1.json b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/stake-address/reg-certificate-1.json index c3abfb43cc..4f624816ab 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/stake-address/reg-certificate-1.json +++ b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/stake-address/reg-certificate-1.json @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "Stake Address Registration Certificate", "cborHex": "83078200581c81b4245f84593f63c0ff2296930254f77a0690fa9de5f969cac27cb01a001e8480" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/stake-address/reg-certificate-2.json b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/stake-address/reg-certificate-2.json index c3abfb43cc..4f624816ab 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/stake-address/reg-certificate-2.json +++ b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/stake-address/reg-certificate-2.json @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "Stake Address Registration Certificate", "cborHex": "83078200581c81b4245f84593f63c0ff2296930254f77a0690fa9de5f969cac27cb01a001e8480" } diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/stake-address/script-reg-certificate.json b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/stake-address/script-reg-certificate.json index 4ee0863f38..50d83a6730 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/stake-address/script-reg-certificate.json +++ b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/stake-address/script-reg-certificate.json @@ -1,5 +1,5 @@ { - "type": "CertificateConway", + "type": "Certificate", "description": "Stake Address Registration Certificate", "cborHex": "83078201581cb9ff787a6dedf9ebe602a26352803778805428c7521b99ec7542aa011a001e8480" } diff --git a/cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/genesis_key_delegation_certificate b/cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/genesis_key_delegation_certificate index ae5180283a..2b84d61286 100644 --- a/cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/genesis_key_delegation_certificate +++ b/cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/genesis_key_delegation_certificate @@ -1,5 +1,5 @@ { - "type": "CertificateShelley", + "type": "Certificate", "description": "Genesis Key Delegation Certificate", - "cborHex": "8405581cc3db461200fa59c81a4ecc8495446d9e42de27483ff6ee4339c9ab94581cd52ac434259f2af7fd2a538ece5ef8d80386527aa93e207473acb31c58201b9de69baec0dff8dde6e81d71f40f8b65fb3df55bb6ece5783aade88b17354d" + "cborHex": "8405581c60fe90a08bbb49ecc26566d935b837267a9a1a610d9b9a5394fe138e581cae97f9a0a7a5f8d5a4c798fe8fb1e6af5c3e6c8f821e5becd09991da582095207a6ad3f44ae6ee3379b0e5f3e1f02eb3c0733e4dc207e9570f8031b271b3" } From fc6b6b219520da98439cd9e5011b086e8c0ac60b Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Thu, 20 Nov 2025 09:38:41 -0400 Subject: [PATCH 9/9] The genesis key delegation certificate test was never a golden test Convert this test to a simple certificate decoding test and move the test to cardano-cli-test --- cardano-cli/cardano-cli.cabal | 2 +- .../genesis_key_delegation_certificate | 5 ----- .../GenesisKeyDelegationCertificate.hs} | 22 ++++++++++--------- 3 files changed, 13 insertions(+), 16 deletions(-) delete mode 100644 cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/genesis_key_delegation_certificate rename cardano-cli/test/{cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegation.hs => cardano-cli-test/Test/Cli/Certificates/GenesisKeyDelegationCertificate.hs} (81%) diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 406806e7b8..766076c19b 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -387,6 +387,7 @@ test-suite cardano-cli-test build-tool-depends: tasty-discover:tasty-discover other-modules: Test.Cli.AddCostModels + Test.Cli.Certificates.GenesisKeyDelegationCertificate Test.Cli.Certificates.StakePool Test.Cli.CheckNodeConfiguration Test.Cli.Compatible.StakeAddress.DelegationCertificate @@ -507,7 +508,6 @@ test-suite cardano-cli-golden Test.Golden.Shelley.StakeAddress.KeyHash Test.Golden.Shelley.StakeAddress.RegistrationCertificate Test.Golden.Shelley.StakePool.RegistrationCertificate - Test.Golden.Shelley.TextEnvelope.Certificates.GenesisKeyDelegation Test.Golden.Shelley.TextEnvelope.Certificates.Operational Test.Golden.Shelley.TextEnvelope.Keys.ExtendedPaymentKeys Test.Golden.Shelley.TextEnvelope.Keys.GenesisDelegateKeys diff --git a/cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/genesis_key_delegation_certificate b/cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/genesis_key_delegation_certificate deleted file mode 100644 index 2b84d61286..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/genesis_key_delegation_certificate +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "Certificate", - "description": "Genesis Key Delegation Certificate", - "cborHex": "8405581c60fe90a08bbb49ecc26566d935b837267a9a1a610d9b9a5394fe138e581cae97f9a0a7a5f8d5a4c798fe8fb1e6af5c3e6c8f821e5becd09991da582095207a6ad3f44ae6ee3379b0e5f3e1f02eb3c0733e4dc207e9570f8031b271b3" -} diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegation.hs b/cardano-cli/test/cardano-cli-test/Test/Cli/Certificates/GenesisKeyDelegationCertificate.hs similarity index 81% rename from cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegation.hs rename to cardano-cli/test/cardano-cli-test/Test/Cli/Certificates/GenesisKeyDelegationCertificate.hs index 5228c7c981..a88ae861a0 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegation.hs +++ b/cardano-cli/test/cardano-cli-test/Test/Cli/Certificates/GenesisKeyDelegationCertificate.hs @@ -1,23 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ScopedTypeVariables #-} -module Test.Golden.Shelley.TextEnvelope.Certificates.GenesisKeyDelegation where +module Test.Cli.Certificates.GenesisKeyDelegationCertificate where + +import Cardano.Api (File (..), ShelleyLedgerEra, readFileTextEnvelope) +import Cardano.Api.Experimental as Exp import Control.Monad (void) import Test.Cardano.CLI.Util -import Hedgehog (Property) +import Hedgehog (Property, evalIO, success) import Hedgehog.Extras qualified as H +import Hedgehog.Internal.Property (failWith) hprop_golden_shelleyGenesisKeyDelegationCertificate :: Property hprop_golden_shelleyGenesisKeyDelegationCertificate = watchdogProp . propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do - -- Reference certificate - referenceCertificateFilePath <- - noteInputFile $ - "test/cardano-cli-golden/files/input/shelley/certificates/" - <> "genesis_key_delegation_certificate" - -- Verification key and certificate filepaths genesisVerKeyFilePath <- noteTempFile tempDir "genesis-verification-key-file" @@ -96,5 +95,8 @@ hprop_golden_shelleyGenesisKeyDelegationCertificate = ] H.assertFilesExist [genesisKeyDelegCertFilePath] - - H.diffFileVsGoldenFile genesisKeyDelegCertFilePath referenceCertificateFilePath + eCert <- + evalIO $ readFileTextEnvelope $ File genesisKeyDelegCertFilePath + case eCert of + Left err -> failWith Nothing $ "Failed to decode generated genesis key delegation certificate: " <> show err + Right (_cert :: Exp.Certificate (ShelleyLedgerEra BabbageEra)) -> success