-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make drep query parser accept zero or more keys
- Loading branch information
1 parent
50733f7
commit 3d452d1
Showing
1 changed file
with
113 additions
and
0 deletions.
There are no files selected for viewing
113 changes: 113 additions & 0 deletions
113
cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Query.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE GADTs #-} | ||
|
||
module Cardano.CLI.EraBased.Options.Governance.Query | ||
( pGovernanceQueryCmds | ||
) where | ||
|
||
import Cardano.Api | ||
|
||
import Cardano.CLI.Environment | ||
import Cardano.CLI.EraBased.Commands.Governance.Query | ||
import Cardano.CLI.EraBased.Options.Common | ||
|
||
import Options.Applicative | ||
import qualified Options.Applicative as Opt | ||
|
||
pGovernanceQueryCmds :: () | ||
=> CardanoEra era | ||
-> EnvCli | ||
-> Maybe (Parser (GovernanceQueryCmds era)) | ||
pGovernanceQueryCmds era env = | ||
subInfoParser "query" | ||
( Opt.progDesc "Query governance-related information" ) | ||
[ pGovernanceQueryGetConstitutionCmd era env | ||
, pGovernanceQueryGetGovStateCmd era env | ||
, pGovernanceQueryDRepStateCmd era env | ||
, pGovernanceQueryDRepStakeDistributionCmd era env | ||
, pGovernanceQueryGetCommitteeStateCmd era env | ||
] | ||
|
||
pGovernanceQueryGetConstitutionCmd :: () | ||
=> CardanoEra era | ||
-> EnvCli | ||
-> Maybe (Parser (GovernanceQueryCmds era)) | ||
pGovernanceQueryGetConstitutionCmd era env = do | ||
cOn <- forEraMaybeEon era | ||
pure | ||
$ subParser "constitution" | ||
$ Opt.info (GovernanceQueryConstitutionCmd cOn <$> pNoArgQueryCmd env) | ||
$ Opt.progDesc "Get the constitution" | ||
|
||
pGovernanceQueryGetGovStateCmd :: () | ||
=> CardanoEra era | ||
-> EnvCli | ||
-> Maybe (Parser (GovernanceQueryCmds era)) | ||
pGovernanceQueryGetGovStateCmd era env = do | ||
cOn <- forEraMaybeEon era | ||
pure | ||
$ subParser "gov-state" | ||
$ Opt.info (GovernanceQueryGovStateCmd cOn <$> pNoArgQueryCmd env) | ||
$ Opt.progDesc "Get the governance state" | ||
|
||
-- TODO Conway: DRep State and DRep Stake Distribution parsers use DRep keys to obtain DRep credentials. This only | ||
-- makes use of 'KeyHashObj' constructor of 'Credential kr c'. Should we also support here 'ScriptHashObj'? | ||
-- What about 'DRep c' - this means that only 'KeyHash' constructor is in use here: should also | ||
-- 'DRepAlwaysAbstain' and 'DRepAlwaysNoConfidence' be supported here? | ||
|
||
pGovernanceQueryDRepStateCmd :: () | ||
=> CardanoEra era | ||
-> EnvCli | ||
-> Maybe (Parser (GovernanceQueryCmds era)) | ||
pGovernanceQueryDRepStateCmd era env = do | ||
cOn <- forEraMaybeEon era | ||
pure | ||
$ subParser "drep-state" | ||
$ Opt.info (GovernanceQueryDRepStateCmd cOn <$> pDRepStateQueryCmd) | ||
$ Opt.progDesc "Get the DRep state. If no DRep credentials are provided, return states for all of them." | ||
where | ||
pDRepStateQueryCmd :: Parser DRepStateQueryCmd | ||
pDRepStateQueryCmd = DRepStateQueryCmd | ||
<$> pSocketPath env | ||
<*> pConsensusModeParams | ||
<*> pNetworkId env | ||
<*> many pDRepVerificationKeyOrHashOrFile | ||
<*> optional pOutputFile | ||
|
||
pGovernanceQueryDRepStakeDistributionCmd :: () | ||
=> CardanoEra era | ||
-> EnvCli | ||
-> Maybe (Parser (GovernanceQueryCmds era)) | ||
pGovernanceQueryDRepStakeDistributionCmd era env = do | ||
cOn <- forEraMaybeEon era | ||
pure | ||
$ subParser "drep-stake-distribution" | ||
$ Opt.info (GovernanceQueryDRepStakeDistributionCmd cOn <$> pDRepStakeDistributionQueryCmd) | ||
$ Opt.progDesc "Get the DRep stake distribution. If no DRep credentials are provided, return stake distributions for all of them." | ||
where | ||
pDRepStakeDistributionQueryCmd :: Parser DRepStakeDistributionQueryCmd | ||
pDRepStakeDistributionQueryCmd = DRepStakeDistributionQueryCmd | ||
<$> pSocketPath env | ||
<*> pConsensusModeParams | ||
<*> pNetworkId env | ||
<*> many pDRepVerificationKeyOrHashOrFile | ||
<*> optional pOutputFile | ||
|
||
pGovernanceQueryGetCommitteeStateCmd :: () | ||
=> CardanoEra era | ||
-> EnvCli | ||
-> Maybe (Parser (GovernanceQueryCmds era)) | ||
pGovernanceQueryGetCommitteeStateCmd era env = do | ||
cOn <- forEraMaybeEon era | ||
pure | ||
$ subParser "committee-state" | ||
$ Opt.info (GovernanceQueryCommitteeStateCmd cOn <$> pNoArgQueryCmd env) | ||
$ Opt.progDesc "Get the committee state" | ||
|
||
pNoArgQueryCmd :: EnvCli -> Parser NoArgQueryCmd | ||
pNoArgQueryCmd env = | ||
NoArgQueryCmd | ||
<$> pSocketPath env | ||
<*> pConsensusModeParams | ||
<*> pNetworkId env | ||
<*> optional pOutputFile |