Skip to content

Commit d78cbcb

Browse files
committed
Remove unused ShelleyToBabbageEra witness from UpdateProtocolParametersPreConway
The `eon` field was never read: the only consumer, `shelleyToBabbageProtocolParametersUpdate`, bound it as `_stB`. It was, however, the sole reason `pUpdateProtocolParametersCmd` needed a seven-way match on the `ShelleyBasedEra` constructors to conjure the witness. Dropping the field lets the parser use `inEonForShelleyBasedEra` like the rest of this branch, and collapses the no-op `forShelleyBasedEraMaybeEon` lookup in `pGovernanceActionProtocolParametersUpdateCmd` to `Just`. No behaviour change: `create-protocol-parameters-update` is still registered for all five pre-Conway eras and for Conway onwards.
1 parent fa7106e commit d78cbcb

4 files changed

Lines changed: 29 additions & 41 deletions

File tree

.changes/replace-era-case-combinators.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ pr: 1438
33
kind:
44
- refactoring
55
description: |
6-
Replaced uses of cardano-api's `caseShelleyToBabbageOrConwayEraOnwards` with `inEonForShelleyBasedEra`, or with a match on the `ShelleyBasedEra` constructors where both branches need era constraints.
6+
Replaced uses of cardano-api's `caseShelleyToBabbageOrConwayEraOnwards` with `inEonForShelleyBasedEra`, and dropped the unused `ShelleyToBabbageEra` witness from `UpdateProtocolParametersPreConway` so the pre-Conway protocol parameters update parser no longer needs an era case split.

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

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE DataKinds #-}
22
{-# LANGUAGE GADTs #-}
3-
{-# LANGUAGE LambdaCase #-}
43
{-# LANGUAGE ScopedTypeVariables #-}
54

65
module Cardano.CLI.Compatible.Governance.Option
@@ -67,66 +66,56 @@ pGovernanceActionCmds sbe =
6766
]
6867

6968
pGovernanceActionProtocolParametersUpdateCmd
70-
:: ()
71-
=> ShelleyBasedEra era
69+
:: ShelleyBasedEra era
7270
-> Maybe (Parser (GovernanceActionProtocolParametersUpdateCmdArgs era))
73-
pGovernanceActionProtocolParametersUpdateCmd sbe = do
74-
w <- forShelleyBasedEraMaybeEon sbe
75-
pure $
76-
pUpdateProtocolParametersCmd w
71+
pGovernanceActionProtocolParametersUpdateCmd =
72+
Just . pUpdateProtocolParametersCmd
7773

7874
pUpdateProtocolParametersCmd
7975
:: ShelleyBasedEra era -> Parser (GovernanceActionProtocolParametersUpdateCmdArgs era)
80-
pUpdateProtocolParametersCmd = \case
81-
ShelleyBasedEraShelley -> preConway ShelleyToBabbageEraShelley
82-
ShelleyBasedEraAllegra -> preConway ShelleyToBabbageEraAllegra
83-
ShelleyBasedEraMary -> preConway ShelleyToBabbageEraMary
84-
ShelleyBasedEraAlonzo -> preConway ShelleyToBabbageEraAlonzo
85-
ShelleyBasedEraBabbage -> preConway ShelleyToBabbageEraBabbage
86-
ShelleyBasedEraConway -> postConway ConwayEraOnwardsConway
87-
ShelleyBasedEraDijkstra -> postConway ConwayEraOnwardsDijkstra
76+
pUpdateProtocolParametersCmd sbe =
77+
inEonForShelleyBasedEra (preConway sbe) postConway sbe
8878
where
8979
preConway
90-
:: ShelleyToBabbageEra era'
80+
:: ShelleyBasedEra era'
9181
-> Parser (GovernanceActionProtocolParametersUpdateCmdArgs era')
92-
preConway shelleyToBab =
93-
let sbe = convert shelleyToBab
94-
in Opt.hsubparser
95-
$ commandWithMetavar "create-protocol-parameters-update"
96-
$ Opt.info
97-
( GovernanceActionProtocolParametersUpdateCmdArgs
98-
(convert shelleyToBab)
99-
<$> fmap Just (pUpdateProtocolParametersPreConway shelleyToBab)
100-
<*> pure Nothing
101-
<*> pGovActionProtocolParametersUpdate sbe
102-
<*> pCostModelsFile sbe
103-
<*> pOutputFile
104-
)
105-
$ Opt.progDesc "Create a protocol parameters update."
82+
preConway sbe' =
83+
Opt.hsubparser
84+
$ commandWithMetavar "create-protocol-parameters-update"
85+
$ Opt.info
86+
( GovernanceActionProtocolParametersUpdateCmdArgs
87+
sbe'
88+
<$> fmap Just pUpdateProtocolParametersPreConway
89+
<*> pure Nothing
90+
<*> pGovActionProtocolParametersUpdate sbe'
91+
<*> pCostModelsFile sbe'
92+
<*> pOutputFile
93+
)
94+
$ Opt.progDesc "Create a protocol parameters update."
10695

10796
postConway
10897
:: ConwayEraOnwards era'
10998
-> Parser (GovernanceActionProtocolParametersUpdateCmdArgs era')
11099
postConway conwayOnwards =
111-
let sbe = convert conwayOnwards
100+
let sbe' = convert conwayOnwards
112101
ppup = fmap Just (obtainCommonConstraints (convert conwayOnwards) pUpdateProtocolParametersPostConway)
113102
in Opt.hsubparser
114103
$ commandWithMetavar "create-protocol-parameters-update"
115104
$ Opt.info
116105
( GovernanceActionProtocolParametersUpdateCmdArgs
117-
(convert conwayOnwards)
106+
sbe'
118107
Nothing
119108
<$> ppup
120-
<*> pGovActionProtocolParametersUpdate sbe
121-
<*> pCostModelsFile sbe
109+
<*> pGovActionProtocolParametersUpdate sbe'
110+
<*> pCostModelsFile sbe'
122111
<*> pOutputFile
123112
)
124113
$ Opt.progDesc "Create a protocol parameters update."
125114

126115
pUpdateProtocolParametersPreConway
127-
:: ShelleyToBabbageEra era -> Parser (UpdateProtocolParametersPreConway era)
128-
pUpdateProtocolParametersPreConway shelleyToBab =
129-
UpdateProtocolParametersPreConway shelleyToBab
116+
:: Parser (UpdateProtocolParametersPreConway era)
117+
pUpdateProtocolParametersPreConway =
118+
UpdateProtocolParametersPreConway
130119
<$> pEpochNoUpdateProp
131120
<*> pProtocolParametersUpdateGenesisKeys
132121

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ shelleyToBabbageProtocolParametersUpdate
132132
shelleyToBabbageProtocolParametersUpdate sbe args = do
133133
let oFp = uppFilePath args
134134
anyEra = AnyShelleyBasedEra sbe
135-
UpdateProtocolParametersPreConway _stB expEpoch genesisVerKeys <-
135+
UpdateProtocolParametersPreConway expEpoch genesisVerKeys <-
136136
fromExceptTCli $
137137
hoistMaybe (GovernanceActionsValueUpdateProtocolParametersNotFound anyEra) $
138138
uppPreConway args

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ data GovernanceActionProtocolParametersUpdateCmdArgs era
3838

3939
data UpdateProtocolParametersPreConway era
4040
= UpdateProtocolParametersPreConway
41-
{ eon :: !(ShelleyToBabbageEra era)
42-
, expiryEpoch :: !EpochNo
41+
{ expiryEpoch :: !EpochNo
4342
, genesisVerificationKeys :: ![VerificationKeyFile In]
4443
}
4544

0 commit comments

Comments
 (0)