Skip to content

Commit adc7a2f

Browse files
committed
Remove explicit EcCBOR, ToCBOR instances for BabbagePParams
in favour of the ones defined in `EraPParams`
1 parent 4c82185 commit adc7a2f

File tree

1 file changed

+0
-85
lines changed
  • eras/babbage/impl/src/Cardano/Ledger/Babbage

1 file changed

+0
-85
lines changed

eras/babbage/impl/src/Cardano/Ledger/Babbage/PParams.hs

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -57,28 +57,19 @@ import Cardano.Ledger.BaseTypes (
5757
ProtVer (..),
5858
StrictMaybe (..),
5959
UnitInterval,
60-
isSNothing,
6160
)
6261
import Cardano.Ledger.Binary (
6362
DecCBOR (..),
6463
EncCBOR (..),
65-
Encoding,
6664
FromCBOR (..),
67-
ToCBOR (..),
6865
decodeRecordNamed,
69-
encodeListLen,
7066
)
7167
import Cardano.Ledger.Binary.Coders (
7268
Decode (..),
73-
Density (..),
74-
Encode (..),
7569
Field (..),
76-
Wrapped (..),
7770
decode,
78-
encode,
7971
field,
8072
invalidField,
81-
(!>),
8273
)
8374
import Cardano.Ledger.Coin (Coin (..))
8475
import Cardano.Ledger.Core (EraPParams (..))
@@ -291,35 +282,6 @@ instance EraGov BabbageEra where
291282

292283
obligationGovState = const mempty
293284

294-
instance Era era => EncCBOR (BabbagePParams Identity era) where
295-
encCBOR BabbagePParams {..} =
296-
encodeListLen 22
297-
<> encCBOR bppMinFeeA
298-
<> encCBOR bppMinFeeB
299-
<> encCBOR bppMaxBBSize
300-
<> encCBOR bppMaxTxSize
301-
<> encCBOR bppMaxBHSize
302-
<> encCBOR bppKeyDeposit
303-
<> encCBOR bppPoolDeposit
304-
<> encCBOR bppEMax
305-
<> encCBOR bppNOpt
306-
<> encCBOR bppA0
307-
<> encCBOR bppRho
308-
<> encCBOR bppTau
309-
<> encCBOR bppProtocolVersion
310-
<> encCBOR bppMinPoolCost
311-
<> encCBOR bppCoinsPerUTxOByte
312-
<> encCBOR bppCostModels
313-
<> encCBOR bppPrices
314-
<> encCBOR bppMaxTxExUnits
315-
<> encCBOR bppMaxBlockExUnits
316-
<> encCBOR bppMaxValSize
317-
<> encCBOR bppCollateralPercentage
318-
<> encCBOR bppMaxCollateralInputs
319-
320-
instance Era era => ToCBOR (BabbagePParams Identity era) where
321-
toCBOR = toEraCBOR @era
322-
323285
instance Era era => DecCBOR (BabbagePParams Identity era) where
324286
decCBOR =
325287
decodeRecordNamed "PParams" (const 22) $ do
@@ -447,50 +409,6 @@ emptyBabbagePParamsUpdate =
447409
, bppMaxCollateralInputs = SNothing
448410
}
449411

450-
-- =======================================================
451-
-- A PParamsUpdate has StrictMaybe fields, we want to Sparse encode it, by
452-
-- writing only those fields where the field is (SJust x), that is the role of
453-
-- the local function (omitStrictMaybe key x)
454-
455-
encodePParamsUpdate ::
456-
BabbagePParams StrictMaybe era ->
457-
Encode ('Closed 'Sparse) (BabbagePParams StrictMaybe era)
458-
encodePParamsUpdate ppup =
459-
Keyed BabbagePParams
460-
!> omitStrictMaybe 0 (bppMinFeeA ppup) encCBOR
461-
!> omitStrictMaybe 1 (bppMinFeeB ppup) encCBOR
462-
!> omitStrictMaybe 2 (bppMaxBBSize ppup) encCBOR
463-
!> omitStrictMaybe 3 (bppMaxTxSize ppup) encCBOR
464-
!> omitStrictMaybe 4 (bppMaxBHSize ppup) encCBOR
465-
!> omitStrictMaybe 5 (bppKeyDeposit ppup) encCBOR
466-
!> omitStrictMaybe 6 (bppPoolDeposit ppup) encCBOR
467-
!> omitStrictMaybe 7 (bppEMax ppup) encCBOR
468-
!> omitStrictMaybe 8 (bppNOpt ppup) encCBOR
469-
!> omitStrictMaybe 9 (bppA0 ppup) encCBOR
470-
!> omitStrictMaybe 10 (bppRho ppup) encCBOR
471-
!> omitStrictMaybe 11 (bppTau ppup) encCBOR
472-
!> omitStrictMaybe 14 (bppProtocolVersion ppup) encCBOR
473-
!> omitStrictMaybe 16 (bppMinPoolCost ppup) encCBOR
474-
!> omitStrictMaybe 17 (bppCoinsPerUTxOByte ppup) encCBOR
475-
!> omitStrictMaybe 18 (bppCostModels ppup) encCBOR
476-
!> omitStrictMaybe 19 (bppPrices ppup) encCBOR
477-
!> omitStrictMaybe 20 (bppMaxTxExUnits ppup) encCBOR
478-
!> omitStrictMaybe 21 (bppMaxBlockExUnits ppup) encCBOR
479-
!> omitStrictMaybe 22 (bppMaxValSize ppup) encCBOR
480-
!> omitStrictMaybe 23 (bppCollateralPercentage ppup) encCBOR
481-
!> omitStrictMaybe 24 (bppMaxCollateralInputs ppup) encCBOR
482-
where
483-
omitStrictMaybe ::
484-
Word -> StrictMaybe a -> (a -> Encoding) -> Encode ('Closed 'Sparse) (StrictMaybe a)
485-
omitStrictMaybe key x enc = Omit isSNothing (Key key (E (enc . fromSJust) x))
486-
487-
fromSJust :: StrictMaybe a -> a
488-
fromSJust (SJust x) = x
489-
fromSJust SNothing = error "SNothing in fromSJust. This should never happen, it is guarded by isSNothing."
490-
491-
instance Era era => EncCBOR (BabbagePParams StrictMaybe era) where
492-
encCBOR ppup = encode (encodePParamsUpdate ppup)
493-
494412
updateField :: Word -> Field (BabbagePParams StrictMaybe era)
495413
updateField 0 = field (\x up -> up {bppMinFeeA = SJust x}) From
496414
updateField 1 = field (\x up -> up {bppMinFeeB = SJust x}) From
@@ -521,9 +439,6 @@ instance Era era => DecCBOR (BabbagePParams StrictMaybe era) where
521439
decode
522440
(SparseKeyed "PParamsUpdate" emptyBabbagePParamsUpdate updateField [])
523441

524-
instance Era era => ToCBOR (BabbagePParams StrictMaybe era) where
525-
toCBOR = toEraCBOR @era
526-
527442
instance Era era => FromCBOR (BabbagePParams StrictMaybe era) where
528443
fromCBOR = fromEraCBOR @era
529444

0 commit comments

Comments
 (0)