Skip to content

Commit

Permalink
Parameterize pGovernanceCmds on ShelleyBasedEra era
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Oct 11, 2024
1 parent dc869a1 commit a6f523e
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 59 deletions.
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pCmds sbe' envCli = do
[ Just (AddressCmds <$> pAddressCmds envCli)
, Just (KeyCmds <$> pKeyCmds)
, fmap GenesisCmds <$> pGenesisCmds cEra envCli
, fmap GovernanceCmds <$> pGovernanceCmds cEra
, fmap GovernanceCmds <$> pGovernanceCmds sbe'
, Just (NodeCmds <$> pNodeCmds)
, fmap QueryCmds <$> pQueryCmds sbe' envCli
, fmap StakeAddressCmds <$> pStakeAddressCmds sbe' envCli
Expand Down
10 changes: 5 additions & 5 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import qualified Options.Applicative as Opt

pGovernanceCmds
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceCmds era))
pGovernanceCmds era =
subInfoParser
Expand All @@ -43,9 +43,9 @@ pGovernanceCmds era =
, fmap GovernanceVoteCmds <$> pGovernanceVoteCmds era
]

pCreateMirCertificatesCmds :: CardanoEra era -> Maybe (Parser (GovernanceCmds era))
pCreateMirCertificatesCmds :: ShelleyBasedEra era -> Maybe (Parser (GovernanceCmds era))
pCreateMirCertificatesCmds era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure $
subParser "create-mir-certificate" $
Opt.info (pMIRPayStakeAddresses w <|> mirCertParsers w) $
Expand Down Expand Up @@ -99,10 +99,10 @@ pGovernanceCreateMirCertificateTransferToReservesCmd w =

pGovernanceGenesisKeyDelegationCertificate
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceCmds era))
pGovernanceGenesisKeyDelegationCertificate era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure $
subParser "create-genesis-key-delegation-certificate" $
Opt.info (parser w) $
Expand Down
34 changes: 17 additions & 17 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import qualified Options.Applicative as Opt

pGovernanceActionCmds
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionCmds era =
subInfoParser
Expand All @@ -44,10 +44,10 @@ pGovernanceActionCmds era =
]

pGovernanceActionViewCmd
:: CardanoEra era
:: ShelleyBasedEra era
-> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionViewCmd era = do
eon <- forEraMaybeEon era
eon <- forShelleyBasedEraMaybeEon era
return
$ subParser "view"
$ Opt.info
Expand All @@ -60,10 +60,10 @@ pGovernanceActionViewCmd era = do
$ Opt.progDesc "View a governance action."

pGovernanceActionNewInfoCmd
:: CardanoEra era
:: ShelleyBasedEra era
-> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionNewInfoCmd era = do
eon <- forEraMaybeEon era
eon <- forShelleyBasedEraMaybeEon era
pure
$ subParser "create-info"
$ Opt.info
Expand All @@ -80,10 +80,10 @@ pGovernanceActionNewInfoCmd era = do
$ Opt.progDesc "Create an info action."

pGovernanceActionNewConstitutionCmd
:: CardanoEra era
:: ShelleyBasedEra era
-> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionNewConstitutionCmd era = do
eon <- forEraMaybeEon era
eon <- forShelleyBasedEraMaybeEon era
pure
$ subParser "create-constitution"
$ Opt.info
Expand All @@ -105,10 +105,10 @@ pGovernanceActionNewConstitutionCmd era = do
$ Opt.progDesc "Create a constitution."

pGovernanceActionUpdateCommitteeCmd
:: CardanoEra era
:: ShelleyBasedEra era
-> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionUpdateCommitteeCmd era = do
eon <- forEraMaybeEon era
eon <- forShelleyBasedEraMaybeEon era
pure
$ subParser "update-committee"
$ Opt.info
Expand Down Expand Up @@ -140,10 +140,10 @@ pUpdateCommitteeCmd eon =
<*> pOutputFile

