Skip to content

Commit cdff0b9

Browse files
committed
Remove explicit EncCBOR, ToCBOR instances for ConwayPParams
in favour of the ones defined in `EraPParams`
1 parent adc7a2f commit cdff0b9

File tree

1 file changed

+1
-100
lines changed
  • eras/conway/impl/src/Cardano/Ledger/Conway

1 file changed

+1
-100
lines changed

eras/conway/impl/src/Cardano/Ledger/Conway/PParams.hs

Lines changed: 1 addition & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ import Cardano.Ledger.BaseTypes (
103103
import Cardano.Ledger.Binary (
104104
DecCBOR (..),
105105
EncCBOR (..),
106-
Encoding,
107106
FromCBOR (..),
108-
ToCBOR (..),
109107
encodeListLen,
110108
)
111109
import Cardano.Ledger.Binary.Coders
@@ -136,7 +134,7 @@ import qualified Data.Aeson as Aeson
136134
import Data.Default (Default (def))
137135
import Data.Functor.Identity (Identity)
138136
import qualified Data.Map.Strict as Map
139-
import Data.Maybe.Strict (StrictMaybe (..), isSNothing)
137+
import Data.Maybe.Strict (StrictMaybe (..))
140138
import Data.Proxy
141139
import Data.Set (Set)
142140
import qualified Data.Set as Set
@@ -889,46 +887,6 @@ instance ConwayEraPParams ConwayEra where
889887
hkdMinFeeRefScriptCostPerByteL =
890888
lens (unTHKD . cppMinFeeRefScriptCostPerByte) $ \pp x -> pp {cppMinFeeRefScriptCostPerByte = THKD x}
891889

892-
instance Era era => EncCBOR (ConwayPParams Identity era) where
893-
encCBOR ConwayPParams {..} =
894-
encode $
895-
Rec (ConwayPParams @Identity)
896-
!> To cppMinFeeA
897-
!> To cppMinFeeB
898-
!> To cppMaxBBSize
899-
!> To cppMaxTxSize
900-
!> To cppMaxBHSize
901-
!> To cppKeyDeposit
902-
!> To cppPoolDeposit
903-
!> To cppEMax
904-
!> To cppNOpt
905-
!> To cppA0
906-
!> To cppRho
907-
!> To cppTau
908-
!> To cppProtocolVersion
909-
!> To cppMinPoolCost
910-
!> To cppCoinsPerUTxOByte
911-
!> To cppCostModels
912-
!> To cppPrices
913-
!> To cppMaxTxExUnits
914-
!> To cppMaxBlockExUnits
915-
!> To cppMaxValSize
916-
!> To cppCollateralPercentage
917-
!> To cppMaxCollateralInputs
918-
-- New for Conway
919-
!> To cppPoolVotingThresholds
920-
!> To cppDRepVotingThresholds
921-
!> To cppCommitteeMinSize
922-
!> To cppCommitteeMaxTermLength
923-
!> To cppGovActionLifetime
924-
!> To cppGovActionDeposit
925-
!> To cppDRepDeposit
926-
!> To cppDRepActivity
927-
!> To cppMinFeeRefScriptCostPerByte
928-
929-
instance Era era => ToCBOR (ConwayPParams Identity era) where
930-
toCBOR = toEraCBOR @era
931-
932890
instance Era era => DecCBOR (ConwayPParams Identity era) where
933891
decCBOR =
934892
decode $
@@ -1094,60 +1052,6 @@ emptyConwayPParamsUpdate =
10941052
, cppMinFeeRefScriptCostPerByte = THKD SNothing
10951053
}
10961054

1097-
encodePParamsUpdate ::
1098-
ConwayPParams StrictMaybe era ->
1099-
Encode ('Closed 'Sparse) (ConwayPParams StrictMaybe era)
1100-
encodePParamsUpdate ppu =
1101-
Keyed ConwayPParams
1102-
!> omitStrictMaybe 0 (cppMinFeeA ppu) encCBOR
1103-
!> omitStrictMaybe 1 (cppMinFeeB ppu) encCBOR
1104-
!> omitStrictMaybe 2 (cppMaxBBSize ppu) encCBOR
1105-
!> omitStrictMaybe 3 (cppMaxTxSize ppu) encCBOR
1106-
!> omitStrictMaybe 4 (cppMaxBHSize ppu) encCBOR
1107-
!> omitStrictMaybe 5 (cppKeyDeposit ppu) encCBOR
1108-
!> omitStrictMaybe 6 (cppPoolDeposit ppu) encCBOR
1109-
!> omitStrictMaybe 7 (cppEMax ppu) encCBOR
1110-
!> omitStrictMaybe 8 (cppNOpt ppu) encCBOR
1111-
!> omitStrictMaybe 9 (cppA0 ppu) encCBOR
1112-
!> omitStrictMaybe 10 (cppRho ppu) encCBOR
1113-
!> omitStrictMaybe 11 (cppTau ppu) encCBOR
1114-
!> OmitC NoUpdate
1115-
!> omitStrictMaybe 16 (cppMinPoolCost ppu) encCBOR
1116-
!> omitStrictMaybe 17 (cppCoinsPerUTxOByte ppu) encCBOR
1117-
!> omitStrictMaybe 18 (cppCostModels ppu) encCBOR
1118-
!> omitStrictMaybe 19 (cppPrices ppu) encCBOR
1119-
!> omitStrictMaybe 20 (cppMaxTxExUnits ppu) encCBOR
1120-
!> omitStrictMaybe 21 (cppMaxBlockExUnits ppu) encCBOR
1121-
!> omitStrictMaybe 22 (cppMaxValSize ppu) encCBOR
1122-
!> omitStrictMaybe 23 (cppCollateralPercentage ppu) encCBOR
1123-
!> omitStrictMaybe 24 (cppMaxCollateralInputs ppu) encCBOR
1124-
-- New for Conway
1125-
!> omitStrictMaybe 25 (cppPoolVotingThresholds ppu) encCBOR
1126-
!> omitStrictMaybe 26 (cppDRepVotingThresholds ppu) encCBOR
1127-
!> omitStrictMaybe 27 (cppCommitteeMinSize ppu) encCBOR
1128-
!> omitStrictMaybe 28 (cppCommitteeMaxTermLength ppu) encCBOR
1129-
!> omitStrictMaybe 29 (cppGovActionLifetime ppu) encCBOR
1130-
!> omitStrictMaybe 30 (cppGovActionDeposit ppu) encCBOR
1131-
!> omitStrictMaybe 31 (cppDRepDeposit ppu) encCBOR
1132-
!> omitStrictMaybe 32 (cppDRepActivity ppu) encCBOR
1133-
!> omitStrictMaybe 33 (cppMinFeeRefScriptCostPerByte ppu) encCBOR
1134-
where
1135-
omitStrictMaybe ::
1136-
Word ->
1137-
THKD t StrictMaybe a ->
1138-
(a -> Encoding) ->
1139-
Encode ('Closed 'Sparse) (THKD t StrictMaybe a)
1140-
omitStrictMaybe key x enc =
1141-
Omit (isSNothing . unTHKD) (Key key (E (enc . fromSJust . unTHKD) x))
1142-
1143-
fromSJust :: StrictMaybe a -> a
1144-
fromSJust (SJust x) = x
1145-
fromSJust SNothing =
1146-
error "SNothing in fromSJust. This should never happen, it is guarded by isSNothing."
1147-
1148-
instance Era era => EncCBOR (ConwayPParams StrictMaybe era) where
1149-
encCBOR ppup = encode (encodePParamsUpdate ppup)
1150-
11511055
updateField :: Word -> Field (ConwayPParams StrictMaybe era)
11521056
updateField = \case
11531057
0 -> field (\x up -> up {cppMinFeeA = THKD (SJust x)}) From
@@ -1186,9 +1090,6 @@ updateField = \case
11861090
instance Era era => DecCBOR (ConwayPParams StrictMaybe era) where
11871091
decCBOR = decode (SparseKeyed "PParamsUpdate" emptyConwayPParamsUpdate updateField [])
11881092

1189-
instance Era era => ToCBOR (ConwayPParams StrictMaybe era) where
1190-
toCBOR = toEraCBOR @era
1191-
11921093
instance Era era => FromCBOR (ConwayPParams StrictMaybe era) where
11931094
fromCBOR = fromEraCBOR @era
11941095

0 commit comments

Comments
 (0)