{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wno-orphans #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}

-- | The various Cardano protocol parameters, including:
--
-- * the current values of updatable protocol parameters: 'ProtocolParameters'
-- * updates to protocol parameters: 'ProtocolParametersUpdate'
-- * update proposals that can be embedded in transactions: 'UpdateProposal'
-- * parameters fixed in the genesis file: 'GenesisParameters'
module Cardano.Api.ProtocolParameters
  ( -- * The updatable protocol parameters
    EpochNo

    -- * The updatable protocol parameters
  , LedgerProtocolParameters (..)
  , EraBasedProtocolParametersUpdate (..)
  , AlonzoOnwardsPParams (..)
  , CommonProtocolParametersUpdate (..)
  , DeprecatedAfterBabbagePParams (..)
  , DeprecatedAfterMaryPParams (..)
  , ShelleyToAlonzoPParams (..)
  , IntroducedInBabbagePParams (..)
  , IntroducedInConwayPParams (..)
  , createEraBasedProtocolParamUpdate
  , createPParams

    -- * Errors
  , ProtocolParametersError (..)
  , ProtocolParametersConversionError (..)

    -- * PraosNonce
  , PraosNonce
  , makePraosNonce

    -- * Execution units, prices and cost models,
  , ExecutionUnits (..)
  , ExecutionUnitPrices (..)
  , CostModels (..)
  , CostModel (..)
  , fromAlonzoCostModels

    -- * Update proposals to change the protocol parameters
  , UpdateProposal (..)
  , makeShelleyUpdateProposal

    -- * Internal conversion functions
  , toLedgerNonce
  , toLedgerUpdate
  , fromLedgerUpdate
  , toLedgerProposedPPUpdates
  , fromLedgerProposedPPUpdates
  , fromLedgerPParamsUpdate
  , toAlonzoPrices
  , fromAlonzoPrices
  , toAlonzoScriptLanguage
  , fromAlonzoScriptLanguage
  , toAlonzoCostModel
  , fromAlonzoCostModel
  , toAlonzoCostModels

    -- * Data family instances
  , AsType (..)

    -- ** Era-dependent protocol features
  )
where

import Cardano.Api.Address
import Cardano.Api.Byron.Internal.Key
import Cardano.Api.Certificate.Internal.StakePoolMetadata
import Cardano.Api.Era
import Cardano.Api.Error
import Cardano.Api.HasTypeProxy
import Cardano.Api.Internal.Orphans ()
import Cardano.Api.Key.Internal
import Cardano.Api.Plutus.Internal.Script
import Cardano.Api.Pretty
import Cardano.Api.Serialise.Cbor
import Cardano.Api.Serialise.Json (toRationalJSON)
import Cardano.Api.Serialise.Raw
import Cardano.Api.Serialise.SerialiseUsing
import Cardano.Api.Serialise.TextEnvelope.Internal
import Cardano.Api.Tx.Internal.TxMetadata
import Cardano.Api.Value.Internal

import Cardano.Binary qualified as CBOR
import Cardano.Crypto.Hash qualified as Hash
import Cardano.Crypto.Hash.Class qualified as Crypto
import Cardano.Ledger.Alonzo.PParams qualified as Ledger
import Cardano.Ledger.Alonzo.Scripts qualified as Alonzo
import Cardano.Ledger.Api.Era qualified as Ledger
import Cardano.Ledger.Api.PParams
import Cardano.Ledger.Babbage.Core qualified as Ledger
import Cardano.Ledger.BaseTypes qualified as Ledger
import Cardano.Ledger.Coin qualified as L
import Cardano.Ledger.Conway.PParams qualified as Ledger
import Cardano.Ledger.Hashes (HASH)
import Cardano.Ledger.Plutus.CostModels qualified as Plutus
import Cardano.Ledger.Plutus.Language qualified as Plutus
import Cardano.Ledger.Shelley.API qualified as Ledger
import Cardano.Slotting.Slot (EpochNo (..))
import PlutusLedgerApi.Common (CostModelApplyError)

import Data.Aeson
  ( FromJSON (..)
  , ToJSON (..)
  , object
  , withObject
  , (.!=)
  , (.:)
  , (.:?)
  , (.=)
  )
import Data.Bifunctor (bimap, first)
import Data.ByteString (ByteString)
import Data.Data (Data)
import Data.Either.Combinators (maybeToRight)
import Data.Int (Int64)
import Data.Map.Strict (Map)
import Data.Map.Strict qualified as Map
import Data.Maybe.Strict (StrictMaybe (..))
import Data.Typeable
import Data.Word
import GHC.Exts (IsList (..))
import GHC.Generics
import Lens.Micro
import Numeric.Natural
import Text.PrettyBy.Default (display)

-- -----------------------------------------------------------------------------
-- Era based ledger protocol parameters
--
newtype LedgerProtocolParameters era = LedgerProtocolParameters
  { forall era.
LedgerProtocolParameters era -> PParams (ShelleyLedgerEra era)
unLedgerProtocolParameters :: Ledger.PParams (ShelleyLedgerEra era)
  }

instance IsShelleyBasedEra era => Show (LedgerProtocolParameters era) where
  show :: LedgerProtocolParameters era -> String
show (LedgerProtocolParameters PParams (ShelleyLedgerEra era)
pp) =
    ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era => String) -> String
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints (forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra @era) ((ShelleyBasedEraConstraints era => String) -> String)
-> (ShelleyBasedEraConstraints era => String) -> String
forall a b. (a -> b) -> a -> b
$
      PParams (ShelleyLedgerEra era) -> String
forall a. Show a => a -> String
show PParams (ShelleyLedgerEra era)
pp

instance IsShelleyBasedEra era => Eq (LedgerProtocolParameters era) where
  LedgerProtocolParameters PParams (ShelleyLedgerEra era)
a == :: LedgerProtocolParameters era
-> LedgerProtocolParameters era -> Bool
== LedgerProtocolParameters PParams (ShelleyLedgerEra era)
b =
    ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era => Bool) -> Bool
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints (forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra @era) ((ShelleyBasedEraConstraints era => Bool) -> Bool)
-> (ShelleyBasedEraConstraints era => Bool) -> Bool
forall a b. (a -> b) -> a -> b
$
      PParams (ShelleyLedgerEra era)
a PParams (ShelleyLedgerEra era)
-> PParams (ShelleyLedgerEra era) -> Bool
forall a. Eq a => a -> a -> Bool
== PParams (ShelleyLedgerEra era)
b

createPParams
  :: ShelleyBasedEra era
  -> EraBasedProtocolParametersUpdate era
  -> Ledger.PParams (ShelleyLedgerEra era)
createPParams :: forall era.
ShelleyBasedEra era
-> EraBasedProtocolParametersUpdate era
-> PParams (ShelleyLedgerEra era)
createPParams ShelleyBasedEra era
sbe EraBasedProtocolParametersUpdate era
ebPParamsUpdate =
  ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era =>
    PParams (ShelleyLedgerEra era))
-> PParams (ShelleyLedgerEra era)
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe ((ShelleyBasedEraConstraints era => PParams (ShelleyLedgerEra era))
 -> PParams (ShelleyLedgerEra era))
-> (ShelleyBasedEraConstraints era =>
    PParams (ShelleyLedgerEra era))
-> PParams (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$
    let ppUp :: PParamsUpdate (ShelleyLedgerEra era)
ppUp = ShelleyBasedEra era
-> EraBasedProtocolParametersUpdate era
-> PParamsUpdate (ShelleyLedgerEra era)
forall era.
ShelleyBasedEra era
-> EraBasedProtocolParametersUpdate era
-> PParamsUpdate (ShelleyLedgerEra era)
createEraBasedProtocolParamUpdate ShelleyBasedEra era
sbe EraBasedProtocolParametersUpdate era
ebPParamsUpdate
     in PParams (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
-> PParams (ShelleyLedgerEra era)
forall era.
EraPParams era =>
PParams era -> PParamsUpdate era -> PParams era
Ledger.applyPPUpdates PParams (ShelleyLedgerEra era)
forall era. EraPParams era => PParams era
emptyPParams PParamsUpdate (ShelleyLedgerEra era)
ppUp

-- -----------------------------------------------------------------------------
-- Era based Ledger protocol parameters update
--

-- | Each constructor corresponds to the set of protocol parameters available
-- in a given era.
data EraBasedProtocolParametersUpdate era where
  ShelleyEraBasedProtocolParametersUpdate
    :: CommonProtocolParametersUpdate
    -> DeprecatedAfterMaryPParams ShelleyEra
    -> DeprecatedAfterBabbagePParams ShelleyEra
    -> ShelleyToAlonzoPParams ShelleyEra
    -> EraBasedProtocolParametersUpdate ShelleyEra
  AllegraEraBasedProtocolParametersUpdate
    :: CommonProtocolParametersUpdate
    -> DeprecatedAfterMaryPParams AllegraEra
    -> ShelleyToAlonzoPParams AllegraEra
    -> DeprecatedAfterBabbagePParams ShelleyEra
    -> EraBasedProtocolParametersUpdate AllegraEra
  MaryEraBasedProtocolParametersUpdate
    :: CommonProtocolParametersUpdate
    -> DeprecatedAfterMaryPParams MaryEra
    -> ShelleyToAlonzoPParams MaryEra
    -> DeprecatedAfterBabbagePParams ShelleyEra
    -> EraBasedProtocolParametersUpdate MaryEra
  AlonzoEraBasedProtocolParametersUpdate
    :: CommonProtocolParametersUpdate
    -> ShelleyToAlonzoPParams AlonzoEra
    -> AlonzoOnwardsPParams AlonzoEra
    -> DeprecatedAfterBabbagePParams ShelleyEra
    -> EraBasedProtocolParametersUpdate AlonzoEra
  BabbageEraBasedProtocolParametersUpdate
    :: CommonProtocolParametersUpdate
    -> AlonzoOnwardsPParams BabbageEra
    -> DeprecatedAfterBabbagePParams ShelleyEra
    -> IntroducedInBabbagePParams BabbageEra
    -> EraBasedProtocolParametersUpdate BabbageEra
  ConwayEraBasedProtocolParametersUpdate
    :: CommonProtocolParametersUpdate
    -> AlonzoOnwardsPParams ConwayEra
    -> IntroducedInBabbagePParams ConwayEra
    -> IntroducedInConwayPParams (ShelleyLedgerEra ConwayEra)
    -> EraBasedProtocolParametersUpdate ConwayEra

deriving instance Show (EraBasedProtocolParametersUpdate era)

deriving instance Eq (EraBasedProtocolParametersUpdate era)

instance IsShelleyBasedEra era => ToCBOR (EraBasedProtocolParametersUpdate era) where
  toCBOR :: EraBasedProtocolParametersUpdate era -> Encoding
toCBOR =
    ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era =>
    EraBasedProtocolParametersUpdate era -> Encoding)
-> EraBasedProtocolParametersUpdate era
-> Encoding
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints (forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra @era) ((ShelleyBasedEraConstraints era =>
  EraBasedProtocolParametersUpdate era -> Encoding)
 -> EraBasedProtocolParametersUpdate era -> Encoding)
-> (ShelleyBasedEraConstraints era =>
    EraBasedProtocolParametersUpdate era -> Encoding)
-> EraBasedProtocolParametersUpdate era
-> Encoding
forall a b. (a -> b) -> a -> b
$
      PParamsUpdate (ShelleyLedgerEra era) -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (PParamsUpdate (ShelleyLedgerEra era) -> Encoding)
-> (EraBasedProtocolParametersUpdate era
    -> PParamsUpdate (ShelleyLedgerEra era))
-> EraBasedProtocolParametersUpdate era
-> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyBasedEra era
-> EraBasedProtocolParametersUpdate era
-> PParamsUpdate (ShelleyLedgerEra era)
forall era.
ShelleyBasedEra era
-> EraBasedProtocolParametersUpdate era
-> PParamsUpdate (ShelleyLedgerEra era)
createEraBasedProtocolParamUpdate ShelleyBasedEra era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra

instance IsShelleyBasedEra era => FromCBOR (EraBasedProtocolParametersUpdate era) where
  fromCBOR :: forall s. Decoder s (EraBasedProtocolParametersUpdate era)
fromCBOR =
    ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era =>
    Decoder s (EraBasedProtocolParametersUpdate era))
-> Decoder s (EraBasedProtocolParametersUpdate era)
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints (forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra @era) ((ShelleyBasedEraConstraints era =>
  Decoder s (EraBasedProtocolParametersUpdate era))
 -> Decoder s (EraBasedProtocolParametersUpdate era))
-> (ShelleyBasedEraConstraints era =>
    Decoder s (EraBasedProtocolParametersUpdate era))
-> Decoder s (EraBasedProtocolParametersUpdate era)
forall a b. (a -> b) -> a -> b
$
      ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> EraBasedProtocolParametersUpdate era
forall era.
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> EraBasedProtocolParametersUpdate era
fromLedgerPParamsUpdate ShelleyBasedEra era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra (PParamsUpdate (ShelleyLedgerEra era)
 -> EraBasedProtocolParametersUpdate era)
-> Decoder s (PParamsUpdate (ShelleyLedgerEra era))
-> Decoder s (EraBasedProtocolParametersUpdate era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s (PParamsUpdate (ShelleyLedgerEra era))
forall s. Decoder s (PParamsUpdate (ShelleyLedgerEra era))
forall a s. FromCBOR a => Decoder s a
fromCBOR

data IntroducedInConwayPParams era
  = IntroducedInConwayPParams
  { forall era.
IntroducedInConwayPParams era -> StrictMaybe PoolVotingThresholds
icPoolVotingThresholds :: StrictMaybe Ledger.PoolVotingThresholds
  , forall era.
IntroducedInConwayPParams era -> StrictMaybe DRepVotingThresholds
icDRepVotingThresholds :: StrictMaybe Ledger.DRepVotingThresholds
  , forall era. IntroducedInConwayPParams era -> StrictMaybe Word16
icMinCommitteeSize :: StrictMaybe Word16
  , forall era.
IntroducedInConwayPParams era -> StrictMaybe EpochInterval
icCommitteeTermLength :: StrictMaybe Ledger.EpochInterval
  , forall era.
IntroducedInConwayPParams era -> StrictMaybe EpochInterval
icGovActionLifetime :: StrictMaybe Ledger.EpochInterval
  , forall era. IntroducedInConwayPParams era -> StrictMaybe Coin
icGovActionDeposit :: StrictMaybe Ledger.Coin
  , forall era. IntroducedInConwayPParams era -> StrictMaybe Coin
icDRepDeposit :: StrictMaybe Ledger.Coin
  , forall era.
IntroducedInConwayPParams era -> StrictMaybe EpochInterval
icDRepActivity :: StrictMaybe Ledger.EpochInterval
  , forall era.
IntroducedInConwayPParams era -> StrictMaybe NonNegativeInterval
icMinFeeRefScriptCostPerByte :: StrictMaybe Ledger.NonNegativeInterval
  }
  deriving (IntroducedInConwayPParams era
-> IntroducedInConwayPParams era -> Bool
(IntroducedInConwayPParams era
 -> IntroducedInConwayPParams era -> Bool)
-> (IntroducedInConwayPParams era
    -> IntroducedInConwayPParams era -> Bool)
-> Eq (IntroducedInConwayPParams era)
forall era.
IntroducedInConwayPParams era
-> IntroducedInConwayPParams era -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall era.
IntroducedInConwayPParams era
-> IntroducedInConwayPParams era -> Bool
== :: IntroducedInConwayPParams era
-> IntroducedInConwayPParams era -> Bool
$c/= :: forall era.
IntroducedInConwayPParams era
-> IntroducedInConwayPParams era -> Bool
/= :: IntroducedInConwayPParams era
-> IntroducedInConwayPParams era -> Bool
Eq, Int -> IntroducedInConwayPParams era -> ShowS
[IntroducedInConwayPParams era] -> ShowS
IntroducedInConwayPParams era -> String
(Int -> IntroducedInConwayPParams era -> ShowS)
-> (IntroducedInConwayPParams era -> String)
-> ([IntroducedInConwayPParams era] -> ShowS)
-> Show (IntroducedInConwayPParams era)
forall era. Int -> IntroducedInConwayPParams era -> ShowS
forall era. [IntroducedInConwayPParams era] -> ShowS
forall era. IntroducedInConwayPParams era -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall era. Int -> IntroducedInConwayPParams era -> ShowS
showsPrec :: Int -> IntroducedInConwayPParams era -> ShowS
$cshow :: forall era. IntroducedInConwayPParams era -> String
show :: IntroducedInConwayPParams era -> String
$cshowList :: forall era. [IntroducedInConwayPParams era] -> ShowS
showList :: [IntroducedInConwayPParams era] -> ShowS
Show)

createIntroducedInConwayPParams
  :: Ledger.ConwayEraPParams ledgerera
  => IntroducedInConwayPParams ledgerera
  -> Ledger.PParamsUpdate ledgerera
createIntroducedInConwayPParams :: forall ledgerera.
ConwayEraPParams ledgerera =>
IntroducedInConwayPParams ledgerera -> PParamsUpdate ledgerera
createIntroducedInConwayPParams IntroducedInConwayPParams{StrictMaybe Word16
StrictMaybe Coin
StrictMaybe DRepVotingThresholds
StrictMaybe PoolVotingThresholds
StrictMaybe EpochInterval
StrictMaybe NonNegativeInterval
icPoolVotingThresholds :: forall era.
IntroducedInConwayPParams era -> StrictMaybe PoolVotingThresholds
icDRepVotingThresholds :: forall era.
IntroducedInConwayPParams era -> StrictMaybe DRepVotingThresholds
icMinCommitteeSize :: forall era. IntroducedInConwayPParams era -> StrictMaybe Word16
icCommitteeTermLength :: forall era.
IntroducedInConwayPParams era -> StrictMaybe EpochInterval
icGovActionLifetime :: forall era.
IntroducedInConwayPParams era -> StrictMaybe EpochInterval
icGovActionDeposit :: forall era. IntroducedInConwayPParams era -> StrictMaybe Coin
icDRepDeposit :: forall era. IntroducedInConwayPParams era -> StrictMaybe Coin
icDRepActivity :: forall era.
IntroducedInConwayPParams era -> StrictMaybe EpochInterval
icMinFeeRefScriptCostPerByte :: forall era.
IntroducedInConwayPParams era -> StrictMaybe NonNegativeInterval
icPoolVotingThresholds :: StrictMaybe PoolVotingThresholds
icDRepVotingThresholds :: StrictMaybe DRepVotingThresholds
icMinCommitteeSize :: StrictMaybe Word16
icCommitteeTermLength :: StrictMaybe EpochInterval
icGovActionLifetime :: StrictMaybe EpochInterval
icGovActionDeposit :: StrictMaybe Coin
icDRepDeposit :: StrictMaybe Coin
icDRepActivity :: StrictMaybe EpochInterval
icMinFeeRefScriptCostPerByte :: StrictMaybe NonNegativeInterval
..} =
  PParamsUpdate ledgerera
forall era. EraPParams era => PParamsUpdate era
Ledger.emptyPParamsUpdate
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe PoolVotingThresholds
 -> Identity (StrictMaybe PoolVotingThresholds))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
ConwayEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe PoolVotingThresholds)
Lens' (PParamsUpdate ledgerera) (StrictMaybe PoolVotingThresholds)
Ledger.ppuPoolVotingThresholdsL ((StrictMaybe PoolVotingThresholds
  -> Identity (StrictMaybe PoolVotingThresholds))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe PoolVotingThresholds
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe PoolVotingThresholds
icPoolVotingThresholds
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe DRepVotingThresholds
 -> Identity (StrictMaybe DRepVotingThresholds))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
ConwayEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe DRepVotingThresholds)
Lens' (PParamsUpdate ledgerera) (StrictMaybe DRepVotingThresholds)
Ledger.ppuDRepVotingThresholdsL ((StrictMaybe DRepVotingThresholds
  -> Identity (StrictMaybe DRepVotingThresholds))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe DRepVotingThresholds
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe DRepVotingThresholds
icDRepVotingThresholds
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe Word16 -> Identity (StrictMaybe Word16))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
ConwayEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word16)
Lens' (PParamsUpdate ledgerera) (StrictMaybe Word16)
Ledger.ppuCommitteeMinSizeL ((StrictMaybe Word16 -> Identity (StrictMaybe Word16))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe Word16
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Word16
icMinCommitteeSize
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe EpochInterval -> Identity (StrictMaybe EpochInterval))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
ConwayEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe EpochInterval)
Lens' (PParamsUpdate ledgerera) (StrictMaybe EpochInterval)
Ledger.ppuCommitteeMaxTermLengthL ((StrictMaybe EpochInterval
  -> Identity (StrictMaybe EpochInterval))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe EpochInterval
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe EpochInterval
icCommitteeTermLength
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe EpochInterval -> Identity (StrictMaybe EpochInterval))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
ConwayEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe EpochInterval)
Lens' (PParamsUpdate ledgerera) (StrictMaybe EpochInterval)
Ledger.ppuGovActionLifetimeL ((StrictMaybe EpochInterval
  -> Identity (StrictMaybe EpochInterval))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe EpochInterval
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe EpochInterval
icGovActionLifetime
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe Coin -> Identity (StrictMaybe Coin))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
(ConwayEraPParams era, HasCallStack) =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
Lens' (PParamsUpdate ledgerera) (StrictMaybe Coin)
Ledger.ppuGovActionDepositL ((StrictMaybe Coin -> Identity (StrictMaybe Coin))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe Coin
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Coin
icGovActionDeposit
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe Coin -> Identity (StrictMaybe Coin))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
ConwayEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
Lens' (PParamsUpdate ledgerera) (StrictMaybe Coin)
Ledger.ppuDRepDepositL ((StrictMaybe Coin -> Identity (StrictMaybe Coin))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe Coin
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Coin
icDRepDeposit
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe EpochInterval -> Identity (StrictMaybe EpochInterval))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
ConwayEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe EpochInterval)
Lens' (PParamsUpdate ledgerera) (StrictMaybe EpochInterval)
Ledger.ppuDRepActivityL ((StrictMaybe EpochInterval
  -> Identity (StrictMaybe EpochInterval))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe EpochInterval
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe EpochInterval
icDRepActivity
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe NonNegativeInterval
 -> Identity (StrictMaybe NonNegativeInterval))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
ConwayEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe NonNegativeInterval)
Lens' (PParamsUpdate ledgerera) (StrictMaybe NonNegativeInterval)
Ledger.ppuMinFeeRefScriptCostPerByteL ((StrictMaybe NonNegativeInterval
  -> Identity (StrictMaybe NonNegativeInterval))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe NonNegativeInterval
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe NonNegativeInterval
icMinFeeRefScriptCostPerByte

pparamsUpdateToIntroducedInConwayPParams
  :: Ledger.ConwayEraPParams ledgerera
  => Ledger.PParamsUpdate ledgerera
  -> IntroducedInConwayPParams ledgerera
pparamsUpdateToIntroducedInConwayPParams :: forall ledgerera.
ConwayEraPParams ledgerera =>
PParamsUpdate ledgerera -> IntroducedInConwayPParams ledgerera
pparamsUpdateToIntroducedInConwayPParams PParamsUpdate ledgerera
ppupdate =
  IntroducedInConwayPParams
    { icPoolVotingThresholds :: StrictMaybe PoolVotingThresholds
icPoolVotingThresholds = PParamsUpdate ledgerera
ppupdate PParamsUpdate ledgerera
-> Getting
     (StrictMaybe PoolVotingThresholds)
     (PParamsUpdate ledgerera)
     (StrictMaybe PoolVotingThresholds)
-> StrictMaybe PoolVotingThresholds
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe PoolVotingThresholds)
  (PParamsUpdate ledgerera)
  (StrictMaybe PoolVotingThresholds)
forall era.
ConwayEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe PoolVotingThresholds)
Lens' (PParamsUpdate ledgerera) (StrictMaybe PoolVotingThresholds)
Ledger.ppuPoolVotingThresholdsL
    , icDRepVotingThresholds :: StrictMaybe DRepVotingThresholds
icDRepVotingThresholds = PParamsUpdate ledgerera
ppupdate PParamsUpdate ledgerera
-> Getting
     (StrictMaybe DRepVotingThresholds)
     (PParamsUpdate ledgerera)
     (StrictMaybe DRepVotingThresholds)
