{-# LANGUAGE NamedFieldPuns #-}

module Cardano.Ledger.Babbage.Genesis
  ( AlonzoGenesis (..),
    extendPPWithGenesis,
  )
where

import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis (..))
import Cardano.Ledger.Babbage.PParams (PParams', extendPP)
import qualified Cardano.Ledger.Shelley.PParams as Shelley
import Data.Functor.Identity (Identity)

-- | Given the missing pieces turn a Shelley.PParams' into an Params'
extendPPWithGenesis ::
  Shelley.PParams' Identity era1 ->
  AlonzoGenesis ->
  PParams' Identity era2
extendPPWithGenesis :: PParams' Identity era1 -> AlonzoGenesis -> PParams' Identity era2
extendPPWithGenesis
  PParams' Identity era1
pp
  AlonzoGenesis
    { Coin
coinsPerUTxOWord :: AlonzoGenesis -> Coin
coinsPerUTxOWord :: Coin
coinsPerUTxOWord,
      CostModels
costmdls :: AlonzoGenesis -> CostModels
costmdls :: CostModels
costmdls,
      Prices
prices :: AlonzoGenesis -> Prices
prices :: Prices
prices,
      ExUnits
maxTxExUnits :: AlonzoGenesis -> ExUnits
maxTxExUnits :: ExUnits
maxTxExUnits,
      ExUnits
maxBlockExUnits :: AlonzoGenesis -> ExUnits
maxBlockExUnits :: ExUnits
maxBlockExUnits,
      Natural
maxValSize :: AlonzoGenesis -> Natural
maxValSize :: Natural
maxValSize,
      Natural
collateralPercentage :: AlonzoGenesis -> Natural
collateralPercentage :: Natural
collateralPercentage,
      Natural
maxCollateralInputs :: AlonzoGenesis -> Natural
maxCollateralInputs :: Natural
maxCollateralInputs
    } =
    PParams' Identity era1
-> HKD Identity Coin
-> HKD Identity CostModels
-> HKD Identity Prices
-> HKD Identity ExUnits
-> HKD Identity ExUnits
-> HKD Identity Natural
-> HKD Identity Natural
-> HKD Identity Natural
-> PParams' Identity era2
forall (f :: * -> *) era1 era2.
PParams' f era1
-> HKD f Coin
-> HKD f CostModels
-> HKD f Prices
-> HKD f ExUnits
-> HKD f ExUnits
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> PParams' f era2
extendPP
      PParams' Identity era1
pp
      Coin
HKD Identity Coin
coinsPerUTxOWord
      CostModels
HKD Identity CostModels
costmdls
      Prices
HKD Identity Prices
prices
      ExUnits
HKD Identity ExUnits
maxTxExUnits
      ExUnits
HKD Identity ExUnits
maxBlockExUnits
      Natural
HKD Identity Natural
maxValSize
      Natural
HKD Identity Natural
collateralPercentage
      Natural
HKD Identity Natural
maxCollateralInputs