Skip to content

Commit

Permalink
Simplify with maybeFeatureInEra
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Sep 22, 2023
1 parent 093655e commit f8f00c5
Showing 1 changed file with 19 additions and 52 deletions.
71 changes: 19 additions & 52 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -133,59 +133,26 @@ pGovernanceActionNoConfidenceCmd era = do
-- | The first argument is the optional prefix.
pAnyStakeIdentifier :: Maybe String -> Parser AnyStakeIdentifier
pAnyStakeIdentifier prefix =
asum [ AnyStakePoolKey <$> pStakePoolVerificationKeyOrHashOrFile prefix
, AnyStakeKey <$> pStakeVerificationKeyOrHashOrFile prefix
]
asum
[ AnyStakePoolKey <$> pStakePoolVerificationKeyOrHashOrFile prefix
, AnyStakeKey <$> pStakeVerificationKeyOrHashOrFile prefix
]

pGovernanceActionProtocolParametersUpdateCmd
:: CardanoEra era -> Maybe (Parser (GovernanceActionCmds era))
pGovernanceActionProtocolParametersUpdateCmd era =
Just $ subParser "create-protocol-parameters-update"
$ Opt.info (pCmd era)
$ Opt.progDesc "Create a protocol parameters update."
where
pCmd :: CardanoEra era -> Parser (GovernanceActionCmds era)
pCmd era' =
case cardanoEraStyle era' of
LegacyByronEra -> empty
ShelleyBasedEra sbe ->
case sbe of
ShelleyBasedEraShelley ->
GovernanceActionProtocolParametersUpdateCmd sbe
<$> pEpochNoUpdateProp
<*> pProtocolParametersUpdateGenesisKeys sbe
<*> dpGovActionProtocolParametersUpdate ShelleyBasedEraShelley
<*> pOutputFile
ShelleyBasedEraAllegra ->
GovernanceActionProtocolParametersUpdateCmd sbe
<$> pEpochNoUpdateProp
<*> pProtocolParametersUpdateGenesisKeys sbe
<*> dpGovActionProtocolParametersUpdate ShelleyBasedEraAllegra
<*> pOutputFile
ShelleyBasedEraMary ->
GovernanceActionProtocolParametersUpdateCmd sbe
<$> pEpochNoUpdateProp
<*> pProtocolParametersUpdateGenesisKeys sbe
<*> dpGovActionProtocolParametersUpdate ShelleyBasedEraMary
<*> pOutputFile
ShelleyBasedEraAlonzo ->
GovernanceActionProtocolParametersUpdateCmd sbe
<$> pEpochNoUpdateProp
<*> pProtocolParametersUpdateGenesisKeys sbe
<*> dpGovActionProtocolParametersUpdate ShelleyBasedEraAlonzo
<*> pOutputFile
ShelleyBasedEraBabbage ->
GovernanceActionProtocolParametersUpdateCmd sbe
<$> pEpochNoUpdateProp
<*> pProtocolParametersUpdateGenesisKeys sbe
<*> dpGovActionProtocolParametersUpdate ShelleyBasedEraBabbage
<*> pOutputFile
ShelleyBasedEraConway ->
GovernanceActionProtocolParametersUpdateCmd sbe
<$> pEpochNoUpdateProp
<*> pProtocolParametersUpdateGenesisKeys sbe
<*> dpGovActionProtocolParametersUpdate ShelleyBasedEraConway
<*> pOutputFile
pGovernanceActionProtocolParametersUpdateCmd :: ()
=> CardanoEra era
-> Maybe (Parser (GovernanceActionCmds era))
pGovernanceActionProtocolParametersUpdateCmd era = do
w <- maybeFeatureInEra era
pure
$ subParser "create-protocol-parameters-update"
$ Opt.info
( GovernanceActionProtocolParametersUpdateCmd w
<$> pEpochNoUpdateProp
<*> pProtocolParametersUpdateGenesisKeys w
<*> dpGovActionProtocolParametersUpdate w
<*> pOutputFile
)
$ Opt.progDesc "Create a protocol parameters update."

convertToLedger :: (a -> b) -> Parser (Maybe a) -> Parser (StrictMaybe b)
convertToLedger conv = fmap (maybeToStrictMaybe . fmap conv)
Expand Down

0 comments on commit f8f00c5

Please sign in to comment.