{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Cardano.Rpc.Server.Internal.UtxoRpc.Type.ProtocolParameters
( protocolParamsToUtxoRpcPParams
, pparamsUpdateToUtxoRpcPParams
, utxoRpcPParamsToProtocolParams
, utxoRpcProtocolVersionToProtVer
)
where
import Cardano.Api.Era
import Cardano.Api.Experimental.Era
import Cardano.Api.Ledger qualified as L
import Cardano.Api.Monad.Error
import Cardano.Rpc.Proto.Api.UtxoRpc.Query qualified as U5c
import Cardano.Rpc.Proto.Api.UtxoRpc.Query qualified as UtxoRpc
import Cardano.Rpc.Server.Internal.Orphans ()
import Cardano.Rpc.Server.Internal.UtxoRpc.Type.BigInt
import Cardano.Rpc.Server.Internal.UtxoRpc.Type.Rational
import Cardano.Ledger.Alonzo.PParams qualified as L
import Cardano.Ledger.Api qualified as L
import Cardano.Ledger.BaseTypes qualified as L
import Cardano.Ledger.Conway.Core qualified as L
import Cardano.Ledger.Conway.PParams qualified as L
import Cardano.Ledger.HKD qualified as L
import Cardano.Ledger.Plutus qualified as L
import RIO hiding (toList)
import Control.Error.Util (note)
import Data.Default
import Data.Map.Strict qualified as M
import Data.ProtoLens (defMessage)
import GHC.IsList
import Network.GRPC.Spec
protocolParamsToUtxoRpcPParams
:: forall era
. Era era
-> L.PParams (LedgerEra era)
-> Proto UtxoRpc.PParams
protocolParamsToUtxoRpcPParams :: forall era. Era era -> PParams (LedgerEra era) -> Proto PParams
protocolParamsToUtxoRpcPParams Era era
era PParams (LedgerEra era)
pparams =
Era era
-> (EraCommonConstraints era => Proto PParams) -> Proto PParams
forall era a. Era era -> (EraCommonConstraints era => a) -> a
obtainCommonConstraints Era era
era ((EraCommonConstraints era => Proto PParams) -> Proto PParams)
-> (EraCommonConstraints era => Proto PParams) -> Proto PParams
forall a b. (a -> b) -> a -> b
$
Proto PParams
forall a. Default a => a
def
Proto PParams -> (Proto PParams -> Proto PParams) -> Proto PParams
forall a b. a -> (a -> b) -> b
& [StrictMaybe (Proto PParams -> Proto PParams)]
-> Proto PParams -> Proto PParams
appSetters (forall (f :: * -> *) era.
(HKDFunctor f, ConwayEraPParams era) =>
(forall a. HKD f a -> StrictMaybe a)
-> PParamsHKD f era
-> [StrictMaybe (Proto PParams -> Proto PParams)]
pparamsFieldSetters @Identity a -> StrictMaybe a
HKD Identity a -> StrictMaybe a
forall a. a -> StrictMaybe a
forall a. HKD Identity a -> StrictMaybe a
L.SJust (PParams (LedgerEra era)
pparams PParams (LedgerEra era)
-> Getting
(PParamsHKD Identity (LedgerEra era))
(PParams (LedgerEra era))
(PParamsHKD Identity (LedgerEra era))
-> PParamsHKD Identity (LedgerEra era)
forall s a. s -> Getting a s a -> a
^. Getting
(PParamsHKD Identity (LedgerEra era))
(PParams (LedgerEra era))
(PParamsHKD Identity (LedgerEra era))
forall era (f :: * -> *).
Functor f =>
(PParamsHKD Identity era -> f (PParamsHKD Identity era))
-> PParams era -> f (PParams era)
L.ppLensHKD))
Proto PParams -> (Proto PParams -> Proto PParams) -> Proto PParams
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto PParams) (Proto ProtocolVersion)
forall (f :: * -> *) s a.
(Functor f, HasField s "protocolVersion" a) =>
LensLike' f s a
U5c.protocolVersion LensLike' Identity (Proto PParams) (Proto ProtocolVersion)
-> Proto ProtocolVersion -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ProtVer -> Proto ProtocolVersion
forall t s. Inject t s => t -> s
inject (PParams (LedgerEra era)
pparams PParams (LedgerEra era)
-> Getting ProtVer (PParams (LedgerEra era)) ProtVer -> ProtVer
forall s a. s -> Getting a s a -> a
^. Getting ProtVer (PParams (LedgerEra era)) ProtVer
forall era. EraPParams era => Lens' (PParams era) ProtVer
Lens' (PParams (LedgerEra era)) ProtVer
L.ppProtocolVersionL)
pparamsUpdateToUtxoRpcPParams
:: L.ConwayEraPParams era
=> L.PParamsUpdate era
-> Proto UtxoRpc.PParams
pparamsUpdateToUtxoRpcPParams :: forall era.
ConwayEraPParams era =>
PParamsUpdate era -> Proto PParams
pparamsUpdateToUtxoRpcPParams PParamsUpdate era
pparamsUpdate =
Proto PParams
forall msg. Message msg => msg
defMessage
Proto PParams -> (Proto PParams -> Proto PParams) -> Proto PParams
forall a b. a -> (a -> b) -> b
& [StrictMaybe (Proto PParams -> Proto PParams)]
-> Proto PParams -> Proto PParams
appSetters (forall (f :: * -> *) era.
(HKDFunctor f, ConwayEraPParams era) =>
(forall a. HKD f a -> StrictMaybe a)
-> PParamsHKD f era
-> [StrictMaybe (Proto PParams -> Proto PParams)]
pparamsFieldSetters @L.StrictMaybe StrictMaybe a -> StrictMaybe a
HKD StrictMaybe a -> StrictMaybe a
forall a. a -> a
forall a. HKD StrictMaybe a -> StrictMaybe a
id (PParamsUpdate era
pparamsUpdate PParamsUpdate era
-> Getting
(PParamsHKD StrictMaybe era)
(PParamsUpdate era)
(PParamsHKD StrictMaybe era)
-> PParamsHKD StrictMaybe era
forall s a. s -> Getting a s a -> a
^. Getting
(PParamsHKD StrictMaybe era)
(PParamsUpdate era)
(PParamsHKD StrictMaybe era)
forall era (f :: * -> *).
Functor f =>
(PParamsHKD StrictMaybe era -> f (PParamsHKD StrictMaybe era))
-> PParamsUpdate era -> f (PParamsUpdate era)
L.ppuLensHKD))
pparamsFieldSetters
:: forall f era
. (L.HKDFunctor f, L.ConwayEraPParams era)
=> (forall a. L.HKD f a -> L.StrictMaybe a)
-> L.PParamsHKD f era
-> [L.StrictMaybe (Proto UtxoRpc.PParams -> Proto UtxoRpc.PParams)]
pparamsFieldSetters :: forall (f :: * -> *) era.
(HKDFunctor f, ConwayEraPParams era) =>
(forall a. HKD f a -> StrictMaybe a)
-> PParamsHKD f era
-> [StrictMaybe (Proto PParams -> Proto PParams)]
pparamsFieldSetters forall a. HKD f a -> StrictMaybe a
extract PParamsHKD f era
pparams =
[ forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @L.CoinPerByte (forall era (f :: * -> *).
(BabbageEraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f CoinPerByte)
L.hkdCoinsPerUTxOByteL @era @f) StrictMaybe CoinPerByte
-> (CoinPerByte -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \CoinPerByte
value ->
LensLike' Identity (Proto PParams) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "coinsPerUtxoByte" a) =>
LensLike' f s a
U5c.coinsPerUtxoByte LensLike' Identity (Proto PParams) (Proto BigInt)
-> Proto BigInt -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Coin -> Proto BigInt
forall t s. Inject t s => t -> s
inject (CompactForm Coin -> Coin
forall a. Compactible a => CompactForm a -> a
L.fromCompact (CoinPerByte -> CompactForm Coin
L.unCoinPerByte CoinPerByte
value))
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @Word32 (forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Word32)
L.hkdMaxTxSizeL @era @f) StrictMaybe Word32
-> (Word32 -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Word32
value ->
LensLike' Identity (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "maxTxSize" a) =>
LensLike' f s a
U5c.maxTxSize LensLike' Identity (Proto PParams) Word64
-> Word64 -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word32 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
value
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @L.CoinPerByte (forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f CoinPerByte)
L.hkdTxFeePerByteL @era @f) StrictMaybe CoinPerByte
-> (CoinPerByte -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \CoinPerByte
value ->
LensLike' Identity (Proto PParams) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "minFeeCoefficient" a) =>
LensLike' f s a
U5c.minFeeCoefficient LensLike' Identity (Proto PParams) (Proto BigInt)
-> Proto BigInt -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Coin -> Proto BigInt
forall t s. Inject t s => t -> s
inject (CompactForm Coin -> Coin
forall a. Compactible a => CompactForm a -> a
L.fromCompact (CoinPerByte -> CompactForm Coin
L.unCoinPerByte CoinPerByte
value))
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @(L.CompactForm L.Coin) (forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f (CompactForm Coin))
L.hkdTxFeeFixedCompactL @era @f) StrictMaybe (CompactForm Coin)
-> (CompactForm Coin -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \CompactForm Coin
value ->
LensLike' Identity (Proto PParams) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "minFeeConstant" a) =>
LensLike' f s a
U5c.minFeeConstant LensLike' Identity (Proto PParams) (Proto BigInt)
-> Proto BigInt -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Coin -> Proto BigInt
forall t s. Inject t s => t -> s
inject (CompactForm Coin -> Coin
forall a. Compactible a => CompactForm a -> a
L.fromCompact CompactForm Coin
value)
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @Word32 (forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Word32)
L.hkdMaxBBSizeL @era @f) StrictMaybe Word32
-> (Word32 -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Word32
value ->
LensLike' Identity (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "maxBlockBodySize" a) =>
LensLike' f s a
U5c.maxBlockBodySize LensLike' Identity (Proto PParams) Word64
-> Word64 -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word32 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
value
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @Word16 (forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Word16)
L.hkdMaxBHSizeL @era @f) StrictMaybe Word16
-> (Word16 -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Word16
value ->
LensLike' Identity (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "maxBlockHeaderSize" a) =>
LensLike' f s a
U5c.maxBlockHeaderSize LensLike' Identity (Proto PParams) Word64
-> Word64 -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word16 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word16
value
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @(L.CompactForm L.Coin) (forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f (CompactForm Coin))
L.hkdKeyDepositCompactL @era @f) StrictMaybe (CompactForm Coin)
-> (CompactForm Coin -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \CompactForm Coin
value ->
LensLike' Identity (Proto PParams) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "stakeKeyDeposit" a) =>
LensLike' f s a
U5c.stakeKeyDeposit LensLike' Identity (Proto PParams) (Proto BigInt)
-> Proto BigInt -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Coin -> Proto BigInt
forall t s. Inject t s => t -> s
inject (CompactForm Coin -> Coin
forall a. Compactible a => CompactForm a -> a
L.fromCompact CompactForm Coin
value)
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @(L.CompactForm L.Coin) (forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f (CompactForm Coin))
L.hkdPoolDepositCompactL @era @f) StrictMaybe (CompactForm Coin)
-> (CompactForm Coin -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \CompactForm Coin
value ->
LensLike' Identity (Proto PParams) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "poolDeposit" a) =>
LensLike' f s a
U5c.poolDeposit LensLike' Identity (Proto PParams) (Proto BigInt)
-> Proto BigInt -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Coin -> Proto BigInt
forall t s. Inject t s => t -> s
inject (CompactForm Coin -> Coin
forall a. Compactible a => CompactForm a -> a
L.fromCompact CompactForm Coin
value)
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @L.EpochInterval (forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f EpochInterval)
L.hkdEMaxL @era @f) StrictMaybe EpochInterval
-> (EpochInterval -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \EpochInterval
value ->
LensLike' Identity (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "poolRetirementEpochBound" a) =>
LensLike' f s a
U5c.poolRetirementEpochBound LensLike' Identity (Proto PParams) Word64
-> Word64 -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word32 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (EpochInterval -> Word32
L.unEpochInterval EpochInterval
value)
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @Word16 (forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Word16)
L.hkdNOptL @era @f) StrictMaybe Word16
-> (Word16 -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Word16
value ->
LensLike' Identity (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "desiredNumberOfPools" a) =>
LensLike' f s a
U5c.desiredNumberOfPools LensLike' Identity (Proto PParams) Word64
-> Word64 -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word16 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word16
value
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @L.NonNegativeInterval (forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f NonNegativeInterval)
L.hkdA0L @era @f) StrictMaybe NonNegativeInterval
-> (NonNegativeInterval -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \NonNegativeInterval
value ->
LensLike' Identity (Proto PParams) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "poolInfluence" a) =>
LensLike' f s a
U5c.poolInfluence LensLike' Identity (Proto PParams) (Proto RationalNumber)
-> Proto RationalNumber -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Ratio Integer -> Proto RationalNumber
forall t s. Inject t s => t -> s
inject (NonNegativeInterval -> Ratio Integer
forall r. BoundedRational r => r -> Ratio Integer
L.unboundRational NonNegativeInterval
value)
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @L.UnitInterval (forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f UnitInterval)
L.hkdRhoL @era @f) StrictMaybe UnitInterval
-> (UnitInterval -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \UnitInterval
value ->
LensLike' Identity (Proto PParams) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "monetaryExpansion" a) =>
LensLike' f s a
U5c.monetaryExpansion LensLike' Identity (Proto PParams) (Proto RationalNumber)
-> Proto RationalNumber -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Ratio Integer -> Proto RationalNumber
forall t s. Inject t s => t -> s
inject (UnitInterval -> Ratio Integer
forall r. BoundedRational r => r -> Ratio Integer
L.unboundRational UnitInterval
value)
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @L.UnitInterval (forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f UnitInterval)
L.hkdTauL @era @f) StrictMaybe UnitInterval
-> (UnitInterval -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \UnitInterval
value ->
LensLike' Identity (Proto PParams) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "treasuryExpansion" a) =>
LensLike' f s a
U5c.treasuryExpansion LensLike' Identity (Proto PParams) (Proto RationalNumber)
-> Proto RationalNumber -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Ratio Integer -> Proto RationalNumber
forall t s. Inject t s => t -> s
inject (UnitInterval -> Ratio Integer
forall r. BoundedRational r => r -> Ratio Integer
L.unboundRational UnitInterval
value)
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @(L.CompactForm L.Coin) (forall era (f :: * -> *).
(EraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f (CompactForm Coin))
L.hkdMinPoolCostCompactL @era @f) StrictMaybe (CompactForm Coin)
-> (CompactForm Coin -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \CompactForm Coin
value ->
LensLike' Identity (Proto PParams) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "minPoolCost" a) =>
LensLike' f s a
U5c.minPoolCost LensLike' Identity (Proto PParams) (Proto BigInt)
-> Proto BigInt -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Coin -> Proto BigInt
forall t s. Inject t s => t -> s
inject (CompactForm Coin -> Coin
forall a. Compactible a => CompactForm a -> a
L.fromCompact CompactForm Coin
value)
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @Word32 (forall era (f :: * -> *).
(AlonzoEraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Word32)
L.hkdMaxValSizeL @era @f) StrictMaybe Word32
-> (Word32 -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Word32
value ->
LensLike' Identity (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "maxValueSize" a) =>
LensLike' f s a
U5c.maxValueSize LensLike' Identity (Proto PParams) Word64
-> Word64 -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word32 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
value
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @Word16 (forall era (f :: * -> *).
(AlonzoEraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Word16)
L.hkdCollateralPercentageL @era @f) StrictMaybe Word16
-> (Word16 -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Word16
value ->
LensLike' Identity (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "collateralPercentage" a) =>
LensLike' f s a
U5c.collateralPercentage LensLike' Identity (Proto PParams) Word64
-> Word64 -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word16 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word16
value
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @Word16 (forall era (f :: * -> *).
(AlonzoEraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Word16)
L.hkdMaxCollateralInputsL @era @f) StrictMaybe Word16
-> (Word16 -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Word16
value ->
LensLike' Identity (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "maxCollateralInputs" a) =>
LensLike' f s a
U5c.maxCollateralInputs LensLike' Identity (Proto PParams) Word64
-> Word64 -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word16 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word16
value
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @L.CostModels (forall era (f :: * -> *).
(AlonzoEraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f CostModels)
L.hkdCostModelsL @era @f) StrictMaybe CostModels
-> (CostModels -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \CostModels
value ->
LensLike' Identity (Proto PParams) (Proto CostModels)
forall (f :: * -> *) s a.
(Functor f, HasField s "costModels" a) =>
LensLike' f s a
U5c.costModels LensLike' Identity (Proto PParams) (Proto CostModels)
-> Proto CostModels -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ CostModels -> Proto CostModels
costModelsToUtxoRpcCostModels CostModels
value
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @L.Prices (forall era (f :: * -> *).
(AlonzoEraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Prices)
L.hkdPricesL @era @f) StrictMaybe Prices
-> (Prices -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Prices
prices ->
(LensLike' Identity (Proto PParams) (Proto ExPrices)
forall (f :: * -> *) s a.
(Functor f, HasField s "prices" a) =>
LensLike' f s a
U5c.prices LensLike' Identity (Proto PParams) (Proto ExPrices)
-> ((Proto RationalNumber -> Identity (Proto RationalNumber))
-> Proto ExPrices -> Identity (Proto ExPrices))
-> LensLike' Identity (Proto PParams) (Proto RationalNumber)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto RationalNumber -> Identity (Proto RationalNumber))
-> Proto ExPrices -> Identity (Proto ExPrices)
forall (f :: * -> *) s a.
(Functor f, HasField s "steps" a) =>
LensLike' f s a
U5c.steps LensLike' Identity (Proto PParams) (Proto RationalNumber)
-> Proto RationalNumber -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Ratio Integer -> Proto RationalNumber
forall t s. Inject t s => t -> s
inject (NonNegativeInterval -> Ratio Integer
forall r. BoundedRational r => r -> Ratio Integer
L.unboundRational (Prices -> NonNegativeInterval
L.prSteps Prices
prices)))
(Proto PParams -> Proto PParams)
-> (Proto PParams -> Proto PParams)
-> Proto PParams
-> Proto PParams
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (LensLike' Identity (Proto PParams) (Proto ExPrices)
forall (f :: * -> *) s a.
(Functor f, HasField s "prices" a) =>
LensLike' f s a
U5c.prices LensLike' Identity (Proto PParams) (Proto ExPrices)
-> ((Proto RationalNumber -> Identity (Proto RationalNumber))
-> Proto ExPrices -> Identity (Proto ExPrices))
-> LensLike' Identity (Proto PParams) (Proto RationalNumber)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto RationalNumber -> Identity (Proto RationalNumber))
-> Proto ExPrices -> Identity (Proto ExPrices)
forall (f :: * -> *) s a.
(Functor f, HasField s "memory" a) =>
LensLike' f s a
U5c.memory LensLike' Identity (Proto PParams) (Proto RationalNumber)
-> Proto RationalNumber -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Ratio Integer -> Proto RationalNumber
forall t s. Inject t s => t -> s
inject (NonNegativeInterval -> Ratio Integer
forall r. BoundedRational r => r -> Ratio Integer
L.unboundRational (Prices -> NonNegativeInterval
L.prMem Prices
prices)))
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @L.ExUnits (forall era (f :: * -> *).
(AlonzoEraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f ExUnits)
L.hkdMaxTxExUnitsL @era @f) StrictMaybe ExUnits
-> (ExUnits -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \ExUnits
value ->
LensLike' Identity (Proto PParams) (Proto ExUnits)
forall (f :: * -> *) s a.
(Functor f, HasField s "maxExecutionUnitsPerTransaction" a) =>
LensLike' f s a
U5c.maxExecutionUnitsPerTransaction LensLike' Identity (Proto PParams) (Proto ExUnits)
-> Proto ExUnits -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ExUnits -> Proto ExUnits
forall t s. Inject t s => t -> s
inject ExUnits
value
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @L.ExUnits (forall era (f :: * -> *).
(AlonzoEraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f ExUnits)
L.hkdMaxBlockExUnitsL @era @f) StrictMaybe ExUnits
-> (ExUnits -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \ExUnits
value ->
LensLike' Identity (Proto PParams) (Proto ExUnits)
forall (f :: * -> *) s a.
(Functor f, HasField s "maxExecutionUnitsPerBlock" a) =>
LensLike' f s a
U5c.maxExecutionUnitsPerBlock LensLike' Identity (Proto PParams) (Proto ExUnits)
-> Proto ExUnits -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ExUnits -> Proto ExUnits
forall t s. Inject t s => t -> s
inject ExUnits
value
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @L.NonNegativeInterval (forall era (f :: * -> *).
(ConwayEraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f NonNegativeInterval)
L.hkdMinFeeRefScriptCostPerByteL @era @f) StrictMaybe NonNegativeInterval
-> (NonNegativeInterval -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \NonNegativeInterval
value ->
LensLike' Identity (Proto PParams) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "minFeeScriptRefCostPerByte" a) =>
LensLike' f s a
U5c.minFeeScriptRefCostPerByte LensLike' Identity (Proto PParams) (Proto RationalNumber)
-> Proto RationalNumber -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Ratio Integer -> Proto RationalNumber
forall t s. Inject t s => t -> s
inject (NonNegativeInterval -> Ratio Integer
forall r. BoundedRational r => r -> Ratio Integer
L.unboundRational NonNegativeInterval
value)
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @L.PoolVotingThresholds (forall era (f :: * -> *).
(ConwayEraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f PoolVotingThresholds)
L.hkdPoolVotingThresholdsL @era @f) StrictMaybe PoolVotingThresholds
-> (PoolVotingThresholds -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \PoolVotingThresholds
poolVotingThresholds ->
LensLike' Identity (Proto PParams) (Proto VotingThresholds)
forall (f :: * -> *) s a.
(Functor f, HasField s "poolVotingThresholds" a) =>
LensLike' f s a
U5c.poolVotingThresholds LensLike' Identity (Proto PParams) (Proto VotingThresholds)
-> (([Proto RationalNumber] -> Identity [Proto RationalNumber])
-> Proto VotingThresholds -> Identity (Proto VotingThresholds))
-> ([Proto RationalNumber] -> Identity [Proto RationalNumber])
-> Proto PParams
-> Identity (Proto PParams)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Proto RationalNumber] -> Identity [Proto RationalNumber])
-> Proto VotingThresholds -> Identity (Proto VotingThresholds)
forall (f :: * -> *) s a.
(Functor f, HasField s "thresholds" a) =>
LensLike' f s a
U5c.thresholds
(([Proto RationalNumber] -> Identity [Proto RationalNumber])
-> Proto PParams -> Identity (Proto PParams))
-> [Proto RationalNumber] -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ( Ratio Integer -> Proto RationalNumber
forall t s. Inject t s => t -> s
inject (Ratio Integer -> Proto RationalNumber)
-> (UnitInterval -> Ratio Integer)
-> UnitInterval
-> Proto RationalNumber
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnitInterval -> Ratio Integer
forall r. BoundedRational r => r -> Ratio Integer
L.unboundRational
(UnitInterval -> Proto RationalNumber)
-> [UnitInterval] -> [Proto RationalNumber]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [ PoolVotingThresholds
poolVotingThresholds PoolVotingThresholds
-> Getting UnitInterval PoolVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval PoolVotingThresholds UnitInterval
Lens' PoolVotingThresholds UnitInterval
L.pvtMotionNoConfidenceL
, PoolVotingThresholds
poolVotingThresholds PoolVotingThresholds
-> Getting UnitInterval PoolVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval PoolVotingThresholds UnitInterval
Lens' PoolVotingThresholds UnitInterval
L.pvtCommitteeNormalL
, PoolVotingThresholds
poolVotingThresholds PoolVotingThresholds
-> Getting UnitInterval PoolVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval PoolVotingThresholds UnitInterval
Lens' PoolVotingThresholds UnitInterval
L.pvtCommitteeNoConfidenceL
, PoolVotingThresholds
poolVotingThresholds PoolVotingThresholds
-> Getting UnitInterval PoolVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval PoolVotingThresholds UnitInterval
Lens' PoolVotingThresholds UnitInterval
L.pvtHardForkInitiationL
, PoolVotingThresholds
poolVotingThresholds PoolVotingThresholds
-> Getting UnitInterval PoolVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval PoolVotingThresholds UnitInterval
Lens' PoolVotingThresholds UnitInterval
L.pvtPPSecurityGroupL
]
)
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @L.DRepVotingThresholds (forall era (f :: * -> *).
(ConwayEraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f DRepVotingThresholds)
L.hkdDRepVotingThresholdsL @era @f) StrictMaybe DRepVotingThresholds
-> (DRepVotingThresholds -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \DRepVotingThresholds
drepVotingThresholds ->
LensLike' Identity (Proto PParams) (Proto VotingThresholds)
forall (f :: * -> *) s a.
(Functor f, HasField s "drepVotingThresholds" a) =>
LensLike' f s a
U5c.drepVotingThresholds LensLike' Identity (Proto PParams) (Proto VotingThresholds)
-> (([Proto RationalNumber] -> Identity [Proto RationalNumber])
-> Proto VotingThresholds -> Identity (Proto VotingThresholds))
-> ([Proto RationalNumber] -> Identity [Proto RationalNumber])
-> Proto PParams
-> Identity (Proto PParams)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Proto RationalNumber] -> Identity [Proto RationalNumber])
-> Proto VotingThresholds -> Identity (Proto VotingThresholds)
forall (f :: * -> *) s a.
(Functor f, HasField s "thresholds" a) =>
LensLike' f s a
U5c.thresholds
(([Proto RationalNumber] -> Identity [Proto RationalNumber])
-> Proto PParams -> Identity (Proto PParams))
-> [Proto RationalNumber] -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ( Ratio Integer -> Proto RationalNumber
forall t s. Inject t s => t -> s
inject (Ratio Integer -> Proto RationalNumber)
-> (UnitInterval -> Ratio Integer)
-> UnitInterval
-> Proto RationalNumber
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnitInterval -> Ratio Integer
forall r. BoundedRational r => r -> Ratio Integer
L.unboundRational
(UnitInterval -> Proto RationalNumber)
-> [UnitInterval] -> [Proto RationalNumber]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [ DRepVotingThresholds
drepVotingThresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtMotionNoConfidenceL
, DRepVotingThresholds
drepVotingThresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtCommitteeNormalL
, DRepVotingThresholds
drepVotingThresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtCommitteeNoConfidenceL
, DRepVotingThresholds
drepVotingThresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtUpdateToConstitutionL
, DRepVotingThresholds
drepVotingThresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtHardForkInitiationL
, DRepVotingThresholds
drepVotingThresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtPPNetworkGroupL
, DRepVotingThresholds
drepVotingThresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtPPEconomicGroupL
, DRepVotingThresholds
drepVotingThresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtPPTechnicalGroupL
, DRepVotingThresholds
drepVotingThresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtPPGovGroupL
, DRepVotingThresholds
drepVotingThresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtTreasuryWithdrawalL
]
)
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @Word16 (forall era (f :: * -> *).
(ConwayEraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f Word16)
L.hkdCommitteeMinSizeL @era @f) StrictMaybe Word16
-> (Word16 -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Word16
value ->
LensLike' Identity (Proto PParams) Word32
forall (f :: * -> *) s a.
(Functor f, HasField s "minCommitteeSize" a) =>
LensLike' f s a
U5c.minCommitteeSize LensLike' Identity (Proto PParams) Word32
-> Word32 -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word16 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word16
value
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @L.EpochInterval (forall era (f :: * -> *).
(ConwayEraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f EpochInterval)
L.hkdCommitteeMaxTermLengthL @era @f) StrictMaybe EpochInterval
-> (EpochInterval -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \EpochInterval
value ->
LensLike' Identity (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "committeeTermLimit" a) =>
LensLike' f s a
U5c.committeeTermLimit LensLike' Identity (Proto PParams) Word64
-> Word64 -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word32 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (EpochInterval -> Word32
L.unEpochInterval EpochInterval
value)
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @L.EpochInterval (forall era (f :: * -> *).
(ConwayEraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f EpochInterval)
L.hkdGovActionLifetimeL @era @f) StrictMaybe EpochInterval
-> (EpochInterval -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \EpochInterval
value ->
LensLike' Identity (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "governanceActionValidityPeriod" a) =>
LensLike' f s a
U5c.governanceActionValidityPeriod LensLike' Identity (Proto PParams) Word64
-> Word64 -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word32 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (EpochInterval -> Word32
L.unEpochInterval EpochInterval
value)
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @(L.CompactForm L.Coin) (forall era (f :: * -> *).
(ConwayEraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f (CompactForm Coin))
L.hkdGovActionDepositCompactL @era @f) StrictMaybe (CompactForm Coin)
-> (CompactForm Coin -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \CompactForm Coin
value ->
LensLike' Identity (Proto PParams) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "governanceActionDeposit" a) =>
LensLike' f s a
U5c.governanceActionDeposit LensLike' Identity (Proto PParams) (Proto BigInt)
-> Proto BigInt -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Coin -> Proto BigInt
forall t s. Inject t s => t -> s
inject (CompactForm Coin -> Coin
forall a. Compactible a => CompactForm a -> a
L.fromCompact CompactForm Coin
value)
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @(L.CompactForm L.Coin) (forall era (f :: * -> *).
(ConwayEraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f (CompactForm Coin))
L.hkdDRepDepositCompactL @era @f) StrictMaybe (CompactForm Coin)
-> (CompactForm Coin -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \CompactForm Coin
value ->
LensLike' Identity (Proto PParams) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "drepDeposit" a) =>
LensLike' f s a
U5c.drepDeposit LensLike' Identity (Proto PParams) (Proto BigInt)
-> Proto BigInt -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Coin -> Proto BigInt
forall t s. Inject t s => t -> s
inject (CompactForm Coin -> Coin
forall a. Compactible a => CompactForm a -> a
L.fromCompact CompactForm Coin
value)
, forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field @L.EpochInterval (forall era (f :: * -> *).
(ConwayEraPParams era, HKDFunctor f) =>
Lens' (PParamsHKD f era) (HKD f EpochInterval)
L.hkdDRepActivityL @era @f) StrictMaybe EpochInterval
-> (EpochInterval -> Proto PParams -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \EpochInterval
value ->
LensLike' Identity (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "drepInactivityPeriod" a) =>
LensLike' f s a
U5c.drepInactivityPeriod LensLike' Identity (Proto PParams) Word64
-> Word64 -> Proto PParams -> Proto PParams
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word32 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (EpochInterval -> Word32
L.unEpochInterval EpochInterval
value)
]
where
field :: forall a. Lens' (L.PParamsHKD f era) (L.HKD f a) -> L.StrictMaybe a
field :: forall a. Lens' (PParamsHKD f era) (HKD f a) -> StrictMaybe a
field Lens' (PParamsHKD f era) (HKD f a)
fieldLens = forall a. HKD f a -> StrictMaybe a
extract @a (PParamsHKD f era
pparams PParamsHKD f era
-> Getting (HKD f a) (PParamsHKD f era) (HKD f a) -> HKD f a
forall s a. s -> Getting a s a -> a
^. Getting (HKD f a) (PParamsHKD f era) (HKD f a)
Lens' (PParamsHKD f era) (HKD f a)
fieldLens)
appSetters
:: [L.StrictMaybe (Proto UtxoRpc.PParams -> Proto UtxoRpc.PParams)]
-> Proto UtxoRpc.PParams
-> Proto UtxoRpc.PParams
appSetters :: [StrictMaybe (Proto PParams -> Proto PParams)]
-> Proto PParams -> Proto PParams
appSetters [StrictMaybe (Proto PParams -> Proto PParams)]
setters Proto PParams
message = (Proto PParams
-> StrictMaybe (Proto PParams -> Proto PParams) -> Proto PParams)
-> Proto PParams
-> [StrictMaybe (Proto PParams -> Proto PParams)]
-> Proto PParams
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\Proto PParams
acc -> Proto PParams
-> ((Proto PParams -> Proto PParams) -> Proto PParams)
-> StrictMaybe (Proto PParams -> Proto PParams)
-> Proto PParams
forall a b. a -> (b -> a) -> StrictMaybe b -> a
L.strictMaybe Proto PParams
acc ((Proto PParams -> Proto PParams) -> Proto PParams -> Proto PParams
forall a b. (a -> b) -> a -> b
$ Proto PParams
acc)) Proto PParams
message [StrictMaybe (Proto PParams -> Proto PParams)]
setters
costModelsToUtxoRpcCostModels :: L.CostModels -> Proto UtxoRpc.CostModels
costModelsToUtxoRpcCostModels :: CostModels -> Proto CostModels
costModelsToUtxoRpcCostModels CostModels
costModels = do
let costModelParams :: Map L.Language [Int64]
costModelParams :: Map Language [Int64]
costModelParams = CostModel -> [Int64]
L.getCostModelParams (CostModel -> [Int64])
-> Map Language CostModel -> Map Language [Int64]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CostModels -> Map Language CostModel
L.costModelsValid CostModels
costModels
costModelFor :: L.Language -> Maybe (Proto UtxoRpc.CostModel)
costModelFor :: Language -> Maybe (Proto CostModel)
costModelFor Language
language =
Language -> Map Language [Int64] -> Maybe [Int64]
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Language
language Map Language [Int64]
costModelParams Maybe [Int64]
-> ([Int64] -> Proto CostModel) -> Maybe (Proto CostModel)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \[Int64]
values -> Proto CostModel
forall msg. Message msg => msg
defMessage Proto CostModel
-> (Proto CostModel -> Proto CostModel) -> Proto CostModel
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto CostModel) [Int64]
forall (f :: * -> *) s a.
(Functor f, HasField s "values" a) =>
LensLike' f s a
U5c.values LensLike' Identity (Proto CostModel) [Int64]
-> [Int64] -> Proto CostModel -> Proto CostModel
forall s t a b. ASetter s t a b -> b -> s -> t
.~ [Int64]
values
Proto CostModels
forall msg. Message msg => msg
defMessage
Proto CostModels
-> (Proto CostModels -> Proto CostModels) -> Proto CostModels
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto CostModels) (Maybe (Proto CostModel))
forall (f :: * -> *) s a.
(Functor f, HasField s "maybe'plutusV1" a) =>
LensLike' f s a
U5c.maybe'plutusV1 LensLike' Identity (Proto CostModels) (Maybe (Proto CostModel))
-> Maybe (Proto CostModel) -> Proto CostModels -> Proto CostModels
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Language -> Maybe (Proto CostModel)
costModelFor Language
L.PlutusV1
Proto CostModels
-> (Proto CostModels -> Proto CostModels) -> Proto CostModels
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto CostModels) (Maybe (Proto CostModel))
forall (f :: * -> *) s a.
(Functor f, HasField s "maybe'plutusV2" a) =>
LensLike' f s a
U5c.maybe'plutusV2 LensLike' Identity (Proto CostModels) (Maybe (Proto CostModel))
-> Maybe (Proto CostModel) -> Proto CostModels -> Proto CostModels
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Language -> Maybe (Proto CostModel)
costModelFor Language
L.PlutusV2
Proto CostModels
-> (Proto CostModels -> Proto CostModels) -> Proto CostModels
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto CostModels) (Maybe (Proto CostModel))
forall (f :: * -> *) s a.
(Functor f, HasField s "maybe'plutusV3" a) =>
LensLike' f s a
U5c.maybe'plutusV3 LensLike' Identity (Proto CostModels) (Maybe (Proto CostModel))
-> Maybe (Proto CostModel) -> Proto CostModels -> Proto CostModels
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Language -> Maybe (Proto CostModel)
costModelFor Language
L.PlutusV3
Proto CostModels
-> (Proto CostModels -> Proto CostModels) -> Proto CostModels
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto CostModels) (Maybe (Proto CostModel))
forall (f :: * -> *) s a.
(Functor f, HasField s "maybe'plutusV4" a) =>
LensLike' f s a
U5c.maybe'plutusV4 LensLike' Identity (Proto CostModels) (Maybe (Proto CostModel))
-> Maybe (Proto CostModel) -> Proto CostModels -> Proto CostModels
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Language -> Maybe (Proto CostModel)
costModelFor Language
L.PlutusV4
utxoRpcPParamsToProtocolParams
:: Era era
-> Proto UtxoRpc.PParams
-> Either String (L.PParams (ShelleyLedgerEra era))
utxoRpcPParamsToProtocolParams :: forall era.
Era era
-> Proto PParams -> Either String (PParams (ShelleyLedgerEra era))
utxoRpcPParamsToProtocolParams Era era
era Proto PParams
pp = Era era
-> (EraCommonConstraints era =>
Either String (PParams (ShelleyLedgerEra era)))
-> Either String (PParams (ShelleyLedgerEra era))
forall era a. Era era -> (EraCommonConstraints era => a) -> a
obtainCommonConstraints Era era
era ((EraCommonConstraints era =>
Either String (PParams (ShelleyLedgerEra era)))
-> Either String (PParams (ShelleyLedgerEra era)))
-> (EraCommonConstraints era =>
Either String (PParams (ShelleyLedgerEra era)))
-> Either String (PParams (ShelleyLedgerEra era))
forall a b. (a -> b) -> a -> b
$ do
PParams (LedgerEra era)
forall a. Default a => a
def
PParams (LedgerEra era)
-> (PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era)))
-> Either String (PParams (LedgerEra era))
forall a b. a -> (a -> b) -> b
& [PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era))]
-> PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era))
forall (m :: * -> *) a. Monad m => [a -> m a] -> a -> m a
appFuns
[ \PParams (LedgerEra era)
r -> do
coinsPerUtxoByte <-
Proto PParams
pp Proto PParams
-> Getting (Maybe Integer) (Proto PParams) (Maybe Integer)
-> Maybe Integer
forall s a. s -> Getting a s a -> a
^. LensLike' (Const (Maybe Integer)) (Proto PParams) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "coinsPerUtxoByte" a) =>
LensLike' f s a
U5c.coinsPerUtxoByte LensLike' (Const (Maybe Integer)) (Proto PParams) (Proto BigInt)
-> ((Maybe Integer -> Const (Maybe Integer) (Maybe Integer))
-> Proto BigInt -> Const (Maybe Integer) (Proto BigInt))
-> Getting (Maybe Integer) (Proto PParams) (Maybe Integer)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto BigInt -> Maybe Integer)
-> SimpleGetter (Proto BigInt) (Maybe Integer)
forall s a. (s -> a) -> SimpleGetter s a
to Proto BigInt -> Maybe Integer
forall (m :: * -> *).
(HasCallStack, MonadThrow m) =>
Proto BigInt -> m Integer
utxoRpcBigIntToInteger Maybe Integer -> String -> Either String Integer
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid coinsPerUtxoByte"
compactCoinsPerUtxO <-
note "Could not convert coinsPerUtxoByte to compact form." $ L.toCompact (L.Coin coinsPerUtxoByte)
pure $ set L.ppCoinsPerUTxOByteL (L.CoinPerByte compactCoinsPerUtxO) r
, PParams (LedgerEra era) -> Either String (PParams (LedgerEra era))
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era)))
-> (PParams (LedgerEra era) -> PParams (LedgerEra era))
-> PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Word32 -> Identity Word32)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era))
forall era. EraPParams era => Lens' (PParams era) Word32
Lens' (PParams (LedgerEra era)) Word32
L.ppMaxTxSizeL ((Word32 -> Identity Word32)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era)))
-> Word32 -> PParams (LedgerEra era) -> PParams (LedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Proto PParams
pp Proto PParams -> Getting Word32 (Proto PParams) Word32 -> Word32
forall s a. s -> Getting a s a -> a
^. LensLike' (Const Word32) (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "maxTxSize" a) =>
LensLike' f s a
U5c.maxTxSize LensLike' (Const Word32) (Proto PParams) Word64
-> ((Word32 -> Const Word32 Word32)
-> Word64 -> Const Word32 Word64)
-> Getting Word32 (Proto PParams) Word32
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word64 -> Word32) -> SimpleGetter Word64 Word32
forall s a. (s -> a) -> SimpleGetter s a
to Word64 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
, \PParams (LedgerEra era)
r -> do
minFeeCoeff <-
Proto PParams
pp Proto PParams
-> Getting (Maybe Integer) (Proto PParams) (Maybe Integer)
-> Maybe Integer
forall s a. s -> Getting a s a -> a
^. LensLike' (Const (Maybe Integer)) (Proto PParams) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "minFeeCoefficient" a) =>
LensLike' f s a
U5c.minFeeCoefficient LensLike' (Const (Maybe Integer)) (Proto PParams) (Proto BigInt)
-> ((Maybe Integer -> Const (Maybe Integer) (Maybe Integer))
-> Proto BigInt -> Const (Maybe Integer) (Proto BigInt))
-> Getting (Maybe Integer) (Proto PParams) (Maybe Integer)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto BigInt -> Maybe Integer)
-> SimpleGetter (Proto BigInt) (Maybe Integer)
forall s a. (s -> a) -> SimpleGetter s a
to Proto BigInt -> Maybe Integer
forall (m :: * -> *).
(HasCallStack, MonadThrow m) =>
Proto BigInt -> m Integer
utxoRpcBigIntToInteger Maybe Integer -> String -> Either String Integer
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid minFeeCoefficient"
minFeeCoeffCompact <-
note "Could not convert minFeeCoefficient to compact form." $ L.toCompact (L.Coin minFeeCoeff)
pure $ set L.ppTxFeePerByteL (L.CoinPerByte minFeeCoeffCompact) r
, \PParams (LedgerEra era)
r -> do
minFeeConst <- Proto PParams
pp Proto PParams
-> Getting (Maybe Integer) (Proto PParams) (Maybe Integer)
-> Maybe Integer
forall s a. s -> Getting a s a -> a
^. LensLike' (Const (Maybe Integer)) (Proto PParams) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "minFeeConstant" a) =>
LensLike' f s a
U5c.minFeeConstant LensLike' (Const (Maybe Integer)) (Proto PParams) (Proto BigInt)
-> ((Maybe Integer -> Const (Maybe Integer) (Maybe Integer))
-> Proto BigInt -> Const (Maybe Integer) (Proto BigInt))
-> Getting (Maybe Integer) (Proto PParams) (Maybe Integer)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto BigInt -> Maybe Integer)
-> SimpleGetter (Proto BigInt) (Maybe Integer)
forall s a. (s -> a) -> SimpleGetter s a
to Proto BigInt -> Maybe Integer
forall (m :: * -> *).
(HasCallStack, MonadThrow m) =>
Proto BigInt -> m Integer
utxoRpcBigIntToInteger Maybe Integer -> String -> Either String Integer
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid minFeeConstant"
pure $ set L.ppTxFeeFixedL (L.Coin minFeeConst) r
, PParams (LedgerEra era) -> Either String (PParams (LedgerEra era))
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era)))
-> (PParams (LedgerEra era) -> PParams (LedgerEra era))
-> PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Word32 -> Identity Word32)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era))
forall era. EraPParams era => Lens' (PParams era) Word32
Lens' (PParams (LedgerEra era)) Word32
L.ppMaxBBSizeL ((Word32 -> Identity Word32)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era)))
-> Word32 -> PParams (LedgerEra era) -> PParams (LedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Proto PParams
pp Proto PParams -> Getting Word32 (Proto PParams) Word32 -> Word32
forall s a. s -> Getting a s a -> a
^. LensLike' (Const Word32) (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "maxBlockBodySize" a) =>
LensLike' f s a
U5c.maxBlockBodySize LensLike' (Const Word32) (Proto PParams) Word64
-> ((Word32 -> Const Word32 Word32)
-> Word64 -> Const Word32 Word64)
-> Getting Word32 (Proto PParams) Word32
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word64 -> Word32) -> SimpleGetter Word64 Word32
forall s a. (s -> a) -> SimpleGetter s a
to Word64 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
, PParams (LedgerEra era) -> Either String (PParams (LedgerEra era))
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era)))
-> (PParams (LedgerEra era) -> PParams (LedgerEra era))
-> PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Word16 -> Identity Word16)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era))
forall era. EraPParams era => Lens' (PParams era) Word16
Lens' (PParams (LedgerEra era)) Word16
L.ppMaxBHSizeL ((Word16 -> Identity Word16)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era)))
-> Word16 -> PParams (LedgerEra era) -> PParams (LedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Proto PParams
pp Proto PParams -> Getting Word16 (Proto PParams) Word16 -> Word16
forall s a. s -> Getting a s a -> a
^. LensLike' (Const Word16) (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "maxBlockHeaderSize" a) =>
LensLike' f s a
U5c.maxBlockHeaderSize LensLike' (Const Word16) (Proto PParams) Word64
-> ((Word16 -> Const Word16 Word16)
-> Word64 -> Const Word16 Word64)
-> Getting Word16 (Proto PParams) Word16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word64 -> Word16) -> SimpleGetter Word64 Word16
forall s a. (s -> a) -> SimpleGetter s a
to Word64 -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
, \PParams (LedgerEra era)
r -> do
stakeKeyDeposit <-
Proto PParams
pp Proto PParams
-> Getting (Maybe Integer) (Proto PParams) (Maybe Integer)
-> Maybe Integer
forall s a. s -> Getting a s a -> a
^. LensLike' (Const (Maybe Integer)) (Proto PParams) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "stakeKeyDeposit" a) =>
LensLike' f s a
U5c.stakeKeyDeposit LensLike' (Const (Maybe Integer)) (Proto PParams) (Proto BigInt)
-> ((Maybe Integer -> Const (Maybe Integer) (Maybe Integer))
-> Proto BigInt -> Const (Maybe Integer) (Proto BigInt))
-> Getting (Maybe Integer) (Proto PParams) (Maybe Integer)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto BigInt -> Maybe Integer)
-> SimpleGetter (Proto BigInt) (Maybe Integer)
forall s a. (s -> a) -> SimpleGetter s a
to Proto BigInt -> Maybe Integer
forall (m :: * -> *).
(HasCallStack, MonadThrow m) =>
Proto BigInt -> m Integer
utxoRpcBigIntToInteger Maybe Integer -> String -> Either String Integer
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid stakeKeyDeposit"
pure $ set L.ppKeyDepositL (L.Coin stakeKeyDeposit) r
, \PParams (LedgerEra era)
r -> do
poolDeposit <- Proto PParams
pp Proto PParams
-> Getting (Maybe Integer) (Proto PParams) (Maybe Integer)
-> Maybe Integer
forall s a. s -> Getting a s a -> a
^. LensLike' (Const (Maybe Integer)) (Proto PParams) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "poolDeposit" a) =>
LensLike' f s a
U5c.poolDeposit LensLike' (Const (Maybe Integer)) (Proto PParams) (Proto BigInt)
-> ((Maybe Integer -> Const (Maybe Integer) (Maybe Integer))
-> Proto BigInt -> Const (Maybe Integer) (Proto BigInt))
-> Getting (Maybe Integer) (Proto PParams) (Maybe Integer)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto BigInt -> Maybe Integer)
-> SimpleGetter (Proto BigInt) (Maybe Integer)
forall s a. (s -> a) -> SimpleGetter s a
to Proto BigInt -> Maybe Integer
forall (m :: * -> *).
(HasCallStack, MonadThrow m) =>
Proto BigInt -> m Integer
utxoRpcBigIntToInteger Maybe Integer -> String -> Either String Integer
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid poolDeposit"
pure $ set L.ppPoolDepositL (L.Coin poolDeposit) r
, PParams (LedgerEra era) -> Either String (PParams (LedgerEra era))
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era)))
-> (PParams (LedgerEra era) -> PParams (LedgerEra era))
-> PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((EpochInterval -> Identity EpochInterval)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era))
forall era. EraPParams era => Lens' (PParams era) EpochInterval
Lens' (PParams (LedgerEra era)) EpochInterval
L.ppEMaxL ((EpochInterval -> Identity EpochInterval)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era)))
-> EpochInterval
-> PParams (LedgerEra era)
-> PParams (LedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Proto PParams
pp Proto PParams
-> Getting EpochInterval (Proto PParams) EpochInterval
-> EpochInterval
forall s a. s -> Getting a s a -> a
^. LensLike' (Const EpochInterval) (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "poolRetirementEpochBound" a) =>
LensLike' f s a
U5c.poolRetirementEpochBound LensLike' (Const EpochInterval) (Proto PParams) Word64
-> ((EpochInterval -> Const EpochInterval EpochInterval)
-> Word64 -> Const EpochInterval Word64)
-> Getting EpochInterval (Proto PParams) EpochInterval
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word64 -> Word32) -> SimpleGetter Word64 Word32
forall s a. (s -> a) -> SimpleGetter s a
to Word64 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Getting EpochInterval Word64 Word32
-> ((EpochInterval -> Const EpochInterval EpochInterval)
-> Word32 -> Const EpochInterval Word32)
-> (EpochInterval -> Const EpochInterval EpochInterval)
-> Word64
-> Const EpochInterval Word64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word32 -> EpochInterval) -> SimpleGetter Word32 EpochInterval
forall s a. (s -> a) -> SimpleGetter s a
to Word32 -> EpochInterval
L.EpochInterval)
, PParams (LedgerEra era) -> Either String (PParams (LedgerEra era))
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era)))
-> (PParams (LedgerEra era) -> PParams (LedgerEra era))
-> PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Word16 -> Identity Word16)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era))
forall era. EraPParams era => Lens' (PParams era) Word16
Lens' (PParams (LedgerEra era)) Word16
L.ppNOptL ((Word16 -> Identity Word16)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era)))
-> Word16 -> PParams (LedgerEra era) -> PParams (LedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Proto PParams
pp Proto PParams -> Getting Word16 (Proto PParams) Word16 -> Word16
forall s a. s -> Getting a s a -> a
^. LensLike' (Const Word16) (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "desiredNumberOfPools" a) =>
LensLike' f s a
U5c.desiredNumberOfPools LensLike' (Const Word16) (Proto PParams) Word64
-> ((Word16 -> Const Word16 Word16)
-> Word64 -> Const Word16 Word64)
-> Getting Word16 (Proto PParams) Word16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word64 -> Word16) -> SimpleGetter Word64 Word16
forall s a. (s -> a) -> SimpleGetter s a
to Word64 -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
, \PParams (LedgerEra era)
r -> do
poolInfluence <-
Proto PParams
pp
Proto PParams
-> Getting
(Maybe NonNegativeInterval)
(Proto PParams)
(Maybe NonNegativeInterval)
-> Maybe NonNegativeInterval
forall s a. s -> Getting a s a -> a
^. LensLike'
(Const (Maybe NonNegativeInterval))
(Proto PParams)
(Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "poolInfluence" a) =>
LensLike' f s a
U5c.poolInfluence
LensLike'
(Const (Maybe NonNegativeInterval))
(Proto PParams)
(Proto RationalNumber)
-> ((Maybe NonNegativeInterval
-> Const (Maybe NonNegativeInterval) (Maybe NonNegativeInterval))
-> Proto RationalNumber
-> Const (Maybe NonNegativeInterval) (Proto RationalNumber))
-> Getting
(Maybe NonNegativeInterval)
(Proto PParams)
(Maybe NonNegativeInterval)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto RationalNumber -> Maybe NonNegativeInterval)
-> SimpleGetter (Proto RationalNumber) (Maybe NonNegativeInterval)
forall s a. (s -> a) -> SimpleGetter s a
to (Ratio Integer -> Maybe NonNegativeInterval
forall r. BoundedRational r => Ratio Integer -> Maybe r
L.boundRational (Ratio Integer -> Maybe NonNegativeInterval)
-> (Proto RationalNumber -> Maybe (Ratio Integer))
-> Proto RationalNumber
-> Maybe NonNegativeInterval
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< Proto RationalNumber -> Maybe (Ratio Integer)
utxoRpcRationalNumberToRational)
Maybe NonNegativeInterval
-> String -> Either String NonNegativeInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid poolInfluence"
pure $ set L.ppA0L poolInfluence r
, \PParams (LedgerEra era)
r -> do
monetaryExpansion <-
Proto PParams
pp
Proto PParams
-> Getting
(Maybe UnitInterval) (Proto PParams) (Maybe UnitInterval)
-> Maybe UnitInterval
forall s a. s -> Getting a s a -> a
^. LensLike'
(Const (Maybe UnitInterval)) (Proto PParams) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "monetaryExpansion" a) =>
LensLike' f s a
U5c.monetaryExpansion
LensLike'
(Const (Maybe UnitInterval)) (Proto PParams) (Proto RationalNumber)
-> ((Maybe UnitInterval
-> Const (Maybe UnitInterval) (Maybe UnitInterval))
-> Proto RationalNumber
-> Const (Maybe UnitInterval) (Proto RationalNumber))
-> Getting
(Maybe UnitInterval) (Proto PParams) (Maybe UnitInterval)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto RationalNumber -> Maybe UnitInterval)
-> SimpleGetter (Proto RationalNumber) (Maybe UnitInterval)
forall s a. (s -> a) -> SimpleGetter s a
to (Ratio Integer -> Maybe UnitInterval
forall r. BoundedRational r => Ratio Integer -> Maybe r
L.boundRational (Ratio Integer -> Maybe UnitInterval)
-> (Proto RationalNumber -> Maybe (Ratio Integer))
-> Proto RationalNumber
-> Maybe UnitInterval
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< Proto RationalNumber -> Maybe (Ratio Integer)
utxoRpcRationalNumberToRational)
Maybe UnitInterval -> String -> Either String UnitInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid monetaryExpansion"
pure $ set L.ppRhoL monetaryExpansion r
, \PParams (LedgerEra era)
r -> do
treasuryExpansion <-
Proto PParams
pp
Proto PParams
-> Getting
(Maybe UnitInterval) (Proto PParams) (Maybe UnitInterval)
-> Maybe UnitInterval
forall s a. s -> Getting a s a -> a
^. LensLike'
(Const (Maybe UnitInterval)) (Proto PParams) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "treasuryExpansion" a) =>
LensLike' f s a
U5c.treasuryExpansion
LensLike'
(Const (Maybe UnitInterval)) (Proto PParams) (Proto RationalNumber)
-> ((Maybe UnitInterval
-> Const (Maybe UnitInterval) (Maybe UnitInterval))
-> Proto RationalNumber
-> Const (Maybe UnitInterval) (Proto RationalNumber))
-> Getting
(Maybe UnitInterval) (Proto PParams) (Maybe UnitInterval)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto RationalNumber -> Maybe UnitInterval)
-> SimpleGetter (Proto RationalNumber) (Maybe UnitInterval)
forall s a. (s -> a) -> SimpleGetter s a
to (Ratio Integer -> Maybe UnitInterval
forall r. BoundedRational r => Ratio Integer -> Maybe r
L.boundRational (Ratio Integer -> Maybe UnitInterval)
-> (Proto RationalNumber -> Maybe (Ratio Integer))
-> Proto RationalNumber
-> Maybe UnitInterval
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< Proto RationalNumber -> Maybe (Ratio Integer)
utxoRpcRationalNumberToRational)
Maybe UnitInterval -> String -> Either String UnitInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid treasuryExpansion"
pure $ set L.ppTauL treasuryExpansion r
, \PParams (LedgerEra era)
r -> do
minPoolCost <- Proto PParams
pp Proto PParams
-> Getting (Maybe Integer) (Proto PParams) (Maybe Integer)
-> Maybe Integer
forall s a. s -> Getting a s a -> a
^. LensLike' (Const (Maybe Integer)) (Proto PParams) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "minPoolCost" a) =>
LensLike' f s a
U5c.minPoolCost LensLike' (Const (Maybe Integer)) (Proto PParams) (Proto BigInt)
-> ((Maybe Integer -> Const (Maybe Integer) (Maybe Integer))
-> Proto BigInt -> Const (Maybe Integer) (Proto BigInt))
-> Getting (Maybe Integer) (Proto PParams) (Maybe Integer)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto BigInt -> Maybe Integer)
-> SimpleGetter (Proto BigInt) (Maybe Integer)
forall s a. (s -> a) -> SimpleGetter s a
to Proto BigInt -> Maybe Integer
forall (m :: * -> *).
(HasCallStack, MonadThrow m) =>
Proto BigInt -> m Integer
utxoRpcBigIntToInteger Maybe Integer -> String -> Either String Integer
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid minPoolCost"
pure $ set L.ppMinPoolCostL (L.Coin minPoolCost) r
, \PParams (LedgerEra era)
r -> do
protocolVersion <-
Proto PParams
pp Proto PParams
-> Getting (Maybe ProtVer) (Proto PParams) (Maybe ProtVer)
-> Maybe ProtVer
forall s a. s -> Getting a s a -> a
^. LensLike'
(Const (Maybe ProtVer)) (Proto PParams) (Proto ProtocolVersion)
forall (f :: * -> *) s a.
(Functor f, HasField s "protocolVersion" a) =>
LensLike' f s a
U5c.protocolVersion LensLike'
(Const (Maybe ProtVer)) (Proto PParams) (Proto ProtocolVersion)
-> ((Maybe ProtVer -> Const (Maybe ProtVer) (Maybe ProtVer))
-> Proto ProtocolVersion
-> Const (Maybe ProtVer) (Proto ProtocolVersion))
-> Getting (Maybe ProtVer) (Proto PParams) (Maybe ProtVer)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto ProtocolVersion -> Maybe ProtVer)
-> SimpleGetter (Proto ProtocolVersion) (Maybe ProtVer)
forall s a. (s -> a) -> SimpleGetter s a
to Proto ProtocolVersion -> Maybe ProtVer
utxoRpcProtocolVersionToProtVer Maybe ProtVer -> String -> Either String ProtVer
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid protocolVersion"
pure $ set L.ppProtocolVersionL protocolVersion r
, PParams (LedgerEra era) -> Either String (PParams (LedgerEra era))
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era)))
-> (PParams (LedgerEra era) -> PParams (LedgerEra era))
-> PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Word32 -> Identity Word32)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era))
forall era. AlonzoEraPParams era => Lens' (PParams era) Word32
Lens' (PParams (LedgerEra era)) Word32
L.ppMaxValSizeL ((Word32 -> Identity Word32)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era)))
-> Word32 -> PParams (LedgerEra era) -> PParams (LedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Proto PParams
pp Proto PParams -> Getting Word32 (Proto PParams) Word32 -> Word32
forall s a. s -> Getting a s a -> a
^. LensLike' (Const Word32) (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "maxValueSize" a) =>
LensLike' f s a
U5c.maxValueSize LensLike' (Const Word32) (Proto PParams) Word64
-> ((Word32 -> Const Word32 Word32)
-> Word64 -> Const Word32 Word64)
-> Getting Word32 (Proto PParams) Word32
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word64 -> Word32) -> SimpleGetter Word64 Word32
forall s a. (s -> a) -> SimpleGetter s a
to Word64 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
, PParams (LedgerEra era) -> Either String (PParams (LedgerEra era))
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era)))
-> (PParams (LedgerEra era) -> PParams (LedgerEra era))
-> PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Word16 -> Identity Word16)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era))
forall era. AlonzoEraPParams era => Lens' (PParams era) Word16
Lens' (PParams (LedgerEra era)) Word16
L.ppCollateralPercentageL ((Word16 -> Identity Word16)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era)))
-> Word16 -> PParams (LedgerEra era) -> PParams (LedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Proto PParams
pp Proto PParams -> Getting Word16 (Proto PParams) Word16 -> Word16
forall s a. s -> Getting a s a -> a
^. LensLike' (Const Word16) (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "collateralPercentage" a) =>
LensLike' f s a
U5c.collateralPercentage LensLike' (Const Word16) (Proto PParams) Word64
-> ((Word16 -> Const Word16 Word16)
-> Word64 -> Const Word16 Word64)
-> Getting Word16 (Proto PParams) Word16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word64 -> Word16) -> SimpleGetter Word64 Word16
forall s a. (s -> a) -> SimpleGetter s a
to Word64 -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
, PParams (LedgerEra era) -> Either String (PParams (LedgerEra era))
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era)))
-> (PParams (LedgerEra era) -> PParams (LedgerEra era))
-> PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Word16 -> Identity Word16)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era))
forall era. AlonzoEraPParams era => Lens' (PParams era) Word16
Lens' (PParams (LedgerEra era)) Word16
L.ppMaxCollateralInputsL ((Word16 -> Identity Word16)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era)))
-> Word16 -> PParams (LedgerEra era) -> PParams (LedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Proto PParams
pp Proto PParams -> Getting Word16 (Proto PParams) Word16 -> Word16
forall s a. s -> Getting a s a -> a
^. LensLike' (Const Word16) (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "maxCollateralInputs" a) =>
LensLike' f s a
U5c.maxCollateralInputs LensLike' (Const Word16) (Proto PParams) Word64
-> ((Word16 -> Const Word16 Word16)
-> Word64 -> Const Word16 Word64)
-> Getting Word16 (Proto PParams) Word16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word64 -> Word16) -> SimpleGetter Word64 Word16
forall s a. (s -> a) -> SimpleGetter s a
to Word64 -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
, \PParams (LedgerEra era)
r -> (CostModelApplyError -> String)
-> Either CostModelApplyError (PParams (LedgerEra era))
-> Either String (PParams (LedgerEra era))
forall a b c. (a -> b) -> Either a c -> Either b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first CostModelApplyError -> String
forall a. Show a => a -> String
show (Either CostModelApplyError (PParams (LedgerEra era))
-> Either String (PParams (LedgerEra era)))
-> Either CostModelApplyError (PParams (LedgerEra era))
-> Either String (PParams (LedgerEra era))
forall a b. (a -> b) -> a -> b
$ do
cm1 <- Language -> [Int64] -> Either CostModelApplyError CostModel
L.mkCostModel Language
L.PlutusV1 ([Int64] -> Either CostModelApplyError CostModel)
-> [Int64] -> Either CostModelApplyError CostModel
forall a b. (a -> b) -> a -> b
$ Proto PParams
pp Proto PParams -> Getting [Int64] (Proto PParams) [Int64] -> [Int64]
forall s a. s -> Getting a s a -> a
^. LensLike' (Const [Int64]) (Proto PParams) (Proto CostModels)
forall (f :: * -> *) s a.
(Functor f, HasField s "costModels" a) =>
LensLike' f s a
U5c.costModels LensLike' (Const [Int64]) (Proto PParams) (Proto CostModels)
-> (([Int64] -> Const [Int64] [Int64])
-> Proto CostModels -> Const [Int64] (Proto CostModels))
-> Getting [Int64] (Proto PParams) [Int64]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike' (Const [Int64]) (Proto CostModels) (Proto CostModel)
forall (f :: * -> *) s a.
(Functor f, HasField s "plutusV1" a) =>
LensLike' f s a
U5c.plutusV1 LensLike' (Const [Int64]) (Proto CostModels) (Proto CostModel)
-> (([Int64] -> Const [Int64] [Int64])
-> Proto CostModel -> Const [Int64] (Proto CostModel))
-> ([Int64] -> Const [Int64] [Int64])
-> Proto CostModels
-> Const [Int64] (Proto CostModels)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Int64] -> Const [Int64] [Int64])
-> Proto CostModel -> Const [Int64] (Proto CostModel)
forall (f :: * -> *) s a.
(Functor f, HasField s "values" a) =>
LensLike' f s a
U5c.values
cm2 <- L.mkCostModel L.PlutusV2 $ pp ^. U5c.costModels . U5c.plutusV2 . U5c.values
cm3 <- L.mkCostModel L.PlutusV3 $ pp ^. U5c.costModels . U5c.plutusV3 . U5c.values
cm4 <- L.mkCostModel L.PlutusV4 $ pp ^. U5c.costModels . U5c.plutusV4 . U5c.values
let nonEmptyCostModels =
[(Language, CostModel)] -> Map Language CostModel
[Item (Map Language CostModel)] -> Map Language CostModel
forall l. IsList l => [Item l] -> l
fromList ([(Language, CostModel)] -> Map Language CostModel)
-> ((CostModel -> Maybe (Language, CostModel))
-> [(Language, CostModel)])
-> (CostModel -> Maybe (Language, CostModel))
-> Map Language CostModel
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((CostModel -> Maybe (Language, CostModel))
-> [CostModel] -> [(Language, CostModel)])
-> [CostModel]
-> (CostModel -> Maybe (Language, CostModel))
-> [(Language, CostModel)]
forall a b c. (a -> b -> c) -> b -> a -> c
flip (CostModel -> Maybe (Language, CostModel))
-> [CostModel] -> [(Language, CostModel)]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe [Item [CostModel]
CostModel
cm1, Item [CostModel]
CostModel
cm2, Item [CostModel]
CostModel
cm3, Item [CostModel]
CostModel
cm4] ((CostModel -> Maybe (Language, CostModel))
-> Map Language CostModel)
-> (CostModel -> Maybe (Language, CostModel))
-> Map Language CostModel
forall a b. (a -> b) -> a -> b
$ \CostModel
cm ->
if Bool -> Bool
not ([Int64] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([Int64] -> Bool) -> [Int64] -> Bool
forall a b. (a -> b) -> a -> b
$ CostModel -> [Int64]
L.getCostModelParams CostModel
cm)
then (Language, CostModel) -> Maybe (Language, CostModel)
forall a. a -> Maybe a
Just (CostModel -> Language
L.getCostModelLanguage CostModel
cm, CostModel
cm)
else Maybe (Language, CostModel)
forall a. Maybe a
Nothing
pure $
r & L.ppCostModelsL .~ L.mkCostModels nonEmptyCostModels
, \PParams (LedgerEra era)
r -> do
steps <-
Proto PParams
pp
Proto PParams
-> Getting
(Maybe NonNegativeInterval)
(Proto PParams)
(Maybe NonNegativeInterval)
-> Maybe NonNegativeInterval
forall s a. s -> Getting a s a -> a
^. LensLike'
(Const (Maybe NonNegativeInterval))
(Proto PParams)
(Proto ExPrices)
forall (f :: * -> *) s a.
(Functor f, HasField s "prices" a) =>
LensLike' f s a
U5c.prices
LensLike'
(Const (Maybe NonNegativeInterval))
(Proto PParams)
(Proto ExPrices)
-> ((Maybe NonNegativeInterval
-> Const (Maybe NonNegativeInterval) (Maybe NonNegativeInterval))
-> Proto ExPrices
-> Const (Maybe NonNegativeInterval) (Proto ExPrices))
-> Getting
(Maybe NonNegativeInterval)
(Proto PParams)
(Maybe NonNegativeInterval)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike'
(Const (Maybe NonNegativeInterval))
(Proto ExPrices)
(Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "steps" a) =>
LensLike' f s a
U5c.steps
LensLike'
(Const (Maybe NonNegativeInterval))
(Proto ExPrices)
(Proto RationalNumber)
-> ((Maybe NonNegativeInterval
-> Const (Maybe NonNegativeInterval) (Maybe NonNegativeInterval))
-> Proto RationalNumber
-> Const (Maybe NonNegativeInterval) (Proto RationalNumber))
-> (Maybe NonNegativeInterval
-> Const (Maybe NonNegativeInterval) (Maybe NonNegativeInterval))
-> Proto ExPrices
-> Const (Maybe NonNegativeInterval) (Proto ExPrices)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto RationalNumber -> Maybe NonNegativeInterval)
-> SimpleGetter (Proto RationalNumber) (Maybe NonNegativeInterval)
forall s a. (s -> a) -> SimpleGetter s a
to (Ratio Integer -> Maybe NonNegativeInterval
forall r. BoundedRational r => Ratio Integer -> Maybe r
L.boundRational (Ratio Integer -> Maybe NonNegativeInterval)
-> (Proto RationalNumber -> Maybe (Ratio Integer))
-> Proto RationalNumber
-> Maybe NonNegativeInterval
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< Proto RationalNumber -> Maybe (Ratio Integer)
utxoRpcRationalNumberToRational)
Maybe NonNegativeInterval
-> String -> Either String NonNegativeInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid prices.steps"
mem <-
pp
^. U5c.prices
. U5c.memory
. to (L.boundRational <=< utxoRpcRationalNumberToRational)
?! "Invalid prices.mem"
pure $
r
& L.ppPricesL . prStepsL .~ steps
& L.ppPricesL . prMemL .~ mem
, PParams (LedgerEra era) -> Either String (PParams (LedgerEra era))
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era)))
-> (PParams (LedgerEra era) -> PParams (LedgerEra era))
-> PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((ExUnits -> Identity ExUnits)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era))
forall era. AlonzoEraPParams era => Lens' (PParams era) ExUnits
Lens' (PParams (LedgerEra era)) ExUnits
L.ppMaxTxExUnitsL ((ExUnits -> Identity ExUnits)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era)))
-> ExUnits -> PParams (LedgerEra era) -> PParams (LedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Proto PParams
pp Proto PParams -> Getting ExUnits (Proto PParams) ExUnits -> ExUnits
forall s a. s -> Getting a s a -> a
^. LensLike' (Const ExUnits) (Proto PParams) (Proto ExUnits)
forall (f :: * -> *) s a.
(Functor f, HasField s "maxExecutionUnitsPerTransaction" a) =>
LensLike' f s a
U5c.maxExecutionUnitsPerTransaction LensLike' (Const ExUnits) (Proto PParams) (Proto ExUnits)
-> ((ExUnits -> Const ExUnits ExUnits)
-> Proto ExUnits -> Const ExUnits (Proto ExUnits))
-> Getting ExUnits (Proto PParams) ExUnits
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto ExUnits -> ExUnits) -> SimpleGetter (Proto ExUnits) ExUnits
forall s a. (s -> a) -> SimpleGetter s a
to Proto ExUnits -> ExUnits
forall t s. Inject t s => t -> s
inject)
, PParams (LedgerEra era) -> Either String (PParams (LedgerEra era))
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era)))
-> (PParams (LedgerEra era) -> PParams (LedgerEra era))
-> PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((ExUnits -> Identity ExUnits)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era))
forall era. AlonzoEraPParams era => Lens' (PParams era) ExUnits
Lens' (PParams (LedgerEra era)) ExUnits
L.ppMaxBlockExUnitsL ((ExUnits -> Identity ExUnits)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era)))
-> ExUnits -> PParams (LedgerEra era) -> PParams (LedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Proto PParams
pp Proto PParams -> Getting ExUnits (Proto PParams) ExUnits -> ExUnits
forall s a. s -> Getting a s a -> a
^. LensLike' (Const ExUnits) (Proto PParams) (Proto ExUnits)
forall (f :: * -> *) s a.
(Functor f, HasField s "maxExecutionUnitsPerBlock" a) =>
LensLike' f s a
U5c.maxExecutionUnitsPerBlock LensLike' (Const ExUnits) (Proto PParams) (Proto ExUnits)
-> ((ExUnits -> Const ExUnits ExUnits)
-> Proto ExUnits -> Const ExUnits (Proto ExUnits))
-> Getting ExUnits (Proto PParams) ExUnits
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto ExUnits -> ExUnits) -> SimpleGetter (Proto ExUnits) ExUnits
forall s a. (s -> a) -> SimpleGetter s a
to Proto ExUnits -> ExUnits
forall t s. Inject t s => t -> s
inject)
, \PParams (LedgerEra era)
r -> do
minFeeScriptRefCostPerByte <-
Proto PParams
pp
Proto PParams
-> Getting
(Maybe NonNegativeInterval)
(Proto PParams)
(Maybe NonNegativeInterval)
-> Maybe NonNegativeInterval
forall s a. s -> Getting a s a -> a
^. LensLike'
(Const (Maybe NonNegativeInterval))
(Proto PParams)
(Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "minFeeScriptRefCostPerByte" a) =>
LensLike' f s a
U5c.minFeeScriptRefCostPerByte
LensLike'
(Const (Maybe NonNegativeInterval))
(Proto PParams)
(Proto RationalNumber)
-> ((Maybe NonNegativeInterval
-> Const (Maybe NonNegativeInterval) (Maybe NonNegativeInterval))
-> Proto RationalNumber
-> Const (Maybe NonNegativeInterval) (Proto RationalNumber))
-> Getting
(Maybe NonNegativeInterval)
(Proto PParams)
(Maybe NonNegativeInterval)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto RationalNumber -> Maybe NonNegativeInterval)
-> SimpleGetter (Proto RationalNumber) (Maybe NonNegativeInterval)
forall s a. (s -> a) -> SimpleGetter s a
to (Ratio Integer -> Maybe NonNegativeInterval
forall r. BoundedRational r => Ratio Integer -> Maybe r
L.boundRational (Ratio Integer -> Maybe NonNegativeInterval)
-> (Proto RationalNumber -> Maybe (Ratio Integer))
-> Proto RationalNumber
-> Maybe NonNegativeInterval
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< Proto RationalNumber -> Maybe (Ratio Integer)
utxoRpcRationalNumberToRational)
Maybe NonNegativeInterval
-> String -> Either String NonNegativeInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid minFeeScriptRefCostPerByte"
pure $ set L.ppMinFeeRefScriptCostPerByteL minFeeScriptRefCostPerByte r
, \PParams (LedgerEra era)
r -> do
let thresholds :: [Proto RationalNumber]
thresholds = Proto PParams
pp Proto PParams
-> Getting
[Proto RationalNumber] (Proto PParams) [Proto RationalNumber]
-> [Proto RationalNumber]
forall s a. s -> Getting a s a -> a
^. LensLike'
(Const [Proto RationalNumber])
(Proto PParams)
(Proto VotingThresholds)
forall (f :: * -> *) s a.
(Functor f, HasField s "poolVotingThresholds" a) =>
LensLike' f s a
U5c.poolVotingThresholds LensLike'
(Const [Proto RationalNumber])
(Proto PParams)
(Proto VotingThresholds)
-> (([Proto RationalNumber]
-> Const [Proto RationalNumber] [Proto RationalNumber])
-> Proto VotingThresholds
-> Const [Proto RationalNumber] (Proto VotingThresholds))
-> Getting
[Proto RationalNumber] (Proto PParams) [Proto RationalNumber]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Proto RationalNumber]
-> Const [Proto RationalNumber] [Proto RationalNumber])
-> Proto VotingThresholds
-> Const [Proto RationalNumber] (Proto VotingThresholds)
forall (f :: * -> *) s a.
(Functor f, HasField s "thresholds" a) =>
LensLike' f s a
U5c.thresholds
Bool -> Either String () -> Either String ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when ([Proto RationalNumber] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Proto RationalNumber]
thresholds Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= Int
5) (Either String () -> Either String ())
-> Either String () -> Either String ()
forall a b. (a -> b) -> a -> b
$
String -> Either String ()
forall a. String -> Either String a
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (String -> Either String ()) -> String -> Either String ()
forall a b. (a -> b) -> a -> b
$
String
"Invalid number of thresholds: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show ([Proto RationalNumber] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Proto RationalNumber]
thresholds)
[ motionNoConfidence
, committeeNormal
, committeeNoConfidence
, hardForkInitiation
, ppSecurityGroup
] <-
((Maybe UnitInterval -> Either String UnitInterval,
Maybe UnitInterval)
-> Either String UnitInterval)
-> [(Maybe UnitInterval -> Either String UnitInterval,
Maybe UnitInterval)]
-> Either String [UnitInterval]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (((Maybe UnitInterval -> Either String UnitInterval)
-> Maybe UnitInterval -> Either String UnitInterval)
-> (Maybe UnitInterval -> Either String UnitInterval,
Maybe UnitInterval)
-> Either String UnitInterval
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry (Maybe UnitInterval -> Either String UnitInterval)
-> Maybe UnitInterval -> Either String UnitInterval
forall a b. (a -> b) -> a -> b
($))
([(Maybe UnitInterval -> Either String UnitInterval,
Maybe UnitInterval)]
-> Either String [UnitInterval])
-> ([Maybe UnitInterval]
-> [(Maybe UnitInterval -> Either String UnitInterval,
Maybe UnitInterval)])
-> [Maybe UnitInterval]
-> Either String [UnitInterval]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe UnitInterval -> Either String UnitInterval]
-> [Maybe UnitInterval]
-> [(Maybe UnitInterval -> Either String UnitInterval,
Maybe UnitInterval)]
forall a b. [a] -> [b] -> [(a, b)]
zip
[ (Maybe UnitInterval -> String -> Either String UnitInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid value in poolVotingThresholds: motionNoConfidence")
, (Maybe UnitInterval -> String -> Either String UnitInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid value in poolVotingThresholds: committeeNormal")
, (Maybe UnitInterval -> String -> Either String UnitInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid value in poolVotingThresholds: committeeNoConfidence")
, (Maybe UnitInterval -> String -> Either String UnitInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid value in poolVotingThresholds: hardForkInitiation")
, (Maybe UnitInterval -> String -> Either String UnitInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid value in poolVotingThresholds: ppSecurityGroup")
]
([Maybe UnitInterval] -> Either String [UnitInterval])
-> [Maybe UnitInterval] -> Either String [UnitInterval]
forall a b. (a -> b) -> a -> b
$ (Proto RationalNumber -> Maybe UnitInterval)
-> [Proto RationalNumber] -> [Maybe UnitInterval]
forall a b. (a -> b) -> [a] -> [b]
map (Ratio Integer -> Maybe UnitInterval
forall r. BoundedRational r => Ratio Integer -> Maybe r
L.boundRational (Ratio Integer -> Maybe UnitInterval)
-> (Proto RationalNumber -> Maybe (Ratio Integer))
-> Proto RationalNumber
-> Maybe UnitInterval
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< Proto RationalNumber -> Maybe (Ratio Integer)
utxoRpcRationalNumberToRational) [Proto RationalNumber]
thresholds
pure $
r
& L.ppPoolVotingThresholdsL . L.pvtMotionNoConfidenceL .~ motionNoConfidence
& L.ppPoolVotingThresholdsL . L.pvtCommitteeNormalL .~ committeeNormal
& L.ppPoolVotingThresholdsL . L.pvtCommitteeNoConfidenceL .~ committeeNoConfidence
& L.ppPoolVotingThresholdsL . L.pvtHardForkInitiationL .~ hardForkInitiation
& L.ppPoolVotingThresholdsL . L.pvtPPSecurityGroupL .~ ppSecurityGroup
, \PParams (LedgerEra era)
r -> do
let thresholds :: [Proto RationalNumber]
thresholds = Proto PParams
pp Proto PParams
-> Getting
[Proto RationalNumber] (Proto PParams) [Proto RationalNumber]
-> [Proto RationalNumber]
forall s a. s -> Getting a s a -> a
^. LensLike'
(Const [Proto RationalNumber])
(Proto PParams)
(Proto VotingThresholds)
forall (f :: * -> *) s a.
(Functor f, HasField s "drepVotingThresholds" a) =>
LensLike' f s a
U5c.drepVotingThresholds LensLike'
(Const [Proto RationalNumber])
(Proto PParams)
(Proto VotingThresholds)
-> (([Proto RationalNumber]
-> Const [Proto RationalNumber] [Proto RationalNumber])
-> Proto VotingThresholds
-> Const [Proto RationalNumber] (Proto VotingThresholds))
-> Getting
[Proto RationalNumber] (Proto PParams) [Proto RationalNumber]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Proto RationalNumber]
-> Const [Proto RationalNumber] [Proto RationalNumber])
-> Proto VotingThresholds
-> Const [Proto RationalNumber] (Proto VotingThresholds)
forall (f :: * -> *) s a.
(Functor f, HasField s "thresholds" a) =>
LensLike' f s a
U5c.thresholds
Bool -> Either String () -> Either String ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when ([Proto RationalNumber] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Proto RationalNumber]
thresholds Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= Int
10) (Either String () -> Either String ())
-> Either String () -> Either String ()
forall a b. (a -> b) -> a -> b
$
String -> Either String ()
forall a. String -> Either String a
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (String -> Either String ()) -> String -> Either String ()
forall a b. (a -> b) -> a -> b
$
String
"Invalid number of thresholds: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show ([Proto RationalNumber] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Proto RationalNumber]
thresholds)
[ motionNoConfidence
, committeeNormal
, committeeNoConfidence
, updateToConstitution
, hardforkInitiation
, ppNetworkGroup
, ppEconomicGroup
, ppTechnicalGroup
, ppGovGroup
, treasuryWithdrawal
] <-
((Maybe UnitInterval -> Either String UnitInterval,
Maybe UnitInterval)
-> Either String UnitInterval)
-> [(Maybe UnitInterval -> Either String UnitInterval,
Maybe UnitInterval)]
-> Either String [UnitInterval]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (((Maybe UnitInterval -> Either String UnitInterval)
-> Maybe UnitInterval -> Either String UnitInterval)
-> (Maybe UnitInterval -> Either String UnitInterval,
Maybe UnitInterval)
-> Either String UnitInterval
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry (Maybe UnitInterval -> Either String UnitInterval)
-> Maybe UnitInterval -> Either String UnitInterval
forall a b. (a -> b) -> a -> b
($))
([(Maybe UnitInterval -> Either String UnitInterval,
Maybe UnitInterval)]
-> Either String [UnitInterval])
-> ([Maybe UnitInterval]
-> [(Maybe UnitInterval -> Either String UnitInterval,
Maybe UnitInterval)])
-> [Maybe UnitInterval]
-> Either String [UnitInterval]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe UnitInterval -> Either String UnitInterval]
-> [Maybe UnitInterval]
-> [(Maybe UnitInterval -> Either String UnitInterval,
Maybe UnitInterval)]
forall a b. [a] -> [b] -> [(a, b)]
zip
[ (Maybe UnitInterval -> String -> Either String UnitInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid value in drepVotingThresholds: motionNoConfidence")
, (Maybe UnitInterval -> String -> Either String UnitInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid value in drepVotingThresholds: committeeNormal")
, (Maybe UnitInterval -> String -> Either String UnitInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid value in drepVotingThresholds: committeeNoConfidence")
, (Maybe UnitInterval -> String -> Either String UnitInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid value in drepVotingThresholds: updateToConstitution")
, (Maybe UnitInterval -> String -> Either String UnitInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid value in drepVotingThresholds: hardforkInitiation")
, (Maybe UnitInterval -> String -> Either String UnitInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid value in drepVotingThresholds: ppNetworkGroup")
, (Maybe UnitInterval -> String -> Either String UnitInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid value in drepVotingThresholds: ppEconomicGroup")
, (Maybe UnitInterval -> String -> Either String UnitInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid value in drepVotingThresholds: ppTechnicalGroup")
, (Maybe UnitInterval -> String -> Either String UnitInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid value in drepVotingThresholds: ppGovGroup")
, (Maybe UnitInterval -> String -> Either String UnitInterval
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid value in drepVotingThresholds: treasuryWithdrawal")
]
([Maybe UnitInterval] -> Either String [UnitInterval])
-> [Maybe UnitInterval] -> Either String [UnitInterval]
forall a b. (a -> b) -> a -> b
$ (Proto RationalNumber -> Maybe UnitInterval)
-> [Proto RationalNumber] -> [Maybe UnitInterval]
forall a b. (a -> b) -> [a] -> [b]
map (Ratio Integer -> Maybe UnitInterval
forall r. BoundedRational r => Ratio Integer -> Maybe r
L.boundRational (Ratio Integer -> Maybe UnitInterval)
-> (Proto RationalNumber -> Maybe (Ratio Integer))
-> Proto RationalNumber
-> Maybe UnitInterval
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< Proto RationalNumber -> Maybe (Ratio Integer)
utxoRpcRationalNumberToRational) [Proto RationalNumber]
thresholds
pure $
r
& L.ppDRepVotingThresholdsL . L.dvtMotionNoConfidenceL .~ motionNoConfidence
& L.ppDRepVotingThresholdsL . L.dvtCommitteeNormalL .~ committeeNormal
& L.ppDRepVotingThresholdsL . L.dvtCommitteeNoConfidenceL .~ committeeNoConfidence
& L.ppDRepVotingThresholdsL . L.dvtUpdateToConstitutionL .~ updateToConstitution
& L.ppDRepVotingThresholdsL . L.dvtHardForkInitiationL .~ hardforkInitiation
& L.ppDRepVotingThresholdsL . L.dvtPPNetworkGroupL .~ ppNetworkGroup
& L.ppDRepVotingThresholdsL . L.dvtPPEconomicGroupL .~ ppEconomicGroup
& L.ppDRepVotingThresholdsL . L.dvtPPTechnicalGroupL .~ ppTechnicalGroup
& L.ppDRepVotingThresholdsL . L.dvtPPGovGroupL .~ ppGovGroup
& L.ppDRepVotingThresholdsL . L.dvtTreasuryWithdrawalL .~ treasuryWithdrawal
, PParams (LedgerEra era) -> Either String (PParams (LedgerEra era))
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era)))
-> (PParams (LedgerEra era) -> PParams (LedgerEra era))
-> PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Word16 -> Identity Word16)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era))
forall era. ConwayEraPParams era => Lens' (PParams era) Word16
Lens' (PParams (LedgerEra era)) Word16
L.ppCommitteeMinSizeL ((Word16 -> Identity Word16)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era)))
-> Word16 -> PParams (LedgerEra era) -> PParams (LedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Proto PParams
pp Proto PParams -> Getting Word16 (Proto PParams) Word16 -> Word16
forall s a. s -> Getting a s a -> a
^. LensLike' (Const Word16) (Proto PParams) Word32
forall (f :: * -> *) s a.
(Functor f, HasField s "minCommitteeSize" a) =>
LensLike' f s a
U5c.minCommitteeSize LensLike' (Const Word16) (Proto PParams) Word32
-> ((Word16 -> Const Word16 Word16)
-> Word32 -> Const Word16 Word32)
-> Getting Word16 (Proto PParams) Word16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word32 -> Word16) -> SimpleGetter Word32 Word16
forall s a. (s -> a) -> SimpleGetter s a
to Word32 -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
, PParams (LedgerEra era) -> Either String (PParams (LedgerEra era))
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
(PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era)))
-> (PParams (LedgerEra era) -> PParams (LedgerEra era))
-> PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((EpochInterval -> Identity EpochInterval)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era))
forall era.
ConwayEraPParams era =>
Lens' (PParams era) EpochInterval
Lens' (PParams (LedgerEra era)) EpochInterval
L.ppCommitteeMaxTermLengthL ((EpochInterval -> Identity EpochInterval)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era)))
-> EpochInterval
-> PParams (LedgerEra era)
-> PParams (LedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Proto PParams
pp Proto PParams
-> Getting EpochInterval (Proto PParams) EpochInterval
-> EpochInterval
forall s a. s -> Getting a s a -> a
^. LensLike' (Const EpochInterval) (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "committeeTermLimit" a) =>
LensLike' f s a
U5c.committeeTermLimit LensLike' (Const EpochInterval) (Proto PParams) Word64
-> ((EpochInterval -> Const EpochInterval EpochInterval)
-> Word64 -> Const EpochInterval Word64)
-> Getting EpochInterval (Proto PParams) EpochInterval
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word64 -> Word32) -> SimpleGetter Word64 Word32
forall s a. (s -> a) -> SimpleGetter s a
to Word64 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Getting EpochInterval Word64 Word32
-> ((EpochInterval -> Const EpochInterval EpochInterval)
-> Word32 -> Const EpochInterval Word32)
-> (EpochInterval -> Const EpochInterval EpochInterval)
-> Word64
-> Const EpochInterval Word64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word32 -> EpochInterval) -> SimpleGetter Word32 EpochInterval
forall s a. (s -> a) -> SimpleGetter s a
to Word32 -> EpochInterval
L.EpochInterval)
, PParams (LedgerEra era) -> Either String (PParams (LedgerEra era))
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
(PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era)))
-> (PParams (LedgerEra era) -> PParams (LedgerEra era))
-> PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ( (EpochInterval -> Identity EpochInterval)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era))
forall era.
ConwayEraPParams era =>
Lens' (PParams era) EpochInterval
Lens' (PParams (LedgerEra era)) EpochInterval
L.ppGovActionLifetimeL
((EpochInterval -> Identity EpochInterval)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era)))
-> EpochInterval
-> PParams (LedgerEra era)
-> PParams (LedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Proto PParams
pp Proto PParams
-> Getting EpochInterval (Proto PParams) EpochInterval
-> EpochInterval
forall s a. s -> Getting a s a -> a
^. LensLike' (Const EpochInterval) (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "governanceActionValidityPeriod" a) =>
LensLike' f s a
U5c.governanceActionValidityPeriod LensLike' (Const EpochInterval) (Proto PParams) Word64
-> ((EpochInterval -> Const EpochInterval EpochInterval)
-> Word64 -> Const EpochInterval Word64)
-> Getting EpochInterval (Proto PParams) EpochInterval
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word64 -> Word32) -> SimpleGetter Word64 Word32
forall s a. (s -> a) -> SimpleGetter s a
to Word64 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Getting EpochInterval Word64 Word32
-> ((EpochInterval -> Const EpochInterval EpochInterval)
-> Word32 -> Const EpochInterval Word32)
-> (EpochInterval -> Const EpochInterval EpochInterval)
-> Word64
-> Const EpochInterval Word64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word32 -> EpochInterval) -> SimpleGetter Word32 EpochInterval
forall s a. (s -> a) -> SimpleGetter s a
to Word32 -> EpochInterval
L.EpochInterval
)
, \PParams (LedgerEra era)
r -> do
govActionDeposit <-
Proto PParams
pp Proto PParams
-> Getting (Maybe Integer) (Proto PParams) (Maybe Integer)
-> Maybe Integer
forall s a. s -> Getting a s a -> a
^. LensLike' (Const (Maybe Integer)) (Proto PParams) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "governanceActionDeposit" a) =>
LensLike' f s a
U5c.governanceActionDeposit LensLike' (Const (Maybe Integer)) (Proto PParams) (Proto BigInt)
-> ((Maybe Integer -> Const (Maybe Integer) (Maybe Integer))
-> Proto BigInt -> Const (Maybe Integer) (Proto BigInt))
-> Getting (Maybe Integer) (Proto PParams) (Maybe Integer)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto BigInt -> Maybe Integer)
-> SimpleGetter (Proto BigInt) (Maybe Integer)
forall s a. (s -> a) -> SimpleGetter s a
to Proto BigInt -> Maybe Integer
forall (m :: * -> *).
(HasCallStack, MonadThrow m) =>
Proto BigInt -> m Integer
utxoRpcBigIntToInteger Maybe Integer -> String -> Either String Integer
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid governanceActionDeposit"
pure $ set L.ppGovActionDepositL (L.Coin govActionDeposit) r
, \PParams (LedgerEra era)
r -> do
drepDeposit <- Proto PParams
pp Proto PParams
-> Getting (Maybe Integer) (Proto PParams) (Maybe Integer)
-> Maybe Integer
forall s a. s -> Getting a s a -> a
^. LensLike' (Const (Maybe Integer)) (Proto PParams) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "drepDeposit" a) =>
LensLike' f s a
U5c.drepDeposit LensLike' (Const (Maybe Integer)) (Proto PParams) (Proto BigInt)
-> ((Maybe Integer -> Const (Maybe Integer) (Maybe Integer))
-> Proto BigInt -> Const (Maybe Integer) (Proto BigInt))
-> Getting (Maybe Integer) (Proto PParams) (Maybe Integer)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Proto BigInt -> Maybe Integer)
-> SimpleGetter (Proto BigInt) (Maybe Integer)
forall s a. (s -> a) -> SimpleGetter s a
to Proto BigInt -> Maybe Integer
forall (m :: * -> *).
(HasCallStack, MonadThrow m) =>
Proto BigInt -> m Integer
utxoRpcBigIntToInteger Maybe Integer -> String -> Either String Integer
forall e (m :: * -> *) a. MonadError e m => Maybe a -> e -> m a
?! String
"Invalid drepDeposit"
pure $ set L.ppDRepDepositL (L.Coin drepDeposit) r
, PParams (LedgerEra era) -> Either String (PParams (LedgerEra era))
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era)))
-> (PParams (LedgerEra era) -> PParams (LedgerEra era))
-> PParams (LedgerEra era)
-> Either String (PParams (LedgerEra era))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((EpochInterval -> Identity EpochInterval)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era))
forall era.
ConwayEraPParams era =>
Lens' (PParams era) EpochInterval
Lens' (PParams (LedgerEra era)) EpochInterval
L.ppDRepActivityL ((EpochInterval -> Identity EpochInterval)
-> PParams (LedgerEra era) -> Identity (PParams (LedgerEra era)))
-> EpochInterval
-> PParams (LedgerEra era)
-> PParams (LedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Proto PParams
pp Proto PParams
-> Getting EpochInterval (Proto PParams) EpochInterval
-> EpochInterval
forall s a. s -> Getting a s a -> a
^. LensLike' (Const EpochInterval) (Proto PParams) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "drepInactivityPeriod" a) =>
LensLike' f s a
U5c.drepInactivityPeriod LensLike' (Const EpochInterval) (Proto PParams) Word64
-> ((EpochInterval -> Const EpochInterval EpochInterval)
-> Word64 -> Const EpochInterval Word64)
-> Getting EpochInterval (Proto PParams) EpochInterval
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word64 -> Word32) -> SimpleGetter Word64 Word32
forall s a. (s -> a) -> SimpleGetter s a
to Word64 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Getting EpochInterval Word64 Word32
-> ((EpochInterval -> Const EpochInterval EpochInterval)
-> Word32 -> Const EpochInterval Word32)
-> (EpochInterval -> Const EpochInterval EpochInterval)
-> Word64
-> Const EpochInterval Word64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word32 -> EpochInterval) -> SimpleGetter Word32 EpochInterval
forall s a. (s -> a) -> SimpleGetter s a
to Word32 -> EpochInterval
L.EpochInterval)
]
where
appFuns :: Monad m => [a -> m a] -> a -> m a
appFuns :: forall (m :: * -> *) a. Monad m => [a -> m a] -> a -> m a
appFuns [a -> m a]
fs a
a0 = ((a -> m a) -> m a -> m a) -> m a -> [a -> m a] -> m a
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (a -> m a) -> m a -> m a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
(=<<) (a -> m a
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
a0) [a -> m a]
fs
prStepsL :: Lens' L.Prices L.NonNegativeInterval
prStepsL :: Lens' Prices NonNegativeInterval
prStepsL = (Prices -> NonNegativeInterval)
-> (Prices -> NonNegativeInterval -> Prices)
-> Lens' Prices NonNegativeInterval
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Prices -> NonNegativeInterval
L.prSteps ((Prices -> NonNegativeInterval -> Prices)
-> Lens' Prices NonNegativeInterval)
-> (Prices -> NonNegativeInterval -> Prices)
-> Lens' Prices NonNegativeInterval
forall a b. (a -> b) -> a -> b
$ \Prices
p NonNegativeInterval
v -> Prices
p{L.prSteps = v}
prMemL :: Lens' L.Prices L.NonNegativeInterval
prMemL :: Lens' Prices NonNegativeInterval
prMemL = (Prices -> NonNegativeInterval)
-> (Prices -> NonNegativeInterval -> Prices)
-> Lens' Prices NonNegativeInterval
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Prices -> NonNegativeInterval
L.prMem ((Prices -> NonNegativeInterval -> Prices)
-> Lens' Prices NonNegativeInterval)
-> (Prices -> NonNegativeInterval -> Prices)
-> Lens' Prices NonNegativeInterval
forall a b. (a -> b) -> a -> b
$ \Prices
p NonNegativeInterval
v -> Prices
p{L.prMem = v}
utxoRpcProtocolVersionToProtVer :: Proto U5c.ProtocolVersion -> Maybe L.ProtVer
utxoRpcProtocolVersionToProtVer :: Proto ProtocolVersion -> Maybe ProtVer
utxoRpcProtocolVersionToProtVer Proto ProtocolVersion
protocolVersion = do
major <- Word32 -> Maybe Version
forall i (m :: * -> *). (Integral i, MonadFail m) => i -> m Version
L.mkVersion (Word32 -> Maybe Version) -> Word32 -> Maybe Version
forall a b. (a -> b) -> a -> b
$ Proto ProtocolVersion
protocolVersion Proto ProtocolVersion
-> Getting Word32 (Proto ProtocolVersion) Word32 -> Word32
forall s a. s -> Getting a s a -> a
^. Getting Word32 (Proto ProtocolVersion) Word32
forall (f :: * -> *) s a.
(Functor f, HasField s "major" a) =>
LensLike' f s a
U5c.major
pure
L.ProtVer
{ L.pvMajor = major
, L.pvMinor = fromIntegral $ protocolVersion ^. U5c.minor
}