Skip to content

Commit

Permalink
Merge pull request #277 from input-output-hk/newhoggy/simplify-era-ha…
Browse files Browse the repository at this point in the history
…ndling

Simplify era handling
  • Loading branch information
newhoggy authored Sep 22, 2023
2 parents 093655e + fdb0ec3 commit d9dddc5
Showing 1 changed file with 23 additions and 60 deletions.
83 changes: 23 additions & 60 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 Expand Up @@ -268,14 +235,10 @@ pIntroducedInBabbagePParams =

-- Not necessary in Conway era onwards
pProtocolParametersUpdateGenesisKeys :: ShelleyBasedEra era -> Parser [VerificationKeyFile In]
pProtocolParametersUpdateGenesisKeys sbe =
case sbe of
ShelleyBasedEraShelley -> many pGenesisVerificationKeyFile
ShelleyBasedEraAllegra -> many pGenesisVerificationKeyFile
ShelleyBasedEraMary -> many pGenesisVerificationKeyFile
ShelleyBasedEraAlonzo -> many pGenesisVerificationKeyFile
ShelleyBasedEraBabbage -> many pGenesisVerificationKeyFile
ShelleyBasedEraConway -> empty
pProtocolParametersUpdateGenesisKeys =
caseShelleyToBabbageOrConwayEraOnwards
(const (many pGenesisVerificationKeyFile))
(const empty)

dpGovActionProtocolParametersUpdate
:: ShelleyBasedEra era -> Parser (EraBasedProtocolParametersUpdate era)
Expand Down

0 comments on commit d9dddc5

Please sign in to comment.