pGovernanceActionNoConfidenceCmd
:: CardanoEra era
:: ShelleyBasedEra era
-> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionNoConfidenceCmd era = do
eon <- forEraMaybeEon era
eon <- forShelleyBasedEraMaybeEon era
pure
$ subParser "create-no-confidence"
$ Opt.info
Expand Down Expand Up @@ -226,10 +226,10 @@ pCostModelsFile =

pGovernanceActionProtocolParametersUpdateCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionProtocolParametersUpdateCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure $
Cmd.GovernanceActionProtocolParametersUpdateCmd
<$> pUpdateProtocolParametersCmd w
Expand Down Expand Up @@ -371,9 +371,9 @@ dpGovActionProtocolParametersUpdate = \case
<*> pIntroducedInConwayPParams

pGovernanceActionTreasuryWithdrawalCmd
:: CardanoEra era -> Maybe (Parser (Cmd.GovernanceActionCmds era))
:: ShelleyBasedEra era -> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionTreasuryWithdrawalCmd era = do
eon <- forEraMaybeEon era
eon <- forShelleyBasedEraMaybeEon era
pure
$ subParser "create-treasury-withdrawal"
$ Opt.info
Expand Down Expand Up @@ -413,10 +413,10 @@ pPV :: Parser L.ProtVer
pPV = mkProtocolVersionOrErr <$> pProtocolVersion

pGovernanceActionHardforkInitCmd
:: CardanoEra era
:: ShelleyBasedEra era
-> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionHardforkInitCmd era = do
eon <- forEraMaybeEon era
eon <- forShelleyBasedEraMaybeEon era
pure
$ subParser "create-hardfork"
$ Opt.info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import qualified Options.Applicative as Opt

pGovernanceCommitteeCmds
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceCommitteeCmds era))
pGovernanceCommitteeCmds era =
subInfoParser
Expand All @@ -39,10 +39,10 @@ pGovernanceCommitteeCmds era =

pGovernanceCommitteeKeyGenColdCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceCommitteeCmds era))
pGovernanceCommitteeKeyGenColdCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure $
subParser "key-gen-cold" $
Opt.info (pCmd w) $
Expand All @@ -63,10 +63,10 @@ pGovernanceCommitteeKeyGenColdCmd era = do

pGovernanceCommitteeKeyGenHotCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceCommitteeCmds era))
pGovernanceCommitteeKeyGenHotCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure $
subParser "key-gen-hot" $
Opt.info (pCmd w) $
Expand All @@ -87,10 +87,10 @@ pGovernanceCommitteeKeyGenHotCmd era = do

pGovernanceCommitteeKeyHashCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceCommitteeCmds era))
pGovernanceCommitteeKeyHashCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure
$ subParser "key-hash"
$ Opt.info
Expand All @@ -105,10 +105,10 @@ pGovernanceCommitteeKeyHashCmd era = do

pGovernanceCommitteeCreateHotKeyAuthorizationCertificateCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceCommitteeCmds era))
pGovernanceCommitteeCreateHotKeyAuthorizationCertificateCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure
$ subParser "create-hot-key-authorization-certificate"
$ Opt.info
Expand All @@ -125,10 +125,10 @@ pGovernanceCommitteeCreateHotKeyAuthorizationCertificateCmd era = do

pGovernanceCommitteeCreateColdKeyResignationCertificateCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceCommitteeCmds era))
pGovernanceCommitteeCreateColdKeyResignationCertificateCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure $
subParser "create-cold-key-resignation-certificate" $
Opt.info (conwayEraOnwardsConstraints w $ mkParser w) $
Expand Down
26 changes: 13 additions & 13 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import qualified Options.Applicative as Opt

pGovernanceDRepCmds
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceDRepCmds era))
pGovernanceDRepCmds era =
subInfoParser
Expand All @@ -52,10 +52,10 @@ pGovernanceDRepCmds era =

pGovernanceDRepKeyGenCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceDRepCmds era))
pGovernanceDRepKeyGenCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure
$ subParser "key-gen"
$ Opt.info
Expand All @@ -68,10 +68,10 @@ pGovernanceDRepKeyGenCmd era = do

pGovernanceDRepKeyIdCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceDRepCmds era))
pGovernanceDRepKeyIdCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure
$ subParser "id"
$ Opt.info
Expand Down Expand Up @@ -101,10 +101,10 @@ pDRepIdOutputFormat =

pRegistrationCertificateCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceDRepCmds era))
pRegistrationCertificateCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure $
subParser "registration-certificate" $
Opt.info (conwayEraOnwardsConstraints w $ mkParser w) $
Expand Down Expand Up @@ -148,10 +148,10 @@ pDrepMetadataHash =

pRetirementCertificateCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceDRepCmds era))
pRetirementCertificateCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure
$ subParser "retirement-certificate"
$ Opt.info
Expand All @@ -165,10 +165,10 @@ pRetirementCertificateCmd era = do

pUpdateCertificateCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceDRepCmds era))
pUpdateCertificateCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure
$ subParser "update-certificate"
$ Opt.info
Expand All @@ -187,10 +187,10 @@ pUpdateCertificateCmd era = do

pGovernanceDrepMetadataHashCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceDRepCmds era))
pGovernanceDrepMetadataHashCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure
$ subParser "metadata-hash"
$ Opt.info
Expand Down
14 changes: 7 additions & 7 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Poll.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import qualified Options.Applicative as Opt

pGovernancePollCmds
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (Cmd.GovernancePollCmds era))
pGovernancePollCmds era =
case parsers of
Expand All @@ -42,9 +42,9 @@ pGovernancePollCmds era =
)
]

pGovernanceCreatePoll :: CardanoEra era -> Maybe (Parser (Cmd.GovernancePollCmds era))
pGovernanceCreatePoll :: ShelleyBasedEra era -> Maybe (Parser (Cmd.GovernancePollCmds era))
pGovernanceCreatePoll era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
when ("BabbageEraOnwardsConway" `isInfixOf` show w) Nothing
pure $
fmap Cmd.GovernanceCreatePoll $
Expand All @@ -54,9 +54,9 @@ pGovernanceCreatePoll era = do
<*> optional pPollNonce
<*> pOutputFile

pGovernanceAnswerPoll :: CardanoEra era -> Maybe (Parser (Cmd.GovernancePollCmds era))
pGovernanceAnswerPoll :: ShelleyBasedEra era -> Maybe (Parser (Cmd.GovernancePollCmds era))
pGovernanceAnswerPoll era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
when ("BabbageEraOnwardsConway" `isInfixOf` show w) Nothing
pure $
fmap Cmd.GovernanceAnswerPoll $
Expand All @@ -65,9 +65,9 @@ pGovernanceAnswerPoll era = do
<*> optional pPollAnswerIndex
<*> optional pOutputFile

pGovernanceVerifyPoll :: CardanoEra era -> Maybe (Parser (Cmd.GovernancePollCmds era))
pGovernanceVerifyPoll :: ShelleyBasedEra era -> Maybe (Parser (Cmd.GovernancePollCmds era))
pGovernanceVerifyPoll era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
when ("BabbageEraOnwardsConway" `isInfixOf` show w) Nothing
pure $
fmap Cmd.GovernanceVerifyPoll $
Expand Down
10 changes: 5 additions & 5 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Vote.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import qualified Options.Applicative as Opt

pGovernanceVoteCmds
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceVoteCmds era))
pGovernanceVoteCmds era =
subInfoParser
Expand All @@ -31,10 +31,10 @@ pGovernanceVoteCmds era =

pGovernanceVoteCreateCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceVoteCmds era))
pGovernanceVoteCreateCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure
$ subParser "create"
$ Opt.info
Expand Down Expand Up @@ -65,10 +65,10 @@ pAnyVotingStakeVerificationKeyOrHashOrFile =

pGovernanceVoteViewCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceVoteCmds era))
pGovernanceVoteViewCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure
$ subParser "view"
$ Opt.info
Expand Down

0 comments on commit a6f523e

Please sign in to comment.