-> StrictMaybe DRepVotingThresholds
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe DRepVotingThresholds)
  (PParamsUpdate ledgerera)
  (StrictMaybe DRepVotingThresholds)
forall era.
ConwayEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe DRepVotingThresholds)
Lens' (PParamsUpdate ledgerera) (StrictMaybe DRepVotingThresholds)
Ledger.ppuDRepVotingThresholdsL
    , icMinCommitteeSize :: StrictMaybe Word16
icMinCommitteeSize = PParamsUpdate ledgerera
ppupdate PParamsUpdate ledgerera
-> Getting
     (StrictMaybe Word16) (PParamsUpdate ledgerera) (StrictMaybe Word16)
-> StrictMaybe Word16
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe Word16) (PParamsUpdate ledgerera) (StrictMaybe Word16)
forall era.
ConwayEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word16)
Lens' (PParamsUpdate ledgerera) (StrictMaybe Word16)
Ledger.ppuCommitteeMinSizeL
    , icCommitteeTermLength :: StrictMaybe EpochInterval
icCommitteeTermLength = PParamsUpdate ledgerera
ppupdate PParamsUpdate ledgerera
-> Getting
     (StrictMaybe EpochInterval)
     (PParamsUpdate ledgerera)
     (StrictMaybe EpochInterval)
-> StrictMaybe EpochInterval
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe EpochInterval)
  (PParamsUpdate ledgerera)
  (StrictMaybe EpochInterval)
forall era.
ConwayEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe EpochInterval)
Lens' (PParamsUpdate ledgerera) (StrictMaybe EpochInterval)
Ledger.ppuCommitteeMaxTermLengthL
    , icGovActionLifetime :: StrictMaybe EpochInterval
icGovActionLifetime = PParamsUpdate ledgerera
ppupdate PParamsUpdate ledgerera
-> Getting
     (StrictMaybe EpochInterval)
     (PParamsUpdate ledgerera)
     (StrictMaybe EpochInterval)
-> StrictMaybe EpochInterval
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe EpochInterval)
  (PParamsUpdate ledgerera)
  (StrictMaybe EpochInterval)
forall era.
ConwayEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe EpochInterval)
Lens' (PParamsUpdate ledgerera) (StrictMaybe EpochInterval)
Ledger.ppuGovActionLifetimeL
    , icGovActionDeposit :: StrictMaybe Coin
icGovActionDeposit = PParamsUpdate ledgerera
ppupdate PParamsUpdate ledgerera
-> Getting
     (StrictMaybe Coin) (PParamsUpdate ledgerera) (StrictMaybe Coin)
-> StrictMaybe Coin
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe Coin) (PParamsUpdate ledgerera) (StrictMaybe Coin)
forall era.
(ConwayEraPParams era, HasCallStack) =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
Lens' (PParamsUpdate ledgerera) (StrictMaybe Coin)
Ledger.ppuGovActionDepositL
    , icDRepDeposit :: StrictMaybe Coin
icDRepDeposit = PParamsUpdate ledgerera
ppupdate PParamsUpdate ledgerera
-> Getting
     (StrictMaybe Coin) (PParamsUpdate ledgerera) (StrictMaybe Coin)
-> StrictMaybe Coin
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe Coin) (PParamsUpdate ledgerera) (StrictMaybe Coin)
forall era.
ConwayEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
Lens' (PParamsUpdate ledgerera) (StrictMaybe Coin)
Ledger.ppuDRepDepositL
    , icDRepActivity :: StrictMaybe EpochInterval
icDRepActivity = PParamsUpdate ledgerera
ppupdate PParamsUpdate ledgerera
-> Getting
     (StrictMaybe EpochInterval)
     (PParamsUpdate ledgerera)
     (StrictMaybe EpochInterval)
-> StrictMaybe EpochInterval
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe EpochInterval)
  (PParamsUpdate ledgerera)
  (StrictMaybe EpochInterval)
forall era.
ConwayEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe EpochInterval)
Lens' (PParamsUpdate ledgerera) (StrictMaybe EpochInterval)
Ledger.ppuDRepActivityL
    , icMinFeeRefScriptCostPerByte :: StrictMaybe NonNegativeInterval
icMinFeeRefScriptCostPerByte = PParamsUpdate ledgerera
ppupdate PParamsUpdate ledgerera
-> Getting
     (StrictMaybe NonNegativeInterval)
     (PParamsUpdate ledgerera)
     (StrictMaybe NonNegativeInterval)
-> StrictMaybe NonNegativeInterval
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe NonNegativeInterval)
  (PParamsUpdate ledgerera)
  (StrictMaybe NonNegativeInterval)
forall era.
ConwayEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe NonNegativeInterval)
Lens' (PParamsUpdate ledgerera) (StrictMaybe NonNegativeInterval)
Ledger.ppuMinFeeRefScriptCostPerByteL
    }

createEraBasedProtocolParamUpdate
  :: ShelleyBasedEra era
  -> EraBasedProtocolParametersUpdate era
  -> Ledger.PParamsUpdate (ShelleyLedgerEra era)
createEraBasedProtocolParamUpdate :: forall era.
ShelleyBasedEra era
-> EraBasedProtocolParametersUpdate era
-> PParamsUpdate (ShelleyLedgerEra era)
createEraBasedProtocolParamUpdate ShelleyBasedEra era
sbe EraBasedProtocolParametersUpdate era
eraPParamsUpdate =
  case EraBasedProtocolParametersUpdate era
eraPParamsUpdate of
    ShelleyEraBasedProtocolParametersUpdate CommonProtocolParametersUpdate
c DeprecatedAfterMaryPParams ShelleyEra
depAfterMary DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage ShelleyToAlonzoPParams ShelleyEra
depAfterAlonzo ->
      let Ledger.PParamsUpdate PParamsHKD StrictMaybe ShelleyEra
common = CommonProtocolParametersUpdate -> PParamsUpdate ShelleyEra
forall ledgerera.
EraPParams ledgerera =>
CommonProtocolParametersUpdate -> PParamsUpdate ledgerera
createCommonPParamsUpdate CommonProtocolParametersUpdate
c
          Ledger.PParamsUpdate PParamsHKD StrictMaybe ShelleyEra
withProtVer = DeprecatedAfterBabbagePParams ShelleyEra
-> PParamsUpdate ShelleyEra
forall ledgerera cppProtocolVersion.
(EraPParams ledgerera, ProtVerAtMost ledgerera 8) =>
DeprecatedAfterBabbagePParams cppProtocolVersion
-> PParamsUpdate ledgerera
createPreConwayProtocolVersionUpdate DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage
          Ledger.PParamsUpdate PParamsHKD StrictMaybe (ShelleyLedgerEra era)
depAfterMary' = ShelleyBasedEra era
-> DeprecatedAfterMaryPParams era
-> PParamsUpdate (ShelleyLedgerEra era)
forall era.
(EraPParams (ShelleyLedgerEra era),
 MaxMaryEra (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> DeprecatedAfterMaryPParams era
-> PParamsUpdate (ShelleyLedgerEra era)
createDeprecatedAfterMaryPParams ShelleyBasedEra era
sbe DeprecatedAfterMaryPParams era
DeprecatedAfterMaryPParams ShelleyEra
depAfterMary
          Ledger.PParamsUpdate PParamsHKD StrictMaybe (ShelleyLedgerEra era)
depAfterAlonzo' = ShelleyBasedEra era
-> ShelleyToAlonzoPParams era
-> PParamsUpdate (ShelleyLedgerEra era)
forall era.
(EraPParams (ShelleyLedgerEra era),
 MaxAlonzoEra (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> ShelleyToAlonzoPParams era
-> PParamsUpdate (ShelleyLedgerEra era)
createDeprecatedAfterAlonzoPParams ShelleyBasedEra era
sbe ShelleyToAlonzoPParams era
ShelleyToAlonzoPParams ShelleyEra
depAfterAlonzo
       in PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall era. PParamsHKD StrictMaybe era -> PParamsUpdate era
Ledger.PParamsUpdate (PParamsHKD StrictMaybe (ShelleyLedgerEra era)
 -> PParamsUpdate (ShelleyLedgerEra era))
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$ PParamsHKD StrictMaybe ShelleyEra
PParamsHKD StrictMaybe (ShelleyLedgerEra era)
common PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe ShelleyEra
ShelleyPParams StrictMaybe ShelleyEra
withProtVer ShelleyPParams StrictMaybe ShelleyEra
-> ShelleyPParams StrictMaybe ShelleyEra
-> ShelleyPParams StrictMaybe ShelleyEra
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
ShelleyPParams StrictMaybe ShelleyEra
depAfterMary' ShelleyPParams StrictMaybe ShelleyEra
-> ShelleyPParams StrictMaybe ShelleyEra
-> ShelleyPParams StrictMaybe ShelleyEra
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
ShelleyPParams StrictMaybe ShelleyEra
depAfterAlonzo'
    AllegraEraBasedProtocolParametersUpdate CommonProtocolParametersUpdate
c DeprecatedAfterMaryPParams AllegraEra
depAfterMary ShelleyToAlonzoPParams AllegraEra
depAfterAlonzo DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage ->
      let Ledger.PParamsUpdate PParamsHKD StrictMaybe AllegraEra
common = CommonProtocolParametersUpdate -> PParamsUpdate AllegraEra
forall ledgerera.
EraPParams ledgerera =>
CommonProtocolParametersUpdate -> PParamsUpdate ledgerera
createCommonPParamsUpdate CommonProtocolParametersUpdate
c
          Ledger.PParamsUpdate PParamsHKD StrictMaybe AllegraEra
withProtVer = DeprecatedAfterBabbagePParams ShelleyEra
-> PParamsUpdate AllegraEra
forall ledgerera cppProtocolVersion.
(EraPParams ledgerera, ProtVerAtMost ledgerera 8) =>
DeprecatedAfterBabbagePParams cppProtocolVersion
-> PParamsUpdate ledgerera
createPreConwayProtocolVersionUpdate DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage
          Ledger.PParamsUpdate PParamsHKD StrictMaybe (ShelleyLedgerEra era)
depAfterMary' = ShelleyBasedEra era
-> DeprecatedAfterMaryPParams era
-> PParamsUpdate (ShelleyLedgerEra era)
forall era.
(EraPParams (ShelleyLedgerEra era),
 MaxMaryEra (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> DeprecatedAfterMaryPParams era
-> PParamsUpdate (ShelleyLedgerEra era)
createDeprecatedAfterMaryPParams ShelleyBasedEra era
sbe DeprecatedAfterMaryPParams era
DeprecatedAfterMaryPParams AllegraEra
depAfterMary
          Ledger.PParamsUpdate PParamsHKD StrictMaybe (ShelleyLedgerEra era)
depAfterAlonzo' = ShelleyBasedEra era
-> ShelleyToAlonzoPParams era
-> PParamsUpdate (ShelleyLedgerEra era)
forall era.
(EraPParams (ShelleyLedgerEra era),
 MaxAlonzoEra (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> ShelleyToAlonzoPParams era
-> PParamsUpdate (ShelleyLedgerEra era)
createDeprecatedAfterAlonzoPParams ShelleyBasedEra era
sbe ShelleyToAlonzoPParams era
ShelleyToAlonzoPParams AllegraEra
depAfterAlonzo
       in PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall era. PParamsHKD StrictMaybe era -> PParamsUpdate era
Ledger.PParamsUpdate (PParamsHKD StrictMaybe (ShelleyLedgerEra era)
 -> PParamsUpdate (ShelleyLedgerEra era))
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$ PParamsHKD StrictMaybe AllegraEra
PParamsHKD StrictMaybe (ShelleyLedgerEra era)
common PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe AllegraEra
ShelleyPParams StrictMaybe AllegraEra
withProtVer ShelleyPParams StrictMaybe AllegraEra
-> ShelleyPParams StrictMaybe AllegraEra
-> ShelleyPParams StrictMaybe AllegraEra
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
ShelleyPParams StrictMaybe AllegraEra
depAfterMary' ShelleyPParams StrictMaybe AllegraEra
-> ShelleyPParams StrictMaybe AllegraEra
-> ShelleyPParams StrictMaybe AllegraEra
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
ShelleyPParams StrictMaybe AllegraEra
depAfterAlonzo'
    MaryEraBasedProtocolParametersUpdate CommonProtocolParametersUpdate
c DeprecatedAfterMaryPParams MaryEra
depAfterMary ShelleyToAlonzoPParams MaryEra
depAfterAlonzo DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage ->
      let Ledger.PParamsUpdate PParamsHKD StrictMaybe MaryEra
common = CommonProtocolParametersUpdate -> PParamsUpdate MaryEra
forall ledgerera.
EraPParams ledgerera =>
CommonProtocolParametersUpdate -> PParamsUpdate ledgerera
createCommonPParamsUpdate CommonProtocolParametersUpdate
c
          Ledger.PParamsUpdate PParamsHKD StrictMaybe MaryEra
withProtVer = DeprecatedAfterBabbagePParams ShelleyEra -> PParamsUpdate MaryEra
forall ledgerera cppProtocolVersion.
(EraPParams ledgerera, ProtVerAtMost ledgerera 8) =>
DeprecatedAfterBabbagePParams cppProtocolVersion
-> PParamsUpdate ledgerera
createPreConwayProtocolVersionUpdate DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage
          Ledger.PParamsUpdate PParamsHKD StrictMaybe (ShelleyLedgerEra era)
depAfterMary' = ShelleyBasedEra era
-> DeprecatedAfterMaryPParams era
-> PParamsUpdate (ShelleyLedgerEra era)
forall era.
(EraPParams (ShelleyLedgerEra era),
 MaxMaryEra (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> DeprecatedAfterMaryPParams era
-> PParamsUpdate (ShelleyLedgerEra era)
createDeprecatedAfterMaryPParams ShelleyBasedEra era
sbe DeprecatedAfterMaryPParams era
DeprecatedAfterMaryPParams MaryEra
depAfterMary
          Ledger.PParamsUpdate PParamsHKD StrictMaybe (ShelleyLedgerEra era)
depAfterAlonzo' = ShelleyBasedEra era
-> ShelleyToAlonzoPParams era
-> PParamsUpdate (ShelleyLedgerEra era)
forall era.
(EraPParams (ShelleyLedgerEra era),
 MaxAlonzoEra (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> ShelleyToAlonzoPParams era
-> PParamsUpdate (ShelleyLedgerEra era)
createDeprecatedAfterAlonzoPParams ShelleyBasedEra era
sbe ShelleyToAlonzoPParams era
ShelleyToAlonzoPParams MaryEra
depAfterAlonzo
       in PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall era. PParamsHKD StrictMaybe era -> PParamsUpdate era
Ledger.PParamsUpdate (PParamsHKD StrictMaybe (ShelleyLedgerEra era)
 -> PParamsUpdate (ShelleyLedgerEra era))
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$ PParamsHKD StrictMaybe MaryEra
PParamsHKD StrictMaybe (ShelleyLedgerEra era)
common PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe MaryEra
ShelleyPParams StrictMaybe MaryEra
withProtVer ShelleyPParams StrictMaybe MaryEra
-> ShelleyPParams StrictMaybe MaryEra
-> ShelleyPParams StrictMaybe MaryEra
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
ShelleyPParams StrictMaybe MaryEra
depAfterMary' ShelleyPParams StrictMaybe MaryEra
-> ShelleyPParams StrictMaybe MaryEra
-> ShelleyPParams StrictMaybe MaryEra
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
ShelleyPParams StrictMaybe MaryEra
depAfterAlonzo'
    AlonzoEraBasedProtocolParametersUpdate CommonProtocolParametersUpdate
c ShelleyToAlonzoPParams AlonzoEra
depAfterAlonzoA AlonzoOnwardsPParams AlonzoEra
introInAlon DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage ->
      let Ledger.PParamsUpdate PParamsHKD StrictMaybe AlonzoEra
common = CommonProtocolParametersUpdate -> PParamsUpdate AlonzoEra
forall ledgerera.
EraPParams ledgerera =>
CommonProtocolParametersUpdate -> PParamsUpdate ledgerera
createCommonPParamsUpdate CommonProtocolParametersUpdate
c
          Ledger.PParamsUpdate PParamsHKD StrictMaybe AlonzoEra
withProtVer = DeprecatedAfterBabbagePParams ShelleyEra -> PParamsUpdate AlonzoEra
forall ledgerera cppProtocolVersion.
(EraPParams ledgerera, ProtVerAtMost ledgerera 8) =>
DeprecatedAfterBabbagePParams cppProtocolVersion
-> PParamsUpdate ledgerera
createPreConwayProtocolVersionUpdate DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage
          Ledger.PParamsUpdate PParamsHKD StrictMaybe (ShelleyLedgerEra AlonzoEra)
preAl' = AlonzoEraOnwards AlonzoEra
-> AlonzoOnwardsPParams AlonzoEra
-> PParamsUpdate (ShelleyLedgerEra AlonzoEra)
forall era.
AlonzoEraOnwards era
-> AlonzoOnwardsPParams era -> PParamsUpdate (ShelleyLedgerEra era)
createPParamsUpdateIntroducedInAlonzo AlonzoEraOnwards AlonzoEra
AlonzoEraOnwardsAlonzo AlonzoOnwardsPParams AlonzoEra
introInAlon
          Ledger.PParamsUpdate PParamsHKD StrictMaybe (ShelleyLedgerEra era)
depAfterAlonzoA' = ShelleyBasedEra era
-> ShelleyToAlonzoPParams era
-> PParamsUpdate (ShelleyLedgerEra era)
forall era.
(EraPParams (ShelleyLedgerEra era),
 MaxAlonzoEra (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> ShelleyToAlonzoPParams era
-> PParamsUpdate (ShelleyLedgerEra era)
createDeprecatedAfterAlonzoPParams ShelleyBasedEra era
sbe ShelleyToAlonzoPParams era
ShelleyToAlonzoPParams AlonzoEra
depAfterAlonzoA
       in PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall era. PParamsHKD StrictMaybe era -> PParamsUpdate era
Ledger.PParamsUpdate (PParamsHKD StrictMaybe (ShelleyLedgerEra era)
 -> PParamsUpdate (ShelleyLedgerEra era))
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$ PParamsHKD StrictMaybe AlonzoEra
PParamsHKD StrictMaybe (ShelleyLedgerEra era)
common PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe AlonzoEra
AlonzoPParams StrictMaybe AlonzoEra
withProtVer AlonzoPParams StrictMaybe AlonzoEra
-> AlonzoPParams StrictMaybe AlonzoEra
-> AlonzoPParams StrictMaybe AlonzoEra
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe (ShelleyLedgerEra AlonzoEra)
AlonzoPParams StrictMaybe AlonzoEra
preAl' AlonzoPParams StrictMaybe AlonzoEra
-> AlonzoPParams StrictMaybe AlonzoEra
-> AlonzoPParams StrictMaybe AlonzoEra
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
AlonzoPParams StrictMaybe AlonzoEra
depAfterAlonzoA'
    BabbageEraBasedProtocolParametersUpdate CommonProtocolParametersUpdate
c AlonzoOnwardsPParams BabbageEra
introInAlonzo DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage IntroducedInBabbagePParams BabbageEra
introInBabbage ->
      let Ledger.PParamsUpdate PParamsHKD StrictMaybe BabbageEra
common = CommonProtocolParametersUpdate -> PParamsUpdate BabbageEra
forall ledgerera.
EraPParams ledgerera =>
CommonProtocolParametersUpdate -> PParamsUpdate ledgerera
createCommonPParamsUpdate CommonProtocolParametersUpdate
c
          Ledger.PParamsUpdate PParamsHKD StrictMaybe BabbageEra
withProtVer = DeprecatedAfterBabbagePParams ShelleyEra
-> PParamsUpdate BabbageEra
forall ledgerera cppProtocolVersion.
(EraPParams ledgerera, ProtVerAtMost ledgerera 8) =>
DeprecatedAfterBabbagePParams cppProtocolVersion
-> PParamsUpdate ledgerera
createPreConwayProtocolVersionUpdate DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage
          Ledger.PParamsUpdate PParamsHKD StrictMaybe (ShelleyLedgerEra BabbageEra)
inAlonzoPParams = AlonzoEraOnwards BabbageEra
-> AlonzoOnwardsPParams BabbageEra
-> PParamsUpdate (ShelleyLedgerEra BabbageEra)
forall era.
AlonzoEraOnwards era
-> AlonzoOnwardsPParams era -> PParamsUpdate (ShelleyLedgerEra era)
createPParamsUpdateIntroducedInAlonzo AlonzoEraOnwards BabbageEra
AlonzoEraOnwardsBabbage AlonzoOnwardsPParams BabbageEra
introInAlonzo
          Ledger.PParamsUpdate PParamsHKD StrictMaybe (ShelleyLedgerEra BabbageEra)
inBAb = BabbageEraOnwards BabbageEra
-> IntroducedInBabbagePParams BabbageEra
-> PParamsUpdate (ShelleyLedgerEra BabbageEra)
forall era.
BabbageEraOnwards era
-> IntroducedInBabbagePParams era
-> PParamsUpdate (ShelleyLedgerEra era)
createIntroducedInBabbagePParams BabbageEraOnwards BabbageEra
BabbageEraOnwardsBabbage IntroducedInBabbagePParams BabbageEra
introInBabbage
       in PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall era. PParamsHKD StrictMaybe era -> PParamsUpdate era
Ledger.PParamsUpdate (PParamsHKD StrictMaybe (ShelleyLedgerEra era)
 -> PParamsUpdate (ShelleyLedgerEra era))
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$ PParamsHKD StrictMaybe BabbageEra
PParamsHKD StrictMaybe (ShelleyLedgerEra era)
common PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe BabbageEra
BabbagePParams StrictMaybe BabbageEra
withProtVer BabbagePParams StrictMaybe BabbageEra
-> BabbagePParams StrictMaybe BabbageEra
-> BabbagePParams StrictMaybe BabbageEra
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe (ShelleyLedgerEra BabbageEra)
BabbagePParams StrictMaybe BabbageEra
inAlonzoPParams BabbagePParams StrictMaybe BabbageEra
-> BabbagePParams StrictMaybe BabbageEra
-> BabbagePParams StrictMaybe BabbageEra
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe (ShelleyLedgerEra BabbageEra)
BabbagePParams StrictMaybe BabbageEra
inBAb
    ConwayEraBasedProtocolParametersUpdate CommonProtocolParametersUpdate
c AlonzoOnwardsPParams ConwayEra
introInAlonzo IntroducedInBabbagePParams ConwayEra
introInBabbage IntroducedInConwayPParams (ShelleyLedgerEra ConwayEra)
introInConway ->
      let Ledger.PParamsUpdate PParamsHKD StrictMaybe ConwayEra
common = CommonProtocolParametersUpdate -> PParamsUpdate ConwayEra
forall ledgerera.
EraPParams ledgerera =>
CommonProtocolParametersUpdate -> PParamsUpdate ledgerera
createCommonPParamsUpdate CommonProtocolParametersUpdate
c
          Ledger.PParamsUpdate PParamsHKD StrictMaybe (ShelleyLedgerEra ConwayEra)
inAlonzoPParams = AlonzoEraOnwards ConwayEra
-> AlonzoOnwardsPParams ConwayEra
-> PParamsUpdate (ShelleyLedgerEra ConwayEra)
forall era.
AlonzoEraOnwards era
-> AlonzoOnwardsPParams era -> PParamsUpdate (ShelleyLedgerEra era)
createPParamsUpdateIntroducedInAlonzo AlonzoEraOnwards ConwayEra
AlonzoEraOnwardsConway AlonzoOnwardsPParams ConwayEra
introInAlonzo
          Ledger.PParamsUpdate PParamsHKD StrictMaybe (ShelleyLedgerEra ConwayEra)
inBab = BabbageEraOnwards ConwayEra
-> IntroducedInBabbagePParams ConwayEra
-> PParamsUpdate (ShelleyLedgerEra ConwayEra)
forall era.
BabbageEraOnwards era
-> IntroducedInBabbagePParams era
-> PParamsUpdate (ShelleyLedgerEra era)
createIntroducedInBabbagePParams BabbageEraOnwards ConwayEra
BabbageEraOnwardsConway IntroducedInBabbagePParams ConwayEra
introInBabbage
          Ledger.PParamsUpdate PParamsHKD StrictMaybe ConwayEra
inCon = IntroducedInConwayPParams ConwayEra -> PParamsUpdate ConwayEra
forall ledgerera.
ConwayEraPParams ledgerera =>
IntroducedInConwayPParams ledgerera -> PParamsUpdate ledgerera
createIntroducedInConwayPParams IntroducedInConwayPParams ConwayEra
IntroducedInConwayPParams (ShelleyLedgerEra ConwayEra)
introInConway
       in PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall era. PParamsHKD StrictMaybe era -> PParamsUpdate era
Ledger.PParamsUpdate (PParamsHKD StrictMaybe (ShelleyLedgerEra era)
 -> PParamsUpdate (ShelleyLedgerEra era))
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$ PParamsHKD StrictMaybe ConwayEra
PParamsHKD StrictMaybe (ShelleyLedgerEra era)
common PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
-> PParamsHKD StrictMaybe (ShelleyLedgerEra era)
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe (ShelleyLedgerEra ConwayEra)
ConwayPParams StrictMaybe ConwayEra
inAlonzoPParams ConwayPParams StrictMaybe ConwayEra
-> ConwayPParams StrictMaybe ConwayEra
-> ConwayPParams StrictMaybe ConwayEra
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe (ShelleyLedgerEra ConwayEra)
ConwayPParams StrictMaybe ConwayEra
inBab ConwayPParams StrictMaybe ConwayEra
-> ConwayPParams StrictMaybe ConwayEra
-> ConwayPParams StrictMaybe ConwayEra
forall a. Semigroup a => a -> a -> a
<> PParamsHKD StrictMaybe ConwayEra
ConwayPParams StrictMaybe ConwayEra
inCon

-- | Protocol parameters common to each era. This can only ever be reduced
-- if parameters are deprecated.
data CommonProtocolParametersUpdate
  = CommonProtocolParametersUpdate
  { CommonProtocolParametersUpdate -> StrictMaybe CoinPerByte
cppTxFeePerByteL :: StrictMaybe Ledger.CoinPerByte
  , CommonProtocolParametersUpdate -> StrictMaybe Coin
cppTxFeeFixedL :: StrictMaybe Ledger.Coin
  , CommonProtocolParametersUpdate -> StrictMaybe Word32
cppMaxBlockBodySize :: StrictMaybe Word32
  , CommonProtocolParametersUpdate -> StrictMaybe Word32
cppMaxTxSize :: StrictMaybe Word32
  , CommonProtocolParametersUpdate -> StrictMaybe Word16
cppMaxBlockHeaderSize :: StrictMaybe Word16
  , CommonProtocolParametersUpdate -> StrictMaybe Coin
cppKeyDeposit :: StrictMaybe Ledger.Coin
  , CommonProtocolParametersUpdate -> StrictMaybe Coin
cppPoolDeposit :: StrictMaybe Ledger.Coin
  , CommonProtocolParametersUpdate -> StrictMaybe EpochInterval
cppPoolRetireMaxEpoch :: StrictMaybe Ledger.EpochInterval
  , CommonProtocolParametersUpdate -> StrictMaybe Word16
cppStakePoolTargetNum :: StrictMaybe Word16
  , CommonProtocolParametersUpdate -> StrictMaybe NonNegativeInterval
cppPoolPledgeInfluence :: StrictMaybe Ledger.NonNegativeInterval
  , CommonProtocolParametersUpdate -> StrictMaybe UnitInterval
cppTreasuryExpansion :: StrictMaybe Ledger.UnitInterval
  , CommonProtocolParametersUpdate -> StrictMaybe UnitInterval
cppMonetaryExpansion :: StrictMaybe Ledger.UnitInterval
  , CommonProtocolParametersUpdate -> StrictMaybe Coin
cppMinPoolCost :: StrictMaybe Ledger.Coin
  }
  deriving (CommonProtocolParametersUpdate
-> CommonProtocolParametersUpdate -> Bool
(CommonProtocolParametersUpdate
 -> CommonProtocolParametersUpdate -> Bool)
-> (CommonProtocolParametersUpdate
    -> CommonProtocolParametersUpdate -> Bool)
-> Eq CommonProtocolParametersUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CommonProtocolParametersUpdate
-> CommonProtocolParametersUpdate -> Bool
== :: CommonProtocolParametersUpdate
-> CommonProtocolParametersUpdate -> Bool
$c/= :: CommonProtocolParametersUpdate
-> CommonProtocolParametersUpdate -> Bool
/= :: CommonProtocolParametersUpdate
-> CommonProtocolParametersUpdate -> Bool
Eq, Int -> CommonProtocolParametersUpdate -> ShowS
[CommonProtocolParametersUpdate] -> ShowS
CommonProtocolParametersUpdate -> String
(Int -> CommonProtocolParametersUpdate -> ShowS)
-> (CommonProtocolParametersUpdate -> String)
-> ([CommonProtocolParametersUpdate] -> ShowS)
-> Show CommonProtocolParametersUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CommonProtocolParametersUpdate -> ShowS
showsPrec :: Int -> CommonProtocolParametersUpdate -> ShowS
$cshow :: CommonProtocolParametersUpdate -> String
show :: CommonProtocolParametersUpdate -> String
$cshowList :: [CommonProtocolParametersUpdate] -> ShowS
showList :: [CommonProtocolParametersUpdate] -> ShowS
Show)

-- | Create a protocol parameters update with parameters common to all eras
createCommonPParamsUpdate
  :: EraPParams ledgerera => CommonProtocolParametersUpdate -> Ledger.PParamsUpdate ledgerera
createCommonPParamsUpdate :: forall ledgerera.
EraPParams ledgerera =>
CommonProtocolParametersUpdate -> PParamsUpdate ledgerera
createCommonPParamsUpdate CommonProtocolParametersUpdate{StrictMaybe Word16
StrictMaybe Word32
StrictMaybe CoinPerByte
StrictMaybe Coin
StrictMaybe EpochInterval
StrictMaybe NonNegativeInterval
StrictMaybe UnitInterval
cppTxFeePerByteL :: CommonProtocolParametersUpdate -> StrictMaybe CoinPerByte
cppTxFeeFixedL :: CommonProtocolParametersUpdate -> StrictMaybe Coin
cppMaxBlockBodySize :: CommonProtocolParametersUpdate -> StrictMaybe Word32
cppMaxTxSize :: CommonProtocolParametersUpdate -> StrictMaybe Word32
cppMaxBlockHeaderSize :: CommonProtocolParametersUpdate -> StrictMaybe Word16
cppKeyDeposit :: CommonProtocolParametersUpdate -> StrictMaybe Coin
cppPoolDeposit :: CommonProtocolParametersUpdate -> StrictMaybe Coin
cppPoolRetireMaxEpoch :: CommonProtocolParametersUpdate -> StrictMaybe EpochInterval
cppStakePoolTargetNum :: CommonProtocolParametersUpdate -> StrictMaybe Word16
cppPoolPledgeInfluence :: CommonProtocolParametersUpdate -> StrictMaybe NonNegativeInterval
cppTreasuryExpansion :: CommonProtocolParametersUpdate -> StrictMaybe UnitInterval
cppMonetaryExpansion :: CommonProtocolParametersUpdate -> StrictMaybe UnitInterval
cppMinPoolCost :: CommonProtocolParametersUpdate -> StrictMaybe Coin
cppTxFeePerByteL :: StrictMaybe CoinPerByte
cppTxFeeFixedL :: StrictMaybe Coin
cppMaxBlockBodySize :: StrictMaybe Word32
cppMaxTxSize :: StrictMaybe Word32
cppMaxBlockHeaderSize :: StrictMaybe Word16
cppKeyDeposit :: StrictMaybe Coin
cppPoolDeposit :: StrictMaybe Coin
cppPoolRetireMaxEpoch :: StrictMaybe EpochInterval
cppStakePoolTargetNum :: StrictMaybe Word16
cppPoolPledgeInfluence :: StrictMaybe NonNegativeInterval
cppTreasuryExpansion :: StrictMaybe UnitInterval
cppMonetaryExpansion :: StrictMaybe UnitInterval
cppMinPoolCost :: StrictMaybe Coin
..} =
  PParamsUpdate ledgerera
forall era. EraPParams era => PParamsUpdate era
emptyPParamsUpdate
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe CoinPerByte -> Identity (StrictMaybe CoinPerByte))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe CoinPerByte)
Lens' (PParamsUpdate ledgerera) (StrictMaybe CoinPerByte)
Ledger.ppuTxFeePerByteL ((StrictMaybe CoinPerByte -> Identity (StrictMaybe CoinPerByte))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe CoinPerByte
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe CoinPerByte
cppTxFeePerByteL
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe Coin -> Identity (StrictMaybe Coin))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
(EraPParams era, HasCallStack) =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
Lens' (PParamsUpdate ledgerera) (StrictMaybe Coin)
Ledger.ppuTxFeeFixedL ((StrictMaybe Coin -> Identity (StrictMaybe Coin))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe Coin
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Coin
cppTxFeeFixedL
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe Word32 -> Identity (StrictMaybe Word32))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word32)
Lens' (PParamsUpdate ledgerera) (StrictMaybe Word32)
Ledger.ppuMaxBBSizeL ((StrictMaybe Word32 -> Identity (StrictMaybe Word32))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe Word32
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Word32
cppMaxBlockBodySize
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe Word32 -> Identity (StrictMaybe Word32))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word32)
Lens' (PParamsUpdate ledgerera) (StrictMaybe Word32)
Ledger.ppuMaxTxSizeL ((StrictMaybe Word32 -> Identity (StrictMaybe Word32))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe Word32
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Word32
cppMaxTxSize
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe Word16 -> Identity (StrictMaybe Word16))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word16)
Lens' (PParamsUpdate ledgerera) (StrictMaybe Word16)
Ledger.ppuMaxBHSizeL ((StrictMaybe Word16 -> Identity (StrictMaybe Word16))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe Word16
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Word16
cppMaxBlockHeaderSize
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe Coin -> Identity (StrictMaybe Coin))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
(EraPParams era, HasCallStack) =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
Lens' (PParamsUpdate ledgerera) (StrictMaybe Coin)
Ledger.ppuKeyDepositL ((StrictMaybe Coin -> Identity (StrictMaybe Coin))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe Coin
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Coin
cppKeyDeposit
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe Coin -> Identity (StrictMaybe Coin))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
(EraPParams era, HasCallStack) =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
Lens' (PParamsUpdate ledgerera) (StrictMaybe Coin)
Ledger.ppuPoolDepositL ((StrictMaybe Coin -> Identity (StrictMaybe Coin))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe Coin
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Coin
cppPoolDeposit
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe EpochInterval -> Identity (StrictMaybe EpochInterval))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe EpochInterval)
Lens' (PParamsUpdate ledgerera) (StrictMaybe EpochInterval)
Ledger.ppuEMaxL ((StrictMaybe EpochInterval
  -> Identity (StrictMaybe EpochInterval))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe EpochInterval
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe EpochInterval
cppPoolRetireMaxEpoch
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe Word16 -> Identity (StrictMaybe Word16))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word16)
Lens' (PParamsUpdate ledgerera) (StrictMaybe Word16)
Ledger.ppuNOptL ((StrictMaybe Word16 -> Identity (StrictMaybe Word16))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe Word16
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Word16
cppStakePoolTargetNum
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe NonNegativeInterval
 -> Identity (StrictMaybe NonNegativeInterval))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe NonNegativeInterval)
Lens' (PParamsUpdate ledgerera) (StrictMaybe NonNegativeInterval)
Ledger.ppuA0L ((StrictMaybe NonNegativeInterval
  -> Identity (StrictMaybe NonNegativeInterval))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe NonNegativeInterval
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe NonNegativeInterval
cppPoolPledgeInfluence
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe UnitInterval -> Identity (StrictMaybe UnitInterval))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe UnitInterval)
Lens' (PParamsUpdate ledgerera) (StrictMaybe UnitInterval)
Ledger.ppuTauL ((StrictMaybe UnitInterval -> Identity (StrictMaybe UnitInterval))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe UnitInterval
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe UnitInterval
cppTreasuryExpansion
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe UnitInterval -> Identity (StrictMaybe UnitInterval))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe UnitInterval)
Lens' (PParamsUpdate ledgerera) (StrictMaybe UnitInterval)
Ledger.ppuRhoL ((StrictMaybe UnitInterval -> Identity (StrictMaybe UnitInterval))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe UnitInterval
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe UnitInterval
cppMonetaryExpansion
    PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe Coin -> Identity (StrictMaybe Coin))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
(EraPParams era, HasCallStack) =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
Lens' (PParamsUpdate ledgerera) (StrictMaybe Coin)
Ledger.ppuMinPoolCostL ((StrictMaybe Coin -> Identity (StrictMaybe Coin))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe Coin
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Coin
cppMinPoolCost

pparamsUpdateToCommonParametersUpdate
  :: ShelleyBasedEra era -> Ledger.PParamsUpdate (ShelleyLedgerEra era) -> CommonProtocolParametersUpdate
pparamsUpdateToCommonParametersUpdate :: forall era.
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> CommonProtocolParametersUpdate
pparamsUpdateToCommonParametersUpdate ShelleyBasedEra era
sbe PParamsUpdate (ShelleyLedgerEra era)
pparamsUpdate =
  ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era =>
    CommonProtocolParametersUpdate)
-> CommonProtocolParametersUpdate
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe ((ShelleyBasedEraConstraints era => CommonProtocolParametersUpdate)
 -> CommonProtocolParametersUpdate)
-> (ShelleyBasedEraConstraints era =>
    CommonProtocolParametersUpdate)
-> CommonProtocolParametersUpdate
forall a b. (a -> b) -> a -> b
$
    CommonProtocolParametersUpdate
      { cppTxFeePerByteL :: StrictMaybe CoinPerByte
cppTxFeePerByteL = PParamsUpdate (ShelleyLedgerEra era)
pparamsUpdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe CoinPerByte)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe CoinPerByte)
-> StrictMaybe CoinPerByte
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe CoinPerByte)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe CoinPerByte)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe CoinPerByte)
Lens'
  (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe CoinPerByte)
