Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move governance query commands to query command group #347

Merged
merged 5 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ library
Cardano.CLI.EraBased.Commands.Governance.Committee
Cardano.CLI.EraBased.Commands.Governance.DRep
Cardano.CLI.EraBased.Commands.Governance.Poll
Cardano.CLI.EraBased.Commands.Governance.Query
Cardano.CLI.EraBased.Commands.Governance.Vote
Cardano.CLI.EraBased.Commands.Key
Cardano.CLI.EraBased.Commands.Node
Expand All @@ -93,7 +92,6 @@ library
Cardano.CLI.EraBased.Options.Governance.Committee
Cardano.CLI.EraBased.Options.Governance.DRep
Cardano.CLI.EraBased.Options.Governance.Poll
Cardano.CLI.EraBased.Options.Governance.Query
Cardano.CLI.EraBased.Options.Governance.Vote
Cardano.CLI.EraBased.Options.Key
Cardano.CLI.EraBased.Options.Node
Expand All @@ -111,7 +109,6 @@ library
Cardano.CLI.EraBased.Run.Governance.Committee
Cardano.CLI.EraBased.Run.Governance.DRep
Cardano.CLI.EraBased.Run.Governance.Poll
Cardano.CLI.EraBased.Run.Governance.Query
Cardano.CLI.EraBased.Run.Governance.Vote
Cardano.CLI.EraBased.Run.Key
Cardano.CLI.EraBased.Run.Node
Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ pCmds era envCli =
[ fmap AddressCmds <$> pAddressCmds era envCli
, fmap KeyCmds <$> pKeyCmds
, fmap GenesisCmds <$> pGenesisCmds envCli
, fmap GovernanceCmds <$> pGovernanceCmds era envCli
, fmap GovernanceCmds <$> pGovernanceCmds era
, fmap NodeCmds <$> pNodeCmds
, fmap QueryCmds <$> pQueryCmds envCli
, fmap QueryCmds <$> pQueryCmds era envCli
, fmap StakeAddressCmds <$> pStakeAddressCmds era envCli
, fmap StakePoolCmds <$> pStakePoolCmds era envCli
, fmap TextViewCmds <$> pTextViewCmds
Expand Down
5 changes: 0 additions & 5 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ 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.Poll
import Cardano.CLI.EraBased.Commands.Governance.Vote
import Cardano.CLI.Types.Common
Expand Down Expand Up @@ -41,8 +40,6 @@ data GovernanceCmds era
(GovernancePollCmds era)
| GovernanceVoteCmds
(GovernanceVoteCmds era)
| GovernanceQueryCmds
(GovernanceQueryCmds era)

renderGovernanceCmds :: GovernanceCmds era -> Text
renderGovernanceCmds = \case
Expand All @@ -62,5 +59,3 @@ renderGovernanceCmds = \case
renderGovernancePollCmds cmds
GovernanceVoteCmds cmds ->
renderGovernanceVoteCmds cmds
GovernanceQueryCmds cmds ->
renderGovernanceQueryCmds cmds
66 changes: 0 additions & 66 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Query.hs

This file was deleted.

74 changes: 59 additions & 15 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ module Cardano.CLI.EraBased.Commands.Query
, QueryPoolStateCmdArgs(..)
, QueryTxMempoolCmdArgs(..)
, QuerySlotNumberCmdArgs(..)
, QueryNoArgCmdArgs(..)
, QueryDRepStateCmdArgs(..)
, QueryDRepStakeDistributionCmdArgs(..)
, renderQueryCmds
) where

Expand All @@ -33,21 +36,26 @@ import Data.Time.Clock
import GHC.Generics

