-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #312 from input-output-hk/newhoggy/new-MaryEraOnly…
…-eon New `MaryEraOnly` eon. Disjoint functions
- Loading branch information
Showing
5 changed files
with
136 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{-# LANGUAGE ConstraintKinds #-} | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE StandaloneDeriving #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
{-# LANGUAGE TypeOperators #-} | ||
|
||
module Cardano.Api.Eon.MaryEraOnly | ||
( MaryEraOnly(..) | ||
, maryEraOnlyConstraints | ||
, maryEraOnlyToCardanoEra | ||
, maryEraOnlyToShelleyBasedEra | ||
|
||
, MaryEraOnlyConstraints | ||
) where | ||
|
||
import Cardano.Api.Eon.ShelleyBasedEra | ||
import Cardano.Api.Eras.Core | ||
import Cardano.Api.Modes | ||
import Cardano.Api.Query.Types | ||
|
||
import Cardano.Binary | ||
import qualified Cardano.Crypto.Hash.Blake2b as Blake2b | ||
import qualified Cardano.Crypto.Hash.Class as C | ||
import qualified Cardano.Crypto.VRF as C | ||
import qualified Cardano.Ledger.Api as L | ||
import qualified Cardano.Ledger.BaseTypes as L | ||
import qualified Cardano.Ledger.Core as L | ||
import qualified Cardano.Ledger.Mary.Value as L | ||
import qualified Cardano.Ledger.SafeHash as L | ||
import qualified Cardano.Ledger.UTxO as L | ||
import qualified Ouroboros.Consensus.Protocol.Abstract as Consensus | ||
import qualified Ouroboros.Consensus.Protocol.Praos.Common as Consensus | ||
import qualified Ouroboros.Consensus.Shelley.Ledger as Consensus | ||
|
||
import Data.Aeson | ||
import Data.Typeable (Typeable) | ||
|
||
data MaryEraOnly era where | ||
MaryEraOnlyMary :: MaryEraOnly MaryEra | ||
|
||
deriving instance Show (MaryEraOnly era) | ||
deriving instance Eq (MaryEraOnly era) | ||
|
||
instance Eon MaryEraOnly where | ||
inEonForEra no yes = \case | ||
ByronEra -> no | ||
ShelleyEra -> no | ||
AllegraEra -> no | ||
MaryEra -> yes MaryEraOnlyMary | ||
AlonzoEra -> no | ||
BabbageEra -> no | ||
ConwayEra -> no | ||
|
||
instance ToCardanoEra MaryEraOnly where | ||
toCardanoEra = \case | ||
MaryEraOnlyMary -> MaryEra | ||
|
||
type MaryEraOnlyConstraints era = | ||
( C.HashAlgorithm (L.HASH (L.EraCrypto (ShelleyLedgerEra era))) | ||
, C.Signable (L.VRF (L.EraCrypto (ShelleyLedgerEra era))) L.Seed | ||
, Consensus.PraosProtocolSupportsNode (ConsensusProtocol era) | ||
, Consensus.ShelleyCompatible (ConsensusProtocol era) (ShelleyLedgerEra era) | ||
, L.ADDRHASH (Consensus.PraosProtocolSupportsNodeCrypto (ConsensusProtocol era)) ~ Blake2b.Blake2b_224 | ||
, L.Crypto (L.EraCrypto (ShelleyLedgerEra era)) | ||
, L.Era (ShelleyLedgerEra era) | ||
, L.EraCrypto (ShelleyLedgerEra era) ~ L.StandardCrypto | ||
, L.EraPParams (ShelleyLedgerEra era) | ||
, L.EraTx (ShelleyLedgerEra era) | ||
, L.EraTxBody (ShelleyLedgerEra era) | ||
, L.EraUTxO (ShelleyLedgerEra era) | ||
, L.HashAnnotated (L.TxBody (ShelleyLedgerEra era)) L.EraIndependentTxBody L.StandardCrypto | ||
, L.MaryEraTxBody (ShelleyLedgerEra era) | ||
, L.ShelleyEraTxBody (ShelleyLedgerEra era) | ||
, L.ShelleyEraTxCert (ShelleyLedgerEra era) | ||
, L.Value (ShelleyLedgerEra era) ~ L.MaryValue L.StandardCrypto | ||
|
||
, FromCBOR (Consensus.ChainDepState (ConsensusProtocol era)) | ||
, FromCBOR (DebugLedgerState era) | ||
, IsCardanoEra era | ||
, IsShelleyBasedEra era | ||
, ToJSON (DebugLedgerState era) | ||
, Typeable era | ||
) | ||
|
||
maryEraOnlyConstraints :: () | ||
=> MaryEraOnly era | ||
-> (MaryEraOnlyConstraints era => a) | ||
-> a | ||
maryEraOnlyConstraints = \case | ||
MaryEraOnlyMary -> id | ||
|
||
maryEraOnlyToCardanoEra :: MaryEraOnly era -> CardanoEra era | ||
maryEraOnlyToCardanoEra = shelleyBasedToCardanoEra . maryEraOnlyToShelleyBasedEra | ||
|
||
maryEraOnlyToShelleyBasedEra :: MaryEraOnly era -> ShelleyBasedEra era | ||
maryEraOnlyToShelleyBasedEra = \case | ||
MaryEraOnlyMary -> ShelleyBasedEraMary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters