{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Cardano.Ledger.Alonzo.Translation where
import Cardano.Ledger.Alonzo.Core hiding (Tx)
import qualified Cardano.Ledger.Alonzo.Core as Core
import Cardano.Ledger.Alonzo.Era (AlonzoEra)
import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis (..))
import Cardano.Ledger.Alonzo.PParams ()
import Cardano.Ledger.Alonzo.Tx (AlonzoTx (..), IsValid (..))
import Cardano.Ledger.Binary (DecoderError)
import Cardano.Ledger.CertState (CommitteeState (..), PState (..), VState (..))
import Cardano.Ledger.Crypto (Crypto)
import Cardano.Ledger.Shelley.LedgerState (
CertState (..),
DState (..),
EpochState (..),
LedgerState (..),
NewEpochState (..),
UTxOState (..),
)
import Cardano.Ledger.Shelley.PParams (ProposedPPUpdates (..))
import Cardano.Ledger.UTxO (UTxO (..))
import Data.Default (def)
import qualified Data.Map.Strict as Map
import Lens.Micro ((^.))
type instance TranslationContext (AlonzoEra c) = AlonzoGenesis
instance Crypto c => TranslateEra (AlonzoEra c) NewEpochState where
translateEra :: TranslationContext (AlonzoEra c)
-> NewEpochState (PreviousEra (AlonzoEra c))
-> Except
(TranslationError (AlonzoEra c) NewEpochState)
(NewEpochState (AlonzoEra c))
translateEra TranslationContext (AlonzoEra c)
ctxt NewEpochState (PreviousEra (AlonzoEra c))
nes =
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$
NewEpochState
{ nesEL :: EpochNo
nesEL = forall era. NewEpochState era -> EpochNo
nesEL NewEpochState (PreviousEra (AlonzoEra c))
nes
, nesBprev :: BlocksMade (EraCrypto (AlonzoEra c))
nesBprev = forall era. NewEpochState era -> BlocksMade (EraCrypto era)
nesBprev NewEpochState (PreviousEra (AlonzoEra c))
nes
, nesBcur :: BlocksMade (EraCrypto (AlonzoEra c))
nesBcur = forall era. NewEpochState era -> BlocksMade (EraCrypto era)
nesBcur NewEpochState (PreviousEra (AlonzoEra c))
nes
, nesEs :: EpochState (AlonzoEra c)
nesEs = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext (AlonzoEra c)
ctxt forall a b. (a -> b) -> a -> b
$ forall era. NewEpochState era -> EpochState era
nesEs NewEpochState (PreviousEra (AlonzoEra c))
nes
, nesRu :: StrictMaybe (PulsingRewUpdate (EraCrypto (AlonzoEra c)))
nesRu = forall era.
NewEpochState era -> StrictMaybe (PulsingRewUpdate (EraCrypto era))
nesRu NewEpochState (PreviousEra (AlonzoEra c))
nes
, nesPd :: PoolDistr (EraCrypto (AlonzoEra c))
nesPd = forall era. NewEpochState era -> PoolDistr (EraCrypto era)
nesPd NewEpochState (PreviousEra (AlonzoEra c))
nes
, stashedAVVMAddresses :: StashedAVVMAddresses (AlonzoEra c)
stashedAVVMAddresses = ()
}
instance Crypto c => TranslateEra (AlonzoEra c) PParams where
translateEra :: TranslationContext (AlonzoEra c)
-> PParams (PreviousEra (AlonzoEra c))
-> Except
(TranslationError (AlonzoEra c) PParams) (PParams (AlonzoEra c))
translateEra (AlonzoGenesisWrapper UpgradeAlonzoPParams Identity
upgradeArgs) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era.
(EraPParams era, EraPParams (PreviousEra era)) =>
UpgradePParams Identity era
-> PParams (PreviousEra era) -> PParams era
upgradePParams UpgradeAlonzoPParams Identity
upgradeArgs
instance Crypto c => TranslateEra (AlonzoEra c) FuturePParams where
translateEra :: TranslationContext (AlonzoEra c)
-> FuturePParams (PreviousEra (AlonzoEra c))
-> Except
(TranslationError (AlonzoEra c) FuturePParams)
(FuturePParams (AlonzoEra c))
translateEra TranslationContext (AlonzoEra c)
ctxt = \case
FuturePParams (PreviousEra (AlonzoEra c))
NoPParamsUpdate -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall era. FuturePParams era
NoPParamsUpdate
DefinitePParamsUpdate PParams (PreviousEra (AlonzoEra c))
pp -> forall era. PParams era -> FuturePParams era
DefinitePParamsUpdate forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall era (f :: * -> *).
TranslateEra era f =>
TranslationContext era
-> f (PreviousEra era) -> Except (TranslationError era f) (f era)
translateEra TranslationContext (AlonzoEra c)
ctxt PParams (PreviousEra (AlonzoEra c))
pp
PotentialPParamsUpdate Maybe (PParams (PreviousEra (AlonzoEra c)))
mpp -> forall era. Maybe (PParams era) -> FuturePParams era
PotentialPParamsUpdate forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall era (f :: * -> *).
TranslateEra era f =>
TranslationContext era
-> f (PreviousEra era) -> Except (TranslationError era f) (f era)
translateEra TranslationContext (AlonzoEra c)
ctxt) Maybe (PParams (PreviousEra (AlonzoEra c)))
mpp
newtype Tx era = Tx {forall era. Tx era -> Tx era
unTx :: Core.Tx era}
instance Crypto c => TranslateEra (AlonzoEra c) Tx where
type TranslationError (AlonzoEra c) Tx = DecoderError
translateEra :: TranslationContext (AlonzoEra c)
-> Tx (PreviousEra (AlonzoEra c))
-> Except (TranslationError (AlonzoEra c) Tx) (Tx (AlonzoEra c))
translateEra TranslationContext (AlonzoEra c)
_ctxt (Tx Tx (PreviousEra (AlonzoEra c))
tx) = do
AlonzoTxBody (AlonzoEra c)
txBody <- forall era (ti :: * -> *) (to :: * -> *).
(Era era, ToCBOR (ti (PreviousEra era)),
DecCBOR (Annotator (to era))) =>
Text -> ti (PreviousEra era) -> Except DecoderError (to era)
translateEraThroughCBOR Text
"TxBody" forall a b. (a -> b) -> a -> b
$ Tx (PreviousEra (AlonzoEra c))
tx forall s a. s -> Getting a s a -> a
^. forall era. EraTx era => Lens' (Tx era) (TxBody era)
bodyTxL
AlonzoTxWits (AlonzoEra c)
txWits <- forall era (ti :: * -> *) (to :: * -> *).
(Era era, ToCBOR (ti (PreviousEra era)),
DecCBOR (Annotator (to era))) =>
Text -> ti (PreviousEra era) -> Except DecoderError (to era)
translateEraThroughCBOR Text
"TxWits" forall a b. (a -> b) -> a -> b
$ Tx (PreviousEra (AlonzoEra c))
tx forall s a. s -> Getting a s a -> a
^. forall era. EraTx era => Lens' (Tx era) (TxWits era)
witsTxL
StrictMaybe (AlonzoTxAuxData (AlonzoEra c))
txAuxData <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall era (ti :: * -> *) (to :: * -> *).
(Era era, ToCBOR (ti (PreviousEra era)),
DecCBOR (Annotator (to era))) =>
Text -> ti (PreviousEra era) -> Except DecoderError (to era)
translateEraThroughCBOR Text
"TxAuxData") (Tx (PreviousEra (AlonzoEra c))
tx forall s a. s -> Getting a s a -> a
^. forall era.
EraTx era =>
Lens' (Tx era) (StrictMaybe (TxAuxData era))
auxDataTxL)
let validating :: IsValid
validating = Bool -> IsValid
IsValid Bool
True
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall era. Tx era -> Tx era
Tx forall a b. (a -> b) -> a -> b
$ forall era.
TxBody era
-> TxWits era
-> IsValid
-> StrictMaybe (TxAuxData era)
-> AlonzoTx era
AlonzoTx AlonzoTxBody (AlonzoEra c)
txBody AlonzoTxWits (AlonzoEra c)
txWits IsValid
validating StrictMaybe (AlonzoTxAuxData (AlonzoEra c))
txAuxData
instance Crypto c => TranslateEra (AlonzoEra c) EpochState where
translateEra :: TranslationContext (AlonzoEra c)
-> EpochState (PreviousEra (AlonzoEra c))
-> Except
(TranslationError (AlonzoEra c) EpochState)
(EpochState (AlonzoEra c))
translateEra TranslationContext (AlonzoEra c)
ctxt EpochState (PreviousEra (AlonzoEra c))
es =
forall (m :: * -> *) a. Monad m => a -> m a
return
EpochState
{ esAccountState :: AccountState
esAccountState = forall era. EpochState era -> AccountState
esAccountState EpochState (PreviousEra (AlonzoEra c))
es
, esSnapshots :: SnapShots (EraCrypto (AlonzoEra c))
esSnapshots = forall era. EpochState era -> SnapShots (EraCrypto era)
esSnapshots EpochState (PreviousEra (AlonzoEra c))
es
, esLState :: LedgerState (AlonzoEra c)
esLState = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext (AlonzoEra c)
ctxt forall a b. (a -> b) -> a -> b
$ forall era. EpochState era -> LedgerState era
esLState EpochState (PreviousEra (AlonzoEra c))
es
, esNonMyopic :: NonMyopic (EraCrypto (AlonzoEra c))
esNonMyopic = forall era. EpochState era -> NonMyopic (EraCrypto era)
esNonMyopic EpochState (PreviousEra (AlonzoEra c))
es
}
instance Crypto c => TranslateEra (AlonzoEra c) DState where
translateEra :: TranslationContext (AlonzoEra c)
-> DState (PreviousEra (AlonzoEra c))
-> Except
(TranslationError (AlonzoEra c) DState) (DState (AlonzoEra c))
translateEra TranslationContext (AlonzoEra c)
_ DState {Map
(FutureGenDeleg (EraCrypto (PreviousEra (AlonzoEra c))))
(GenDelegPair (EraCrypto (PreviousEra (AlonzoEra c))))
InstantaneousRewards (EraCrypto (PreviousEra (AlonzoEra c)))
UMap (EraCrypto (PreviousEra (AlonzoEra c)))
GenDelegs (EraCrypto (PreviousEra (AlonzoEra c)))
dsUnified :: forall era. DState era -> UMap (EraCrypto era)
dsFutureGenDelegs :: forall era.
DState era
-> Map
(FutureGenDeleg (EraCrypto era)) (GenDelegPair (EraCrypto era))
dsGenDelegs :: forall era. DState era -> GenDelegs (EraCrypto era)
dsIRewards :: forall era. DState era -> InstantaneousRewards (EraCrypto era)
dsIRewards :: InstantaneousRewards (EraCrypto (PreviousEra (AlonzoEra c)))
dsGenDelegs :: GenDelegs (EraCrypto (PreviousEra (AlonzoEra c)))
dsFutureGenDelegs :: Map
(FutureGenDeleg (EraCrypto (PreviousEra (AlonzoEra c))))
(GenDelegPair (EraCrypto (PreviousEra (AlonzoEra c))))
dsUnified :: UMap (EraCrypto (PreviousEra (AlonzoEra c)))
..} = forall (f :: * -> *) a. Applicative f => a -> f a
pure DState {Map
(FutureGenDeleg (EraCrypto (PreviousEra (AlonzoEra c))))
(GenDelegPair (EraCrypto (PreviousEra (AlonzoEra c))))
InstantaneousRewards (EraCrypto (PreviousEra (AlonzoEra c)))
UMap (EraCrypto (PreviousEra (AlonzoEra c)))
GenDelegs (EraCrypto (PreviousEra (AlonzoEra c)))
dsUnified :: UMap (EraCrypto (AlonzoEra c))
dsFutureGenDelegs :: Map
(FutureGenDeleg (EraCrypto (AlonzoEra c)))
(GenDelegPair (EraCrypto (AlonzoEra c)))
dsGenDelegs :: GenDelegs (EraCrypto (AlonzoEra c))
dsIRewards :: InstantaneousRewards (EraCrypto (AlonzoEra c))
dsIRewards :: InstantaneousRewards (EraCrypto (PreviousEra (AlonzoEra c)))
dsGenDelegs :: GenDelegs (EraCrypto (PreviousEra (AlonzoEra c)))
dsFutureGenDelegs :: Map
(FutureGenDeleg (EraCrypto (PreviousEra (AlonzoEra c))))
(GenDelegPair (EraCrypto (PreviousEra (AlonzoEra c))))
dsUnified :: UMap (EraCrypto (PreviousEra (AlonzoEra c)))
..}
instance Crypto c => TranslateEra (AlonzoEra c) CommitteeState where
translateEra :: TranslationContext (AlonzoEra c)
-> CommitteeState (PreviousEra (AlonzoEra c))
-> Except
(TranslationError (AlonzoEra c) CommitteeState)
(CommitteeState (AlonzoEra c))
translateEra TranslationContext (AlonzoEra c)
_ CommitteeState {Map
(Credential
'ColdCommitteeRole (EraCrypto (PreviousEra (AlonzoEra c))))
(CommitteeAuthorization (EraCrypto (PreviousEra (AlonzoEra c))))
csCommitteeCreds :: forall era.
CommitteeState era
-> Map
(Credential 'ColdCommitteeRole (EraCrypto era))
(CommitteeAuthorization (EraCrypto era))
csCommitteeCreds :: Map
(Credential
'ColdCommitteeRole (EraCrypto (PreviousEra (AlonzoEra c))))
(CommitteeAuthorization (EraCrypto (PreviousEra (AlonzoEra c))))
..} = forall (f :: * -> *) a. Applicative f => a -> f a
pure CommitteeState {Map
(Credential
'ColdCommitteeRole (EraCrypto (PreviousEra (AlonzoEra c))))
(CommitteeAuthorization (EraCrypto (PreviousEra (AlonzoEra c))))
csCommitteeCreds :: Map
(Credential 'ColdCommitteeRole (EraCrypto (AlonzoEra c)))
(CommitteeAuthorization (EraCrypto (AlonzoEra c)))
csCommitteeCreds :: Map
(Credential
'ColdCommitteeRole (EraCrypto (PreviousEra (AlonzoEra c))))
(CommitteeAuthorization (EraCrypto (PreviousEra (AlonzoEra c))))
..}
instance Crypto c => TranslateEra (AlonzoEra c) VState where
translateEra :: TranslationContext (AlonzoEra c)
-> VState (PreviousEra (AlonzoEra c))
-> Except
(TranslationError (AlonzoEra c) VState) (VState (AlonzoEra c))
translateEra TranslationContext (AlonzoEra c)
ctx VState {Map
(Credential 'DRepRole (EraCrypto (PreviousEra (AlonzoEra c))))
(DRepState (EraCrypto (PreviousEra (AlonzoEra c))))
CommitteeState (PreviousEra (AlonzoEra c))
EpochNo
vsDReps :: forall era.
VState era
-> Map
(Credential 'DRepRole (EraCrypto era)) (DRepState (EraCrypto era))
vsCommitteeState :: forall era. VState era -> CommitteeState era
vsNumDormantEpochs :: forall era. VState era -> EpochNo
vsNumDormantEpochs :: EpochNo
vsCommitteeState :: CommitteeState (PreviousEra (AlonzoEra c))
vsDReps :: Map
(Credential 'DRepRole (EraCrypto (PreviousEra (AlonzoEra c))))
(DRepState (EraCrypto (PreviousEra (AlonzoEra c))))
..} = do
CommitteeState (AlonzoEra c)
committeeState <- forall era (f :: * -> *).
TranslateEra era f =>
TranslationContext era
-> f (PreviousEra era) -> Except (TranslationError era f) (f era)
translateEra TranslationContext (AlonzoEra c)
ctx CommitteeState (PreviousEra (AlonzoEra c))
vsCommitteeState
forall (f :: * -> *) a. Applicative f => a -> f a
pure VState {vsCommitteeState :: CommitteeState (AlonzoEra c)
vsCommitteeState = CommitteeState (AlonzoEra c)
committeeState, Map
(Credential 'DRepRole (EraCrypto (PreviousEra (AlonzoEra c))))
(DRepState (EraCrypto (PreviousEra (AlonzoEra c))))
EpochNo
vsDReps :: Map
(Credential 'DRepRole (EraCrypto (AlonzoEra c)))
(DRepState (EraCrypto (AlonzoEra c)))
vsNumDormantEpochs :: EpochNo
vsNumDormantEpochs :: EpochNo
vsDReps :: Map
(Credential 'DRepRole (EraCrypto (PreviousEra (AlonzoEra c))))
(DRepState (EraCrypto (PreviousEra (AlonzoEra c))))
..}
instance Crypto c => TranslateEra (AlonzoEra c) PState where
translateEra :: TranslationContext (AlonzoEra c)
-> PState (PreviousEra (AlonzoEra c))
-> Except
(TranslationError (AlonzoEra c) PState) (PState (AlonzoEra c))
translateEra TranslationContext (AlonzoEra c)
_ PState {Map
(KeyHash 'StakePool (EraCrypto (PreviousEra (AlonzoEra c))))
(PoolParams (EraCrypto (PreviousEra (AlonzoEra c))))
Map
(KeyHash 'StakePool (EraCrypto (PreviousEra (AlonzoEra c)))) Coin
Map
(KeyHash 'StakePool (EraCrypto (PreviousEra (AlonzoEra c))))
EpochNo
psStakePoolParams :: forall era.
PState era
-> Map
(KeyHash 'StakePool (EraCrypto era)) (PoolParams (EraCrypto era))
psFutureStakePoolParams :: forall era.
PState era
-> Map
(KeyHash 'StakePool (EraCrypto era)) (PoolParams (EraCrypto era))
psRetiring :: forall era.
PState era -> Map (KeyHash 'StakePool (EraCrypto era)) EpochNo
psDeposits :: forall era.
PState era -> Map (KeyHash 'StakePool (EraCrypto era)) Coin
psDeposits :: Map
(KeyHash 'StakePool (EraCrypto (PreviousEra (AlonzoEra c)))) Coin
psRetiring :: Map
(KeyHash 'StakePool (EraCrypto (PreviousEra (AlonzoEra c))))
EpochNo
psFutureStakePoolParams :: Map
(KeyHash 'StakePool (EraCrypto (PreviousEra (AlonzoEra c))))
(PoolParams (EraCrypto (PreviousEra (AlonzoEra c))))
psStakePoolParams :: Map
(KeyHash 'StakePool (EraCrypto (PreviousEra (AlonzoEra c))))
(PoolParams (EraCrypto (PreviousEra (AlonzoEra c))))
..} = forall (f :: * -> *) a. Applicative f => a -> f a
pure PState {Map
(KeyHash 'StakePool (EraCrypto (PreviousEra (AlonzoEra c))))
(PoolParams (EraCrypto (PreviousEra (AlonzoEra c))))
Map
(KeyHash 'StakePool (EraCrypto (PreviousEra (AlonzoEra c)))) Coin
Map
(KeyHash 'StakePool (EraCrypto (PreviousEra (AlonzoEra c))))
EpochNo
psStakePoolParams :: Map
(KeyHash 'StakePool (EraCrypto (AlonzoEra c)))
(PoolParams (EraCrypto (AlonzoEra c)))
psFutureStakePoolParams :: Map
(KeyHash 'StakePool (EraCrypto (AlonzoEra c)))
(PoolParams (EraCrypto (AlonzoEra c)))
psRetiring :: Map (KeyHash 'StakePool (EraCrypto (AlonzoEra c))) EpochNo
psDeposits :: Map (KeyHash 'StakePool (EraCrypto (AlonzoEra c))) Coin
psDeposits :: Map
(KeyHash 'StakePool (EraCrypto (PreviousEra (AlonzoEra c)))) Coin
psRetiring :: Map
(KeyHash 'StakePool (EraCrypto (PreviousEra (AlonzoEra c))))
EpochNo
psFutureStakePoolParams :: Map
(KeyHash 'StakePool (EraCrypto (PreviousEra (AlonzoEra c))))
(PoolParams (EraCrypto (PreviousEra (AlonzoEra c))))
psStakePoolParams :: Map
(KeyHash 'StakePool (EraCrypto (PreviousEra (AlonzoEra c))))
(PoolParams (EraCrypto (PreviousEra (AlonzoEra c))))
..}
instance Crypto c => TranslateEra (AlonzoEra c) CertState where
translateEra :: TranslationContext (AlonzoEra c)
-> CertState (PreviousEra (AlonzoEra c))
-> Except
(TranslationError (AlonzoEra c) CertState)
(CertState (AlonzoEra c))
translateEra TranslationContext (AlonzoEra c)
ctxt CertState (PreviousEra (AlonzoEra c))
ls =
forall (f :: * -> *) a. Applicative f => a -> f a
pure
CertState
{ certDState :: DState (AlonzoEra c)
certDState = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext (AlonzoEra c)
ctxt forall a b. (a -> b) -> a -> b
$ forall era. CertState era -> DState era
certDState CertState (PreviousEra (AlonzoEra c))
ls
, certPState :: PState (AlonzoEra c)
certPState = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext (AlonzoEra c)
ctxt forall a b. (a -> b) -> a -> b
$ forall era. CertState era -> PState era
certPState CertState (PreviousEra (AlonzoEra c))
ls
, certVState :: VState (AlonzoEra c)
certVState = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext (AlonzoEra c)
ctxt forall a b. (a -> b) -> a -> b
$ forall era. CertState era -> VState era
certVState CertState (PreviousEra (AlonzoEra c))
ls
}
instance Crypto c => TranslateEra (AlonzoEra c) LedgerState where
translateEra :: TranslationContext (AlonzoEra c)
-> LedgerState (PreviousEra (AlonzoEra c))
-> Except
(TranslationError (AlonzoEra c) LedgerState)
(LedgerState (AlonzoEra c))
translateEra TranslationContext (AlonzoEra c)
ctxt LedgerState (PreviousEra (AlonzoEra c))
ls =
forall (m :: * -> *) a. Monad m => a -> m a
return
LedgerState
{ lsUTxOState :: UTxOState (AlonzoEra c)
lsUTxOState = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext (AlonzoEra c)
ctxt forall a b. (a -> b) -> a -> b
$ forall era. LedgerState era -> UTxOState era
lsUTxOState LedgerState (PreviousEra (AlonzoEra c))
ls
, lsCertState :: CertState (AlonzoEra c)
lsCertState = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext (AlonzoEra c)
ctxt forall a b. (a -> b) -> a -> b
$ forall era. LedgerState era -> CertState era
lsCertState LedgerState (PreviousEra (AlonzoEra c))
ls
}
instance Crypto c => TranslateEra (AlonzoEra c) UTxOState where
translateEra :: TranslationContext (AlonzoEra c)
-> UTxOState (PreviousEra (AlonzoEra c))
-> Except
(TranslationError (AlonzoEra c) UTxOState)
(UTxOState (AlonzoEra c))
translateEra TranslationContext (AlonzoEra c)
ctxt UTxOState (PreviousEra (AlonzoEra c))
us =
forall (m :: * -> *) a. Monad m => a -> m a
return
UTxOState
{ utxosUtxo :: UTxO (AlonzoEra c)
utxosUtxo = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext (AlonzoEra c)
ctxt forall a b. (a -> b) -> a -> b
$ forall era. UTxOState era -> UTxO era
utxosUtxo UTxOState (PreviousEra (AlonzoEra c))
us
, utxosDeposited :: Coin
utxosDeposited = forall era. UTxOState era -> Coin
utxosDeposited UTxOState (PreviousEra (AlonzoEra c))
us
, utxosFees :: Coin
utxosFees = forall era. UTxOState era -> Coin
utxosFees UTxOState (PreviousEra (AlonzoEra c))
us
, utxosGovState :: GovState (AlonzoEra c)
utxosGovState = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext (AlonzoEra c)
ctxt forall a b. (a -> b) -> a -> b
$ forall era. UTxOState era -> GovState era
utxosGovState UTxOState (PreviousEra (AlonzoEra c))
us
, utxosStakeDistr :: IncrementalStake (EraCrypto (AlonzoEra c))
utxosStakeDistr = forall era. UTxOState era -> IncrementalStake (EraCrypto era)
utxosStakeDistr UTxOState (PreviousEra (AlonzoEra c))
us
, utxosDonation :: Coin
utxosDonation = forall era. UTxOState era -> Coin
utxosDonation UTxOState (PreviousEra (AlonzoEra c))
us
}
instance Crypto c => TranslateEra (AlonzoEra c) UTxO where
translateEra :: TranslationContext (AlonzoEra c)
-> UTxO (PreviousEra (AlonzoEra c))
-> Except
(TranslationError (AlonzoEra c) UTxO) (UTxO (AlonzoEra c))
translateEra TranslationContext (AlonzoEra c)
_ctxt UTxO (PreviousEra (AlonzoEra c))
utxo =
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall era. Map (TxIn (EraCrypto era)) (TxOut era) -> UTxO era
UTxO forall a b. (a -> b) -> a -> b
$ forall era.
(EraTxOut era, EraTxOut (PreviousEra era)) =>
TxOut (PreviousEra era) -> TxOut era
upgradeTxOut forall a b k. (a -> b) -> Map k a -> Map k b
`Map.map` forall era. UTxO era -> Map (TxIn (EraCrypto era)) (TxOut era)
unUTxO UTxO (PreviousEra (AlonzoEra c))
utxo
instance Crypto c => TranslateEra (AlonzoEra c) ShelleyGovState where
translateEra :: TranslationContext (AlonzoEra c)
-> ShelleyGovState (PreviousEra (AlonzoEra c))
-> Except
(TranslationError (AlonzoEra c) ShelleyGovState)
(ShelleyGovState (AlonzoEra c))
translateEra TranslationContext (AlonzoEra c)
ctxt ShelleyGovState (PreviousEra (AlonzoEra c))
ps =
forall (m :: * -> *) a. Monad m => a -> m a
return
ShelleyGovState
{ sgsCurProposals :: ProposedPPUpdates (AlonzoEra c)
sgsCurProposals = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext (AlonzoEra c)
ctxt forall a b. (a -> b) -> a -> b
$ forall era. ShelleyGovState era -> ProposedPPUpdates era
sgsCurProposals ShelleyGovState (PreviousEra (AlonzoEra c))
ps
, sgsFutureProposals :: ProposedPPUpdates (AlonzoEra c)
sgsFutureProposals = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext (AlonzoEra c)
ctxt forall a b. (a -> b) -> a -> b
$ forall era. ShelleyGovState era -> ProposedPPUpdates era
sgsFutureProposals ShelleyGovState (PreviousEra (AlonzoEra c))
ps
, sgsCurPParams :: PParams (AlonzoEra c)
sgsCurPParams = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext (AlonzoEra c)
ctxt forall a b. (a -> b) -> a -> b
$ forall era. ShelleyGovState era -> PParams era
sgsCurPParams ShelleyGovState (PreviousEra (AlonzoEra c))
ps
, sgsPrevPParams :: PParams (AlonzoEra c)
sgsPrevPParams = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext (AlonzoEra c)
ctxt forall a b. (a -> b) -> a -> b
$ forall era. ShelleyGovState era -> PParams era
sgsPrevPParams ShelleyGovState (PreviousEra (AlonzoEra c))
ps
, sgsFuturePParams :: FuturePParams (AlonzoEra c)
sgsFuturePParams = forall era (f :: * -> *).
(TranslateEra era f, TranslationError era f ~ Void) =>
TranslationContext era -> f (PreviousEra era) -> f era
translateEra' TranslationContext (AlonzoEra c)
ctxt forall a b. (a -> b) -> a -> b
$ forall era. ShelleyGovState era -> FuturePParams era
sgsFuturePParams ShelleyGovState (PreviousEra (AlonzoEra c))
ps
}
instance Crypto c => TranslateEra (AlonzoEra c) ProposedPPUpdates where
translateEra :: TranslationContext (AlonzoEra c)
-> ProposedPPUpdates (PreviousEra (AlonzoEra c))
-> Except
(TranslationError (AlonzoEra c) ProposedPPUpdates)
(ProposedPPUpdates (AlonzoEra c))
translateEra TranslationContext (AlonzoEra c)
_ctxt (ProposedPPUpdates Map
(KeyHash 'Genesis (EraCrypto (PreviousEra (AlonzoEra c))))
(PParamsUpdate (PreviousEra (AlonzoEra c)))
ppup) =
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall era.
Map (KeyHash 'Genesis (EraCrypto era)) (PParamsUpdate era)
-> ProposedPPUpdates era
ProposedPPUpdates forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall era.
(EraPParams era, EraPParams (PreviousEra era)) =>
UpgradePParams StrictMaybe era
-> PParamsUpdate (PreviousEra era) -> PParamsUpdate era
upgradePParamsUpdate forall a. Default a => a
def) Map
(KeyHash 'Genesis (EraCrypto (PreviousEra (AlonzoEra c))))
(PParamsUpdate (PreviousEra (AlonzoEra c)))
ppup