{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE NumericUnderscores #-}
module Cardano.Rpc.Server.Internal.UtxoRpc.Type.Genesis
( genesisBundleToProto
, byronGenesisToProto
, shelleyGenesisToProto
, alonzoGenesisToProto
, conwayGenesisToProto
)
where
import Cardano.Api.Era (Inject (..))
import Cardano.Api.Ledger qualified as L
import Cardano.Rpc.Proto.Api.UtxoRpc.Query qualified as U5c
import Cardano.Rpc.Server.Internal.Orphans ()
import Cardano.Rpc.Server.Internal.UtxoRpc.Type.Certificate
( constitutionToUtxoRpcConstitution
, keyHashToBytes
, scriptHashToBytes
)
import Cardano.Rpc.Server.NodeKernelAccess.Type (GenesisBundle (..))
import Cardano.Chain.Common qualified as Byron
( KeyHash
, LovelacePortion
, TxFeePolicy (..)
, TxSizeLinear (..)
, addressF
, lovelacePortionToRational
, lovelaceToInteger
, unBlockCount
, unKeyHash
)
import Cardano.Chain.Delegation qualified as Byron
( Certificate
, delegateVK
, epoch
, issuerVK
, signature
)
import Cardano.Chain.Genesis qualified as Byron
( GenesisAvvmBalances (..)
, GenesisData (..)
, GenesisDelegation (..)
, GenesisKeyHashes (..)
, GenesisNonAvvmBalances (..)
, configGenesisData
)
import Cardano.Chain.Slotting qualified as Byron (getEpochNumber, unSlotNumber)
import Cardano.Chain.Update qualified as Byron (ProtocolParameters (..), SoftforkRule (..))
import Cardano.Crypto qualified as Byron
( fromCompactRedeemVerificationKey
, fullSignatureHexF
, fullVerificationKeyF
, hashHexF
, redeemVKB64UrlF
, unProtocolMagicId
)
import Cardano.Ledger.Address qualified as L
import Cardano.Ledger.Alonzo.Genesis qualified as L
import Cardano.Ledger.Api qualified as L
import Cardano.Ledger.Api.Transition qualified as L
import Cardano.Ledger.BaseTypes qualified as L
import Cardano.Ledger.Conway.PParams qualified as L
import Cardano.Ledger.Hashes qualified as L
import Cardano.Ledger.Shelley.Genesis qualified as L
import RIO
import Data.ByteString.Base16 qualified as Base16
import Data.Map.Strict qualified as Map
import Data.ProtoLens (defMessage)
import Data.Text qualified as Text (pack)
import Data.Text.Encoding qualified as Text (decodeUtf8)
import Data.Time.Clock.POSIX (utcTimeToPOSIXSeconds)
import Data.Time.Format.ISO8601 (iso8601Show)
import Formatting (sformat)
import GHC.Exts qualified as Exts (toList)
import Lens.Micro ((?~))
import Network.GRPC.Spec
genesisBundleToProto :: GenesisBundle -> Proto U5c.Genesis
genesisBundleToProto :: GenesisBundle -> Proto Genesis
genesisBundleToProto GenesisBundle{Config
byronConfig :: Config
byronConfig :: GenesisBundle -> Config
byronConfig, TransitionConfig LatestKnownEra
transitionConfig :: TransitionConfig LatestKnownEra
transitionConfig :: GenesisBundle -> TransitionConfig LatestKnownEra
transitionConfig} =
GenesisData -> Proto Genesis -> Proto Genesis
byronGenesisToProto GenesisData
byronGenesis
(Proto Genesis -> Proto Genesis)
-> (Proto Genesis -> Proto Genesis)
-> Proto Genesis
-> Proto Genesis
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyGenesis -> Proto Genesis -> Proto Genesis
shelleyGenesisToProto ShelleyGenesis
shelleyGenesis
(Proto Genesis -> Proto Genesis)
-> (Proto Genesis -> Proto Genesis)
-> Proto Genesis
-> Proto Genesis
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AlonzoGenesis -> Proto Genesis -> Proto Genesis
alonzoGenesisToProto AlonzoGenesis
alonzoGenesis
(Proto Genesis -> Proto Genesis)
-> (Proto Genesis -> Proto Genesis)
-> Proto Genesis
-> Proto Genesis
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConwayGenesis -> Proto Genesis -> Proto Genesis
conwayGenesisToProto ConwayGenesis
conwayGenesis
(Proto Genesis -> Proto Genesis) -> Proto Genesis -> Proto Genesis
forall a b. (a -> b) -> a -> b
$ Proto Genesis
forall msg. Message msg => msg
defMessage
where
byronGenesis :: GenesisData
byronGenesis = Config -> GenesisData
Byron.configGenesisData Config
byronConfig
shelleyGenesis :: ShelleyGenesis
shelleyGenesis = TransitionConfig LatestKnownEra
transitionConfig TransitionConfig LatestKnownEra
-> Getting
ShelleyGenesis (TransitionConfig LatestKnownEra) ShelleyGenesis
-> ShelleyGenesis
forall s a. s -> Getting a s a -> a
^. Getting
ShelleyGenesis (TransitionConfig LatestKnownEra) ShelleyGenesis
forall era.
EraTransition era =>
Lens' (TransitionConfig era) ShelleyGenesis
Lens' (TransitionConfig LatestKnownEra) ShelleyGenesis
L.tcShelleyGenesisL
conwayGenesis :: ConwayGenesis
conwayGenesis = TransitionConfig LatestKnownEra
transitionConfig TransitionConfig LatestKnownEra
-> Getting
ConwayGenesis (TransitionConfig LatestKnownEra) ConwayGenesis
-> ConwayGenesis
forall s a. s -> Getting a s a -> a
^. (TransitionConfig (PreviousEra LatestKnownEra)
-> Const
ConwayGenesis (TransitionConfig (PreviousEra LatestKnownEra)))
-> TransitionConfig LatestKnownEra
-> Const ConwayGenesis (TransitionConfig LatestKnownEra)
(TransitionConfig ConwayEra
-> Const ConwayGenesis (TransitionConfig ConwayEra))
-> TransitionConfig LatestKnownEra
-> Const ConwayGenesis (TransitionConfig LatestKnownEra)
forall era.
(EraTransition era, EraTransition (PreviousEra era)) =>
Lens' (TransitionConfig era) (TransitionConfig (PreviousEra era))
Lens'
(TransitionConfig LatestKnownEra)
(TransitionConfig (PreviousEra LatestKnownEra))
L.tcPreviousEraConfigL ((TransitionConfig ConwayEra
-> Const ConwayGenesis (TransitionConfig ConwayEra))
-> TransitionConfig LatestKnownEra
-> Const ConwayGenesis (TransitionConfig LatestKnownEra))
-> ((ConwayGenesis -> Const ConwayGenesis ConwayGenesis)
-> TransitionConfig ConwayEra
-> Const ConwayGenesis (TransitionConfig ConwayEra))
-> Getting
ConwayGenesis (TransitionConfig LatestKnownEra) ConwayGenesis
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ConwayGenesis -> Const ConwayGenesis ConwayGenesis)
-> TransitionConfig ConwayEra
-> Const ConwayGenesis (TransitionConfig ConwayEra)
(TranslationContext ConwayEra
-> Const ConwayGenesis (TranslationContext ConwayEra))
-> TransitionConfig ConwayEra
-> Const ConwayGenesis (TransitionConfig ConwayEra)
forall era.
EraTransition era =>
Lens' (TransitionConfig era) (TranslationContext era)
Lens' (TransitionConfig ConwayEra) (TranslationContext ConwayEra)
L.tcTranslationContextL
alonzoGenesis :: AlonzoGenesis
alonzoGenesis =
TransitionConfig LatestKnownEra
transitionConfig
TransitionConfig LatestKnownEra
-> Getting
AlonzoGenesis (TransitionConfig LatestKnownEra) AlonzoGenesis
-> AlonzoGenesis
forall s a. s -> Getting a s a -> a
^. (TransitionConfig (PreviousEra LatestKnownEra)
-> Const
AlonzoGenesis (TransitionConfig (PreviousEra LatestKnownEra)))
-> TransitionConfig LatestKnownEra
-> Const AlonzoGenesis (TransitionConfig LatestKnownEra)
(TransitionConfig ConwayEra
-> Const AlonzoGenesis (TransitionConfig ConwayEra))
-> TransitionConfig LatestKnownEra
-> Const AlonzoGenesis (TransitionConfig LatestKnownEra)
forall era.
(EraTransition era, EraTransition (PreviousEra era)) =>
Lens' (TransitionConfig era) (TransitionConfig (PreviousEra era))
Lens'
(TransitionConfig LatestKnownEra)
(TransitionConfig (PreviousEra LatestKnownEra))
L.tcPreviousEraConfigL
((TransitionConfig ConwayEra
-> Const AlonzoGenesis (TransitionConfig ConwayEra))
-> TransitionConfig LatestKnownEra
-> Const AlonzoGenesis (TransitionConfig LatestKnownEra))
-> ((AlonzoGenesis -> Const AlonzoGenesis AlonzoGenesis)
-> TransitionConfig ConwayEra
-> Const AlonzoGenesis (TransitionConfig ConwayEra))
-> Getting
AlonzoGenesis (TransitionConfig LatestKnownEra) AlonzoGenesis
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TransitionConfig (PreviousEra ConwayEra)
-> Const AlonzoGenesis (TransitionConfig (PreviousEra ConwayEra)))
-> TransitionConfig ConwayEra
-> Const AlonzoGenesis (TransitionConfig ConwayEra)
(TransitionConfig BabbageEra
-> Const AlonzoGenesis (TransitionConfig BabbageEra))
-> TransitionConfig ConwayEra
-> Const AlonzoGenesis (TransitionConfig ConwayEra)
forall era.
(EraTransition era, EraTransition (PreviousEra era)) =>
Lens' (TransitionConfig era) (TransitionConfig (PreviousEra era))
Lens'
(TransitionConfig ConwayEra)
(TransitionConfig (PreviousEra ConwayEra))
L.tcPreviousEraConfigL
((TransitionConfig BabbageEra
-> Const AlonzoGenesis (TransitionConfig BabbageEra))
-> TransitionConfig ConwayEra
-> Const AlonzoGenesis (TransitionConfig ConwayEra))
-> ((AlonzoGenesis -> Const AlonzoGenesis AlonzoGenesis)
-> TransitionConfig BabbageEra
-> Const AlonzoGenesis (TransitionConfig BabbageEra))
-> (AlonzoGenesis -> Const AlonzoGenesis AlonzoGenesis)
-> TransitionConfig ConwayEra
-> Const AlonzoGenesis (TransitionConfig ConwayEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TransitionConfig (PreviousEra BabbageEra)
-> Const AlonzoGenesis (TransitionConfig (PreviousEra BabbageEra)))
-> TransitionConfig BabbageEra
-> Const AlonzoGenesis (TransitionConfig BabbageEra)
(TransitionConfig AlonzoEra
-> Const AlonzoGenesis (TransitionConfig AlonzoEra))
-> TransitionConfig BabbageEra
-> Const AlonzoGenesis (TransitionConfig BabbageEra)
forall era.
(EraTransition era, EraTransition (PreviousEra era)) =>
Lens' (TransitionConfig era) (TransitionConfig (PreviousEra era))
Lens'
(TransitionConfig BabbageEra)
(TransitionConfig (PreviousEra BabbageEra))
L.tcPreviousEraConfigL
((TransitionConfig AlonzoEra
-> Const AlonzoGenesis (TransitionConfig AlonzoEra))
-> TransitionConfig BabbageEra
-> Const AlonzoGenesis (TransitionConfig BabbageEra))
-> ((AlonzoGenesis -> Const AlonzoGenesis AlonzoGenesis)
-> TransitionConfig AlonzoEra
-> Const AlonzoGenesis (TransitionConfig AlonzoEra))
-> (AlonzoGenesis -> Const AlonzoGenesis AlonzoGenesis)
-> TransitionConfig BabbageEra
-> Const AlonzoGenesis (TransitionConfig BabbageEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AlonzoGenesis -> Const AlonzoGenesis AlonzoGenesis)
-> TransitionConfig AlonzoEra
-> Const AlonzoGenesis (TransitionConfig AlonzoEra)
(TranslationContext AlonzoEra
-> Const AlonzoGenesis (TranslationContext AlonzoEra))
-> TransitionConfig AlonzoEra
-> Const AlonzoGenesis (TransitionConfig AlonzoEra)
forall era.
EraTransition era =>
Lens' (TransitionConfig era) (TranslationContext era)
Lens' (TransitionConfig AlonzoEra) (TranslationContext AlonzoEra)
L.tcTranslationContextL
byronGenesisToProto :: Byron.GenesisData -> Proto U5c.Genesis -> Proto U5c.Genesis
byronGenesisToProto :: GenesisData -> Proto Genesis -> Proto Genesis
byronGenesisToProto GenesisData
genesisData Proto Genesis
message =
Proto Genesis
message
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Map Text Text)
forall (f :: * -> *) s a.
(Functor f, HasField s "avvmDistr" a) =>
LensLike' f s a
U5c.avvmDistr LensLike' Identity (Proto Genesis) (Map Text Text)
-> Map Text Text -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Map Text Text
avvmDistr
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto BlockVersionData)
forall (f :: * -> *) s a.
(Functor f, HasField s "blockVersionData" a) =>
LensLike' f s a
U5c.blockVersionData LensLike' Identity (Proto Genesis) (Proto BlockVersionData)
-> Proto BlockVersionData -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ProtocolParameters -> Proto BlockVersionData
blockVersionData (GenesisData -> ProtocolParameters
Byron.gdProtocolParameters GenesisData
genesisData)
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto ProtocolConsts)
forall (f :: * -> *) s a.
(Functor f, HasField s "protocolConsts" a) =>
LensLike' f s a
U5c.protocolConsts LensLike' Identity (Proto Genesis) (Proto ProtocolConsts)
-> Proto ProtocolConsts -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Proto ProtocolConsts
protocolConsts
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "startTime" a) =>
LensLike' f s a
U5c.startTime LensLike' Identity (Proto Genesis) Word64
-> Word64 -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word64
startTime
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Map Text Word64)
forall (f :: * -> *) s a.
(Functor f, HasField s "bootStakeholders" a) =>
LensLike' f s a
U5c.bootStakeholders LensLike' Identity (Proto Genesis) (Map Text Word64)
-> Map Text Word64 -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Map Text Word64
bootStakeholders
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike'
Identity (Proto Genesis) (Map Text (Proto HeavyDelegation))
forall (f :: * -> *) s a.
(Functor f, HasField s "heavyDelegation" a) =>
LensLike' f s a
U5c.heavyDelegation LensLike'
Identity (Proto Genesis) (Map Text (Proto HeavyDelegation))
-> Map Text (Proto HeavyDelegation)
-> Proto Genesis
-> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Map Text (Proto HeavyDelegation)
heavyDelegation
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Map Text Text)
forall (f :: * -> *) s a.
(Functor f, HasField s "nonAvvmBalances" a) =>
LensLike' f s a
U5c.nonAvvmBalances LensLike' Identity (Proto Genesis) (Map Text Text)
-> Map Text Text -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Map Text Text
nonAvvmBalances
where
startTime :: Word64
startTime :: Word64
startTime = NominalDiffTime -> Word64
forall b. Integral b => NominalDiffTime -> b
forall a b. (RealFrac a, Integral b) => a -> b
round (UTCTime -> NominalDiffTime
utcTimeToPOSIXSeconds (GenesisData -> UTCTime
Byron.gdStartTime GenesisData
genesisData))
protocolConsts :: Proto U5c.ProtocolConsts
protocolConsts :: Proto ProtocolConsts
protocolConsts =
Proto ProtocolConsts
forall msg. Message msg => msg
defMessage
Proto ProtocolConsts
-> (Proto ProtocolConsts -> Proto ProtocolConsts)
-> Proto ProtocolConsts
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto ProtocolConsts) Word32
forall (f :: * -> *) s a.
(Functor f, HasField s "k" a) =>
LensLike' f s a
U5c.k LensLike' Identity (Proto ProtocolConsts) Word32
-> Word32 -> Proto ProtocolConsts -> Proto ProtocolConsts
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word64 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (BlockCount -> Word64
Byron.unBlockCount (GenesisData -> BlockCount
Byron.gdK GenesisData
genesisData))
Proto ProtocolConsts
-> (Proto ProtocolConsts -> Proto ProtocolConsts)
-> Proto ProtocolConsts
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto ProtocolConsts) Word32
forall (f :: * -> *) s a.
(Functor f, HasField s "protocolMagic" a) =>
LensLike' f s a
U5c.protocolMagic LensLike' Identity (Proto ProtocolConsts) Word32
-> Word32 -> Proto ProtocolConsts -> Proto ProtocolConsts
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ProtocolMagicId -> Word32
Byron.unProtocolMagicId (GenesisData -> ProtocolMagicId
Byron.gdProtocolMagicId GenesisData
genesisData)
bootStakeholders :: Map Text Word64
bootStakeholders :: Map Text Word64
bootStakeholders =
[(Text, Word64)] -> Map Text Word64
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
[ (KeyHash -> Text
byronKeyHashHex KeyHash
keyHash, Word64
1)
| KeyHash
keyHash <- Set KeyHash -> [KeyHash]
forall a. Set a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (GenesisKeyHashes -> Set KeyHash
Byron.unGenesisKeyHashes (GenesisData -> GenesisKeyHashes
Byron.gdGenesisKeyHashes GenesisData
genesisData))
]
heavyDelegation :: Map Text (Proto U5c.HeavyDelegation)
heavyDelegation :: Map Text (Proto HeavyDelegation)
heavyDelegation =
[(Text, Proto HeavyDelegation)] -> Map Text (Proto HeavyDelegation)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
[ (KeyHash -> Text
byronKeyHashHex KeyHash
keyHash, Certificate -> Proto HeavyDelegation
heavyDelegationCert Certificate
cert)
| (KeyHash
keyHash, Certificate
cert) <-
Map KeyHash Certificate -> [(KeyHash, Certificate)]
forall k a. Map k a -> [(k, a)]
Map.toList (GenesisDelegation -> Map KeyHash Certificate
Byron.unGenesisDelegation (GenesisData -> GenesisDelegation
Byron.gdHeavyDelegation GenesisData
genesisData))
]
nonAvvmBalances :: Map Text Text
nonAvvmBalances :: Map Text Text
nonAvvmBalances =
[(Text, Text)] -> Map Text Text
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
[ (Format Text (Address -> Text) -> Address -> Text
forall a. Format Text a -> a
sformat Format Text (Address -> Text)
forall r. Format r (Address -> r)
Byron.addressF Address
address, Integer -> Text
forall a. Show a => a -> Text
tshow (Lovelace -> Integer
Byron.lovelaceToInteger Lovelace
lovelace))
| (Address
address, Lovelace
lovelace) <-
Map Address Lovelace -> [(Address, Lovelace)]
forall k a. Map k a -> [(k, a)]
Map.toList (GenesisNonAvvmBalances -> Map Address Lovelace
Byron.unGenesisNonAvvmBalances (GenesisData -> GenesisNonAvvmBalances
Byron.gdNonAvvmBalances GenesisData
genesisData))
]
avvmDistr :: Map Text Text
avvmDistr :: Map Text Text
avvmDistr =
[(Text, Text)] -> Map Text Text
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
[ ( Format Text (RedeemVerificationKey -> Text)
-> RedeemVerificationKey -> Text
forall a. Format Text a -> a
sformat Format Text (RedeemVerificationKey -> Text)
forall r. Format r (RedeemVerificationKey -> r)
Byron.redeemVKB64UrlF (CompactRedeemVerificationKey -> RedeemVerificationKey
Byron.fromCompactRedeemVerificationKey CompactRedeemVerificationKey
redeemKey)
, Integer -> Text
forall a. Show a => a -> Text
tshow (Lovelace -> Integer
Byron.lovelaceToInteger Lovelace
lovelace)
)
| (CompactRedeemVerificationKey
redeemKey, Lovelace
lovelace) <-
Map CompactRedeemVerificationKey Lovelace
-> [(CompactRedeemVerificationKey, Lovelace)]
forall k a. Map k a -> [(k, a)]
Map.toList (GenesisAvvmBalances -> Map CompactRedeemVerificationKey Lovelace
Byron.unGenesisAvvmBalances (GenesisData -> GenesisAvvmBalances
Byron.gdAvvmDistr GenesisData
genesisData))
]
byronKeyHashHex :: Byron.KeyHash -> Text
byronKeyHashHex :: KeyHash -> Text
byronKeyHashHex = Format Text (AbstractHash Blake2b_224 VerificationKey -> Text)
-> AbstractHash Blake2b_224 VerificationKey -> Text
forall a. Format Text a -> a
sformat Format Text (AbstractHash Blake2b_224 VerificationKey -> Text)
forall r algo a. Format r (AbstractHash algo a -> r)
Byron.hashHexF (AbstractHash Blake2b_224 VerificationKey -> Text)
-> (KeyHash -> AbstractHash Blake2b_224 VerificationKey)
-> KeyHash
-> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. KeyHash -> AbstractHash Blake2b_224 VerificationKey
Byron.unKeyHash
heavyDelegationCert :: Byron.Certificate -> Proto U5c.HeavyDelegation
heavyDelegationCert :: Certificate -> Proto HeavyDelegation
heavyDelegationCert Certificate
cert =
Proto HeavyDelegation
forall msg. Message msg => msg
defMessage
Proto HeavyDelegation
-> (Proto HeavyDelegation -> Proto HeavyDelegation)
-> Proto HeavyDelegation
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto HeavyDelegation) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "cert" a) =>
LensLike' f s a
U5c.cert LensLike' Identity (Proto HeavyDelegation) Text
-> Text -> Proto HeavyDelegation -> Proto HeavyDelegation
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Format Text (Signature EpochNumber -> Text)
-> Signature EpochNumber -> Text
forall a. Format Text a -> a
sformat Format Text (Signature EpochNumber -> Text)
forall r a. Format r (Signature a -> r)
Byron.fullSignatureHexF (Certificate -> Signature EpochNumber
forall a. ACertificate a -> Signature EpochNumber
Byron.signature Certificate
cert)
Proto HeavyDelegation
-> (Proto HeavyDelegation -> Proto HeavyDelegation)
-> Proto HeavyDelegation
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto HeavyDelegation) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "delegatePk" a) =>
LensLike' f s a
U5c.delegatePk LensLike' Identity (Proto HeavyDelegation) Text
-> Text -> Proto HeavyDelegation -> Proto HeavyDelegation
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Format Text (VerificationKey -> Text) -> VerificationKey -> Text
forall a. Format Text a -> a
sformat Format Text (VerificationKey -> Text)
forall r. Format r (VerificationKey -> r)
Byron.fullVerificationKeyF (Certificate -> VerificationKey
forall a. ACertificate a -> VerificationKey
Byron.delegateVK Certificate
cert)
Proto HeavyDelegation
-> (Proto HeavyDelegation -> Proto HeavyDelegation)
-> Proto HeavyDelegation
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto HeavyDelegation) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "issuerPk" a) =>
LensLike' f s a
U5c.issuerPk LensLike' Identity (Proto HeavyDelegation) Text
-> Text -> Proto HeavyDelegation -> Proto HeavyDelegation
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Format Text (VerificationKey -> Text) -> VerificationKey -> Text
forall a. Format Text a -> a
sformat Format Text (VerificationKey -> Text)
forall r. Format r (VerificationKey -> r)
Byron.fullVerificationKeyF (Certificate -> VerificationKey
forall a. ACertificate a -> VerificationKey
Byron.issuerVK Certificate
cert)
Proto HeavyDelegation
-> (Proto HeavyDelegation -> Proto HeavyDelegation)
-> Proto HeavyDelegation
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto HeavyDelegation) Word32
forall (f :: * -> *) s a.
(Functor f, HasField s "omega" a) =>
LensLike' f s a
U5c.omega LensLike' Identity (Proto HeavyDelegation) Word32
-> Word32 -> Proto HeavyDelegation -> Proto HeavyDelegation
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word64 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (EpochNumber -> Word64
Byron.getEpochNumber (Certificate -> EpochNumber
forall a. ACertificate a -> EpochNumber
Byron.epoch Certificate
cert))
blockVersionData :: Byron.ProtocolParameters -> Proto U5c.BlockVersionData
blockVersionData :: ProtocolParameters -> Proto BlockVersionData
blockVersionData ProtocolParameters
pp =
Proto BlockVersionData
forall msg. Message msg => msg
defMessage
Proto BlockVersionData
-> (Proto BlockVersionData -> Proto BlockVersionData)
-> Proto BlockVersionData
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto BlockVersionData) Word32
forall (f :: * -> *) s a.
(Functor f, HasField s "scriptVersion" a) =>
LensLike' f s a
U5c.scriptVersion LensLike' Identity (Proto BlockVersionData) Word32
-> Word32 -> Proto BlockVersionData -> Proto BlockVersionData
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 (ProtocolParameters -> Word16
Byron.ppScriptVersion ProtocolParameters
pp)
Proto BlockVersionData
-> (Proto BlockVersionData -> Proto BlockVersionData)
-> Proto BlockVersionData
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto BlockVersionData) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "slotDuration" a) =>
LensLike' f s a
U5c.slotDuration LensLike' Identity (Proto BlockVersionData) Text
-> Text -> Proto BlockVersionData -> Proto BlockVersionData
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Natural -> Text
forall a. Show a => a -> Text
tshow (ProtocolParameters -> Natural
Byron.ppSlotDuration ProtocolParameters
pp)
Proto BlockVersionData
-> (Proto BlockVersionData -> Proto BlockVersionData)
-> Proto BlockVersionData
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto BlockVersionData) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "maxBlockSize" a) =>
LensLike' f s a
U5c.maxBlockSize LensLike' Identity (Proto BlockVersionData) Text
-> Text -> Proto BlockVersionData -> Proto BlockVersionData
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Natural -> Text
forall a. Show a => a -> Text
tshow (ProtocolParameters -> Natural
Byron.ppMaxBlockSize ProtocolParameters
pp)
Proto BlockVersionData
-> (Proto BlockVersionData -> Proto BlockVersionData)
-> Proto BlockVersionData
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto BlockVersionData) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "maxHeaderSize" a) =>
LensLike' f s a
U5c.maxHeaderSize LensLike' Identity (Proto BlockVersionData) Text
-> Text -> Proto BlockVersionData -> Proto BlockVersionData
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Natural -> Text
forall a. Show a => a -> Text
tshow (ProtocolParameters -> Natural
Byron.ppMaxHeaderSize ProtocolParameters
pp)
Proto BlockVersionData
-> (Proto BlockVersionData -> Proto BlockVersionData)
-> Proto BlockVersionData
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto BlockVersionData) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "maxTxSize" a) =>
LensLike' f s a
U5c.maxTxSize LensLike' Identity (Proto BlockVersionData) Text
-> Text -> Proto BlockVersionData -> Proto BlockVersionData
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Natural -> Text
forall a. Show a => a -> Text
tshow (ProtocolParameters -> Natural
Byron.ppMaxTxSize ProtocolParameters
pp)
Proto BlockVersionData
-> (Proto BlockVersionData -> Proto BlockVersionData)
-> Proto BlockVersionData
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto BlockVersionData) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "maxProposalSize" a) =>
LensLike' f s a
U5c.maxProposalSize LensLike' Identity (Proto BlockVersionData) Text
-> Text -> Proto BlockVersionData -> Proto BlockVersionData
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Natural -> Text
forall a. Show a => a -> Text
tshow (ProtocolParameters -> Natural
Byron.ppMaxProposalSize ProtocolParameters
pp)
Proto BlockVersionData
-> (Proto BlockVersionData -> Proto BlockVersionData)
-> Proto BlockVersionData
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto BlockVersionData) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "mpcThd" a) =>
LensLike' f s a
U5c.mpcThd LensLike' Identity (Proto BlockVersionData) Text
-> Text -> Proto BlockVersionData -> Proto BlockVersionData
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word64 -> Text
forall a. Show a => a -> Text
tshow (LovelacePortion -> Word64
lovelacePortionWord (ProtocolParameters -> LovelacePortion
Byron.ppMpcThd ProtocolParameters
pp))
Proto BlockVersionData
-> (Proto BlockVersionData -> Proto BlockVersionData)
-> Proto BlockVersionData
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto BlockVersionData) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "heavyDelThd" a) =>
LensLike' f s a
U5c.heavyDelThd LensLike' Identity (Proto BlockVersionData) Text
-> Text -> Proto BlockVersionData -> Proto BlockVersionData
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word64 -> Text
forall a. Show a => a -> Text
tshow (LovelacePortion -> Word64
lovelacePortionWord (ProtocolParameters -> LovelacePortion
Byron.ppHeavyDelThd ProtocolParameters
pp))
Proto BlockVersionData
-> (Proto BlockVersionData -> Proto BlockVersionData)
-> Proto BlockVersionData
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto BlockVersionData) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "updateVoteThd" a) =>
LensLike' f s a
U5c.updateVoteThd LensLike' Identity (Proto BlockVersionData) Text
-> Text -> Proto BlockVersionData -> Proto BlockVersionData
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word64 -> Text
forall a. Show a => a -> Text
tshow (LovelacePortion -> Word64
lovelacePortionWord (ProtocolParameters -> LovelacePortion
Byron.ppUpdateVoteThd ProtocolParameters
pp))
Proto BlockVersionData
-> (Proto BlockVersionData -> Proto BlockVersionData)
-> Proto BlockVersionData
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto BlockVersionData) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "updateProposalThd" a) =>
LensLike' f s a
U5c.updateProposalThd LensLike' Identity (Proto BlockVersionData) Text
-> Text -> Proto BlockVersionData -> Proto BlockVersionData
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word64 -> Text
forall a. Show a => a -> Text
tshow (LovelacePortion -> Word64
lovelacePortionWord (ProtocolParameters -> LovelacePortion
Byron.ppUpdateProposalThd ProtocolParameters
pp))
Proto BlockVersionData
-> (Proto BlockVersionData -> Proto BlockVersionData)
-> Proto BlockVersionData
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto BlockVersionData) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "updateImplicit" a) =>
LensLike' f s a
U5c.updateImplicit LensLike' Identity (Proto BlockVersionData) Text
-> Text -> Proto BlockVersionData -> Proto BlockVersionData
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word64 -> Text
forall a. Show a => a -> Text
tshow (SlotNumber -> Word64
Byron.unSlotNumber (ProtocolParameters -> SlotNumber
Byron.ppUpdateProposalTTL ProtocolParameters
pp))
Proto BlockVersionData
-> (Proto BlockVersionData -> Proto BlockVersionData)
-> Proto BlockVersionData
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto BlockVersionData) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "unlockStakeEpoch" a) =>
LensLike' f s a
U5c.unlockStakeEpoch LensLike' Identity (Proto BlockVersionData) Text
-> Text -> Proto BlockVersionData -> Proto BlockVersionData
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word64 -> Text
forall a. Show a => a -> Text
tshow (EpochNumber -> Word64
Byron.getEpochNumber (ProtocolParameters -> EpochNumber
Byron.ppUnlockStakeEpoch ProtocolParameters
pp))
Proto BlockVersionData
-> (Proto BlockVersionData -> Proto BlockVersionData)
-> Proto BlockVersionData
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto BlockVersionData) (Proto SoftforkRule)
forall (f :: * -> *) s a.
(Functor f, HasField s "softforkRule" a) =>
LensLike' f s a
U5c.softforkRule LensLike' Identity (Proto BlockVersionData) (Proto SoftforkRule)
-> Proto SoftforkRule
-> Proto BlockVersionData
-> Proto BlockVersionData
forall s t a b. ASetter s t a b -> b -> s -> t
.~ SoftforkRule -> Proto SoftforkRule
softforkRule (ProtocolParameters -> SoftforkRule
Byron.ppSoftforkRule ProtocolParameters
pp)
Proto BlockVersionData
-> (Proto BlockVersionData -> Proto BlockVersionData)
-> Proto BlockVersionData
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto BlockVersionData) (Proto TxFeePolicy)
forall (f :: * -> *) s a.
(Functor f, HasField s "txFeePolicy" a) =>
LensLike' f s a
U5c.txFeePolicy LensLike' Identity (Proto BlockVersionData) (Proto TxFeePolicy)
-> Proto TxFeePolicy
-> Proto BlockVersionData
-> Proto BlockVersionData
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxFeePolicy -> Proto TxFeePolicy
txFeePolicy (ProtocolParameters -> TxFeePolicy
Byron.ppTxFeePolicy ProtocolParameters
pp)
softforkRule :: Byron.SoftforkRule -> Proto U5c.SoftforkRule
softforkRule :: SoftforkRule -> Proto SoftforkRule
softforkRule SoftforkRule
rule =
Proto SoftforkRule
forall msg. Message msg => msg
defMessage
Proto SoftforkRule
-> (Proto SoftforkRule -> Proto SoftforkRule) -> Proto SoftforkRule
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto SoftforkRule) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "initThd" a) =>
LensLike' f s a
U5c.initThd LensLike' Identity (Proto SoftforkRule) Text
-> Text -> Proto SoftforkRule -> Proto SoftforkRule
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word64 -> Text
forall a. Show a => a -> Text
tshow (LovelacePortion -> Word64
lovelacePortionWord (SoftforkRule -> LovelacePortion
Byron.srInitThd SoftforkRule
rule))
Proto SoftforkRule
-> (Proto SoftforkRule -> Proto SoftforkRule) -> Proto SoftforkRule
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto SoftforkRule) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "minThd" a) =>
LensLike' f s a
U5c.minThd LensLike' Identity (Proto SoftforkRule) Text
-> Text -> Proto SoftforkRule -> Proto SoftforkRule
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word64 -> Text
forall a. Show a => a -> Text
tshow (LovelacePortion -> Word64
lovelacePortionWord (SoftforkRule -> LovelacePortion
Byron.srMinThd SoftforkRule
rule))
Proto SoftforkRule
-> (Proto SoftforkRule -> Proto SoftforkRule) -> Proto SoftforkRule
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto SoftforkRule) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "thdDecrement" a) =>
LensLike' f s a
U5c.thdDecrement LensLike' Identity (Proto SoftforkRule) Text
-> Text -> Proto SoftforkRule -> Proto SoftforkRule
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word64 -> Text
forall a. Show a => a -> Text
tshow (LovelacePortion -> Word64
lovelacePortionWord (SoftforkRule -> LovelacePortion
Byron.srThdDecrement SoftforkRule
rule))
lovelacePortionWord :: Byron.LovelacePortion -> Word64
lovelacePortionWord :: LovelacePortion -> Word64
lovelacePortionWord = Ratio Integer -> Word64
forall b. Integral b => Ratio Integer -> b
forall a b. (RealFrac a, Integral b) => a -> b
round (Ratio Integer -> Word64)
-> (LovelacePortion -> Ratio Integer) -> LovelacePortion -> Word64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Ratio Integer -> Ratio Integer -> Ratio Integer
forall a. Num a => a -> a -> a
* Ratio Integer
1_000_000_000_000_000) (Ratio Integer -> Ratio Integer)
-> (LovelacePortion -> Ratio Integer)
-> LovelacePortion
-> Ratio Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LovelacePortion -> Ratio Integer
Byron.lovelacePortionToRational
txFeePolicy :: Byron.TxFeePolicy -> Proto U5c.TxFeePolicy
txFeePolicy :: TxFeePolicy -> Proto TxFeePolicy
txFeePolicy = \case
Byron.TxFeePolicyTxSizeLinear (Byron.TxSizeLinear Lovelace
constant Ratio Integer
multiplier) ->
Proto TxFeePolicy
forall msg. Message msg => msg
defMessage
Proto TxFeePolicy
-> (Proto TxFeePolicy -> Proto TxFeePolicy) -> Proto TxFeePolicy
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto TxFeePolicy) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "summand" a) =>
LensLike' f s a
U5c.summand LensLike' Identity (Proto TxFeePolicy) Text
-> Text -> Proto TxFeePolicy -> Proto TxFeePolicy
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Integer -> Text
forall a. Show a => a -> Text
tshow (Integer
1_000_000_000 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Lovelace -> Integer
Byron.lovelaceToInteger Lovelace
constant)
Proto TxFeePolicy
-> (Proto TxFeePolicy -> Proto TxFeePolicy) -> Proto TxFeePolicy
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto TxFeePolicy) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "multiplier" a) =>
LensLike' f s a
U5c.multiplier LensLike' Identity (Proto TxFeePolicy) Text
-> Text -> Proto TxFeePolicy -> Proto TxFeePolicy
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Integer -> Text
forall a. Show a => a -> Text
tshow (Ratio Integer -> Integer
forall b. Integral b => Ratio Integer -> b
forall a b. (RealFrac a, Integral b) => a -> b
floor (Ratio Integer
1_000_000_000 Ratio Integer -> Ratio Integer -> Ratio Integer
forall a. Num a => a -> a -> a
* Ratio Integer
multiplier) :: Integer)
shelleyGenesisToProto :: L.ShelleyGenesis -> Proto U5c.Genesis -> Proto U5c.Genesis
shelleyGenesisToProto :: ShelleyGenesis -> Proto Genesis -> Proto Genesis
shelleyGenesisToProto ShelleyGenesis
genesis Proto Genesis
message =
Proto Genesis
message
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "activeSlotsCoeff" a) =>
LensLike' f s a
U5c.activeSlotsCoeff LensLike' Identity (Proto Genesis) (Proto RationalNumber)
-> Proto RationalNumber -> Proto Genesis -> Proto Genesis
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 (PositiveUnitInterval -> Ratio Integer
forall r. BoundedRational r => r -> Ratio Integer
L.unboundRational (ShelleyGenesis -> PositiveUnitInterval
L.sgActiveSlotsCoeff ShelleyGenesis
genesis))
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) Word32
forall (f :: * -> *) s a.
(Functor f, HasField s "epochLength" a) =>
LensLike' f s a
U5c.epochLength LensLike' Identity (Proto Genesis) Word32
-> Word32 -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word64 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (EpochSize -> Word64
L.unEpochSize (ShelleyGenesis -> EpochSize
L.sgEpochLength ShelleyGenesis
genesis))
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) Word32
forall (f :: * -> *) s a.
(Functor f, HasField s "maxKesEvolutions" a) =>
LensLike' f s a
U5c.maxKesEvolutions LensLike' Identity (Proto Genesis) Word32
-> Word32 -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word64 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (ShelleyGenesis -> Word64
L.sgMaxKESEvolutions ShelleyGenesis
genesis)
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) Word32
forall (f :: * -> *) s a.
(Functor f, HasField s "slotsPerKesPeriod" a) =>
LensLike' f s a
U5c.slotsPerKesPeriod LensLike' Identity (Proto Genesis) Word32
-> Word32 -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word64 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (ShelleyGenesis -> Word64
L.sgSlotsPerKESPeriod ShelleyGenesis
genesis)
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) Word32
forall (f :: * -> *) s a.
(Functor f, HasField s "updateQuorum" a) =>
LensLike' f s a
U5c.updateQuorum LensLike' Identity (Proto Genesis) Word32
-> Word32 -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word64 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (ShelleyGenesis -> Word64
L.sgUpdateQuorum ShelleyGenesis
genesis)
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) Word32
forall (f :: * -> *) s a.
(Functor f, HasField s "securityParam" a) =>
LensLike' f s a
U5c.securityParam LensLike' Identity (Proto Genesis) Word32
-> Word32 -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Word64 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (NonZero Word64 -> Word64
forall a. NonZero a -> a
L.unNonZero (ShelleyGenesis -> NonZero Word64
L.sgSecurityParam ShelleyGenesis
genesis))
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "maxLovelaceSupply" a) =>
LensLike' f s a
U5c.maxLovelaceSupply LensLike' Identity (Proto Genesis) (Proto BigInt)
-> Proto BigInt -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Integer -> Proto BigInt
forall t s. Inject t s => t -> s
inject (Word64 -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (ShelleyGenesis -> Word64
L.sgMaxLovelaceSupply ShelleyGenesis
genesis) :: Integer)
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) Word32
forall (f :: * -> *) s a.
(Functor f, HasField s "networkMagic" a) =>
LensLike' f s a
U5c.networkMagic LensLike' Identity (Proto Genesis) Word32
-> Word32 -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyGenesis -> Word32
L.sgNetworkMagic ShelleyGenesis
genesis
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "networkId" a) =>
LensLike' f s a
U5c.networkId LensLike' Identity (Proto Genesis) Text
-> Text -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Network -> Text
networkIdText (ShelleyGenesis -> Network
L.sgNetworkId ShelleyGenesis
genesis)
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) Word32
forall (f :: * -> *) s a.
(Functor f, HasField s "slotLength" a) =>
LensLike' f s a
U5c.slotLength LensLike' Identity (Proto Genesis) Word32
-> Word32 -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ NominalDiffTime -> Word32
forall b. Integral b => NominalDiffTime -> b
forall a b. (RealFrac a, Integral b) => a -> b
round (NominalDiffTime
1000 NominalDiffTime -> NominalDiffTime -> NominalDiffTime
forall a. Num a => a -> a -> a
* NominalDiffTimeMicro -> NominalDiffTime
L.fromNominalDiffTimeMicro (ShelleyGenesis -> NominalDiffTimeMicro
L.sgSlotLength ShelleyGenesis
genesis))
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "systemStart" a) =>
LensLike' f s a
U5c.systemStart LensLike' Identity (Proto Genesis) Text
-> Text -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ String -> Text
Text.pack (UTCTime -> String
forall t. ISO8601 t => t -> String
iso8601Show (ShelleyGenesis -> UTCTime
L.sgSystemStart ShelleyGenesis
genesis))
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Map Text (Proto GenDelegs))
forall (f :: * -> *) s a.
(Functor f, HasField s "genDelegs" a) =>
LensLike' f s a
U5c.genDelegs LensLike' Identity (Proto Genesis) (Map Text (Proto GenDelegs))
-> Map Text (Proto GenDelegs) -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Map Text (Proto GenDelegs)
genDelegs
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Map Text (Proto BigInt))
forall (f :: * -> *) s a.
(Functor f, HasField s "initialFunds" a) =>
LensLike' f s a
U5c.initialFunds LensLike' Identity (Proto Genesis) (Map Text (Proto BigInt))
-> Map Text (Proto BigInt) -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Map Text (Proto BigInt)
initialFunds
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto PParams)
forall (f :: * -> *) s a.
(Functor f, HasField s "protocolParams" a) =>
LensLike' f s a
U5c.protocolParams LensLike' Identity (Proto Genesis) (Proto PParams)
-> Proto PParams -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Proto PParams
protocolParams
where
networkIdText :: L.Network -> Text
networkIdText :: Network -> Text
networkIdText = \case
Network
L.Mainnet -> Text
"Mainnet"
Network
L.Testnet -> Text
"Testnet"
genDelegs :: Map Text (Proto U5c.GenDelegs)
genDelegs :: Map Text (Proto GenDelegs)
genDelegs =
[(Text, Proto GenDelegs)] -> Map Text (Proto GenDelegs)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
[ ( ByteString -> Text
hexText (KeyHash GenesisRole -> ByteString
forall (kr :: KeyRole). KeyHash kr -> ByteString
keyHashToBytes KeyHash GenesisRole
keyHash)
, Proto GenDelegs
forall msg. Message msg => msg
defMessage
Proto GenDelegs
-> (Proto GenDelegs -> Proto GenDelegs) -> Proto GenDelegs
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto GenDelegs) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "delegate" a) =>
LensLike' f s a
U5c.delegate LensLike' Identity (Proto GenDelegs) Text
-> Text -> Proto GenDelegs -> Proto GenDelegs
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ByteString -> Text
hexText (KeyHash GenesisDelegate -> ByteString
forall (kr :: KeyRole). KeyHash kr -> ByteString
keyHashToBytes (GenDelegPair -> KeyHash GenesisDelegate
L.genDelegKeyHash GenDelegPair
pair))
Proto GenDelegs
-> (Proto GenDelegs -> Proto GenDelegs) -> Proto GenDelegs
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto GenDelegs) Text
forall (f :: * -> *) s a.
(Functor f, HasField s "vrf" a) =>
LensLike' f s a
U5c.vrf LensLike' Identity (Proto GenDelegs) Text
-> Text -> Proto GenDelegs -> Proto GenDelegs
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ByteString -> Text
hexText (Hash HASH KeyRoleVRF -> ByteString
forall h a. Hash h a -> ByteString
L.hashToBytes (VRFVerKeyHash GenDelegVRF -> Hash HASH KeyRoleVRF
forall (r :: KeyRoleVRF). VRFVerKeyHash r -> Hash HASH KeyRoleVRF
L.unVRFVerKeyHash (GenDelegPair -> VRFVerKeyHash GenDelegVRF
L.genDelegVrfHash GenDelegPair
pair)))
)
| (KeyHash GenesisRole
keyHash, GenDelegPair
pair) <- Map (KeyHash GenesisRole) GenDelegPair
-> [(KeyHash GenesisRole, GenDelegPair)]
forall k a. Map k a -> [(k, a)]
Map.toList (ShelleyGenesis -> Map (KeyHash GenesisRole) GenDelegPair
L.sgGenDelegs ShelleyGenesis
genesis)
]
initialFunds :: Map Text (Proto U5c.BigInt)
initialFunds :: Map Text (Proto BigInt)
initialFunds =
[(Text, Proto BigInt)] -> Map Text (Proto BigInt)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
[ (ByteString -> Text
hexText (Addr -> ByteString
L.serialiseAddr Addr
address), Coin -> Proto BigInt
forall t s. Inject t s => t -> s
inject Coin
coin)
| (Addr
address, Coin
coin) <- ListMap Addr Coin -> [Item (ListMap Addr Coin)]
forall l. IsList l => l -> [Item l]
Exts.toList (ShelleyGenesis -> ListMap Addr Coin
L.sgInitialFunds ShelleyGenesis
genesis)
]
protocolParams :: Proto U5c.PParams
protocolParams :: Proto PParams
protocolParams =
Proto PParams
forall msg. Message msg => msg
defMessage
Proto PParams -> (Proto PParams -> Proto PParams) -> Proto PParams
forall a b. a -> (a -> b) -> b
& 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 (PParams ShelleyEra
pp PParams ShelleyEra
-> Getting CoinPerByte (PParams ShelleyEra) CoinPerByte
-> CoinPerByte
forall s a. s -> Getting a s a -> a
^. Getting CoinPerByte (PParams ShelleyEra) CoinPerByte
forall era. EraPParams era => Lens' (PParams era) CoinPerByte
Lens' (PParams ShelleyEra) CoinPerByte
L.ppTxFeePerByteL)))
Proto PParams -> (Proto PParams -> Proto PParams) -> Proto PParams
forall a b. a -> (a -> b) -> b
& 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 (PParams ShelleyEra
pp PParams ShelleyEra
-> Getting Coin (PParams ShelleyEra) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (PParams ShelleyEra) Coin
forall era.
(EraPParams era, HasCallStack) =>
Lens' (PParams era) Coin
Lens' (PParams ShelleyEra) Coin
L.ppTxFeeFixedL)
Proto PParams -> (Proto PParams -> Proto PParams) -> Proto PParams
forall a b. a -> (a -> b) -> b
& 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 (PParams ShelleyEra
pp PParams ShelleyEra
-> Getting Word32 (PParams ShelleyEra) Word32 -> Word32
forall s a. s -> Getting a s a -> a
^. Getting Word32 (PParams ShelleyEra) Word32
forall era. EraPParams era => Lens' (PParams era) Word32
Lens' (PParams ShelleyEra) Word32
L.ppMaxBBSizeL)
Proto PParams -> (Proto PParams -> Proto PParams) -> Proto PParams
forall a b. a -> (a -> b) -> b
& 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 (PParams ShelleyEra
pp PParams ShelleyEra
-> Getting Word32 (PParams ShelleyEra) Word32 -> Word32
forall s a. s -> Getting a s a -> a
^. Getting Word32 (PParams ShelleyEra) Word32
forall era. EraPParams era => Lens' (PParams era) Word32
Lens' (PParams ShelleyEra) Word32
L.ppMaxTxSizeL)
Proto PParams -> (Proto PParams -> Proto PParams) -> Proto PParams
forall a b. a -> (a -> b) -> b
& 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 (PParams ShelleyEra
pp PParams ShelleyEra
-> Getting Word16 (PParams ShelleyEra) Word16 -> Word16
forall s a. s -> Getting a s a -> a
^. Getting Word16 (PParams ShelleyEra) Word16
forall era. EraPParams era => Lens' (PParams era) Word16
Lens' (PParams ShelleyEra) Word16
L.ppMaxBHSizeL)
Proto PParams -> (Proto PParams -> Proto PParams) -> Proto PParams
forall a b. a -> (a -> b) -> b
& 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 (PParams ShelleyEra
pp PParams ShelleyEra
-> Getting Coin (PParams ShelleyEra) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (PParams ShelleyEra) Coin
forall era.
(EraPParams era, HasCallStack) =>
Lens' (PParams era) Coin
Lens' (PParams ShelleyEra) Coin
L.ppKeyDepositL)
Proto PParams -> (Proto PParams -> Proto PParams) -> Proto PParams
forall a b. a -> (a -> b) -> b
& 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 (PParams ShelleyEra
pp PParams ShelleyEra
-> Getting Coin (PParams ShelleyEra) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (PParams ShelleyEra) Coin
forall era.
(EraPParams era, HasCallStack) =>
Lens' (PParams era) Coin
Lens' (PParams ShelleyEra) Coin
L.ppPoolDepositL)
Proto PParams -> (Proto PParams -> Proto PParams) -> Proto PParams
forall a b. a -> (a -> b) -> b
& 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 (PParams ShelleyEra
pp PParams ShelleyEra
-> Getting EpochInterval (PParams ShelleyEra) EpochInterval
-> EpochInterval
forall s a. s -> Getting a s a -> a
^. Getting EpochInterval (PParams ShelleyEra) EpochInterval
forall era. EraPParams era => Lens' (PParams era) EpochInterval
Lens' (PParams ShelleyEra) EpochInterval
L.ppEMaxL))
Proto PParams -> (Proto PParams -> Proto PParams) -> Proto PParams
forall a b. a -> (a -> b) -> b
& 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 (PParams ShelleyEra
pp PParams ShelleyEra
-> Getting Word16 (PParams ShelleyEra) Word16 -> Word16
forall s a. s -> Getting a s a -> a
^. Getting Word16 (PParams ShelleyEra) Word16
forall era. EraPParams era => Lens' (PParams era) Word16
Lens' (PParams ShelleyEra) Word16
L.ppNOptL)
Proto PParams -> (Proto PParams -> Proto PParams) -> Proto PParams
forall a b. a -> (a -> b) -> b
& 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 (PParams ShelleyEra
pp PParams ShelleyEra
-> Getting
NonNegativeInterval (PParams ShelleyEra) NonNegativeInterval
-> NonNegativeInterval
forall s a. s -> Getting a s a -> a
^. Getting
NonNegativeInterval (PParams ShelleyEra) NonNegativeInterval
forall era.
EraPParams era =>
Lens' (PParams era) NonNegativeInterval
Lens' (PParams ShelleyEra) NonNegativeInterval
L.ppA0L))
Proto PParams -> (Proto PParams -> Proto PParams) -> Proto PParams
forall a b. a -> (a -> b) -> b
& 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 (PParams ShelleyEra
pp PParams ShelleyEra
-> Getting UnitInterval (PParams ShelleyEra) UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval (PParams ShelleyEra) UnitInterval
forall era. EraPParams era => Lens' (PParams era) UnitInterval
Lens' (PParams ShelleyEra) UnitInterval
L.ppRhoL))
Proto PParams -> (Proto PParams -> Proto PParams) -> Proto PParams
forall a b. a -> (a -> b) -> b
& 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 (PParams ShelleyEra
pp PParams ShelleyEra
-> Getting UnitInterval (PParams ShelleyEra) UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval (PParams ShelleyEra) UnitInterval
forall era. EraPParams era => Lens' (PParams era) UnitInterval
Lens' (PParams ShelleyEra) UnitInterval
L.ppTauL))
Proto PParams -> (Proto PParams -> Proto PParams) -> Proto PParams
forall a b. a -> (a -> b) -> b
& 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 (PParams ShelleyEra
pp PParams ShelleyEra
-> Getting Coin (PParams ShelleyEra) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (PParams ShelleyEra) Coin
forall era.
(EraPParams era, HasCallStack) =>
Lens' (PParams era) Coin
Lens' (PParams ShelleyEra) Coin
L.ppMinPoolCostL)
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 ShelleyEra
pp PParams ShelleyEra
-> Getting ProtVer (PParams ShelleyEra) ProtVer -> ProtVer
forall s a. s -> Getting a s a -> a
^. Getting ProtVer (PParams ShelleyEra) ProtVer
forall era. EraPParams era => Lens' (PParams era) ProtVer
Lens' (PParams ShelleyEra) ProtVer
L.ppProtocolVersionL)
where
pp :: PParams ShelleyEra
pp = ShelleyGenesis -> PParams ShelleyEra
L.sgProtocolParams ShelleyGenesis
genesis
alonzoGenesisToProto :: L.AlonzoGenesis -> Proto U5c.Genesis -> Proto U5c.Genesis
alonzoGenesisToProto :: AlonzoGenesis -> Proto Genesis -> Proto Genesis
alonzoGenesisToProto AlonzoGenesis
genesis Proto Genesis
message =
Proto Genesis
message
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "lovelacePerUtxoWord" a) =>
LensLike' f s a
U5c.lovelacePerUtxoWord LensLike' Identity (Proto Genesis) (Proto BigInt)
-> Proto BigInt -> Proto Genesis -> Proto Genesis
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 (CoinPerWord -> Coin
L.unCoinPerWord (AlonzoGenesis -> CoinPerWord
L.agCoinsPerUTxOWord AlonzoGenesis
genesis))
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto ExPrices)
forall (f :: * -> *) s a.
(Functor f, HasField s "executionPrices" a) =>
LensLike' f s a
U5c.executionPrices
LensLike' Identity (Proto Genesis) (Proto ExPrices)
-> Proto ExPrices -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ( Proto ExPrices
forall msg. Message msg => msg
defMessage
Proto ExPrices
-> (Proto ExPrices -> Proto ExPrices) -> Proto ExPrices
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto ExPrices) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "steps" a) =>
LensLike' f s a
U5c.steps LensLike' Identity (Proto ExPrices) (Proto RationalNumber)
-> Proto RationalNumber -> Proto ExPrices -> Proto ExPrices
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 ExPrices
-> (Proto ExPrices -> Proto ExPrices) -> Proto ExPrices
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto ExPrices) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "memory" a) =>
LensLike' f s a
U5c.memory LensLike' Identity (Proto ExPrices) (Proto RationalNumber)
-> Proto RationalNumber -> Proto ExPrices -> Proto ExPrices
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))
)
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto ExUnits)
forall (f :: * -> *) s a.
(Functor f, HasField s "maxTxExUnits" a) =>
LensLike' f s a
U5c.maxTxExUnits LensLike' Identity (Proto Genesis) (Proto ExUnits)
-> Proto ExUnits -> Proto Genesis -> Proto Genesis
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 (AlonzoGenesis -> ExUnits
L.agMaxTxExUnits AlonzoGenesis
genesis)
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto ExUnits)
forall (f :: * -> *) s a.
(Functor f, HasField s "maxBlockExUnits" a) =>
LensLike' f s a
U5c.maxBlockExUnits LensLike' Identity (Proto Genesis) (Proto ExUnits)
-> Proto ExUnits -> Proto Genesis -> Proto Genesis
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 (AlonzoGenesis -> ExUnits
L.agMaxBlockExUnits AlonzoGenesis
genesis)
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) Word32
forall (f :: * -> *) s a.
(Functor f, HasField s "maxValueSize" a) =>
LensLike' f s a
U5c.maxValueSize LensLike' Identity (Proto Genesis) Word32
-> Word32 -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ AlonzoGenesis -> Word32
L.agMaxValSize AlonzoGenesis
genesis
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) Word32
forall (f :: * -> *) s a.
(Functor f, HasField s "collateralPercentage" a) =>
LensLike' f s a
U5c.collateralPercentage LensLike' Identity (Proto Genesis) Word32
-> Word32 -> Proto Genesis -> Proto Genesis
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 (AlonzoGenesis -> Word16
L.agCollateralPercentage AlonzoGenesis
genesis)
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) Word32
forall (f :: * -> *) s a.
(Functor f, HasField s "maxCollateralInputs" a) =>
LensLike' f s a
U5c.maxCollateralInputs LensLike' Identity (Proto Genesis) Word32
-> Word32 -> Proto Genesis -> Proto Genesis
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 (AlonzoGenesis -> Word16
L.agMaxCollateralInputs AlonzoGenesis
genesis)
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto CostModelMap)
forall (f :: * -> *) s a.
(Functor f, HasField s "costModels" a) =>
LensLike' f s a
U5c.costModels LensLike' Identity (Proto Genesis) (Proto CostModelMap)
-> ((Maybe (Proto CostModel) -> Identity (Maybe (Proto CostModel)))
-> Proto CostModelMap -> Identity (Proto CostModelMap))
-> (Maybe (Proto CostModel) -> Identity (Maybe (Proto CostModel)))
-> Proto Genesis
-> Identity (Proto Genesis)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe (Proto CostModel) -> Identity (Maybe (Proto CostModel)))
-> Proto CostModelMap -> Identity (Proto CostModelMap)
forall (f :: * -> *) s a.
(Functor f, HasField s "maybe'plutusV1" a) =>
LensLike' f s a
U5c.maybe'plutusV1
((Maybe (Proto CostModel) -> Identity (Maybe (Proto CostModel)))
-> Proto Genesis -> Identity (Proto Genesis))
-> Proto CostModel -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ (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
.~ CostModel -> [Int64]
L.getCostModelParams (AlonzoGenesis -> CostModel
L.agPlutusV1CostModel AlonzoGenesis
genesis))
where
prices :: Prices
prices = AlonzoGenesis -> Prices
L.agPrices AlonzoGenesis
genesis
conwayGenesisToProto :: L.ConwayGenesis -> Proto U5c.Genesis -> Proto U5c.Genesis
conwayGenesisToProto :: ConwayGenesis -> Proto Genesis -> Proto Genesis
conwayGenesisToProto ConwayGenesis
genesis Proto Genesis
message =
Proto Genesis
message
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "committeeMinSize" a) =>
LensLike' f s a
U5c.committeeMinSize LensLike' Identity (Proto Genesis) Word64
-> Word64 -> Proto Genesis -> Proto Genesis
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 (UpgradeConwayPParams Identity -> HKD Identity Word16
forall (f :: * -> *). UpgradeConwayPParams f -> HKD f Word16
L.ucppCommitteeMinSize UpgradeConwayPParams Identity
upgrade)
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "committeeMaxTermLength" a) =>
LensLike' f s a
U5c.committeeMaxTermLength
LensLike' Identity (Proto Genesis) Word64
-> Word64 -> Proto Genesis -> Proto Genesis
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 (UpgradeConwayPParams Identity -> HKD Identity EpochInterval
forall (f :: * -> *). UpgradeConwayPParams f -> HKD f EpochInterval
L.ucppCommitteeMaxTermLength UpgradeConwayPParams Identity
upgrade))
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "govActionLifetime" a) =>
LensLike' f s a
U5c.govActionLifetime LensLike' Identity (Proto Genesis) Word64
-> Word64 -> Proto Genesis -> Proto Genesis
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 (UpgradeConwayPParams Identity -> HKD Identity EpochInterval
forall (f :: * -> *). UpgradeConwayPParams f -> HKD f EpochInterval
L.ucppGovActionLifetime UpgradeConwayPParams Identity
upgrade))
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) Word64
forall (f :: * -> *) s a.
(Functor f, HasField s "drepActivity" a) =>
LensLike' f s a
U5c.drepActivity LensLike' Identity (Proto Genesis) Word64
-> Word64 -> Proto Genesis -> Proto Genesis
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 (UpgradeConwayPParams Identity -> HKD Identity EpochInterval
forall (f :: * -> *). UpgradeConwayPParams f -> HKD f EpochInterval
L.ucppDRepActivity UpgradeConwayPParams Identity
upgrade))
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "govActionDeposit" a) =>
LensLike' f s a
U5c.govActionDeposit LensLike' Identity (Proto Genesis) (Proto BigInt)
-> Proto BigInt -> Proto Genesis -> Proto Genesis
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 (UpgradeConwayPParams Identity -> HKD Identity Coin
forall (f :: * -> *). UpgradeConwayPParams f -> HKD f Coin
L.ucppGovActionDeposit UpgradeConwayPParams Identity
upgrade)
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto BigInt)
forall (f :: * -> *) s a.
(Functor f, HasField s "drepDeposit" a) =>
LensLike' f s a
U5c.drepDeposit LensLike' Identity (Proto Genesis) (Proto BigInt)
-> Proto BigInt -> Proto Genesis -> Proto Genesis
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 (UpgradeConwayPParams Identity -> HKD Identity Coin
forall (f :: * -> *). UpgradeConwayPParams f -> HKD f Coin
L.ucppDRepDeposit UpgradeConwayPParams Identity
upgrade)
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "minFeeRefScriptCostPerByte" a) =>
LensLike' f s a
U5c.minFeeRefScriptCostPerByte
LensLike' Identity (Proto Genesis) (Proto RationalNumber)
-> Proto RationalNumber -> Proto Genesis -> Proto Genesis
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 (UpgradeConwayPParams Identity -> HKD Identity NonNegativeInterval
forall (f :: * -> *).
UpgradeConwayPParams f -> HKD f NonNegativeInterval
L.ucppMinFeeRefScriptCostPerByte UpgradeConwayPParams Identity
upgrade))
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto PoolVotingThresholds)
forall (f :: * -> *) s a.
(Functor f, HasField s "poolVotingThresholds" a) =>
LensLike' f s a
U5c.poolVotingThresholds LensLike' Identity (Proto Genesis) (Proto PoolVotingThresholds)
-> Proto PoolVotingThresholds -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ PoolVotingThresholds -> Proto PoolVotingThresholds
poolVotingThresholds (UpgradeConwayPParams Identity -> HKD Identity PoolVotingThresholds
forall (f :: * -> *).
UpgradeConwayPParams f -> HKD f PoolVotingThresholds
L.ucppPoolVotingThresholds UpgradeConwayPParams Identity
upgrade)
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto DRepVotingThresholds)
forall (f :: * -> *) s a.
(Functor f, HasField s "drepVotingThresholds" a) =>
LensLike' f s a
U5c.drepVotingThresholds LensLike' Identity (Proto Genesis) (Proto DRepVotingThresholds)
-> Proto DRepVotingThresholds -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ DRepVotingThresholds -> Proto DRepVotingThresholds
drepVotingThresholds (UpgradeConwayPParams Identity -> HKD Identity DRepVotingThresholds
forall (f :: * -> *).
UpgradeConwayPParams f -> HKD f DRepVotingThresholds
L.ucppDRepVotingThresholds UpgradeConwayPParams Identity
upgrade)
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto Constitution)
forall (f :: * -> *) s a.
(Functor f, HasField s "constitution" a) =>
LensLike' f s a
U5c.constitution LensLike' Identity (Proto Genesis) (Proto Constitution)
-> Proto Constitution -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Constitution ConwayEra -> Proto Constitution
forall era. Constitution era -> Proto Constitution
constitutionToUtxoRpcConstitution (ConwayGenesis -> Constitution ConwayEra
L.cgConstitution ConwayGenesis
genesis)
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto Committee)
forall (f :: * -> *) s a.
(Functor f, HasField s "committee" a) =>
LensLike' f s a
U5c.committee LensLike' Identity (Proto Genesis) (Proto Committee)
-> Proto Committee -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Proto Committee
committee
Proto Genesis -> (Proto Genesis -> Proto Genesis) -> Proto Genesis
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Genesis) (Proto CostModelMap)
forall (f :: * -> *) s a.
(Functor f, HasField s "costModels" a) =>
LensLike' f s a
U5c.costModels LensLike' Identity (Proto Genesis) (Proto CostModelMap)
-> ((Maybe (Proto CostModel) -> Identity (Maybe (Proto CostModel)))
-> Proto CostModelMap -> Identity (Proto CostModelMap))
-> (Maybe (Proto CostModel) -> Identity (Maybe (Proto CostModel)))
-> Proto Genesis
-> Identity (Proto Genesis)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe (Proto CostModel) -> Identity (Maybe (Proto CostModel)))
-> Proto CostModelMap -> Identity (Proto CostModelMap)
forall (f :: * -> *) s a.
(Functor f, HasField s "maybe'plutusV3" a) =>
LensLike' f s a
U5c.maybe'plutusV3
((Maybe (Proto CostModel) -> Identity (Maybe (Proto CostModel)))
-> Proto Genesis -> Identity (Proto Genesis))
-> Proto CostModel -> Proto Genesis -> Proto Genesis
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ (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
.~ CostModel -> [Int64]
L.getCostModelParams (UpgradeConwayPParams Identity -> HKD Identity CostModel
forall (f :: * -> *). UpgradeConwayPParams f -> HKD f CostModel
L.ucppPlutusV3CostModel UpgradeConwayPParams Identity
upgrade))
where
upgrade :: UpgradeConwayPParams Identity
upgrade = ConwayGenesis -> UpgradeConwayPParams Identity
L.cgUpgradePParams ConwayGenesis
genesis
poolVotingThresholds :: L.PoolVotingThresholds -> Proto U5c.PoolVotingThresholds
poolVotingThresholds :: PoolVotingThresholds -> Proto PoolVotingThresholds
poolVotingThresholds PoolVotingThresholds
thresholds =
Proto PoolVotingThresholds
forall msg. Message msg => msg
defMessage
Proto PoolVotingThresholds
-> (Proto PoolVotingThresholds -> Proto PoolVotingThresholds)
-> Proto PoolVotingThresholds
forall a b. a -> (a -> b) -> b
& LensLike'
Identity (Proto PoolVotingThresholds) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "motionNoConfidence" a) =>
LensLike' f s a
U5c.motionNoConfidence LensLike'
Identity (Proto PoolVotingThresholds) (Proto RationalNumber)
-> Proto RationalNumber
-> Proto PoolVotingThresholds
-> Proto PoolVotingThresholds
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 (PoolVotingThresholds
thresholds PoolVotingThresholds
-> Getting UnitInterval PoolVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval PoolVotingThresholds UnitInterval
Lens' PoolVotingThresholds UnitInterval
L.pvtMotionNoConfidenceL))
Proto PoolVotingThresholds
-> (Proto PoolVotingThresholds -> Proto PoolVotingThresholds)
-> Proto PoolVotingThresholds
forall a b. a -> (a -> b) -> b
& LensLike'
Identity (Proto PoolVotingThresholds) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "committeeNormal" a) =>
LensLike' f s a
U5c.committeeNormal LensLike'
Identity (Proto PoolVotingThresholds) (Proto RationalNumber)
-> Proto RationalNumber
-> Proto PoolVotingThresholds
-> Proto PoolVotingThresholds
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 (PoolVotingThresholds
thresholds PoolVotingThresholds
-> Getting UnitInterval PoolVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval PoolVotingThresholds UnitInterval
Lens' PoolVotingThresholds UnitInterval
L.pvtCommitteeNormalL))
Proto PoolVotingThresholds
-> (Proto PoolVotingThresholds -> Proto PoolVotingThresholds)
-> Proto PoolVotingThresholds
forall a b. a -> (a -> b) -> b
& LensLike'
Identity (Proto PoolVotingThresholds) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "committeeNoConfidence" a) =>
LensLike' f s a
U5c.committeeNoConfidence
LensLike'
Identity (Proto PoolVotingThresholds) (Proto RationalNumber)
-> Proto RationalNumber
-> Proto PoolVotingThresholds
-> Proto PoolVotingThresholds
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 (PoolVotingThresholds
thresholds PoolVotingThresholds
-> Getting UnitInterval PoolVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval PoolVotingThresholds UnitInterval
Lens' PoolVotingThresholds UnitInterval
L.pvtCommitteeNoConfidenceL))
Proto PoolVotingThresholds
-> (Proto PoolVotingThresholds -> Proto PoolVotingThresholds)
-> Proto PoolVotingThresholds
forall a b. a -> (a -> b) -> b
& LensLike'
Identity (Proto PoolVotingThresholds) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "hardForkInitiation" a) =>
LensLike' f s a
U5c.hardForkInitiation LensLike'
Identity (Proto PoolVotingThresholds) (Proto RationalNumber)
-> Proto RationalNumber
-> Proto PoolVotingThresholds
-> Proto PoolVotingThresholds
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 (PoolVotingThresholds
thresholds PoolVotingThresholds
-> Getting UnitInterval PoolVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval PoolVotingThresholds UnitInterval
Lens' PoolVotingThresholds UnitInterval
L.pvtHardForkInitiationL))
Proto PoolVotingThresholds
-> (Proto PoolVotingThresholds -> Proto PoolVotingThresholds)
-> Proto PoolVotingThresholds
forall a b. a -> (a -> b) -> b
& LensLike'
Identity (Proto PoolVotingThresholds) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "ppSecurityGroup" a) =>
LensLike' f s a
U5c.ppSecurityGroup LensLike'
Identity (Proto PoolVotingThresholds) (Proto RationalNumber)
-> Proto RationalNumber
-> Proto PoolVotingThresholds
-> Proto PoolVotingThresholds
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 (PoolVotingThresholds
thresholds PoolVotingThresholds
-> Getting UnitInterval PoolVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval PoolVotingThresholds UnitInterval
Lens' PoolVotingThresholds UnitInterval
L.pvtPPSecurityGroupL))
drepVotingThresholds :: L.DRepVotingThresholds -> Proto U5c.DRepVotingThresholds
drepVotingThresholds :: DRepVotingThresholds -> Proto DRepVotingThresholds
drepVotingThresholds DRepVotingThresholds
thresholds =
Proto DRepVotingThresholds
forall msg. Message msg => msg
defMessage
Proto DRepVotingThresholds
-> (Proto DRepVotingThresholds -> Proto DRepVotingThresholds)
-> Proto DRepVotingThresholds
forall a b. a -> (a -> b) -> b
& LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "motionNoConfidence" a) =>
LensLike' f s a
U5c.motionNoConfidence LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
-> Proto RationalNumber
-> Proto DRepVotingThresholds
-> Proto DRepVotingThresholds
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 (DRepVotingThresholds
thresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtMotionNoConfidenceL))
Proto DRepVotingThresholds
-> (Proto DRepVotingThresholds -> Proto DRepVotingThresholds)
-> Proto DRepVotingThresholds
forall a b. a -> (a -> b) -> b
& LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "committeeNormal" a) =>
LensLike' f s a
U5c.committeeNormal LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
-> Proto RationalNumber
-> Proto DRepVotingThresholds
-> Proto DRepVotingThresholds
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 (DRepVotingThresholds
thresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtCommitteeNormalL))
Proto DRepVotingThresholds
-> (Proto DRepVotingThresholds -> Proto DRepVotingThresholds)
-> Proto DRepVotingThresholds
forall a b. a -> (a -> b) -> b
& LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "committeeNoConfidence" a) =>
LensLike' f s a
U5c.committeeNoConfidence
LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
-> Proto RationalNumber
-> Proto DRepVotingThresholds
-> Proto DRepVotingThresholds
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 (DRepVotingThresholds
thresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtCommitteeNoConfidenceL))
Proto DRepVotingThresholds
-> (Proto DRepVotingThresholds -> Proto DRepVotingThresholds)
-> Proto DRepVotingThresholds
forall a b. a -> (a -> b) -> b
& LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "updateToConstitution" a) =>
LensLike' f s a
U5c.updateToConstitution
LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
-> Proto RationalNumber
-> Proto DRepVotingThresholds
-> Proto DRepVotingThresholds
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 (DRepVotingThresholds
thresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtUpdateToConstitutionL))
Proto DRepVotingThresholds
-> (Proto DRepVotingThresholds -> Proto DRepVotingThresholds)
-> Proto DRepVotingThresholds
forall a b. a -> (a -> b) -> b
& LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "hardForkInitiation" a) =>
LensLike' f s a
U5c.hardForkInitiation LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
-> Proto RationalNumber
-> Proto DRepVotingThresholds
-> Proto DRepVotingThresholds
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 (DRepVotingThresholds
thresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtHardForkInitiationL))
Proto DRepVotingThresholds
-> (Proto DRepVotingThresholds -> Proto DRepVotingThresholds)
-> Proto DRepVotingThresholds
forall a b. a -> (a -> b) -> b
& LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "ppNetworkGroup" a) =>
LensLike' f s a
U5c.ppNetworkGroup LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
-> Proto RationalNumber
-> Proto DRepVotingThresholds
-> Proto DRepVotingThresholds
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 (DRepVotingThresholds
thresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtPPNetworkGroupL))
Proto DRepVotingThresholds
-> (Proto DRepVotingThresholds -> Proto DRepVotingThresholds)
-> Proto DRepVotingThresholds
forall a b. a -> (a -> b) -> b
& LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "ppEconomicGroup" a) =>
LensLike' f s a
U5c.ppEconomicGroup LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
-> Proto RationalNumber
-> Proto DRepVotingThresholds
-> Proto DRepVotingThresholds
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 (DRepVotingThresholds
thresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtPPEconomicGroupL))
Proto DRepVotingThresholds
-> (Proto DRepVotingThresholds -> Proto DRepVotingThresholds)
-> Proto DRepVotingThresholds
forall a b. a -> (a -> b) -> b
& LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "ppTechnicalGroup" a) =>
LensLike' f s a
U5c.ppTechnicalGroup LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
-> Proto RationalNumber
-> Proto DRepVotingThresholds
-> Proto DRepVotingThresholds
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 (DRepVotingThresholds
thresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtPPTechnicalGroupL))
Proto DRepVotingThresholds
-> (Proto DRepVotingThresholds -> Proto DRepVotingThresholds)
-> Proto DRepVotingThresholds
forall a b. a -> (a -> b) -> b
& LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "ppGovGroup" a) =>
LensLike' f s a
U5c.ppGovGroup LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
-> Proto RationalNumber
-> Proto DRepVotingThresholds
-> Proto DRepVotingThresholds
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 (DRepVotingThresholds
thresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtPPGovGroupL))
Proto DRepVotingThresholds
-> (Proto DRepVotingThresholds -> Proto DRepVotingThresholds)
-> Proto DRepVotingThresholds
forall a b. a -> (a -> b) -> b
& LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "treasuryWithdrawal" a) =>
LensLike' f s a
U5c.treasuryWithdrawal LensLike'
Identity (Proto DRepVotingThresholds) (Proto RationalNumber)
-> Proto RationalNumber
-> Proto DRepVotingThresholds
-> Proto DRepVotingThresholds
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 (DRepVotingThresholds
thresholds DRepVotingThresholds
-> Getting UnitInterval DRepVotingThresholds UnitInterval
-> UnitInterval
forall s a. s -> Getting a s a -> a
^. Getting UnitInterval DRepVotingThresholds UnitInterval
Lens' DRepVotingThresholds UnitInterval
L.dvtTreasuryWithdrawalL))
committee :: Proto U5c.Committee
committee :: Proto Committee
committee =
Proto Committee
forall msg. Message msg => msg
defMessage
Proto Committee
-> (Proto Committee -> Proto Committee) -> Proto Committee
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Committee) (Proto RationalNumber)
forall (f :: * -> *) s a.
(Functor f, HasField s "threshold" a) =>
LensLike' f s a
U5c.threshold LensLike' Identity (Proto Committee) (Proto RationalNumber)
-> Proto RationalNumber -> Proto Committee -> Proto Committee
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 (Committee ConwayEra -> UnitInterval
forall era. Committee era -> UnitInterval
L.committeeThreshold Committee ConwayEra
c))
Proto Committee
-> (Proto Committee -> Proto Committee) -> Proto Committee
forall a b. a -> (a -> b) -> b
& LensLike' Identity (Proto Committee) (Map Text Word64)
forall (f :: * -> *) s a.
(Functor f, HasField s "members" a) =>
LensLike' f s a
U5c.members
LensLike' Identity (Proto Committee) (Map Text Word64)
-> Map Text Word64 -> Proto Committee -> Proto Committee
forall s t a b. ASetter s t a b -> b -> s -> t
.~ [(Text, Word64)] -> Map Text Word64
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
[ (Credential ColdCommitteeRole -> Text
forall (kr :: KeyRole). Credential kr -> Text
credentialHexText Credential ColdCommitteeRole
credential, Word64 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (EpochNo -> Word64
L.unEpochNo EpochNo
epochNo))
| (Credential ColdCommitteeRole
credential, EpochNo
epochNo) <- Map (Credential ColdCommitteeRole) EpochNo
-> [(Credential ColdCommitteeRole, EpochNo)]
forall k a. Map k a -> [(k, a)]
Map.toList (Committee ConwayEra -> Map (Credential ColdCommitteeRole) EpochNo
forall era.
Committee era -> Map (Credential ColdCommitteeRole) EpochNo
L.committeeMembers Committee ConwayEra
c)
]
where
c :: Committee ConwayEra
c = ConwayGenesis -> Committee ConwayEra
L.cgCommittee ConwayGenesis
genesis
hexText :: ByteString -> Text
hexText :: ByteString -> Text
hexText = ByteString -> Text
Text.decodeUtf8 (ByteString -> Text)
-> (ByteString -> ByteString) -> ByteString -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
Base16.encode
credentialHexText :: L.Credential kr -> Text
credentialHexText :: forall (kr :: KeyRole). Credential kr -> Text
credentialHexText = \case
L.KeyHashObj KeyHash kr
keyHash -> ByteString -> Text
hexText (KeyHash kr -> ByteString
forall (kr :: KeyRole). KeyHash kr -> ByteString
keyHashToBytes KeyHash kr
keyHash)
L.ScriptHashObj ScriptHash
scriptHash -> ByteString -> Text
hexText (ScriptHash -> ByteString
scriptHashToBytes ScriptHash
scriptHash)