Ledger.ppuTxFeePerByteL
      , cppTxFeeFixedL :: StrictMaybe Coin
cppTxFeeFixedL = PParamsUpdate (ShelleyLedgerEra era)
pparamsUpdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe Coin)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe Coin)
-> StrictMaybe Coin
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe Coin)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe Coin)
forall era.
(EraPParams era, HasCallStack) =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Coin)
Ledger.ppuTxFeeFixedL
      , cppMaxBlockBodySize :: StrictMaybe Word32
cppMaxBlockBodySize = PParamsUpdate (ShelleyLedgerEra era)
pparamsUpdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe Word32)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe Word32)
-> StrictMaybe Word32
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe Word32)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe Word32)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word32)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Word32)
Ledger.ppuMaxBBSizeL
      , cppMaxTxSize :: StrictMaybe Word32
cppMaxTxSize = PParamsUpdate (ShelleyLedgerEra era)
pparamsUpdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe Word32)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe Word32)
-> StrictMaybe Word32
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe Word32)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe Word32)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word32)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Word32)
Ledger.ppuMaxTxSizeL
      , cppMaxBlockHeaderSize :: StrictMaybe Word16
cppMaxBlockHeaderSize = PParamsUpdate (ShelleyLedgerEra era)
pparamsUpdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe Word16)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe Word16)
-> StrictMaybe Word16
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe Word16)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe Word16)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word16)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Word16)
Ledger.ppuMaxBHSizeL
      , cppKeyDeposit :: StrictMaybe Coin
cppKeyDeposit = PParamsUpdate (ShelleyLedgerEra era)
pparamsUpdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe Coin)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe Coin)
-> StrictMaybe Coin
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe Coin)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe Coin)
forall era.
(EraPParams era, HasCallStack) =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Coin)
Ledger.ppuKeyDepositL
      , cppPoolDeposit :: StrictMaybe Coin
cppPoolDeposit = PParamsUpdate (ShelleyLedgerEra era)
pparamsUpdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe Coin)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe Coin)
-> StrictMaybe Coin
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe Coin)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe Coin)
forall era.
(EraPParams era, HasCallStack) =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Coin)
Ledger.ppuPoolDepositL
      , cppPoolRetireMaxEpoch :: StrictMaybe EpochInterval
cppPoolRetireMaxEpoch = PParamsUpdate (ShelleyLedgerEra era)
pparamsUpdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe EpochInterval)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe EpochInterval)
-> StrictMaybe EpochInterval
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe EpochInterval)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe EpochInterval)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe EpochInterval)
Lens'
  (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe EpochInterval)
Ledger.ppuEMaxL
      , cppStakePoolTargetNum :: StrictMaybe Word16
cppStakePoolTargetNum = PParamsUpdate (ShelleyLedgerEra era)
pparamsUpdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe Word16)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe Word16)
-> StrictMaybe Word16
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe Word16)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe Word16)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word16)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Word16)
Ledger.ppuNOptL
      , cppPoolPledgeInfluence :: StrictMaybe NonNegativeInterval
cppPoolPledgeInfluence = PParamsUpdate (ShelleyLedgerEra era)
pparamsUpdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe NonNegativeInterval)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe NonNegativeInterval)
-> StrictMaybe NonNegativeInterval
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe NonNegativeInterval)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe NonNegativeInterval)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe NonNegativeInterval)
Lens'
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe NonNegativeInterval)
Ledger.ppuA0L
      , cppTreasuryExpansion :: StrictMaybe UnitInterval
cppTreasuryExpansion = PParamsUpdate (ShelleyLedgerEra era)
pparamsUpdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe UnitInterval)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe UnitInterval)
-> StrictMaybe UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe UnitInterval)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe UnitInterval)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe UnitInterval)
Lens'
  (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe UnitInterval)
Ledger.ppuTauL
      , cppMonetaryExpansion :: StrictMaybe UnitInterval
cppMonetaryExpansion = PParamsUpdate (ShelleyLedgerEra era)
pparamsUpdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe UnitInterval)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe UnitInterval)
-> StrictMaybe UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe UnitInterval)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe UnitInterval)
forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe UnitInterval)
Lens'
  (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe UnitInterval)
Ledger.ppuRhoL
      , cppMinPoolCost :: StrictMaybe Coin
cppMinPoolCost = PParamsUpdate (ShelleyLedgerEra era)
pparamsUpdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe Coin)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe Coin)
-> StrictMaybe Coin
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe Coin)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe Coin)
forall era.
(EraPParams era, HasCallStack) =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Coin)
Ledger.ppuMinPoolCostL
      }

-- | Updating protocol version with PParamUpdate is being prevented in Conway
-- (via the `ProtVerAtMost era 8` constraint in `ppuProtocolVersionL`).
-- As a consequence, ppuProtocolVersionL cannot be used in `createCommonPParamsUpdate`,
-- as was the case pre-Conway.
-- Here we isolate the usage of the lens, so that it can be used in each pre-conway era
-- when creating `Ledger.PParamsUpdate` within `createEraBasedProtocolParamUpdate`.
createPreConwayProtocolVersionUpdate
  :: (EraPParams ledgerera, Ledger.ProtVerAtMost ledgerera 8)
  => DeprecatedAfterBabbagePParams cppProtocolVersion
  -> Ledger.PParamsUpdate ledgerera
createPreConwayProtocolVersionUpdate :: forall ledgerera cppProtocolVersion.
(EraPParams ledgerera, ProtVerAtMost ledgerera 8) =>
DeprecatedAfterBabbagePParams cppProtocolVersion
-> PParamsUpdate ledgerera
createPreConwayProtocolVersionUpdate (DeprecatedAfterBabbagePParams StrictMaybe ProtVer
cppProtocolVersion) =
  PParamsUpdate ledgerera
forall era. EraPParams era => PParamsUpdate era
Ledger.emptyPParamsUpdate PParamsUpdate ledgerera
-> (PParamsUpdate ledgerera -> PParamsUpdate ledgerera)
-> PParamsUpdate ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe ProtVer -> Identity (StrictMaybe ProtVer))
-> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera)
forall era.
(EraPParams era, AtMostEra "Babbage" era) =>
Lens' (PParamsUpdate era) (StrictMaybe ProtVer)
Lens' (PParamsUpdate ledgerera) (StrictMaybe ProtVer)
Ledger.ppuProtocolVersionL ((StrictMaybe ProtVer -> Identity (StrictMaybe ProtVer))
 -> PParamsUpdate ledgerera -> Identity (PParamsUpdate ledgerera))
-> StrictMaybe ProtVer
-> PParamsUpdate ledgerera
-> PParamsUpdate ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe ProtVer
cppProtocolVersion

newtype DeprecatedAfterBabbagePParams ledgerera
  = DeprecatedAfterBabbagePParams (StrictMaybe Ledger.ProtVer)
  deriving (DeprecatedAfterBabbagePParams ledgerera
-> DeprecatedAfterBabbagePParams ledgerera -> Bool
(DeprecatedAfterBabbagePParams ledgerera
 -> DeprecatedAfterBabbagePParams ledgerera -> Bool)
-> (DeprecatedAfterBabbagePParams ledgerera
    -> DeprecatedAfterBabbagePParams ledgerera -> Bool)
-> Eq (DeprecatedAfterBabbagePParams ledgerera)
forall ledgerera.
DeprecatedAfterBabbagePParams ledgerera
-> DeprecatedAfterBabbagePParams ledgerera -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall ledgerera.
DeprecatedAfterBabbagePParams ledgerera
-> DeprecatedAfterBabbagePParams ledgerera -> Bool
== :: DeprecatedAfterBabbagePParams ledgerera
-> DeprecatedAfterBabbagePParams ledgerera -> Bool
$c/= :: forall ledgerera.
DeprecatedAfterBabbagePParams ledgerera
-> DeprecatedAfterBabbagePParams ledgerera -> Bool
/= :: DeprecatedAfterBabbagePParams ledgerera
-> DeprecatedAfterBabbagePParams ledgerera -> Bool
Eq, Int -> DeprecatedAfterBabbagePParams ledgerera -> ShowS
[DeprecatedAfterBabbagePParams ledgerera] -> ShowS
DeprecatedAfterBabbagePParams ledgerera -> String
(Int -> DeprecatedAfterBabbagePParams ledgerera -> ShowS)
-> (DeprecatedAfterBabbagePParams ledgerera -> String)
-> ([DeprecatedAfterBabbagePParams ledgerera] -> ShowS)
-> Show (DeprecatedAfterBabbagePParams ledgerera)
forall ledgerera.
Int -> DeprecatedAfterBabbagePParams ledgerera -> ShowS
forall ledgerera.
[DeprecatedAfterBabbagePParams ledgerera] -> ShowS
forall ledgerera. DeprecatedAfterBabbagePParams ledgerera -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall ledgerera.
Int -> DeprecatedAfterBabbagePParams ledgerera -> ShowS
showsPrec :: Int -> DeprecatedAfterBabbagePParams ledgerera -> ShowS
$cshow :: forall ledgerera. DeprecatedAfterBabbagePParams ledgerera -> String
show :: DeprecatedAfterBabbagePParams ledgerera -> String
$cshowList :: forall ledgerera.
[DeprecatedAfterBabbagePParams ledgerera] -> ShowS
showList :: [DeprecatedAfterBabbagePParams ledgerera] -> ShowS
Show)

type MaxBabbageEra ledgerera = Ledger.ProtVerAtMost ledgerera 8

pparamsUpdateToDeprecatedAfterBabbagePParams
  :: MaxBabbageEra (ShelleyLedgerEra era)
  => EraPParams (ShelleyLedgerEra era)
  => ShelleyBasedEra era
  -> Ledger.PParamsUpdate (ShelleyLedgerEra era)
  -> DeprecatedAfterBabbagePParams ShelleyEra
