{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

-- | This module contains just the type of protocol parameters.
module Cardano.Ledger.Shelley.PParams
  ( PParams' (..),
    PParams,
    emptyPParams,
    HKD,
    HKDFunctor (..),
    PPUpdateEnv (..),
    ProposedPPUpdates (..),
    emptyPPPUpdates,
    PParamsUpdate,
    emptyPParamsUpdate,
    Update (..),
    updatePParams,
  )
where

import Cardano.Binary
  ( FromCBOR (..),
    ToCBOR (..),
    decodeWord,
    encodeListLen,
    encodeMapLen,
    encodeWord,
  )
import Cardano.Ledger.BaseTypes
  ( NonNegativeInterval,
    Nonce (NeutralNonce),
    StrictMaybe (..),
    UnitInterval,
    fromSMaybe,
    invalidKey,
    strictMaybeToMaybe,
  )
import qualified Cardano.Ledger.BaseTypes as BT
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Core (PParamsDelta)
import Cardano.Ledger.Era
import Cardano.Ledger.Keys (GenDelegs, KeyHash, KeyRole (..))
import Cardano.Ledger.Serialization
  ( FromCBORGroup (..),
    ToCBORGroup (..),
    decodeMapContents,
    decodeRecordNamed,
    mapFromCBOR,
    mapToCBOR,
  )
import Cardano.Ledger.Shelley.Orphans ()
import Cardano.Ledger.Slot (EpochNo (..), SlotNo (..))
import Control.DeepSeq (NFData)
import Control.Monad (unless)
import Data.Aeson (FromJSON (..), ToJSON (..), (.!=), (.:), (.:?), (.=))
import qualified Data.Aeson as Aeson
import Data.Coders
  ( Decode (From, RecD),
    decode,
    (<!),
  )
import Data.Default.Class (Default, def)
import Data.Foldable (fold)
import Data.Functor.Identity (Identity)
import Data.List (nub)
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.Maybe (mapMaybe)
import Data.Proxy (Proxy)
import GHC.Generics (Generic)
import NoThunks.Class (NoThunks (..))
import Numeric.Natural (Natural)

-- ====================================================================

-- | Higher Kinded Data
type family HKD f a where
  HKD Identity a = a
  HKD f a = f a

class HKDFunctor f where
  hkdMap :: Proxy f -> (a -> b) -> HKD f a -> HKD f b

instance HKDFunctor Identity where
  hkdMap :: Proxy Identity -> (a -> b) -> HKD Identity a -> HKD Identity b
hkdMap Proxy Identity
_ a -> b
f HKD Identity a
a = a -> b
f a
HKD Identity a
a

instance HKDFunctor Maybe where
  hkdMap :: Proxy Maybe -> (a -> b) -> HKD Maybe a -> HKD Maybe b
hkdMap Proxy Maybe
_ a -> b
f = (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f

instance HKDFunctor StrictMaybe where
  hkdMap :: Proxy StrictMaybe
-> (a -> b) -> HKD StrictMaybe a -> HKD StrictMaybe b
hkdMap Proxy StrictMaybe
_ a -> b
f = (a -> b) -> StrictMaybe a -> StrictMaybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f

-- | Protocol parameters.
--
-- We use the HKD type family so that the protocol parameters type and
-- the type for the updates to the protocol parameters can share records fields.
-- The protocol parameters will have type 'PParams'' 'Identity', and the updates
-- will have type 'PParams'' 'StrictMaybe', though 'Identity' will be hidden from use.
--
-- For example:
--
-- @
--   myParameters =
--     PParams
--       { _minfeeA = 0,
--         _minfeeB = 0,
--         ...
--       }
--
--   myUpdate =
--     PParamsUpdate
--       { _minfeeA = SNothing,
--         _minfeeB = SJust 42,
--         ...
--       }
-- @
data PParams' f era = PParams
  { -- | The linear factor for the minimum fee calculation
    PParams' f era -> HKD f Natural
_minfeeA :: !(HKD f Natural),
    -- | The constant factor for the minimum fee calculation
    PParams' f era -> HKD f Natural
_minfeeB :: !(HKD f Natural),
    -- | Maximal block body size
    PParams' f era -> HKD f Natural
_maxBBSize :: !(HKD f Natural),
    -- | Maximal transaction size
    PParams' f era -> HKD f Natural
_maxTxSize :: !(HKD f Natural),
    -- | Maximal block header size
    PParams' f era -> HKD f Natural
_maxBHSize :: !(HKD f Natural),
    -- | The amount of a key registration deposit
    PParams' f era -> HKD f Coin
_keyDeposit :: !(HKD f Coin),
    -- | The amount of a pool registration deposit
    PParams' f era -> HKD f Coin
_poolDeposit :: !(HKD f Coin),
    -- | epoch bound on pool retirement
    PParams' f era -> HKD f EpochNo
_eMax :: !(HKD f EpochNo),
    -- | Desired number of pools
    PParams' f era -> HKD f Natural
_nOpt :: !(HKD f Natural),
    -- | Pool influence
    PParams' f era -> HKD f NonNegativeInterval
_a0 :: !(HKD f NonNegativeInterval),
    -- | Monetary expansion
    PParams' f era -> HKD f UnitInterval
_rho :: !(HKD f UnitInterval),
    -- | Treasury expansion
    PParams' f era -> HKD f UnitInterval
_tau :: !(HKD f UnitInterval),
    -- | Decentralization parameter
    PParams' f era -> HKD f UnitInterval
_d :: !(HKD f UnitInterval),
    -- | Extra entropy
    PParams' f era -> HKD f Nonce
_extraEntropy :: !(HKD f Nonce),
    -- | Protocol version
    PParams' f era -> HKD f ProtVer
_protocolVersion :: !(HKD f BT.ProtVer),
    -- | Minimum UTxO value
    PParams' f era -> HKD f Coin
_minUTxOValue :: !(HKD f Coin),
    -- | Minimum Stake Pool Cost
    PParams' f era -> HKD f Coin
_minPoolCost :: !(HKD f Coin)
  }
  deriving ((forall x. PParams' f era -> Rep (PParams' f era) x)
-> (forall x. Rep (PParams' f era) x -> PParams' f era)
-> Generic (PParams' f era)
forall x. Rep (PParams' f era) x -> PParams' f era
forall x. PParams' f era -> Rep (PParams' f era) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (f :: * -> *) era x.
Rep (PParams' f era) x -> PParams' f era
forall (f :: * -> *) era x.
PParams' f era -> Rep (PParams' f era) x
$cto :: forall (f :: * -> *) era x.
Rep (PParams' f era) x -> PParams' f era
$cfrom :: forall (f :: * -> *) era x.
PParams' f era -> Rep (PParams' f era) x
Generic)

type PParams era = PParams' Identity era

deriving instance Eq (PParams' Identity era)

deriving instance Show (PParams' Identity era)

deriving instance NFData (PParams' Identity era)

instance NoThunks (PParams era)

instance (Era era) => ToCBOR (PParams era) where
  toCBOR :: PParams era -> Encoding
toCBOR
    PParams
      { _minfeeA :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_minfeeA = HKD Identity Natural
minfeeA',
        _minfeeB :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_minfeeB = HKD Identity Natural
minfeeB',
        _maxBBSize :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_maxBBSize = HKD Identity Natural
maxBBSize',
        _maxTxSize :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_maxTxSize = HKD Identity Natural
maxTxSize',
        _maxBHSize :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_maxBHSize = HKD Identity Natural
maxBHSize',
        _keyDeposit :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_keyDeposit = HKD Identity Coin
keyDeposit',
        _poolDeposit :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_poolDeposit = HKD Identity Coin
poolDeposit',
        _eMax :: forall (f :: * -> *) era. PParams' f era -> HKD f EpochNo
_eMax = HKD Identity EpochNo
eMax',
        _nOpt :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_nOpt = HKD Identity Natural
nOpt',
        _a0 :: forall (f :: * -> *) era.
PParams' f era -> HKD f NonNegativeInterval
_a0 = HKD Identity NonNegativeInterval
a0',
        _rho :: forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
_rho = HKD Identity UnitInterval
rho',
        _tau :: forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
_tau = HKD Identity UnitInterval
tau',
        _d :: forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
_d = HKD Identity UnitInterval
d',
        _extraEntropy :: forall (f :: * -> *) era. PParams' f era -> HKD f Nonce
_extraEntropy = HKD Identity Nonce
extraEntropy',
        _protocolVersion :: forall (f :: * -> *) era. PParams' f era -> HKD f ProtVer
_protocolVersion = HKD Identity ProtVer
protocolVersion',
        _minUTxOValue :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_minUTxOValue = HKD Identity Coin
minUTxOValue',
        _minPoolCost :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_minPoolCost = HKD Identity Coin
minPoolCost'
      } =
      Word -> Encoding
encodeListLen Word
18
        Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Natural
HKD Identity Natural
minfeeA'
        Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Natural
HKD Identity Natural
minfeeB'
        Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Natural
HKD Identity Natural
maxBBSize'
        Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Natural
HKD Identity Natural
maxTxSize'
        Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Natural
HKD Identity Natural
maxBHSize'
        Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Coin -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Coin
HKD Identity Coin
keyDeposit'
        Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Coin -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Coin
HKD Identity Coin
poolDeposit'
        Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> EpochNo -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR EpochNo
HKD Identity EpochNo
eMax'
        Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Natural
HKD Identity Natural
nOpt'
        Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> NonNegativeInterval -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR NonNegativeInterval
HKD Identity NonNegativeInterval
a0'
        Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> UnitInterval -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR UnitInterval
HKD Identity UnitInterval
rho'
        Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> UnitInterval -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR UnitInterval
HKD Identity UnitInterval
tau'
        Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> UnitInterval -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR UnitInterval
HKD Identity UnitInterval
d'
        Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Nonce -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Nonce
HKD Identity Nonce
extraEntropy'
        Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> ProtVer -> Encoding
forall a. ToCBORGroup a => a -> Encoding
toCBORGroup ProtVer
HKD Identity ProtVer
protocolVersion'
        Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Coin -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Coin
HKD Identity Coin
minUTxOValue'
        Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Coin -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Coin
HKD Identity Coin
minPoolCost'

instance (Era era) => FromCBOR (PParams era) where
  fromCBOR :: Decoder s (PParams era)
fromCBOR = do
    Text
-> (PParams era -> Int)
-> Decoder s (PParams era)
-> Decoder s (PParams era)
forall a s. Text -> (a -> Int) -> Decoder s a -> Decoder s a
decodeRecordNamed Text
"PParams" (Int -> PParams era -> Int
forall a b. a -> b -> a
const Int
18) (Decoder s (PParams era) -> Decoder s (PParams era))
-> Decoder s (PParams era) -> Decoder s (PParams era)
forall a b. (a -> b) -> a -> b
$
      Natural
-> Natural
-> Natural
-> Natural
-> Natural
-> Coin
-> Coin
-> EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> PParams era
forall (f :: * -> *) era.
HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Coin
-> HKD f Coin
-> HKD f EpochNo
-> HKD f Natural
-> HKD f NonNegativeInterval
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f Nonce
-> HKD f ProtVer
-> HKD f Coin
-> HKD f Coin
-> PParams' f era
PParams
        (Natural
 -> Natural
 -> Natural
 -> Natural
 -> Natural
 -> Coin
 -> Coin
 -> EpochNo
 -> Natural
 -> NonNegativeInterval
 -> UnitInterval
 -> UnitInterval
 -> UnitInterval
 -> Nonce
 -> ProtVer
 -> Coin
 -> Coin
 -> PParams era)
-> Decoder s Natural
-> Decoder
     s
     (Natural
      -> Natural
      -> Natural
      -> Natural
      -> Coin
      -> Coin
      -> EpochNo
      -> Natural
      -> NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s Natural
forall a s. FromCBOR a => Decoder s a
fromCBOR -- _minfeeA         :: Integer
        Decoder
  s
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> Coin
   -> Coin
   -> EpochNo
   -> Natural
   -> NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Decoder s Natural
-> Decoder
     s
     (Natural
      -> Natural
      -> Natural
      -> Coin
      -> Coin
      -> EpochNo
      -> Natural
      -> NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Natural
forall a s. FromCBOR a => Decoder s a
fromCBOR -- _minfeeB         :: Natural
        Decoder
  s
  (Natural
   -> Natural
   -> Natural
   -> Coin
   -> Coin
   -> EpochNo
   -> Natural
   -> NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Decoder s Natural
-> Decoder
     s
     (Natural
      -> Natural
      -> Coin
      -> Coin
      -> EpochNo
      -> Natural
      -> NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Natural
forall a s. FromCBOR a => Decoder s a
fromCBOR -- _maxBBSize       :: Natural
        Decoder
  s
  (Natural
   -> Natural
   -> Coin
   -> Coin
   -> EpochNo
   -> Natural
   -> NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Decoder s Natural
-> Decoder
     s
     (Natural
      -> Coin
      -> Coin
      -> EpochNo
      -> Natural
      -> NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Natural
forall a s. FromCBOR a => Decoder s a
fromCBOR -- _maxTxSize       :: Natural
        Decoder
  s
  (Natural
   -> Coin
   -> Coin
   -> EpochNo
   -> Natural
   -> NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Decoder s Natural
-> Decoder
     s
     (Coin
      -> Coin
      -> EpochNo
      -> Natural
      -> NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Natural
forall a s. FromCBOR a => Decoder s a
fromCBOR -- _maxBHSize       :: Natural
        Decoder
  s
  (Coin
   -> Coin
   -> EpochNo
   -> Natural
   -> NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Decoder s Coin
-> Decoder
     s
     (Coin
      -> EpochNo
      -> Natural
      -> NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Coin
forall a s. FromCBOR a => Decoder s a
fromCBOR -- _keyDeposit      :: Coin
        Decoder
  s
  (Coin
   -> EpochNo
   -> Natural
   -> NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Decoder s Coin
-> Decoder
     s
     (EpochNo
      -> Natural
      -> NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Coin
forall a s. FromCBOR a => Decoder s a
fromCBOR -- _poolDeposit     :: Coin
        Decoder
  s
  (EpochNo
   -> Natural
   -> NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Decoder s EpochNo
-> Decoder
     s
     (Natural
      -> NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s EpochNo
forall a s. FromCBOR a => Decoder s a
fromCBOR -- _eMax            :: EpochNo
        Decoder
  s
  (Natural
   -> NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Decoder s Natural
-> Decoder
     s
     (NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Natural
forall a s. FromCBOR a => Decoder s a
fromCBOR -- _nOpt            :: Natural
        Decoder
  s
  (NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Decoder s NonNegativeInterval
-> Decoder
     s
     (UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s NonNegativeInterval
forall a s. FromCBOR a => Decoder s a
fromCBOR -- _a0              :: NonNegativeInterval
        Decoder
  s
  (UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Decoder s UnitInterval
-> Decoder
     s
     (UnitInterval
      -> UnitInterval -> Nonce -> ProtVer -> Coin -> Coin -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s UnitInterval
forall a s. FromCBOR a => Decoder s a
fromCBOR -- _rho             :: UnitInterval
        Decoder
  s
  (UnitInterval
   -> UnitInterval -> Nonce -> ProtVer -> Coin -> Coin -> PParams era)
-> Decoder s UnitInterval
-> Decoder
     s (UnitInterval -> Nonce -> ProtVer -> Coin -> Coin -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s UnitInterval
forall a s. FromCBOR a => Decoder s a
fromCBOR -- _tau             :: UnitInterval
        Decoder
  s (UnitInterval -> Nonce -> ProtVer -> Coin -> Coin -> PParams era)
-> Decoder s UnitInterval
-> Decoder s (Nonce -> ProtVer -> Coin -> Coin -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s UnitInterval
forall a s. FromCBOR a => Decoder s a
fromCBOR -- _d               :: UnitInterval
        Decoder s (Nonce -> ProtVer -> Coin -> Coin -> PParams era)
-> Decoder s Nonce
-> Decoder s (ProtVer -> Coin -> Coin -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Nonce
forall a s. FromCBOR a => Decoder s a
fromCBOR -- _extraEntropy    :: Nonce
        Decoder s (ProtVer -> Coin -> Coin -> PParams era)
-> Decoder s ProtVer -> Decoder s (Coin -> Coin -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s ProtVer
forall a s. FromCBORGroup a => Decoder s a
fromCBORGroup -- _protocolVersion :: ProtVer
        Decoder s (Coin -> Coin -> PParams era)
-> Decoder s Coin -> Decoder s (Coin -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Coin
forall a s. FromCBOR a => Decoder s a
fromCBOR -- _minUTxOValue    :: Natural
        Decoder s (Coin -> PParams era)
-> Decoder s Coin -> Decoder s (PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Coin
forall a s. FromCBOR a => Decoder s a
fromCBOR -- _minPoolCost     :: Natural

instance ToJSON (PParams era) where
  toJSON :: PParams era -> Value
toJSON PParams era
pp =
    [Pair] -> Value
Aeson.object
      [ Key
"minFeeA" Key -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_minfeeA PParams era
pp,
        Key
"minFeeB" Key -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_minfeeB PParams era
pp,
        Key
"maxBlockBodySize" Key -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_maxBBSize PParams era
pp,
        Key
"maxTxSize" Key -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_maxTxSize PParams era
pp,
        Key
"maxBlockHeaderSize" Key -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_maxBHSize PParams era
pp,
        Key
"keyDeposit" Key -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParams era -> HKD Identity Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_keyDeposit PParams era
pp,
        Key
"poolDeposit" Key -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParams era -> HKD Identity Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_poolDeposit PParams era
pp,
        Key
"eMax" Key -> EpochNo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParams era -> HKD Identity EpochNo
forall (f :: * -> *) era. PParams' f era -> HKD f EpochNo
_eMax PParams era
pp,
        Key
"nOpt" Key -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_nOpt PParams era
pp,
        Key
"a0" Key -> NonNegativeInterval -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParams era -> HKD Identity NonNegativeInterval
forall (f :: * -> *) era.
PParams' f era -> HKD f NonNegativeInterval
_a0 PParams era
pp,
        Key
"rho" Key -> UnitInterval -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParams era -> HKD Identity UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
_rho PParams era
pp,
        Key
"tau" Key -> UnitInterval -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParams era -> HKD Identity UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
_tau PParams era
pp,
        Key
"decentralisationParam" Key -> UnitInterval -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParams era -> HKD Identity UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
_d PParams era
pp,
        Key
"extraEntropy" Key -> Nonce -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParams era -> HKD Identity Nonce
forall (f :: * -> *) era. PParams' f era -> HKD f Nonce
_extraEntropy PParams era
pp,
        Key
"protocolVersion" Key -> ProtVer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParams era -> HKD Identity ProtVer
forall (f :: * -> *) era. PParams' f era -> HKD f ProtVer
_protocolVersion PParams era
pp,
        Key
"minUTxOValue" Key -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParams era -> HKD Identity Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_minUTxOValue PParams era
pp,
        Key
"minPoolCost" Key -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PParams era -> HKD Identity Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_minPoolCost PParams era
pp
      ]

instance FromJSON (PParams era) where
  parseJSON :: Value -> Parser (PParams era)
parseJSON =
    String
-> (Object -> Parser (PParams era))
-> Value
-> Parser (PParams era)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"PParams" ((Object -> Parser (PParams era)) -> Value -> Parser (PParams era))
-> (Object -> Parser (PParams era))
-> Value
-> Parser (PParams era)
forall a b. (a -> b) -> a -> b
$ \Object
obj ->
      Natural
-> Natural
-> Natural
-> Natural
-> Natural
-> Coin
-> Coin
-> EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> PParams era
forall (f :: * -> *) era.
HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Coin
-> HKD f Coin
-> HKD f EpochNo
-> HKD f Natural
-> HKD f NonNegativeInterval
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f Nonce
-> HKD f ProtVer
-> HKD f Coin
-> HKD f Coin
-> PParams' f era
PParams
        (Natural
 -> Natural
 -> Natural
 -> Natural
 -> Natural
 -> Coin
 -> Coin
 -> EpochNo
 -> Natural
 -> NonNegativeInterval
 -> UnitInterval
 -> UnitInterval
 -> UnitInterval
 -> Nonce
 -> ProtVer
 -> Coin
 -> Coin
 -> PParams era)
-> Parser Natural
-> Parser
     (Natural
      -> Natural
      -> Natural
      -> Natural
      -> Coin
      -> Coin
      -> EpochNo
      -> Natural
      -> NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
obj Object -> Key -> Parser Natural
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"minFeeA"
        Parser
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> Coin
   -> Coin
   -> EpochNo
   -> Natural
   -> NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Parser Natural
-> Parser
     (Natural
      -> Natural
      -> Natural
      -> Coin
      -> Coin
      -> EpochNo
      -> Natural
      -> NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser Natural
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"minFeeB"
        Parser
  (Natural
   -> Natural
   -> Natural
   -> Coin
   -> Coin
   -> EpochNo
   -> Natural
   -> NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Parser Natural
-> Parser
     (Natural
      -> Natural
      -> Coin
      -> Coin
      -> EpochNo
      -> Natural
      -> NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser Natural
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"maxBlockBodySize"
        Parser
  (Natural
   -> Natural
   -> Coin
   -> Coin
   -> EpochNo
   -> Natural
   -> NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Parser Natural
-> Parser
     (Natural
      -> Coin
      -> Coin
      -> EpochNo
      -> Natural
      -> NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser Natural
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"maxTxSize"
        Parser
  (Natural
   -> Coin
   -> Coin
   -> EpochNo
   -> Natural
   -> NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Parser Natural
-> Parser
     (Coin
      -> Coin
      -> EpochNo
      -> Natural
      -> NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser Natural
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"maxBlockHeaderSize"
        Parser
  (Coin
   -> Coin
   -> EpochNo
   -> Natural
   -> NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Parser Coin
-> Parser
     (Coin
      -> EpochNo
      -> Natural
      -> NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser Coin
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"keyDeposit"
        Parser
  (Coin
   -> EpochNo
   -> Natural
   -> NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Parser Coin
-> Parser
     (EpochNo
      -> Natural
      -> NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser Coin
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"poolDeposit"
        Parser
  (EpochNo
   -> Natural
   -> NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Parser EpochNo
-> Parser
     (Natural
      -> NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser EpochNo
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"eMax"
        Parser
  (Natural
   -> NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Parser Natural
-> Parser
     (NonNegativeInterval
      -> UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser Natural
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"nOpt"
        Parser
  (NonNegativeInterval
   -> UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Parser NonNegativeInterval
-> Parser
     (UnitInterval
      -> UnitInterval
      -> UnitInterval
      -> Nonce
      -> ProtVer
      -> Coin
      -> Coin
      -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser NonNegativeInterval
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"a0"
        Parser
  (UnitInterval
   -> UnitInterval
   -> UnitInterval
   -> Nonce
   -> ProtVer
   -> Coin
   -> Coin
   -> PParams era)
-> Parser UnitInterval
-> Parser
     (UnitInterval
      -> UnitInterval -> Nonce -> ProtVer -> Coin -> Coin -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser UnitInterval
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"rho"
        Parser
  (UnitInterval
   -> UnitInterval -> Nonce -> ProtVer -> Coin -> Coin -> PParams era)
-> Parser UnitInterval
-> Parser
     (UnitInterval -> Nonce -> ProtVer -> Coin -> Coin -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser UnitInterval
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"tau"
        Parser
  (UnitInterval -> Nonce -> ProtVer -> Coin -> Coin -> PParams era)
-> Parser UnitInterval
-> Parser (Nonce -> ProtVer -> Coin -> Coin -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser UnitInterval
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"decentralisationParam"
        Parser (Nonce -> ProtVer -> Coin -> Coin -> PParams era)
-> Parser Nonce -> Parser (ProtVer -> Coin -> Coin -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser Nonce
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"extraEntropy"
        Parser (ProtVer -> Coin -> Coin -> PParams era)
-> Parser ProtVer -> Parser (Coin -> Coin -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser ProtVer
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"protocolVersion"
        Parser (Coin -> Coin -> PParams era)
-> Parser Coin -> Parser (Coin -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser (Maybe Coin)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"minUTxOValue" Parser (Maybe Coin) -> Coin -> Parser Coin
forall a. Parser (Maybe a) -> a -> Parser a
.!= Coin
forall a. Monoid a => a
mempty
        Parser (Coin -> PParams era) -> Parser Coin -> Parser (PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Key -> Parser (Maybe Coin)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"minPoolCost" Parser (Maybe Coin) -> Coin -> Parser Coin
forall a. Parser (Maybe a) -> a -> Parser a
.!= Coin
forall a. Monoid a => a
mempty

instance Default (PParams era) where
  def :: PParams era
def = PParams era
forall era. PParams era
emptyPParams

-- | Returns a basic "empty" `PParams` structure with all zero values.
emptyPParams :: PParams era
emptyPParams :: PParams era
emptyPParams =
  PParams :: forall (f :: * -> *) era.
HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Coin
-> HKD f Coin
-> HKD f EpochNo
-> HKD f Natural
-> HKD f NonNegativeInterval
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f Nonce
-> HKD f ProtVer
-> HKD f Coin
-> HKD f Coin
-> PParams' f era
PParams
    { _minfeeA :: HKD Identity Natural
_minfeeA = HKD Identity Natural
0,
      _minfeeB :: HKD Identity Natural
_minfeeB = HKD Identity Natural
0,
      _maxBBSize :: HKD Identity Natural
_maxBBSize = HKD Identity Natural
0,
      _maxTxSize :: HKD Identity Natural
_maxTxSize = HKD Identity Natural
2048,
      _maxBHSize :: HKD Identity Natural
_maxBHSize = HKD Identity Natural
0,
      _keyDeposit :: HKD Identity Coin
_keyDeposit = Integer -> Coin
Coin Integer
0,
      _poolDeposit :: HKD Identity Coin
_poolDeposit = Integer -> Coin
Coin Integer
0,
      _eMax :: HKD Identity EpochNo
_eMax = Word64 -> EpochNo
EpochNo Word64
0,
      _nOpt :: HKD Identity Natural
_nOpt = HKD Identity Natural
100,
      _a0 :: HKD Identity NonNegativeInterval
_a0 = HKD Identity NonNegativeInterval
forall a. Bounded a => a
minBound,
      _rho :: HKD Identity UnitInterval
_rho = HKD Identity UnitInterval
forall a. Bounded a => a
minBound,
      _tau :: HKD Identity UnitInterval
_tau = HKD Identity UnitInterval
forall a. Bounded a => a
minBound,
      _d :: HKD Identity UnitInterval
_d = HKD Identity UnitInterval
forall a. Bounded a => a
minBound,
      _extraEntropy :: HKD Identity Nonce
_extraEntropy = Nonce
HKD Identity Nonce
NeutralNonce,
      _protocolVersion :: HKD Identity ProtVer
_protocolVersion = Natural -> Natural -> ProtVer
BT.ProtVer Natural
0 Natural
0,
      _minUTxOValue :: HKD Identity Coin
_minUTxOValue = HKD Identity Coin
forall a. Monoid a => a
mempty,
      _minPoolCost :: HKD Identity Coin
_minPoolCost = HKD Identity Coin
forall a. Monoid a => a
mempty
    }

-- | Update Proposal
data Update era
  = Update !(ProposedPPUpdates era) !EpochNo
  deriving ((forall x. Update era -> Rep (Update era) x)
-> (forall x. Rep (Update era) x -> Update era)
-> Generic (Update era)
forall x. Rep (Update era) x -> Update era
forall x. Update era -> Rep (Update era) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x. Rep (Update era) x -> Update era
forall era x. Update era -> Rep (Update era) x
$cto :: forall era x. Rep (Update era) x -> Update era
$cfrom :: forall era x. Update era -> Rep (Update era) x
Generic)

deriving instance Eq (PParamsDelta era) => Eq (Update era)

deriving instance NFData (PParamsDelta era) => NFData (Update era)

deriving instance Show (PParamsDelta era) => Show (Update era)

instance NoThunks (PParamsDelta era) => NoThunks (Update era)

instance (Era era, ToCBOR (PParamsDelta era)) => ToCBOR (Update era) where
  toCBOR :: Update era -> Encoding
toCBOR (Update ProposedPPUpdates era
ppUpdate EpochNo
e) =
    Word -> Encoding
encodeListLen Word
2 Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> ProposedPPUpdates era -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR ProposedPPUpdates era
ppUpdate Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> EpochNo -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR EpochNo
e

instance
  (Era era, FromCBOR (PParamsDelta era)) =>
  FromCBOR (Update era)
  where
  fromCBOR :: Decoder s (Update era)
fromCBOR = Decode ('Closed 'Dense) (Update era) -> Decoder s (Update era)
forall (w :: Wrapped) t s. Decode w t -> Decoder s t
decode (Decode ('Closed 'Dense) (Update era) -> Decoder s (Update era))
-> Decode ('Closed 'Dense) (Update era) -> Decoder s (Update era)
forall a b. (a -> b) -> a -> b
$ (ProposedPPUpdates era -> EpochNo -> Update era)
-> Decode
     ('Closed 'Dense) (ProposedPPUpdates era -> EpochNo -> Update era)
forall t. t -> Decode ('Closed 'Dense) t
RecD ProposedPPUpdates era -> EpochNo -> Update era
forall era. ProposedPPUpdates era -> EpochNo -> Update era
Update Decode
  ('Closed 'Dense) (ProposedPPUpdates era -> EpochNo -> Update era)
-> Decode ('Closed Any) (ProposedPPUpdates era)
-> Decode ('Closed 'Dense) (EpochNo -> Update era)
forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) (ProposedPPUpdates era)
forall t (w :: Wrapped). FromCBOR t => Decode w t
From Decode ('Closed 'Dense) (EpochNo -> Update era)
-> Decode ('Closed Any) EpochNo
-> Decode ('Closed 'Dense) (Update era)
forall (w1 :: Wrapped) a t (w :: Density).
Decode w1 (a -> t) -> Decode ('Closed w) a -> Decode w1 t
<! Decode ('Closed Any) EpochNo
forall t (w :: Wrapped). FromCBOR t => Decode w t
From

data PPUpdateEnv era = PPUpdateEnv SlotNo (GenDelegs era)
  deriving (Int -> PPUpdateEnv era -> ShowS
[PPUpdateEnv era] -> ShowS
PPUpdateEnv era -> String
(Int -> PPUpdateEnv era -> ShowS)
-> (PPUpdateEnv era -> String)
-> ([PPUpdateEnv era] -> ShowS)
-> Show (PPUpdateEnv era)
forall era. Int -> PPUpdateEnv era -> ShowS
forall era. [PPUpdateEnv era] -> ShowS
forall era. PPUpdateEnv era -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PPUpdateEnv era] -> ShowS
$cshowList :: forall era. [PPUpdateEnv era] -> ShowS
show :: PPUpdateEnv era -> String
$cshow :: forall era. PPUpdateEnv era -> String
showsPrec :: Int -> PPUpdateEnv era -> ShowS
$cshowsPrec :: forall era. Int -> PPUpdateEnv era -> ShowS
Show, PPUpdateEnv era -> PPUpdateEnv era -> Bool
(PPUpdateEnv era -> PPUpdateEnv era -> Bool)
-> (PPUpdateEnv era -> PPUpdateEnv era -> Bool)
-> Eq (PPUpdateEnv era)
forall era. PPUpdateEnv era -> PPUpdateEnv era -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PPUpdateEnv era -> PPUpdateEnv era -> Bool
$c/= :: forall era. PPUpdateEnv era -> PPUpdateEnv era -> Bool
== :: PPUpdateEnv era -> PPUpdateEnv era -> Bool
$c== :: forall era. PPUpdateEnv era -> PPUpdateEnv era -> Bool
Eq, (forall x. PPUpdateEnv era -> Rep (PPUpdateEnv era) x)
-> (forall x. Rep (PPUpdateEnv era) x -> PPUpdateEnv era)
-> Generic (PPUpdateEnv era)
forall x. Rep (PPUpdateEnv era) x -> PPUpdateEnv era
forall x. PPUpdateEnv era -> Rep (PPUpdateEnv era) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x. Rep (PPUpdateEnv era) x -> PPUpdateEnv era
forall era x. PPUpdateEnv era -> Rep (PPUpdateEnv era) x
$cto :: forall era x. Rep (PPUpdateEnv era) x -> PPUpdateEnv era
$cfrom :: forall era x. PPUpdateEnv era -> Rep (PPUpdateEnv era) x
Generic)

instance NoThunks (PPUpdateEnv era)

type PParamsUpdate era = PParams' StrictMaybe era

deriving instance Eq (PParams' StrictMaybe era)

deriving instance Show (PParams' StrictMaybe era)

deriving instance Ord (PParams' StrictMaybe era)

deriving instance NFData (PParams' StrictMaybe era)

instance NoThunks (PParamsUpdate era)

instance (Era era) => ToCBOR (PParamsUpdate era) where
  toCBOR :: PParamsUpdate era -> Encoding
toCBOR PParamsUpdate era
ppup =
    let l :: [Encoding]
l =
          (StrictMaybe Encoding -> Maybe Encoding)
-> [StrictMaybe Encoding] -> [Encoding]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe
            StrictMaybe Encoding -> Maybe Encoding
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe
            [ Word -> (Natural -> Encoding) -> Natural -> StrictMaybe Encoding
forall t. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
0 Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (Natural -> StrictMaybe Encoding)
-> StrictMaybe Natural -> StrictMaybe Encoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_minfeeA PParamsUpdate era
ppup,
              Word -> (Natural -> Encoding) -> Natural -> StrictMaybe Encoding
forall t. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
1 Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (Natural -> StrictMaybe Encoding)
-> StrictMaybe Natural -> StrictMaybe Encoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_minfeeB PParamsUpdate era
ppup,
              Word -> (Natural -> Encoding) -> Natural -> StrictMaybe Encoding
forall t. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
2 Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (Natural -> StrictMaybe Encoding)
-> StrictMaybe Natural -> StrictMaybe Encoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_maxBBSize PParamsUpdate era
ppup,
              Word -> (Natural -> Encoding) -> Natural -> StrictMaybe Encoding
forall t. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
3 Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (Natural -> StrictMaybe Encoding)
-> StrictMaybe Natural -> StrictMaybe Encoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_maxTxSize PParamsUpdate era
ppup,
              Word -> (Natural -> Encoding) -> Natural -> StrictMaybe Encoding
forall t. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
4 Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (Natural -> StrictMaybe Encoding)
-> StrictMaybe Natural -> StrictMaybe Encoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_maxBHSize PParamsUpdate era
ppup,
              Word -> (Coin -> Encoding) -> Coin -> StrictMaybe Encoding
forall t. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
5 Coin -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (Coin -> StrictMaybe Encoding)
-> StrictMaybe Coin -> StrictMaybe Encoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PParamsUpdate era -> HKD StrictMaybe Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_keyDeposit PParamsUpdate era
ppup,
              Word -> (Coin -> Encoding) -> Coin -> StrictMaybe Encoding
forall t. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
6 Coin -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (Coin -> StrictMaybe Encoding)
-> StrictMaybe Coin -> StrictMaybe Encoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PParamsUpdate era -> HKD StrictMaybe Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_poolDeposit PParamsUpdate era
ppup,
              Word -> (EpochNo -> Encoding) -> EpochNo -> StrictMaybe Encoding
forall t. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
7 EpochNo -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (EpochNo -> StrictMaybe Encoding)
-> StrictMaybe EpochNo -> StrictMaybe Encoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PParamsUpdate era -> HKD StrictMaybe EpochNo
forall (f :: * -> *) era. PParams' f era -> HKD f EpochNo
_eMax PParamsUpdate era
ppup,
              Word -> (Natural -> Encoding) -> Natural -> StrictMaybe Encoding
forall t. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
8 Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (Natural -> StrictMaybe Encoding)
-> StrictMaybe Natural -> StrictMaybe Encoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_nOpt PParamsUpdate era
ppup,
              Word
-> (NonNegativeInterval -> Encoding)
-> NonNegativeInterval
-> StrictMaybe Encoding
forall t. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
9 NonNegativeInterval -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (NonNegativeInterval -> StrictMaybe Encoding)
-> StrictMaybe NonNegativeInterval -> StrictMaybe Encoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PParamsUpdate era -> HKD StrictMaybe NonNegativeInterval
forall (f :: * -> *) era.
PParams' f era -> HKD f NonNegativeInterval
_a0 PParamsUpdate era
ppup,
              Word
-> (UnitInterval -> Encoding)
-> UnitInterval
-> StrictMaybe Encoding
forall t. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
10 UnitInterval -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (UnitInterval -> StrictMaybe Encoding)
-> StrictMaybe UnitInterval -> StrictMaybe Encoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PParamsUpdate era -> HKD StrictMaybe UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
_rho PParamsUpdate era
ppup,
              Word
-> (UnitInterval -> Encoding)
-> UnitInterval
-> StrictMaybe Encoding
forall t. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
11 UnitInterval -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (UnitInterval -> StrictMaybe Encoding)
-> StrictMaybe UnitInterval -> StrictMaybe Encoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PParamsUpdate era -> HKD StrictMaybe UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
_tau PParamsUpdate era
ppup,
              Word
-> (UnitInterval -> Encoding)
-> UnitInterval
-> StrictMaybe Encoding
forall t. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
12 UnitInterval -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (UnitInterval -> StrictMaybe Encoding)
-> StrictMaybe UnitInterval -> StrictMaybe Encoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PParamsUpdate era -> HKD StrictMaybe UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
_d PParamsUpdate era
ppup,
              Word -> (Nonce -> Encoding) -> Nonce -> StrictMaybe Encoding
forall t. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
13 Nonce -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (Nonce -> StrictMaybe Encoding)
-> StrictMaybe Nonce -> StrictMaybe Encoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PParamsUpdate era -> HKD StrictMaybe Nonce
forall (f :: * -> *) era. PParams' f era -> HKD f Nonce
_extraEntropy PParamsUpdate era
ppup,
              Word -> (ProtVer -> Encoding) -> ProtVer -> StrictMaybe Encoding
forall t. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
14 ProtVer -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (ProtVer -> StrictMaybe Encoding)
-> StrictMaybe ProtVer -> StrictMaybe Encoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PParamsUpdate era -> HKD StrictMaybe ProtVer
forall (f :: * -> *) era. PParams' f era -> HKD f ProtVer
_protocolVersion PParamsUpdate era
ppup,
              Word -> (Coin -> Encoding) -> Coin -> StrictMaybe Encoding
forall t. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
15 Coin -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (Coin -> StrictMaybe Encoding)
-> StrictMaybe Coin -> StrictMaybe Encoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PParamsUpdate era -> HKD StrictMaybe Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_minUTxOValue PParamsUpdate era
ppup,
              Word -> (Coin -> Encoding) -> Coin -> StrictMaybe Encoding
forall t. Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
16 Coin -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (Coin -> StrictMaybe Encoding)
-> StrictMaybe Coin -> StrictMaybe Encoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< PParamsUpdate era -> HKD StrictMaybe Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_minPoolCost PParamsUpdate era
ppup
            ]
        n :: Word
n = Int -> Word
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word) -> Int -> Word
forall a b. (a -> b) -> a -> b
$ [Encoding] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Encoding]
l
     in Word -> Encoding
encodeMapLen Word
n Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> [Encoding] -> Encoding
forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m
fold [Encoding]
l
    where
      encodeMapElement :: Word -> (t -> Encoding) -> t -> StrictMaybe Encoding
encodeMapElement Word
ix t -> Encoding
encoder t
x = Encoding -> StrictMaybe Encoding
forall a. a -> StrictMaybe a
SJust (Word -> Encoding
encodeWord Word
ix Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> t -> Encoding
encoder t
x)

emptyPParamsUpdate :: PParamsUpdate era
emptyPParamsUpdate :: PParamsUpdate era
emptyPParamsUpdate =
  PParams :: forall (f :: * -> *) era.
HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Coin
-> HKD f Coin
-> HKD f EpochNo
-> HKD f Natural
-> HKD f NonNegativeInterval
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f Nonce
-> HKD f ProtVer
-> HKD f Coin
-> HKD f Coin
-> PParams' f era
PParams
    { _minfeeA :: HKD StrictMaybe Natural
_minfeeA = HKD StrictMaybe Natural
forall a. StrictMaybe a
SNothing,
      _minfeeB :: HKD StrictMaybe Natural
_minfeeB = HKD StrictMaybe Natural
forall a. StrictMaybe a
SNothing,
      _maxBBSize :: HKD StrictMaybe Natural
_maxBBSize = HKD StrictMaybe Natural
forall a. StrictMaybe a
SNothing,
      _maxTxSize :: HKD StrictMaybe Natural
_maxTxSize = HKD StrictMaybe Natural
forall a. StrictMaybe a
SNothing,
      _maxBHSize :: HKD StrictMaybe Natural
_maxBHSize = HKD StrictMaybe Natural
forall a. StrictMaybe a
SNothing,
      _keyDeposit :: HKD StrictMaybe Coin
_keyDeposit = HKD StrictMaybe Coin
forall a. StrictMaybe a
SNothing,
      _poolDeposit :: HKD StrictMaybe Coin
_poolDeposit = HKD StrictMaybe Coin
forall a. StrictMaybe a
SNothing,
      _eMax :: HKD StrictMaybe EpochNo
_eMax = HKD StrictMaybe EpochNo
forall a. StrictMaybe a
SNothing,
      _nOpt :: HKD StrictMaybe Natural
_nOpt = HKD StrictMaybe Natural
forall a. StrictMaybe a
SNothing,
      _a0 :: HKD StrictMaybe NonNegativeInterval
_a0 = HKD StrictMaybe NonNegativeInterval
forall a. StrictMaybe a
SNothing,
      _rho :: HKD StrictMaybe UnitInterval
_rho = HKD StrictMaybe UnitInterval
forall a. StrictMaybe a
SNothing,
      _tau :: HKD StrictMaybe UnitInterval
_tau = HKD StrictMaybe UnitInterval
forall a. StrictMaybe a
SNothing,
      _d :: HKD StrictMaybe UnitInterval
_d = HKD StrictMaybe UnitInterval
forall a. StrictMaybe a
SNothing,
      _extraEntropy :: HKD StrictMaybe Nonce
_extraEntropy = HKD StrictMaybe Nonce
forall a. StrictMaybe a
SNothing,
      _protocolVersion :: HKD StrictMaybe ProtVer
_protocolVersion = HKD StrictMaybe ProtVer
forall a. StrictMaybe a
SNothing,
      _minUTxOValue :: HKD StrictMaybe Coin
_minUTxOValue = HKD StrictMaybe Coin
forall a. StrictMaybe a
SNothing,
      _minPoolCost :: HKD StrictMaybe Coin
_minPoolCost = HKD StrictMaybe Coin
forall a. StrictMaybe a
SNothing
    }

instance (Era era) => FromCBOR (PParamsUpdate era) where
  fromCBOR :: Decoder s (PParamsUpdate era)
fromCBOR = do
    [(Int, PParamsUpdate era -> PParamsUpdate era)]
mapParts <-
      Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s [(Int, PParamsUpdate era -> PParamsUpdate era)]
forall s a. Decoder s a -> Decoder s [a]
decodeMapContents (Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
 -> Decoder s [(Int, PParamsUpdate era -> PParamsUpdate era)])
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s [(Int, PParamsUpdate era -> PParamsUpdate era)]
forall a b. (a -> b) -> a -> b
$
        Decoder s Word
forall s. Decoder s Word
decodeWord Decoder s Word
-> (Word
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
          Word
0 -> Decoder s Natural
forall a s. FromCBOR a => Decoder s a
fromCBOR Decoder s Natural
-> (Natural
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Natural
x -> (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
0, \PParamsUpdate era
up -> PParamsUpdate era
up {_minfeeA :: HKD StrictMaybe Natural
_minfeeA = Natural -> StrictMaybe Natural
forall a. a -> StrictMaybe a
SJust Natural
x})
          Word
1 -> Decoder s Natural
forall a s. FromCBOR a => Decoder s a
fromCBOR Decoder s Natural
-> (Natural
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Natural
x -> (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
1, \PParamsUpdate era
up -> PParamsUpdate era
up {_minfeeB :: HKD StrictMaybe Natural
_minfeeB = Natural -> StrictMaybe Natural
forall a. a -> StrictMaybe a
SJust Natural
x})
          Word
2 -> Decoder s Natural
forall a s. FromCBOR a => Decoder s a
fromCBOR Decoder s Natural
-> (Natural
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Natural
x -> (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
2, \PParamsUpdate era
up -> PParamsUpdate era
up {_maxBBSize :: HKD StrictMaybe Natural
_maxBBSize = Natural -> StrictMaybe Natural
forall a. a -> StrictMaybe a
SJust Natural
x})
          Word
3 -> Decoder s Natural
forall a s. FromCBOR a => Decoder s a
fromCBOR Decoder s Natural
-> (Natural
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Natural
x -> (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
3, \PParamsUpdate era
up -> PParamsUpdate era
up {_maxTxSize :: HKD StrictMaybe Natural
_maxTxSize = Natural -> StrictMaybe Natural
forall a. a -> StrictMaybe a
SJust Natural
x})
          Word
4 -> Decoder s Natural
forall a s. FromCBOR a => Decoder s a
fromCBOR Decoder s Natural
-> (Natural
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Natural
x -> (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
4, \PParamsUpdate era
up -> PParamsUpdate era
up {_maxBHSize :: HKD StrictMaybe Natural
_maxBHSize = Natural -> StrictMaybe Natural
forall a. a -> StrictMaybe a
SJust Natural
x})
          Word
5 -> Decoder s Coin
forall a s. FromCBOR a => Decoder s a
fromCBOR Decoder s Coin
-> (Coin
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Coin
x -> (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
5, \PParamsUpdate era
up -> PParamsUpdate era
up {_keyDeposit :: HKD StrictMaybe Coin
_keyDeposit = Coin -> StrictMaybe Coin
forall a. a -> StrictMaybe a
SJust Coin
x})
          Word
6 -> Decoder s Coin
forall a s. FromCBOR a => Decoder s a
fromCBOR Decoder s Coin
-> (Coin
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Coin
x -> (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
6, \PParamsUpdate era
up -> PParamsUpdate era
up {_poolDeposit :: HKD StrictMaybe Coin
_poolDeposit = Coin -> StrictMaybe Coin
forall a. a -> StrictMaybe a
SJust Coin
x})
          Word
7 -> Decoder s EpochNo
forall a s. FromCBOR a => Decoder s a
fromCBOR Decoder s EpochNo
-> (EpochNo
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \EpochNo
x -> (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
7, \PParamsUpdate era
up -> PParamsUpdate era
up {_eMax :: HKD StrictMaybe EpochNo
_eMax = EpochNo -> StrictMaybe EpochNo
forall a. a -> StrictMaybe a
SJust EpochNo
x})
          Word
8 -> Decoder s Natural
forall a s. FromCBOR a => Decoder s a
fromCBOR Decoder s Natural
-> (Natural
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Natural
x -> (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
8, \PParamsUpdate era
up -> PParamsUpdate era
up {_nOpt :: HKD StrictMaybe Natural
_nOpt = Natural -> StrictMaybe Natural
forall a. a -> StrictMaybe a
SJust Natural
x})
          Word
9 -> Decoder s NonNegativeInterval
forall a s. FromCBOR a => Decoder s a
fromCBOR Decoder s NonNegativeInterval
-> (NonNegativeInterval
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \NonNegativeInterval
x -> (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
9, \PParamsUpdate era
up -> PParamsUpdate era
up {_a0 :: HKD StrictMaybe NonNegativeInterval
_a0 = NonNegativeInterval -> StrictMaybe NonNegativeInterval
forall a. a -> StrictMaybe a
SJust NonNegativeInterval
x})
          Word
10 -> Decoder s UnitInterval
forall a s. FromCBOR a => Decoder s a
fromCBOR Decoder s UnitInterval
-> (UnitInterval
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \UnitInterval
x -> (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
10, \PParamsUpdate era
up -> PParamsUpdate era
up {_rho :: HKD StrictMaybe UnitInterval
_rho = UnitInterval -> StrictMaybe UnitInterval
forall a. a -> StrictMaybe a
SJust UnitInterval
x})
          Word
11 -> Decoder s UnitInterval
forall a s. FromCBOR a => Decoder s a
fromCBOR Decoder s UnitInterval
-> (UnitInterval
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \UnitInterval
x -> (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
11, \PParamsUpdate era
up -> PParamsUpdate era
up {_tau :: HKD StrictMaybe UnitInterval
_tau = UnitInterval -> StrictMaybe UnitInterval
forall a. a -> StrictMaybe a
SJust UnitInterval
x})
          Word
12 -> Decoder s UnitInterval
forall a s. FromCBOR a => Decoder s a
fromCBOR Decoder s UnitInterval
-> (UnitInterval
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \UnitInterval
x -> (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
12, \PParamsUpdate era
up -> PParamsUpdate era
up {_d :: HKD StrictMaybe UnitInterval
_d = UnitInterval -> StrictMaybe UnitInterval
forall a. a -> StrictMaybe a
SJust UnitInterval
x})
          Word
13 -> Decoder s Nonce
forall a s. FromCBOR a => Decoder s a
fromCBOR Decoder s Nonce
-> (Nonce
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Nonce
x -> (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
13, \PParamsUpdate era
up -> PParamsUpdate era
up {_extraEntropy :: HKD StrictMaybe Nonce
_extraEntropy = Nonce -> StrictMaybe Nonce
forall a. a -> StrictMaybe a
SJust Nonce
x})
          Word
14 -> Decoder s ProtVer
forall a s. FromCBOR a => Decoder s a
fromCBOR Decoder s ProtVer
-> (ProtVer
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ProtVer
x -> (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
14, \PParamsUpdate era
up -> PParamsUpdate era
up {_protocolVersion :: HKD StrictMaybe ProtVer
_protocolVersion = ProtVer -> StrictMaybe ProtVer
forall a. a -> StrictMaybe a
SJust ProtVer
x})
          Word
15 -> Decoder s Coin
forall a s. FromCBOR a => Decoder s a
fromCBOR Decoder s Coin
-> (Coin
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Coin
x -> (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
15, \PParamsUpdate era
up -> PParamsUpdate era
up {_minUTxOValue :: HKD StrictMaybe Coin
_minUTxOValue = Coin -> StrictMaybe Coin
forall a. a -> StrictMaybe a
SJust Coin
x})
          Word
16 -> Decoder s Coin
forall a s. FromCBOR a => Decoder s a
fromCBOR Decoder s Coin
-> (Coin
    -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era))
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Coin
x -> (Int, PParamsUpdate era -> PParamsUpdate era)
-> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int
16, \PParamsUpdate era
up -> PParamsUpdate era
up {_minPoolCost :: HKD StrictMaybe Coin
_minPoolCost = Coin -> StrictMaybe Coin
forall a. a -> StrictMaybe a
SJust Coin
x})
          Word
k -> Word -> Decoder s (Int, PParamsUpdate era -> PParamsUpdate era)
forall s a. Word -> Decoder s a
invalidKey Word
k
    let fields :: [Int]
fields = (Int, PParamsUpdate era -> PParamsUpdate era) -> Int
forall a b. (a, b) -> a
fst ((Int, PParamsUpdate era -> PParamsUpdate era) -> Int)
-> [(Int, PParamsUpdate era -> PParamsUpdate era)] -> [Int]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Int, PParamsUpdate era -> PParamsUpdate era)]
mapParts :: [Int]
    Bool -> Decoder s () -> Decoder s ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless
      ([Int] -> [Int]
forall a. Eq a => [a] -> [a]
nub [Int]
fields [Int] -> [Int] -> Bool
forall a. Eq a => a -> a -> Bool
== [Int]
fields)
      (String -> Decoder s ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Decoder s ()) -> String -> Decoder s ()
forall a b. (a -> b) -> a -> b
$ String
"duplicate keys: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> [Int] -> String
forall a. Show a => a -> String
show [Int]
fields)
    PParamsUpdate era -> Decoder s (PParamsUpdate era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PParamsUpdate era -> Decoder s (PParamsUpdate era))
-> PParamsUpdate era -> Decoder s (PParamsUpdate era)
forall a b. (a -> b) -> a -> b
$ ((PParamsUpdate era -> PParamsUpdate era)
 -> PParamsUpdate era -> PParamsUpdate era)
-> PParamsUpdate era
-> [PParamsUpdate era -> PParamsUpdate era]
-> PParamsUpdate era
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (PParamsUpdate era -> PParamsUpdate era)
-> PParamsUpdate era -> PParamsUpdate era
forall a b. (a -> b) -> a -> b
($) PParamsUpdate era
forall era. PParamsUpdate era
emptyPParamsUpdate ((Int, PParamsUpdate era -> PParamsUpdate era)
-> PParamsUpdate era -> PParamsUpdate era
forall a b. (a, b) -> b
snd ((Int, PParamsUpdate era -> PParamsUpdate era)
 -> PParamsUpdate era -> PParamsUpdate era)
-> [(Int, PParamsUpdate era -> PParamsUpdate era)]
-> [PParamsUpdate era -> PParamsUpdate era]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Int, PParamsUpdate era -> PParamsUpdate era)]
mapParts)

-- | Update operation for protocol parameters structure @PParams
newtype ProposedPPUpdates era
  = ProposedPPUpdates (Map (KeyHash 'Genesis (Crypto era)) (PParamsDelta era))
  deriving ((forall x. ProposedPPUpdates era -> Rep (ProposedPPUpdates era) x)
-> (forall x.
    Rep (ProposedPPUpdates era) x -> ProposedPPUpdates era)
-> Generic (ProposedPPUpdates era)
forall x. Rep (ProposedPPUpdates era) x -> ProposedPPUpdates era
forall x. ProposedPPUpdates era -> Rep (ProposedPPUpdates era) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x.
Rep (ProposedPPUpdates era) x -> ProposedPPUpdates era
forall era x.
ProposedPPUpdates era -> Rep (ProposedPPUpdates era) x
$cto :: forall era x.
Rep (ProposedPPUpdates era) x -> ProposedPPUpdates era
$cfrom :: forall era x.
ProposedPPUpdates era -> Rep (ProposedPPUpdates era) x
Generic)

deriving instance Eq (PParamsDelta era) => Eq (ProposedPPUpdates era)

deriving instance NFData (PParamsDelta era) => NFData (ProposedPPUpdates era)

deriving instance Show (PParamsDelta era) => Show (ProposedPPUpdates era)

instance NoThunks (PParamsDelta era) => NoThunks (ProposedPPUpdates era)

instance
  (Era era, ToCBOR (PParamsDelta era)) =>
  ToCBOR (ProposedPPUpdates era)
  where
  toCBOR :: ProposedPPUpdates era -> Encoding
toCBOR (ProposedPPUpdates Map (KeyHash 'Genesis (Crypto era)) (PParamsDelta era)
m) = Map (KeyHash 'Genesis (Crypto era)) (PParamsDelta era) -> Encoding
forall a b. (ToCBOR a, ToCBOR b) => Map a b -> Encoding
mapToCBOR Map (KeyHash 'Genesis (Crypto era)) (PParamsDelta era)
m

instance
  (Era era, FromCBOR (PParamsDelta era)) =>
  FromCBOR (ProposedPPUpdates era)
  where
  fromCBOR :: Decoder s (ProposedPPUpdates era)
fromCBOR = Map (KeyHash 'Genesis (Crypto era)) (PParamsDelta era)
-> ProposedPPUpdates era
forall era.
Map (KeyHash 'Genesis (Crypto era)) (PParamsDelta era)
-> ProposedPPUpdates era
ProposedPPUpdates (Map (KeyHash 'Genesis (Crypto era)) (PParamsDelta era)
 -> ProposedPPUpdates era)
-> Decoder
     s (Map (KeyHash 'Genesis (Crypto era)) (PParamsDelta era))
-> Decoder s (ProposedPPUpdates era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s (Map (KeyHash 'Genesis (Crypto era)) (PParamsDelta era))
forall a b s.
(Ord a, FromCBOR a, FromCBOR b) =>
Decoder s (Map a b)
mapFromCBOR

emptyPPPUpdates :: ProposedPPUpdates era
emptyPPPUpdates :: ProposedPPUpdates era
emptyPPPUpdates = Map (KeyHash 'Genesis (Crypto era)) (PParamsDelta era)
-> ProposedPPUpdates era
forall era.
Map (KeyHash 'Genesis (Crypto era)) (PParamsDelta era)
-> ProposedPPUpdates era
ProposedPPUpdates Map (KeyHash 'Genesis (Crypto era)) (PParamsDelta era)
forall k a. Map k a
Map.empty

updatePParams :: PParams era -> PParamsUpdate era -> PParams era
updatePParams :: PParams era -> PParamsUpdate era -> PParams era
updatePParams PParams era
pp PParamsUpdate era
ppup =
  PParams :: forall (f :: * -> *) era.
HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Coin
-> HKD f Coin
-> HKD f EpochNo
-> HKD f Natural
-> HKD f NonNegativeInterval
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f Nonce
-> HKD f ProtVer
-> HKD f Coin
-> HKD f Coin
-> PParams' f era
PParams
    { _minfeeA :: HKD Identity Natural
_minfeeA = Natural -> StrictMaybe Natural -> Natural
forall a. a -> StrictMaybe a -> a
fromSMaybe (PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_minfeeA PParams era
pp) (PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_minfeeA PParamsUpdate era
ppup),
      _minfeeB :: HKD Identity Natural
_minfeeB = Natural -> StrictMaybe Natural -> Natural
forall a. a -> StrictMaybe a -> a
fromSMaybe (PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_minfeeB PParams era
pp) (PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_minfeeB PParamsUpdate era
ppup),
      _maxBBSize :: HKD Identity Natural
_maxBBSize = Natural -> StrictMaybe Natural -> Natural
forall a. a -> StrictMaybe a -> a
fromSMaybe (PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_maxBBSize PParams era
pp) (PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_maxBBSize PParamsUpdate era
ppup),
      _maxTxSize :: HKD Identity Natural
_maxTxSize = Natural -> StrictMaybe Natural -> Natural
forall a. a -> StrictMaybe a -> a
fromSMaybe (PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_maxTxSize PParams era
pp) (PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_maxTxSize PParamsUpdate era
ppup),
      _maxBHSize :: HKD Identity Natural
_maxBHSize = Natural -> StrictMaybe Natural -> Natural
forall a. a -> StrictMaybe a -> a
fromSMaybe (PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_maxBHSize PParams era
pp) (PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_maxBHSize PParamsUpdate era
ppup),
      _keyDeposit :: HKD Identity Coin
_keyDeposit = Coin -> StrictMaybe Coin -> Coin
forall a. a -> StrictMaybe a -> a
fromSMaybe (PParams era -> HKD Identity Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_keyDeposit PParams era
pp) (PParamsUpdate era -> HKD StrictMaybe Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_keyDeposit PParamsUpdate era
ppup),
      _poolDeposit :: HKD Identity Coin
_poolDeposit = Coin -> StrictMaybe Coin -> Coin
forall a. a -> StrictMaybe a -> a
fromSMaybe (PParams era -> HKD Identity Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_poolDeposit PParams era
pp) (PParamsUpdate era -> HKD StrictMaybe Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_poolDeposit PParamsUpdate era
ppup),
      _eMax :: HKD Identity EpochNo
_eMax = EpochNo -> StrictMaybe EpochNo -> EpochNo
forall a. a -> StrictMaybe a -> a
fromSMaybe (PParams era -> HKD Identity EpochNo
forall (f :: * -> *) era. PParams' f era -> HKD f EpochNo
_eMax PParams era
pp) (PParamsUpdate era -> HKD StrictMaybe EpochNo
forall (f :: * -> *) era. PParams' f era -> HKD f EpochNo
_eMax PParamsUpdate era
ppup),
      _nOpt :: HKD Identity Natural
_nOpt = Natural -> StrictMaybe Natural -> Natural
forall a. a -> StrictMaybe a -> a
fromSMaybe (PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_nOpt PParams era
pp) (PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
_nOpt PParamsUpdate era
ppup),
      _a0 :: HKD Identity NonNegativeInterval
_a0 = NonNegativeInterval
-> StrictMaybe NonNegativeInterval -> NonNegativeInterval
forall a. a -> StrictMaybe a -> a
fromSMaybe (PParams era -> HKD Identity NonNegativeInterval
forall (f :: * -> *) era.
PParams' f era -> HKD f NonNegativeInterval
_a0 PParams era
pp) (PParamsUpdate era -> HKD StrictMaybe NonNegativeInterval
forall (f :: * -> *) era.
PParams' f era -> HKD f NonNegativeInterval
_a0 PParamsUpdate era
ppup),
      _rho :: HKD Identity UnitInterval
_rho = UnitInterval -> StrictMaybe UnitInterval -> UnitInterval
forall a. a -> StrictMaybe a -> a
fromSMaybe (PParams era -> HKD Identity UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
_rho PParams era
pp) (PParamsUpdate era -> HKD StrictMaybe UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
_rho PParamsUpdate era
ppup),
      _tau :: HKD Identity UnitInterval
_tau = UnitInterval -> StrictMaybe UnitInterval -> UnitInterval
forall a. a -> StrictMaybe a -> a
fromSMaybe (PParams era -> HKD Identity UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
_tau PParams era
pp) (PParamsUpdate era -> HKD StrictMaybe UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
_tau PParamsUpdate era
ppup),
      _d :: HKD Identity UnitInterval
_d = UnitInterval -> StrictMaybe UnitInterval -> UnitInterval
forall a. a -> StrictMaybe a -> a
fromSMaybe (PParams era -> HKD Identity UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
_d PParams era
pp) (PParamsUpdate era -> HKD StrictMaybe UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
_d PParamsUpdate era
ppup),
      _extraEntropy :: HKD Identity Nonce
_extraEntropy = Nonce -> StrictMaybe Nonce -> Nonce
forall a. a -> StrictMaybe a -> a
fromSMaybe (PParams era -> HKD Identity Nonce
forall (f :: * -> *) era. PParams' f era -> HKD f Nonce
_extraEntropy PParams era
pp) (PParamsUpdate era -> HKD StrictMaybe Nonce
forall (f :: * -> *) era. PParams' f era -> HKD f Nonce
_extraEntropy PParamsUpdate era
ppup),
      _protocolVersion :: HKD Identity ProtVer
_protocolVersion = ProtVer -> StrictMaybe ProtVer -> ProtVer
forall a. a -> StrictMaybe a -> a
fromSMaybe (PParams era -> HKD Identity ProtVer
forall (f :: * -> *) era. PParams' f era -> HKD f ProtVer
_protocolVersion PParams era
pp) (PParamsUpdate era -> HKD StrictMaybe ProtVer
forall (f :: * -> *) era. PParams' f era -> HKD f ProtVer
_protocolVersion PParamsUpdate era
ppup),
      _minUTxOValue :: HKD Identity Coin
_minUTxOValue = Coin -> StrictMaybe Coin -> Coin
forall a. a -> StrictMaybe a -> a
fromSMaybe (PParams era -> HKD Identity Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_minUTxOValue PParams era
pp) (PParamsUpdate era -> HKD StrictMaybe Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_minUTxOValue PParamsUpdate era
ppup),
      _minPoolCost :: HKD Identity Coin
_minPoolCost = Coin -> StrictMaybe Coin -> Coin
forall a. a -> StrictMaybe a -> a
fromSMaybe (PParams era -> HKD Identity Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_minPoolCost PParams era
pp) (PParamsUpdate era -> HKD StrictMaybe Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
_minPoolCost PParamsUpdate era
ppup)
    }