@@ -426,8 +426,46 @@ instance FromJSON ShelleyGenesisStaking where
426426 <$> (forceElemsToWHNF <$> obj .: " pools" )
427427 <*> (forceElemsToWHNF <$> obj .: " stake" )
428428
429+ shelleyGenesisDecoder :: Decoder s ShelleyGenesis
430+ shelleyGenesisDecoder =
431+ decodeRecordNamed " ShelleyGenesis" (const 15 ) $ do
432+ sgSystemStart <- decCBOR
433+ sgNetworkMagic <- decCBOR
434+ sgNetworkId <- decCBOR
435+ sgActiveSlotsCoeff <- activeSlotsCoeffDecCBOR
436+ sgSecurityParam <- decCBOR
437+ sgEpochLength <- decCBOR
438+ sgSlotsPerKESPeriod <- decCBOR
439+ sgMaxKESEvolutions <- decCBOR
440+ sgSlotLength <- decCBOR
441+ sgUpdateQuorum <- decCBOR
442+ sgMaxLovelaceSupply <- decCBOR
443+ sgProtocolParams <- decCBOR
444+ sgGenDelegs <- decCBOR
445+ sgInitialFunds <- decCBOR
446+ sgStaking <- decCBOR
447+ pure $
448+ ShelleyGenesis
449+ sgSystemStart
450+ sgNetworkMagic
451+ sgNetworkId
452+ sgActiveSlotsCoeff
453+ sgSecurityParam
454+ (EpochSize sgEpochLength)
455+ sgSlotsPerKESPeriod
456+ sgMaxKESEvolutions
457+ sgSlotLength
458+ sgUpdateQuorum
459+ sgMaxLovelaceSupply
460+ sgProtocolParams
461+ sgGenDelegs
462+ sgInitialFunds
463+ sgStaking
464+
429465-- | Genesis are always encoded with the version of era they are defined in.
430- instance DecCBOR ShelleyGenesis
466+ instance DecCBOR ShelleyGenesis where
467+ decCBOR = shelleyGenesisDecoder
468+ {-# INLINE decCBOR #-}
431469
432470instance EncCBOR ShelleyGenesis
433471
@@ -469,40 +507,8 @@ instance ToCBOR ShelleyGenesis where
469507 <> encCBOR sgStaking
470508
471509instance FromCBOR ShelleyGenesis where
472- fromCBOR = toPlainDecoder Nothing shelleyProtVer $ do
473- decodeRecordNamed " ShelleyGenesis" (const 15 ) $ do
474- sgSystemStart <- decCBOR
475- sgNetworkMagic <- decCBOR
476- sgNetworkId <- decCBOR
477- sgActiveSlotsCoeff <- activeSlotsCoeffDecCBOR
478- sgSecurityParam <- decCBOR
479- sgEpochLength <- decCBOR
480- sgSlotsPerKESPeriod <- decCBOR
481- sgMaxKESEvolutions <- decCBOR
482- sgSlotLength <- decCBOR
483- sgUpdateQuorum <- decCBOR
484- sgMaxLovelaceSupply <- decCBOR
485- sgProtocolParams <- decCBOR
486- sgGenDelegs <- decCBOR
487- sgInitialFunds <- decCBOR
488- sgStaking <- decCBOR
489- pure $
490- ShelleyGenesis
491- sgSystemStart
492- sgNetworkMagic
493- sgNetworkId
494- sgActiveSlotsCoeff
495- sgSecurityParam
496- (EpochSize sgEpochLength)
497- sgSlotsPerKESPeriod
498- sgMaxKESEvolutions
499- sgSlotLength
500- sgUpdateQuorum
501- sgMaxLovelaceSupply
502- sgProtocolParams
503- sgGenDelegs
504- sgInitialFunds
505- sgStaking
510+ fromCBOR = toPlainDecoder Nothing shelleyProtVer shelleyGenesisDecoder
511+ {-# INLINE fromCBOR #-}
506512
507513-- | Serialize `PositiveUnitInterval` type in the same way `Rational` is serialized,
508514-- however ensure there is no usage of tag 30 by enforcing Shelley protocol version.
0 commit comments