pparamsUpdateToDeprecatedAfterBabbagePParams :: forall era.
(MaxBabbageEra (ShelleyLedgerEra era),
 EraPParams (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterBabbagePParams ShelleyEra
pparamsUpdateToDeprecatedAfterBabbagePParams ShelleyBasedEra era
_ PParamsUpdate (ShelleyLedgerEra era)
ppupdate =
  StrictMaybe ProtVer -> DeprecatedAfterBabbagePParams ShelleyEra
forall ledgerera.
StrictMaybe ProtVer -> DeprecatedAfterBabbagePParams ledgerera
DeprecatedAfterBabbagePParams (StrictMaybe ProtVer -> DeprecatedAfterBabbagePParams ShelleyEra)
-> StrictMaybe ProtVer -> DeprecatedAfterBabbagePParams ShelleyEra
forall a b. (a -> b) -> a -> b
$
    PParamsUpdate (ShelleyLedgerEra era)
ppupdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe ProtVer)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe ProtVer)
-> StrictMaybe ProtVer
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe ProtVer)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe ProtVer)
forall era.
(EraPParams era, AtMostEra "Babbage" era) =>
Lens' (PParamsUpdate era) (StrictMaybe ProtVer)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe ProtVer)
Ledger.ppuProtocolVersionL

type MaxMaryEra ledgerera = Ledger.ProtVerAtMost ledgerera 4

newtype DeprecatedAfterMaryPParams ledgerera
  = DeprecatedAfterMaryPParams (StrictMaybe Ledger.Coin) -- Minimum UTxO value
  deriving (DeprecatedAfterMaryPParams ledgerera
-> DeprecatedAfterMaryPParams ledgerera -> Bool
(DeprecatedAfterMaryPParams ledgerera
 -> DeprecatedAfterMaryPParams ledgerera -> Bool)
-> (DeprecatedAfterMaryPParams ledgerera
    -> DeprecatedAfterMaryPParams ledgerera -> Bool)
-> Eq (DeprecatedAfterMaryPParams ledgerera)
forall ledgerera.
DeprecatedAfterMaryPParams ledgerera
-> DeprecatedAfterMaryPParams ledgerera -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall ledgerera.
DeprecatedAfterMaryPParams ledgerera
-> DeprecatedAfterMaryPParams ledgerera -> Bool
== :: DeprecatedAfterMaryPParams ledgerera
-> DeprecatedAfterMaryPParams ledgerera -> Bool
$c/= :: forall ledgerera.
DeprecatedAfterMaryPParams ledgerera
-> DeprecatedAfterMaryPParams ledgerera -> Bool
/= :: DeprecatedAfterMaryPParams ledgerera
-> DeprecatedAfterMaryPParams ledgerera -> Bool
Eq, Int -> DeprecatedAfterMaryPParams ledgerera -> ShowS
[DeprecatedAfterMaryPParams ledgerera] -> ShowS
DeprecatedAfterMaryPParams ledgerera -> String
(Int -> DeprecatedAfterMaryPParams ledgerera -> ShowS)
-> (DeprecatedAfterMaryPParams ledgerera -> String)
-> ([DeprecatedAfterMaryPParams ledgerera] -> ShowS)
-> Show (DeprecatedAfterMaryPParams ledgerera)
forall ledgerera.
Int -> DeprecatedAfterMaryPParams ledgerera -> ShowS
forall ledgerera. [DeprecatedAfterMaryPParams ledgerera] -> ShowS
forall ledgerera. DeprecatedAfterMaryPParams ledgerera -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall ledgerera.
Int -> DeprecatedAfterMaryPParams ledgerera -> ShowS
showsPrec :: Int -> DeprecatedAfterMaryPParams ledgerera -> ShowS
$cshow :: forall ledgerera. DeprecatedAfterMaryPParams ledgerera -> String
show :: DeprecatedAfterMaryPParams ledgerera -> String
$cshowList :: forall ledgerera. [DeprecatedAfterMaryPParams ledgerera] -> ShowS
showList :: [DeprecatedAfterMaryPParams ledgerera] -> ShowS
Show)

createDeprecatedAfterMaryPParams
  :: EraPParams (ShelleyLedgerEra era)
  => MaxMaryEra (ShelleyLedgerEra era)
  => ShelleyBasedEra era -> DeprecatedAfterMaryPParams era -> Ledger.PParamsUpdate (ShelleyLedgerEra era)
createDeprecatedAfterMaryPParams :: forall era.
(EraPParams (ShelleyLedgerEra era),
 MaxMaryEra (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> DeprecatedAfterMaryPParams era
-> PParamsUpdate (ShelleyLedgerEra era)
createDeprecatedAfterMaryPParams ShelleyBasedEra era
_ (DeprecatedAfterMaryPParams StrictMaybe Coin
minUtxoVal) =
  PParamsUpdate (ShelleyLedgerEra era)
forall era. EraPParams era => PParamsUpdate era
Ledger.emptyPParamsUpdate PParamsUpdate (ShelleyLedgerEra era)
-> (PParamsUpdate (ShelleyLedgerEra era)
    -> PParamsUpdate (ShelleyLedgerEra era))
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. a -> (a -> b) -> b
& (StrictMaybe Coin -> Identity (StrictMaybe Coin))
-> PParamsUpdate (ShelleyLedgerEra era)
-> Identity (PParamsUpdate (ShelleyLedgerEra era))
forall era.
(EraPParams era, AtMostEra "Mary" era, HasCallStack) =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Coin)
Ledger.ppuMinUTxOValueL ((StrictMaybe Coin -> Identity (StrictMaybe Coin))
 -> PParamsUpdate (ShelleyLedgerEra era)
 -> Identity (PParamsUpdate (ShelleyLedgerEra era)))
-> StrictMaybe Coin
-> PParamsUpdate (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Coin
minUtxoVal

pparamsUpdateToDeprecatedAfterMaryPParams
  :: MaxMaryEra (ShelleyLedgerEra era)
  => EraPParams (ShelleyLedgerEra era)
  => ShelleyBasedEra era -> Ledger.PParamsUpdate (ShelleyLedgerEra era) -> DeprecatedAfterMaryPParams era
pparamsUpdateToDeprecatedAfterMaryPParams :: forall era.
(MaxMaryEra (ShelleyLedgerEra era),
 EraPParams (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterMaryPParams era
pparamsUpdateToDeprecatedAfterMaryPParams ShelleyBasedEra era
_ PParamsUpdate (ShelleyLedgerEra era)
ppupdate =
  StrictMaybe Coin -> DeprecatedAfterMaryPParams era
forall ledgerera.
StrictMaybe Coin -> DeprecatedAfterMaryPParams ledgerera
DeprecatedAfterMaryPParams (StrictMaybe Coin -> DeprecatedAfterMaryPParams era)
-> StrictMaybe Coin -> DeprecatedAfterMaryPParams era
forall a b. (a -> b) -> a -> b
$
    PParamsUpdate (ShelleyLedgerEra era)
ppupdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe Coin)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe Coin)
-> StrictMaybe Coin
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe Coin)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe Coin)
forall era.
(EraPParams era, AtMostEra "Mary" era, HasCallStack) =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Coin)
Ledger.ppuMinUTxOValueL

data ShelleyToAlonzoPParams ledgerera
  = ShelleyToAlonzoPParams
      (StrictMaybe Ledger.Nonce)
      -- ^ Extra entropy
      (StrictMaybe Ledger.UnitInterval)
      -- ^ Decentralization parameter
  deriving (ShelleyToAlonzoPParams ledgerera
-> ShelleyToAlonzoPParams ledgerera -> Bool
(ShelleyToAlonzoPParams ledgerera
 -> ShelleyToAlonzoPParams ledgerera -> Bool)
-> (ShelleyToAlonzoPParams ledgerera
    -> ShelleyToAlonzoPParams ledgerera -> Bool)
-> Eq (ShelleyToAlonzoPParams ledgerera)
forall ledgerera.
ShelleyToAlonzoPParams ledgerera
-> ShelleyToAlonzoPParams ledgerera -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall ledgerera.
ShelleyToAlonzoPParams ledgerera
-> ShelleyToAlonzoPParams ledgerera -> Bool
== :: ShelleyToAlonzoPParams ledgerera
-> ShelleyToAlonzoPParams ledgerera -> Bool
$c/= :: forall ledgerera.
ShelleyToAlonzoPParams ledgerera
-> ShelleyToAlonzoPParams ledgerera -> Bool
/= :: ShelleyToAlonzoPParams ledgerera
-> ShelleyToAlonzoPParams ledgerera -> Bool
Eq, Int -> ShelleyToAlonzoPParams ledgerera -> ShowS
[ShelleyToAlonzoPParams ledgerera] -> ShowS
ShelleyToAlonzoPParams ledgerera -> String
(Int -> ShelleyToAlonzoPParams ledgerera -> ShowS)
-> (ShelleyToAlonzoPParams ledgerera -> String)
-> ([ShelleyToAlonzoPParams ledgerera] -> ShowS)
-> Show (ShelleyToAlonzoPParams ledgerera)
forall ledgerera. Int -> ShelleyToAlonzoPParams ledgerera -> ShowS
forall ledgerera. [ShelleyToAlonzoPParams ledgerera] -> ShowS
forall ledgerera. ShelleyToAlonzoPParams ledgerera -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall ledgerera. Int -> ShelleyToAlonzoPParams ledgerera -> ShowS
showsPrec :: Int -> ShelleyToAlonzoPParams ledgerera -> ShowS
$cshow :: forall ledgerera. ShelleyToAlonzoPParams ledgerera -> String
show :: ShelleyToAlonzoPParams ledgerera -> String
$cshowList :: forall ledgerera. [ShelleyToAlonzoPParams ledgerera] -> ShowS
showList :: [ShelleyToAlonzoPParams ledgerera] -> ShowS
Show)

type MaxAlonzoEra ledgerera = Ledger.ProtVerAtMost ledgerera 6

createDeprecatedAfterAlonzoPParams
  :: EraPParams (ShelleyLedgerEra era)
  => MaxAlonzoEra (ShelleyLedgerEra era)
  => ShelleyBasedEra era
  -> ShelleyToAlonzoPParams era
  -> Ledger.PParamsUpdate (ShelleyLedgerEra era)
createDeprecatedAfterAlonzoPParams :: forall era.
(EraPParams (ShelleyLedgerEra era),
 MaxAlonzoEra (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> ShelleyToAlonzoPParams era
-> PParamsUpdate (ShelleyLedgerEra era)
createDeprecatedAfterAlonzoPParams ShelleyBasedEra era
_ (ShelleyToAlonzoPParams StrictMaybe Nonce
extraEntropy StrictMaybe UnitInterval
decentralization) =
  PParamsUpdate (ShelleyLedgerEra era)
forall era. EraPParams era => PParamsUpdate era
Ledger.emptyPParamsUpdate
    PParamsUpdate (ShelleyLedgerEra era)
-> (PParamsUpdate (ShelleyLedgerEra era)
    -> PParamsUpdate (ShelleyLedgerEra era))
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. a -> (a -> b) -> b
& (StrictMaybe Nonce -> Identity (StrictMaybe Nonce))
-> PParamsUpdate (ShelleyLedgerEra era)
-> Identity (PParamsUpdate (ShelleyLedgerEra era))
forall era.
(EraPParams era, AtMostEra "Alonzo" era) =>
Lens' (PParamsUpdate era) (StrictMaybe Nonce)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Nonce)
Ledger.ppuExtraEntropyL ((StrictMaybe Nonce -> Identity (StrictMaybe Nonce))
 -> PParamsUpdate (ShelleyLedgerEra era)
 -> Identity (PParamsUpdate (ShelleyLedgerEra era)))
-> StrictMaybe Nonce
-> PParamsUpdate (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Nonce
extraEntropy
    PParamsUpdate (ShelleyLedgerEra era)
-> (PParamsUpdate (ShelleyLedgerEra era)
    -> PParamsUpdate (ShelleyLedgerEra era))
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. a -> (a -> b) -> b
& (StrictMaybe UnitInterval -> Identity (StrictMaybe UnitInterval))
-> PParamsUpdate (ShelleyLedgerEra era)
-> Identity (PParamsUpdate (ShelleyLedgerEra era))
forall era.
(EraPParams era, AtMostEra "Alonzo" era) =>
Lens' (PParamsUpdate era) (StrictMaybe UnitInterval)
Lens'
  (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe UnitInterval)
Ledger.ppuDL ((StrictMaybe UnitInterval -> Identity (StrictMaybe UnitInterval))
 -> PParamsUpdate (ShelleyLedgerEra era)
 -> Identity (PParamsUpdate (ShelleyLedgerEra era)))
-> StrictMaybe UnitInterval
-> PParamsUpdate (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe UnitInterval
decentralization

pparamsUpdateToShelleyToAlonzoPParams
  :: EraPParams (ShelleyLedgerEra era)
  => MaxAlonzoEra (ShelleyLedgerEra era)
  => ShelleyBasedEra era
  -> Ledger.PParamsUpdate (ShelleyLedgerEra era)
  -> ShelleyToAlonzoPParams era
pparamsUpdateToShelleyToAlonzoPParams :: forall era.
(EraPParams (ShelleyLedgerEra era),
 MaxAlonzoEra (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> ShelleyToAlonzoPParams era
pparamsUpdateToShelleyToAlonzoPParams ShelleyBasedEra era
_ PParamsUpdate (ShelleyLedgerEra era)
pparamUpdate =
  StrictMaybe Nonce
-> StrictMaybe UnitInterval -> ShelleyToAlonzoPParams era
forall ledgerera.
StrictMaybe Nonce
-> StrictMaybe UnitInterval -> ShelleyToAlonzoPParams ledgerera
ShelleyToAlonzoPParams
    (PParamsUpdate (ShelleyLedgerEra era)
pparamUpdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe Nonce)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe Nonce)
-> StrictMaybe Nonce
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe Nonce)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe Nonce)
forall era.
(EraPParams era, AtMostEra "Alonzo" era) =>
Lens' (PParamsUpdate era) (StrictMaybe Nonce)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Nonce)
Ledger.ppuExtraEntropyL)
    (PParamsUpdate (ShelleyLedgerEra era)
pparamUpdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe UnitInterval)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe UnitInterval)
-> StrictMaybe UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe UnitInterval)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe UnitInterval)
forall era.
(EraPParams era, AtMostEra "Alonzo" era) =>
Lens' (PParamsUpdate era) (StrictMaybe UnitInterval)
Lens'
  (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe UnitInterval)
Ledger.ppuDL)

data AlonzoOnwardsPParams ledgerera
  = AlonzoOnwardsPParams
  { forall ledgerera.
AlonzoOnwardsPParams ledgerera -> StrictMaybe CostModels
alCostModels :: StrictMaybe Alonzo.CostModels
  , forall ledgerera.
AlonzoOnwardsPParams ledgerera -> StrictMaybe Prices
alPrices :: StrictMaybe Alonzo.Prices
  , forall ledgerera.
AlonzoOnwardsPParams ledgerera -> StrictMaybe ExUnits
alMaxTxExUnits :: StrictMaybe Alonzo.ExUnits
  , forall ledgerera.
AlonzoOnwardsPParams ledgerera -> StrictMaybe ExUnits
alMaxBlockExUnits :: StrictMaybe Alonzo.ExUnits
  , forall ledgerera.
AlonzoOnwardsPParams ledgerera -> StrictMaybe Word32
alMaxValSize :: StrictMaybe Word32
  , forall ledgerera.
AlonzoOnwardsPParams ledgerera -> StrictMaybe Word16
alCollateralPercentage :: StrictMaybe Word16
  , forall ledgerera.
AlonzoOnwardsPParams ledgerera -> StrictMaybe Word16
alMaxCollateralInputs :: StrictMaybe Word16
  }
  deriving (AlonzoOnwardsPParams ledgerera
-> AlonzoOnwardsPParams ledgerera -> Bool
(AlonzoOnwardsPParams ledgerera
 -> AlonzoOnwardsPParams ledgerera -> Bool)
-> (AlonzoOnwardsPParams ledgerera
    -> AlonzoOnwardsPParams ledgerera -> Bool)
-> Eq (AlonzoOnwardsPParams ledgerera)
forall ledgerera.
AlonzoOnwardsPParams ledgerera
-> AlonzoOnwardsPParams ledgerera -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall ledgerera.
AlonzoOnwardsPParams ledgerera
-> AlonzoOnwardsPParams ledgerera -> Bool
== :: AlonzoOnwardsPParams ledgerera
-> AlonzoOnwardsPParams ledgerera -> Bool
$c/= :: forall ledgerera.
AlonzoOnwardsPParams ledgerera
-> AlonzoOnwardsPParams ledgerera -> Bool
/= :: AlonzoOnwardsPParams ledgerera
-> AlonzoOnwardsPParams ledgerera -> Bool
Eq, Int -> AlonzoOnwardsPParams ledgerera -> ShowS
[AlonzoOnwardsPParams ledgerera] -> ShowS
AlonzoOnwardsPParams ledgerera -> String
(Int -> AlonzoOnwardsPParams ledgerera -> ShowS)
-> (AlonzoOnwardsPParams ledgerera -> String)
-> ([AlonzoOnwardsPParams ledgerera] -> ShowS)
-> Show (AlonzoOnwardsPParams ledgerera)
forall ledgerera. Int -> AlonzoOnwardsPParams ledgerera -> ShowS
forall ledgerera. [AlonzoOnwardsPParams ledgerera] -> ShowS
forall ledgerera. AlonzoOnwardsPParams ledgerera -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall ledgerera. Int -> AlonzoOnwardsPParams ledgerera -> ShowS
showsPrec :: Int -> AlonzoOnwardsPParams ledgerera -> ShowS
$cshow :: forall ledgerera. AlonzoOnwardsPParams ledgerera -> String
show :: AlonzoOnwardsPParams ledgerera -> String
$cshowList :: forall ledgerera. [AlonzoOnwardsPParams ledgerera] -> ShowS
showList :: [AlonzoOnwardsPParams ledgerera] -> ShowS
Show)

createPParamsUpdateIntroducedInAlonzo
  :: ()
  => AlonzoEraOnwards era
  -> AlonzoOnwardsPParams era
  -> Ledger.PParamsUpdate (ShelleyLedgerEra era)
createPParamsUpdateIntroducedInAlonzo :: forall era.
AlonzoEraOnwards era
-> AlonzoOnwardsPParams era -> PParamsUpdate (ShelleyLedgerEra era)
createPParamsUpdateIntroducedInAlonzo AlonzoEraOnwards era
w (AlonzoOnwardsPParams{StrictMaybe Word16
StrictMaybe Word32
StrictMaybe ExUnits
StrictMaybe CostModels
StrictMaybe Prices
alCostModels :: forall ledgerera.
AlonzoOnwardsPParams ledgerera -> StrictMaybe CostModels
alPrices :: forall ledgerera.
AlonzoOnwardsPParams ledgerera -> StrictMaybe Prices
alMaxTxExUnits :: forall ledgerera.
AlonzoOnwardsPParams ledgerera -> StrictMaybe ExUnits
alMaxBlockExUnits :: forall ledgerera.
AlonzoOnwardsPParams ledgerera -> StrictMaybe ExUnits
alMaxValSize :: forall ledgerera.
AlonzoOnwardsPParams ledgerera -> StrictMaybe Word32
alCollateralPercentage :: forall ledgerera.
AlonzoOnwardsPParams ledgerera -> StrictMaybe Word16
alMaxCollateralInputs :: forall ledgerera.
AlonzoOnwardsPParams ledgerera -> StrictMaybe Word16
alCostModels :: StrictMaybe CostModels
alPrices :: StrictMaybe Prices
alMaxTxExUnits :: StrictMaybe ExUnits
alMaxBlockExUnits :: StrictMaybe ExUnits
alMaxValSize :: StrictMaybe Word32
alCollateralPercentage :: StrictMaybe Word16
alMaxCollateralInputs :: StrictMaybe Word16
..}) =
  AlonzoEraOnwards era
-> (AlonzoEraOnwardsConstraints era =>
    PParamsUpdate (ShelleyLedgerEra era))
-> PParamsUpdate (ShelleyLedgerEra era)
forall era a.
AlonzoEraOnwards era -> (AlonzoEraOnwardsConstraints era => a) -> a
alonzoEraOnwardsConstraints AlonzoEraOnwards era
w ((AlonzoEraOnwardsConstraints era =>
  PParamsUpdate (ShelleyLedgerEra era))
 -> PParamsUpdate (ShelleyLedgerEra era))
-> (AlonzoEraOnwardsConstraints era =>
    PParamsUpdate (ShelleyLedgerEra era))
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$
    PParamsUpdate (ShelleyLedgerEra era)
forall era. EraPParams era => PParamsUpdate era
Ledger.emptyPParamsUpdate
      PParamsUpdate (ShelleyLedgerEra era)
-> (PParamsUpdate (ShelleyLedgerEra era)
    -> PParamsUpdate (ShelleyLedgerEra era))
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. a -> (a -> b) -> b
& (StrictMaybe CostModels -> Identity (StrictMaybe CostModels))
-> PParamsUpdate (ShelleyLedgerEra era)
-> Identity (PParamsUpdate (ShelleyLedgerEra era))
forall era.
AlonzoEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe CostModels)
Lens'
  (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe CostModels)
Ledger.ppuCostModelsL ((StrictMaybe CostModels -> Identity (StrictMaybe CostModels))
 -> PParamsUpdate (ShelleyLedgerEra era)
 -> Identity (PParamsUpdate (ShelleyLedgerEra era)))
-> StrictMaybe CostModels
-> PParamsUpdate (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe CostModels
alCostModels
      PParamsUpdate (ShelleyLedgerEra era)
-> (PParamsUpdate (ShelleyLedgerEra era)
    -> PParamsUpdate (ShelleyLedgerEra era))
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. a -> (a -> b) -> b
& (StrictMaybe Prices -> Identity (StrictMaybe Prices))
-> PParamsUpdate (ShelleyLedgerEra era)
-> Identity (PParamsUpdate (ShelleyLedgerEra era))
forall era.
AlonzoEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Prices)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Prices)
Ledger.ppuPricesL ((StrictMaybe Prices -> Identity (StrictMaybe Prices))
 -> PParamsUpdate (ShelleyLedgerEra era)
 -> Identity (PParamsUpdate (ShelleyLedgerEra era)))
-> StrictMaybe Prices
-> PParamsUpdate (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Prices
alPrices
      PParamsUpdate (ShelleyLedgerEra era)
-> (PParamsUpdate (ShelleyLedgerEra era)
    -> PParamsUpdate (ShelleyLedgerEra era))
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. a -> (a -> b) -> b
& (StrictMaybe ExUnits -> Identity (StrictMaybe ExUnits))
-> PParamsUpdate (ShelleyLedgerEra era)
-> Identity (PParamsUpdate (ShelleyLedgerEra era))
forall era.
AlonzoEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe ExUnits)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe ExUnits)
Ledger.ppuMaxTxExUnitsL ((StrictMaybe ExUnits -> Identity (StrictMaybe ExUnits))
 -> PParamsUpdate (ShelleyLedgerEra era)
 -> Identity (PParamsUpdate (ShelleyLedgerEra era)))
-> StrictMaybe ExUnits
-> PParamsUpdate (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe ExUnits
alMaxTxExUnits
      PParamsUpdate (ShelleyLedgerEra era)
-> (PParamsUpdate (ShelleyLedgerEra era)
    -> PParamsUpdate (ShelleyLedgerEra era))
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. a -> (a -> b) -> b
& (StrictMaybe ExUnits -> Identity (StrictMaybe ExUnits))
-> PParamsUpdate (ShelleyLedgerEra era)
-> Identity (PParamsUpdate (ShelleyLedgerEra era))
forall era.
AlonzoEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe ExUnits)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe ExUnits)
Ledger.ppuMaxBlockExUnitsL ((StrictMaybe ExUnits -> Identity (StrictMaybe ExUnits))
 -> PParamsUpdate (ShelleyLedgerEra era)
 -> Identity (PParamsUpdate (ShelleyLedgerEra era)))
-> StrictMaybe ExUnits
-> PParamsUpdate (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe ExUnits
alMaxBlockExUnits
      PParamsUpdate (ShelleyLedgerEra era)
-> (PParamsUpdate (ShelleyLedgerEra era)
    -> PParamsUpdate (ShelleyLedgerEra era))
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. a -> (a -> b) -> b
& (StrictMaybe Word32 -> Identity (StrictMaybe Word32))
-> PParamsUpdate (ShelleyLedgerEra era)
-> Identity (PParamsUpdate (ShelleyLedgerEra era))
forall era.
AlonzoEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word32)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Word32)
Ledger.ppuMaxValSizeL ((StrictMaybe Word32 -> Identity (StrictMaybe Word32))
 -> PParamsUpdate (ShelleyLedgerEra era)
 -> Identity (PParamsUpdate (ShelleyLedgerEra era)))
