1- {-# LANGUAGE DataKinds #-}
21{-# LANGUAGE GADTs #-}
3- {-# LANGUAGE ScopedTypeVariables #-}
42
53module Cardano.CLI.Compatible.Governance.Option
64 ( pCompatibleGovernanceCmds
75 )
86where
97
108import Cardano.Api
11- import Cardano.Api.Experimental (obtainCommonConstraints )
129
1310import Cardano.CLI.Compatible.Governance.Command
1411import Cardano.CLI.Compatible.Governance.Types
@@ -33,24 +30,29 @@ pCompatibleGovernanceCmds
3330pCompatibleGovernanceCmds sbe =
3431 asum $
3532 catMaybes
36- [ caseShelleyToBabbageOrConwayEraOnwards
37- ( const $
38- subInfoParser
39- " governance"
40- ( Opt. progDesc $
41- mconcat
42- [ " Governance commands."
43- ]
44- )
45- [ pCreateMirCertificatesCmds sbe
46- , pGovernanceGenesisKeyDelegationCertificate
47- , fmap CreateCompatibleProtocolParametersUpdateCmd <$> pGovernanceActionCmds sbe
48- ]
49- )
50- ( \ w ->
51- fmap LatestCompatibleGovernanceCmds <$> obtainCommonConstraints (convert w) Latest. pGovernanceCmds
52- )
53- sbe
33+ [ case sbe of
34+ ShelleyBasedEraShelley -> preConway
35+ ShelleyBasedEraAllegra -> preConway
36+ ShelleyBasedEraMary -> preConway
37+ ShelleyBasedEraAlonzo -> preConway
38+ ShelleyBasedEraBabbage -> preConway
39+ ShelleyBasedEraConway ->
40+ fmap LatestCompatibleGovernanceCmds <$> Latest. pGovernanceCmds
41+ ShelleyBasedEraDijkstra ->
42+ fmap LatestCompatibleGovernanceCmds <$> Latest. pGovernanceCmds
43+ ]
44+ where
45+ preConway =
46+ subInfoParser
47+ " governance"
48+ ( Opt. progDesc $
49+ mconcat
50+ [ " Governance commands."
51+ ]
52+ )
53+ [ pCreateMirCertificatesCmds sbe
54+ , pGovernanceGenesisKeyDelegationCertificate
55+ , fmap CreateCompatibleProtocolParametersUpdateCmd <$> pGovernanceActionCmds sbe
5456 ]
5557
5658pGovernanceActionCmds
@@ -63,58 +65,64 @@ pGovernanceActionCmds sbe =
6365 [ " Governance action commands."
6466 ]
6567 )
66- [ pGovernanceActionProtocolParametersUpdateCmd sbe
68+ [ Just $ pUpdateProtocolParametersCmd sbe
6769 ]
6870
69- pGovernanceActionProtocolParametersUpdateCmd
70- :: ()
71- => ShelleyBasedEra era
72- -> Maybe (Parser (GovernanceActionProtocolParametersUpdateCmdArgs era ))
73- pGovernanceActionProtocolParametersUpdateCmd sbe = do
74- w <- forShelleyBasedEraMaybeEon sbe
75- pure $
76- pUpdateProtocolParametersCmd w
77-
7871pUpdateProtocolParametersCmd
7972 :: ShelleyBasedEra era -> Parser (GovernanceActionProtocolParametersUpdateCmdArgs era )
80- pUpdateProtocolParametersCmd =
81- caseShelleyToBabbageOrConwayEraOnwards
82- ( \ shelleyToBab ->
83- let sbe = convert shelleyToBab
84- in Opt. hsubparser
85- $ commandWithMetavar " create-protocol-parameters-update"
86- $ Opt. info
87- ( GovernanceActionProtocolParametersUpdateCmdArgs
88- (convert shelleyToBab)
89- <$> fmap Just (pUpdateProtocolParametersPreConway shelleyToBab)
90- <*> pure Nothing
91- <*> pGovActionProtocolParametersUpdate sbe
92- <*> pCostModelsFile sbe
93- <*> pOutputFile
94- )
95- $ Opt. progDesc " Create a protocol parameters update."
96- )
97- ( \ conwayOnwards ->
98- let sbe = convert conwayOnwards
99- ppup = fmap Just (obtainCommonConstraints (convert conwayOnwards) pUpdateProtocolParametersPostConway)
100- in Opt. hsubparser
101- $ commandWithMetavar " create-protocol-parameters-update"
102- $ Opt. info
103- ( GovernanceActionProtocolParametersUpdateCmdArgs
104- (convert conwayOnwards)
105- Nothing
106- <$> ppup
107- <*> pGovActionProtocolParametersUpdate sbe
108- <*> pCostModelsFile sbe
109- <*> pOutputFile
110- )
111- $ Opt. progDesc " Create a protocol parameters update."
112- )
73+ pUpdateProtocolParametersCmd sbe =
74+ case sbe of
75+ ShelleyBasedEraShelley -> pPreConwayUpdateProtocolParametersCmd sbe
76+ ShelleyBasedEraAllegra -> pPreConwayUpdateProtocolParametersCmd sbe
77+ ShelleyBasedEraMary -> pPreConwayUpdateProtocolParametersCmd sbe
78+ ShelleyBasedEraAlonzo -> pPreConwayUpdateProtocolParametersCmd sbe
79+ ShelleyBasedEraBabbage -> pPreConwayUpdateProtocolParametersCmd sbe
80+ ShelleyBasedEraConway -> pPostConwayUpdateProtocolParametersCmd sbe
81+ ShelleyBasedEraDijkstra -> pPostConwayUpdateProtocolParametersCmd sbe
82+
83+ pPreConwayUpdateProtocolParametersCmd
84+ :: ShelleyBasedEra era -> Parser (GovernanceActionProtocolParametersUpdateCmdArgs era )
85+ pPreConwayUpdateProtocolParametersCmd sbe =
86+ Opt. hsubparser
87+ $ commandWithMetavar " create-protocol-parameters-update"
88+ $ Opt. info
89+ ( GovernanceActionProtocolParametersUpdateCmdArgs sbe
90+ <$> fmap Just pUpdateProtocolParametersPreConway
91+ <*> pure Nothing
92+ <*> pGovActionProtocolParametersUpdate sbe
93+ <*> pCostModelsFile sbe
94+ <*> pOutputFile
95+ )
96+ $ Opt. progDesc " Create a protocol parameters update."
97+
98+ pPostConwayUpdateProtocolParametersCmd
99+ :: ShelleyBasedEra era -> Parser (GovernanceActionProtocolParametersUpdateCmdArgs era )
100+ pPostConwayUpdateProtocolParametersCmd sbe =
101+ Opt. hsubparser
102+ $ commandWithMetavar " create-protocol-parameters-update"
103+ $ Opt. info
104+ ( GovernanceActionProtocolParametersUpdateCmdArgs sbe Nothing
105+ <$> pConwayOnwards
106+ <*> pGovActionProtocolParametersUpdate sbe
107+ <*> pCostModelsFile sbe
108+ <*> pOutputFile
109+ )
110+ $ Opt. progDesc " Create a protocol parameters update."
111+ where
112+ pConwayOnwards =
113+ case sbe of
114+ ShelleyBasedEraShelley -> pure Nothing
115+ ShelleyBasedEraAllegra -> pure Nothing
116+ ShelleyBasedEraMary -> pure Nothing
117+ ShelleyBasedEraAlonzo -> pure Nothing
118+ ShelleyBasedEraBabbage -> pure Nothing
119+ ShelleyBasedEraConway -> Just <$> pUpdateProtocolParametersPostConway
120+ ShelleyBasedEraDijkstra -> Just <$> pUpdateProtocolParametersPostConway
113121
114122pUpdateProtocolParametersPreConway
115- :: ShelleyToBabbageEra era -> Parser (UpdateProtocolParametersPreConway era )
116- pUpdateProtocolParametersPreConway shelleyToBab =
117- UpdateProtocolParametersPreConway shelleyToBab
123+ :: Parser (UpdateProtocolParametersPreConway era )
124+ pUpdateProtocolParametersPreConway =
125+ UpdateProtocolParametersPreConway
118126 <$> pEpochNoUpdateProp
119127 <*> pProtocolParametersUpdateGenesisKeys
120128
0 commit comments