{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}

-- | The various Bcc protocol parameters, including:
--
-- * the current values of updateable 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 Bcc.Api.ProtocolParameters (
    -- * The updateable protocol paramaters
    ProtocolParameters(..),
    checkProtocolParameters,
    ProtocolParametersError(..),
    EpochNo,

    -- * Updates to the protocol paramaters
    ProtocolParametersUpdate(..),

    -- * OptimumNonce
    OptimumNonce,
    makeOptimumNonce,

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

    -- * Update proposals to change the protocol paramaters
    UpdateProposal(..),
    makeSophieUpdateProposal,

    -- * Internal conversion functions
    toLedgerUpdate,
    fromLedgerUpdate,
    toLedgerProposedPPUpdates,
    fromLedgerProposedPPUpdates,
    toLedgerPParams,
    fromLedgerPParams,
    fromSophiePParams,
    toAurumPrices,
    fromAurumPrices,
    toAurumScriptLanguage,
    fromAurumScriptLanguage,
    toAurumCostModel,
    fromAurumCostModel,

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

import           Prelude

import           Control.Monad
import           Data.Aeson (FromJSON (..), ToJSON (..), object, withObject, (.!=), (.:), (.:?),
                   (.=))
import           Data.Bifunctor (bimap)
import           Data.ByteString (ByteString)
import           Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import           Data.Maybe (fromMaybe, isJust)
import           Data.String (IsString)
import           Data.Text (Text)
import           GHC.Generics
import           Numeric.Natural

import           Bcc.Api.Json
import qualified Bcc.Binary as CBOR
import qualified Bcc.Crypto.Hash.Class as Crypto
import           Bcc.Slotting.Slot (EpochNo)

import           Bcc.Ledger.BaseTypes (maybeToStrictMaybe, strictMaybeToMaybe)
import qualified Bcc.Ledger.BaseTypes as Ledger
import qualified Bcc.Ledger.Core as Ledger
import           Bcc.Ledger.Crypto (StandardCrypto)
import qualified Bcc.Ledger.Era as Ledger
import qualified Bcc.Ledger.Keys as Ledger
import qualified Sophie.Spec.Ledger.PParams as Ledger (ProposedPPUpdates (..), ProtVer (..),
                   Update (..))
-- Some of the things from Sophie.Spec.Ledger.PParams are generic across all
-- eras, and some are specific to the Sophie era (and other pre-Aurum eras).
-- So we import in twice under different names.
import qualified Sophie.Spec.Ledger.PParams as Sophie (PParams, PParams' (..), PParamsUpdate)

import qualified Bcc.Ledger.Aurum.Language as Aurum
import qualified Bcc.Ledger.Aurum.PParams as Aurum
import qualified Bcc.Ledger.Aurum.Scripts as Aurum

import           Bcc.Api.Address
import           Bcc.Api.Eras
import           Bcc.Api.Error
import           Bcc.Api.HasTypeProxy
import           Bcc.Api.Hash
import           Bcc.Api.KeysCole
import           Bcc.Api.KeysSophie
import           Bcc.Api.Script
import           Bcc.Api.SerialiseCBOR
import           Bcc.Api.SerialiseRaw
import           Bcc.Api.SerialiseTextEnvelope
import           Bcc.Api.SerialiseUsing
import           Bcc.Api.StakePoolMetadata
import           Bcc.Api.TxMetadata
import           Bcc.Api.Value


-- | The values of the set of /updateable/ protocol paramaters. At any
-- particular point on the chain there is a current set of paramaters in use.
--
-- These paramaters 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 paramaters fixed in the Genesis file. See 'GenesisParameters'.
--
data ProtocolParameters =
     ProtocolParameters {

       -- | Protocol version, major and minor. Updating the major version is
       -- used to trigger hard forks.
       --
       ProtocolParameters -> (Natural, Natural)
protocolParamProtocolVersion :: (Natural, Natural),

       -- | The decentralization parameter. This is fraction of slots that
       -- belong to the BFT overlay schedule, rather than the Optimum schedule.
       -- So 1 means fully centralised, while 0 means fully decentralised.
       --
       -- This is the \"d\" parameter from the design document.
       --
       ProtocolParameters -> Rational
protocolParamDecentralization :: Rational,

       -- | Extra entropy for the Optimum 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 -> Maybe OptimumNonce
protocolParamExtraOptimumEntropy :: Maybe OptimumNonce,

       -- | 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
protocolParamMaxBlockHeaderSize :: Natural,

       -- | The maximum permitted size of the block body (that is, the block
       -- payload, without the block header).
       --
       -- This should be picked with the Optimum network delta security parameter
       -- in mind. Making this too large can severely weaken the Optimum
       -- 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
protocolParamMaxBlockBodySize :: 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 -> Natural
protocolParamMaxTxSize :: Natural,

       -- | The constant factor for the minimum fee calculation.
       --
       ProtocolParameters -> Natural
protocolParamTxFeeFixed :: Natural,

       -- | The linear factor for the minimum fee calculation.
       --
       ProtocolParameters -> Natural
protocolParamTxFeePerByte :: Natural,

       -- | The minimum permitted value for new UTxO entries, ie for
       -- transaction outputs.
       --
       ProtocolParameters -> Maybe Entropic
protocolParamMinUTxOValue :: Maybe Entropic,

       -- | The deposit required to register a stake address.
       --
       ProtocolParameters -> Entropic
protocolParamStakeAddressDeposit :: Entropic,

       -- | The deposit required to register a stake pool.
       --
       ProtocolParameters -> Entropic
protocolParamStakePoolDeposit :: Entropic,

       -- | The minimum value that stake pools are permitted to declare for
       -- their cost parameter.
       --
       ProtocolParameters -> Entropic
protocolParamMinPoolCost :: Entropic,

       -- | The maximum number of epochs into the future that stake pools
       -- are permitted to schedule a retirement.
       --
       ProtocolParameters -> EpochNo
protocolParamPoolRetireMaxEpoch :: EpochNo,

       -- | The equilibrium target number of stake pools.
       --
       -- This is the \"k\" incentives parameter from the design document.
       --
       ProtocolParameters -> Natural
protocolParamStakePoolTargetNum :: Natural,

       -- | The influence of the pledge in stake pool rewards.
       --
       -- This is the \"a_0\" incentives parameter from the design document.
       --
       ProtocolParameters -> Rational
protocolParamPoolPledgeInfluence :: 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
protocolParamMonetaryExpansion :: 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 -> Rational
protocolParamTreasuryCut :: Rational,

       -- | Cost in bcc per word of UTxO storage.
       --
       -- /Introduced in Aurum/
       ProtocolParameters -> Maybe Entropic
protocolParamUTxOCostPerWord :: Maybe Entropic,

       -- | Cost models for script languages that use them.
       --
       -- /Introduced in Aurum/
       ProtocolParameters -> Map AnyZerepochScriptVersion CostModel
protocolParamCostModels :: Map AnyZerepochScriptVersion CostModel,

       -- | Price of execution units for script languages that use them.
       --
       -- /Introduced in Aurum/
       ProtocolParameters -> Maybe ExecutionUnitPrices
protocolParamPrices :: Maybe ExecutionUnitPrices,

       -- | Max total script execution resources units allowed per tx
       --
       -- /Introduced in Aurum/
       ProtocolParameters -> Maybe ExecutionUnits
protocolParamMaxTxExUnits :: Maybe ExecutionUnits,

       -- | Max total script execution resources units allowed per block
       --
       -- /Introduced in Aurum/
       ProtocolParameters -> Maybe ExecutionUnits
protocolParamMaxBlockExUnits :: Maybe ExecutionUnits,

       -- | Max size of a Value in a tx ouput.
       --
       -- /Introduced in Aurum/
       ProtocolParameters -> Maybe Natural
protocolParamMaxValueSize :: Maybe Natural,

       -- | The percentage of the script contribution to the txfee that must be
       -- provided as collateral inputs when including Zerepoch scripts.
       --
       -- /Introduced in Aurum/
       ProtocolParameters -> Maybe Natural
protocolParamCollateralPercent :: Maybe Natural,

       -- | The maximum number of collateral inputs allowed in a transaction.
       --
       -- /Introduced in Aurum/
       ProtocolParameters -> Maybe Natural
protocolParamMaxCollateralInputs :: Maybe Natural
    }
  deriving (ProtocolParameters -> ProtocolParameters -> Bool
(ProtocolParameters -> ProtocolParameters -> Bool)
-> (ProtocolParameters -> ProtocolParameters -> Bool)
-> Eq ProtocolParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProtocolParameters -> ProtocolParameters -> Bool
$c/= :: ProtocolParameters -> ProtocolParameters -> Bool
== :: ProtocolParameters -> ProtocolParameters -> Bool
$c== :: 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
$cto :: forall x. Rep ProtocolParameters x -> ProtocolParameters
$cfrom :: forall x. ProtocolParameters -> Rep ProtocolParameters x
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
showList :: [ProtocolParameters] -> ShowS
$cshowList :: [ProtocolParameters] -> ShowS
show :: ProtocolParameters -> String
$cshow :: ProtocolParameters -> String
showsPrec :: Int -> ProtocolParameters -> ShowS
$cshowsPrec :: Int -> ProtocolParameters -> ShowS
Show)

instance FromJSON ProtocolParameters where
  parseJSON :: Value -> Parser ProtocolParameters
parseJSON =
    String
-> (Object -> Parser ProtocolParameters)
-> Value
-> Parser ProtocolParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ProtocolParameters" ((Object -> Parser ProtocolParameters)
 -> Value -> Parser ProtocolParameters)
-> (Object -> Parser ProtocolParameters)
-> Value
-> Parser ProtocolParameters
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
      Object
v <- Object
o Object -> Text -> Parser Object
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"protocolVersion"
      (Natural, Natural)
-> Rational
-> Maybe OptimumNonce
-> Natural
-> Natural
-> Natural
-> Natural
-> Natural
-> Maybe Entropic
-> Entropic
-> Entropic
-> Entropic
-> EpochNo
-> Natural
-> Rational
-> Rational
-> Rational
-> Maybe Entropic
-> Map AnyZerepochScriptVersion CostModel
-> Maybe ExecutionUnitPrices
-> Maybe ExecutionUnits
-> Maybe ExecutionUnits
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> ProtocolParameters
ProtocolParameters
        ((Natural, Natural)
 -> Rational
 -> Maybe OptimumNonce
 -> Natural
 -> Natural
 -> Natural
 -> Natural
 -> Natural
 -> Maybe Entropic
 -> Entropic
 -> Entropic
 -> Entropic
 -> EpochNo
 -> Natural
 -> Rational
 -> Rational
 -> Rational
 -> Maybe Entropic
 -> Map AnyZerepochScriptVersion CostModel
 -> Maybe ExecutionUnitPrices
 -> Maybe ExecutionUnits
 -> Maybe ExecutionUnits
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> ProtocolParameters)
-> Parser (Natural, Natural)
-> Parser
     (Rational
      -> Maybe OptimumNonce
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> Maybe Entropic
      -> Entropic
      -> Entropic
      -> Entropic
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) (Natural -> Natural -> (Natural, Natural))
-> Parser Natural -> Parser (Natural -> (Natural, Natural))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"major" Parser (Natural -> (Natural, Natural))
-> Parser Natural -> Parser (Natural, Natural)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"sentry")
        Parser
  (Rational
   -> Maybe OptimumNonce
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> Maybe Entropic
   -> Entropic
   -> Entropic
   -> Entropic
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser Rational
-> Parser
     (Maybe OptimumNonce
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> Maybe Entropic
      -> Entropic
      -> Entropic
      -> Entropic
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser Rational
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"decentralization"
        Parser
  (Maybe OptimumNonce
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> Maybe Entropic
   -> Entropic
   -> Entropic
   -> Entropic
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser (Maybe OptimumNonce)
-> Parser
     (Natural
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> Maybe Entropic
      -> Entropic
      -> Entropic
      -> Entropic
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser (Maybe OptimumNonce)
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"extraOptimumEntropy"
        Parser
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> Maybe Entropic
   -> Entropic
   -> Entropic
   -> Entropic
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser Natural
-> Parser
     (Natural
      -> Natural
      -> Natural
      -> Natural
      -> Maybe Entropic
      -> Entropic
      -> Entropic
      -> Entropic
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"maxBlockHeaderSize"
        Parser
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> Maybe Entropic
   -> Entropic
   -> Entropic
   -> Entropic
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser Natural
-> Parser
     (Natural
      -> Natural
      -> Natural
      -> Maybe Entropic
      -> Entropic
      -> Entropic
      -> Entropic
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"maxBlockBodySize"
        Parser
  (Natural
   -> Natural
   -> Natural
   -> Maybe Entropic
   -> Entropic
   -> Entropic
   -> Entropic
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser Natural
-> Parser
     (Natural
      -> Natural
      -> Maybe Entropic
      -> Entropic
      -> Entropic
      -> Entropic
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"maxTxSize"
        Parser
  (Natural
   -> Natural
   -> Maybe Entropic
   -> Entropic
   -> Entropic
   -> Entropic
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser Natural
-> Parser
     (Natural
      -> Maybe Entropic
      -> Entropic
      -> Entropic
      -> Entropic
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"txFeeFixed"
        Parser
  (Natural
   -> Maybe Entropic
   -> Entropic
   -> Entropic
   -> Entropic
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser Natural
-> Parser
     (Maybe Entropic
      -> Entropic
      -> Entropic
      -> Entropic
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"txFeePerByte"
        Parser
  (Maybe Entropic
   -> Entropic
   -> Entropic
   -> Entropic
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser (Maybe Entropic)
-> Parser
     (Entropic
      -> Entropic
      -> Entropic
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser (Maybe Entropic)
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"minUTxOValue"
        Parser
  (Entropic
   -> Entropic
   -> Entropic
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser Entropic
-> Parser
     (Entropic
      -> Entropic
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser Entropic
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"stakeAddressDeposit"
        Parser
  (Entropic
   -> Entropic
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser Entropic
-> Parser
     (Entropic
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser Entropic
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"stakePoolDeposit"
        Parser
  (Entropic
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser Entropic
-> Parser
     (EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser Entropic
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"minPoolCost"
        Parser
  (EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser EpochNo
-> Parser
     (Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser EpochNo
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"poolRetireMaxEpoch"
        Parser
  (Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser Natural
-> Parser
     (Rational
      -> Rational
      -> Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"stakePoolTargetNum"
        Parser
  (Rational
   -> Rational
   -> Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser Rational
-> Parser
     (Rational
      -> Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser Rational
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"poolPledgeInfluence"
        Parser
  (Rational
   -> Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser Rational
-> Parser
     (Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser Rational
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"monetaryExpansion"
        Parser
  (Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser Rational
-> Parser
     (Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser Rational
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"treasuryCut"
        Parser
  (Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser (Maybe Entropic)
-> Parser
     (Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser (Maybe Entropic)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"utxoCostPerWord"
        Parser
  (Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser (Map AnyZerepochScriptVersion CostModel)
-> Parser
     (Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object
-> Text -> Parser (Maybe (Map AnyZerepochScriptVersion CostModel))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"costModels" Parser (Maybe (Map AnyZerepochScriptVersion CostModel))
-> Map AnyZerepochScriptVersion CostModel
-> Parser (Map AnyZerepochScriptVersion CostModel)
forall a. Parser (Maybe a) -> a -> Parser a
.!= Map AnyZerepochScriptVersion CostModel
forall k a. Map k a
Map.empty
        Parser
  (Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser (Maybe ExecutionUnitPrices)
-> Parser
     (Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser (Maybe ExecutionUnitPrices)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"executionUnitPrices"
        Parser
  (Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser (Maybe ExecutionUnits)
-> Parser
     (Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser (Maybe ExecutionUnits)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"maxTxExecutionUnits"
        Parser
  (Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParameters)
-> Parser (Maybe ExecutionUnits)
-> Parser
     (Maybe Natural
      -> Maybe Natural -> Maybe Natural -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser (Maybe ExecutionUnits)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"maxBlockExecutionUnits"
        Parser
  (Maybe Natural
   -> Maybe Natural -> Maybe Natural -> ProtocolParameters)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> Maybe Natural -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"maxValueSize"
        Parser (Maybe Natural -> Maybe Natural -> ProtocolParameters)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"collateralPercentage"
        Parser (Maybe Natural -> ProtocolParameters)
-> Parser (Maybe Natural) -> Parser ProtocolParameters
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"maxCollateralInputs"

instance ToJSON ProtocolParameters where
  toJSON :: ProtocolParameters -> Value
toJSON ProtocolParameters{Natural
Maybe Natural
Maybe ExecutionUnits
Maybe Entropic
Maybe ExecutionUnitPrices
Maybe OptimumNonce
Rational
(Natural, Natural)
Map AnyZerepochScriptVersion CostModel
EpochNo
Entropic
protocolParamMaxCollateralInputs :: Maybe Natural
protocolParamCollateralPercent :: Maybe Natural
protocolParamMaxValueSize :: Maybe Natural
protocolParamMaxBlockExUnits :: Maybe ExecutionUnits
protocolParamMaxTxExUnits :: Maybe ExecutionUnits
protocolParamPrices :: Maybe ExecutionUnitPrices
protocolParamCostModels :: Map AnyZerepochScriptVersion CostModel
protocolParamUTxOCostPerWord :: Maybe Entropic
protocolParamTreasuryCut :: Rational
protocolParamMonetaryExpansion :: Rational
protocolParamPoolPledgeInfluence :: Rational
protocolParamStakePoolTargetNum :: Natural
protocolParamPoolRetireMaxEpoch :: EpochNo
protocolParamMinPoolCost :: Entropic
protocolParamStakePoolDeposit :: Entropic
protocolParamStakeAddressDeposit :: Entropic
protocolParamMinUTxOValue :: Maybe Entropic
protocolParamTxFeePerByte :: Natural
protocolParamTxFeeFixed :: Natural
protocolParamMaxTxSize :: Natural
protocolParamMaxBlockBodySize :: Natural
protocolParamMaxBlockHeaderSize :: Natural
protocolParamExtraOptimumEntropy :: Maybe OptimumNonce
protocolParamDecentralization :: Rational
protocolParamProtocolVersion :: (Natural, Natural)
protocolParamMaxCollateralInputs :: ProtocolParameters -> Maybe Natural
protocolParamCollateralPercent :: ProtocolParameters -> Maybe Natural
protocolParamMaxValueSize :: ProtocolParameters -> Maybe Natural
protocolParamMaxBlockExUnits :: ProtocolParameters -> Maybe ExecutionUnits
protocolParamMaxTxExUnits :: ProtocolParameters -> Maybe ExecutionUnits
protocolParamPrices :: ProtocolParameters -> Maybe ExecutionUnitPrices
protocolParamCostModels :: ProtocolParameters -> Map AnyZerepochScriptVersion CostModel
protocolParamUTxOCostPerWord :: ProtocolParameters -> Maybe Entropic
protocolParamTreasuryCut :: ProtocolParameters -> Rational
protocolParamMonetaryExpansion :: ProtocolParameters -> Rational
protocolParamPoolPledgeInfluence :: ProtocolParameters -> Rational
protocolParamStakePoolTargetNum :: ProtocolParameters -> Natural
protocolParamPoolRetireMaxEpoch :: ProtocolParameters -> EpochNo
protocolParamMinPoolCost :: ProtocolParameters -> Entropic
protocolParamStakePoolDeposit :: ProtocolParameters -> Entropic
protocolParamStakeAddressDeposit :: ProtocolParameters -> Entropic
protocolParamMinUTxOValue :: ProtocolParameters -> Maybe Entropic
protocolParamTxFeePerByte :: ProtocolParameters -> Natural
protocolParamTxFeeFixed :: ProtocolParameters -> Natural
protocolParamMaxTxSize :: ProtocolParameters -> Natural
protocolParamMaxBlockBodySize :: ProtocolParameters -> Natural
protocolParamMaxBlockHeaderSize :: ProtocolParameters -> Natural
protocolParamExtraOptimumEntropy :: ProtocolParameters -> Maybe OptimumNonce
protocolParamDecentralization :: ProtocolParameters -> Rational
protocolParamProtocolVersion :: ProtocolParameters -> (Natural, Natural)
..} =
    [Pair] -> Value
object
      [ Text
"extraOptimumEntropy"   Text -> Maybe OptimumNonce -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Maybe OptimumNonce
protocolParamExtraOptimumEntropy
      , Text
"stakePoolTargetNum"  Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
protocolParamStakePoolTargetNum
      , Text
"minUTxOValue"        Text -> Maybe Entropic -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Maybe Entropic
protocolParamMinUTxOValue
      , Text
"poolRetireMaxEpoch"  Text -> EpochNo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochNo
protocolParamPoolRetireMaxEpoch
      , Text
"decentralization"    Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Rational -> Value
toRationalJSON Rational
protocolParamDecentralization
      , Text
"stakePoolDeposit"    Text -> Entropic -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Entropic
protocolParamStakePoolDeposit
      , Text
"maxBlockHeaderSize"  Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
protocolParamMaxBlockHeaderSize
      , Text
"maxBlockBodySize"    Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
protocolParamMaxBlockBodySize
      , Text
"maxTxSize"           Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
protocolParamMaxTxSize
      , Text
"treasuryCut"         Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Rational -> Value
toRationalJSON Rational
protocolParamTreasuryCut
      , Text
"minPoolCost"         Text -> Entropic -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Entropic
protocolParamMinPoolCost
      , Text
"monetaryExpansion"   Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Rational -> Value
toRationalJSON Rational
protocolParamMonetaryExpansion
      , Text
"stakeAddressDeposit" Text -> Entropic -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Entropic
protocolParamStakeAddressDeposit
      , Text
"poolPledgeInfluence" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Rational -> Value
toRationalJSON Rational
protocolParamPoolPledgeInfluence
      , Text
"protocolVersion"     Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= let (Natural
major, Natural
sentry) = (Natural, Natural)
protocolParamProtocolVersion
                                  in [Pair] -> Value
object [Text
"major" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
major, Text
"sentry" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
sentry]
      , Text
"txFeeFixed"          Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
protocolParamTxFeeFixed
      , Text
"txFeePerByte"        Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
protocolParamTxFeePerByte
      -- Aurum era:
      , Text
"utxoCostPerWord"        Text -> Maybe Entropic -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Maybe Entropic
protocolParamUTxOCostPerWord
      , Text
"costModels"             Text -> Map AnyZerepochScriptVersion CostModel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Map AnyZerepochScriptVersion CostModel
protocolParamCostModels
      , Text
"executionUnitPrices"    Text -> Maybe ExecutionUnitPrices -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Maybe ExecutionUnitPrices
protocolParamPrices
      , Text
"maxTxExecutionUnits"    Text -> Maybe ExecutionUnits -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Maybe ExecutionUnits
protocolParamMaxTxExUnits
      , Text
"maxBlockExecutionUnits" Text -> Maybe ExecutionUnits -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Maybe ExecutionUnits
protocolParamMaxBlockExUnits
      , Text
"maxValueSize"           Text -> Maybe Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Maybe Natural
protocolParamMaxValueSize
      , Text
"collateralPercentage"   Text -> Maybe Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Maybe Natural
protocolParamCollateralPercent
      , Text
"maxCollateralInputs"    Text -> Maybe Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Maybe Natural
protocolParamMaxCollateralInputs
      ]


-- ----------------------------------------------------------------------------
-- Updates to the protocol paramaters
--

-- | The representation of a change in the 'ProtocolParameters'.
--
data ProtocolParametersUpdate =
     ProtocolParametersUpdate {

       -- | Protocol version, major and current open Sentry. Updating the major version is
       -- used to trigger hard forks.
       --
       ProtocolParametersUpdate -> Maybe (Natural, Natural)
protocolUpdateProtocolVersion :: Maybe (Natural, Natural),

       -- | The decentralization parameter. This is fraction of slots that
       -- belong to the BFT overlay schedule, rather than the Optimum schedule.
       -- So 1 means fully centralised, while 0 means fully decentralised.
       --
       -- This is the \"d\" parameter from the design document.
       --
       ProtocolParametersUpdate -> Maybe Rational
protocolUpdateDecentralization :: Maybe Rational,

       -- | Extra entropy for the Optimum 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.
       --
       ProtocolParametersUpdate -> Maybe (Maybe OptimumNonce)
protocolUpdateExtraOptimumEntropy :: Maybe (Maybe OptimumNonce),

       -- | 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!
       --
       ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxBlockHeaderSize :: Maybe Natural,

       -- | The maximum permitted size of the block body (that is, the block
       -- payload, without the block header).
       --
       -- This should be picked with the Optimum network delta security parameter
       -- in mind. Making this too large can severely weaken the Optimum
       -- 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!
       --
       ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxBlockBodySize :: Maybe 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.
       --
       ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxTxSize :: Maybe Natural,

       -- | The constant factor for the minimum fee calculation.
       --
       ProtocolParametersUpdate -> Maybe Natural
protocolUpdateTxFeeFixed :: Maybe Natural,

       -- | The linear factor for the minimum fee calculation.
       --
       ProtocolParametersUpdate -> Maybe Natural
protocolUpdateTxFeePerByte :: Maybe Natural,

       -- | The minimum permitted value for new UTxO entries, ie for
       -- transaction outputs.
       --
       ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateMinUTxOValue :: Maybe Entropic,

       -- | The deposit required to register a stake address.
       --
       ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateStakeAddressDeposit :: Maybe Entropic,

       -- | The deposit required to register a stake pool.
       --
       ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateStakePoolDeposit :: Maybe Entropic,

       -- | The minimum value that stake pools are permitted to declare for
       -- their cost parameter.
       --
       ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateMinPoolCost :: Maybe Entropic,

       -- | The maximum number of epochs into the future that stake pools
       -- are permitted to schedule a retirement.
       --
       ProtocolParametersUpdate -> Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch :: Maybe EpochNo,

       -- | The equilibrium target number of stake pools.
       --
       -- This is the \"k\" incentives parameter from the design document.
       --
       ProtocolParametersUpdate -> Maybe Natural
protocolUpdateStakePoolTargetNum :: Maybe Natural,

       -- | The influence of the pledge in stake pool rewards.
       --
       -- This is the \"a_0\" incentives parameter from the design document.
       --
       ProtocolParametersUpdate -> Maybe Rational
protocolUpdatePoolPledgeInfluence :: Maybe 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.
       --
       ProtocolParametersUpdate -> Maybe Rational
protocolUpdateMonetaryExpansion :: Maybe Rational,

       -- | The fraction of the fee pot each epoch that goes to the treasury.
       --
       -- This is the \"tau\" incentives parameter from the design document.
       --
       ProtocolParametersUpdate -> Maybe Rational
protocolUpdateTreasuryCut :: Maybe Rational,

       -- Introduced in Aurum

       -- | Cost in bcc per word of UTxO storage.
       --
       -- /Introduced in Aurum/
       ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateUTxOCostPerWord :: Maybe Entropic,

       -- | Cost models for script languages that use them.
       --
       -- /Introduced in Aurum/
       ProtocolParametersUpdate -> Map AnyZerepochScriptVersion CostModel
protocolUpdateCostModels :: Map AnyZerepochScriptVersion CostModel,

       -- | Price of execution units for script languages that use them.
       --
       -- /Introduced in Aurum/
       ProtocolParametersUpdate -> Maybe ExecutionUnitPrices
protocolUpdatePrices :: Maybe ExecutionUnitPrices,

       -- | Max total script execution resources units allowed per tx
       --
       -- /Introduced in Aurum/
       ProtocolParametersUpdate -> Maybe ExecutionUnits
protocolUpdateMaxTxExUnits :: Maybe ExecutionUnits,

       -- | Max total script execution resources units allowed per block
       --
       -- /Introduced in Aurum/
       ProtocolParametersUpdate -> Maybe ExecutionUnits
protocolUpdateMaxBlockExUnits :: Maybe ExecutionUnits,

       -- | Max size of a 'Value' in a tx output.
       --
       -- /Introduced in Aurum/
       ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxValueSize :: Maybe Natural,

       -- | The percentage of the script contribution to the txfee that must be
       -- provided as collateral inputs when including Zerepoch scripts.
       --
       -- /Introduced in Aurum/
       ProtocolParametersUpdate -> Maybe Natural
protocolUpdateCollateralPercent :: Maybe Natural,

       -- | The maximum number of collateral inputs allowed in a transaction.
       --
       -- /Introduced in Aurum/
       ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxCollateralInputs :: Maybe Natural
    }
  deriving (ProtocolParametersUpdate -> ProtocolParametersUpdate -> Bool
(ProtocolParametersUpdate -> ProtocolParametersUpdate -> Bool)
-> (ProtocolParametersUpdate -> ProtocolParametersUpdate -> Bool)
-> Eq ProtocolParametersUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProtocolParametersUpdate -> ProtocolParametersUpdate -> Bool
$c/= :: ProtocolParametersUpdate -> ProtocolParametersUpdate -> Bool
== :: ProtocolParametersUpdate -> ProtocolParametersUpdate -> Bool
$c== :: ProtocolParametersUpdate -> ProtocolParametersUpdate -> Bool
Eq, Int -> ProtocolParametersUpdate -> ShowS
[ProtocolParametersUpdate] -> ShowS
ProtocolParametersUpdate -> String
(Int -> ProtocolParametersUpdate -> ShowS)
-> (ProtocolParametersUpdate -> String)
-> ([ProtocolParametersUpdate] -> ShowS)
-> Show ProtocolParametersUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProtocolParametersUpdate] -> ShowS
$cshowList :: [ProtocolParametersUpdate] -> ShowS
show :: ProtocolParametersUpdate -> String
$cshow :: ProtocolParametersUpdate -> String
showsPrec :: Int -> ProtocolParametersUpdate -> ShowS
$cshowsPrec :: Int -> ProtocolParametersUpdate -> ShowS
Show)

instance Semigroup ProtocolParametersUpdate where
    ProtocolParametersUpdate
ppu1 <> :: ProtocolParametersUpdate
-> ProtocolParametersUpdate -> ProtocolParametersUpdate
<> ProtocolParametersUpdate
ppu2 =
      ProtocolParametersUpdate :: Maybe (Natural, Natural)
-> Maybe Rational
-> Maybe (Maybe OptimumNonce)
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Entropic
-> Maybe Entropic
-> Maybe Entropic
-> Maybe Entropic
-> Maybe EpochNo
-> Maybe Natural
-> Maybe Rational
-> Maybe Rational
-> Maybe Rational
-> Maybe Entropic
-> Map AnyZerepochScriptVersion CostModel
-> Maybe ExecutionUnitPrices
-> Maybe ExecutionUnits
-> Maybe ExecutionUnits
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> ProtocolParametersUpdate
ProtocolParametersUpdate {
        protocolUpdateProtocolVersion :: Maybe (Natural, Natural)
protocolUpdateProtocolVersion     = (ProtocolParametersUpdate -> Maybe (Natural, Natural))
-> Maybe (Natural, Natural)
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe (Natural, Natural)
protocolUpdateProtocolVersion
      , protocolUpdateDecentralization :: Maybe Rational
protocolUpdateDecentralization    = (ProtocolParametersUpdate -> Maybe Rational) -> Maybe Rational
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Rational
protocolUpdateDecentralization
      , protocolUpdateExtraOptimumEntropy :: Maybe (Maybe OptimumNonce)
protocolUpdateExtraOptimumEntropy   = (ProtocolParametersUpdate -> Maybe (Maybe OptimumNonce))
-> Maybe (Maybe OptimumNonce)
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe (Maybe OptimumNonce)
protocolUpdateExtraOptimumEntropy
      , protocolUpdateMaxBlockHeaderSize :: Maybe Natural
protocolUpdateMaxBlockHeaderSize  = (ProtocolParametersUpdate -> Maybe Natural) -> Maybe Natural
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxBlockHeaderSize
      , protocolUpdateMaxBlockBodySize :: Maybe Natural
protocolUpdateMaxBlockBodySize    = (ProtocolParametersUpdate -> Maybe Natural) -> Maybe Natural
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxBlockBodySize
      , protocolUpdateMaxTxSize :: Maybe Natural
protocolUpdateMaxTxSize           = (ProtocolParametersUpdate -> Maybe Natural) -> Maybe Natural
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxTxSize
      , protocolUpdateTxFeeFixed :: Maybe Natural
protocolUpdateTxFeeFixed          = (ProtocolParametersUpdate -> Maybe Natural) -> Maybe Natural
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Natural
protocolUpdateTxFeeFixed
      , protocolUpdateTxFeePerByte :: Maybe Natural
protocolUpdateTxFeePerByte        = (ProtocolParametersUpdate -> Maybe Natural) -> Maybe Natural
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Natural
protocolUpdateTxFeePerByte
      , protocolUpdateMinUTxOValue :: Maybe Entropic
protocolUpdateMinUTxOValue        = (ProtocolParametersUpdate -> Maybe Entropic) -> Maybe Entropic
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateMinUTxOValue
      , protocolUpdateStakeAddressDeposit :: Maybe Entropic
protocolUpdateStakeAddressDeposit = (ProtocolParametersUpdate -> Maybe Entropic) -> Maybe Entropic
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateStakeAddressDeposit
      , protocolUpdateStakePoolDeposit :: Maybe Entropic
protocolUpdateStakePoolDeposit    = (ProtocolParametersUpdate -> Maybe Entropic) -> Maybe Entropic
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateStakePoolDeposit
      , protocolUpdateMinPoolCost :: Maybe Entropic
protocolUpdateMinPoolCost         = (ProtocolParametersUpdate -> Maybe Entropic) -> Maybe Entropic
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateMinPoolCost
      , protocolUpdatePoolRetireMaxEpoch :: Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch  = (ProtocolParametersUpdate -> Maybe EpochNo) -> Maybe EpochNo
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch
      , protocolUpdateStakePoolTargetNum :: Maybe Natural
protocolUpdateStakePoolTargetNum  = (ProtocolParametersUpdate -> Maybe Natural) -> Maybe Natural
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Natural
protocolUpdateStakePoolTargetNum
      , protocolUpdatePoolPledgeInfluence :: Maybe Rational
protocolUpdatePoolPledgeInfluence = (ProtocolParametersUpdate -> Maybe Rational) -> Maybe Rational
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Rational
protocolUpdatePoolPledgeInfluence
      , protocolUpdateMonetaryExpansion :: Maybe Rational
protocolUpdateMonetaryExpansion   = (ProtocolParametersUpdate -> Maybe Rational) -> Maybe Rational
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Rational
protocolUpdateMonetaryExpansion
      , protocolUpdateTreasuryCut :: Maybe Rational
protocolUpdateTreasuryCut         = (ProtocolParametersUpdate -> Maybe Rational) -> Maybe Rational
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Rational
protocolUpdateTreasuryCut
      -- Intoduced in Aurum below.
      , protocolUpdateUTxOCostPerWord :: Maybe Entropic
protocolUpdateUTxOCostPerWord     = (ProtocolParametersUpdate -> Maybe Entropic) -> Maybe Entropic
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateUTxOCostPerWord
      , protocolUpdateCostModels :: Map AnyZerepochScriptVersion CostModel
protocolUpdateCostModels          = (ProtocolParametersUpdate
 -> Map AnyZerepochScriptVersion CostModel)
-> Map AnyZerepochScriptVersion CostModel
forall k a.
Ord k =>
(ProtocolParametersUpdate -> Map k a) -> Map k a
mergeMap ProtocolParametersUpdate -> Map AnyZerepochScriptVersion CostModel
protocolUpdateCostModels
      , protocolUpdatePrices :: Maybe ExecutionUnitPrices
protocolUpdatePrices              = (ProtocolParametersUpdate -> Maybe ExecutionUnitPrices)
-> Maybe ExecutionUnitPrices
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe ExecutionUnitPrices
protocolUpdatePrices
      , protocolUpdateMaxTxExUnits :: Maybe ExecutionUnits
protocolUpdateMaxTxExUnits        = (ProtocolParametersUpdate -> Maybe ExecutionUnits)
-> Maybe ExecutionUnits
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe ExecutionUnits
protocolUpdateMaxTxExUnits
      , protocolUpdateMaxBlockExUnits :: Maybe ExecutionUnits
protocolUpdateMaxBlockExUnits     = (ProtocolParametersUpdate -> Maybe ExecutionUnits)
-> Maybe ExecutionUnits
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe ExecutionUnits
protocolUpdateMaxBlockExUnits
      , protocolUpdateMaxValueSize :: Maybe Natural
protocolUpdateMaxValueSize        = (ProtocolParametersUpdate -> Maybe Natural) -> Maybe Natural
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxValueSize
      , protocolUpdateCollateralPercent :: Maybe Natural
protocolUpdateCollateralPercent   = (ProtocolParametersUpdate -> Maybe Natural) -> Maybe Natural
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Natural
protocolUpdateCollateralPercent
      , protocolUpdateMaxCollateralInputs :: Maybe Natural
protocolUpdateMaxCollateralInputs = (ProtocolParametersUpdate -> Maybe Natural) -> Maybe Natural
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxCollateralInputs
      }
      where
        -- prefer the right hand side:
        merge :: (ProtocolParametersUpdate -> Maybe a) -> Maybe a
        merge :: (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe a
f = ProtocolParametersUpdate -> Maybe a
f ProtocolParametersUpdate
ppu2 Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus` ProtocolParametersUpdate -> Maybe a
f ProtocolParametersUpdate
ppu1

        -- prefer the right hand side:
        mergeMap :: Ord k => (ProtocolParametersUpdate -> Map k a) -> Map k a
        mergeMap :: (ProtocolParametersUpdate -> Map k a) -> Map k a
mergeMap ProtocolParametersUpdate -> Map k a
f = ProtocolParametersUpdate -> Map k a
f ProtocolParametersUpdate
ppu2 Map k a -> Map k a -> Map k a
forall k a. Ord k => Map k a -> Map k a -> Map k a
`Map.union` ProtocolParametersUpdate -> Map k a
f ProtocolParametersUpdate
ppu1

instance Monoid ProtocolParametersUpdate where
    mempty :: ProtocolParametersUpdate
mempty =
      ProtocolParametersUpdate :: Maybe (Natural, Natural)
-> Maybe Rational
-> Maybe (Maybe OptimumNonce)
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Entropic
-> Maybe Entropic
-> Maybe Entropic
-> Maybe Entropic
-> Maybe EpochNo
-> Maybe Natural
-> Maybe Rational
-> Maybe Rational
-> Maybe Rational
-> Maybe Entropic
-> Map AnyZerepochScriptVersion CostModel
-> Maybe ExecutionUnitPrices
-> Maybe ExecutionUnits
-> Maybe ExecutionUnits
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> ProtocolParametersUpdate
ProtocolParametersUpdate {
        protocolUpdateProtocolVersion :: Maybe (Natural, Natural)
protocolUpdateProtocolVersion     = Maybe (Natural, Natural)
forall a. Maybe a
Nothing
      , protocolUpdateDecentralization :: Maybe Rational
protocolUpdateDecentralization    = Maybe Rational
forall a. Maybe a
Nothing
      , protocolUpdateExtraOptimumEntropy :: Maybe (Maybe OptimumNonce)
protocolUpdateExtraOptimumEntropy   = Maybe (Maybe OptimumNonce)
forall a. Maybe a
Nothing
      , protocolUpdateMaxBlockHeaderSize :: Maybe Natural
protocolUpdateMaxBlockHeaderSize  = Maybe Natural
forall a. Maybe a
Nothing
      , protocolUpdateMaxBlockBodySize :: Maybe Natural
protocolUpdateMaxBlockBodySize    = Maybe Natural
forall a. Maybe a
Nothing
      , protocolUpdateMaxTxSize :: Maybe Natural
protocolUpdateMaxTxSize           = Maybe Natural
forall a. Maybe a
Nothing
      , protocolUpdateTxFeeFixed :: Maybe Natural
protocolUpdateTxFeeFixed          = Maybe Natural
forall a. Maybe a
Nothing
      , protocolUpdateTxFeePerByte :: Maybe Natural
protocolUpdateTxFeePerByte        = Maybe Natural
forall a. Maybe a
Nothing
      , protocolUpdateMinUTxOValue :: Maybe Entropic
protocolUpdateMinUTxOValue        = Maybe Entropic
forall a. Maybe a
Nothing
      , protocolUpdateStakeAddressDeposit :: Maybe Entropic
protocolUpdateStakeAddressDeposit = Maybe Entropic
forall a. Maybe a
Nothing
      , protocolUpdateStakePoolDeposit :: Maybe Entropic
protocolUpdateStakePoolDeposit    = Maybe Entropic
forall a. Maybe a
Nothing
      , protocolUpdateMinPoolCost :: Maybe Entropic
protocolUpdateMinPoolCost         = Maybe Entropic
forall a. Maybe a
Nothing
      , protocolUpdatePoolRetireMaxEpoch :: Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch  = Maybe EpochNo
forall a. Maybe a
Nothing
      , protocolUpdateStakePoolTargetNum :: Maybe Natural
protocolUpdateStakePoolTargetNum  = Maybe Natural
forall a. Maybe a
Nothing
      , protocolUpdatePoolPledgeInfluence :: Maybe Rational
protocolUpdatePoolPledgeInfluence = Maybe Rational
forall a. Maybe a
Nothing
      , protocolUpdateMonetaryExpansion :: Maybe Rational
protocolUpdateMonetaryExpansion   = Maybe Rational
forall a. Maybe a
Nothing
      , protocolUpdateTreasuryCut :: Maybe Rational
protocolUpdateTreasuryCut         = Maybe Rational
forall a. Maybe a
Nothing
      , protocolUpdateUTxOCostPerWord :: Maybe Entropic
protocolUpdateUTxOCostPerWord     = Maybe Entropic
forall a. Maybe a
Nothing
      , protocolUpdateCostModels :: Map AnyZerepochScriptVersion CostModel
protocolUpdateCostModels          = Map AnyZerepochScriptVersion CostModel
forall a. Monoid a => a
mempty
      , protocolUpdatePrices :: Maybe ExecutionUnitPrices
protocolUpdatePrices              = Maybe ExecutionUnitPrices
forall a. Maybe a
Nothing
      , protocolUpdateMaxTxExUnits :: Maybe ExecutionUnits
protocolUpdateMaxTxExUnits        = Maybe ExecutionUnits
forall a. Maybe a
Nothing
      , protocolUpdateMaxBlockExUnits :: Maybe ExecutionUnits
protocolUpdateMaxBlockExUnits     = Maybe ExecutionUnits
forall a. Maybe a
Nothing
      , protocolUpdateMaxValueSize :: Maybe Natural
protocolUpdateMaxValueSize        = Maybe Natural
forall a. Maybe a
Nothing
      , protocolUpdateCollateralPercent :: Maybe Natural
protocolUpdateCollateralPercent   = Maybe Natural
forall a. Maybe a
Nothing
      , protocolUpdateMaxCollateralInputs :: Maybe Natural
protocolUpdateMaxCollateralInputs = Maybe Natural
forall a. Maybe a
Nothing
      }

instance ToCBOR ProtocolParametersUpdate where
    toCBOR :: ProtocolParametersUpdate -> Encoding
toCBOR ProtocolParametersUpdate{Maybe Natural
Maybe (Maybe OptimumNonce)
Maybe Rational
Maybe (Natural, Natural)
Maybe EpochNo
Maybe ExecutionUnits
Maybe Entropic
Maybe ExecutionUnitPrices
Map AnyZerepochScriptVersion CostModel
protocolUpdateMaxCollateralInputs :: Maybe Natural
protocolUpdateCollateralPercent :: Maybe Natural
protocolUpdateMaxValueSize :: Maybe Natural
protocolUpdateMaxBlockExUnits :: Maybe ExecutionUnits
protocolUpdateMaxTxExUnits :: Maybe ExecutionUnits
protocolUpdatePrices :: Maybe ExecutionUnitPrices
protocolUpdateCostModels :: Map AnyZerepochScriptVersion CostModel
protocolUpdateUTxOCostPerWord :: Maybe Entropic
protocolUpdateTreasuryCut :: Maybe Rational
protocolUpdateMonetaryExpansion :: Maybe Rational
protocolUpdatePoolPledgeInfluence :: Maybe Rational
protocolUpdateStakePoolTargetNum :: Maybe Natural
protocolUpdatePoolRetireMaxEpoch :: Maybe EpochNo
protocolUpdateMinPoolCost :: Maybe Entropic
protocolUpdateStakePoolDeposit :: Maybe Entropic
protocolUpdateStakeAddressDeposit :: Maybe Entropic
protocolUpdateMinUTxOValue :: Maybe Entropic
protocolUpdateTxFeePerByte :: Maybe Natural
protocolUpdateTxFeeFixed :: Maybe Natural
protocolUpdateMaxTxSize :: Maybe Natural
protocolUpdateMaxBlockBodySize :: Maybe Natural
protocolUpdateMaxBlockHeaderSize :: Maybe Natural
protocolUpdateExtraOptimumEntropy :: Maybe (Maybe OptimumNonce)
protocolUpdateDecentralization :: Maybe Rational
protocolUpdateProtocolVersion :: Maybe (Natural, Natural)
protocolUpdateMaxCollateralInputs :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateCollateralPercent :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxValueSize :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxBlockExUnits :: ProtocolParametersUpdate -> Maybe ExecutionUnits
protocolUpdateMaxTxExUnits :: ProtocolParametersUpdate -> Maybe ExecutionUnits
protocolUpdatePrices :: ProtocolParametersUpdate -> Maybe ExecutionUnitPrices
protocolUpdateCostModels :: ProtocolParametersUpdate -> Map AnyZerepochScriptVersion CostModel
protocolUpdateUTxOCostPerWord :: ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateTreasuryCut :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdateMonetaryExpansion :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdatePoolPledgeInfluence :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdateStakePoolTargetNum :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdatePoolRetireMaxEpoch :: ProtocolParametersUpdate -> Maybe EpochNo
protocolUpdateMinPoolCost :: ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateStakePoolDeposit :: ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateStakeAddressDeposit :: ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateMinUTxOValue :: ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateTxFeePerByte :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateTxFeeFixed :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxTxSize :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxBlockBodySize :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxBlockHeaderSize :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateExtraOptimumEntropy :: ProtocolParametersUpdate -> Maybe (Maybe OptimumNonce)
protocolUpdateDecentralization :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdateProtocolVersion :: ProtocolParametersUpdate -> Maybe (Natural, Natural)
..} =
        Word -> Encoding
CBOR.encodeListLen Word
25
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe (Natural, Natural) -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe (Natural, Natural)
protocolUpdateProtocolVersion
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Rational -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Rational
protocolUpdateDecentralization
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe (Maybe OptimumNonce) -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe (Maybe OptimumNonce)
protocolUpdateExtraOptimumEntropy
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Natural
protocolUpdateMaxBlockHeaderSize
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Natural
protocolUpdateMaxBlockBodySize
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Natural
protocolUpdateMaxTxSize
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Natural
protocolUpdateTxFeeFixed
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Natural
protocolUpdateTxFeePerByte
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Entropic -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Entropic
protocolUpdateMinUTxOValue
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Entropic -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Entropic
protocolUpdateStakeAddressDeposit
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Entropic -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Entropic
protocolUpdateStakePoolDeposit
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Entropic -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Entropic
protocolUpdateMinPoolCost
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe EpochNo -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Natural
protocolUpdateStakePoolTargetNum
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Rational -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Rational
protocolUpdatePoolPledgeInfluence
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Rational -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Rational
protocolUpdateMonetaryExpansion
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Rational -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Rational
protocolUpdateTreasuryCut
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Entropic -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Entropic
protocolUpdateUTxOCostPerWord
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Map AnyZerepochScriptVersion CostModel -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Map AnyZerepochScriptVersion CostModel
protocolUpdateCostModels
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe ExecutionUnitPrices -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe ExecutionUnitPrices
protocolUpdatePrices
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe ExecutionUnits -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe ExecutionUnits
protocolUpdateMaxTxExUnits
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe ExecutionUnits -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe ExecutionUnits
protocolUpdateMaxBlockExUnits
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Natural
protocolUpdateMaxValueSize
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Natural
protocolUpdateCollateralPercent
     Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Maybe Natural -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR Maybe Natural
protocolUpdateMaxCollateralInputs

instance FromCBOR ProtocolParametersUpdate where
    fromCBOR :: Decoder s ProtocolParametersUpdate
fromCBOR = do
      Text -> Int -> Decoder s ()
forall s. Text -> Int -> Decoder s ()
CBOR.enforceSize Text
"ProtocolParametersUpdate" Int
25
      Maybe (Natural, Natural)
-> Maybe Rational
-> Maybe (Maybe OptimumNonce)
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Entropic
-> Maybe Entropic
-> Maybe Entropic
-> Maybe Entropic
-> Maybe EpochNo
-> Maybe Natural
-> Maybe Rational
-> Maybe Rational
-> Maybe Rational
-> Maybe Entropic
-> Map AnyZerepochScriptVersion CostModel
-> Maybe ExecutionUnitPrices
-> Maybe ExecutionUnits
-> Maybe ExecutionUnits
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> ProtocolParametersUpdate
ProtocolParametersUpdate
        (Maybe (Natural, Natural)
 -> Maybe Rational
 -> Maybe (Maybe OptimumNonce)
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Entropic
 -> Maybe Entropic
 -> Maybe Entropic
 -> Maybe Entropic
 -> Maybe EpochNo
 -> Maybe Natural
 -> Maybe Rational
 -> Maybe Rational
 -> Maybe Rational
 -> Maybe Entropic
 -> Map AnyZerepochScriptVersion CostModel
 -> Maybe ExecutionUnitPrices
 -> Maybe ExecutionUnits
 -> Maybe ExecutionUnits
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> ProtocolParametersUpdate)
-> Decoder s (Maybe (Natural, Natural))
-> Decoder
     s
     (Maybe Rational
      -> Maybe (Maybe OptimumNonce)
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s (Maybe (Natural, Natural))
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe Rational
   -> Maybe (Maybe OptimumNonce)
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe Rational)
-> Decoder
     s
     (Maybe (Maybe OptimumNonce)
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Rational)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe (Maybe OptimumNonce)
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe (Maybe OptimumNonce))
-> Decoder
     s
     (Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe (Maybe OptimumNonce))
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe Natural)
-> Decoder
     s
     (Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Natural)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe Natural)
-> Decoder
     s
     (Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Natural)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe Natural)
-> Decoder
     s
     (Maybe Natural
      -> Maybe Natural
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Natural)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe Natural
   -> Maybe Natural
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe Natural)
-> Decoder
     s
     (Maybe Natural
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Natural)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe Natural
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe Natural)
-> Decoder
     s
     (Maybe Entropic
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Natural)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe Entropic
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe Entropic)
-> Decoder
     s
     (Maybe Entropic
      -> Maybe Entropic
      -> Maybe Entropic
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Entropic)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe Entropic
   -> Maybe Entropic
   -> Maybe Entropic
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe Entropic)
-> Decoder
     s
     (Maybe Entropic
      -> Maybe Entropic
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Entropic)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe Entropic
   -> Maybe Entropic
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe Entropic)
-> Decoder
     s
     (Maybe Entropic
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Entropic)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe Entropic
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe Entropic)
-> Decoder
     s
     (Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Entropic)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe EpochNo)
-> Decoder
     s
     (Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe EpochNo)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe Natural)
-> Decoder
     s
     (Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Natural)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe Rational)
-> Decoder
     s
     (Maybe Rational
      -> Maybe Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Rational)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe Rational
   -> Maybe Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe Rational)
-> Decoder
     s
     (Maybe Rational
      -> Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Rational)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe Rational
   -> Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe Rational)
-> Decoder
     s
     (Maybe Entropic
      -> Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Rational)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe Entropic
   -> Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe Entropic)
-> Decoder
     s
     (Map AnyZerepochScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Entropic)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Map AnyZerepochScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Map AnyZerepochScriptVersion CostModel)
-> Decoder
     s
     (Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Map AnyZerepochScriptVersion CostModel)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe ExecutionUnitPrices)
-> Decoder
     s
     (Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe ExecutionUnitPrices)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe ExecutionUnits)
-> Decoder
     s
     (Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe ExecutionUnits)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> ProtocolParametersUpdate)
-> Decoder s (Maybe ExecutionUnits)
-> Decoder
     s
     (Maybe Natural
      -> Maybe Natural -> Maybe Natural -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe ExecutionUnits)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s
  (Maybe Natural
   -> Maybe Natural -> Maybe Natural -> ProtocolParametersUpdate)
-> Decoder s (Maybe Natural)
-> Decoder
     s (Maybe Natural -> Maybe Natural -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Natural)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder
  s (Maybe Natural -> Maybe Natural -> ProtocolParametersUpdate)
-> Decoder s (Maybe Natural)
-> Decoder s (Maybe Natural -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Natural)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder s (Maybe Natural -> ProtocolParametersUpdate)
-> Decoder s (Maybe Natural) -> Decoder s ProtocolParametersUpdate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s (Maybe Natural)
forall a s. FromCBOR a => Decoder s a
fromCBOR


-- ----------------------------------------------------------------------------
-- Optimum nonce
--

newtype OptimumNonce = OptimumNonce (Ledger.Hash StandardCrypto ByteString)
  deriving stock (OptimumNonce -> OptimumNonce -> Bool
(OptimumNonce -> OptimumNonce -> Bool)
-> (OptimumNonce -> OptimumNonce -> Bool) -> Eq OptimumNonce
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OptimumNonce -> OptimumNonce -> Bool
$c/= :: OptimumNonce -> OptimumNonce -> Bool
== :: OptimumNonce -> OptimumNonce -> Bool
$c== :: OptimumNonce -> OptimumNonce -> Bool
Eq, Eq OptimumNonce
Eq OptimumNonce
-> (OptimumNonce -> OptimumNonce -> Ordering)
-> (OptimumNonce -> OptimumNonce -> Bool)
-> (OptimumNonce -> OptimumNonce -> Bool)
-> (OptimumNonce -> OptimumNonce -> Bool)
-> (OptimumNonce -> OptimumNonce -> Bool)
-> (OptimumNonce -> OptimumNonce -> OptimumNonce)
-> (OptimumNonce -> OptimumNonce -> OptimumNonce)
-> Ord OptimumNonce
OptimumNonce -> OptimumNonce -> Bool
OptimumNonce -> OptimumNonce -> Ordering
OptimumNonce -> OptimumNonce -> OptimumNonce
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
min :: OptimumNonce -> OptimumNonce -> OptimumNonce
$cmin :: OptimumNonce -> OptimumNonce -> OptimumNonce
max :: OptimumNonce -> OptimumNonce -> OptimumNonce
$cmax :: OptimumNonce -> OptimumNonce -> OptimumNonce
>= :: OptimumNonce -> OptimumNonce -> Bool
$c>= :: OptimumNonce -> OptimumNonce -> Bool
> :: OptimumNonce -> OptimumNonce -> Bool
$c> :: OptimumNonce -> OptimumNonce -> Bool
<= :: OptimumNonce -> OptimumNonce -> Bool
$c<= :: OptimumNonce -> OptimumNonce -> Bool
< :: OptimumNonce -> OptimumNonce -> Bool
$c< :: OptimumNonce -> OptimumNonce -> Bool
compare :: OptimumNonce -> OptimumNonce -> Ordering
$ccompare :: OptimumNonce -> OptimumNonce -> Ordering
$cp1Ord :: Eq OptimumNonce
Ord, (forall x. OptimumNonce -> Rep OptimumNonce x)
-> (forall x. Rep OptimumNonce x -> OptimumNonce)
-> Generic OptimumNonce
forall x. Rep OptimumNonce x -> OptimumNonce
forall x. OptimumNonce -> Rep OptimumNonce x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OptimumNonce x -> OptimumNonce
$cfrom :: forall x. OptimumNonce -> Rep OptimumNonce x
Generic)
  deriving (Int -> OptimumNonce -> ShowS
[OptimumNonce] -> ShowS
OptimumNonce -> String
(Int -> OptimumNonce -> ShowS)
-> (OptimumNonce -> String)
-> ([OptimumNonce] -> ShowS)
-> Show OptimumNonce
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OptimumNonce] -> ShowS
$cshowList :: [OptimumNonce] -> ShowS
show :: OptimumNonce -> String
$cshow :: OptimumNonce -> String
showsPrec :: Int -> OptimumNonce -> ShowS
$cshowsPrec :: Int -> OptimumNonce -> ShowS
Show, String -> OptimumNonce
(String -> OptimumNonce) -> IsString OptimumNonce
forall a. (String -> a) -> IsString a
fromString :: String -> OptimumNonce
$cfromString :: String -> OptimumNonce
IsString)   via UsingRawBytesHex OptimumNonce
  deriving ([OptimumNonce] -> Value
[OptimumNonce] -> Encoding
OptimumNonce -> Value
OptimumNonce -> Encoding
(OptimumNonce -> Value)
-> (OptimumNonce -> Encoding)
-> ([OptimumNonce] -> Value)
-> ([OptimumNonce] -> Encoding)
-> ToJSON OptimumNonce
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [OptimumNonce] -> Encoding
$ctoEncodingList :: [OptimumNonce] -> Encoding
toJSONList :: [OptimumNonce] -> Value
$ctoJSONList :: [OptimumNonce] -> Value
toEncoding :: OptimumNonce -> Encoding
$ctoEncoding :: OptimumNonce -> Encoding
toJSON :: OptimumNonce -> Value
$ctoJSON :: OptimumNonce -> Value
ToJSON, Value -> Parser [OptimumNonce]
Value -> Parser OptimumNonce
(Value -> Parser OptimumNonce)
-> (Value -> Parser [OptimumNonce]) -> FromJSON OptimumNonce
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [OptimumNonce]
$cparseJSONList :: Value -> Parser [OptimumNonce]
parseJSON :: Value -> Parser OptimumNonce
$cparseJSON :: Value -> Parser OptimumNonce
FromJSON) via UsingRawBytesHex OptimumNonce
  deriving (Typeable OptimumNonce
Typeable OptimumNonce
-> (OptimumNonce -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy OptimumNonce -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy [OptimumNonce] -> Size)
-> ToCBOR OptimumNonce
OptimumNonce -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [OptimumNonce] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy OptimumNonce -> 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
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [OptimumNonce] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [OptimumNonce] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy OptimumNonce -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy OptimumNonce -> Size
toCBOR :: OptimumNonce -> Encoding
$ctoCBOR :: OptimumNonce -> Encoding
$cp1ToCBOR :: Typeable OptimumNonce
ToCBOR, Typeable OptimumNonce
Decoder s OptimumNonce
Typeable OptimumNonce
-> (forall s. Decoder s OptimumNonce)
-> (Proxy OptimumNonce -> Text)
-> FromCBOR OptimumNonce
Proxy OptimumNonce -> Text
forall s. Decoder s OptimumNonce
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy OptimumNonce -> Text
$clabel :: Proxy OptimumNonce -> Text
fromCBOR :: Decoder s OptimumNonce
$cfromCBOR :: forall s. Decoder s OptimumNonce
$cp1FromCBOR :: Typeable OptimumNonce
FromCBOR) via UsingRawBytes    OptimumNonce

instance HasTypeProxy OptimumNonce where
    data AsType OptimumNonce = AsOptimumNonce
    proxyToAsType :: Proxy OptimumNonce -> AsType OptimumNonce
proxyToAsType Proxy OptimumNonce
_ = AsType OptimumNonce
AsOptimumNonce

instance SerialiseAsRawBytes OptimumNonce where
    serialiseToRawBytes :: OptimumNonce -> ByteString
serialiseToRawBytes (OptimumNonce Hash StandardCrypto ByteString
h) =
      Hash Blake2b_256 ByteString -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash StandardCrypto ByteString
Hash Blake2b_256 ByteString
h

    deserialiseFromRawBytes :: AsType OptimumNonce -> ByteString -> Maybe OptimumNonce
deserialiseFromRawBytes AsType OptimumNonce
AsOptimumNonce ByteString
bs =
      Hash StandardCrypto ByteString -> OptimumNonce
Hash Blake2b_256 ByteString -> OptimumNonce
OptimumNonce (Hash Blake2b_256 ByteString -> OptimumNonce)
-> Maybe (Hash Blake2b_256 ByteString) -> Maybe OptimumNonce
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Hash Blake2b_256 ByteString)
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs


makeOptimumNonce :: ByteString -> OptimumNonce
makeOptimumNonce :: ByteString -> OptimumNonce
makeOptimumNonce = Hash StandardCrypto ByteString -> OptimumNonce
Hash Blake2b_256 ByteString -> OptimumNonce
OptimumNonce (Hash Blake2b_256 ByteString -> OptimumNonce)
-> (ByteString -> Hash Blake2b_256 ByteString)
-> ByteString
-> OptimumNonce
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> ByteString)
-> ByteString -> Hash Blake2b_256 ByteString
forall h a. HashAlgorithm h => (a -> ByteString) -> a -> Hash h a
Crypto.hashWith ByteString -> ByteString
forall a. a -> a
id

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

fromLedgerNonce :: Ledger.Nonce -> Maybe OptimumNonce
fromLedgerNonce :: Nonce -> Maybe OptimumNonce
fromLedgerNonce Nonce
Ledger.NeutralNonce = Maybe OptimumNonce
forall a. Maybe a
Nothing
fromLedgerNonce (Ledger.Nonce Hash Blake2b_256 Nonce
h)    = OptimumNonce -> Maybe OptimumNonce
forall a. a -> Maybe a
Just (Hash StandardCrypto ByteString -> OptimumNonce
OptimumNonce (Hash Blake2b_256 Nonce -> Hash Blake2b_256 ByteString
forall h a b. Hash h a -> Hash h b
Crypto.castHash Hash Blake2b_256 Nonce
h))


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

-- | The prices for 'ExecutionUnits' as a fraction of a 'Entropic'.
--
-- 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
/= :: ExecutionUnitPrices -> ExecutionUnitPrices -> Bool
$c/= :: ExecutionUnitPrices -> ExecutionUnitPrices -> Bool
== :: ExecutionUnitPrices -> ExecutionUnitPrices -> Bool
$c== :: 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
showList :: [ExecutionUnitPrices] -> ShowS
$cshowList :: [ExecutionUnitPrices] -> ShowS
show :: ExecutionUnitPrices -> String
$cshow :: ExecutionUnitPrices -> String
showsPrec :: Int -> ExecutionUnitPrices -> ShowS
$cshowsPrec :: Int -> ExecutionUnitPrices -> ShowS
Show)

instance ToCBOR ExecutionUnitPrices where
  toCBOR :: ExecutionUnitPrices -> Encoding
toCBOR ExecutionUnitPrices{Rational
priceExecutionSteps :: Rational
priceExecutionSteps :: ExecutionUnitPrices -> Rational
priceExecutionSteps, Rational
priceExecutionMemory :: Rational
priceExecutionMemory :: ExecutionUnitPrices -> 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 :: 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 a s. FromCBOR a => Decoder s a
fromCBOR
      Decoder s (Rational -> ExecutionUnitPrices)
-> Decoder s Rational -> Decoder s ExecutionUnitPrices
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decoder s Rational
forall a s. FromCBOR a => Decoder s a
fromCBOR

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

instance FromJSON ExecutionUnitPrices where
  parseJSON :: Value -> Parser ExecutionUnitPrices
parseJSON =
    String
-> (Object -> Parser ExecutionUnitPrices)
-> Value
-> Parser ExecutionUnitPrices
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ExecutionUnitPrices" ((Object -> Parser ExecutionUnitPrices)
 -> Value -> Parser ExecutionUnitPrices)
-> (Object -> Parser ExecutionUnitPrices)
-> Value
-> Parser ExecutionUnitPrices
forall a b. (a -> b) -> a -> b
$ \Object
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
<$> Object
o Object -> Text -> Parser Rational
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"priceSteps"
        Parser (Rational -> ExecutionUnitPrices)
-> Parser Rational -> Parser ExecutionUnitPrices
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Text -> Parser Rational
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"priceMemory"


toAurumPrices :: ExecutionUnitPrices -> Maybe Aurum.Prices
toAurumPrices :: ExecutionUnitPrices -> Maybe Prices
toAurumPrices ExecutionUnitPrices {
                 Rational
priceExecutionSteps :: Rational
priceExecutionSteps :: ExecutionUnitPrices -> Rational
priceExecutionSteps,
                 Rational
priceExecutionMemory :: Rational
priceExecutionMemory :: ExecutionUnitPrices -> Rational
priceExecutionMemory
               } = do
  NonNegativeInterval
prSteps <- Rational -> Maybe NonNegativeInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational Rational
priceExecutionSteps
  NonNegativeInterval
prMem   <- Rational -> Maybe NonNegativeInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational Rational
priceExecutionMemory
  Prices -> Maybe Prices
forall (m :: * -> *) a. Monad m => a -> m a
return Prices :: NonNegativeInterval -> NonNegativeInterval -> Prices
Aurum.Prices {
    NonNegativeInterval
prSteps :: NonNegativeInterval
prSteps :: NonNegativeInterval
Aurum.prSteps,
    NonNegativeInterval
prMem :: NonNegativeInterval
prMem :: NonNegativeInterval
Aurum.prMem
  }

fromAurumPrices :: Aurum.Prices -> ExecutionUnitPrices
fromAurumPrices :: Prices -> ExecutionUnitPrices
fromAurumPrices Aurum.Prices{NonNegativeInterval
prSteps :: NonNegativeInterval
prSteps :: Prices -> NonNegativeInterval
Aurum.prSteps, NonNegativeInterval
prMem :: NonNegativeInterval
prMem :: Prices -> NonNegativeInterval
Aurum.prMem} =
  ExecutionUnitPrices :: Rational -> Rational -> ExecutionUnitPrices
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 (Map Text Integer)
  deriving (CostModel -> CostModel -> Bool
(CostModel -> CostModel -> Bool)
-> (CostModel -> CostModel -> Bool) -> Eq CostModel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CostModel -> CostModel -> Bool
$c/= :: CostModel -> CostModel -> Bool
== :: CostModel -> CostModel -> Bool
$c== :: 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
showList :: [CostModel] -> ShowS
$cshowList :: [CostModel] -> ShowS
show :: CostModel -> String
$cshow :: CostModel -> String
showsPrec :: Int -> CostModel -> ShowS
$cshowsPrec :: Int -> CostModel -> ShowS
Show)
  deriving newtype ([CostModel] -> Value
[CostModel] -> Encoding
CostModel -> Value
CostModel -> Encoding
(CostModel -> Value)
-> (CostModel -> Encoding)
-> ([CostModel] -> Value)
-> ([CostModel] -> Encoding)
-> ToJSON CostModel
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [CostModel] -> Encoding
$ctoEncodingList :: [CostModel] -> Encoding
toJSONList :: [CostModel] -> Value
$ctoJSONList :: [CostModel] -> Value
toEncoding :: CostModel -> Encoding
$ctoEncoding :: CostModel -> Encoding
toJSON :: CostModel -> Value
$ctoJSON :: CostModel -> Value
ToJSON, Value -> Parser [CostModel]
Value -> Parser CostModel
(Value -> Parser CostModel)
-> (Value -> Parser [CostModel]) -> FromJSON CostModel
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [CostModel]
$cparseJSONList :: Value -> Parser [CostModel]
parseJSON :: Value -> Parser CostModel
$cparseJSON :: Value -> Parser CostModel
FromJSON)
  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
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [CostModel] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [CostModel] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy CostModel -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy CostModel -> Size
toCBOR :: CostModel -> Encoding
$ctoCBOR :: CostModel -> Encoding
$cp1ToCBOR :: Typeable CostModel
ToCBOR, Typeable CostModel
Decoder s 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
label :: Proxy CostModel -> Text
$clabel :: Proxy CostModel -> Text
fromCBOR :: Decoder s CostModel
$cfromCBOR :: forall s. Decoder s CostModel
$cp1FromCBOR :: Typeable CostModel
FromCBOR)

validateCostModel :: ZerepochScriptVersion lang
                  -> CostModel
                  -> Either InvalidCostModel ()
validateCostModel :: ZerepochScriptVersion lang
-> CostModel -> Either InvalidCostModel ()
validateCostModel ZerepochScriptVersion lang
ZerepochScriptV1 (CostModel Map Text Integer
m)
  | Map Text Integer -> Bool
Aurum.validateCostModelParams Map Text Integer
m = () -> Either InvalidCostModel ()
forall a b. b -> Either a b
Right ()
  | Bool
otherwise                        = InvalidCostModel -> Either InvalidCostModel ()
forall a b. a -> Either a b
Left (CostModel -> InvalidCostModel
InvalidCostModel (Map Text Integer -> CostModel
CostModel Map Text Integer
m))

-- TODO aurum: it'd be nice if the library told us what was wrong
newtype InvalidCostModel = InvalidCostModel CostModel
  deriving Int -> InvalidCostModel -> ShowS
[InvalidCostModel] -> ShowS
InvalidCostModel -> String
(Int -> InvalidCostModel -> ShowS)
-> (InvalidCostModel -> String)
-> ([InvalidCostModel] -> ShowS)
-> Show InvalidCostModel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InvalidCostModel] -> ShowS
$cshowList :: [InvalidCostModel] -> ShowS
show :: InvalidCostModel -> String
$cshow :: InvalidCostModel -> String
showsPrec :: Int -> InvalidCostModel -> ShowS
$cshowsPrec :: Int -> InvalidCostModel -> ShowS
Show

instance Error InvalidCostModel where
  displayError :: InvalidCostModel -> String
displayError (InvalidCostModel CostModel
cm) =
    String
"Invalid cost model: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ CostModel -> String
forall a. Show a => a -> String
show CostModel
cm


toAurumCostModels
  :: Map AnyZerepochScriptVersion CostModel
  -> Map Aurum.Language Aurum.CostModel
toAurumCostModels :: Map AnyZerepochScriptVersion CostModel -> Map Language CostModel
toAurumCostModels =
    [(Language, CostModel)] -> Map Language CostModel
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
  ([(Language, CostModel)] -> Map Language CostModel)
-> (Map AnyZerepochScriptVersion CostModel
    -> [(Language, CostModel)])
-> Map AnyZerepochScriptVersion CostModel
-> Map Language CostModel
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((AnyZerepochScriptVersion, CostModel) -> (Language, CostModel))
-> [(AnyZerepochScriptVersion, CostModel)]
-> [(Language, CostModel)]
forall a b. (a -> b) -> [a] -> [b]
map ((AnyZerepochScriptVersion -> Language)
-> (CostModel -> CostModel)
-> (AnyZerepochScriptVersion, CostModel)
-> (Language, CostModel)
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap AnyZerepochScriptVersion -> Language
toAurumScriptLanguage CostModel -> CostModel
toAurumCostModel)
  ([(AnyZerepochScriptVersion, CostModel)]
 -> [(Language, CostModel)])
-> (Map AnyZerepochScriptVersion CostModel
    -> [(AnyZerepochScriptVersion, CostModel)])
-> Map AnyZerepochScriptVersion CostModel
-> [(Language, CostModel)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map AnyZerepochScriptVersion CostModel
-> [(AnyZerepochScriptVersion, CostModel)]
forall k a. Map k a -> [(k, a)]
Map.toList

fromAurumCostModels
  :: Map Aurum.Language Aurum.CostModel
  -> Map AnyZerepochScriptVersion CostModel
fromAurumCostModels :: Map Language CostModel -> Map AnyZerepochScriptVersion CostModel
fromAurumCostModels =
    [(AnyZerepochScriptVersion, CostModel)]
-> Map AnyZerepochScriptVersion CostModel
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
  ([(AnyZerepochScriptVersion, CostModel)]
 -> Map AnyZerepochScriptVersion CostModel)
-> (Map Language CostModel
    -> [(AnyZerepochScriptVersion, CostModel)])
-> Map Language CostModel
-> Map AnyZerepochScriptVersion CostModel
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Language, CostModel) -> (AnyZerepochScriptVersion, CostModel))
-> [(Language, CostModel)]
-> [(AnyZerepochScriptVersion, CostModel)]
forall a b. (a -> b) -> [a] -> [b]
map ((Language -> AnyZerepochScriptVersion)
-> (CostModel -> CostModel)
-> (Language, CostModel)
-> (AnyZerepochScriptVersion, CostModel)
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap Language -> AnyZerepochScriptVersion
fromAurumScriptLanguage CostModel -> CostModel
fromAurumCostModel)
  ([(Language, CostModel)]
 -> [(AnyZerepochScriptVersion, CostModel)])
-> (Map Language CostModel -> [(Language, CostModel)])
-> Map Language CostModel
-> [(AnyZerepochScriptVersion, CostModel)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map Language CostModel -> [(Language, CostModel)]
forall k a. Map k a -> [(k, a)]
Map.toList

toAurumScriptLanguage :: AnyZerepochScriptVersion -> Aurum.Language
toAurumScriptLanguage :: AnyZerepochScriptVersion -> Language
toAurumScriptLanguage (AnyZerepochScriptVersion ZerepochScriptVersion lang
ZerepochScriptV1) = Language
Aurum.ZerepochV1

fromAurumScriptLanguage :: Aurum.Language -> AnyZerepochScriptVersion
fromAurumScriptLanguage :: Language -> AnyZerepochScriptVersion
fromAurumScriptLanguage Language
Aurum.ZerepochV1 = ZerepochScriptVersion ZerepochScriptV1 -> AnyZerepochScriptVersion
forall lang. ZerepochScriptVersion lang -> AnyZerepochScriptVersion
AnyZerepochScriptVersion ZerepochScriptVersion ZerepochScriptV1
ZerepochScriptV1

toAurumCostModel :: CostModel -> Aurum.CostModel
toAurumCostModel :: CostModel -> CostModel
toAurumCostModel (CostModel Map Text Integer
m) = Map Text Integer -> CostModel
Aurum.CostModel Map Text Integer
m

fromAurumCostModel :: Aurum.CostModel -> CostModel
fromAurumCostModel :: CostModel -> CostModel
fromAurumCostModel (Aurum.CostModel Map Text Integer
m) = Map Text Integer -> CostModel
CostModel Map Text Integer
m


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

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

instance HasTypeProxy UpdateProposal where
    data AsType UpdateProposal = AsUpdateProposal
    proxyToAsType :: Proxy UpdateProposal -> AsType UpdateProposal
proxyToAsType Proxy UpdateProposal
_ = AsType UpdateProposal
AsUpdateProposal

instance HasTextEnvelope UpdateProposal where
    textEnvelopeType :: AsType UpdateProposal -> TextEnvelopeType
textEnvelopeType AsType UpdateProposal
_ = TextEnvelopeType
"UpdateProposalSophie"

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

instance FromCBOR UpdateProposal where
    fromCBOR :: Decoder s UpdateProposal
fromCBOR = do
      Text -> Int -> Decoder s ()
forall s. Text -> Int -> Decoder s ()
CBOR.enforceSize Text
"ProtocolParametersUpdate" Int
2
      Map (Hash GenesisKey) ProtocolParametersUpdate
-> EpochNo -> UpdateProposal
UpdateProposal
        (Map (Hash GenesisKey) ProtocolParametersUpdate
 -> EpochNo -> UpdateProposal)
-> Decoder s (Map (Hash GenesisKey) ProtocolParametersUpdate)
-> Decoder s (EpochNo -> UpdateProposal)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s (Map (Hash GenesisKey) ProtocolParametersUpdate)
forall a s. FromCBOR a => Decoder s a
fromCBOR
        Decoder s (EpochNo -> UpdateProposal)
-> Decoder s EpochNo -> Decoder s UpdateProposal
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

makeSophieUpdateProposal :: ProtocolParametersUpdate
                          -> [Hash GenesisKey]
                          -> EpochNo
                          -> UpdateProposal
makeSophieUpdateProposal :: ProtocolParametersUpdate
-> [Hash GenesisKey] -> EpochNo -> UpdateProposal
makeSophieUpdateProposal ProtocolParametersUpdate
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) ProtocolParametersUpdate
-> EpochNo -> UpdateProposal
UpdateProposal ([(Hash GenesisKey, ProtocolParametersUpdate)]
-> Map (Hash GenesisKey) ProtocolParametersUpdate
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [ (Hash GenesisKey
kh, ProtocolParametersUpdate
params) | Hash GenesisKey
kh <- [Hash GenesisKey]
genesisKeyHashes ])


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

toLedgerUpdate :: forall era ledgerera.
                  SophieLedgerEra era ~ ledgerera
               => Ledger.Crypto ledgerera ~ StandardCrypto
               => SophieBasedEra era
               -> UpdateProposal
               -> Ledger.Update ledgerera
toLedgerUpdate :: SophieBasedEra era -> UpdateProposal -> Update ledgerera
toLedgerUpdate SophieBasedEra era
era (UpdateProposal Map (Hash GenesisKey) ProtocolParametersUpdate
ppup EpochNo
epochno) =
    ProposedPPUpdates ledgerera -> EpochNo -> Update ledgerera
forall era. ProposedPPUpdates era -> EpochNo -> Update era
Ledger.Update (SophieBasedEra era
-> Map (Hash GenesisKey) ProtocolParametersUpdate
-> ProposedPPUpdates ledgerera
forall era ledgerera.
(SophieLedgerEra era ~ ledgerera,
 Crypto ledgerera ~ StandardCrypto) =>
SophieBasedEra era
-> Map (Hash GenesisKey) ProtocolParametersUpdate
-> ProposedPPUpdates ledgerera
toLedgerProposedPPUpdates SophieBasedEra era
era Map (Hash GenesisKey) ProtocolParametersUpdate
ppup) EpochNo
epochno


toLedgerProposedPPUpdates :: forall era ledgerera.
                             SophieLedgerEra era ~ ledgerera
                          => Ledger.Crypto ledgerera ~ StandardCrypto
                          => SophieBasedEra era
                          -> Map (Hash GenesisKey) ProtocolParametersUpdate
                          -> Ledger.ProposedPPUpdates ledgerera
toLedgerProposedPPUpdates :: SophieBasedEra era
-> Map (Hash GenesisKey) ProtocolParametersUpdate
-> ProposedPPUpdates ledgerera
toLedgerProposedPPUpdates SophieBasedEra era
era =
    Map (KeyHash 'Genesis StandardCrypto) (PParamsDelta ledgerera)
-> ProposedPPUpdates ledgerera
forall era.
Map (KeyHash 'Genesis (Crypto era)) (PParamsDelta era)
-> ProposedPPUpdates era
Ledger.ProposedPPUpdates
  (Map (KeyHash 'Genesis StandardCrypto) (PParamsDelta ledgerera)
 -> ProposedPPUpdates ledgerera)
-> (Map (Hash GenesisKey) ProtocolParametersUpdate
    -> Map (KeyHash 'Genesis StandardCrypto) (PParamsDelta ledgerera))
-> Map (Hash GenesisKey) ProtocolParametersUpdate
-> ProposedPPUpdates ledgerera
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Hash GenesisKey -> KeyHash 'Genesis StandardCrypto)
-> Map (Hash GenesisKey) (PParamsDelta ledgerera)
-> Map (KeyHash 'Genesis StandardCrypto) (PParamsDelta ledgerera)
forall k1 k2 a. (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeysMonotonic (\(GenesisKeyHash kh) -> KeyHash 'Genesis StandardCrypto
kh)
  (Map (Hash GenesisKey) (PParamsDelta ledgerera)
 -> Map (KeyHash 'Genesis StandardCrypto) (PParamsDelta ledgerera))
-> (Map (Hash GenesisKey) ProtocolParametersUpdate
    -> Map (Hash GenesisKey) (PParamsDelta ledgerera))
-> Map (Hash GenesisKey) ProtocolParametersUpdate
-> Map (KeyHash 'Genesis StandardCrypto) (PParamsDelta ledgerera)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ProtocolParametersUpdate -> PParamsDelta ledgerera)
-> Map (Hash GenesisKey) ProtocolParametersUpdate
-> Map (Hash GenesisKey) (PParamsDelta ledgerera)
forall a b k. (a -> b) -> Map k a -> Map k b
Map.map (SophieBasedEra era
-> ProtocolParametersUpdate -> PParamsDelta (SophieLedgerEra era)
forall era.
SophieBasedEra era
-> ProtocolParametersUpdate -> PParamsDelta (SophieLedgerEra era)
toLedgerPParamsDelta SophieBasedEra era
era)


toLedgerPParamsDelta :: SophieBasedEra era
                     -> ProtocolParametersUpdate
                     -> Ledger.PParamsDelta (SophieLedgerEra era)
toLedgerPParamsDelta :: SophieBasedEra era
-> ProtocolParametersUpdate -> PParamsDelta (SophieLedgerEra era)
toLedgerPParamsDelta SophieBasedEra era
SophieBasedEraSophie = ProtocolParametersUpdate -> PParamsDelta (SophieLedgerEra era)
forall ledgerera.
ProtocolParametersUpdate -> PParamsUpdate ledgerera
toSophiePParamsUpdate
toLedgerPParamsDelta SophieBasedEra era
SophieBasedEraEvie = ProtocolParametersUpdate -> PParamsDelta (SophieLedgerEra era)
forall ledgerera.
ProtocolParametersUpdate -> PParamsUpdate ledgerera
toSophiePParamsUpdate
toLedgerPParamsDelta SophieBasedEra era
SophieBasedEraJen    = ProtocolParametersUpdate -> PParamsDelta (SophieLedgerEra era)
forall ledgerera.
ProtocolParametersUpdate -> PParamsUpdate ledgerera
toSophiePParamsUpdate
toLedgerPParamsDelta SophieBasedEra era
SophieBasedEraAurum  = ProtocolParametersUpdate -> PParamsDelta (SophieLedgerEra era)
forall ledgerera.
ProtocolParametersUpdate -> PParamsUpdate ledgerera
toAurumPParamsUpdate


--TODO: we should do validation somewhere, not just silently drop changes that
-- are not valid. Specifically, see Ledger.boundRational below.
toSophiePParamsUpdate :: ProtocolParametersUpdate
                       -> Sophie.PParamsUpdate ledgerera
toSophiePParamsUpdate :: ProtocolParametersUpdate -> PParamsUpdate ledgerera
toSophiePParamsUpdate
    ProtocolParametersUpdate {
      Maybe (Natural, Natural)
protocolUpdateProtocolVersion :: Maybe (Natural, Natural)
protocolUpdateProtocolVersion :: ProtocolParametersUpdate -> Maybe (Natural, Natural)
protocolUpdateProtocolVersion
    , Maybe Rational
protocolUpdateDecentralization :: Maybe Rational
protocolUpdateDecentralization :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdateDecentralization
    , Maybe (Maybe OptimumNonce)
protocolUpdateExtraOptimumEntropy :: Maybe (Maybe OptimumNonce)
protocolUpdateExtraOptimumEntropy :: ProtocolParametersUpdate -> Maybe (Maybe OptimumNonce)
protocolUpdateExtraOptimumEntropy
    , Maybe Natural
protocolUpdateMaxBlockHeaderSize :: Maybe Natural
protocolUpdateMaxBlockHeaderSize :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxBlockHeaderSize
    , Maybe Natural
protocolUpdateMaxBlockBodySize :: Maybe Natural
protocolUpdateMaxBlockBodySize :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxBlockBodySize
    , Maybe Natural
protocolUpdateMaxTxSize :: Maybe Natural
protocolUpdateMaxTxSize :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxTxSize
    , Maybe Natural
protocolUpdateTxFeeFixed :: Maybe Natural
protocolUpdateTxFeeFixed :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateTxFeeFixed
    , Maybe Natural
protocolUpdateTxFeePerByte :: Maybe Natural
protocolUpdateTxFeePerByte :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateTxFeePerByte
    , Maybe Entropic
protocolUpdateMinUTxOValue :: Maybe Entropic
protocolUpdateMinUTxOValue :: ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateMinUTxOValue
    , Maybe Entropic
protocolUpdateStakeAddressDeposit :: Maybe Entropic
protocolUpdateStakeAddressDeposit :: ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateStakeAddressDeposit
    , Maybe Entropic
protocolUpdateStakePoolDeposit :: Maybe Entropic
protocolUpdateStakePoolDeposit :: ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateStakePoolDeposit
    , Maybe Entropic
protocolUpdateMinPoolCost :: Maybe Entropic
protocolUpdateMinPoolCost :: ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateMinPoolCost
    , Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch :: Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch :: ProtocolParametersUpdate -> Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch
    , Maybe Natural
protocolUpdateStakePoolTargetNum :: Maybe Natural
protocolUpdateStakePoolTargetNum :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateStakePoolTargetNum
    , Maybe Rational
protocolUpdatePoolPledgeInfluence :: Maybe Rational
protocolUpdatePoolPledgeInfluence :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdatePoolPledgeInfluence
    , Maybe Rational
protocolUpdateMonetaryExpansion :: Maybe Rational
protocolUpdateMonetaryExpansion :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdateMonetaryExpansion
    , Maybe Rational
protocolUpdateTreasuryCut :: Maybe Rational
protocolUpdateTreasuryCut :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdateTreasuryCut
    } =
    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
Sophie.PParams {
      _minfeeA :: HKD StrictMaybe Natural
Sophie._minfeeA     = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateTxFeePerByte
    , _minfeeB :: HKD StrictMaybe Natural
Sophie._minfeeB     = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateTxFeeFixed
    , _maxBBSize :: HKD StrictMaybe Natural
Sophie._maxBBSize   = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateMaxBlockBodySize
    , _maxTxSize :: HKD StrictMaybe Natural
Sophie._maxTxSize   = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateMaxTxSize
    , _maxBHSize :: HKD StrictMaybe Natural
Sophie._maxBHSize   = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateMaxBlockHeaderSize
    , _keyDeposit :: HKD StrictMaybe Coin
Sophie._keyDeposit  = Entropic -> Coin
toSophieEntropic (Entropic -> Coin) -> StrictMaybe Entropic -> StrictMaybe Coin
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                               Maybe Entropic -> StrictMaybe Entropic
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Entropic
protocolUpdateStakeAddressDeposit
    , _poolDeposit :: HKD StrictMaybe Coin
Sophie._poolDeposit = Entropic -> Coin
toSophieEntropic (Entropic -> Coin) -> StrictMaybe Entropic -> StrictMaybe Coin
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                               Maybe Entropic -> StrictMaybe Entropic
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Entropic
protocolUpdateStakePoolDeposit
    , _eMax :: HKD StrictMaybe EpochNo
Sophie._eMax        = Maybe EpochNo -> StrictMaybe EpochNo
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch
    , _nOpt :: HKD StrictMaybe Natural
Sophie._nOpt        = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateStakePoolTargetNum
    , _a0 :: HKD StrictMaybe NonNegativeInterval
Sophie._a0          = Maybe NonNegativeInterval -> StrictMaybe NonNegativeInterval
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe (Maybe NonNegativeInterval -> StrictMaybe NonNegativeInterval)
-> Maybe NonNegativeInterval -> StrictMaybe NonNegativeInterval
forall a b. (a -> b) -> a -> b
$ Rational -> Maybe NonNegativeInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational (Rational -> Maybe NonNegativeInterval)
-> Maybe Rational -> Maybe NonNegativeInterval
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<
                              Maybe Rational
protocolUpdatePoolPledgeInfluence
    , _rho :: HKD StrictMaybe UnitInterval
Sophie._rho         = Maybe UnitInterval -> StrictMaybe UnitInterval
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe (Maybe UnitInterval -> StrictMaybe UnitInterval)
-> Maybe UnitInterval -> StrictMaybe UnitInterval
forall a b. (a -> b) -> a -> b
$ Rational -> Maybe UnitInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational (Rational -> Maybe UnitInterval)
-> Maybe Rational -> Maybe UnitInterval
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<
                                Maybe Rational
protocolUpdateMonetaryExpansion
    , _tau :: HKD StrictMaybe UnitInterval
Sophie._tau         = Maybe UnitInterval -> StrictMaybe UnitInterval
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe (Maybe UnitInterval -> StrictMaybe UnitInterval)
-> Maybe UnitInterval -> StrictMaybe UnitInterval
forall a b. (a -> b) -> a -> b
$ Rational -> Maybe UnitInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational (Rational -> Maybe UnitInterval)
-> Maybe Rational -> Maybe UnitInterval
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<
                                Maybe Rational
protocolUpdateTreasuryCut
    , _d :: HKD StrictMaybe UnitInterval
Sophie._d           = Maybe UnitInterval -> StrictMaybe UnitInterval
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe (Maybe UnitInterval -> StrictMaybe UnitInterval)
-> Maybe UnitInterval -> StrictMaybe UnitInterval
forall a b. (a -> b) -> a -> b
$ Rational -> Maybe UnitInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational (Rational -> Maybe UnitInterval)
-> Maybe Rational -> Maybe UnitInterval
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<
                                Maybe Rational
protocolUpdateDecentralization
    , _extraEntropy :: HKD StrictMaybe Nonce
Sophie._extraEntropy    = Maybe OptimumNonce -> Nonce
toLedgerNonce (Maybe OptimumNonce -> Nonce)
-> StrictMaybe (Maybe OptimumNonce) -> StrictMaybe Nonce
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                   Maybe (Maybe OptimumNonce) -> StrictMaybe (Maybe OptimumNonce)
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe (Maybe OptimumNonce)
protocolUpdateExtraOptimumEntropy
    , _protocolVersion :: HKD StrictMaybe ProtVer
Sophie._protocolVersion = (Natural -> Natural -> ProtVer) -> (Natural, Natural) -> ProtVer
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Natural -> Natural -> ProtVer
Ledger.ProtVer ((Natural, Natural) -> ProtVer)
-> StrictMaybe (Natural, Natural) -> StrictMaybe ProtVer
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                   Maybe (Natural, Natural) -> StrictMaybe (Natural, Natural)
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe (Natural, Natural)
protocolUpdateProtocolVersion
    , _minUTxOValue :: HKD StrictMaybe Coin
Sophie._minUTxOValue    = Entropic -> Coin
toSophieEntropic (Entropic -> Coin) -> StrictMaybe Entropic -> StrictMaybe Coin
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                   Maybe Entropic -> StrictMaybe Entropic
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Entropic
protocolUpdateMinUTxOValue
    , _minPoolCost :: HKD StrictMaybe Coin
Sophie._minPoolCost     = Entropic -> Coin
toSophieEntropic (Entropic -> Coin) -> StrictMaybe Entropic -> StrictMaybe Coin
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                   Maybe Entropic -> StrictMaybe Entropic
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Entropic
protocolUpdateMinPoolCost
    }


toAurumPParamsUpdate :: ProtocolParametersUpdate
                      -> Aurum.PParamsUpdate ledgerera
toAurumPParamsUpdate :: ProtocolParametersUpdate -> PParamsUpdate ledgerera
toAurumPParamsUpdate
    ProtocolParametersUpdate {
      Maybe (Natural, Natural)
protocolUpdateProtocolVersion :: Maybe (Natural, Natural)
protocolUpdateProtocolVersion :: ProtocolParametersUpdate -> Maybe (Natural, Natural)
protocolUpdateProtocolVersion
    , Maybe Rational
protocolUpdateDecentralization :: Maybe Rational
protocolUpdateDecentralization :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdateDecentralization
    , Maybe (Maybe OptimumNonce)
protocolUpdateExtraOptimumEntropy :: Maybe (Maybe OptimumNonce)
protocolUpdateExtraOptimumEntropy :: ProtocolParametersUpdate -> Maybe (Maybe OptimumNonce)
protocolUpdateExtraOptimumEntropy
    , Maybe Natural
protocolUpdateMaxBlockHeaderSize :: Maybe Natural
protocolUpdateMaxBlockHeaderSize :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxBlockHeaderSize
    , Maybe Natural
protocolUpdateMaxBlockBodySize :: Maybe Natural
protocolUpdateMaxBlockBodySize :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxBlockBodySize
    , Maybe Natural
protocolUpdateMaxTxSize :: Maybe Natural
protocolUpdateMaxTxSize :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxTxSize
    , Maybe Natural
protocolUpdateTxFeeFixed :: Maybe Natural
protocolUpdateTxFeeFixed :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateTxFeeFixed
    , Maybe Natural
protocolUpdateTxFeePerByte :: Maybe Natural
protocolUpdateTxFeePerByte :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateTxFeePerByte
    , Maybe Entropic
protocolUpdateStakeAddressDeposit :: Maybe Entropic
protocolUpdateStakeAddressDeposit :: ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateStakeAddressDeposit
    , Maybe Entropic
protocolUpdateStakePoolDeposit :: Maybe Entropic
protocolUpdateStakePoolDeposit :: ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateStakePoolDeposit
    , Maybe Entropic
protocolUpdateMinPoolCost :: Maybe Entropic
protocolUpdateMinPoolCost :: ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateMinPoolCost
    , Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch :: Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch :: ProtocolParametersUpdate -> Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch
    , Maybe Natural
protocolUpdateStakePoolTargetNum :: Maybe Natural
protocolUpdateStakePoolTargetNum :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateStakePoolTargetNum
    , Maybe Rational
protocolUpdatePoolPledgeInfluence :: Maybe Rational
protocolUpdatePoolPledgeInfluence :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdatePoolPledgeInfluence
    , Maybe Rational
protocolUpdateMonetaryExpansion :: Maybe Rational
protocolUpdateMonetaryExpansion :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdateMonetaryExpansion
    , Maybe Rational
protocolUpdateTreasuryCut :: Maybe Rational
protocolUpdateTreasuryCut :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdateTreasuryCut
    , Maybe Entropic
protocolUpdateUTxOCostPerWord :: Maybe Entropic
protocolUpdateUTxOCostPerWord :: ProtocolParametersUpdate -> Maybe Entropic
protocolUpdateUTxOCostPerWord
    , Map AnyZerepochScriptVersion CostModel
protocolUpdateCostModels :: Map AnyZerepochScriptVersion CostModel
protocolUpdateCostModels :: ProtocolParametersUpdate -> Map AnyZerepochScriptVersion CostModel
protocolUpdateCostModels
    , Maybe ExecutionUnitPrices
protocolUpdatePrices :: Maybe ExecutionUnitPrices
protocolUpdatePrices :: ProtocolParametersUpdate -> Maybe ExecutionUnitPrices
protocolUpdatePrices
    , Maybe ExecutionUnits
protocolUpdateMaxTxExUnits :: Maybe ExecutionUnits
protocolUpdateMaxTxExUnits :: ProtocolParametersUpdate -> Maybe ExecutionUnits
protocolUpdateMaxTxExUnits
    , Maybe ExecutionUnits
protocolUpdateMaxBlockExUnits :: Maybe ExecutionUnits
protocolUpdateMaxBlockExUnits :: ProtocolParametersUpdate -> Maybe ExecutionUnits
protocolUpdateMaxBlockExUnits
    , Maybe Natural
protocolUpdateMaxValueSize :: Maybe Natural
protocolUpdateMaxValueSize :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxValueSize
    , Maybe Natural
protocolUpdateCollateralPercent :: Maybe Natural
protocolUpdateCollateralPercent :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateCollateralPercent
    , Maybe Natural
protocolUpdateMaxCollateralInputs :: Maybe Natural
protocolUpdateMaxCollateralInputs :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxCollateralInputs
    } =
    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
-> HKD f (Map Language CostModel)
-> HKD f Prices
-> HKD f ExUnits
-> HKD f ExUnits
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> PParams' f era
Aurum.PParams {
      _minfeeA :: HKD StrictMaybe Natural
Aurum._minfeeA     = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateTxFeePerByte
    , _minfeeB :: HKD StrictMaybe Natural
Aurum._minfeeB     = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateTxFeeFixed
    , _maxBBSize :: HKD StrictMaybe Natural
Aurum._maxBBSize   = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateMaxBlockBodySize
    , _maxTxSize :: HKD StrictMaybe Natural
Aurum._maxTxSize   = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateMaxTxSize
    , _maxBHSize :: HKD StrictMaybe Natural
Aurum._maxBHSize   = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateMaxBlockHeaderSize
    , _keyDeposit :: HKD StrictMaybe Coin
Aurum._keyDeposit  = Entropic -> Coin
toSophieEntropic (Entropic -> Coin) -> StrictMaybe Entropic -> StrictMaybe Coin
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                              Maybe Entropic -> StrictMaybe Entropic
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Entropic
protocolUpdateStakeAddressDeposit
    , _poolDeposit :: HKD StrictMaybe Coin
Aurum._poolDeposit = Entropic -> Coin
toSophieEntropic (Entropic -> Coin) -> StrictMaybe Entropic -> StrictMaybe Coin
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                              Maybe Entropic -> StrictMaybe Entropic
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Entropic
protocolUpdateStakePoolDeposit
    , _eMax :: HKD StrictMaybe EpochNo
Aurum._eMax        = Maybe EpochNo -> StrictMaybe EpochNo
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch
    , _nOpt :: HKD StrictMaybe Natural
Aurum._nOpt        = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateStakePoolTargetNum
    , _a0 :: HKD StrictMaybe NonNegativeInterval
Aurum._a0          = Maybe NonNegativeInterval -> StrictMaybe NonNegativeInterval
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe (Maybe NonNegativeInterval -> StrictMaybe NonNegativeInterval)
-> Maybe NonNegativeInterval -> StrictMaybe NonNegativeInterval
forall a b. (a -> b) -> a -> b
$ Rational -> Maybe NonNegativeInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational (Rational -> Maybe NonNegativeInterval)
-> Maybe Rational -> Maybe NonNegativeInterval
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<
                              Maybe Rational
protocolUpdatePoolPledgeInfluence
    , _rho :: HKD StrictMaybe UnitInterval
Aurum._rho         = Maybe UnitInterval -> StrictMaybe UnitInterval
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe (Maybe UnitInterval -> StrictMaybe UnitInterval)
-> Maybe UnitInterval -> StrictMaybe UnitInterval
forall a b. (a -> b) -> a -> b
$ Rational -> Maybe UnitInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational (Rational -> Maybe UnitInterval)
-> Maybe Rational -> Maybe UnitInterval
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<
                               Maybe Rational
protocolUpdateMonetaryExpansion
    , _tau :: HKD StrictMaybe UnitInterval
Aurum._tau         = Maybe UnitInterval -> StrictMaybe UnitInterval
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe (Maybe UnitInterval -> StrictMaybe UnitInterval)
-> Maybe UnitInterval -> StrictMaybe UnitInterval
forall a b. (a -> b) -> a -> b
$ Rational -> Maybe UnitInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational (Rational -> Maybe UnitInterval)
-> Maybe Rational -> Maybe UnitInterval
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<
                               Maybe Rational
protocolUpdateTreasuryCut
    , _d :: HKD StrictMaybe UnitInterval
Aurum._d           = Maybe UnitInterval -> StrictMaybe UnitInterval
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe (Maybe UnitInterval -> StrictMaybe UnitInterval)
-> Maybe UnitInterval -> StrictMaybe UnitInterval
forall a b. (a -> b) -> a -> b
$ Rational -> Maybe UnitInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational (Rational -> Maybe UnitInterval)
-> Maybe Rational -> Maybe UnitInterval
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<
                               Maybe Rational
protocolUpdateDecentralization
    , _extraEntropy :: HKD StrictMaybe Nonce
Aurum._extraEntropy    = Maybe OptimumNonce -> Nonce
toLedgerNonce (Maybe OptimumNonce -> Nonce)
-> StrictMaybe (Maybe OptimumNonce) -> StrictMaybe Nonce
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                  Maybe (Maybe OptimumNonce) -> StrictMaybe (Maybe OptimumNonce)
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe (Maybe OptimumNonce)
protocolUpdateExtraOptimumEntropy
    , _protocolVersion :: HKD StrictMaybe ProtVer
Aurum._protocolVersion = (Natural -> Natural -> ProtVer) -> (Natural, Natural) -> ProtVer
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Natural -> Natural -> ProtVer
Ledger.ProtVer ((Natural, Natural) -> ProtVer)
-> StrictMaybe (Natural, Natural) -> StrictMaybe ProtVer
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                  Maybe (Natural, Natural) -> StrictMaybe (Natural, Natural)
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe (Natural, Natural)
protocolUpdateProtocolVersion
    , _minPoolCost :: HKD StrictMaybe Coin
Aurum._minPoolCost     = Entropic -> Coin
toSophieEntropic (Entropic -> Coin) -> StrictMaybe Entropic -> StrictMaybe Coin
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                  Maybe Entropic -> StrictMaybe Entropic
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Entropic
protocolUpdateMinPoolCost
    , _coinsPerUTxOWord :: HKD StrictMaybe Coin
Aurum._coinsPerUTxOWord  = Entropic -> Coin
toSophieEntropic (Entropic -> Coin) -> StrictMaybe Entropic -> StrictMaybe Coin
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                  Maybe Entropic -> StrictMaybe Entropic
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Entropic
protocolUpdateUTxOCostPerWord
    , _costmdls :: HKD StrictMaybe (Map Language CostModel)
Aurum._costmdls        = if Map AnyZerepochScriptVersion CostModel -> Bool
forall k a. Map k a -> Bool
Map.null Map AnyZerepochScriptVersion CostModel
protocolUpdateCostModels
                                  then HKD StrictMaybe (Map Language CostModel)
forall a. StrictMaybe a
Ledger.SNothing
                                  else Map Language CostModel -> StrictMaybe (Map Language CostModel)
forall a. a -> StrictMaybe a
Ledger.SJust
                                         (Map AnyZerepochScriptVersion CostModel -> Map Language CostModel
toAurumCostModels Map AnyZerepochScriptVersion CostModel
protocolUpdateCostModels)
    , _prices :: HKD StrictMaybe Prices
Aurum._prices          = Maybe Prices -> StrictMaybe Prices
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe (Maybe Prices -> StrictMaybe Prices)
-> Maybe Prices -> StrictMaybe Prices
forall a b. (a -> b) -> a -> b
$
                                  ExecutionUnitPrices -> Maybe Prices
toAurumPrices (ExecutionUnitPrices -> Maybe Prices)
-> Maybe ExecutionUnitPrices -> Maybe Prices
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Maybe ExecutionUnitPrices
protocolUpdatePrices
    , _maxTxExUnits :: HKD StrictMaybe ExUnits
Aurum._maxTxExUnits    = ExecutionUnits -> ExUnits
toAurumExUnits  (ExecutionUnits -> ExUnits)
-> StrictMaybe ExecutionUnits -> StrictMaybe ExUnits
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                  Maybe ExecutionUnits -> StrictMaybe ExecutionUnits
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe ExecutionUnits
protocolUpdateMaxTxExUnits
    , _maxBlockExUnits :: HKD StrictMaybe ExUnits
Aurum._maxBlockExUnits = ExecutionUnits -> ExUnits
toAurumExUnits  (ExecutionUnits -> ExUnits)
-> StrictMaybe ExecutionUnits -> StrictMaybe ExUnits
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                  Maybe ExecutionUnits -> StrictMaybe ExecutionUnits
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe ExecutionUnits
protocolUpdateMaxBlockExUnits
    , _maxValSize :: HKD StrictMaybe Natural
Aurum._maxValSize      = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateMaxValueSize
    , _collateralPercentage :: HKD StrictMaybe Natural
Aurum._collateralPercentage = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateCollateralPercent
    , _maxCollateralInputs :: HKD StrictMaybe Natural
Aurum._maxCollateralInputs  = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateMaxCollateralInputs
    }


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

fromLedgerUpdate :: forall era ledgerera.
                    SophieLedgerEra era ~ ledgerera
                 => Ledger.Crypto ledgerera ~ StandardCrypto
                 => SophieBasedEra era
                 -> Ledger.Update ledgerera
                 -> UpdateProposal
fromLedgerUpdate :: SophieBasedEra era -> Update ledgerera -> UpdateProposal
fromLedgerUpdate SophieBasedEra era
era (Ledger.Update ProposedPPUpdates ledgerera
ppup EpochNo
epochno) =
    Map (Hash GenesisKey) ProtocolParametersUpdate
-> EpochNo -> UpdateProposal
UpdateProposal (SophieBasedEra era
-> ProposedPPUpdates ledgerera
-> Map (Hash GenesisKey) ProtocolParametersUpdate
forall era ledgerera.
(SophieLedgerEra era ~ ledgerera,
 Crypto ledgerera ~ StandardCrypto) =>
SophieBasedEra era
-> ProposedPPUpdates ledgerera
-> Map (Hash GenesisKey) ProtocolParametersUpdate
fromLedgerProposedPPUpdates SophieBasedEra era
era ProposedPPUpdates ledgerera
ppup) EpochNo
epochno


fromLedgerProposedPPUpdates :: forall era ledgerera.
                               SophieLedgerEra era ~ ledgerera
                            => Ledger.Crypto ledgerera ~ StandardCrypto
                            => SophieBasedEra era
                            -> Ledger.ProposedPPUpdates ledgerera
                            -> Map (Hash GenesisKey) ProtocolParametersUpdate
fromLedgerProposedPPUpdates :: SophieBasedEra era
-> ProposedPPUpdates ledgerera
-> Map (Hash GenesisKey) ProtocolParametersUpdate
fromLedgerProposedPPUpdates SophieBasedEra era
era =
    (PParamsDelta ledgerera -> ProtocolParametersUpdate)
-> Map (Hash GenesisKey) (PParamsDelta ledgerera)
-> Map (Hash GenesisKey) ProtocolParametersUpdate
forall a b k. (a -> b) -> Map k a -> Map k b
Map.map (SophieBasedEra era
-> PParamsDelta (SophieLedgerEra era) -> ProtocolParametersUpdate
forall era.
SophieBasedEra era
-> PParamsDelta (SophieLedgerEra era) -> ProtocolParametersUpdate
fromLedgerPParamsDelta SophieBasedEra era
era)
  (Map (Hash GenesisKey) (PParamsDelta ledgerera)
 -> Map (Hash GenesisKey) ProtocolParametersUpdate)
-> (ProposedPPUpdates ledgerera
    -> Map (Hash GenesisKey) (PParamsDelta ledgerera))
-> ProposedPPUpdates ledgerera
-> Map (Hash GenesisKey) ProtocolParametersUpdate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (KeyHash 'Genesis StandardCrypto -> Hash GenesisKey)
-> Map (KeyHash 'Genesis StandardCrypto) (PParamsDelta ledgerera)
-> Map (Hash GenesisKey) (PParamsDelta ledgerera)
forall k1 k2 a. (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeysMonotonic KeyHash 'Genesis StandardCrypto -> Hash GenesisKey
GenesisKeyHash
  (Map (KeyHash 'Genesis StandardCrypto) (PParamsDelta ledgerera)
 -> Map (Hash GenesisKey) (PParamsDelta ledgerera))
-> (ProposedPPUpdates ledgerera
    -> Map (KeyHash 'Genesis StandardCrypto) (PParamsDelta ledgerera))
-> ProposedPPUpdates ledgerera
-> Map (Hash GenesisKey) (PParamsDelta ledgerera)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\(Ledger.ProposedPPUpdates Map (KeyHash 'Genesis (Crypto ledgerera)) (PParamsDelta ledgerera)
ppup) -> Map (KeyHash 'Genesis StandardCrypto) (PParamsDelta ledgerera)
Map (KeyHash 'Genesis (Crypto ledgerera)) (PParamsDelta ledgerera)
ppup)


fromLedgerPParamsDelta :: SophieBasedEra era
                       -> Ledger.PParamsDelta (SophieLedgerEra era)
                       -> ProtocolParametersUpdate
fromLedgerPParamsDelta :: SophieBasedEra era
-> PParamsDelta (SophieLedgerEra era) -> ProtocolParametersUpdate
fromLedgerPParamsDelta SophieBasedEra era
SophieBasedEraSophie = PParamsDelta (SophieLedgerEra era) -> ProtocolParametersUpdate
forall ledgerera.
PParamsUpdate ledgerera -> ProtocolParametersUpdate
fromSophiePParamsUpdate
fromLedgerPParamsDelta SophieBasedEra era
SophieBasedEraEvie = PParamsDelta (SophieLedgerEra era) -> ProtocolParametersUpdate
forall ledgerera.
PParamsUpdate ledgerera -> ProtocolParametersUpdate
fromSophiePParamsUpdate
fromLedgerPParamsDelta SophieBasedEra era
SophieBasedEraJen    = PParamsDelta (SophieLedgerEra era) -> ProtocolParametersUpdate
forall ledgerera.
PParamsUpdate ledgerera -> ProtocolParametersUpdate
fromSophiePParamsUpdate
fromLedgerPParamsDelta SophieBasedEra era
SophieBasedEraAurum  = PParamsDelta (SophieLedgerEra era) -> ProtocolParametersUpdate
forall ledgerera.
PParamsUpdate ledgerera -> ProtocolParametersUpdate
fromAurumPParamsUpdate


fromSophiePParamsUpdate :: Sophie.PParamsUpdate ledgerera
                         -> ProtocolParametersUpdate
fromSophiePParamsUpdate :: PParamsUpdate ledgerera -> ProtocolParametersUpdate
fromSophiePParamsUpdate
    Sophie.PParams {
      HKD StrictMaybe Natural
_minfeeA :: HKD StrictMaybe Natural
_minfeeA :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._minfeeA
    , HKD StrictMaybe Natural
_minfeeB :: HKD StrictMaybe Natural
_minfeeB :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._minfeeB
    , HKD StrictMaybe Natural
_maxBBSize :: HKD StrictMaybe Natural
_maxBBSize :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._maxBBSize
    , HKD StrictMaybe Natural
_maxTxSize :: HKD StrictMaybe Natural
_maxTxSize :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._maxTxSize
    , HKD StrictMaybe Natural
_maxBHSize :: HKD StrictMaybe Natural
_maxBHSize :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._maxBHSize
    , HKD StrictMaybe Coin
_keyDeposit :: HKD StrictMaybe Coin
_keyDeposit :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Sophie._keyDeposit
    , HKD StrictMaybe Coin
_poolDeposit :: HKD StrictMaybe Coin
_poolDeposit :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Sophie._poolDeposit
    , HKD StrictMaybe EpochNo
_eMax :: HKD StrictMaybe EpochNo
_eMax :: forall (f :: * -> *) era. PParams' f era -> HKD f EpochNo
Sophie._eMax
    , HKD StrictMaybe Natural
_nOpt :: HKD StrictMaybe Natural
_nOpt :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._nOpt
    , HKD StrictMaybe NonNegativeInterval
_a0 :: HKD StrictMaybe NonNegativeInterval
_a0 :: forall (f :: * -> *) era.
PParams' f era -> HKD f NonNegativeInterval
Sophie._a0
    , HKD StrictMaybe UnitInterval
_rho :: HKD StrictMaybe UnitInterval
_rho :: forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Sophie._rho
    , HKD StrictMaybe UnitInterval
_tau :: HKD StrictMaybe UnitInterval
_tau :: forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Sophie._tau
    , HKD StrictMaybe UnitInterval
_d :: HKD StrictMaybe UnitInterval
_d :: forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Sophie._d
    , HKD StrictMaybe Nonce
_extraEntropy :: HKD StrictMaybe Nonce
_extraEntropy :: forall (f :: * -> *) era. PParams' f era -> HKD f Nonce
Sophie._extraEntropy
    , HKD StrictMaybe ProtVer
_protocolVersion :: HKD StrictMaybe ProtVer
_protocolVersion :: forall (f :: * -> *) era. PParams' f era -> HKD f ProtVer
Sophie._protocolVersion
    , HKD StrictMaybe Coin
_minUTxOValue :: HKD StrictMaybe Coin
_minUTxOValue :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Sophie._minUTxOValue
    , HKD StrictMaybe Coin
_minPoolCost :: HKD StrictMaybe Coin
_minPoolCost :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Sophie._minPoolCost
    } =
    ProtocolParametersUpdate :: Maybe (Natural, Natural)
-> Maybe Rational
-> Maybe (Maybe OptimumNonce)
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Entropic
-> Maybe Entropic
-> Maybe Entropic
-> Maybe Entropic
-> Maybe EpochNo
-> Maybe Natural
-> Maybe Rational
-> Maybe Rational
-> Maybe Rational
-> Maybe Entropic
-> Map AnyZerepochScriptVersion CostModel
-> Maybe ExecutionUnitPrices
-> Maybe ExecutionUnits
-> Maybe ExecutionUnits
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> ProtocolParametersUpdate
ProtocolParametersUpdate {
      protocolUpdateProtocolVersion :: Maybe (Natural, Natural)
protocolUpdateProtocolVersion     = (\(Ledger.ProtVer Natural
a Natural
b) -> (Natural
a,Natural
b)) (ProtVer -> (Natural, Natural))
-> Maybe ProtVer -> Maybe (Natural, Natural)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                          StrictMaybe ProtVer -> Maybe ProtVer
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe ProtVer
HKD StrictMaybe ProtVer
_protocolVersion
    , protocolUpdateDecentralization :: Maybe Rational
protocolUpdateDecentralization    = UnitInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational (UnitInterval -> Rational) -> Maybe UnitInterval -> Maybe Rational
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe UnitInterval -> Maybe UnitInterval
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe UnitInterval
HKD StrictMaybe UnitInterval
_d
    , protocolUpdateExtraOptimumEntropy :: Maybe (Maybe OptimumNonce)
protocolUpdateExtraOptimumEntropy   = Nonce -> Maybe OptimumNonce
fromLedgerNonce (Nonce -> Maybe OptimumNonce)
-> Maybe Nonce -> Maybe (Maybe OptimumNonce)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe Nonce -> Maybe Nonce
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Nonce
HKD StrictMaybe Nonce
_extraEntropy
    , protocolUpdateMaxBlockHeaderSize :: Maybe Natural
protocolUpdateMaxBlockHeaderSize  = StrictMaybe Natural -> Maybe Natural
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Natural
HKD StrictMaybe Natural
_maxBHSize
    , protocolUpdateMaxBlockBodySize :: Maybe Natural
protocolUpdateMaxBlockBodySize    = StrictMaybe Natural -> Maybe Natural
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Natural
HKD StrictMaybe Natural
_maxBBSize
    , protocolUpdateMaxTxSize :: Maybe Natural
protocolUpdateMaxTxSize           = StrictMaybe Natural -> Maybe Natural
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Natural
HKD StrictMaybe Natural
_maxTxSize
    , protocolUpdateTxFeeFixed :: Maybe Natural
protocolUpdateTxFeeFixed          = StrictMaybe Natural -> Maybe Natural
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Natural
HKD StrictMaybe Natural
_minfeeB
    , protocolUpdateTxFeePerByte :: Maybe Natural
protocolUpdateTxFeePerByte        = StrictMaybe Natural -> Maybe Natural
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Natural
HKD StrictMaybe Natural
_minfeeA
    , protocolUpdateMinUTxOValue :: Maybe Entropic
protocolUpdateMinUTxOValue        = Coin -> Entropic
fromSophieEntropic (Coin -> Entropic) -> Maybe Coin -> Maybe Entropic
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe Coin -> Maybe Coin
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Coin
HKD StrictMaybe Coin
_minUTxOValue
    , protocolUpdateStakeAddressDeposit :: Maybe Entropic
protocolUpdateStakeAddressDeposit = Coin -> Entropic
fromSophieEntropic (Coin -> Entropic) -> Maybe Coin -> Maybe Entropic
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe Coin -> Maybe Coin
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Coin
HKD StrictMaybe Coin
_keyDeposit
    , protocolUpdateStakePoolDeposit :: Maybe Entropic
protocolUpdateStakePoolDeposit    = Coin -> Entropic
fromSophieEntropic (Coin -> Entropic) -> Maybe Coin -> Maybe Entropic
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe Coin -> Maybe Coin
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Coin
HKD StrictMaybe Coin
_poolDeposit
    , protocolUpdateMinPoolCost :: Maybe Entropic
protocolUpdateMinPoolCost         = Coin -> Entropic
fromSophieEntropic (Coin -> Entropic) -> Maybe Coin -> Maybe Entropic
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe Coin -> Maybe Coin
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Coin
HKD StrictMaybe Coin
_minPoolCost
    , protocolUpdatePoolRetireMaxEpoch :: Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch  = StrictMaybe EpochNo -> Maybe EpochNo
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe EpochNo
HKD StrictMaybe EpochNo
_eMax
    , protocolUpdateStakePoolTargetNum :: Maybe Natural
protocolUpdateStakePoolTargetNum  = StrictMaybe Natural -> Maybe Natural
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Natural
HKD StrictMaybe Natural
_nOpt
    , protocolUpdatePoolPledgeInfluence :: Maybe Rational
protocolUpdatePoolPledgeInfluence = NonNegativeInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational (NonNegativeInterval -> Rational)
-> Maybe NonNegativeInterval -> Maybe Rational
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe NonNegativeInterval -> Maybe NonNegativeInterval
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe NonNegativeInterval
HKD StrictMaybe NonNegativeInterval
_a0
    , protocolUpdateMonetaryExpansion :: Maybe Rational
protocolUpdateMonetaryExpansion   = UnitInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational (UnitInterval -> Rational) -> Maybe UnitInterval -> Maybe Rational
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe UnitInterval -> Maybe UnitInterval
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe UnitInterval
HKD StrictMaybe UnitInterval
_rho
    , protocolUpdateTreasuryCut :: Maybe Rational
protocolUpdateTreasuryCut         = UnitInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational (UnitInterval -> Rational) -> Maybe UnitInterval -> Maybe Rational
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe UnitInterval -> Maybe UnitInterval
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe UnitInterval
HKD StrictMaybe UnitInterval
_tau
    , protocolUpdateUTxOCostPerWord :: Maybe Entropic
protocolUpdateUTxOCostPerWord     = Maybe Entropic
forall a. Maybe a
Nothing
    , protocolUpdateCostModels :: Map AnyZerepochScriptVersion CostModel
protocolUpdateCostModels          = Map AnyZerepochScriptVersion CostModel
forall a. Monoid a => a
mempty
    , protocolUpdatePrices :: Maybe ExecutionUnitPrices
protocolUpdatePrices              = Maybe ExecutionUnitPrices
forall a. Maybe a
Nothing
    , protocolUpdateMaxTxExUnits :: Maybe ExecutionUnits
protocolUpdateMaxTxExUnits        = Maybe ExecutionUnits
forall a. Maybe a
Nothing
    , protocolUpdateMaxBlockExUnits :: Maybe ExecutionUnits
protocolUpdateMaxBlockExUnits     = Maybe ExecutionUnits
forall a. Maybe a
Nothing
    , protocolUpdateMaxValueSize :: Maybe Natural
protocolUpdateMaxValueSize        = Maybe Natural
forall a. Maybe a
Nothing
    , protocolUpdateCollateralPercent :: Maybe Natural
protocolUpdateCollateralPercent   = Maybe Natural
forall a. Maybe a
Nothing
    , protocolUpdateMaxCollateralInputs :: Maybe Natural
protocolUpdateMaxCollateralInputs = Maybe Natural
forall a. Maybe a
Nothing
    }

fromAurumPParamsUpdate :: Aurum.PParamsUpdate ledgerera
                        -> ProtocolParametersUpdate
fromAurumPParamsUpdate :: PParamsUpdate ledgerera -> ProtocolParametersUpdate
fromAurumPParamsUpdate
    Aurum.PParams {
      HKD StrictMaybe Natural
_minfeeA :: HKD StrictMaybe Natural
_minfeeA :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._minfeeA
    , HKD StrictMaybe Natural
_minfeeB :: HKD StrictMaybe Natural
_minfeeB :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._minfeeB
    , HKD StrictMaybe Natural
_maxBBSize :: HKD StrictMaybe Natural
_maxBBSize :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._maxBBSize
    , HKD StrictMaybe Natural
_maxTxSize :: HKD StrictMaybe Natural
_maxTxSize :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._maxTxSize
    , HKD StrictMaybe Natural
_maxBHSize :: HKD StrictMaybe Natural
_maxBHSize :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._maxBHSize
    , HKD StrictMaybe Coin
_keyDeposit :: HKD StrictMaybe Coin
_keyDeposit :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Aurum._keyDeposit
    , HKD StrictMaybe Coin
_poolDeposit :: HKD StrictMaybe Coin
_poolDeposit :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Aurum._poolDeposit
    , HKD StrictMaybe EpochNo
_eMax :: HKD StrictMaybe EpochNo
_eMax :: forall (f :: * -> *) era. PParams' f era -> HKD f EpochNo
Aurum._eMax
    , HKD StrictMaybe Natural
_nOpt :: HKD StrictMaybe Natural
_nOpt :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._nOpt
    , HKD StrictMaybe NonNegativeInterval
_a0 :: HKD StrictMaybe NonNegativeInterval
_a0 :: forall (f :: * -> *) era.
PParams' f era -> HKD f NonNegativeInterval
Aurum._a0
    , HKD StrictMaybe UnitInterval
_rho :: HKD StrictMaybe UnitInterval
_rho :: forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Aurum._rho
    , HKD StrictMaybe UnitInterval
_tau :: HKD StrictMaybe UnitInterval
_tau :: forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Aurum._tau
    , HKD StrictMaybe UnitInterval
_d :: HKD StrictMaybe UnitInterval
_d :: forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Aurum._d
    , HKD StrictMaybe Nonce
_extraEntropy :: HKD StrictMaybe Nonce
_extraEntropy :: forall (f :: * -> *) era. PParams' f era -> HKD f Nonce
Aurum._extraEntropy
    , HKD StrictMaybe ProtVer
_protocolVersion :: HKD StrictMaybe ProtVer
_protocolVersion :: forall (f :: * -> *) era. PParams' f era -> HKD f ProtVer
Aurum._protocolVersion
    , HKD StrictMaybe Coin
_minPoolCost :: HKD StrictMaybe Coin
_minPoolCost :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Aurum._minPoolCost
    , HKD StrictMaybe Coin
_coinsPerUTxOWord :: HKD StrictMaybe Coin
_coinsPerUTxOWord :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Aurum._coinsPerUTxOWord
    , HKD StrictMaybe (Map Language CostModel)
_costmdls :: HKD StrictMaybe (Map Language CostModel)
_costmdls :: forall (f :: * -> *) era.
PParams' f era -> HKD f (Map Language CostModel)
Aurum._costmdls
    , HKD StrictMaybe Prices
_prices :: HKD StrictMaybe Prices
_prices :: forall (f :: * -> *) era. PParams' f era -> HKD f Prices
Aurum._prices
    , HKD StrictMaybe ExUnits
_maxTxExUnits :: HKD StrictMaybe ExUnits
_maxTxExUnits :: forall (f :: * -> *) era. PParams' f era -> HKD f ExUnits
Aurum._maxTxExUnits
    , HKD StrictMaybe ExUnits
_maxBlockExUnits :: HKD StrictMaybe ExUnits
_maxBlockExUnits :: forall (f :: * -> *) era. PParams' f era -> HKD f ExUnits
Aurum._maxBlockExUnits
    , HKD StrictMaybe Natural
_maxValSize :: HKD StrictMaybe Natural
_maxValSize :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._maxValSize
    , HKD StrictMaybe Natural
_collateralPercentage :: HKD StrictMaybe Natural
_collateralPercentage :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._collateralPercentage
    , HKD StrictMaybe Natural
_maxCollateralInputs :: HKD StrictMaybe Natural
_maxCollateralInputs :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._maxCollateralInputs
    } =
    ProtocolParametersUpdate :: Maybe (Natural, Natural)
-> Maybe Rational
-> Maybe (Maybe OptimumNonce)
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Entropic
-> Maybe Entropic
-> Maybe Entropic
-> Maybe Entropic
-> Maybe EpochNo
-> Maybe Natural
-> Maybe Rational
-> Maybe Rational
-> Maybe Rational
-> Maybe Entropic
-> Map AnyZerepochScriptVersion CostModel
-> Maybe ExecutionUnitPrices
-> Maybe ExecutionUnits
-> Maybe ExecutionUnits
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> ProtocolParametersUpdate
ProtocolParametersUpdate {
      protocolUpdateProtocolVersion :: Maybe (Natural, Natural)
protocolUpdateProtocolVersion     = (\(Ledger.ProtVer Natural
a Natural
b) -> (Natural
a,Natural
b)) (ProtVer -> (Natural, Natural))
-> Maybe ProtVer -> Maybe (Natural, Natural)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                          StrictMaybe ProtVer -> Maybe ProtVer
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe ProtVer
HKD StrictMaybe ProtVer
_protocolVersion
    , protocolUpdateDecentralization :: Maybe Rational
protocolUpdateDecentralization    = UnitInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational (UnitInterval -> Rational) -> Maybe UnitInterval -> Maybe Rational
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe UnitInterval -> Maybe UnitInterval
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe UnitInterval
HKD StrictMaybe UnitInterval
_d
    , protocolUpdateExtraOptimumEntropy :: Maybe (Maybe OptimumNonce)
protocolUpdateExtraOptimumEntropy   = Nonce -> Maybe OptimumNonce
fromLedgerNonce (Nonce -> Maybe OptimumNonce)
-> Maybe Nonce -> Maybe (Maybe OptimumNonce)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe Nonce -> Maybe Nonce
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Nonce
HKD StrictMaybe Nonce
_extraEntropy
    , protocolUpdateMaxBlockHeaderSize :: Maybe Natural
protocolUpdateMaxBlockHeaderSize  = StrictMaybe Natural -> Maybe Natural
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Natural
HKD StrictMaybe Natural
_maxBHSize
    , protocolUpdateMaxBlockBodySize :: Maybe Natural
protocolUpdateMaxBlockBodySize    = StrictMaybe Natural -> Maybe Natural
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Natural
HKD StrictMaybe Natural
_maxBBSize
    , protocolUpdateMaxTxSize :: Maybe Natural
protocolUpdateMaxTxSize           = StrictMaybe Natural -> Maybe Natural
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Natural
HKD StrictMaybe Natural
_maxTxSize
    , protocolUpdateTxFeeFixed :: Maybe Natural
protocolUpdateTxFeeFixed          = StrictMaybe Natural -> Maybe Natural
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Natural
HKD StrictMaybe Natural
_minfeeB
    , protocolUpdateTxFeePerByte :: Maybe Natural
protocolUpdateTxFeePerByte        = StrictMaybe Natural -> Maybe Natural
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Natural
HKD StrictMaybe Natural
_minfeeA
    , protocolUpdateMinUTxOValue :: Maybe Entropic
protocolUpdateMinUTxOValue        = Maybe Entropic
forall a. Maybe a
Nothing
    , protocolUpdateStakeAddressDeposit :: Maybe Entropic
protocolUpdateStakeAddressDeposit = Coin -> Entropic
fromSophieEntropic (Coin -> Entropic) -> Maybe Coin -> Maybe Entropic
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe Coin -> Maybe Coin
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Coin
HKD StrictMaybe Coin
_keyDeposit
    , protocolUpdateStakePoolDeposit :: Maybe Entropic
protocolUpdateStakePoolDeposit    = Coin -> Entropic
fromSophieEntropic (Coin -> Entropic) -> Maybe Coin -> Maybe Entropic
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe Coin -> Maybe Coin
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Coin
HKD StrictMaybe Coin
_poolDeposit
    , protocolUpdateMinPoolCost :: Maybe Entropic
protocolUpdateMinPoolCost         = Coin -> Entropic
fromSophieEntropic (Coin -> Entropic) -> Maybe Coin -> Maybe Entropic
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe Coin -> Maybe Coin
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Coin
HKD StrictMaybe Coin
_minPoolCost
    , protocolUpdatePoolRetireMaxEpoch :: Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch  = StrictMaybe EpochNo -> Maybe EpochNo
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe EpochNo
HKD StrictMaybe EpochNo
_eMax
    , protocolUpdateStakePoolTargetNum :: Maybe Natural
protocolUpdateStakePoolTargetNum  = StrictMaybe Natural -> Maybe Natural
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Natural
HKD StrictMaybe Natural
_nOpt
    , protocolUpdatePoolPledgeInfluence :: Maybe Rational
protocolUpdatePoolPledgeInfluence = NonNegativeInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational (NonNegativeInterval -> Rational)
-> Maybe NonNegativeInterval -> Maybe Rational
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe NonNegativeInterval -> Maybe NonNegativeInterval
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe NonNegativeInterval
HKD StrictMaybe NonNegativeInterval
_a0
    , protocolUpdateMonetaryExpansion :: Maybe Rational
protocolUpdateMonetaryExpansion   = UnitInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational (UnitInterval -> Rational) -> Maybe UnitInterval -> Maybe Rational
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe UnitInterval -> Maybe UnitInterval
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe UnitInterval
HKD StrictMaybe UnitInterval
_rho
    , protocolUpdateTreasuryCut :: Maybe Rational
protocolUpdateTreasuryCut         = UnitInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational (UnitInterval -> Rational) -> Maybe UnitInterval -> Maybe Rational
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe UnitInterval -> Maybe UnitInterval
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe UnitInterval
HKD StrictMaybe UnitInterval
_tau
    , protocolUpdateUTxOCostPerWord :: Maybe Entropic
protocolUpdateUTxOCostPerWord     = Coin -> Entropic
fromSophieEntropic (Coin -> Entropic) -> Maybe Coin -> Maybe Entropic
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe Coin -> Maybe Coin
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Coin
HKD StrictMaybe Coin
_coinsPerUTxOWord
    , protocolUpdateCostModels :: Map AnyZerepochScriptVersion CostModel
protocolUpdateCostModels          = Map AnyZerepochScriptVersion CostModel
-> (Map Language CostModel
    -> Map AnyZerepochScriptVersion CostModel)
-> Maybe (Map Language CostModel)
-> Map AnyZerepochScriptVersion CostModel
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Map AnyZerepochScriptVersion CostModel
forall a. Monoid a => a
mempty Map Language CostModel -> Map AnyZerepochScriptVersion CostModel
fromAurumCostModels
                                               (StrictMaybe (Map Language CostModel)
-> Maybe (Map Language CostModel)
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe (Map Language CostModel)
HKD StrictMaybe (Map Language CostModel)
_costmdls)
    , protocolUpdatePrices :: Maybe ExecutionUnitPrices
protocolUpdatePrices              = Prices -> ExecutionUnitPrices
fromAurumPrices (Prices -> ExecutionUnitPrices)
-> Maybe Prices -> Maybe ExecutionUnitPrices
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe Prices -> Maybe Prices
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Prices
HKD StrictMaybe Prices
_prices
    , protocolUpdateMaxTxExUnits :: Maybe ExecutionUnits
protocolUpdateMaxTxExUnits        = ExUnits -> ExecutionUnits
fromAurumExUnits (ExUnits -> ExecutionUnits)
-> Maybe ExUnits -> Maybe ExecutionUnits
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe ExUnits -> Maybe ExUnits
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe ExUnits
HKD StrictMaybe ExUnits
_maxTxExUnits
    , protocolUpdateMaxBlockExUnits :: Maybe ExecutionUnits
protocolUpdateMaxBlockExUnits     = ExUnits -> ExecutionUnits
fromAurumExUnits (ExUnits -> ExecutionUnits)
-> Maybe ExUnits -> Maybe ExecutionUnits
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                                            StrictMaybe ExUnits -> Maybe ExUnits
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe ExUnits
HKD StrictMaybe ExUnits
_maxBlockExUnits
    , protocolUpdateMaxValueSize :: Maybe Natural
protocolUpdateMaxValueSize        = StrictMaybe Natural -> Maybe Natural
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Natural
HKD StrictMaybe Natural
_maxValSize
    , protocolUpdateCollateralPercent :: Maybe Natural
protocolUpdateCollateralPercent   = StrictMaybe Natural -> Maybe Natural
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Natural
HKD StrictMaybe Natural
_collateralPercentage
    , protocolUpdateMaxCollateralInputs :: Maybe Natural
protocolUpdateMaxCollateralInputs = StrictMaybe Natural -> Maybe Natural
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe Natural
HKD StrictMaybe Natural
_maxCollateralInputs
    }


-- ----------------------------------------------------------------------------
-- Conversion functions: protocol paramaters to ledger types
--

--TODO: this has to be a Maybe or Either for some of the parameter validation.
-- Both parameters that must be present or absent in specific eras,
-- and parameter values that need validation, such as the Rational values
toLedgerPParams
  :: SophieBasedEra era
  -> ProtocolParameters
  -> Ledger.PParams (SophieLedgerEra era)
toLedgerPParams :: SophieBasedEra era
-> ProtocolParameters -> PParams (SophieLedgerEra era)
toLedgerPParams SophieBasedEra era
SophieBasedEraSophie = ProtocolParameters -> PParams (SophieLedgerEra era)
forall ledgerera. ProtocolParameters -> PParams ledgerera
toSophiePParams
toLedgerPParams SophieBasedEra era
SophieBasedEraEvie = ProtocolParameters -> PParams (SophieLedgerEra era)
forall ledgerera. ProtocolParameters -> PParams ledgerera
toSophiePParams
toLedgerPParams SophieBasedEra era
SophieBasedEraJen    = ProtocolParameters -> PParams (SophieLedgerEra era)
forall ledgerera. ProtocolParameters -> PParams ledgerera
toSophiePParams
toLedgerPParams SophieBasedEra era
SophieBasedEraAurum  = ProtocolParameters -> PParams (SophieLedgerEra era)
forall ledgerera. ProtocolParameters -> PParams ledgerera
toAurumPParams

toSophiePParams :: ProtocolParameters -> Sophie.PParams ledgerera
toSophiePParams :: ProtocolParameters -> PParams ledgerera
toSophiePParams ProtocolParameters {
                   (Natural, Natural)
protocolParamProtocolVersion :: (Natural, Natural)
protocolParamProtocolVersion :: ProtocolParameters -> (Natural, Natural)
protocolParamProtocolVersion,
                   Rational
protocolParamDecentralization :: Rational
protocolParamDecentralization :: ProtocolParameters -> Rational
protocolParamDecentralization,
                   Maybe OptimumNonce
protocolParamExtraOptimumEntropy :: Maybe OptimumNonce
protocolParamExtraOptimumEntropy :: ProtocolParameters -> Maybe OptimumNonce
protocolParamExtraOptimumEntropy,
                   Natural
protocolParamMaxBlockHeaderSize :: Natural
protocolParamMaxBlockHeaderSize :: ProtocolParameters -> Natural
protocolParamMaxBlockHeaderSize,
                   Natural
protocolParamMaxBlockBodySize :: Natural
protocolParamMaxBlockBodySize :: ProtocolParameters -> Natural
protocolParamMaxBlockBodySize,
                   Natural
protocolParamMaxTxSize :: Natural
protocolParamMaxTxSize :: ProtocolParameters -> Natural
protocolParamMaxTxSize,
                   Natural
protocolParamTxFeeFixed :: Natural
protocolParamTxFeeFixed :: ProtocolParameters -> Natural
protocolParamTxFeeFixed,
                   Natural
protocolParamTxFeePerByte :: Natural
protocolParamTxFeePerByte :: ProtocolParameters -> Natural
protocolParamTxFeePerByte,
                   protocolParamMinUTxOValue :: ProtocolParameters -> Maybe Entropic
protocolParamMinUTxOValue = Just Entropic
minUTxOValue,
                   Entropic
protocolParamStakeAddressDeposit :: Entropic
protocolParamStakeAddressDeposit :: ProtocolParameters -> Entropic
protocolParamStakeAddressDeposit,
                   Entropic
protocolParamStakePoolDeposit :: Entropic
protocolParamStakePoolDeposit :: ProtocolParameters -> Entropic
protocolParamStakePoolDeposit,
                   Entropic
protocolParamMinPoolCost :: Entropic
protocolParamMinPoolCost :: ProtocolParameters -> Entropic
protocolParamMinPoolCost,
                   EpochNo
protocolParamPoolRetireMaxEpoch :: EpochNo
protocolParamPoolRetireMaxEpoch :: ProtocolParameters -> EpochNo
protocolParamPoolRetireMaxEpoch,
                   Natural
protocolParamStakePoolTargetNum :: Natural
protocolParamStakePoolTargetNum :: ProtocolParameters -> Natural
protocolParamStakePoolTargetNum,
                   Rational
protocolParamPoolPledgeInfluence :: Rational
protocolParamPoolPledgeInfluence :: ProtocolParameters -> Rational
protocolParamPoolPledgeInfluence,
                   Rational
protocolParamMonetaryExpansion :: Rational
protocolParamMonetaryExpansion :: ProtocolParameters -> Rational
protocolParamMonetaryExpansion,
                   Rational
protocolParamTreasuryCut :: Rational
protocolParamTreasuryCut :: ProtocolParameters -> Rational
protocolParamTreasuryCut
                 } =
   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
Sophie.PParams
     { _protocolVersion :: HKD Identity ProtVer
Sophie._protocolVersion
                             = let (Natural
maj, Natural
sentry) = (Natural, Natural)
protocolParamProtocolVersion
                                in Natural -> Natural -> ProtVer
Ledger.ProtVer Natural
maj Natural
sentry
     , _d :: HKD Identity UnitInterval
Sophie._d            = UnitInterval -> Maybe UnitInterval -> UnitInterval
forall a. a -> Maybe a -> a
fromMaybe
                                 (String -> UnitInterval
forall a. HasCallStack => String -> a
error String
"toAurumPParams: invalid Decentralization value")
                                 (Rational -> Maybe UnitInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational Rational
protocolParamDecentralization)
     , _extraEntropy :: HKD Identity Nonce
Sophie._extraEntropy = Maybe OptimumNonce -> Nonce
toLedgerNonce Maybe OptimumNonce
protocolParamExtraOptimumEntropy
     , _maxBHSize :: HKD Identity Natural
Sophie._maxBHSize    = Natural
HKD Identity Natural
protocolParamMaxBlockHeaderSize
     , _maxBBSize :: HKD Identity Natural
Sophie._maxBBSize    = Natural
HKD Identity Natural
protocolParamMaxBlockBodySize
     , _maxTxSize :: HKD Identity Natural
Sophie._maxTxSize    = Natural
HKD Identity Natural
protocolParamMaxTxSize
     , _minfeeB :: HKD Identity Natural
Sophie._minfeeB      = Natural
HKD Identity Natural
protocolParamTxFeeFixed
     , _minfeeA :: HKD Identity Natural
Sophie._minfeeA      = Natural
HKD Identity Natural
protocolParamTxFeePerByte
     , _minUTxOValue :: HKD Identity Coin
Sophie._minUTxOValue = Entropic -> Coin
toSophieEntropic Entropic
minUTxOValue
     , _keyDeposit :: HKD Identity Coin
Sophie._keyDeposit   = Entropic -> Coin
toSophieEntropic Entropic
protocolParamStakeAddressDeposit
     , _poolDeposit :: HKD Identity Coin
Sophie._poolDeposit  = Entropic -> Coin
toSophieEntropic Entropic
protocolParamStakePoolDeposit
     , _minPoolCost :: HKD Identity Coin
Sophie._minPoolCost  = Entropic -> Coin
toSophieEntropic Entropic
protocolParamMinPoolCost
     , _eMax :: HKD Identity EpochNo
Sophie._eMax         = EpochNo
HKD Identity EpochNo
protocolParamPoolRetireMaxEpoch
     , _nOpt :: HKD Identity Natural
Sophie._nOpt         = Natural
HKD Identity Natural
protocolParamStakePoolTargetNum
     , _a0 :: HKD Identity NonNegativeInterval
Sophie._a0           = NonNegativeInterval
-> Maybe NonNegativeInterval -> NonNegativeInterval
forall a. a -> Maybe a -> a
fromMaybe
                                 (String -> NonNegativeInterval
forall a. HasCallStack => String -> a
error String
"toAurumPParams: invalid PoolPledgeInfluence value")
                                 (Rational -> Maybe NonNegativeInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational Rational
protocolParamPoolPledgeInfluence)
     , _rho :: HKD Identity UnitInterval
Sophie._rho          = UnitInterval -> Maybe UnitInterval -> UnitInterval
forall a. a -> Maybe a -> a
fromMaybe
                                 (String -> UnitInterval
forall a. HasCallStack => String -> a
error String
"toAurumPParams: invalid MonetaryExpansion value")
                                 (Rational -> Maybe UnitInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational Rational
protocolParamMonetaryExpansion)
     , _tau :: HKD Identity UnitInterval
Sophie._tau          = UnitInterval -> Maybe UnitInterval -> UnitInterval
forall a. a -> Maybe a -> a
fromMaybe
                                 (String -> UnitInterval
forall a. HasCallStack => String -> a
error String
"toAurumPParams: invalid TreasuryCut value")
                                 (Rational -> Maybe UnitInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational Rational
protocolParamTreasuryCut)
     }
toSophiePParams ProtocolParameters { protocolParamMinUTxOValue :: ProtocolParameters -> Maybe Entropic
protocolParamMinUTxOValue = Maybe Entropic
Nothing } =
  String -> PParams ledgerera
forall a. HasCallStack => String -> a
error String
"toSophiePParams: must specify protocolParamMinUTxOValue"

toAurumPParams :: ProtocolParameters -> Aurum.PParams ledgerera
toAurumPParams :: ProtocolParameters -> PParams ledgerera
toAurumPParams ProtocolParameters {
                   (Natural, Natural)
protocolParamProtocolVersion :: (Natural, Natural)
protocolParamProtocolVersion :: ProtocolParameters -> (Natural, Natural)
protocolParamProtocolVersion,
                   Rational
protocolParamDecentralization :: Rational
protocolParamDecentralization :: ProtocolParameters -> Rational
protocolParamDecentralization,
                   Maybe OptimumNonce
protocolParamExtraOptimumEntropy :: Maybe OptimumNonce
protocolParamExtraOptimumEntropy :: ProtocolParameters -> Maybe OptimumNonce
protocolParamExtraOptimumEntropy,
                   Natural
protocolParamMaxBlockHeaderSize :: Natural
protocolParamMaxBlockHeaderSize :: ProtocolParameters -> Natural
protocolParamMaxBlockHeaderSize,
                   Natural
protocolParamMaxBlockBodySize :: Natural
protocolParamMaxBlockBodySize :: ProtocolParameters -> Natural
protocolParamMaxBlockBodySize,
                   Natural
protocolParamMaxTxSize :: Natural
protocolParamMaxTxSize :: ProtocolParameters -> Natural
protocolParamMaxTxSize,
                   Natural
protocolParamTxFeeFixed :: Natural
protocolParamTxFeeFixed :: ProtocolParameters -> Natural
protocolParamTxFeeFixed,
                   Natural
protocolParamTxFeePerByte :: Natural
protocolParamTxFeePerByte :: ProtocolParameters -> Natural
protocolParamTxFeePerByte,
                   Entropic
protocolParamStakeAddressDeposit :: Entropic
protocolParamStakeAddressDeposit :: ProtocolParameters -> Entropic
protocolParamStakeAddressDeposit,
                   Entropic
protocolParamStakePoolDeposit :: Entropic
protocolParamStakePoolDeposit :: ProtocolParameters -> Entropic
protocolParamStakePoolDeposit,
                   Entropic
protocolParamMinPoolCost :: Entropic
protocolParamMinPoolCost :: ProtocolParameters -> Entropic
protocolParamMinPoolCost,
                   EpochNo
protocolParamPoolRetireMaxEpoch :: EpochNo
protocolParamPoolRetireMaxEpoch :: ProtocolParameters -> EpochNo
protocolParamPoolRetireMaxEpoch,
                   Natural
protocolParamStakePoolTargetNum :: Natural
protocolParamStakePoolTargetNum :: ProtocolParameters -> Natural
protocolParamStakePoolTargetNum,
                   Rational
protocolParamPoolPledgeInfluence :: Rational
protocolParamPoolPledgeInfluence :: ProtocolParameters -> Rational
protocolParamPoolPledgeInfluence,
                   Rational
protocolParamMonetaryExpansion :: Rational
protocolParamMonetaryExpansion :: ProtocolParameters -> Rational
protocolParamMonetaryExpansion,
                   Rational
protocolParamTreasuryCut :: Rational
protocolParamTreasuryCut :: ProtocolParameters -> Rational
protocolParamTreasuryCut,
                   protocolParamUTxOCostPerWord :: ProtocolParameters -> Maybe Entropic
protocolParamUTxOCostPerWord = Just Entropic
utxoCostPerWord,
                   Map AnyZerepochScriptVersion CostModel
protocolParamCostModels :: Map AnyZerepochScriptVersion CostModel
protocolParamCostModels :: ProtocolParameters -> Map AnyZerepochScriptVersion CostModel
protocolParamCostModels,
                   protocolParamPrices :: ProtocolParameters -> Maybe ExecutionUnitPrices
protocolParamPrices          = Just ExecutionUnitPrices
prices,
                   protocolParamMaxTxExUnits :: ProtocolParameters -> Maybe ExecutionUnits
protocolParamMaxTxExUnits    = Just ExecutionUnits
maxTxExUnits,
                   protocolParamMaxBlockExUnits :: ProtocolParameters -> Maybe ExecutionUnits
protocolParamMaxBlockExUnits = Just ExecutionUnits
maxBlockExUnits,
                   protocolParamMaxValueSize :: ProtocolParameters -> Maybe Natural
protocolParamMaxValueSize    = Just Natural
maxValueSize,
                   protocolParamCollateralPercent :: ProtocolParameters -> Maybe Natural
protocolParamCollateralPercent   = Just Natural
collateralPercentage,
                   protocolParamMaxCollateralInputs :: ProtocolParameters -> Maybe Natural
protocolParamMaxCollateralInputs = Just Natural
maxCollateralInputs
                 } =
    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
-> HKD f (Map Language CostModel)
-> HKD f Prices
-> HKD f ExUnits
-> HKD f ExUnits
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> PParams' f era
Aurum.PParams {
      _protocolVersion :: HKD Identity ProtVer
Aurum._protocolVersion
                           = let (Natural
maj, Natural
sentry) = (Natural, Natural)
protocolParamProtocolVersion
                              in Natural -> Natural -> ProtVer
Aurum.ProtVer Natural
maj Natural
sentry 
    , _d :: HKD Identity UnitInterval
Aurum._d            = UnitInterval -> Maybe UnitInterval -> UnitInterval
forall a. a -> Maybe a -> a
fromMaybe
                               (String -> UnitInterval
forall a. HasCallStack => String -> a
error String
"toAurumPParams: invalid Decentralization value")
                               (Rational -> Maybe UnitInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational Rational
protocolParamDecentralization)
    , _extraEntropy :: HKD Identity Nonce
Aurum._extraEntropy = Maybe OptimumNonce -> Nonce
toLedgerNonce Maybe OptimumNonce
protocolParamExtraOptimumEntropy
    , _maxBHSize :: HKD Identity Natural
Aurum._maxBHSize    = Natural
HKD Identity Natural
protocolParamMaxBlockHeaderSize
    , _maxBBSize :: HKD Identity Natural
Aurum._maxBBSize    = Natural
HKD Identity Natural
protocolParamMaxBlockBodySize
    , _maxTxSize :: HKD Identity Natural
Aurum._maxTxSize    = Natural
HKD Identity Natural
protocolParamMaxTxSize
    , _minfeeB :: HKD Identity Natural
Aurum._minfeeB      = Natural
HKD Identity Natural
protocolParamTxFeeFixed
    , _minfeeA :: HKD Identity Natural
Aurum._minfeeA      = Natural
HKD Identity Natural
protocolParamTxFeePerByte
    , _keyDeposit :: HKD Identity Coin
Aurum._keyDeposit   = Entropic -> Coin
toSophieEntropic Entropic
protocolParamStakeAddressDeposit
    , _poolDeposit :: HKD Identity Coin
Aurum._poolDeposit  = Entropic -> Coin
toSophieEntropic Entropic
protocolParamStakePoolDeposit
    , _minPoolCost :: HKD Identity Coin
Aurum._minPoolCost  = Entropic -> Coin
toSophieEntropic Entropic
protocolParamMinPoolCost
    , _eMax :: HKD Identity EpochNo
Aurum._eMax         = EpochNo
HKD Identity EpochNo
protocolParamPoolRetireMaxEpoch
    , _nOpt :: HKD Identity Natural
Aurum._nOpt         = Natural
HKD Identity Natural
protocolParamStakePoolTargetNum
    , _a0 :: HKD Identity NonNegativeInterval
Aurum._a0           = NonNegativeInterval
-> Maybe NonNegativeInterval -> NonNegativeInterval
forall a. a -> Maybe a -> a
fromMaybe
                               (String -> NonNegativeInterval
forall a. HasCallStack => String -> a
error String
"toAurumPParams: invalid PoolPledgeInfluence value")
                               (Rational -> Maybe NonNegativeInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational Rational
protocolParamPoolPledgeInfluence)
    , _rho :: HKD Identity UnitInterval
Aurum._rho          = UnitInterval -> Maybe UnitInterval -> UnitInterval
forall a. a -> Maybe a -> a
fromMaybe
                               (String -> UnitInterval
forall a. HasCallStack => String -> a
error String
"toAurumPParams: invalid MonetaryExpansion value")
                               (Rational -> Maybe UnitInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational Rational
protocolParamMonetaryExpansion)
    , _tau :: HKD Identity UnitInterval
Aurum._tau          = UnitInterval -> Maybe UnitInterval -> UnitInterval
forall a. a -> Maybe a -> a
fromMaybe
                               (String -> UnitInterval
forall a. HasCallStack => String -> a
error String
"toAurumPParams: invalid TreasuryCut value")
                               (Rational -> Maybe UnitInterval
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational Rational
protocolParamTreasuryCut)

      -- New params in Aurum:
    , _coinsPerUTxOWord :: HKD Identity Coin
Aurum._coinsPerUTxOWord  = Entropic -> Coin
toSophieEntropic Entropic
utxoCostPerWord
    , _costmdls :: HKD Identity (Map Language CostModel)
Aurum._costmdls        = Map AnyZerepochScriptVersion CostModel -> Map Language CostModel
toAurumCostModels Map AnyZerepochScriptVersion CostModel
protocolParamCostModels
    , _prices :: HKD Identity Prices
Aurum._prices          = Prices -> Maybe Prices -> Prices
forall a. a -> Maybe a -> a
fromMaybe
                                  (String -> Prices
forall a. HasCallStack => String -> a
error String
"toAurumPParams: invalid Price values")
                                  (ExecutionUnitPrices -> Maybe Prices
toAurumPrices ExecutionUnitPrices
prices)
    , _maxTxExUnits :: HKD Identity ExUnits
Aurum._maxTxExUnits    = ExecutionUnits -> ExUnits
toAurumExUnits ExecutionUnits
maxTxExUnits
    , _maxBlockExUnits :: HKD Identity ExUnits
Aurum._maxBlockExUnits = ExecutionUnits -> ExUnits
toAurumExUnits ExecutionUnits
maxBlockExUnits
    , _maxValSize :: HKD Identity Natural
Aurum._maxValSize      = Natural
HKD Identity Natural
maxValueSize
    , _collateralPercentage :: HKD Identity Natural
Aurum._collateralPercentage = Natural
HKD Identity Natural
collateralPercentage
    , _maxCollateralInputs :: HKD Identity Natural
Aurum._maxCollateralInputs  = Natural
HKD Identity Natural
maxCollateralInputs
    }
toAurumPParams ProtocolParameters { protocolParamUTxOCostPerWord :: ProtocolParameters -> Maybe Entropic
protocolParamUTxOCostPerWord = Maybe Entropic
Nothing } =
  String -> PParams ledgerera
forall a. HasCallStack => String -> a
error String
"toAurumPParams: must specify protocolParamUTxOCostPerWord"
toAurumPParams ProtocolParameters { protocolParamPrices :: ProtocolParameters -> Maybe ExecutionUnitPrices
protocolParamPrices          = Maybe ExecutionUnitPrices
Nothing } =
  String -> PParams ledgerera
forall a. HasCallStack => String -> a
error String
"toAurumPParams: must specify protocolParamPrices"
toAurumPParams ProtocolParameters { protocolParamMaxTxExUnits :: ProtocolParameters -> Maybe ExecutionUnits
protocolParamMaxTxExUnits    = Maybe ExecutionUnits
Nothing } =
  String -> PParams ledgerera
forall a. HasCallStack => String -> a
error String
"toAurumPParams: must specify protocolParamMaxTxExUnits"
toAurumPParams ProtocolParameters { protocolParamMaxBlockExUnits :: ProtocolParameters -> Maybe ExecutionUnits
protocolParamMaxBlockExUnits = Maybe ExecutionUnits
Nothing } =
  String -> PParams ledgerera
forall a. HasCallStack => String -> a
error String
"toAurumPParams: must specify protocolParamMaxBlockExUnits"
toAurumPParams ProtocolParameters { protocolParamMaxValueSize :: ProtocolParameters -> Maybe Natural
protocolParamMaxValueSize    = Maybe Natural
Nothing } =
    String -> PParams ledgerera
forall a. HasCallStack => String -> a
error String
"toAurumPParams: must specify protocolParamMaxValueSize"
toAurumPParams ProtocolParameters { protocolParamCollateralPercent :: ProtocolParameters -> Maybe Natural
protocolParamCollateralPercent = Maybe Natural
Nothing } =
    String -> PParams ledgerera
forall a. HasCallStack => String -> a
error String
"toAurumPParams: must specify protocolParamCollateralPercent"
toAurumPParams ProtocolParameters { protocolParamMaxCollateralInputs :: ProtocolParameters -> Maybe Natural
protocolParamMaxCollateralInputs = Maybe Natural
Nothing } =
    String -> PParams ledgerera
forall a. HasCallStack => String -> a
error String
"toAurumPParams: must specify protocolParamMaxCollateralInputs"


-- ----------------------------------------------------------------------------
-- Conversion functions: protocol paramaters from ledger types
--

fromLedgerPParams
  :: SophieBasedEra era
  -> Ledger.PParams (SophieLedgerEra era)
  -> ProtocolParameters
fromLedgerPParams :: SophieBasedEra era
-> PParams (SophieLedgerEra era) -> ProtocolParameters
fromLedgerPParams SophieBasedEra era
SophieBasedEraSophie = PParams (SophieLedgerEra era) -> ProtocolParameters
forall ledgerera. PParams ledgerera -> ProtocolParameters
fromSophiePParams
fromLedgerPParams SophieBasedEra era
SophieBasedEraEvie = PParams (SophieLedgerEra era) -> ProtocolParameters
forall ledgerera. PParams ledgerera -> ProtocolParameters
fromSophiePParams
fromLedgerPParams SophieBasedEra era
SophieBasedEraJen    = PParams (SophieLedgerEra era) -> ProtocolParameters
forall ledgerera. PParams ledgerera -> ProtocolParameters
fromSophiePParams
fromLedgerPParams SophieBasedEra era
SophieBasedEraAurum  = PParams (SophieLedgerEra era) -> ProtocolParameters
forall ledgerera. PParams ledgerera -> ProtocolParameters
fromAurumPParams


fromSophiePParams :: Sophie.PParams ledgerera
                   -> ProtocolParameters
fromSophiePParams :: PParams ledgerera -> ProtocolParameters
fromSophiePParams
    Sophie.PParams {
      HKD Identity Natural
_minfeeA :: HKD Identity Natural
_minfeeA :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._minfeeA
    , HKD Identity Natural
_minfeeB :: HKD Identity Natural
_minfeeB :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._minfeeB
    , HKD Identity Natural
_maxBBSize :: HKD Identity Natural
_maxBBSize :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._maxBBSize
    , HKD Identity Natural
_maxTxSize :: HKD Identity Natural
_maxTxSize :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._maxTxSize
    , HKD Identity Natural
_maxBHSize :: HKD Identity Natural
_maxBHSize :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._maxBHSize
    , HKD Identity Coin
_keyDeposit :: HKD Identity Coin
_keyDeposit :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Sophie._keyDeposit
    , HKD Identity Coin
_poolDeposit :: HKD Identity Coin
_poolDeposit :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Sophie._poolDeposit
    , HKD Identity EpochNo
_eMax :: HKD Identity EpochNo
_eMax :: forall (f :: * -> *) era. PParams' f era -> HKD f EpochNo
Sophie._eMax
    , HKD Identity Natural
_nOpt :: HKD Identity Natural
_nOpt :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._nOpt
    , HKD Identity NonNegativeInterval
_a0 :: HKD Identity NonNegativeInterval
_a0 :: forall (f :: * -> *) era.
PParams' f era -> HKD f NonNegativeInterval
Sophie._a0
    , HKD Identity UnitInterval
_rho :: HKD Identity UnitInterval
_rho :: forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Sophie._rho
    , HKD Identity UnitInterval
_tau :: HKD Identity UnitInterval
_tau :: forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Sophie._tau
    , HKD Identity UnitInterval
_d :: HKD Identity UnitInterval
_d :: forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Sophie._d
    , HKD Identity Nonce
_extraEntropy :: HKD Identity Nonce
_extraEntropy :: forall (f :: * -> *) era. PParams' f era -> HKD f Nonce
Sophie._extraEntropy
    , HKD Identity ProtVer
_protocolVersion :: HKD Identity ProtVer
_protocolVersion :: forall (f :: * -> *) era. PParams' f era -> HKD f ProtVer
Sophie._protocolVersion
    , HKD Identity Coin
_minUTxOValue :: HKD Identity Coin
_minUTxOValue :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Sophie._minUTxOValue
    , HKD Identity Coin
_minPoolCost :: HKD Identity Coin
_minPoolCost :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Sophie._minPoolCost
    } =
    ProtocolParameters :: (Natural, Natural)
-> Rational
-> Maybe OptimumNonce
-> Natural
-> Natural
-> Natural
-> Natural
-> Natural
-> Maybe Entropic
-> Entropic
-> Entropic
-> Entropic
-> EpochNo
-> Natural
-> Rational
-> Rational
-> Rational
-> Maybe Entropic
-> Map AnyZerepochScriptVersion CostModel
-> Maybe ExecutionUnitPrices
-> Maybe ExecutionUnits
-> Maybe ExecutionUnits
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> ProtocolParameters
ProtocolParameters {
      protocolParamProtocolVersion :: (Natural, Natural)
protocolParamProtocolVersion     = (\(Ledger.ProtVer Natural
a Natural
b) -> (Natural
a,Natural
b))
                                           ProtVer
HKD Identity ProtVer
_protocolVersion
    , protocolParamDecentralization :: Rational
protocolParamDecentralization    = UnitInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational UnitInterval
HKD Identity UnitInterval
_d
    , protocolParamExtraOptimumEntropy :: Maybe OptimumNonce
protocolParamExtraOptimumEntropy   = Nonce -> Maybe OptimumNonce
fromLedgerNonce Nonce
HKD Identity Nonce
_extraEntropy
    , protocolParamMaxBlockHeaderSize :: Natural
protocolParamMaxBlockHeaderSize  = Natural
HKD Identity Natural
_maxBHSize
    , protocolParamMaxBlockBodySize :: Natural
protocolParamMaxBlockBodySize    = Natural
HKD Identity Natural
_maxBBSize
    , protocolParamMaxTxSize :: Natural
protocolParamMaxTxSize           = Natural
HKD Identity Natural
_maxTxSize
    , protocolParamTxFeeFixed :: Natural
protocolParamTxFeeFixed          = Natural
HKD Identity Natural
_minfeeB
    , protocolParamTxFeePerByte :: Natural
protocolParamTxFeePerByte        = Natural
HKD Identity Natural
_minfeeA
    , protocolParamMinUTxOValue :: Maybe Entropic
protocolParamMinUTxOValue        = Entropic -> Maybe Entropic
forall a. a -> Maybe a
Just (Coin -> Entropic
fromSophieEntropic Coin
HKD Identity Coin
_minUTxOValue)
    , protocolParamStakeAddressDeposit :: Entropic
protocolParamStakeAddressDeposit = Coin -> Entropic
fromSophieEntropic Coin
HKD Identity Coin
_keyDeposit
    , protocolParamStakePoolDeposit :: Entropic
protocolParamStakePoolDeposit    = Coin -> Entropic
fromSophieEntropic Coin
HKD Identity Coin
_poolDeposit
    , protocolParamMinPoolCost :: Entropic
protocolParamMinPoolCost         = Coin -> Entropic
fromSophieEntropic Coin
HKD Identity Coin
_minPoolCost
    , protocolParamPoolRetireMaxEpoch :: EpochNo
protocolParamPoolRetireMaxEpoch  = EpochNo
HKD Identity EpochNo
_eMax
    , protocolParamStakePoolTargetNum :: Natural
protocolParamStakePoolTargetNum  = Natural
HKD Identity Natural
_nOpt
    , protocolParamPoolPledgeInfluence :: Rational
protocolParamPoolPledgeInfluence = NonNegativeInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational NonNegativeInterval
HKD Identity NonNegativeInterval
_a0
    , protocolParamMonetaryExpansion :: Rational
protocolParamMonetaryExpansion   = UnitInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational UnitInterval
HKD Identity UnitInterval
_rho
    , protocolParamTreasuryCut :: Rational
protocolParamTreasuryCut         = UnitInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational UnitInterval
HKD Identity UnitInterval
_tau
    , protocolParamUTxOCostPerWord :: Maybe Entropic
protocolParamUTxOCostPerWord     = Maybe Entropic
forall a. Maybe a
Nothing
    , protocolParamCostModels :: Map AnyZerepochScriptVersion CostModel
protocolParamCostModels          = Map AnyZerepochScriptVersion CostModel
forall k a. Map k a
Map.empty
    , protocolParamPrices :: Maybe ExecutionUnitPrices
protocolParamPrices              = Maybe ExecutionUnitPrices
forall a. Maybe a
Nothing
    , protocolParamMaxTxExUnits :: Maybe ExecutionUnits
protocolParamMaxTxExUnits        = Maybe ExecutionUnits
forall a. Maybe a
Nothing
    , protocolParamMaxBlockExUnits :: Maybe ExecutionUnits
protocolParamMaxBlockExUnits     = Maybe ExecutionUnits
forall a. Maybe a
Nothing
    , protocolParamMaxValueSize :: Maybe Natural
protocolParamMaxValueSize        = Maybe Natural
forall a. Maybe a
Nothing
    , protocolParamCollateralPercent :: Maybe Natural
protocolParamCollateralPercent   = Maybe Natural
forall a. Maybe a
Nothing
    , protocolParamMaxCollateralInputs :: Maybe Natural
protocolParamMaxCollateralInputs = Maybe Natural
forall a. Maybe a
Nothing
    }


fromAurumPParams :: Aurum.PParams ledgerera -> ProtocolParameters
fromAurumPParams :: PParams ledgerera -> ProtocolParameters
fromAurumPParams
    Aurum.PParams {
      HKD Identity Natural
_minfeeA :: HKD Identity Natural
_minfeeA :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._minfeeA
    , HKD Identity Natural
_minfeeB :: HKD Identity Natural
_minfeeB :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._minfeeB
    , HKD Identity Natural
_maxBBSize :: HKD Identity Natural
_maxBBSize :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._maxBBSize
    , HKD Identity Natural
_maxTxSize :: HKD Identity Natural
_maxTxSize :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._maxTxSize
    , HKD Identity Natural
_maxBHSize :: HKD Identity Natural
_maxBHSize :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._maxBHSize
    , HKD Identity Coin
_keyDeposit :: HKD Identity Coin
_keyDeposit :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Aurum._keyDeposit
    , HKD Identity Coin
_poolDeposit :: HKD Identity Coin
_poolDeposit :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Aurum._poolDeposit
    , HKD Identity EpochNo
_eMax :: HKD Identity EpochNo
_eMax :: forall (f :: * -> *) era. PParams' f era -> HKD f EpochNo
Aurum._eMax
    , HKD Identity Natural
_nOpt :: HKD Identity Natural
_nOpt :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._nOpt
    , HKD Identity NonNegativeInterval
_a0 :: HKD Identity NonNegativeInterval
_a0 :: forall (f :: * -> *) era.
PParams' f era -> HKD f NonNegativeInterval
Aurum._a0
    , HKD Identity UnitInterval
_rho :: HKD Identity UnitInterval
_rho :: forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Aurum._rho
    , HKD Identity UnitInterval
_tau :: HKD Identity UnitInterval
_tau :: forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Aurum._tau
    , HKD Identity UnitInterval
_d :: HKD Identity UnitInterval
_d :: forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Aurum._d
    , HKD Identity Nonce
_extraEntropy :: HKD Identity Nonce
_extraEntropy :: forall (f :: * -> *) era. PParams' f era -> HKD f Nonce
Aurum._extraEntropy
    , HKD Identity ProtVer
_protocolVersion :: HKD Identity ProtVer
_protocolVersion :: forall (f :: * -> *) era. PParams' f era -> HKD f ProtVer
Aurum._protocolVersion
    , HKD Identity Coin
_minPoolCost :: HKD Identity Coin
_minPoolCost :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Aurum._minPoolCost
    , HKD Identity Coin
_coinsPerUTxOWord :: HKD Identity Coin
_coinsPerUTxOWord :: forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Aurum._coinsPerUTxOWord
    , HKD Identity (Map Language CostModel)
_costmdls :: HKD Identity (Map Language CostModel)
_costmdls :: forall (f :: * -> *) era.
PParams' f era -> HKD f (Map Language CostModel)
Aurum._costmdls
    , HKD Identity Prices
_prices :: HKD Identity Prices
_prices :: forall (f :: * -> *) era. PParams' f era -> HKD f Prices
Aurum._prices
    , HKD Identity ExUnits
_maxTxExUnits :: HKD Identity ExUnits
_maxTxExUnits :: forall (f :: * -> *) era. PParams' f era -> HKD f ExUnits
Aurum._maxTxExUnits
    , HKD Identity ExUnits
_maxBlockExUnits :: HKD Identity ExUnits
_maxBlockExUnits :: forall (f :: * -> *) era. PParams' f era -> HKD f ExUnits
Aurum._maxBlockExUnits
    , HKD Identity Natural
_maxValSize :: HKD Identity Natural
_maxValSize :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._maxValSize
    , HKD Identity Natural
_collateralPercentage :: HKD Identity Natural
_collateralPercentage :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._collateralPercentage
    , HKD Identity Natural
_maxCollateralInputs :: HKD Identity Natural
_maxCollateralInputs :: forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._maxCollateralInputs
    } =
    ProtocolParameters :: (Natural, Natural)
-> Rational
-> Maybe OptimumNonce
-> Natural
-> Natural
-> Natural
-> Natural
-> Natural
-> Maybe Entropic
-> Entropic
-> Entropic
-> Entropic
-> EpochNo
-> Natural
-> Rational
-> Rational
-> Rational
-> Maybe Entropic
-> Map AnyZerepochScriptVersion CostModel
-> Maybe ExecutionUnitPrices
-> Maybe ExecutionUnits
-> Maybe ExecutionUnits
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> ProtocolParameters
ProtocolParameters {
      protocolParamProtocolVersion :: (Natural, Natural)
protocolParamProtocolVersion     = (\(Ledger.ProtVer Natural
a Natural
b) -> (Natural
a,Natural
b))
                                           ProtVer
HKD Identity ProtVer
_protocolVersion
    , protocolParamDecentralization :: Rational
protocolParamDecentralization    = UnitInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational UnitInterval
HKD Identity UnitInterval
_d
    , protocolParamExtraOptimumEntropy :: Maybe OptimumNonce
protocolParamExtraOptimumEntropy   = Nonce -> Maybe OptimumNonce
fromLedgerNonce Nonce
HKD Identity Nonce
_extraEntropy
    , protocolParamMaxBlockHeaderSize :: Natural
protocolParamMaxBlockHeaderSize  = Natural
HKD Identity Natural
_maxBHSize
    , protocolParamMaxBlockBodySize :: Natural
protocolParamMaxBlockBodySize    = Natural
HKD Identity Natural
_maxBBSize
    , protocolParamMaxTxSize :: Natural
protocolParamMaxTxSize           = Natural
HKD Identity Natural
_maxTxSize
    , protocolParamTxFeeFixed :: Natural
protocolParamTxFeeFixed          = Natural
HKD Identity Natural
_minfeeB
    , protocolParamTxFeePerByte :: Natural
protocolParamTxFeePerByte        = Natural
HKD Identity Natural
_minfeeA
    , protocolParamMinUTxOValue :: Maybe Entropic
protocolParamMinUTxOValue        = Maybe Entropic
forall a. Maybe a
Nothing
    , protocolParamStakeAddressDeposit :: Entropic
protocolParamStakeAddressDeposit = Coin -> Entropic
fromSophieEntropic Coin
HKD Identity Coin
_keyDeposit
    , protocolParamStakePoolDeposit :: Entropic
protocolParamStakePoolDeposit    = Coin -> Entropic
fromSophieEntropic Coin
HKD Identity Coin
_poolDeposit
    , protocolParamMinPoolCost :: Entropic
protocolParamMinPoolCost         = Coin -> Entropic
fromSophieEntropic Coin
HKD Identity Coin
_minPoolCost
    , protocolParamPoolRetireMaxEpoch :: EpochNo
protocolParamPoolRetireMaxEpoch  = EpochNo
HKD Identity EpochNo
_eMax
    , protocolParamStakePoolTargetNum :: Natural
protocolParamStakePoolTargetNum  = Natural
HKD Identity Natural
_nOpt
    , protocolParamPoolPledgeInfluence :: Rational
protocolParamPoolPledgeInfluence = NonNegativeInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational NonNegativeInterval
HKD Identity NonNegativeInterval
_a0
    , protocolParamMonetaryExpansion :: Rational
protocolParamMonetaryExpansion   = UnitInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational UnitInterval
HKD Identity UnitInterval
_rho
    , protocolParamTreasuryCut :: Rational
protocolParamTreasuryCut         = UnitInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational UnitInterval
HKD Identity UnitInterval
_tau
    , protocolParamUTxOCostPerWord :: Maybe Entropic
protocolParamUTxOCostPerWord     = Entropic -> Maybe Entropic
forall a. a -> Maybe a
Just (Coin -> Entropic
fromSophieEntropic Coin
HKD Identity Coin
_coinsPerUTxOWord)
    , protocolParamCostModels :: Map AnyZerepochScriptVersion CostModel
protocolParamCostModels          = Map Language CostModel -> Map AnyZerepochScriptVersion CostModel
fromAurumCostModels Map Language CostModel
HKD Identity (Map Language CostModel)
_costmdls
    , protocolParamPrices :: Maybe ExecutionUnitPrices
protocolParamPrices              = ExecutionUnitPrices -> Maybe ExecutionUnitPrices
forall a. a -> Maybe a
Just (Prices -> ExecutionUnitPrices
fromAurumPrices Prices
HKD Identity Prices
_prices)
    , protocolParamMaxTxExUnits :: Maybe ExecutionUnits
protocolParamMaxTxExUnits        = ExecutionUnits -> Maybe ExecutionUnits
forall a. a -> Maybe a
Just (ExUnits -> ExecutionUnits
fromAurumExUnits ExUnits
HKD Identity ExUnits
_maxTxExUnits)
    , protocolParamMaxBlockExUnits :: Maybe ExecutionUnits
protocolParamMaxBlockExUnits     = ExecutionUnits -> Maybe ExecutionUnits
forall a. a -> Maybe a
Just (ExUnits -> ExecutionUnits
fromAurumExUnits ExUnits
HKD Identity ExUnits
_maxBlockExUnits)
    , protocolParamMaxValueSize :: Maybe Natural
protocolParamMaxValueSize        = Natural -> Maybe Natural
forall a. a -> Maybe a
Just Natural
HKD Identity Natural
_maxValSize
    , protocolParamCollateralPercent :: Maybe Natural
protocolParamCollateralPercent   = Natural -> Maybe Natural
forall a. a -> Maybe a
Just Natural
HKD Identity Natural
_collateralPercentage
    , protocolParamMaxCollateralInputs :: Maybe Natural
protocolParamMaxCollateralInputs = Natural -> Maybe Natural
forall a. a -> Maybe a
Just Natural
HKD Identity Natural
_maxCollateralInputs
    }

data ProtocolParametersError =
    PParamsErrorMissingMinUTxoValue AnyBccEra
  | PParamsErrorMissingAurumProtocolParameter
  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
showList :: [ProtocolParametersError] -> ShowS
$cshowList :: [ProtocolParametersError] -> ShowS
show :: ProtocolParametersError -> String
$cshow :: ProtocolParametersError -> String
showsPrec :: Int -> ProtocolParametersError -> ShowS
$cshowsPrec :: Int -> ProtocolParametersError -> ShowS
Show

instance Error ProtocolParametersError where
  displayError :: ProtocolParametersError -> String
displayError (PParamsErrorMissingMinUTxoValue (AnyBccEra BccEra era
era)) =
   String
"The " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> BccEra era -> String
forall a. Show a => a -> String
show BccEra era
era String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" protocol parameters value is missing the following \
       \field: MinUTxoValue. Did you intend to use a " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> BccEra era -> String
forall a. Show a => a -> String
show BccEra era
era String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" protocol \
       \ parameters value?"
  displayError ProtocolParametersError
PParamsErrorMissingAurumProtocolParameter =
    String
"The Aurum era protocol parameters in use is missing one or more of the \
    \following fields: UTxOCostPerWord, CostModels, Prices, MaxTxExUnits, \
    \MaxBlockExUnits, MaxValueSize, CollateralPercent, MaxCollateralInputs. Did \
    \you intend to use an Aurum era protocol parameters value?"

checkProtocolParameters
  :: forall era. IsBccEra era
  => SophieBasedEra era
  -> ProtocolParameters
  -> Either ProtocolParametersError ()
checkProtocolParameters :: SophieBasedEra era
-> ProtocolParameters -> Either ProtocolParametersError ()
checkProtocolParameters SophieBasedEra era
sbe ProtocolParameters{Natural
Maybe Natural
Maybe ExecutionUnits
Maybe Entropic
Maybe ExecutionUnitPrices
Maybe OptimumNonce
Rational
(Natural, Natural)
Map AnyZerepochScriptVersion CostModel
EpochNo
Entropic
protocolParamMaxCollateralInputs :: Maybe Natural
protocolParamCollateralPercent :: Maybe Natural
protocolParamMaxValueSize :: Maybe Natural
protocolParamMaxBlockExUnits :: Maybe ExecutionUnits
protocolParamMaxTxExUnits :: Maybe ExecutionUnits
protocolParamPrices :: Maybe ExecutionUnitPrices
protocolParamCostModels :: Map AnyZerepochScriptVersion CostModel
protocolParamUTxOCostPerWord :: Maybe Entropic
protocolParamTreasuryCut :: Rational
protocolParamMonetaryExpansion :: Rational
protocolParamPoolPledgeInfluence :: Rational
protocolParamStakePoolTargetNum :: Natural
protocolParamPoolRetireMaxEpoch :: EpochNo
protocolParamMinPoolCost :: Entropic
protocolParamStakePoolDeposit :: Entropic
protocolParamStakeAddressDeposit :: Entropic
protocolParamMinUTxOValue :: Maybe Entropic
protocolParamTxFeePerByte :: Natural
protocolParamTxFeeFixed :: Natural
protocolParamMaxTxSize :: Natural
protocolParamMaxBlockBodySize :: Natural
protocolParamMaxBlockHeaderSize :: Natural
protocolParamExtraOptimumEntropy :: Maybe OptimumNonce
protocolParamDecentralization :: Rational
protocolParamProtocolVersion :: (Natural, Natural)
protocolParamMaxCollateralInputs :: ProtocolParameters -> Maybe Natural
protocolParamCollateralPercent :: ProtocolParameters -> Maybe Natural
protocolParamMaxValueSize :: ProtocolParameters -> Maybe Natural
protocolParamMaxBlockExUnits :: ProtocolParameters -> Maybe ExecutionUnits
protocolParamMaxTxExUnits :: ProtocolParameters -> Maybe ExecutionUnits
protocolParamPrices :: ProtocolParameters -> Maybe ExecutionUnitPrices
protocolParamCostModels :: ProtocolParameters -> Map AnyZerepochScriptVersion CostModel
protocolParamUTxOCostPerWord :: ProtocolParameters -> Maybe Entropic
protocolParamTreasuryCut :: ProtocolParameters -> Rational
protocolParamMonetaryExpansion :: ProtocolParameters -> Rational
protocolParamPoolPledgeInfluence :: ProtocolParameters -> Rational
protocolParamStakePoolTargetNum :: ProtocolParameters -> Natural
protocolParamPoolRetireMaxEpoch :: ProtocolParameters -> EpochNo
protocolParamMinPoolCost :: ProtocolParameters -> Entropic
protocolParamStakePoolDeposit :: ProtocolParameters -> Entropic
protocolParamStakeAddressDeposit :: ProtocolParameters -> Entropic
protocolParamMinUTxOValue :: ProtocolParameters -> Maybe Entropic
protocolParamTxFeePerByte :: ProtocolParameters -> Natural
protocolParamTxFeeFixed :: ProtocolParameters -> Natural
protocolParamMaxTxSize :: ProtocolParameters -> Natural
protocolParamMaxBlockBodySize :: ProtocolParameters -> Natural
protocolParamMaxBlockHeaderSize :: ProtocolParameters -> Natural
protocolParamExtraOptimumEntropy :: ProtocolParameters -> Maybe OptimumNonce
protocolParamDecentralization :: ProtocolParameters -> Rational
protocolParamProtocolVersion :: ProtocolParameters -> (Natural, Natural)
..} =
  case SophieBasedEra era
sbe of
    SophieBasedEra era
SophieBasedEraSophie -> Either ProtocolParametersError ()
checkMinUTxOVal
    SophieBasedEra era
SophieBasedEraEvie -> Either ProtocolParametersError ()
checkMinUTxOVal
    SophieBasedEra era
SophieBasedEraJen -> Either ProtocolParametersError ()
checkMinUTxOVal
    SophieBasedEra era
SophieBasedEraAurum -> Either ProtocolParametersError ()
checkAurumParams
 where
   era :: BccEra era
   era :: BccEra era
era = SophieBasedEra era -> BccEra era
forall era. SophieBasedEra era -> BccEra era
sophieBasedToBccEra SophieBasedEra era
sbe

   costPerWord :: Bool
costPerWord = Maybe Entropic -> Bool
forall a. Maybe a -> Bool
isJust Maybe Entropic
protocolParamUTxOCostPerWord
   cModel :: Bool
cModel = Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ Map AnyZerepochScriptVersion CostModel -> Bool
forall k a. Map k a -> Bool
Map.null Map AnyZerepochScriptVersion CostModel
protocolParamCostModels
   prices :: Bool
prices = Maybe ExecutionUnitPrices -> Bool
forall a. Maybe a -> Bool
isJust Maybe ExecutionUnitPrices
protocolParamPrices
   maxTxUnits :: Bool
maxTxUnits = Maybe ExecutionUnits -> Bool
forall a. Maybe a -> Bool
isJust Maybe ExecutionUnits
protocolParamMaxTxExUnits
   maxBlockExUnits :: Bool
maxBlockExUnits = Maybe ExecutionUnits -> Bool
forall a. Maybe a -> Bool
isJust Maybe ExecutionUnits
protocolParamMaxBlockExUnits
   maxValueSize :: Bool
maxValueSize = Maybe Natural -> Bool
forall a. Maybe a -> Bool
isJust Maybe Natural
protocolParamMaxValueSize
   collateralPercent :: Bool
collateralPercent = Maybe Natural -> Bool
forall a. Maybe a -> Bool
isJust Maybe Natural
protocolParamCollateralPercent
   maxCollateralInputs :: Bool
maxCollateralInputs = Maybe Natural -> Bool
forall a. Maybe a -> Bool
isJust Maybe Natural
protocolParamMaxCollateralInputs

   checkAurumParams :: Either ProtocolParametersError ()
   checkAurumParams :: Either ProtocolParametersError ()
checkAurumParams =
     if (Bool -> Bool) -> [Bool] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool
True) [ Bool
costPerWord
                      , Bool
cModel
                      , Bool
prices
                      , Bool
maxTxUnits
                      , Bool
maxBlockExUnits
                      , Bool
maxValueSize
                      , Bool
collateralPercent
                      , Bool
maxCollateralInputs
                      ]
     then () -> Either ProtocolParametersError ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     else ProtocolParametersError -> Either ProtocolParametersError ()
forall a b. a -> Either a b
Left ProtocolParametersError
PParamsErrorMissingAurumProtocolParameter

   checkMinUTxOVal :: Either ProtocolParametersError ()
   checkMinUTxOVal :: Either ProtocolParametersError ()
checkMinUTxOVal =
     if Maybe Entropic -> Bool
forall a. Maybe a -> Bool
isJust Maybe Entropic
protocolParamMinUTxOValue
     then () -> Either ProtocolParametersError ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     else ProtocolParametersError -> Either ProtocolParametersError ()
forall a b. a -> Either a b
Left (ProtocolParametersError -> Either ProtocolParametersError ())
-> (AnyBccEra -> ProtocolParametersError)
-> AnyBccEra
-> Either ProtocolParametersError ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AnyBccEra -> ProtocolParametersError
PParamsErrorMissingMinUTxoValue
               (AnyBccEra -> Either ProtocolParametersError ())
-> AnyBccEra -> Either ProtocolParametersError ()
forall a b. (a -> b) -> a -> b
$ BccEra era -> AnyBccEra
forall era. IsBccEra era => BccEra era -> AnyBccEra
AnyBccEra BccEra era
era