data QueryCmds era
= QueryLeadershipScheduleCmd !QueryLeadershipScheduleCmdArgs
| QueryProtocolParametersCmd !QueryProtocolParametersCmdArgs
| QueryConstitutionHashCmd !QueryConstitutionHashCmdArgs
| QueryTipCmd !QueryTipCmdArgs
| QueryStakePoolsCmd !QueryStakePoolsCmdArgs
| QueryStakeDistributionCmd !QueryStakeDistributionCmdArgs
| QueryStakeAddressInfoCmd !QueryStakeAddressInfoCmdArgs
| QueryUTxOCmd !QueryUTxOCmdArgs
| QueryLedgerStateCmd !QueryLedgerStateCmdArgs
| QueryProtocolStateCmd !QueryProtocolStateCmdArgs
| QueryStakeSnapshotCmd !QueryStakeSnapshotCmdArgs
| QueryKesPeriodInfoCmd !QueryKesPeriodInfoCmdArgs
| QueryPoolStateCmd !QueryPoolStateCmdArgs
| QueryTxMempoolCmd !QueryTxMempoolCmdArgs
| QuerySlotNumberCmd !QuerySlotNumberCmdArgs
= QueryLeadershipScheduleCmd !QueryLeadershipScheduleCmdArgs
| QueryProtocolParametersCmd !QueryProtocolParametersCmdArgs
| QueryConstitutionHashCmd !QueryConstitutionHashCmdArgs
| QueryTipCmd !QueryTipCmdArgs
| QueryStakePoolsCmd !QueryStakePoolsCmdArgs
| QueryStakeDistributionCmd !QueryStakeDistributionCmdArgs
| QueryStakeAddressInfoCmd !QueryStakeAddressInfoCmdArgs
| QueryUTxOCmd !QueryUTxOCmdArgs
| QueryLedgerStateCmd !QueryLedgerStateCmdArgs
| QueryProtocolStateCmd !QueryProtocolStateCmdArgs
| QueryStakeSnapshotCmd !QueryStakeSnapshotCmdArgs
| QueryKesPeriodInfoCmd !QueryKesPeriodInfoCmdArgs
| QueryPoolStateCmd !QueryPoolStateCmdArgs
| QueryTxMempoolCmd !QueryTxMempoolCmdArgs
| QuerySlotNumberCmd !QuerySlotNumberCmdArgs
| QueryConstitutionCmd !(QueryNoArgCmdArgs era)
| QueryGovStateCmd !(QueryNoArgCmdArgs era)
| QueryDRepStateCmd !(QueryDRepStateCmdArgs era)
| QueryDRepStakeDistributionCmd !(QueryDRepStakeDistributionCmdArgs era)
| QueryCommitteeStateCmd !(QueryNoArgCmdArgs era)
deriving (Generic, Show)

data QueryLeadershipScheduleCmdArgs = QueryLeadershipScheduleCmdArgs
Expand Down Expand Up @@ -165,6 +173,32 @@ data QuerySlotNumberCmdArgs = QuerySlotNumberCmdArgs
, utcTime :: !UTCTime
} deriving (Generic, Show)

data QueryNoArgCmdArgs era = QueryNoArgCmdArgs
{ eon :: !(ConwayEraOnwards era)
, nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, networkId :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving Show

data QueryDRepStateCmdArgs era = QueryDRepStateCmdArgs
{ eon :: !(ConwayEraOnwards era)
, nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, networkId :: !NetworkId
, drepKeys :: ![VerificationKeyOrHashOrFile DRepKey]
, mOutFile :: !(Maybe (File () Out))
} deriving Show

data QueryDRepStakeDistributionCmdArgs era = QueryDRepStakeDistributionCmdArgs
{ eon :: !(ConwayEraOnwards era)
, nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, networkId :: !NetworkId
, drepKeys :: ![VerificationKeyOrHashOrFile DRepKey]
, mOutFile :: !(Maybe (File () Out))
} deriving Show

renderQueryCmds :: QueryCmds era -> Text
renderQueryCmds = \case
QueryLeadershipScheduleCmd {} ->
Expand Down Expand Up @@ -197,6 +231,16 @@ renderQueryCmds = \case
"query tx-mempool" <> renderTxMempoolQuery q
QuerySlotNumberCmd {} ->
"query slot-number"
QueryConstitutionCmd {} ->
"constitution"
QueryGovStateCmd {} ->
"gov-state"
QueryDRepStateCmd {} ->
"drep-state"
QueryDRepStakeDistributionCmd {} ->
"drep-stake-distribution"
QueryCommitteeStateCmd {} ->
"committee-state"

renderTxMempoolQuery :: TxMempoolQuery -> Text
renderTxMempoolQuery = \case
Expand Down
6 changes: 1 addition & 5 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ module Cardano.CLI.EraBased.Options.Governance

import Cardano.Api

import Cardano.CLI.Environment
import Cardano.CLI.EraBased.Commands.Governance
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.Poll
import Cardano.CLI.EraBased.Options.Governance.Query
import Cardano.CLI.EraBased.Options.Governance.Vote
import Cardano.CLI.Types.Common

Expand All @@ -26,17 +24,15 @@ import qualified Options.Applicative as Opt

pGovernanceCmds :: ()
=> CardanoEra era
-> EnvCli
-> Maybe (Parser (GovernanceCmds era))
pGovernanceCmds era envCli =
pGovernanceCmds era =
subInfoParser "governance"
( Opt.progDesc
$ mconcat
[ "Governance commands."
]
)
[ pCreateMirCertificatesCmds era
, fmap GovernanceQueryCmds <$> pGovernanceQueryCmds era envCli
, fmap GovernanceActionCmds <$> pGovernanceActionCmds era
, fmap GovernanceCommitteeCmds <$> pGovernanceCommitteeCmds era
, fmap GovernanceDRepCmds <$> pGovernanceDRepCmds era
Expand Down
113 changes: 0 additions & 113 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Query.hs

This file was deleted.

Loading