From 3a8e53b6d2b764dda7a64fd39aba8815ffb30290 Mon Sep 17 00:00:00 2001 From: Mateusz Galazyn Date: Fri, 25 Aug 2023 15:04:44 +0200 Subject: [PATCH] No-args queries --- .../CLI/EraBased/Commands/Governance.hs | 5 + .../CLI/EraBased/Commands/Governance/Query.hs | 55 ++++- .../CLI/EraBased/Options/Governance.hs | 5 +- .../CLI/EraBased/Options/Governance/Query.hs | 95 ++++++++- cardano-cli/src/Cardano/CLI/EraBased/Run.hs | 4 + .../CLI/EraBased/Run/Governance/Query.hs | 116 +++++------ cardano-cli/src/Cardano/CLI/Read.hs | 3 +- .../src/Cardano/CLI/Types/Errors/CmdError.hs | 3 + .../CLI/Types/Errors/GovernanceQueryError.hs | 38 ++-- .../cardano-cli-golden/files/golden/help.cli | 194 +++++++++++++++++- .../files/golden/help/conway_governance.cli | 3 +- .../golden/help/conway_governance_query.cli | 19 ++ ...onway_governance_query_committee-state.cli | 35 ++++ .../conway_governance_query_constitution.cli | 35 ++++ ...vernance_query_drep-stake-distribution.cli | 46 +++++ .../conway_governance_query_drep-state.cli | 45 ++++ .../conway_governance_query_gov-state.cli | 34 +++ .../golden/help/experimental_governance.cli | 9 +- .../help/experimental_governance_query.cli | 19 ++ ...ental_governance_query_committee-state.cli | 35 ++++ ...rimental_governance_query_constitution.cli | 35 ++++ ...vernance_query_drep-stake-distribution.cli | 46 +++++ ...perimental_governance_query_drep-state.cli | 46 +++++ ...xperimental_governance_query_gov-state.cli | 35 ++++ 24 files changed, 859 insertions(+), 101 deletions(-) create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query.cli create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_committee-state.cli create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_constitution.cli create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_drep-stake-distribution.cli create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_drep-state.cli create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_gov-state.cli create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query.cli create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_committee-state.cli create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_constitution.cli create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_drep-stake-distribution.cli create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_drep-state.cli create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_gov-state.cli diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs index cf21d5f2fb..b9bf73ea99 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs @@ -12,6 +12,7 @@ import Cardano.Api import Cardano.CLI.EraBased.Commands.Governance.Actions import Cardano.CLI.EraBased.Commands.Governance.Committee import Cardano.CLI.EraBased.Commands.Governance.DRep +import Cardano.CLI.EraBased.Commands.Governance.Query import Cardano.CLI.EraBased.Commands.Governance.Vote import Cardano.CLI.Types.Common @@ -37,6 +38,8 @@ data EraBasedGovernanceCmds era (GovernanceDRepCmds era) | EraBasedGovernanceVoteCmds (GovernanceVoteCmds era) + | EraBasedGovernanceQueryCmds + (GovernanceQueryCmds era) renderEraBasedGovernanceCmds :: EraBasedGovernanceCmds era -> Text renderEraBasedGovernanceCmds = \case @@ -54,3 +57,5 @@ renderEraBasedGovernanceCmds = \case renderGovernanceDRepCmds cmds EraBasedGovernanceVoteCmds cmds -> renderGovernanceVoteCmds cmds + EraBasedGovernanceQueryCmds cmds -> + renderGovernanceQueryCmds cmds diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Query.hs index b0bfffe1d7..de635bc6b1 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Query.hs @@ -1,27 +1,68 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} -{-# LANGUAGE StandaloneDeriving #-} module Cardano.CLI.EraBased.Commands.Governance.Query ( GovernanceQueryCmds(..) + , EraBasedNoArgQuery(..) + , EraBasedDRepStateQuery(..) + , EraBasedDRepStakeDistributionQuery(..) , renderGovernanceQueryCmds ) where import Cardano.Api import qualified Cardano.Api.Ledger as Ledger -import Cardano.Api.Shelley -import Cardano.CLI.Types.Common (Constitution, VerificationKeyFile) import Cardano.CLI.Types.Key +import Data.Set import Data.Text (Text) -import Data.Word data GovernanceQueryCmds era - = GovernanceQueryGetConstitution + = GovernanceQueryConstitution + (ConwayEraOnwards era) + EraBasedNoArgQuery + | GovernanceQueryGovState + (ConwayEraOnwards era) + EraBasedNoArgQuery + | GovernanceQueryDRepState + (ConwayEraOnwards era) + EraBasedDRepStateQuery + | GovernanceQueryDRepStakeDistribution + (ConwayEraOnwards era) + EraBasedDRepStakeDistributionQuery + | GovernanceQueryCommitteeState + (ConwayEraOnwards era) + EraBasedNoArgQuery deriving Show +data EraBasedNoArgQuery = EraBasedNoArgQuery + { naSocketPath :: !SocketPath + , naConsensusModeParams :: !AnyConsensusModeParams + , naNetworkId :: !NetworkId + , naOutputFile :: !(Maybe (File () Out)) + } deriving Show + +data EraBasedDRepStateQuery = EraBasedDRepStateQuery + { dsSocketPath :: !SocketPath + , dsConsensusModeParams :: !AnyConsensusModeParams + , dsNetworkId :: !NetworkId + , dsDRepKeys :: ![VerificationKeyOrHashOrFile DRepKey] + , dsOutputFile :: !(Maybe (File () Out)) + } deriving Show + +data EraBasedDRepStakeDistributionQuery = EraBasedDRepStakeDistributionQuery + { dsdSocketPath :: !SocketPath + , dsdConsensusModeParams :: !AnyConsensusModeParams + , dsdNetworkId :: !NetworkId + , dsdDRepKeys :: ![VerificationKeyOrHashOrFile DRepKey] -- TODO + , dsdOutputFile :: !(Maybe (File () Out)) + } deriving Show + renderGovernanceQueryCmds :: GovernanceQueryCmds era -> Text -renderGovernanceQueryCmds = \case - GovernanceQueryGetConstitution{} -> "get-constitution" +renderGovernanceQueryCmds = ("governance query " <>) . \case + GovernanceQueryConstitution{} -> "constitution" + GovernanceQueryGovState{} -> "gov-state" + GovernanceQueryDRepState{} -> "drep-state" + GovernanceQueryDRepStakeDistribution{} -> "drep-stake-distribution" + GovernanceQueryCommitteeState{} -> "committee-state" diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs index 0235ceaa97..9aff34f5bc 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs @@ -15,6 +15,7 @@ import Cardano.CLI.EraBased.Options.Common import Cardano.CLI.EraBased.Options.Governance.Actions import Cardano.CLI.EraBased.Options.Governance.Committee import Cardano.CLI.EraBased.Options.Governance.DRep +import Cardano.CLI.EraBased.Options.Governance.Query (pGovernanceQueryCmds) import Cardano.CLI.EraBased.Options.Governance.Vote import Cardano.CLI.Types.Common @@ -31,13 +32,11 @@ pEraBasedGovernanceCmds envCli era = , fmap EraBasedGovernanceCommitteeCmds <$> pGovernanceCommitteeCmds era , fmap EraBasedGovernanceDRepCmds <$> pGovernanceDRepCmds envCli era , fmap EraBasedGovernanceVoteCmds <$> pGovernanceVoteCmds era + , fmap EraBasedGovernanceQueryCmds <$> pGovernanceQueryCmds envCli era ] -------------------------------------------------------------------------------- - -- Vote related - - -------------------------------------------------------------------------------- diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Query.hs index 2e19efdbf4..ab44c44820 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Query.hs @@ -1,6 +1,5 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} -{-# LANGUAGE LambdaCase #-} module Cardano.CLI.EraBased.Options.Governance.Query ( pGovernanceQueryCmds @@ -10,6 +9,7 @@ import Cardano.Api import Cardano.Api.Ledger import Cardano.Api.Shelley +import Cardano.CLI.Environment import Cardano.CLI.EraBased.Commands.Governance.Actions import Cardano.CLI.EraBased.Commands.Governance.Query import Cardano.CLI.EraBased.Options.Common @@ -25,6 +25,95 @@ import qualified Options.Applicative as Opt pGovernanceQueryCmds :: () - => CardanoEra era + => EnvCli + -> CardanoEra era -> Maybe (Parser (GovernanceQueryCmds era)) -pGovernanceQueryCmds era = undefined +pGovernanceQueryCmds env era = + subInfoParser "query" + ( Opt.progDesc "Query governance-related information" ) + [ pGovernanceQueryGetConstitution env era + , pGovernanceQueryGetGovState env era + , pGovernanceQueryDRepState env era + , pGovernanceQueryDRepStakeDistribution env era + , pGovernanceQueryGetCommitteeState env era + ] + +pGovernanceQueryGetConstitution + :: EnvCli + -> CardanoEra era + -> Maybe (Parser (GovernanceQueryCmds era)) +pGovernanceQueryGetConstitution env era = do + cOn <- maybeFeatureInEra era + pure + $ subParser "constitution" + $ Opt.info (GovernanceQueryConstitution cOn <$> pEraBasedNoArgQuery env) + $ Opt.progDesc "Get the constitution" + +pGovernanceQueryGetGovState + :: EnvCli + -> CardanoEra era + -> Maybe (Parser (GovernanceQueryCmds era)) +pGovernanceQueryGetGovState env era = do + cOn <- maybeFeatureInEra era + pure + $ subParser "gov-state" + $ Opt.info (GovernanceQueryGovState cOn <$> pEraBasedNoArgQuery env) + $ Opt.progDesc "Get the governance state" + +pGovernanceQueryDRepState + :: EnvCli + -> CardanoEra era + -> Maybe (Parser (GovernanceQueryCmds era)) +pGovernanceQueryDRepState env era = do + cOn <- maybeFeatureInEra era + pure + $ subParser "drep-state" + $ Opt.info (GovernanceQueryDRepState cOn <$> pEraBasedDRepStateQuery) + $ Opt.progDesc "Get the DRep state" + where + pEraBasedDRepStateQuery :: Parser EraBasedDRepStateQuery + pEraBasedDRepStateQuery = EraBasedDRepStateQuery + <$> pSocketPath env + <*> pConsensusModeParams + <*> pNetworkId env + <*> some pDRepVerificationKeyOrHashOrFile + <*> optional pOutputFile + +pGovernanceQueryDRepStakeDistribution + :: EnvCli + -> CardanoEra era + -> Maybe (Parser (GovernanceQueryCmds era)) +pGovernanceQueryDRepStakeDistribution env era = do + cOn <- maybeFeatureInEra era + pure + $ subParser "drep-stake-distribution" + $ Opt.info (GovernanceQueryDRepStakeDistribution cOn <$> pEraBasedDRepStakeDistributionQuery) + $ Opt.progDesc "Get the DRep stake distribution" + where + pEraBasedDRepStakeDistributionQuery :: Parser EraBasedDRepStakeDistributionQuery + pEraBasedDRepStakeDistributionQuery = EraBasedDRepStakeDistributionQuery + <$> pSocketPath env + <*> pConsensusModeParams + <*> pNetworkId env + <*> some pDRepVerificationKeyOrHashOrFile + <*> optional pOutputFile + +pGovernanceQueryGetCommitteeState + :: EnvCli + -> CardanoEra era + -> Maybe (Parser (GovernanceQueryCmds era)) +pGovernanceQueryGetCommitteeState env era = do + cOn <- maybeFeatureInEra era + pure + $ subParser "committee-state" + $ Opt.info (GovernanceQueryCommitteeState cOn <$> pEraBasedNoArgQuery env) + $ Opt.progDesc "Get the committee state" + +pEraBasedNoArgQuery :: EnvCli -> Parser EraBasedNoArgQuery +pEraBasedNoArgQuery env = + EraBasedNoArgQuery + <$> pSocketPath env + <*> pConsensusModeParams + <*> pNetworkId env + <*> optional pOutputFile + diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run.hs index 83c226daf7..7a6fe5dbe4 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run.hs @@ -15,6 +15,7 @@ import Cardano.CLI.EraBased.Run.Governance import Cardano.CLI.EraBased.Run.Governance.Actions import Cardano.CLI.EraBased.Run.Governance.Committee import Cardano.CLI.EraBased.Run.Governance.DRep +import Cardano.CLI.EraBased.Run.Governance.Query import Cardano.CLI.EraBased.Run.Governance.Vote import Cardano.CLI.Types.Errors.CmdError @@ -59,3 +60,6 @@ runEraBasedGovernanceCmds = \case EraBasedGovernanceVoteCmds cmds -> runGovernanceVoteCmds cmds + + EraBasedGovernanceQueryCmds cmds -> + runGovernanceQueryCmds cmds diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Query.hs index adfa44addd..dfbed1d2e7 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Query.hs @@ -14,10 +14,12 @@ module Cardano.CLI.EraBased.Run.Governance.Query import Cardano.Api import qualified Cardano.Api.Ledger as Ledger -import Cardano.Api.Shelley import Cardano.CLI.EraBased.Commands.Governance.Query +import Cardano.CLI.Read +import Cardano.CLI.Types.Errors.CmdError import Cardano.CLI.Types.Errors.GovernanceQueryError +import qualified Ouroboros.Consensus.Cardano.Block as Consensus import Control.Monad.IO.Class (liftIO) import Control.Monad.Trans.Except (ExceptT) @@ -30,26 +32,26 @@ import qualified Data.ByteString.Lazy.Char8 as LBS import Data.Function import qualified Data.Map.Strict as Map import Data.Set (Set) +import qualified Data.Set as Set import Data.Yaml.Aeson (ToJSON (..)) import Lens.Micro ((^.)) runGovernanceQueryCmds :: GovernanceQueryCmds era - -> ExceptT GovernanceQueryError IO () -runGovernanceQueryCmds = \case - GovernanceQueryGetConstitution{} -> undefined - -- runGetConstitution w socketPath cModeParams network mFile - - -runGetConstitution + -> ExceptT CmdError IO () +runGovernanceQueryCmds = firstExceptT CmdGovernanceQueryError . \case + GovernanceQueryConstitution cOn args -> runQueryConstitution cOn args + GovernanceQueryGovState cOn args -> runQueryGovState cOn args + GovernanceQueryDRepState cOn args -> runQueryDRepState cOn args + GovernanceQueryDRepStakeDistribution cOn args -> runQueryDRepStakeDistribution cOn args + GovernanceQueryCommitteeState cOn args -> runQueryCommitteeState cOn args + +runQueryConstitution :: ConwayEraOnwards era - -> SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Maybe (File () Out) + -> EraBasedNoArgQuery -> ExceptT GovernanceQueryError IO () -runGetConstitution w socketPath (AnyConsensusModeParams cModeParams) network mFile = conwayEraOnwardsConstraints w $ do +runQueryConstitution w (EraBasedNoArgQuery socketPath (AnyConsensusModeParams cModeParams) network mFile) = conwayEraOnwardsConstraints w $ do let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath sbe = conwayEraOnwardsToShelleyBasedEra w cEra = conwayEraOnwardsToCardanoEra w @@ -58,21 +60,15 @@ runGetConstitution w socketPath (AnyConsensusModeParams cModeParams) network mFi eraInMode <- toEraInMode cEra cMode & hoistMaybe (GovernanceQueryEraConsensusModeMismatch (AnyConsensusMode cMode) (AnyCardanoEra cEra)) - constitution <- firstExceptT GovernanceQueryAcqireFailureError - ( newExceptT $ executeLocalStateQueryExpr localNodeConnInfo Nothing $ queryConstitution eraInMode sbe) - & onLeft (left . GovernanceQueryUnsupportedNtcVersion) - & onLeft (left . GovernanceQueryEraMismatch) + constitution <- runQuery localNodeConnInfo $ queryConstitution eraInMode sbe writeOutput mFile $ encodePretty constitution -runGetGovState +runQueryGovState :: ConwayEraOnwards era - -> SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Maybe (File (Ledger.GovState (ShelleyLedgerEra era)) Out) + -> EraBasedNoArgQuery -> ExceptT GovernanceQueryError IO () -runGetGovState w socketPath (AnyConsensusModeParams cModeParams) network mFile = conwayEraOnwardsConstraints w $ do +runQueryGovState w (EraBasedNoArgQuery socketPath (AnyConsensusModeParams cModeParams) network mFile) = conwayEraOnwardsConstraints w $ do let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath sbe = conwayEraOnwardsToShelleyBasedEra w cEra = conwayEraOnwardsToCardanoEra w @@ -81,23 +77,15 @@ runGetGovState w socketPath (AnyConsensusModeParams cModeParams) network mFile = eraInMode <- toEraInMode cEra cMode & hoistMaybe (GovernanceQueryEraConsensusModeMismatch (AnyConsensusMode cMode) (AnyCardanoEra cEra)) - govState <- firstExceptT GovernanceQueryAcqireFailureError - ( newExceptT $ executeLocalStateQueryExpr localNodeConnInfo Nothing $ queryGovState eraInMode sbe) - & onLeft (left . GovernanceQueryUnsupportedNtcVersion) - & onLeft (left . GovernanceQueryEraMismatch) - + govState <- runQuery localNodeConnInfo $ queryGovState eraInMode sbe writeOutput mFile $ encodePretty govState -runGetDRepState +runQueryDRepState :: ConwayEraOnwards era - -> SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Set (Ledger.Credential Ledger.DRepRole Ledger.StandardCrypto) - -> Maybe (File () Out) + -> EraBasedDRepStateQuery -> ExceptT GovernanceQueryError IO () -runGetDRepState w socketPath (AnyConsensusModeParams cModeParams) network drepCreds mFile = conwayEraOnwardsConstraints w $ do +runQueryDRepState w (EraBasedDRepStateQuery socketPath (AnyConsensusModeParams cModeParams) network drepKeys mFile) = conwayEraOnwardsConstraints w $ do let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath sbe = conwayEraOnwardsToShelleyBasedEra w cEra = conwayEraOnwardsToCardanoEra w @@ -106,11 +94,9 @@ runGetDRepState w socketPath (AnyConsensusModeParams cModeParams) network drepCr eraInMode <- toEraInMode cEra cMode & hoistMaybe (GovernanceQueryEraConsensusModeMismatch (AnyConsensusMode cMode) (AnyCardanoEra cEra)) - drepState <- firstExceptT GovernanceQueryAcqireFailureError - ( newExceptT $ executeLocalStateQueryExpr localNodeConnInfo Nothing $ queryDRepState eraInMode sbe drepCreds) - & onLeft (left . GovernanceQueryUnsupportedNtcVersion) - & onLeft (left . GovernanceQueryEraMismatch) + drepCreds <- Set.fromList <$> mapM (firstExceptT GovernanceQueryDRepKeyError . getDRepCredentialFromVrf) drepKeys + drepState <- runQuery localNodeConnInfo $ queryDRepState eraInMode sbe drepCreds writeOutput mFile $ encodePretty $ bimap toJSON drepStateToJson <$> Map.assocs drepState where @@ -120,40 +106,30 @@ runGetDRepState w socketPath (AnyConsensusModeParams cModeParams) network drepCr , "deposit" .= (ds ^. Ledger.drepDepositL) ] -runGetDRepStakeDistribution +runQueryDRepStakeDistribution :: ConwayEraOnwards era - -> SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Set (Ledger.DRep Ledger.StandardCrypto) - -> Maybe (File () Out) + -> EraBasedDRepStakeDistributionQuery -> ExceptT GovernanceQueryError IO () -runGetDRepStakeDistribution w socketPath (AnyConsensusModeParams cModeParams) network dreps mFile = conwayEraOnwardsConstraints w $ do +runQueryDRepStakeDistribution w (EraBasedDRepStakeDistributionQuery socketPath (AnyConsensusModeParams cModeParams) network drepKeys mFile) = conwayEraOnwardsConstraints w $ do let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath sbe = conwayEraOnwardsToShelleyBasedEra w cEra = conwayEraOnwardsToCardanoEra w cMode = consensusModeOnly cModeParams + let dreps = error "TODO" :: Set (Ledger.DRep Ledger.StandardCrypto) + eraInMode <- toEraInMode cEra cMode & hoistMaybe (GovernanceQueryEraConsensusModeMismatch (AnyConsensusMode cMode) (AnyCardanoEra cEra)) - drepStakeDistribution <- firstExceptT GovernanceQueryAcqireFailureError - ( newExceptT $ executeLocalStateQueryExpr localNodeConnInfo Nothing $ queryDRepStakeDistribution eraInMode sbe dreps) - & onLeft (left . GovernanceQueryUnsupportedNtcVersion) - & onLeft (left . GovernanceQueryEraMismatch) - + drepStakeDistribution <- runQuery localNodeConnInfo $ queryDRepStakeDistribution eraInMode sbe dreps writeOutput mFile $ encodePretty $ Map.assocs drepStakeDistribution - -runGetCommitteeState +runQueryCommitteeState :: ConwayEraOnwards era - -> SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Maybe (File () Out) + -> EraBasedNoArgQuery -> ExceptT GovernanceQueryError IO () -runGetCommitteeState w socketPath (AnyConsensusModeParams cModeParams) network mFile = conwayEraOnwardsConstraints w $ do +runQueryCommitteeState w (EraBasedNoArgQuery socketPath (AnyConsensusModeParams cModeParams) network mFile) = conwayEraOnwardsConstraints w $ do let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath sbe = conwayEraOnwardsToShelleyBasedEra w cEra = conwayEraOnwardsToCardanoEra w @@ -162,13 +138,27 @@ runGetCommitteeState w socketPath (AnyConsensusModeParams cModeParams) network m eraInMode <- toEraInMode cEra cMode & hoistMaybe (GovernanceQueryEraConsensusModeMismatch (AnyConsensusMode cMode) (AnyCardanoEra cEra)) - committeeState <- firstExceptT GovernanceQueryAcqireFailureError - ( newExceptT $ executeLocalStateQueryExpr localNodeConnInfo Nothing $ queryCommitteeState eraInMode sbe) - & onLeft (left . GovernanceQueryUnsupportedNtcVersion) - & onLeft (left . GovernanceQueryEraMismatch) + committeeState <- runQuery localNodeConnInfo $ queryCommitteeState eraInMode sbe writeOutput mFile $ encodePretty . toJSON . Map.assocs $ committeeState ^. Ledger.csCommitteeCredsL +runQuery :: LocalNodeConnectInfo mode + -> LocalStateQueryExpr + (BlockInMode mode) + ChainPoint + (QueryInMode mode) + () + IO + (Either + UnsupportedNtcVersionError + (Either Consensus.EraMismatch a)) + -> ExceptT GovernanceQueryError IO a +runQuery localNodeConnInfo query = + firstExceptT GovernanceQueryAcqireFailureError + ( newExceptT $ executeLocalStateQueryExpr localNodeConnInfo Nothing query) + & onLeft (left . GovernanceQueryUnsupportedNtcVersion) + & onLeft (left . GovernanceQueryEraMismatch) + writeOutput :: Maybe (File a Out) -> LBS.ByteString -> ExceptT GovernanceQueryError IO () @@ -177,3 +167,5 @@ writeOutput mFile content = case mFile of Just (File f) -> handleIOExceptT (GovernanceQueryWriteFileError . FileIOError f) $ LBS.writeFile f content + + diff --git a/cardano-cli/src/Cardano/CLI/Read.hs b/cardano-cli/src/Cardano/CLI/Read.hs index a9516df64d..6f3f60e10a 100644 --- a/cardano-cli/src/Cardano/CLI/Read.hs +++ b/cardano-cli/src/Cardano/CLI/Read.hs @@ -935,12 +935,11 @@ getStakeAddressFromVerifier networkId stakeVerifier = getDRepCredentialFromVrf :: () => VerificationKeyOrHashOrFile DRepKey - -> ExceptT StakeCredentialError IO (Ledger.Credential Ledger.DRepRole Ledger.StandardCrypto) + -> ExceptT (FileError InputDecodeError) IO (Ledger.Credential Ledger.DRepRole Ledger.StandardCrypto) getDRepCredentialFromVrf = \case VerificationKeyOrFile verKeyOrFile -> do drepVerKey <- ExceptT (readVerificationKeyOrFile AsDRepKey verKeyOrFile) - & firstExceptT StakeCredentialInputDecodeError pure . Ledger.KeyHashObj . unDRepKeyHash $ verificationKeyHash drepVerKey VerificationKeyHash kh -> pure . Ledger.KeyHashObj $ unDRepKeyHash kh diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/CmdError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/CmdError.hs index e50a42024a..0535dad51b 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/CmdError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/CmdError.hs @@ -12,6 +12,7 @@ import Cardano.CLI.Types.Errors.EraBasedRegistrationError import Cardano.CLI.Types.Errors.GovernanceActionsError import Cardano.CLI.Types.Errors.GovernanceCmdError import Cardano.CLI.Types.Errors.GovernanceCommitteeError +import Cardano.CLI.Types.Errors.GovernanceQueryError import Cardano.CLI.Types.Errors.GovernanceVoteCmdError import Cardano.CLI.Types.Errors.ShelleyAddressCmdError import Cardano.CLI.Types.Errors.ShelleyGenesisCmdError @@ -35,6 +36,7 @@ data CmdError | CmdGovernanceCmdError !GovernanceCmdError | CmdGovernanceCommitteeError !GovernanceCommitteeError | CmdGovernanceVoteError !GovernanceVoteCmdError + | CmdGovernanceQueryError !GovernanceQueryError | CmdKeyError !ShelleyKeyCmdError | CmdNodeError !ShelleyNodeCmdError | CmdPoolError !ShelleyPoolCmdError @@ -53,6 +55,7 @@ renderCmdError cmdText = \case CmdGovernanceCmdError e -> renderError (Text.pack . displayError) e CmdGovernanceCommitteeError e -> renderError (Text.pack . displayError) e CmdGovernanceVoteError e -> renderError (Text.pack . displayError) e + CmdGovernanceQueryError e -> renderError (Text.pack . displayError) e CmdKeyError e -> renderError renderShelleyKeyCmdError e CmdNodeError e -> renderError renderShelleyNodeCmdError e CmdPoolError e -> renderError renderShelleyPoolCmdError e diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceQueryError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceQueryError.hs index e3940664d1..d718a7fa6c 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceQueryError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceQueryError.hs @@ -1,20 +1,11 @@ +{-# LANGUAGE LambdaCase #-} module Cardano.CLI.Types.Errors.GovernanceQueryError where import Cardano.Api import Cardano.Api.Shelley -import Cardano.Binary (DecoderError) -import Cardano.CLI.Read (CddlError) -import Cardano.CLI.Types.Errors.ShelleyStakeAddressCmdError import Ouroboros.Consensus.Cardano.Block (EraMismatch) -import qualified Data.List as List -import Data.Text (Text) -import qualified Data.Text as Text -import Data.Text.Encoding.Error -import qualified Data.Text.Lazy as TL -import qualified Data.Text.Lazy.Builder as TL -import qualified Formatting.Buildable as B data GovernanceQueryError = GovernanceQueryWriteFileError !(FileError ()) @@ -22,16 +13,23 @@ data GovernanceQueryError | GovernanceQueryEraConsensusModeMismatch !AnyConsensusMode !AnyCardanoEra | GovernanceQueryUnsupportedNtcVersion !UnsupportedNtcVersionError | GovernanceQueryEraMismatch !EraMismatch + | GovernanceQueryDRepKeyError !(FileError InputDecodeError) deriving Show instance Error GovernanceQueryError where - displayError (GovernanceQueryWriteFileError err) = - "Error writing file: " <> displayError err - displayError (GovernanceQueryAcqireFailureError err) = - "Error acquiring: " <> error "todo" -- displayError err - displayError (GovernanceQueryEraConsensusModeMismatch (AnyConsensusMode cMode) (AnyCardanoEra cEra)) = - "Era " <> show cEra <> " does not support consensus mode " <> show cMode - displayError (GovernanceQueryUnsupportedNtcVersion err) = - "Unsupported ntc version: " <> error "todo" -- displayError err - displayError (GovernanceQueryEraMismatch err) = - "Era mismatch: " <> error "todo" -- displayError err + displayError = \case + GovernanceQueryWriteFileError err -> + "Error writing file: " <> displayError err + GovernanceQueryAcqireFailureError err -> + show err + GovernanceQueryEraConsensusModeMismatch (AnyConsensusMode cMode) (AnyCardanoEra cEra) -> + "Era " <> show cEra <> " does not support consensus mode " <> show cMode + GovernanceQueryUnsupportedNtcVersion (UnsupportedNtcVersionError minNtcVersion ntcVersion) -> unlines + [ "Unsupported feature for the node-to-client protocol version." + , "This query requires at least " <> show minNtcVersion <> " but the node negotiated " <> show ntcVersion <> "." + , "Later node versions support later protocol versions (but development protocol versions are not enabled in the node by default)." + ] + GovernanceQueryEraMismatch err -> + "A query from a certain era was applied to a ledger from a different era: " <> show err + GovernanceQueryDRepKeyError err -> + "Error reading delegation-representative key: " <> displayError err diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli index c7933e516c..7a7bdf5e77 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -688,7 +688,7 @@ Usage: cardano-cli conway governance Conway era commands -Usage: cardano-cli conway governance (action | committee | drep | vote) +Usage: cardano-cli conway governance (action | committee | drep | vote | query) Era-based governance commands @@ -1002,6 +1002,97 @@ Usage: cardano-cli conway governance vote create (--yes | --no | --abstain) Vote creation. +Usage: cardano-cli conway governance query + ( constitution + | gov-state + | drep-state + | drep-stake-distribution + | committee-state + ) + + Query governance-related information + +Usage: cardano-cli conway governance query constitution + --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + [--out-file FILE] + + Get the constitution + +Usage: cardano-cli conway governance query gov-state --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + [--out-file FILE] + + Get the governance state + +Usage: cardano-cli conway governance query drep-state --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + ( --drep-verification-key STRING + | --drep-verification-key-file FILE + | --drep-key-hash HASH + ) + [--out-file FILE] + + Get the DRep state + +Usage: cardano-cli conway governance query drep-stake-distribution + --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + ( --drep-verification-key STRING + | --drep-verification-key-file FILE + | --drep-key-hash HASH + ) + [--out-file FILE] + + Get the DRep stake distribution + +Usage: cardano-cli conway governance query committee-state + --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + [--out-file FILE] + + Get the committee state + Usage: cardano-cli latest governance Latest era commands (Babbage) @@ -1141,7 +1232,13 @@ Usage: cardano-cli experimental governance Experimental era commands (Conway) -Usage: cardano-cli experimental governance (action | committee | drep | vote) +Usage: cardano-cli experimental governance + ( action + | committee + | drep + | vote + | query + ) Era-based governance commands @@ -1459,6 +1556,99 @@ Usage: cardano-cli experimental governance vote create Vote creation. +Usage: cardano-cli experimental governance query + ( constitution + | gov-state + | drep-state + | drep-stake-distribution + | committee-state + ) + + Query governance-related information + +Usage: cardano-cli experimental governance query constitution + --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + [--out-file FILE] + + Get the constitution + +Usage: cardano-cli experimental governance query gov-state + --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + [--out-file FILE] + + Get the governance state + +Usage: cardano-cli experimental governance query drep-state + --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + ( --drep-verification-key STRING + | --drep-verification-key-file FILE + | --drep-key-hash HASH + ) + [--out-file FILE] + + Get the DRep state + +Usage: cardano-cli experimental governance query drep-stake-distribution + --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + ( --drep-verification-key STRING + | --drep-verification-key-file FILE + | --drep-key-hash HASH + ) + [--out-file FILE] + + Get the DRep stake distribution + +Usage: cardano-cli experimental governance query committee-state + --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + [--out-file FILE] + + Get the committee state + Usage: cardano-cli legacy Legacy commands Legacy commands diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance.cli index 1fcf076dc6..5ce7838a02 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance.cli @@ -1,4 +1,4 @@ -Usage: cardano-cli conway governance (action | committee | drep | vote) +Usage: cardano-cli conway governance (action | committee | drep | vote | query) Era-based governance commands @@ -10,3 +10,4 @@ Available commands: committee Committee member commands. drep DRep member commands. vote Vote commands. + query Query governance-related information diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query.cli new file mode 100644 index 0000000000..c80fe959bb --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query.cli @@ -0,0 +1,19 @@ +Usage: cardano-cli conway governance query + ( constitution + | gov-state + | drep-state + | drep-stake-distribution + | committee-state + ) + + Query governance-related information + +Available options: + -h,--help Show this help text + +Available commands: + constitution Get the constitution + gov-state Get the governance state + drep-state Get the DRep state + drep-stake-distribution Get the DRep stake distribution + committee-state Get the committee state diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_committee-state.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_committee-state.cli new file mode 100644 index 0000000000..bfa5dffc47 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_committee-state.cli @@ -0,0 +1,35 @@ +Usage: cardano-cli conway governance query committee-state + --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + [--out-file FILE] + + Get the committee state + +Available options: + --socket-path SOCKET_PATH + Path to the node socket. This overrides the + CARDANO_NODE_SOCKET_PATH environment variable. The + argument is optional if CARDANO_NODE_SOCKET_PATH is + defined and mandatory otherwise. + --shelley-mode For talking to a node running in Shelley-only mode. + --byron-mode For talking to a node running in Byron-only mode. + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --cardano-mode For talking to a node running in full Cardano mode + (default). + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --mainnet Use the mainnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --testnet-magic NATURAL Specify a testnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --out-file FILE The output file. + -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_constitution.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_constitution.cli new file mode 100644 index 0000000000..fecd0d42d7 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_constitution.cli @@ -0,0 +1,35 @@ +Usage: cardano-cli conway governance query constitution + --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + [--out-file FILE] + + Get the constitution + +Available options: + --socket-path SOCKET_PATH + Path to the node socket. This overrides the + CARDANO_NODE_SOCKET_PATH environment variable. The + argument is optional if CARDANO_NODE_SOCKET_PATH is + defined and mandatory otherwise. + --shelley-mode For talking to a node running in Shelley-only mode. + --byron-mode For talking to a node running in Byron-only mode. + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --cardano-mode For talking to a node running in full Cardano mode + (default). + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --mainnet Use the mainnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --testnet-magic NATURAL Specify a testnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --out-file FILE The output file. + -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_drep-stake-distribution.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_drep-stake-distribution.cli new file mode 100644 index 0000000000..5bda7a0678 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_drep-stake-distribution.cli @@ -0,0 +1,46 @@ +Usage: cardano-cli conway governance query drep-stake-distribution + --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + ( --drep-verification-key STRING + | --drep-verification-key-file FILE + | --drep-key-hash HASH + ) + [--out-file FILE] + + Get the DRep stake distribution + +Available options: + --socket-path SOCKET_PATH + Path to the node socket. This overrides the + CARDANO_NODE_SOCKET_PATH environment variable. The + argument is optional if CARDANO_NODE_SOCKET_PATH is + defined and mandatory otherwise. + --shelley-mode For talking to a node running in Shelley-only mode. + --byron-mode For talking to a node running in Byron-only mode. + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --cardano-mode For talking to a node running in full Cardano mode + (default). + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --mainnet Use the mainnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --testnet-magic NATURAL Specify a testnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --drep-verification-key STRING + DRep verification key (Bech32 or hex-encoded). + --drep-verification-key-file FILE + Filepath of the DRep verification key. + --drep-key-hash HASH DRep verification key hash (either Bech32-encoded or + hex-encoded). Zero or more occurences of this option + is allowed. + --out-file FILE The output file. + -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_drep-state.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_drep-state.cli new file mode 100644 index 0000000000..449afc1ecf --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_drep-state.cli @@ -0,0 +1,45 @@ +Usage: cardano-cli conway governance query drep-state --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + ( --drep-verification-key STRING + | --drep-verification-key-file FILE + | --drep-key-hash HASH + ) + [--out-file FILE] + + Get the DRep state + +Available options: + --socket-path SOCKET_PATH + Path to the node socket. This overrides the + CARDANO_NODE_SOCKET_PATH environment variable. The + argument is optional if CARDANO_NODE_SOCKET_PATH is + defined and mandatory otherwise. + --shelley-mode For talking to a node running in Shelley-only mode. + --byron-mode For talking to a node running in Byron-only mode. + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --cardano-mode For talking to a node running in full Cardano mode + (default). + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --mainnet Use the mainnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --testnet-magic NATURAL Specify a testnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --drep-verification-key STRING + DRep verification key (Bech32 or hex-encoded). + --drep-verification-key-file FILE + Filepath of the DRep verification key. + --drep-key-hash HASH DRep verification key hash (either Bech32-encoded or + hex-encoded). Zero or more occurences of this option + is allowed. + --out-file FILE The output file. + -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_gov-state.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_gov-state.cli new file mode 100644 index 0000000000..e37b14f944 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_query_gov-state.cli @@ -0,0 +1,34 @@ +Usage: cardano-cli conway governance query gov-state --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + [--out-file FILE] + + Get the governance state + +Available options: + --socket-path SOCKET_PATH + Path to the node socket. This overrides the + CARDANO_NODE_SOCKET_PATH environment variable. The + argument is optional if CARDANO_NODE_SOCKET_PATH is + defined and mandatory otherwise. + --shelley-mode For talking to a node running in Shelley-only mode. + --byron-mode For talking to a node running in Byron-only mode. + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --cardano-mode For talking to a node running in full Cardano mode + (default). + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --mainnet Use the mainnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --testnet-magic NATURAL Specify a testnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --out-file FILE The output file. + -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance.cli index 0b3b1ec1dd..ccd4ba2030 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance.cli @@ -1,4 +1,10 @@ -Usage: cardano-cli experimental governance (action | committee | drep | vote) +Usage: cardano-cli experimental governance + ( action + | committee + | drep + | vote + | query + ) Era-based governance commands @@ -10,3 +16,4 @@ Available commands: committee Committee member commands. drep DRep member commands. vote Vote commands. + query Query governance-related information diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query.cli new file mode 100644 index 0000000000..18fb2b7b0c --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query.cli @@ -0,0 +1,19 @@ +Usage: cardano-cli experimental governance query + ( constitution + | gov-state + | drep-state + | drep-stake-distribution + | committee-state + ) + + Query governance-related information + +Available options: + -h,--help Show this help text + +Available commands: + constitution Get the constitution + gov-state Get the governance state + drep-state Get the DRep state + drep-stake-distribution Get the DRep stake distribution + committee-state Get the committee state diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_committee-state.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_committee-state.cli new file mode 100644 index 0000000000..f252f52af1 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_committee-state.cli @@ -0,0 +1,35 @@ +Usage: cardano-cli experimental governance query committee-state + --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + [--out-file FILE] + + Get the committee state + +Available options: + --socket-path SOCKET_PATH + Path to the node socket. This overrides the + CARDANO_NODE_SOCKET_PATH environment variable. The + argument is optional if CARDANO_NODE_SOCKET_PATH is + defined and mandatory otherwise. + --shelley-mode For talking to a node running in Shelley-only mode. + --byron-mode For talking to a node running in Byron-only mode. + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --cardano-mode For talking to a node running in full Cardano mode + (default). + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --mainnet Use the mainnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --testnet-magic NATURAL Specify a testnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --out-file FILE The output file. + -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_constitution.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_constitution.cli new file mode 100644 index 0000000000..2cbb9a3522 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_constitution.cli @@ -0,0 +1,35 @@ +Usage: cardano-cli experimental governance query constitution + --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + [--out-file FILE] + + Get the constitution + +Available options: + --socket-path SOCKET_PATH + Path to the node socket. This overrides the + CARDANO_NODE_SOCKET_PATH environment variable. The + argument is optional if CARDANO_NODE_SOCKET_PATH is + defined and mandatory otherwise. + --shelley-mode For talking to a node running in Shelley-only mode. + --byron-mode For talking to a node running in Byron-only mode. + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --cardano-mode For talking to a node running in full Cardano mode + (default). + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --mainnet Use the mainnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --testnet-magic NATURAL Specify a testnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --out-file FILE The output file. + -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_drep-stake-distribution.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_drep-stake-distribution.cli new file mode 100644 index 0000000000..22e97b0a5e --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_drep-stake-distribution.cli @@ -0,0 +1,46 @@ +Usage: cardano-cli experimental governance query drep-stake-distribution + --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + ( --drep-verification-key STRING + | --drep-verification-key-file FILE + | --drep-key-hash HASH + ) + [--out-file FILE] + + Get the DRep stake distribution + +Available options: + --socket-path SOCKET_PATH + Path to the node socket. This overrides the + CARDANO_NODE_SOCKET_PATH environment variable. The + argument is optional if CARDANO_NODE_SOCKET_PATH is + defined and mandatory otherwise. + --shelley-mode For talking to a node running in Shelley-only mode. + --byron-mode For talking to a node running in Byron-only mode. + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --cardano-mode For talking to a node running in full Cardano mode + (default). + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --mainnet Use the mainnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --testnet-magic NATURAL Specify a testnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --drep-verification-key STRING + DRep verification key (Bech32 or hex-encoded). + --drep-verification-key-file FILE + Filepath of the DRep verification key. + --drep-key-hash HASH DRep verification key hash (either Bech32-encoded or + hex-encoded). Zero or more occurences of this option + is allowed. + --out-file FILE The output file. + -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_drep-state.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_drep-state.cli new file mode 100644 index 0000000000..87a8767dbc --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_drep-state.cli @@ -0,0 +1,46 @@ +Usage: cardano-cli experimental governance query drep-state + --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + ( --drep-verification-key STRING + | --drep-verification-key-file FILE + | --drep-key-hash HASH + ) + [--out-file FILE] + + Get the DRep state + +Available options: + --socket-path SOCKET_PATH + Path to the node socket. This overrides the + CARDANO_NODE_SOCKET_PATH environment variable. The + argument is optional if CARDANO_NODE_SOCKET_PATH is + defined and mandatory otherwise. + --shelley-mode For talking to a node running in Shelley-only mode. + --byron-mode For talking to a node running in Byron-only mode. + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --cardano-mode For talking to a node running in full Cardano mode + (default). + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --mainnet Use the mainnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --testnet-magic NATURAL Specify a testnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --drep-verification-key STRING + DRep verification key (Bech32 or hex-encoded). + --drep-verification-key-file FILE + Filepath of the DRep verification key. + --drep-key-hash HASH DRep verification key hash (either Bech32-encoded or + hex-encoded). Zero or more occurences of this option + is allowed. + --out-file FILE The output file. + -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_gov-state.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_gov-state.cli new file mode 100644 index 0000000000..efe19b4f2e --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_query_gov-state.cli @@ -0,0 +1,35 @@ +Usage: cardano-cli experimental governance query gov-state + --socket-path SOCKET_PATH + [ --shelley-mode + | --byron-mode + [--epoch-slots SLOTS] + | --cardano-mode + [--epoch-slots SLOTS] + ] + ( --mainnet + | --testnet-magic NATURAL + ) + [--out-file FILE] + + Get the governance state + +Available options: + --socket-path SOCKET_PATH + Path to the node socket. This overrides the + CARDANO_NODE_SOCKET_PATH environment variable. The + argument is optional if CARDANO_NODE_SOCKET_PATH is + defined and mandatory otherwise. + --shelley-mode For talking to a node running in Shelley-only mode. + --byron-mode For talking to a node running in Byron-only mode. + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --cardano-mode For talking to a node running in full Cardano mode + (default). + --epoch-slots SLOTS The number of slots per epoch for the Byron era. + (default: 21600) + --mainnet Use the mainnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --testnet-magic NATURAL Specify a testnet magic id. This overrides the + CARDANO_NODE_NETWORK_ID environment variable + --out-file FILE The output file. + -h,--help Show this help text