{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
module Cardano.Api.GenesisParameters
(
GenesisParameters (..)
, EpochSize (..)
, fromShelleyGenesis
)
where
import Cardano.Api.Eon.ShelleyBasedEra
import Cardano.Api.Eras
import Cardano.Api.NetworkId
import qualified Cardano.Api.ReexposeLedger as Ledger
import qualified Cardano.Ledger.Coin as L
import qualified Cardano.Ledger.Shelley.Genesis as Shelley
import Cardano.Slotting.Slot (EpochSize (..))
import Data.Time (NominalDiffTime, UTCTime)
data GenesisParameters era
= GenesisParameters
{ forall era. GenesisParameters era -> UTCTime
protocolParamSystemStart :: UTCTime
, forall era. GenesisParameters era -> NetworkId
protocolParamNetworkId :: NetworkId
, forall era. GenesisParameters era -> Rational
protocolParamActiveSlotsCoefficient :: Rational
, forall era. GenesisParameters era -> Int
protocolParamSecurity :: Int
, forall era. GenesisParameters era -> EpochSize
protocolParamEpochLength :: EpochSize
, forall era. GenesisParameters era -> NominalDiffTime
protocolParamSlotLength :: NominalDiffTime
, forall era. GenesisParameters era -> Int
protocolParamSlotsPerKESPeriod :: Int
, forall era. GenesisParameters era -> Int
protocolParamMaxKESEvolutions :: Int
, forall era. GenesisParameters era -> Int
protocolParamUpdateQuorum :: Int
, forall era. GenesisParameters era -> Coin
protocolParamMaxLovelaceSupply :: L.Coin
, forall era. GenesisParameters era -> PParams (ShelleyLedgerEra era)
protocolInitialUpdateableProtocolParameters :: Ledger.PParams (ShelleyLedgerEra era)
}
fromShelleyGenesis :: Shelley.ShelleyGenesis Ledger.StandardCrypto -> GenesisParameters ShelleyEra
fromShelleyGenesis :: ShelleyGenesis StandardCrypto -> GenesisParameters ShelleyEra
fromShelleyGenesis
sg :: ShelleyGenesis StandardCrypto
sg@Shelley.ShelleyGenesis
{ UTCTime
sgSystemStart :: UTCTime
sgSystemStart :: forall c. ShelleyGenesis c -> UTCTime
Shelley.sgSystemStart
, Word32
sgNetworkMagic :: Word32
sgNetworkMagic :: forall c. ShelleyGenesis c -> Word32
Shelley.sgNetworkMagic
, Network
sgNetworkId :: Network
sgNetworkId :: forall c. ShelleyGenesis c -> Network
Shelley.sgNetworkId
, PositiveUnitInterval
sgActiveSlotsCoeff :: PositiveUnitInterval
sgActiveSlotsCoeff :: forall c. ShelleyGenesis c -> PositiveUnitInterval
Shelley.sgActiveSlotsCoeff
, Word64
sgSecurityParam :: Word64
sgSecurityParam :: forall c. ShelleyGenesis c -> Word64
Shelley.sgSecurityParam
, EpochSize
sgEpochLength :: EpochSize
sgEpochLength :: forall c. ShelleyGenesis c -> EpochSize
Shelley.sgEpochLength
, Word64
sgSlotsPerKESPeriod :: Word64
sgSlotsPerKESPeriod :: forall c. ShelleyGenesis c -> Word64
Shelley.sgSlotsPerKESPeriod
, Word64
sgMaxKESEvolutions :: Word64
sgMaxKESEvolutions :: forall c. ShelleyGenesis c -> Word64
Shelley.sgMaxKESEvolutions
, NominalDiffTimeMicro
sgSlotLength :: NominalDiffTimeMicro
sgSlotLength :: forall c. ShelleyGenesis c -> NominalDiffTimeMicro
Shelley.sgSlotLength
, Word64
sgUpdateQuorum :: Word64
sgUpdateQuorum :: forall c. ShelleyGenesis c -> Word64
Shelley.sgUpdateQuorum
, Word64
sgMaxLovelaceSupply :: Word64
sgMaxLovelaceSupply :: forall c. ShelleyGenesis c -> Word64
Shelley.sgMaxLovelaceSupply
, sgGenDelegs :: forall c.
ShelleyGenesis c -> Map (KeyHash 'Genesis c) (GenDelegPair c)
Shelley.sgGenDelegs = Map (KeyHash 'Genesis StandardCrypto) (GenDelegPair StandardCrypto)
_
, sgInitialFunds :: forall c. ShelleyGenesis c -> ListMap (Addr c) Coin
Shelley.sgInitialFunds = ListMap (Addr StandardCrypto) Coin
_
, sgStaking :: forall c. ShelleyGenesis c -> ShelleyGenesisStaking c
Shelley.sgStaking = ShelleyGenesisStaking StandardCrypto
_
} =
GenesisParameters
{ protocolParamSystemStart :: UTCTime
protocolParamSystemStart = UTCTime
sgSystemStart
, protocolParamNetworkId :: NetworkId
protocolParamNetworkId =
Network -> NetworkMagic -> NetworkId
fromShelleyNetwork
Network
sgNetworkId
(Word32 -> NetworkMagic
NetworkMagic Word32
sgNetworkMagic)
, protocolParamActiveSlotsCoefficient :: Rational
protocolParamActiveSlotsCoefficient =
PositiveUnitInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational
PositiveUnitInterval
sgActiveSlotsCoeff
, protocolParamSecurity :: Int
protocolParamSecurity = Word64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word64
sgSecurityParam
, protocolParamEpochLength :: EpochSize
protocolParamEpochLength = EpochSize
sgEpochLength
, protocolParamSlotLength :: NominalDiffTime
protocolParamSlotLength = NominalDiffTimeMicro -> NominalDiffTime
Shelley.fromNominalDiffTimeMicro NominalDiffTimeMicro
sgSlotLength
, protocolParamSlotsPerKESPeriod :: Int
protocolParamSlotsPerKESPeriod = Word64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word64
sgSlotsPerKESPeriod
, protocolParamMaxKESEvolutions :: Int
protocolParamMaxKESEvolutions = Word64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word64
sgMaxKESEvolutions
, protocolParamUpdateQuorum :: Int
protocolParamUpdateQuorum = Word64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word64
sgUpdateQuorum
, protocolParamMaxLovelaceSupply :: Coin
protocolParamMaxLovelaceSupply = Integer -> Coin
L.Coin (Integer -> Coin) -> Integer -> Coin
forall a b. (a -> b) -> a -> b
$ Word64 -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word64
sgMaxLovelaceSupply
, protocolInitialUpdateableProtocolParameters :: PParams (ShelleyLedgerEra ShelleyEra)
protocolInitialUpdateableProtocolParameters = ShelleyGenesis StandardCrypto
-> PParams (ShelleyEra StandardCrypto)
forall c. ShelleyGenesis c -> PParams (ShelleyEra c)
Shelley.sgProtocolParams ShelleyGenesis StandardCrypto
sg
}