-> StrictMaybe Word32
-> PParamsUpdate (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Word32
alMaxValSize
      PParamsUpdate (ShelleyLedgerEra era)
-> (PParamsUpdate (ShelleyLedgerEra era)
    -> PParamsUpdate (ShelleyLedgerEra era))
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. a -> (a -> b) -> b
& (StrictMaybe Word16 -> Identity (StrictMaybe Word16))
-> PParamsUpdate (ShelleyLedgerEra era)
-> Identity (PParamsUpdate (ShelleyLedgerEra era))
forall era.
AlonzoEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word16)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Word16)
Ledger.ppuCollateralPercentageL ((StrictMaybe Word16 -> Identity (StrictMaybe Word16))
 -> PParamsUpdate (ShelleyLedgerEra era)
 -> Identity (PParamsUpdate (ShelleyLedgerEra era)))
-> StrictMaybe Word16
-> PParamsUpdate (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Word16
alCollateralPercentage
      PParamsUpdate (ShelleyLedgerEra era)
-> (PParamsUpdate (ShelleyLedgerEra era)
    -> PParamsUpdate (ShelleyLedgerEra era))
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. a -> (a -> b) -> b
& (StrictMaybe Word16 -> Identity (StrictMaybe Word16))
-> PParamsUpdate (ShelleyLedgerEra era)
-> Identity (PParamsUpdate (ShelleyLedgerEra era))
forall era.
AlonzoEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word16)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Word16)
Ledger.ppuMaxCollateralInputsL ((StrictMaybe Word16 -> Identity (StrictMaybe Word16))
 -> PParamsUpdate (ShelleyLedgerEra era)
 -> Identity (PParamsUpdate (ShelleyLedgerEra era)))
-> StrictMaybe Word16
-> PParamsUpdate (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Word16
alMaxCollateralInputs

pparamsUpdateToAlonzoOnwardsPParams
  :: AlonzoEraOnwards era
  -> Ledger.PParamsUpdate (ShelleyLedgerEra era)
  -> AlonzoOnwardsPParams era
pparamsUpdateToAlonzoOnwardsPParams :: forall era.
AlonzoEraOnwards era
-> PParamsUpdate (ShelleyLedgerEra era) -> AlonzoOnwardsPParams era
pparamsUpdateToAlonzoOnwardsPParams AlonzoEraOnwards era
w PParamsUpdate (ShelleyLedgerEra era)
ppupdate =
  AlonzoEraOnwards era
-> (AlonzoEraOnwardsConstraints era => AlonzoOnwardsPParams era)
-> AlonzoOnwardsPParams era
forall era a.
AlonzoEraOnwards era -> (AlonzoEraOnwardsConstraints era => a) -> a
alonzoEraOnwardsConstraints AlonzoEraOnwards era
w ((AlonzoEraOnwardsConstraints era => AlonzoOnwardsPParams era)
 -> AlonzoOnwardsPParams era)
-> (AlonzoEraOnwardsConstraints era => AlonzoOnwardsPParams era)
-> AlonzoOnwardsPParams era
forall a b. (a -> b) -> a -> b
$
    AlonzoOnwardsPParams
      { alCostModels :: StrictMaybe CostModels
alCostModels = PParamsUpdate (ShelleyLedgerEra era)
ppupdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe CostModels)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe CostModels)
-> StrictMaybe CostModels
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe CostModels)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe CostModels)
forall era.
AlonzoEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe CostModels)
Lens'
  (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe CostModels)
Ledger.ppuCostModelsL
      , alPrices :: StrictMaybe Prices
alPrices = PParamsUpdate (ShelleyLedgerEra era)
ppupdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe Prices)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe Prices)
-> StrictMaybe Prices
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe Prices)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe Prices)
forall era.
AlonzoEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Prices)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Prices)
Ledger.ppuPricesL
      , alMaxTxExUnits :: StrictMaybe ExUnits
alMaxTxExUnits = PParamsUpdate (ShelleyLedgerEra era)
ppupdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe ExUnits)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe ExUnits)
-> StrictMaybe ExUnits
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe ExUnits)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe ExUnits)
forall era.
AlonzoEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe ExUnits)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe ExUnits)
Ledger.ppuMaxTxExUnitsL
      , alMaxBlockExUnits :: StrictMaybe ExUnits
alMaxBlockExUnits = PParamsUpdate (ShelleyLedgerEra era)
ppupdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe ExUnits)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe ExUnits)
-> StrictMaybe ExUnits
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe ExUnits)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe ExUnits)
forall era.
AlonzoEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe ExUnits)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe ExUnits)
Ledger.ppuMaxBlockExUnitsL
      , alMaxValSize :: StrictMaybe Word32
alMaxValSize = PParamsUpdate (ShelleyLedgerEra era)
ppupdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe Word32)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe Word32)
-> StrictMaybe Word32
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe Word32)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe Word32)
forall era.
AlonzoEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word32)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Word32)
Ledger.ppuMaxValSizeL
      , alCollateralPercentage :: StrictMaybe Word16
alCollateralPercentage = PParamsUpdate (ShelleyLedgerEra era)
ppupdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe Word16)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe Word16)
-> StrictMaybe Word16
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe Word16)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe Word16)
forall era.
AlonzoEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word16)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Word16)
Ledger.ppuCollateralPercentageL
      , alMaxCollateralInputs :: StrictMaybe Word16
alMaxCollateralInputs = PParamsUpdate (ShelleyLedgerEra era)
ppupdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe Word16)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe Word16)
-> StrictMaybe Word16
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe Word16)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe Word16)
forall era.
AlonzoEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word16)
Lens' (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe Word16)
Ledger.ppuMaxCollateralInputsL
      }

newtype IntroducedInBabbagePParams era
  = -- | Coins per UTxO byte
    IntroducedInBabbagePParams
      (StrictMaybe CoinPerByte)
  deriving (IntroducedInBabbagePParams era
-> IntroducedInBabbagePParams era -> Bool
(IntroducedInBabbagePParams era
 -> IntroducedInBabbagePParams era -> Bool)
-> (IntroducedInBabbagePParams era
    -> IntroducedInBabbagePParams era -> Bool)
-> Eq (IntroducedInBabbagePParams era)
forall era.
IntroducedInBabbagePParams era
-> IntroducedInBabbagePParams era -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall era.
IntroducedInBabbagePParams era
-> IntroducedInBabbagePParams era -> Bool
== :: IntroducedInBabbagePParams era
-> IntroducedInBabbagePParams era -> Bool
$c/= :: forall era.
IntroducedInBabbagePParams era
-> IntroducedInBabbagePParams era -> Bool
/= :: IntroducedInBabbagePParams era
-> IntroducedInBabbagePParams era -> Bool
Eq, Int -> IntroducedInBabbagePParams era -> ShowS
[IntroducedInBabbagePParams era] -> ShowS
IntroducedInBabbagePParams era -> String
(Int -> IntroducedInBabbagePParams era -> ShowS)
-> (IntroducedInBabbagePParams era -> String)
-> ([IntroducedInBabbagePParams era] -> ShowS)
-> Show (IntroducedInBabbagePParams era)
forall era. Int -> IntroducedInBabbagePParams era -> ShowS
forall era. [IntroducedInBabbagePParams era] -> ShowS
forall era. IntroducedInBabbagePParams era -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall era. Int -> IntroducedInBabbagePParams era -> ShowS
showsPrec :: Int -> IntroducedInBabbagePParams era -> ShowS
$cshow :: forall era. IntroducedInBabbagePParams era -> String
show :: IntroducedInBabbagePParams era -> String
$cshowList :: forall era. [IntroducedInBabbagePParams era] -> ShowS
showList :: [IntroducedInBabbagePParams era] -> ShowS
Show)

createIntroducedInBabbagePParams
  :: ()
  => BabbageEraOnwards era
  -> IntroducedInBabbagePParams era
  -> Ledger.PParamsUpdate (ShelleyLedgerEra era)
createIntroducedInBabbagePParams :: forall era.
BabbageEraOnwards era
-> IntroducedInBabbagePParams era
-> PParamsUpdate (ShelleyLedgerEra era)
createIntroducedInBabbagePParams BabbageEraOnwards era
w (IntroducedInBabbagePParams StrictMaybe CoinPerByte
coinsPerUTxOByte) =
  BabbageEraOnwards era
-> (BabbageEraOnwardsConstraints era =>
    PParamsUpdate (ShelleyLedgerEra era))
-> PParamsUpdate (ShelleyLedgerEra era)
forall era a.
BabbageEraOnwards era
-> (BabbageEraOnwardsConstraints era => a) -> a
babbageEraOnwardsConstraints BabbageEraOnwards era
w ((BabbageEraOnwardsConstraints era =>
  PParamsUpdate (ShelleyLedgerEra era))
 -> PParamsUpdate (ShelleyLedgerEra era))
-> (BabbageEraOnwardsConstraints era =>
    PParamsUpdate (ShelleyLedgerEra era))
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$
    PParamsUpdate (ShelleyLedgerEra era)
forall era. EraPParams era => PParamsUpdate era
Ledger.emptyPParamsUpdate PParamsUpdate (ShelleyLedgerEra era)
-> (PParamsUpdate (ShelleyLedgerEra era)
    -> PParamsUpdate (ShelleyLedgerEra era))
-> PParamsUpdate (ShelleyLedgerEra era)
forall a b. a -> (a -> b) -> b
& (StrictMaybe CoinPerByte -> Identity (StrictMaybe CoinPerByte))
-> PParamsUpdate (ShelleyLedgerEra era)
-> Identity (PParamsUpdate (ShelleyLedgerEra era))
forall era.
BabbageEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe CoinPerByte)
Lens'
  (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe CoinPerByte)
Ledger.ppuCoinsPerUTxOByteL ((StrictMaybe CoinPerByte -> Identity (StrictMaybe CoinPerByte))
 -> PParamsUpdate (ShelleyLedgerEra era)
 -> Identity (PParamsUpdate (ShelleyLedgerEra era)))
-> StrictMaybe CoinPerByte
-> PParamsUpdate (ShelleyLedgerEra era)
-> PParamsUpdate (ShelleyLedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe CoinPerByte
coinsPerUTxOByte

pparamsUpdateToIntroducedInBabbagePParams
  :: BabbageEraOnwards era
  -> Ledger.PParamsUpdate (ShelleyLedgerEra era)
  -> IntroducedInBabbagePParams era
pparamsUpdateToIntroducedInBabbagePParams :: forall era.
BabbageEraOnwards era
-> PParamsUpdate (ShelleyLedgerEra era)
-> IntroducedInBabbagePParams era
pparamsUpdateToIntroducedInBabbagePParams BabbageEraOnwards era
w PParamsUpdate (ShelleyLedgerEra era)
ppupdate =
  BabbageEraOnwards era
-> (BabbageEraOnwardsConstraints era =>
    IntroducedInBabbagePParams era)
-> IntroducedInBabbagePParams era
forall era a.
BabbageEraOnwards era
-> (BabbageEraOnwardsConstraints era => a) -> a
babbageEraOnwardsConstraints BabbageEraOnwards era
w ((BabbageEraOnwardsConstraints era =>
  IntroducedInBabbagePParams era)
 -> IntroducedInBabbagePParams era)
-> (BabbageEraOnwardsConstraints era =>
    IntroducedInBabbagePParams era)
-> IntroducedInBabbagePParams era
forall a b. (a -> b) -> a -> b
$
    StrictMaybe CoinPerByte -> IntroducedInBabbagePParams era
forall era.
StrictMaybe CoinPerByte -> IntroducedInBabbagePParams era
IntroducedInBabbagePParams (PParamsUpdate (ShelleyLedgerEra era)
ppupdate PParamsUpdate (ShelleyLedgerEra era)
-> Getting
     (StrictMaybe CoinPerByte)
     (PParamsUpdate (ShelleyLedgerEra era))
     (StrictMaybe CoinPerByte)
-> StrictMaybe CoinPerByte
forall s a. s -> Getting a s a -> a
^. Getting
  (StrictMaybe CoinPerByte)
  (PParamsUpdate (ShelleyLedgerEra era))
  (StrictMaybe CoinPerByte)
forall era.
BabbageEraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe CoinPerByte)
Lens'
  (PParamsUpdate (ShelleyLedgerEra era)) (StrictMaybe CoinPerByte)
Ledger.ppuCoinsPerUTxOByteL)

-- | The values of the set of /updatable/ protocol parameters. At any
-- particular point on the chain there is a current set of parameters in use.
--
-- These parameters can be updated (at epoch boundaries) via an
-- 'UpdateProposal', which contains a 'ProtocolParametersUpdate'.
--
-- The 'ProtocolParametersUpdate' is essentially a diff for the
-- 'ProtocolParameters'.
--
-- There are also parameters fixed in the Genesis file. See 'GenesisParameters'.
{-# DEPRECATED
  ProtocolParameters
  "Use the ledger's PParams (from module Cardano.Api.Ledger) type instead of ProtocolParameters. The type will be removed after Chang hard fork."
  #-}

data ProtocolParameters
  = ProtocolParameters
  { ProtocolParameters -> (Natural, Natural)
protocolParamProtocolVersion :: (Natural, Natural)
  -- ^ Protocol version, major and minor. Updating the major version is
  -- used to trigger hard forks.
  --                              (Major  , Minor  )
  , ProtocolParameters -> Maybe Rational
protocolParamDecentralization :: Maybe Rational
  -- ^ The decentralization parameter. This is fraction of slots that
  -- belong to the BFT overlay schedule, rather than the Praos schedule.
  -- So 1 means fully centralised, while 0 means fully decentralised.
  --
  -- This is the \"d\" parameter from the design document.
  --
  -- /Deprecated in Babbage/
  , ProtocolParameters -> Maybe PraosNonce
protocolParamExtraPraosEntropy :: Maybe PraosNonce
  -- ^ Extra entropy for the Praos per-epoch nonce.
  --
  -- This can be used to add extra entropy during the decentralisation
  -- process. If the extra entropy can be demonstrated to be generated
  -- randomly then this method can be used to show that the initial
  -- federated operators did not subtly bias the initial schedule so that
  -- they retain undue influence after decentralisation.
  , ProtocolParameters -> Natural
protocolParamMaxBlockHeaderSize :: Natural
  -- ^ The maximum permitted size of a block header.
  --
  -- This must be at least as big as the largest legitimate block headers
  -- but should not be too much larger, to help prevent DoS attacks.
  --
  -- Caution: setting this to be smaller than legitimate block headers is
  -- a sure way to brick the system!
  , ProtocolParameters -> Natural
protocolParamMaxBlockBodySize :: Natural
  -- ^ The maximum permitted size of the block body (that is, the block
  -- payload, without the block header).
  --
  -- This should be picked with the Praos network delta security parameter
  -- in mind. Making this too large can severely weaken the Praos
  -- consensus properties.
  --
  -- Caution: setting this to be smaller than a transaction that can
  -- change the protocol parameters is a sure way to brick the system!
  , ProtocolParameters -> Natural
protocolParamMaxTxSize :: Natural
  -- ^ The maximum permitted size of a transaction.
  --
  -- Typically this should not be too high a fraction of the block size,
  -- otherwise wastage from block fragmentation becomes a problem, and
  -- the current implementation does not use any sophisticated box packing
  -- algorithm.
  , ProtocolParameters -> Coin
protocolParamTxFeeFixed :: L.Coin
  -- ^ The constant factor for the minimum fee calculation.
  , ProtocolParameters -> Coin
protocolParamTxFeePerByte :: L.Coin
  -- ^ Per byte linear factor for the minimum fee calculation.
  , ProtocolParameters -> Maybe Coin
protocolParamMinUTxOValue :: Maybe L.Coin
  -- ^ The minimum permitted value for new UTxO entries, ie for
  -- transaction outputs.
  , ProtocolParameters -> Coin
protocolParamStakeAddressDeposit :: L.Coin
  -- ^ The deposit required to register a stake address.
  , ProtocolParameters -> Coin
protocolParamStakePoolDeposit :: L.Coin
  -- ^ The deposit required to register a stake pool.
  , ProtocolParameters -> Coin
protocolParamMinPoolCost :: L.Coin
  -- ^ The minimum value that stake pools are permitted to declare for
  -- their cost parameter.
  , ProtocolParameters -> EpochInterval
protocolParamPoolRetireMaxEpoch :: Ledger.EpochInterval
  -- ^ The maximum number of epochs into the future that stake pools
  -- are permitted to schedule a retirement.
  , ProtocolParameters -> Word16
protocolParamStakePoolTargetNum :: Word16
  -- ^ The equilibrium target number of stake pools.
  --
  -- This is the \"k\" incentives parameter from the design document.
  , ProtocolParameters -> Rational
protocolParamPoolPledgeInfluence :: Rational
  -- ^ The influence of the pledge in stake pool rewards.
  --
  -- This is the \"a_0\" incentives parameter from the design document.
  , ProtocolParameters -> Rational
protocolParamMonetaryExpansion :: Rational
  -- ^ The monetary expansion rate. This determines the fraction of the
  -- reserves that are added to the fee pot each epoch.
  --
  -- This is the \"rho\" incentives parameter from the design document.
  , ProtocolParameters -> Rational
protocolParamTreasuryCut :: Rational
  -- ^ The fraction of the fee pot each epoch that goes to the treasury.
  --
  -- This is the \"tau\" incentives parameter from the design document.
  , ProtocolParameters -> Map AnyPlutusScriptVersion CostModel
protocolParamCostModels :: Map AnyPlutusScriptVersion CostModel
  -- ^ Cost models for script languages that use them.
  --
  -- /Introduced in Alonzo/
  , ProtocolParameters -> Maybe ExecutionUnitPrices
protocolParamPrices :: Maybe ExecutionUnitPrices
  -- ^ Price of execution units for script languages that use them.
  --
  -- /Introduced in Alonzo/
  , ProtocolParameters -> Maybe ExecutionUnits
protocolParamMaxTxExUnits :: Maybe ExecutionUnits
  -- ^ Max total script execution resources units allowed per tx
  --
  -- /Introduced in Alonzo/
  , ProtocolParameters -> Maybe ExecutionUnits
protocolParamMaxBlockExUnits :: Maybe ExecutionUnits
  -- ^ Max total script execution resources units allowed per block
  --
  -- /Introduced in Alonzo/
  , ProtocolParameters -> Maybe Natural
protocolParamMaxValueSize :: Maybe Natural
  -- ^ Max size of a Value in a tx output.
  --
  -- /Introduced in Alonzo/
  , ProtocolParameters -> Maybe Natural
protocolParamCollateralPercent :: Maybe Natural
  -- ^ The percentage of the script contribution to the txfee that must be
  -- provided as collateral inputs when including Plutus scripts.
  --
  -- /Introduced in Alonzo/
  , ProtocolParameters -> Maybe Natural
protocolParamMaxCollateralInputs :: Maybe Natural
  -- ^ The maximum number of collateral inputs allowed in a transaction.
  --
  -- /Introduced in Alonzo/
  , ProtocolParameters -> Maybe Coin
protocolParamUTxOCostPerByte :: Maybe L.Coin
  -- ^ Cost in ada per byte of UTxO storage.
  --
  -- /Introduced in Babbage/
  }
  deriving (ProtocolParameters -> ProtocolParameters -> Bool
(ProtocolParameters -> ProtocolParameters -> Bool)
-> (ProtocolParameters -> ProtocolParameters -> Bool)
-> Eq ProtocolParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ProtocolParameters -> ProtocolParameters -> Bool
== :: ProtocolParameters -> ProtocolParameters -> Bool
$c/= :: ProtocolParameters -> ProtocolParameters -> Bool
/= :: ProtocolParameters -> ProtocolParameters -> Bool
Eq, (forall x. ProtocolParameters -> Rep ProtocolParameters x)
-> (forall x. Rep ProtocolParameters x -> ProtocolParameters)
-> Generic ProtocolParameters
forall x. Rep ProtocolParameters x -> ProtocolParameters
forall x. ProtocolParameters -> Rep ProtocolParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ProtocolParameters -> Rep ProtocolParameters x
from :: forall x. ProtocolParameters -> Rep ProtocolParameters x
$cto :: forall x. Rep ProtocolParameters x -> ProtocolParameters
to :: forall x. Rep ProtocolParameters x -> ProtocolParameters
Generic, Int -> ProtocolParameters -> ShowS
[ProtocolParameters] -> ShowS
ProtocolParameters -> String
(Int -> ProtocolParameters -> ShowS)
-> (ProtocolParameters -> String)
-> ([ProtocolParameters] -> ShowS)
-> Show ProtocolParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ProtocolParameters -> ShowS
showsPrec :: Int -> ProtocolParameters -> ShowS
$cshow :: ProtocolParameters -> String
show :: ProtocolParameters -> String
$cshowList :: [ProtocolParameters] -> ShowS
showList :: [ProtocolParameters] -> ShowS
Show)

instance FromJSON ProtocolParameters where
  parseJSON :: Value -> Parser ProtocolParameters
parseJSON =
    String
-> (KeyMap Value -> Parser ProtocolParameters)
-> Value
-> Parser ProtocolParameters
forall a. String -> (KeyMap Value -> Parser a) -> Value -> Parser a
withObject String
"ProtocolParameters" ((KeyMap Value -> Parser ProtocolParameters)
 -> Value -> Parser ProtocolParameters)
-> (KeyMap Value -> Parser ProtocolParameters)
-> Value
-> Parser ProtocolParameters
forall a b. (a -> b) -> a -> b
$ \KeyMap Value
o -> do
      v <- KeyMap Value
o KeyMap Value -> Key -> Parser (KeyMap Value)
forall a. FromJSON a => KeyMap Value -> Key -> Parser a
.: Key
"protocolVersion"
      ProtocolParameters
        <$> ((,) <$> v .: "major" <*> v .: "minor")
        <*> o .:? "decentralization"
        <*> o .: "extraPraosEntropy"
        <*> o .: "maxBlockHeaderSize"
        <*> o .: "maxBlockBodySize"
        <*> o .: "maxTxSize"
        <*> o .: "txFeeFixed"
        <*> o .: "txFeePerByte"
        <*> o .: "minUTxOValue"
        <*> o .: "stakeAddressDeposit"
        <*> o .: "stakePoolDeposit"
        <*> o .: "minPoolCost"
        <*> o .: "poolRetireMaxEpoch"
        <*> o .: "stakePoolTargetNum"
        <*> o .: "poolPledgeInfluence"
        <*> o .: "monetaryExpansion"
        <*> o .: "treasuryCut"
        <*> (fmap unCostModels <$> o .:? "costModels") .!= Map.empty
        <*> o .:? "executionUnitPrices"
        <*> o .:? "maxTxExecutionUnits"
        <*> o .:? "maxBlockExecutionUnits"
        <*> o .:? "maxValueSize"
        <*> o .:? "collateralPercentage"
        <*> o .:? "maxCollateralInputs"
        <*> o .:? "utxoCostPerByte"

instance ToJSON ProtocolParameters where
  toJSON :: ProtocolParameters -> Value
toJSON ProtocolParameters{Natural
Maybe Natural
Maybe Rational
Maybe Coin
Maybe ExecutionUnits
Maybe ExecutionUnitPrices
Maybe PraosNonce
Rational
Word16
(Natural, Natural)
Map AnyPlutusScriptVersion CostModel
Coin
EpochInterval
protocolParamProtocolVersion :: ProtocolParameters -> (Natural, Natural)
protocolParamDecentralization :: ProtocolParameters -> Maybe Rational
protocolParamExtraPraosEntropy :: ProtocolParameters -> Maybe PraosNonce
protocolParamMaxBlockHeaderSize :: ProtocolParameters -> Natural
protocolParamMaxBlockBodySize :: ProtocolParameters -> Natural
protocolParamMaxTxSize :: ProtocolParameters -> Natural
protocolParamTxFeeFixed :: ProtocolParameters -> Coin
protocolParamTxFeePerByte :: ProtocolParameters -> Coin
protocolParamMinUTxOValue :: ProtocolParameters -> Maybe Coin
protocolParamStakeAddressDeposit :: ProtocolParameters -> Coin
protocolParamStakePoolDeposit :: ProtocolParameters -> Coin
protocolParamMinPoolCost :: ProtocolParameters -> Coin
protocolParamPoolRetireMaxEpoch :: ProtocolParameters -> EpochInterval
protocolParamStakePoolTargetNum :: ProtocolParameters -> Word16
protocolParamPoolPledgeInfluence :: ProtocolParameters -> Rational
protocolParamMonetaryExpansion :: ProtocolParameters -> Rational
protocolParamTreasuryCut :: ProtocolParameters -> Rational
protocolParamCostModels :: ProtocolParameters -> Map AnyPlutusScriptVersion CostModel
protocolParamPrices :: ProtocolParameters -> Maybe ExecutionUnitPrices
protocolParamMaxTxExUnits :: ProtocolParameters -> Maybe ExecutionUnits
protocolParamMaxBlockExUnits :: ProtocolParameters -> Maybe ExecutionUnits
protocolParamMaxValueSize :: ProtocolParameters -> Maybe Natural
protocolParamCollateralPercent :: ProtocolParameters -> Maybe Natural
protocolParamMaxCollateralInputs :: ProtocolParameters -> Maybe Natural
protocolParamUTxOCostPerByte :: ProtocolParameters -> Maybe Coin
protocolParamProtocolVersion :: (Natural, Natural)
protocolParamDecentralization :: Maybe Rational
protocolParamExtraPraosEntropy :: Maybe PraosNonce
protocolParamMaxBlockHeaderSize :: Natural
protocolParamMaxBlockBodySize :: Natural
protocolParamMaxTxSize :: Natural
protocolParamTxFeeFixed :: Coin
protocolParamTxFeePerByte :: Coin
protocolParamMinUTxOValue :: Maybe Coin
protocolParamStakeAddressDeposit :: Coin
protocolParamStakePoolDeposit :: Coin
protocolParamMinPoolCost :: Coin
protocolParamPoolRetireMaxEpoch :: EpochInterval
protocolParamStakePoolTargetNum :: Word16
protocolParamPoolPledgeInfluence :: Rational
protocolParamMonetaryExpansion :: Rational
protocolParamTreasuryCut :: Rational
protocolParamCostModels :: Map AnyPlutusScriptVersion CostModel
protocolParamPrices :: Maybe ExecutionUnitPrices
protocolParamMaxTxExUnits :: Maybe ExecutionUnits
protocolParamMaxBlockExUnits :: Maybe ExecutionUnits
protocolParamMaxValueSize :: Maybe Natural
protocolParamCollateralPercent :: Maybe Natural
protocolParamMaxCollateralInputs :: Maybe Natural
protocolParamUTxOCostPerByte :: Maybe Coin
..} =
    [(Key, Value)] -> Value
object
      [ Key
"extraPraosEntropy" Key -> Maybe PraosNonce -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe PraosNonce
protocolParamExtraPraosEntropy
      , Key
"stakePoolTargetNum" Key -> Word16 -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Word16
protocolParamStakePoolTargetNum
      , Key
"minUTxOValue" Key -> Maybe Coin -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Coin
protocolParamMinUTxOValue
      , Key
"poolRetireMaxEpoch" Key -> EpochInterval -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= EpochInterval
protocolParamPoolRetireMaxEpoch
      , Key
"decentralization" Key -> Maybe Value -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Rational -> Value
toRationalJSON (Rational -> Value) -> Maybe Rational -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Rational
protocolParamDecentralization)
      , Key
"stakePoolDeposit" Key -> Coin -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Coin
protocolParamStakePoolDeposit
      , Key
"maxBlockHeaderSize" Key -> Natural -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Natural
protocolParamMaxBlockHeaderSize
      , Key
"maxBlockBodySize" Key -> Natural -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Natural
protocolParamMaxBlockBodySize
      , Key
"maxTxSize" Key -> Natural -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Natural
protocolParamMaxTxSize
      , Key
"treasuryCut" Key -> Value -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Rational -> Value
toRationalJSON Rational
protocolParamTreasuryCut
      , Key
"minPoolCost" Key -> Coin -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Coin
protocolParamMinPoolCost
      , Key
"monetaryExpansion" Key -> Value -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Rational -> Value
toRationalJSON Rational
protocolParamMonetaryExpansion
      , Key
"stakeAddressDeposit" Key -> Coin -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Coin
protocolParamStakeAddressDeposit
      , Key
"poolPledgeInfluence" Key -> Value -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Rational -> Value
toRationalJSON Rational
protocolParamPoolPledgeInfluence
      , Key
"protocolVersion"
          Key -> Value -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= let (Natural
major, Natural
minor) = (Natural, Natural)
protocolParamProtocolVersion
              in [(Key, Value)] -> Value
object [Key
"major" Key -> Natural -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Natural
major, Key
"minor" Key -> Natural -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Natural
minor]
      , Key
"txFeeFixed" Key -> Coin -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Coin
protocolParamTxFeeFixed
      , Key
"txFeePerByte" Key -> Coin -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Coin
protocolParamTxFeePerByte
      , -- Alonzo era:
        Key
"costModels" Key -> CostModels -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Map AnyPlutusScriptVersion CostModel -> CostModels
CostModels Map AnyPlutusScriptVersion CostModel
protocolParamCostModels
      , Key
"executionUnitPrices" Key -> Maybe ExecutionUnitPrices -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe ExecutionUnitPrices
protocolParamPrices
      , Key
"maxTxExecutionUnits" Key -> Maybe ExecutionUnits -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe ExecutionUnits
protocolParamMaxTxExUnits
      , Key
"maxBlockExecutionUnits" Key -> Maybe ExecutionUnits -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe ExecutionUnits
protocolParamMaxBlockExUnits
      , Key
"maxValueSize" Key -> Maybe Natural -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Natural
protocolParamMaxValueSize
      , Key
"collateralPercentage" Key -> Maybe Natural -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Natural
protocolParamCollateralPercent
      , Key
"maxCollateralInputs" Key -> Maybe Natural -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Natural
protocolParamMaxCollateralInputs
      , -- Babbage era:
        Key
"utxoCostPerByte" Key -> Maybe Coin -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Coin
protocolParamUTxOCostPerByte
      ]

-- ----------------------------------------------------------------------------
-- Praos nonce
--

newtype PraosNonce = PraosNonce {PraosNonce -> Hash HASH ByteString
unPraosNonce :: Hash.Hash HASH ByteString}
  deriving stock (PraosNonce -> PraosNonce -> Bool
(PraosNonce -> PraosNonce -> Bool)
-> (PraosNonce -> PraosNonce -> Bool) -> Eq PraosNonce
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PraosNonce -> PraosNonce -> Bool
== :: PraosNonce -> PraosNonce -> Bool
$c/= :: PraosNonce -> PraosNonce -> Bool
/= :: PraosNonce -> PraosNonce -> Bool
Eq, Eq PraosNonce
Eq PraosNonce =>
(PraosNonce -> PraosNonce -> Ordering)
-> (PraosNonce -> PraosNonce -> Bool)
-> (PraosNonce -> PraosNonce -> Bool)
-> (PraosNonce -> PraosNonce -> Bool)
-> (PraosNonce -> PraosNonce -> Bool)
-> (PraosNonce -> PraosNonce -> PraosNonce)
-> (PraosNonce -> PraosNonce -> PraosNonce)
-> Ord PraosNonce
PraosNonce -> PraosNonce -> Bool
PraosNonce -> PraosNonce -> Ordering
PraosNonce -> PraosNonce -> PraosNonce
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: PraosNonce -> PraosNonce -> Ordering
compare :: PraosNonce -> PraosNonce -> Ordering
$c< :: PraosNonce -> PraosNonce -> Bool
< :: PraosNonce -> PraosNonce -> Bool
$c<= :: PraosNonce -> PraosNonce -> Bool
<= :: PraosNonce -> PraosNonce -> Bool
$c> :: PraosNonce -> PraosNonce -> Bool
> :: PraosNonce -> PraosNonce -> Bool
$c>= :: PraosNonce -> PraosNonce -> Bool
>= :: PraosNonce -> PraosNonce -> Bool
$cmax :: PraosNonce -> PraosNonce -> PraosNonce
max :: PraosNonce -> PraosNonce -> PraosNonce
$cmin :: PraosNonce -> PraosNonce -> PraosNonce
min :: PraosNonce -> PraosNonce -> PraosNonce
Ord, (forall x. PraosNonce -> Rep PraosNonce x)
-> (forall x. Rep PraosNonce x -> PraosNonce) -> Generic PraosNonce
forall x. Rep PraosNonce x -> PraosNonce
forall x. PraosNonce -> Rep PraosNonce x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PraosNonce -> Rep PraosNonce x
from :: forall x. PraosNonce -> Rep PraosNonce x
$cto :: forall x. Rep PraosNonce x -> PraosNonce
to :: forall x. Rep PraosNonce x -> PraosNonce
Generic)
  deriving (Int -> PraosNonce -> ShowS
[PraosNonce] -> ShowS
PraosNonce -> String
(Int -> PraosNonce -> ShowS)
-> (PraosNonce -> String)
-> ([PraosNonce] -> ShowS)
-> Show PraosNonce
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PraosNonce -> ShowS
showsPrec :: Int -> PraosNonce -> ShowS
$cshow :: PraosNonce -> String
show :: PraosNonce -> String
$cshowList :: [PraosNonce] -> ShowS
showList :: [PraosNonce] -> ShowS
Show, (forall ann. PraosNonce -> Doc ann)
-> (forall ann. [PraosNonce] -> Doc ann) -> Pretty PraosNonce
forall ann. [PraosNonce] -> Doc ann
forall ann. PraosNonce -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. PraosNonce -> Doc ann
pretty :: forall ann. PraosNonce -> Doc ann
$cprettyList :: forall ann. [PraosNonce] -> Doc ann
prettyList :: forall ann. [PraosNonce] -> Doc ann
Pretty) via UsingRawBytesHex PraosNonce
  deriving ([PraosNonce] -> Value
[PraosNonce] -> Encoding
PraosNonce -> Bool
PraosNonce -> Value
PraosNonce -> Encoding
(PraosNonce -> Value)
-> (PraosNonce -> Encoding)
-> ([PraosNonce] -> Value)
-> ([PraosNonce] -> Encoding)
-> (PraosNonce -> Bool)
-> ToJSON PraosNonce
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: PraosNonce -> Value
toJSON :: PraosNonce -> Value
$ctoEncoding :: PraosNonce -> Encoding
toEncoding :: PraosNonce -> Encoding
$ctoJSONList :: [PraosNonce] -> Value
toJSONList :: [PraosNonce] -> Value
$ctoEncodingList :: [PraosNonce] -> Encoding
toEncodingList :: [PraosNonce] -> Encoding
$comitField :: PraosNonce -> Bool
omitField :: PraosNonce -> Bool
ToJSON, Maybe PraosNonce
Value -> Parser [PraosNonce]
Value -> Parser PraosNonce
(Value -> Parser PraosNonce)
-> (Value -> Parser [PraosNonce])
-> Maybe PraosNonce
-> FromJSON PraosNonce
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser PraosNonce
parseJSON :: Value -> Parser PraosNonce
$cparseJSONList :: Value -> Parser [PraosNonce]
parseJSONList :: Value -> Parser [PraosNonce]
$comittedField :: Maybe PraosNonce
omittedField :: Maybe PraosNonce
FromJSON) via UsingRawBytesHex PraosNonce
  deriving (Typeable PraosNonce
Typeable PraosNonce =>
(PraosNonce -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy PraosNonce -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy [PraosNonce] -> Size)
-> ToCBOR PraosNonce
PraosNonce -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PraosNonce] -> Size
(forall t. ToCBOR t => Proxy t -> Size) -> Proxy PraosNonce -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
$ctoCBOR :: PraosNonce -> Encoding
toCBOR :: PraosNonce -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy PraosNonce -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy PraosNonce -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PraosNonce] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [PraosNonce] -> Size
ToCBOR, Typeable PraosNonce
Typeable PraosNonce =>
(forall s. Decoder s PraosNonce)
-> (Proxy PraosNonce -> Text) -> FromCBOR PraosNonce
Proxy PraosNonce -> Text
forall s. Decoder s PraosNonce
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s PraosNonce
fromCBOR :: forall s. Decoder s PraosNonce
$clabel :: Proxy PraosNonce -> Text
label :: Proxy PraosNonce -> Text
FromCBOR) via UsingRawBytes PraosNonce

instance HasTypeProxy PraosNonce where
  data AsType PraosNonce = AsPraosNonce
  proxyToAsType :: Proxy PraosNonce -> AsType PraosNonce
proxyToAsType Proxy PraosNonce
_ = AsType PraosNonce
AsPraosNonce

instance SerialiseAsRawBytes PraosNonce where
  serialiseToRawBytes :: PraosNonce -> ByteString
serialiseToRawBytes (PraosNonce Hash HASH ByteString
h) =
    Hash HASH ByteString -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash HASH ByteString
h

  deserialiseFromRawBytes :: AsType PraosNonce
-> ByteString -> Either SerialiseAsRawBytesError PraosNonce
deserialiseFromRawBytes AsType PraosNonce
R:AsTypePraosNonce
AsPraosNonce ByteString
bs =
    SerialiseAsRawBytesError
-> Maybe PraosNonce -> Either SerialiseAsRawBytesError PraosNonce
forall b a. b -> Maybe a -> Either b a
maybeToRight (String -> SerialiseAsRawBytesError
SerialiseAsRawBytesError String
"Unable to deserialise PraosNonce") (Maybe PraosNonce -> Either SerialiseAsRawBytesError PraosNonce)
-> Maybe PraosNonce -> Either SerialiseAsRawBytesError PraosNonce
forall a b. (a -> b) -> a -> b
$
      Hash HASH ByteString -> PraosNonce
PraosNonce (Hash HASH ByteString -> PraosNonce)
-> Maybe (Hash HASH ByteString) -> Maybe PraosNonce
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Hash HASH ByteString)
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs

makePraosNonce :: ByteString -> PraosNonce
makePraosNonce :: ByteString -> PraosNonce
makePraosNonce = Hash HASH ByteString -> PraosNonce
PraosNonce (Hash HASH ByteString -> PraosNonce)
-> (ByteString -> Hash HASH ByteString) -> ByteString -> PraosNonce
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> ByteString) -> ByteString -> Hash HASH ByteString
forall h a. HashAlgorithm h => (a -> ByteString) -> a -> Hash h a
Crypto.hashWith ByteString -> ByteString
forall a. a -> a
id

toLedgerNonce :: Maybe PraosNonce -> Ledger.Nonce
toLedgerNonce :: Maybe PraosNonce -> Nonce
toLedgerNonce Maybe PraosNonce
Nothing = Nonce
Ledger.NeutralNonce
toLedgerNonce (Just (PraosNonce Hash HASH ByteString
h)) = Hash HASH Nonce -> Nonce
Ledger.Nonce (Hash HASH ByteString -> Hash HASH Nonce
forall h a b. Hash h a -> Hash h b
Crypto.castHash Hash HASH ByteString
h)

-- ----------------------------------------------------------------------------
-- Script execution unit prices and cost models
--

-- | The prices for 'ExecutionUnits' as a fraction of a 'L.Coin'.
--
-- These are used to determine the fee for the use of a script within a
-- transaction, based on the 'ExecutionUnits' needed by the use of the script.
data ExecutionUnitPrices
  = ExecutionUnitPrices
  { ExecutionUnitPrices -> Rational
priceExecutionSteps :: Rational
  , ExecutionUnitPrices -> Rational
priceExecutionMemory :: Rational
  }
  deriving (ExecutionUnitPrices -> ExecutionUnitPrices -> Bool
(ExecutionUnitPrices -> ExecutionUnitPrices -> Bool)
-> (ExecutionUnitPrices -> ExecutionUnitPrices -> Bool)
-> Eq ExecutionUnitPrices
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ExecutionUnitPrices -> ExecutionUnitPrices -> Bool
== :: ExecutionUnitPrices -> ExecutionUnitPrices -> Bool
$c/= :: ExecutionUnitPrices -> ExecutionUnitPrices -> Bool
/= :: ExecutionUnitPrices -> ExecutionUnitPrices -> Bool
Eq, Int -> ExecutionUnitPrices -> ShowS
[ExecutionUnitPrices] -> ShowS
ExecutionUnitPrices -> String
(Int -> ExecutionUnitPrices -> ShowS)
-> (ExecutionUnitPrices -> String)
-> ([ExecutionUnitPrices] -> ShowS)
-> Show ExecutionUnitPrices
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ExecutionUnitPrices -> ShowS
showsPrec :: Int -> ExecutionUnitPrices -> ShowS
$cshow :: ExecutionUnitPrices -> String
show :: ExecutionUnitPrices -> String
$cshowList :: [ExecutionUnitPrices] -> ShowS
showList :: [ExecutionUnitPrices] -> ShowS
Show)

instance ToCBOR ExecutionUnitPrices where
  toCBOR :: ExecutionUnitPrices -> Encoding
toCBOR ExecutionUnitPrices{Rational
priceExecutionSteps :: ExecutionUnitPrices -> Rational
priceExecutionSteps :: Rational
priceExecutionSteps, Rational
priceExecutionMemory :: ExecutionUnitPrices -> Rational
priceExecutionMemory :: Rational
priceExecutionMemory} =
    Word -> Encoding
CBOR.encodeListLen Word
2
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Rational -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Rational
priceExecutionSteps
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Rational -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Rational
priceExecutionMemory

instance FromCBOR ExecutionUnitPrices where
  fromCBOR :: forall s. Decoder s ExecutionUnitPrices
fromCBOR = do
    Text -> Int -> Decoder s ()
forall s. Text -> Int -> Decoder s ()
CBOR.enforceSize Text
"ExecutionUnitPrices" Int
2
    Rational -> Rational -> ExecutionUnitPrices
ExecutionUnitPrices
      (Rational -> Rational -> ExecutionUnitPrices)
-> Decoder s Rational
-> Decoder s (Rational -> ExecutionUnitPrices)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s Rational
forall s. Decoder s Rational
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder s (Rational -> ExecutionUnitPrices)
-> Decoder s Rational -> Decoder s ExecutionUnitPrices
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Rational
forall s. Decoder s Rational
forall a s. FromCBOR a => Decoder s a
fromCBOR

instance ToJSON ExecutionUnitPrices where
  toJSON :: ExecutionUnitPrices -> Value
toJSON ExecutionUnitPrices{Rational
priceExecutionSteps :: ExecutionUnitPrices -> Rational
priceExecutionSteps :: Rational
priceExecutionSteps, Rational
priceExecutionMemory :: ExecutionUnitPrices -> Rational
priceExecutionMemory :: Rational
priceExecutionMemory} =
    [(Key, Value)] -> Value
object
      [ Key
"priceSteps" Key -> Value -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Rational -> Value
toRationalJSON Rational
priceExecutionSteps
      , Key
"priceMemory" Key -> Value -> (Key, Value)
forall v. ToJSON v => Key -> v -> (Key, Value)
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Rational -> Value
toRationalJSON Rational
priceExecutionMemory
      ]

instance FromJSON ExecutionUnitPrices where
  parseJSON :: Value -> Parser ExecutionUnitPrices
parseJSON =
    String
-> (KeyMap Value -> Parser ExecutionUnitPrices)
-> Value
-> Parser ExecutionUnitPrices
forall a. String -> (KeyMap Value -> Parser a) -> Value -> Parser a
withObject String
"ExecutionUnitPrices" ((KeyMap Value -> Parser ExecutionUnitPrices)
 -> Value -> Parser ExecutionUnitPrices)
-> (KeyMap Value -> Parser ExecutionUnitPrices)
-> Value
-> Parser ExecutionUnitPrices
forall a b. (a -> b) -> a -> b
$ \KeyMap Value
o ->
      Rational -> Rational -> ExecutionUnitPrices
ExecutionUnitPrices
        (Rational -> Rational -> ExecutionUnitPrices)
-> Parser Rational -> Parser (Rational -> ExecutionUnitPrices)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> KeyMap Value
o KeyMap Value -> Key -> Parser Rational
forall a. FromJSON a => KeyMap Value -> Key -> Parser a
.: Key
"priceSteps"
        Parser (Rational -> ExecutionUnitPrices)
-> Parser Rational -> Parser ExecutionUnitPrices
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> KeyMap Value
o KeyMap Value -> Key -> Parser Rational
forall a. FromJSON a => KeyMap Value -> Key -> Parser a
.: Key
"priceMemory"

toAlonzoPrices :: ExecutionUnitPrices -> Either ProtocolParametersConversionError Alonzo.Prices
toAlonzoPrices :: ExecutionUnitPrices
-> Either ProtocolParametersConversionError Prices
toAlonzoPrices
  ExecutionUnitPrices
    { Rational
priceExecutionSteps :: ExecutionUnitPrices -> Rational
priceExecutionSteps :: Rational
priceExecutionSteps
    , Rational
priceExecutionMemory :: ExecutionUnitPrices -> Rational
priceExecutionMemory :: Rational
priceExecutionMemory
    } = do
    prSteps <- String
-> Rational
-> Either ProtocolParametersConversionError NonNegativeInterval
forall b.
BoundedRational b =>
String -> Rational -> Either ProtocolParametersConversionError b
boundRationalEither String
"Steps" Rational
priceExecutionSteps
    prMem <- boundRationalEither "Mem" priceExecutionMemory
    return
      Alonzo.Prices
        { Alonzo.prSteps
        , Alonzo.prMem
        }

fromAlonzoPrices :: Alonzo.Prices -> ExecutionUnitPrices
fromAlonzoPrices :: Prices -> ExecutionUnitPrices
fromAlonzoPrices Alonzo.Prices{NonNegativeInterval
prSteps :: Prices -> NonNegativeInterval
prSteps :: NonNegativeInterval
Alonzo.prSteps, NonNegativeInterval
prMem :: Prices -> NonNegativeInterval
prMem :: NonNegativeInterval
Alonzo.prMem} =
  ExecutionUnitPrices
    { priceExecutionSteps :: Rational
priceExecutionSteps = NonNegativeInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational NonNegativeInterval
prSteps
    , priceExecutionMemory :: Rational
priceExecutionMemory = NonNegativeInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational NonNegativeInterval
prMem
    }

-- ----------------------------------------------------------------------------
-- Script cost models
--

