Skip to content

Commit 8f890fb

Browse files
committed
Elaborate compatible governance parsers over all ShelleyBasedEra constructors
inEonForShelleyBasedEra infers its eon from the branch that consumes the witness. In pCompatibleGovernanceCmds that was the experimental Era, whose membership shrinks as eras are retired: once Conway leaves it, Conway would silently take the pre-Conway branch and lose its governance commands, with no compilation error. Match on the ShelleyBasedEra constructors instead. The branches refine era to a concrete one, so IsEra resolves directly and no experimental witness needs to be threaded through this compatible module. pUpdateProtocolParametersCmd gets the same treatment, dropping its ConwayEraOnwards witness and the convert round trip to the experimental Era.
1 parent 9dfb018 commit 8f890fb

1 file changed

Lines changed: 37 additions & 35 deletions

File tree

  • cardano-cli/src/Cardano/CLI/Compatible/Governance

cardano-cli/src/Cardano/CLI/Compatible/Governance/Option.hs

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
{-# LANGUAGE GADTs #-}
2+
13
module Cardano.CLI.Compatible.Governance.Option
24
( pCompatibleGovernanceCmds
35
)
46
where
57

68
import Cardano.Api
7-
import Cardano.Api.Experimental qualified as Exp
89

910
import Cardano.CLI.Compatible.Governance.Command
1011
import Cardano.CLI.Compatible.Governance.Types
@@ -29,23 +30,29 @@ pCompatibleGovernanceCmds
2930
pCompatibleGovernanceCmds sbe =
3031
asum $
3132
catMaybes
32-
[ inEonForShelleyBasedEra
33-
( subInfoParser
34-
"governance"
35-
( Opt.progDesc $
36-
mconcat
37-
[ "Governance commands."
38-
]
39-
)
40-
[ pCreateMirCertificatesCmds sbe
41-
, pGovernanceGenesisKeyDelegationCertificate
42-
, fmap CreateCompatibleProtocolParametersUpdateCmd <$> pGovernanceActionCmds sbe
43-
]
44-
)
45-
( \w ->
46-
fmap LatestCompatibleGovernanceCmds <$> Exp.obtainCommonConstraints w Latest.pGovernanceCmds
47-
)
48-
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
4956
]
5057

5158
pGovernanceActionCmds
@@ -64,7 +71,16 @@ pGovernanceActionCmds sbe =
6471
pUpdateProtocolParametersCmd
6572
:: ShelleyBasedEra era -> Parser (GovernanceActionProtocolParametersUpdateCmdArgs era)
6673
pUpdateProtocolParametersCmd sbe =
67-
inEonForShelleyBasedEra (preConway sbe) postConway sbe
74+
case sbe of
75+
ShelleyBasedEraShelley -> preConway
76+
ShelleyBasedEraAllegra -> preConway
77+
ShelleyBasedEraMary -> preConway
78+
ShelleyBasedEraAlonzo -> preConway
79+
ShelleyBasedEraBabbage -> preConway
80+
ShelleyBasedEraConway ->
81+
mkCmd sbe (pure Nothing) (Just <$> pUpdateProtocolParametersPostConway)
82+
ShelleyBasedEraDijkstra ->
83+
mkCmd sbe (pure Nothing) (Just <$> pUpdateProtocolParametersPostConway)
6884
where
6985
-- The two branches build the same command and differ only in which of the two
7086
-- optional payloads they populate.
@@ -86,22 +102,8 @@ pUpdateProtocolParametersCmd sbe =
86102
)
87103
$ Opt.progDesc "Create a protocol parameters update."
88104

89-
preConway
90-
:: ShelleyBasedEra era'
91-
-> Parser (GovernanceActionProtocolParametersUpdateCmdArgs era')
92-
preConway sbe' =
93-
mkCmd sbe' (Just <$> pUpdateProtocolParametersPreConway) (pure Nothing)
94-
95-
postConway
96-
:: ConwayEraOnwards era'
97-
-> Parser (GovernanceActionProtocolParametersUpdateCmdArgs era')
98-
postConway conwayOnwards =
99-
mkCmd
100-
(convert conwayOnwards)
101-
(pure Nothing)
102-
( Just
103-
<$> Exp.obtainCommonConstraints (convert conwayOnwards) pUpdateProtocolParametersPostConway
104-
)
105+
preConway =
106+
mkCmd sbe (Just <$> pUpdateProtocolParametersPreConway) (pure Nothing)
105107

106108
pUpdateProtocolParametersPreConway
107109
:: Parser (UpdateProtocolParametersPreConway era)

0 commit comments

Comments
 (0)