{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
module Cardano.Api.GenesisParameters (
GenesisParameters(..),
EpochSize(..),
fromShelleyGenesis,
) where
import Prelude
import Data.Time (NominalDiffTime, UTCTime)
import Cardano.Slotting.Slot (EpochSize (..))
import qualified Cardano.Ledger.BaseTypes as Ledger
import qualified Cardano.Ledger.Shelley.Genesis as Shelley
import Cardano.Api.NetworkId
import Cardano.Api.ProtocolParameters
import Cardano.Api.Value
data GenesisParameters =
GenesisParameters {
GenesisParameters -> UTCTime
protocolParamSystemStart :: UTCTime,
GenesisParameters -> NetworkId
protocolParamNetworkId :: NetworkId,
GenesisParameters -> Rational
protocolParamActiveSlotsCoefficient :: Rational,
GenesisParameters -> Int
protocolParamSecurity :: Int,
GenesisParameters -> EpochSize
protocolParamEpochLength :: EpochSize,
GenesisParameters -> NominalDiffTime
protocolParamSlotLength :: NominalDiffTime,
GenesisParameters -> Int
protocolParamSlotsPerKESPeriod :: Int,
GenesisParameters -> Int
protocolParamMaxKESEvolutions :: Int,
GenesisParameters -> Int
protocolParamUpdateQuorum :: Int,
GenesisParameters -> Lovelace
protocolParamMaxLovelaceSupply :: Lovelace,
GenesisParameters -> ProtocolParameters
protocolInitialUpdateableProtocolParameters :: ProtocolParameters
}
fromShelleyGenesis :: Shelley.ShelleyGenesis era -> GenesisParameters
fromShelleyGenesis :: ShelleyGenesis era -> GenesisParameters
fromShelleyGenesis
Shelley.ShelleyGenesis {
UTCTime
sgSystemStart :: forall era. ShelleyGenesis era -> UTCTime
sgSystemStart :: UTCTime
Shelley.sgSystemStart
, Word32
sgNetworkMagic :: forall era. ShelleyGenesis era -> Word32
sgNetworkMagic :: Word32
Shelley.sgNetworkMagic
, Network
sgNetworkId :: forall era. ShelleyGenesis era -> Network
sgNetworkId :: Network
Shelley.sgNetworkId
, PositiveUnitInterval
sgActiveSlotsCoeff :: forall era. ShelleyGenesis era -> PositiveUnitInterval
sgActiveSlotsCoeff :: PositiveUnitInterval
Shelley.sgActiveSlotsCoeff
, Word64
sgSecurityParam :: forall era. ShelleyGenesis era -> Word64
sgSecurityParam :: Word64
Shelley.sgSecurityParam
, EpochSize
sgEpochLength :: forall era. ShelleyGenesis era -> EpochSize
sgEpochLength :: EpochSize
Shelley.sgEpochLength
, Word64
sgSlotsPerKESPeriod :: forall era. ShelleyGenesis era -> Word64
sgSlotsPerKESPeriod :: Word64
Shelley.sgSlotsPerKESPeriod
, Word64
sgMaxKESEvolutions :: forall era. ShelleyGenesis era -> Word64
sgMaxKESEvolutions :: Word64
Shelley.sgMaxKESEvolutions
, NominalDiffTime
sgSlotLength :: forall era. ShelleyGenesis era -> NominalDiffTime
sgSlotLength :: NominalDiffTime
Shelley.sgSlotLength
, Word64
sgUpdateQuorum :: forall era. ShelleyGenesis era -> Word64
sgUpdateQuorum :: Word64
Shelley.sgUpdateQuorum
, Word64
sgMaxLovelaceSupply :: forall era. ShelleyGenesis era -> Word64
sgMaxLovelaceSupply :: Word64
Shelley.sgMaxLovelaceSupply
, PParams era
sgProtocolParams :: forall era. ShelleyGenesis era -> PParams era
sgProtocolParams :: PParams era
Shelley.sgProtocolParams
, sgGenDelegs :: forall era.
ShelleyGenesis era
-> Map (KeyHash 'Genesis (Crypto era)) (GenDelegPair (Crypto era))
Shelley.sgGenDelegs = Map (KeyHash 'Genesis (Crypto era)) (GenDelegPair (Crypto era))
_
, sgInitialFunds :: forall era. ShelleyGenesis era -> Map (Addr (Crypto era)) Coin
Shelley.sgInitialFunds = Map (Addr (Crypto era)) Coin
_
, sgStaking :: forall era.
ShelleyGenesis era -> ShelleyGenesisStaking (Crypto era)
Shelley.sgStaking = ShelleyGenesisStaking (Crypto era)
_
} =
GenesisParameters :: UTCTime
-> NetworkId
-> Rational
-> Int
-> EpochSize
-> NominalDiffTime
-> Int
-> Int
-> Int
-> Lovelace
-> ProtocolParameters
-> GenesisParameters
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 = NominalDiffTime
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 :: Lovelace
protocolParamMaxLovelaceSupply = Integer -> Lovelace
Lovelace
(Word64 -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word64
sgMaxLovelaceSupply)
, protocolInitialUpdateableProtocolParameters :: ProtocolParameters
protocolInitialUpdateableProtocolParameters = PParams era -> ProtocolParameters
forall ledgerera. PParams ledgerera -> ProtocolParameters
fromShelleyPParams
PParams era
sgProtocolParams
}