newtype CostModel = CostModel [Int64]
  deriving (CostModel -> CostModel -> Bool
(CostModel -> CostModel -> Bool)
-> (CostModel -> CostModel -> Bool) -> Eq CostModel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CostModel -> CostModel -> Bool
== :: CostModel -> CostModel -> Bool
$c/= :: CostModel -> CostModel -> Bool
/= :: CostModel -> CostModel -> Bool
Eq, Int -> CostModel -> ShowS
[CostModel] -> ShowS
CostModel -> String
(Int -> CostModel -> ShowS)
-> (CostModel -> String)
-> ([CostModel] -> ShowS)
-> Show CostModel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CostModel -> ShowS
showsPrec :: Int -> CostModel -> ShowS
$cshow :: CostModel -> String
show :: CostModel -> String
$cshowList :: [CostModel] -> ShowS
showList :: [CostModel] -> ShowS
Show, Typeable CostModel
Typeable CostModel =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> CostModel -> c CostModel)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CostModel)
-> (CostModel -> Constr)
-> (CostModel -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CostModel))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CostModel))
-> ((forall b. Data b => b -> b) -> CostModel -> CostModel)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> CostModel -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> CostModel -> r)
-> (forall u. (forall d. Data d => d -> u) -> CostModel -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> CostModel -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> CostModel -> m CostModel)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CostModel -> m CostModel)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> CostModel -> m CostModel)
-> Data CostModel
CostModel -> Constr
CostModel -> DataType
(forall b. Data b => b -> b) -> CostModel -> CostModel
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> CostModel -> u
forall u. (forall d. Data d => d -> u) -> CostModel -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CostModel -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CostModel -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CostModel -> m CostModel
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CostModel -> m CostModel
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CostModel
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CostModel -> c CostModel
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CostModel)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CostModel)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CostModel -> c CostModel
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CostModel -> c CostModel
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CostModel
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CostModel
$ctoConstr :: CostModel -> Constr
toConstr :: CostModel -> Constr
$cdataTypeOf :: CostModel -> DataType
dataTypeOf :: CostModel -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CostModel)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CostModel)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CostModel)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CostModel)
$cgmapT :: (forall b. Data b => b -> b) -> CostModel -> CostModel
gmapT :: (forall b. Data b => b -> b) -> CostModel -> CostModel
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CostModel -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CostModel -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CostModel -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CostModel -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> CostModel -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> CostModel -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CostModel -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CostModel -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CostModel -> m CostModel
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CostModel -> m CostModel
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CostModel -> m CostModel
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CostModel -> m CostModel
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CostModel -> m CostModel
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CostModel -> m CostModel
Data)
  deriving newtype (Typeable CostModel
Typeable CostModel =>
(CostModel -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy CostModel -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy [CostModel] -> Size)
-> ToCBOR CostModel
CostModel -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [CostModel] -> Size
(forall t. ToCBOR t => Proxy t -> Size) -> Proxy CostModel -> Size
forall a.
Typeable a =>
(a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
$ctoCBOR :: CostModel -> Encoding
toCBOR :: CostModel -> Encoding
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy CostModel -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy CostModel -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [CostModel] -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [CostModel] -> Size
ToCBOR, Typeable CostModel
Typeable CostModel =>
(forall s. Decoder s CostModel)
-> (Proxy CostModel -> Text) -> FromCBOR CostModel
Proxy CostModel -> Text
forall s. Decoder s CostModel
forall a.
Typeable a =>
(forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
$cfromCBOR :: forall s. Decoder s CostModel
fromCBOR :: forall s. Decoder s CostModel
$clabel :: Proxy CostModel -> Text
label :: Proxy CostModel -> Text
FromCBOR)

newtype CostModels = CostModels {CostModels -> Map AnyPlutusScriptVersion CostModel
unCostModels :: Map AnyPlutusScriptVersion CostModel}
  deriving (CostModels -> CostModels -> Bool
(CostModels -> CostModels -> Bool)
-> (CostModels -> CostModels -> Bool) -> Eq CostModels
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CostModels -> CostModels -> Bool
== :: CostModels -> CostModels -> Bool
$c/= :: CostModels -> CostModels -> Bool
/= :: CostModels -> CostModels -> Bool
Eq, Int -> CostModels -> ShowS
[CostModels] -> ShowS
CostModels -> String
(Int -> CostModels -> ShowS)
-> (CostModels -> String)
-> ([CostModels] -> ShowS)
-> Show CostModels
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CostModels -> ShowS
showsPrec :: Int -> CostModels -> ShowS
$cshow :: CostModels -> String
show :: CostModels -> String
$cshowList :: [CostModels] -> ShowS
showList :: [CostModels] -> ShowS
Show)

instance FromJSON CostModels where
  parseJSON :: Value -> Parser CostModels
parseJSON Value
v = Map AnyPlutusScriptVersion CostModel -> CostModels
CostModels (Map AnyPlutusScriptVersion CostModel -> CostModels)
-> (CostModels -> Map AnyPlutusScriptVersion CostModel)
-> CostModels
-> CostModels
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CostModels -> Map AnyPlutusScriptVersion CostModel
fromAlonzoCostModels (CostModels -> CostModels)
-> Parser CostModels -> Parser CostModels
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser CostModels
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v

instance ToJSON CostModels where
  toJSON :: CostModels -> Value
toJSON (CostModels Map AnyPlutusScriptVersion CostModel
costModels) =
    case Map AnyPlutusScriptVersion CostModel
-> Either ProtocolParametersConversionError CostModels
toAlonzoCostModels Map AnyPlutusScriptVersion CostModel
costModels of
      Left ProtocolParametersConversionError
err -> String -> Value
forall a. HasCallStack => String -> a
error (String -> Value) -> String -> Value
forall a b. (a -> b) -> a -> b
$ ProtocolParametersConversionError -> String
forall a. Error a => a -> String
displayError ProtocolParametersConversionError
err
      Right CostModels
ledgerCostModels -> CostModels -> Value
forall a. ToJSON a => a -> Value
toJSON CostModels
ledgerCostModels

toAlonzoCostModels
  :: Map AnyPlutusScriptVersion CostModel
  -> Either ProtocolParametersConversionError Alonzo.CostModels
toAlonzoCostModels :: Map AnyPlutusScriptVersion CostModel
-> Either ProtocolParametersConversionError CostModels
toAlonzoCostModels Map AnyPlutusScriptVersion CostModel
m = do
  f <- ((AnyPlutusScriptVersion, CostModel)
 -> Either ProtocolParametersConversionError (Language, CostModel))
-> [(AnyPlutusScriptVersion, CostModel)]
-> Either ProtocolParametersConversionError [(Language, CostModel)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (AnyPlutusScriptVersion, CostModel)
-> Either ProtocolParametersConversionError (Language, CostModel)
conv ([(AnyPlutusScriptVersion, CostModel)]
 -> Either
      ProtocolParametersConversionError [(Language, CostModel)])
-> [(AnyPlutusScriptVersion, CostModel)]
-> Either ProtocolParametersConversionError [(Language, CostModel)]
forall a b. (a -> b) -> a -> b
$ Map AnyPlutusScriptVersion CostModel
-> [Item (Map AnyPlutusScriptVersion CostModel)]
forall l. IsList l => l -> [Item l]
toList Map AnyPlutusScriptVersion CostModel
m
  Right $ Plutus.mkCostModels $ fromList f
 where
  conv
    :: (AnyPlutusScriptVersion, CostModel)
    -> Either ProtocolParametersConversionError (Plutus.Language, Alonzo.CostModel)
  conv :: (AnyPlutusScriptVersion, CostModel)
-> Either ProtocolParametersConversionError (Language, CostModel)
conv (AnyPlutusScriptVersion
anySVer, CostModel
cModel) = do
    alonzoCostModel <- CostModel
-> Language -> Either ProtocolParametersConversionError CostModel
toAlonzoCostModel CostModel
cModel (AnyPlutusScriptVersion -> Language
toAlonzoScriptLanguage AnyPlutusScriptVersion
anySVer)
    Right (toAlonzoScriptLanguage anySVer, alonzoCostModel)

fromAlonzoCostModels
  :: Plutus.CostModels
  -> Map AnyPlutusScriptVersion CostModel
fromAlonzoCostModels :: CostModels -> Map AnyPlutusScriptVersion CostModel
fromAlonzoCostModels CostModels
cModels =
  [(AnyPlutusScriptVersion, CostModel)]
-> Map AnyPlutusScriptVersion CostModel
[Item (Map AnyPlutusScriptVersion CostModel)]
-> Map AnyPlutusScriptVersion CostModel
forall l. IsList l => [Item l] -> l
fromList
    ([(AnyPlutusScriptVersion, CostModel)]
 -> Map AnyPlutusScriptVersion CostModel)
-> ([Item (Map Language CostModel)]
    -> [(AnyPlutusScriptVersion, CostModel)])
-> [Item (Map Language CostModel)]
-> Map AnyPlutusScriptVersion CostModel
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Language, CostModel) -> (AnyPlutusScriptVersion, CostModel))
-> [(Language, CostModel)] -> [(AnyPlutusScriptVersion, CostModel)]
forall a b. (a -> b) -> [a] -> [b]
map ((Language -> AnyPlutusScriptVersion)
-> (CostModel -> CostModel)
-> (Language, CostModel)
-> (AnyPlutusScriptVersion, CostModel)
forall a b c d. (a -> b) -> (c -> d) -> (a, c) -> (b, d)
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap Language -> AnyPlutusScriptVersion
fromAlonzoScriptLanguage CostModel -> CostModel
fromAlonzoCostModel)
    ([Item (Map Language CostModel)]
 -> Map AnyPlutusScriptVersion CostModel)
-> [Item (Map Language CostModel)]
-> Map AnyPlutusScriptVersion CostModel
forall a b. (a -> b) -> a -> b
$ Map Language CostModel -> [Item (Map Language CostModel)]
forall l. IsList l => l -> [Item l]
toList
    (Map Language CostModel -> [Item (Map Language CostModel)])
-> Map Language CostModel -> [Item (Map Language CostModel)]
forall a b. (a -> b) -> a -> b
$ CostModels -> Map Language CostModel
Plutus.costModelsValid CostModels
cModels

toAlonzoScriptLanguage :: AnyPlutusScriptVersion -> Plutus.Language
toAlonzoScriptLanguage :: AnyPlutusScriptVersion -> Language
toAlonzoScriptLanguage (AnyPlutusScriptVersion PlutusScriptVersion lang
PlutusScriptV1) = Language
Plutus.PlutusV1
toAlonzoScriptLanguage (AnyPlutusScriptVersion PlutusScriptVersion lang
PlutusScriptV2) = Language
Plutus.PlutusV2
toAlonzoScriptLanguage (AnyPlutusScriptVersion PlutusScriptVersion lang
PlutusScriptV3) = Language
Plutus.PlutusV3
toAlonzoScriptLanguage (AnyPlutusScriptVersion PlutusScriptVersion lang
PlutusScriptV4) = Language
Plutus.PlutusV4

fromAlonzoScriptLanguage :: Plutus.Language -> AnyPlutusScriptVersion
fromAlonzoScriptLanguage :: Language -> AnyPlutusScriptVersion
fromAlonzoScriptLanguage Language
Plutus.PlutusV1 = PlutusScriptVersion PlutusScriptV1 -> AnyPlutusScriptVersion
forall lang.
IsPlutusScriptLanguage lang =>
PlutusScriptVersion lang -> AnyPlutusScriptVersion
AnyPlutusScriptVersion PlutusScriptVersion PlutusScriptV1
PlutusScriptV1
fromAlonzoScriptLanguage Language
Plutus.PlutusV2 = PlutusScriptVersion PlutusScriptV2 -> AnyPlutusScriptVersion
forall lang.
IsPlutusScriptLanguage lang =>
PlutusScriptVersion lang -> AnyPlutusScriptVersion
AnyPlutusScriptVersion PlutusScriptVersion PlutusScriptV2
PlutusScriptV2
fromAlonzoScriptLanguage Language
Plutus.PlutusV3 = PlutusScriptVersion PlutusScriptV3 -> AnyPlutusScriptVersion
forall lang.
IsPlutusScriptLanguage lang =>
PlutusScriptVersion lang -> AnyPlutusScriptVersion
AnyPlutusScriptVersion PlutusScriptVersion PlutusScriptV3
PlutusScriptV3
fromAlonzoScriptLanguage Language
Plutus.PlutusV4 = PlutusScriptVersion PlutusScriptV4 -> AnyPlutusScriptVersion
forall lang.
IsPlutusScriptLanguage lang =>
PlutusScriptVersion lang -> AnyPlutusScriptVersion
AnyPlutusScriptVersion PlutusScriptVersion PlutusScriptV4
PlutusScriptV4

toAlonzoCostModel
  :: CostModel -> Plutus.Language -> Either ProtocolParametersConversionError Alonzo.CostModel
toAlonzoCostModel :: CostModel
-> Language -> Either ProtocolParametersConversionError CostModel
toAlonzoCostModel (CostModel [Int64]
m) Language
l = (CostModelApplyError -> ProtocolParametersConversionError)
-> Either CostModelApplyError CostModel
-> Either ProtocolParametersConversionError CostModel
forall a b c. (a -> b) -> Either a c -> Either b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (CostModel
-> CostModelApplyError -> ProtocolParametersConversionError
PpceInvalidCostModel ([Int64] -> CostModel
CostModel [Int64]
m)) (Either CostModelApplyError CostModel
 -> Either ProtocolParametersConversionError CostModel)
-> Either CostModelApplyError CostModel
-> Either ProtocolParametersConversionError CostModel
forall a b. (a -> b) -> a -> b
$ Language -> [Int64] -> Either CostModelApplyError CostModel
Alonzo.mkCostModel Language
l [Int64]
m

fromAlonzoCostModel :: Alonzo.CostModel -> CostModel
fromAlonzoCostModel :: CostModel -> CostModel
fromAlonzoCostModel CostModel
m = [Int64] -> CostModel
CostModel ([Int64] -> CostModel) -> [Int64] -> CostModel
forall a b. (a -> b) -> a -> b
$ CostModel -> [Int64]
Alonzo.getCostModelParams CostModel
m

-- ----------------------------------------------------------------------------
-- Proposals embedded in transactions to update protocol parameters
--

data UpdateProposal era
  = UpdateProposal
      !(Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era))
      !EpochNo
  deriving stock (UpdateProposal era -> UpdateProposal era -> Bool
(UpdateProposal era -> UpdateProposal era -> Bool)
-> (UpdateProposal era -> UpdateProposal era -> Bool)
-> Eq (UpdateProposal era)
forall era. UpdateProposal era -> UpdateProposal era -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall era. UpdateProposal era -> UpdateProposal era -> Bool
== :: UpdateProposal era -> UpdateProposal era -> Bool
$c/= :: forall era. UpdateProposal era -> UpdateProposal era -> Bool
/= :: UpdateProposal era -> UpdateProposal era -> Bool
Eq, Int -> UpdateProposal era -> ShowS
[UpdateProposal era] -> ShowS
UpdateProposal era -> String
(Int -> UpdateProposal era -> ShowS)
-> (UpdateProposal era -> String)
-> ([UpdateProposal era] -> ShowS)
-> Show (UpdateProposal era)
forall era. Int -> UpdateProposal era -> ShowS
forall era. [UpdateProposal era] -> ShowS
forall era. UpdateProposal era -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall era. Int -> UpdateProposal era -> ShowS
showsPrec :: Int -> UpdateProposal era -> ShowS
$cshow :: forall era. UpdateProposal era -> String
show :: UpdateProposal era -> String
$cshowList :: forall era. [UpdateProposal era] -> ShowS
showList :: [UpdateProposal era] -> ShowS
Show)
  deriving anyclass HasTypeProxy (UpdateProposal era)
AsType (UpdateProposal era)
-> ByteString -> Either DecoderError (UpdateProposal era)
HasTypeProxy (UpdateProposal era) =>
(UpdateProposal era -> ByteString)
-> (AsType (UpdateProposal era)
    -> ByteString -> Either DecoderError (UpdateProposal era))
-> SerialiseAsCBOR (UpdateProposal era)
UpdateProposal era -> ByteString
forall a.
HasTypeProxy a =>
(a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
forall era.
IsShelleyBasedEra era =>
HasTypeProxy (UpdateProposal era)
forall era.
IsShelleyBasedEra era =>
AsType (UpdateProposal era)
-> ByteString -> Either DecoderError (UpdateProposal era)
forall era.
IsShelleyBasedEra era =>
UpdateProposal era -> ByteString
$cserialiseToCBOR :: forall era.
IsShelleyBasedEra era =>
UpdateProposal era -> ByteString
serialiseToCBOR :: UpdateProposal era -> ByteString
$cdeserialiseFromCBOR :: forall era.
IsShelleyBasedEra era =>
AsType (UpdateProposal era)
-> ByteString -> Either DecoderError (UpdateProposal era)
deserialiseFromCBOR :: AsType (UpdateProposal era)
-> ByteString -> Either DecoderError (UpdateProposal era)
SerialiseAsCBOR

instance Typeable era => HasTypeProxy (UpdateProposal era) where
  data AsType (UpdateProposal era) = AsUpdateProposal
  proxyToAsType :: Proxy (UpdateProposal era) -> AsType (UpdateProposal era)
proxyToAsType Proxy (UpdateProposal era)
_ = AsType (UpdateProposal era)
forall era. AsType (UpdateProposal era)
AsUpdateProposal

instance IsShelleyBasedEra era => HasTextEnvelope (UpdateProposal era) where
  textEnvelopeType :: AsType (UpdateProposal era) -> TextEnvelopeType
textEnvelopeType AsType (UpdateProposal era)
_ = TextEnvelopeType
"UpdateProposalShelley"

instance IsShelleyBasedEra era => ToCBOR (UpdateProposal era) where
  toCBOR :: UpdateProposal era -> Encoding
toCBOR (UpdateProposal Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
ppup EpochNo
epochno) =
    Word -> Encoding
CBOR.encodeListLen Word
2
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
-> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
ppup
      Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> EpochNo -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR EpochNo
epochno

instance IsShelleyBasedEra era => FromCBOR (UpdateProposal era) where
  fromCBOR :: forall s. Decoder s (UpdateProposal era)
fromCBOR = do
    Text -> Int -> Decoder s ()
forall s. Text -> Int -> Decoder s ()
CBOR.enforceSize Text
"UpdateProposal" Int
2
    Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
-> EpochNo -> UpdateProposal era
forall era.
Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
-> EpochNo -> UpdateProposal era
UpdateProposal
      (Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
 -> EpochNo -> UpdateProposal era)
-> Decoder
     s (Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era))
-> Decoder s (EpochNo -> UpdateProposal era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder
  s (Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era))
forall s.
Decoder
  s (Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era))
forall a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder s (EpochNo -> UpdateProposal era)
-> Decoder s EpochNo -> Decoder s (UpdateProposal era)
forall a b. Decoder s (a -> b) -> Decoder s a -> Decoder s b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s EpochNo
forall s. Decoder s EpochNo
forall a s. FromCBOR a => Decoder s a
fromCBOR

makeShelleyUpdateProposal
  :: EraBasedProtocolParametersUpdate era
  -> [Hash GenesisKey]
  -> EpochNo
  -> UpdateProposal era
makeShelleyUpdateProposal :: forall era.
EraBasedProtocolParametersUpdate era
-> [Hash GenesisKey] -> EpochNo -> UpdateProposal era
makeShelleyUpdateProposal EraBasedProtocolParametersUpdate era
params [Hash GenesisKey]
genesisKeyHashes =
  -- TODO decide how to handle parameter validation
  --     for example we need to validate the Rational values can convert
  --     into the UnitInterval type ok.
  Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
-> EpochNo -> UpdateProposal era
forall era.
Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
-> EpochNo -> UpdateProposal era
UpdateProposal ([Item
   (Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era))]
-> Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
forall l. IsList l => [Item l] -> l
fromList [(Hash GenesisKey
kh, EraBasedProtocolParametersUpdate era
params) | Hash GenesisKey
kh <- [Hash GenesisKey]
genesisKeyHashes])

-- ----------------------------------------------------------------------------
-- Conversion functions: updates to ledger types
--

boundRationalEither
  :: Ledger.BoundedRational b
  => String
  -> Rational
  -> Either ProtocolParametersConversionError b
boundRationalEither :: forall b.
BoundedRational b =>
String -> Rational -> Either ProtocolParametersConversionError b
boundRationalEither String
name Rational
r = ProtocolParametersConversionError
-> Maybe b -> Either ProtocolParametersConversionError b
forall b a. b -> Maybe a -> Either b a
maybeToRight (String -> Rational -> ProtocolParametersConversionError
PpceOutOfBounds String
name Rational
r) (Maybe b -> Either ProtocolParametersConversionError b)
-> Maybe b -> Either ProtocolParametersConversionError b
forall a b. (a -> b) -> a -> b
$ Rational -> Maybe b
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational Rational
r

toLedgerUpdate
  :: ()
  => ShelleyBasedEra era
  -> UpdateProposal era
  -> Ledger.Update (ShelleyLedgerEra era)
toLedgerUpdate :: forall era.
ShelleyBasedEra era
-> UpdateProposal era -> Update (ShelleyLedgerEra era)
toLedgerUpdate ShelleyBasedEra era
sbe (UpdateProposal Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
ppup EpochNo
epochno) =
  ProposedPPUpdates (ShelleyLedgerEra era)
-> EpochNo -> Update (ShelleyLedgerEra era)
forall era. ProposedPPUpdates era -> EpochNo -> Update era
Ledger.Update (ShelleyBasedEra era
-> Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
-> ProposedPPUpdates (ShelleyLedgerEra era)
forall era.
ShelleyBasedEra era
-> Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
-> ProposedPPUpdates (ShelleyLedgerEra era)
toLedgerProposedPPUpdates ShelleyBasedEra era
sbe Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
ppup) EpochNo
epochno

toLedgerProposedPPUpdates
  :: ()
  => ShelleyBasedEra era
  -> Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
  -> Ledger.ProposedPPUpdates (ShelleyLedgerEra era)
toLedgerProposedPPUpdates :: forall era.
ShelleyBasedEra era
-> Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
-> ProposedPPUpdates (ShelleyLedgerEra era)
toLedgerProposedPPUpdates ShelleyBasedEra era
sbe Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
m =
  Map (KeyHash GenesisRole) (PParamsUpdate (ShelleyLedgerEra era))
-> ProposedPPUpdates (ShelleyLedgerEra era)
forall era.
Map (KeyHash GenesisRole) (PParamsUpdate era)
-> ProposedPPUpdates era
Ledger.ProposedPPUpdates (Map (KeyHash GenesisRole) (PParamsUpdate (ShelleyLedgerEra era))
 -> ProposedPPUpdates (ShelleyLedgerEra era))
-> Map (KeyHash GenesisRole) (PParamsUpdate (ShelleyLedgerEra era))
-> ProposedPPUpdates (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$
    (Hash GenesisKey -> KeyHash GenesisRole)
-> Map (Hash GenesisKey) (PParamsUpdate (ShelleyLedgerEra era))
-> Map (KeyHash GenesisRole) (PParamsUpdate (ShelleyLedgerEra era))
forall k1 k2 a. (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeysMonotonic (\(GenesisKeyHash KeyHash GenesisRole
kh) -> KeyHash GenesisRole
kh) (Map (Hash GenesisKey) (PParamsUpdate (ShelleyLedgerEra era))
 -> Map
      (KeyHash GenesisRole) (PParamsUpdate (ShelleyLedgerEra era)))
-> Map (Hash GenesisKey) (PParamsUpdate (ShelleyLedgerEra era))
-> Map (KeyHash GenesisRole) (PParamsUpdate (ShelleyLedgerEra era))
forall a b. (a -> b) -> a -> b
$
      (EraBasedProtocolParametersUpdate era
 -> PParamsUpdate (ShelleyLedgerEra era))
-> Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
-> Map (Hash GenesisKey) (PParamsUpdate (ShelleyLedgerEra era))
forall a b k. (a -> b) -> Map k a -> Map k b
Map.map (ShelleyBasedEra era
-> EraBasedProtocolParametersUpdate era
-> PParamsUpdate (ShelleyLedgerEra era)
forall era.
ShelleyBasedEra era
-> EraBasedProtocolParametersUpdate era
-> PParamsUpdate (ShelleyLedgerEra era)
createEraBasedProtocolParamUpdate ShelleyBasedEra era
sbe) Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
m

-- ----------------------------------------------------------------------------
-- Conversion functions: updates from ledger types
--

fromLedgerUpdate
  :: forall era ledgerera
   . ShelleyLedgerEra era ~ ledgerera
  => ShelleyBasedEra era
  -> Ledger.Update ledgerera
  -> UpdateProposal era
fromLedgerUpdate :: forall era ledgerera.
(ShelleyLedgerEra era ~ ledgerera) =>
ShelleyBasedEra era -> Update ledgerera -> UpdateProposal era
fromLedgerUpdate ShelleyBasedEra era
sbe (Ledger.Update ProposedPPUpdates ledgerera
ppup EpochNo
epochno) =
  Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
-> EpochNo -> UpdateProposal era
forall era.
Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
-> EpochNo -> UpdateProposal era
UpdateProposal (ShelleyBasedEra era
-> ProposedPPUpdates ledgerera
-> Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
forall era ledgerera.
(ShelleyLedgerEra era ~ ledgerera) =>
ShelleyBasedEra era
-> ProposedPPUpdates ledgerera
-> Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
fromLedgerProposedPPUpdates ShelleyBasedEra era
sbe ProposedPPUpdates ledgerera
ppup) EpochNo
epochno

fromLedgerProposedPPUpdates
  :: forall era ledgerera
   . ShelleyLedgerEra era ~ ledgerera
  => ShelleyBasedEra era
  -> Ledger.ProposedPPUpdates ledgerera
  -> Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
fromLedgerProposedPPUpdates :: forall era ledgerera.
(ShelleyLedgerEra era ~ ledgerera) =>
ShelleyBasedEra era
-> ProposedPPUpdates ledgerera
-> Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
fromLedgerProposedPPUpdates ShelleyBasedEra era
sbe =
  (PParamsUpdate ledgerera -> EraBasedProtocolParametersUpdate era)
-> Map (Hash GenesisKey) (PParamsUpdate ledgerera)
-> Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
forall a b k. (a -> b) -> Map k a -> Map k b
Map.map (ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> EraBasedProtocolParametersUpdate era
forall era.
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> EraBasedProtocolParametersUpdate era
fromLedgerPParamsUpdate ShelleyBasedEra era
sbe)
    (Map (Hash GenesisKey) (PParamsUpdate ledgerera)
 -> Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era))
-> (ProposedPPUpdates ledgerera
    -> Map (Hash GenesisKey) (PParamsUpdate ledgerera))
-> ProposedPPUpdates ledgerera
-> Map (Hash GenesisKey) (EraBasedProtocolParametersUpdate era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (KeyHash GenesisRole -> Hash GenesisKey)
-> Map (KeyHash GenesisRole) (PParamsUpdate ledgerera)
-> Map (Hash GenesisKey) (PParamsUpdate ledgerera)
forall k1 k2 a. (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeysMonotonic KeyHash GenesisRole -> Hash GenesisKey
GenesisKeyHash
    (Map (KeyHash GenesisRole) (PParamsUpdate ledgerera)
 -> Map (Hash GenesisKey) (PParamsUpdate ledgerera))
-> (ProposedPPUpdates ledgerera
    -> Map (KeyHash GenesisRole) (PParamsUpdate ledgerera))
-> ProposedPPUpdates ledgerera
-> Map (Hash GenesisKey) (PParamsUpdate ledgerera)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\(Ledger.ProposedPPUpdates Map (KeyHash GenesisRole) (PParamsUpdate ledgerera)
ppup) -> Map (KeyHash GenesisRole) (PParamsUpdate ledgerera)
ppup)

fromLedgerPParamsUpdate
  :: ShelleyBasedEra era
  -> Ledger.PParamsUpdate (ShelleyLedgerEra era)
  -> EraBasedProtocolParametersUpdate era
fromLedgerPParamsUpdate :: forall era.
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> EraBasedProtocolParametersUpdate era
fromLedgerPParamsUpdate ShelleyBasedEra era
sbe PParamsUpdate (ShelleyLedgerEra era)
ppup =
  let common :: CommonProtocolParametersUpdate
common = ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> CommonProtocolParametersUpdate
forall era.
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> CommonProtocolParametersUpdate
pparamsUpdateToCommonParametersUpdate ShelleyBasedEra era
sbe PParamsUpdate (ShelleyLedgerEra era)
ppup
   in case ShelleyBasedEra era
sbe of
        ShelleyBasedEra era
ShelleyBasedEraShelley ->
          let depAfterMary :: DeprecatedAfterMaryPParams era
depAfterMary = ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterMaryPParams era
forall era.
(MaxMaryEra (ShelleyLedgerEra era),
 EraPParams (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterMaryPParams era
pparamsUpdateToDeprecatedAfterMaryPParams ShelleyBasedEra era
sbe PParamsUpdate (ShelleyLedgerEra era)
ppup
              sToAPParamsUpdate :: ShelleyToAlonzoPParams era
sToAPParamsUpdate = ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> ShelleyToAlonzoPParams era
forall era.
(EraPParams (ShelleyLedgerEra era),
 MaxAlonzoEra (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> ShelleyToAlonzoPParams era
pparamsUpdateToShelleyToAlonzoPParams ShelleyBasedEra era
sbe PParamsUpdate (ShelleyLedgerEra era)
ppup
              depAfterBabbage :: DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage = ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterBabbagePParams ShelleyEra
forall era.
(MaxBabbageEra (ShelleyLedgerEra era),
 EraPParams (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterBabbagePParams ShelleyEra
pparamsUpdateToDeprecatedAfterBabbagePParams ShelleyBasedEra era
sbe PParamsUpdate (ShelleyLedgerEra era)
ppup
           in CommonProtocolParametersUpdate
-> DeprecatedAfterMaryPParams ShelleyEra
-> DeprecatedAfterBabbagePParams ShelleyEra
-> ShelleyToAlonzoPParams ShelleyEra
-> EraBasedProtocolParametersUpdate ShelleyEra
ShelleyEraBasedProtocolParametersUpdate CommonProtocolParametersUpdate
common DeprecatedAfterMaryPParams era
DeprecatedAfterMaryPParams ShelleyEra
depAfterMary DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage ShelleyToAlonzoPParams era
ShelleyToAlonzoPParams ShelleyEra
sToAPParamsUpdate
        ShelleyBasedEra era
ShelleyBasedEraAllegra ->
          let depAfterMary :: DeprecatedAfterMaryPParams era
depAfterMary = ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterMaryPParams era
forall era.
(MaxMaryEra (ShelleyLedgerEra era),
 EraPParams (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterMaryPParams era
pparamsUpdateToDeprecatedAfterMaryPParams ShelleyBasedEra era
sbe PParamsUpdate (ShelleyLedgerEra era)
ppup
              sToAPParamsUpdate :: ShelleyToAlonzoPParams era
sToAPParamsUpdate = ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> ShelleyToAlonzoPParams era
forall era.
(EraPParams (ShelleyLedgerEra era),
 MaxAlonzoEra (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> ShelleyToAlonzoPParams era
pparamsUpdateToShelleyToAlonzoPParams ShelleyBasedEra era
sbe PParamsUpdate (ShelleyLedgerEra era)
ppup
              depAfterBabbage :: DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage = ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterBabbagePParams ShelleyEra
forall era.
(MaxBabbageEra (ShelleyLedgerEra era),
 EraPParams (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterBabbagePParams ShelleyEra
pparamsUpdateToDeprecatedAfterBabbagePParams ShelleyBasedEra era
sbe PParamsUpdate (ShelleyLedgerEra era)
ppup
           in CommonProtocolParametersUpdate
-> DeprecatedAfterMaryPParams AllegraEra
-> ShelleyToAlonzoPParams AllegraEra
-> DeprecatedAfterBabbagePParams ShelleyEra
-> EraBasedProtocolParametersUpdate AllegraEra
AllegraEraBasedProtocolParametersUpdate CommonProtocolParametersUpdate
common DeprecatedAfterMaryPParams era
DeprecatedAfterMaryPParams AllegraEra
depAfterMary ShelleyToAlonzoPParams era
ShelleyToAlonzoPParams AllegraEra
sToAPParamsUpdate DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage
        ShelleyBasedEra era
ShelleyBasedEraMary ->
          let depAfterMary :: DeprecatedAfterMaryPParams era
depAfterMary = ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterMaryPParams era
forall era.
(MaxMaryEra (ShelleyLedgerEra era),
 EraPParams (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterMaryPParams era
pparamsUpdateToDeprecatedAfterMaryPParams ShelleyBasedEra era
sbe PParamsUpdate (ShelleyLedgerEra era)
ppup
              sToAPParamsUpdate :: ShelleyToAlonzoPParams era
sToAPParamsUpdate = ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> ShelleyToAlonzoPParams era
forall era.
(EraPParams (ShelleyLedgerEra era),
 MaxAlonzoEra (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> ShelleyToAlonzoPParams era
pparamsUpdateToShelleyToAlonzoPParams ShelleyBasedEra era
sbe PParamsUpdate (ShelleyLedgerEra era)
ppup
              depAfterBabbage :: DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage = ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterBabbagePParams ShelleyEra
forall era.
(MaxBabbageEra (ShelleyLedgerEra era),
 EraPParams (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterBabbagePParams ShelleyEra
pparamsUpdateToDeprecatedAfterBabbagePParams ShelleyBasedEra era
sbe PParamsUpdate (ShelleyLedgerEra era)
ppup
           in CommonProtocolParametersUpdate
-> DeprecatedAfterMaryPParams MaryEra
-> ShelleyToAlonzoPParams MaryEra
-> DeprecatedAfterBabbagePParams ShelleyEra
-> EraBasedProtocolParametersUpdate MaryEra
MaryEraBasedProtocolParametersUpdate CommonProtocolParametersUpdate
common DeprecatedAfterMaryPParams era
DeprecatedAfterMaryPParams MaryEra
depAfterMary ShelleyToAlonzoPParams era
ShelleyToAlonzoPParams MaryEra
sToAPParamsUpdate DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage
        ShelleyBasedEra era
ShelleyBasedEraAlonzo ->
          let sToAPParamsUpdate :: ShelleyToAlonzoPParams era
sToAPParamsUpdate = ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> ShelleyToAlonzoPParams era
forall era.
(EraPParams (ShelleyLedgerEra era),
 MaxAlonzoEra (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> ShelleyToAlonzoPParams era
pparamsUpdateToShelleyToAlonzoPParams ShelleyBasedEra era
sbe PParamsUpdate (ShelleyLedgerEra era)
ppup
              depAfterBabbage :: DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage = ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterBabbagePParams ShelleyEra
forall era.
(MaxBabbageEra (ShelleyLedgerEra era),
 EraPParams (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterBabbagePParams ShelleyEra
pparamsUpdateToDeprecatedAfterBabbagePParams ShelleyBasedEra era
sbe PParamsUpdate (ShelleyLedgerEra era)
ppup
              introInAlonzo :: AlonzoOnwardsPParams AlonzoEra
introInAlonzo = AlonzoEraOnwards AlonzoEra
-> PParamsUpdate (ShelleyLedgerEra AlonzoEra)
-> AlonzoOnwardsPParams AlonzoEra
forall era.
AlonzoEraOnwards era
-> PParamsUpdate (ShelleyLedgerEra era) -> AlonzoOnwardsPParams era
pparamsUpdateToAlonzoOnwardsPParams AlonzoEraOnwards AlonzoEra
AlonzoEraOnwardsAlonzo PParamsUpdate (ShelleyLedgerEra era)
PParamsUpdate (ShelleyLedgerEra AlonzoEra)
ppup
           in CommonProtocolParametersUpdate
-> ShelleyToAlonzoPParams AlonzoEra
-> AlonzoOnwardsPParams AlonzoEra
-> DeprecatedAfterBabbagePParams ShelleyEra
-> EraBasedProtocolParametersUpdate AlonzoEra
AlonzoEraBasedProtocolParametersUpdate CommonProtocolParametersUpdate
common ShelleyToAlonzoPParams era
ShelleyToAlonzoPParams AlonzoEra
sToAPParamsUpdate AlonzoOnwardsPParams AlonzoEra
introInAlonzo DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage
        ShelleyBasedEra era
ShelleyBasedEraBabbage ->
          let depAfterBabbage :: DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage = ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterBabbagePParams ShelleyEra
forall era.
(MaxBabbageEra (ShelleyLedgerEra era),
 EraPParams (ShelleyLedgerEra era)) =>
ShelleyBasedEra era
-> PParamsUpdate (ShelleyLedgerEra era)
-> DeprecatedAfterBabbagePParams ShelleyEra
pparamsUpdateToDeprecatedAfterBabbagePParams ShelleyBasedEra era
sbe PParamsUpdate (ShelleyLedgerEra era)
ppup
              introInAlonzo :: AlonzoOnwardsPParams BabbageEra
introInAlonzo = AlonzoEraOnwards BabbageEra
-> PParamsUpdate (ShelleyLedgerEra BabbageEra)
-> AlonzoOnwardsPParams BabbageEra
forall era.
AlonzoEraOnwards era
-> PParamsUpdate (ShelleyLedgerEra era) -> AlonzoOnwardsPParams era
pparamsUpdateToAlonzoOnwardsPParams AlonzoEraOnwards BabbageEra
AlonzoEraOnwardsBabbage PParamsUpdate (ShelleyLedgerEra era)
PParamsUpdate (ShelleyLedgerEra BabbageEra)
ppup
              introInBabbage :: IntroducedInBabbagePParams BabbageEra
introInBabbage = BabbageEraOnwards BabbageEra
-> PParamsUpdate (ShelleyLedgerEra BabbageEra)
-> IntroducedInBabbagePParams BabbageEra
forall era.
BabbageEraOnwards era
-> PParamsUpdate (ShelleyLedgerEra era)
-> IntroducedInBabbagePParams era
pparamsUpdateToIntroducedInBabbagePParams BabbageEraOnwards BabbageEra
BabbageEraOnwardsBabbage PParamsUpdate (ShelleyLedgerEra era)
PParamsUpdate (ShelleyLedgerEra BabbageEra)
ppup
           in CommonProtocolParametersUpdate
-> AlonzoOnwardsPParams BabbageEra
-> DeprecatedAfterBabbagePParams ShelleyEra
-> IntroducedInBabbagePParams BabbageEra
-> EraBasedProtocolParametersUpdate BabbageEra
BabbageEraBasedProtocolParametersUpdate CommonProtocolParametersUpdate
common AlonzoOnwardsPParams BabbageEra
introInAlonzo DeprecatedAfterBabbagePParams ShelleyEra
depAfterBabbage IntroducedInBabbagePParams BabbageEra
introInBabbage
        ShelleyBasedEra era
ShelleyBasedEraConway ->
          let introInAlonzo :: AlonzoOnwardsPParams ConwayEra
introInAlonzo = AlonzoEraOnwards ConwayEra
-> PParamsUpdate (ShelleyLedgerEra ConwayEra)
-> AlonzoOnwardsPParams ConwayEra
forall era.
AlonzoEraOnwards era
-> PParamsUpdate (ShelleyLedgerEra era) -> AlonzoOnwardsPParams era
pparamsUpdateToAlonzoOnwardsPParams AlonzoEraOnwards ConwayEra
AlonzoEraOnwardsConway PParamsUpdate (ShelleyLedgerEra era)
PParamsUpdate (ShelleyLedgerEra ConwayEra)
ppup
              introInBabbage :: IntroducedInBabbagePParams ConwayEra
introInBabbage = BabbageEraOnwards ConwayEra
-> PParamsUpdate (ShelleyLedgerEra ConwayEra)
-> IntroducedInBabbagePParams ConwayEra
forall era.
BabbageEraOnwards era
-> PParamsUpdate (ShelleyLedgerEra era)
-> IntroducedInBabbagePParams era
pparamsUpdateToIntroducedInBabbagePParams BabbageEraOnwards ConwayEra
BabbageEraOnwardsConway PParamsUpdate (ShelleyLedgerEra era)
PParamsUpdate (ShelleyLedgerEra ConwayEra)
ppup
              introInConway :: IntroducedInConwayPParams ConwayEra
introInConway = PParamsUpdate ConwayEra -> IntroducedInConwayPParams ConwayEra
forall ledgerera.
ConwayEraPParams ledgerera =>
PParamsUpdate ledgerera -> IntroducedInConwayPParams ledgerera
pparamsUpdateToIntroducedInConwayPParams PParamsUpdate ConwayEra
PParamsUpdate (ShelleyLedgerEra era)
ppup
           in CommonProtocolParametersUpdate
-> AlonzoOnwardsPParams ConwayEra
-> IntroducedInBabbagePParams ConwayEra
-> IntroducedInConwayPParams (ShelleyLedgerEra ConwayEra)
-> EraBasedProtocolParametersUpdate ConwayEra
ConwayEraBasedProtocolParametersUpdate CommonProtocolParametersUpdate
common AlonzoOnwardsPParams ConwayEra
introInAlonzo IntroducedInBabbagePParams ConwayEra
introInBabbage IntroducedInConwayPParams ConwayEra
IntroducedInConwayPParams (ShelleyLedgerEra ConwayEra)
introInConway
        ShelleyBasedEra era
ShelleyBasedEraDijkstra ->
          String -> EraBasedProtocolParametersUpdate era
forall a. HasCallStack => String -> a
error String
"TODO Dijkstra: fromLedgerPParamsUpdate: era not supported"

data ProtocolParametersError
  = PParamsErrorMissingMinUTxoValue !AnyCardanoEra
  | PParamsErrorMissingAlonzoProtocolParameter
  deriving Int -> ProtocolParametersError -> ShowS
[ProtocolParametersError] -> ShowS
ProtocolParametersError -> String
(Int -> ProtocolParametersError -> ShowS)
-> (ProtocolParametersError -> String)
-> ([ProtocolParametersError] -> ShowS)
-> Show ProtocolParametersError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ProtocolParametersError -> ShowS
showsPrec :: Int -> ProtocolParametersError -> ShowS
$cshow :: ProtocolParametersError -> String
show :: ProtocolParametersError -> String
$cshowList :: [ProtocolParametersError] -> ShowS
showList :: [ProtocolParametersError] -> ShowS
Show

instance Error ProtocolParametersError where
  prettyError :: forall ann. ProtocolParametersError -> Doc ann
prettyError = \case
    PParamsErrorMissingMinUTxoValue (AnyCardanoEra CardanoEra era
era) ->
      [Doc ann] -> Doc ann
forall a. Monoid a => [a] -> a
mconcat
        [ Doc ann
"The " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> CardanoEra era -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. CardanoEra era -> Doc ann
pretty CardanoEra era
era Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
" protocol parameters value is missing the following "
        , Doc ann
"field: MinUTxoValue. Did you intend to use a " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> CardanoEra era -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. CardanoEra era -> Doc ann
pretty CardanoEra era
era Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
" protocol "
        , Doc ann
"parameters value?"
        ]
    ProtocolParametersError
PParamsErrorMissingAlonzoProtocolParameter ->
      [Doc ann] -> Doc ann
forall a. Monoid a => [a] -> a
mconcat
        [ Doc ann
"The Alonzo era protocol parameters in use is missing one or more of the "
        , Doc ann
"following fields: UTxOCostPerWord, CostModels, Prices, MaxTxExUnits, "
        , Doc ann
"MaxBlockExUnits, MaxValueSize, CollateralPercent, MaxCollateralInputs. Did "
        , Doc ann
"you intend to use an Alonzo era protocol parameters value?"
        ]

data ProtocolParametersConversionError
  = PpceOutOfBounds !ProtocolParameterName !Rational
  | PpceVersionInvalid !ProtocolParameterVersion
  | PpceInvalidCostModel !CostModel !CostModelApplyError
  | PpceMissingParameter !ProtocolParameterName
  deriving (ProtocolParametersConversionError
-> ProtocolParametersConversionError -> Bool
(ProtocolParametersConversionError
 -> ProtocolParametersConversionError -> Bool)
-> (ProtocolParametersConversionError
    -> ProtocolParametersConversionError -> Bool)
-> Eq ProtocolParametersConversionError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ProtocolParametersConversionError
-> ProtocolParametersConversionError -> Bool
== :: ProtocolParametersConversionError
-> ProtocolParametersConversionError -> Bool
$c/= :: ProtocolParametersConversionError
-> ProtocolParametersConversionError -> Bool
/= :: ProtocolParametersConversionError
-> ProtocolParametersConversionError -> Bool
Eq, Int -> ProtocolParametersConversionError -> ShowS
[ProtocolParametersConversionError] -> ShowS
ProtocolParametersConversionError -> String
(Int -> ProtocolParametersConversionError -> ShowS)
-> (ProtocolParametersConversionError -> String)
-> ([ProtocolParametersConversionError] -> ShowS)
-> Show ProtocolParametersConversionError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ProtocolParametersConversionError -> ShowS
showsPrec :: Int -> ProtocolParametersConversionError -> ShowS
$cshow :: ProtocolParametersConversionError -> String
show :: ProtocolParametersConversionError -> String
$cshowList :: [ProtocolParametersConversionError] -> ShowS
showList :: [ProtocolParametersConversionError] -> ShowS
Show, Typeable ProtocolParametersConversionError
Typeable ProtocolParametersConversionError =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g)
 -> ProtocolParametersConversionError
 -> c ProtocolParametersConversionError)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r)
    -> Constr
    -> c ProtocolParametersConversionError)
-> (ProtocolParametersConversionError -> Constr)
-> (ProtocolParametersConversionError -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d))
    -> Maybe (c ProtocolParametersConversionError))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ProtocolParametersConversionError))
-> ((forall b. Data b => b -> b)
    -> ProtocolParametersConversionError
    -> ProtocolParametersConversionError)
-> (forall r r'.
    (r -> r' -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> ProtocolParametersConversionError
    -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> ProtocolParametersConversionError
    -> r)
-> (forall u.
    (forall d. Data d => d -> u)
    -> ProtocolParametersConversionError -> [u])
-> (forall u.
    Int
    -> (forall d. Data d => d -> u)
    -> ProtocolParametersConversionError
    -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> ProtocolParametersConversionError
    -> m ProtocolParametersConversionError)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> ProtocolParametersConversionError
    -> m ProtocolParametersConversionError)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> ProtocolParametersConversionError
    -> m ProtocolParametersConversionError)
-> Data ProtocolParametersConversionError
ProtocolParametersConversionError -> Constr
ProtocolParametersConversionError -> DataType
(forall b. Data b => b -> b)
-> ProtocolParametersConversionError
-> ProtocolParametersConversionError
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int
-> (forall d. Data d => d -> u)
-> ProtocolParametersConversionError
-> u
forall u.
(forall d. Data d => d -> u)
-> ProtocolParametersConversionError -> [u]
forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> ProtocolParametersConversionError
-> r
forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> ProtocolParametersConversionError
-> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ProtocolParametersConversionError
-> m ProtocolParametersConversionError
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ProtocolParametersConversionError
-> m ProtocolParametersConversionError
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c ProtocolParametersConversionError
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> ProtocolParametersConversionError
-> c ProtocolParametersConversionError
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c ProtocolParametersConversionError)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ProtocolParametersConversionError)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> ProtocolParametersConversionError
-> c ProtocolParametersConversionError
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> ProtocolParametersConversionError
-> c ProtocolParametersConversionError
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c ProtocolParametersConversionError
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c ProtocolParametersConversionError
$ctoConstr :: ProtocolParametersConversionError -> Constr
toConstr :: ProtocolParametersConversionError -> Constr
$cdataTypeOf :: ProtocolParametersConversionError -> DataType
dataTypeOf :: ProtocolParametersConversionError -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c ProtocolParametersConversionError)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c ProtocolParametersConversionError)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ProtocolParametersConversionError)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ProtocolParametersConversionError)
$cgmapT :: (forall b. Data b => b -> b)
-> ProtocolParametersConversionError
-> ProtocolParametersConversionError
gmapT :: (forall b. Data b => b -> b)
-> ProtocolParametersConversionError
-> ProtocolParametersConversionError
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> ProtocolParametersConversionError
-> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> ProtocolParametersConversionError
-> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> ProtocolParametersConversionError
-> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> ProtocolParametersConversionError
-> r
$cgmapQ :: forall u.
(forall d. Data d => d -> u)
-> ProtocolParametersConversionError -> [u]
gmapQ :: forall u.
(forall d. Data d => d -> u)
-> ProtocolParametersConversionError -> [u]
$cgmapQi :: forall u.
Int
-> (forall d. Data d => d -> u)
-> ProtocolParametersConversionError
-> u
gmapQi :: forall u.
Int
-> (forall d. Data d => d -> u)
-> ProtocolParametersConversionError
-> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ProtocolParametersConversionError
-> m ProtocolParametersConversionError
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ProtocolParametersConversionError
-> m ProtocolParametersConversionError
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ProtocolParametersConversionError
-> m ProtocolParametersConversionError
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ProtocolParametersConversionError
-> m ProtocolParametersConversionError
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ProtocolParametersConversionError
-> m ProtocolParametersConversionError
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ProtocolParametersConversionError
-> m ProtocolParametersConversionError
Data)

type ProtocolParameterName = String

type ProtocolParameterVersion = Natural

instance Error ProtocolParametersConversionError where
  prettyError :: forall ann. ProtocolParametersConversionError -> Doc ann
prettyError = \case
    PpceOutOfBounds String
name Rational
r ->
      Doc ann
"Value for '" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
name Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
"' is outside of bounds: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Double -> Doc ann
forall ann. Double -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty (Rational -> Double
forall a. Fractional a => Rational -> a
fromRational Rational
r :: Double)
    PpceVersionInvalid Natural
majorProtVer ->
      Doc ann
"Major protocol version is invalid: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Natural -> Doc ann
forall ann. Natural -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Natural
majorProtVer
    PpceInvalidCostModel CostModel
cm CostModelApplyError
err ->
      Doc ann
"Invalid cost model: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> forall a ann. Pretty a => a -> Doc ann
pretty @Text (CostModelApplyError -> Text
forall str a. (Pretty a, Render str) => a -> str
display CostModelApplyError
err) Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
" Cost model: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> CostModel -> Doc ann
forall a ann. Show a => a -> Doc ann
pshow CostModel
cm
    PpceMissingParameter String
name ->
      Doc ann
"Missing parameter: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
name