module PlutusLedgerApi.Common.ProtocolVersions
( MajorProtocolVersion (..)
, shelleyPV
, allegraPV
, maryPV
, alonzoPV
, vasilPV
, valentinePV
, changPV
, changPlus1PV
, knownPVs
, futurePV
) where
import Codec.Serialise (Serialise)
import Data.Set qualified as Set
import GHC.Generics (Generic)
import Prettyprinter
newtype MajorProtocolVersion = MajorProtocolVersion { MajorProtocolVersion -> Int
getMajorProtocolVersion :: Int }
deriving newtype (MajorProtocolVersion -> MajorProtocolVersion -> Bool
(MajorProtocolVersion -> MajorProtocolVersion -> Bool)
-> (MajorProtocolVersion -> MajorProtocolVersion -> Bool)
-> Eq MajorProtocolVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MajorProtocolVersion -> MajorProtocolVersion -> Bool
== :: MajorProtocolVersion -> MajorProtocolVersion -> Bool
$c/= :: MajorProtocolVersion -> MajorProtocolVersion -> Bool
/= :: MajorProtocolVersion -> MajorProtocolVersion -> Bool
Eq, Eq MajorProtocolVersion
Eq MajorProtocolVersion =>
(MajorProtocolVersion -> MajorProtocolVersion -> Ordering)
-> (MajorProtocolVersion -> MajorProtocolVersion -> Bool)
-> (MajorProtocolVersion -> MajorProtocolVersion -> Bool)
-> (MajorProtocolVersion -> MajorProtocolVersion -> Bool)
-> (MajorProtocolVersion -> MajorProtocolVersion -> Bool)
-> (MajorProtocolVersion
-> MajorProtocolVersion -> MajorProtocolVersion)
-> (MajorProtocolVersion
-> MajorProtocolVersion -> MajorProtocolVersion)
-> Ord MajorProtocolVersion
MajorProtocolVersion -> MajorProtocolVersion -> Bool
MajorProtocolVersion -> MajorProtocolVersion -> Ordering
MajorProtocolVersion
-> MajorProtocolVersion -> MajorProtocolVersion
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: MajorProtocolVersion -> MajorProtocolVersion -> Ordering
compare :: MajorProtocolVersion -> MajorProtocolVersion -> Ordering
$c< :: MajorProtocolVersion -> MajorProtocolVersion -> Bool
< :: MajorProtocolVersion -> MajorProtocolVersion -> Bool
$c<= :: MajorProtocolVersion -> MajorProtocolVersion -> Bool
<= :: MajorProtocolVersion -> MajorProtocolVersion -> Bool
$c> :: MajorProtocolVersion -> MajorProtocolVersion -> Bool
> :: MajorProtocolVersion -> MajorProtocolVersion -> Bool
$c>= :: MajorProtocolVersion -> MajorProtocolVersion -> Bool
>= :: MajorProtocolVersion -> MajorProtocolVersion -> Bool
$cmax :: MajorProtocolVersion
-> MajorProtocolVersion -> MajorProtocolVersion
max :: MajorProtocolVersion
-> MajorProtocolVersion -> MajorProtocolVersion
$cmin :: MajorProtocolVersion
-> MajorProtocolVersion -> MajorProtocolVersion
min :: MajorProtocolVersion
-> MajorProtocolVersion -> MajorProtocolVersion
Ord, Int -> MajorProtocolVersion -> ShowS
[MajorProtocolVersion] -> ShowS
MajorProtocolVersion -> String
(Int -> MajorProtocolVersion -> ShowS)
-> (MajorProtocolVersion -> String)
-> ([MajorProtocolVersion] -> ShowS)
-> Show MajorProtocolVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MajorProtocolVersion -> ShowS
showsPrec :: Int -> MajorProtocolVersion -> ShowS
$cshow :: MajorProtocolVersion -> String
show :: MajorProtocolVersion -> String
$cshowList :: [MajorProtocolVersion] -> ShowS
showList :: [MajorProtocolVersion] -> ShowS
Show, [MajorProtocolVersion] -> Encoding
MajorProtocolVersion -> Encoding
(MajorProtocolVersion -> Encoding)
-> (forall s. Decoder s MajorProtocolVersion)
-> ([MajorProtocolVersion] -> Encoding)
-> (forall s. Decoder s [MajorProtocolVersion])
-> Serialise MajorProtocolVersion
forall s. Decoder s [MajorProtocolVersion]
forall s. Decoder s MajorProtocolVersion
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
$cencode :: MajorProtocolVersion -> Encoding
encode :: MajorProtocolVersion -> Encoding
$cdecode :: forall s. Decoder s MajorProtocolVersion
decode :: forall s. Decoder s MajorProtocolVersion
$cencodeList :: [MajorProtocolVersion] -> Encoding
encodeList :: [MajorProtocolVersion] -> Encoding
$cdecodeList :: forall s. Decoder s [MajorProtocolVersion]
decodeList :: forall s. Decoder s [MajorProtocolVersion]
Serialise)
deriving stock ((forall x. MajorProtocolVersion -> Rep MajorProtocolVersion x)
-> (forall x. Rep MajorProtocolVersion x -> MajorProtocolVersion)
-> Generic MajorProtocolVersion
forall x. Rep MajorProtocolVersion x -> MajorProtocolVersion
forall x. MajorProtocolVersion -> Rep MajorProtocolVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MajorProtocolVersion -> Rep MajorProtocolVersion x
from :: forall x. MajorProtocolVersion -> Rep MajorProtocolVersion x
$cto :: forall x. Rep MajorProtocolVersion x -> MajorProtocolVersion
to :: forall x. Rep MajorProtocolVersion x -> MajorProtocolVersion
Generic)
instance Pretty MajorProtocolVersion where
pretty :: forall ann. MajorProtocolVersion -> Doc ann
pretty (MajorProtocolVersion Int
v) = Int -> Doc ann
forall ann. Int -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Int
v
shelleyPV :: MajorProtocolVersion
shelleyPV :: MajorProtocolVersion
shelleyPV = Int -> MajorProtocolVersion
MajorProtocolVersion Int
2
allegraPV :: MajorProtocolVersion
allegraPV :: MajorProtocolVersion
allegraPV = Int -> MajorProtocolVersion
MajorProtocolVersion Int
3
maryPV :: MajorProtocolVersion
maryPV :: MajorProtocolVersion
maryPV = Int -> MajorProtocolVersion
MajorProtocolVersion Int
4
alonzoPV :: MajorProtocolVersion
alonzoPV :: MajorProtocolVersion
alonzoPV = Int -> MajorProtocolVersion
MajorProtocolVersion Int
5
vasilPV :: MajorProtocolVersion
vasilPV :: MajorProtocolVersion
vasilPV = Int -> MajorProtocolVersion
MajorProtocolVersion Int
7
valentinePV :: MajorProtocolVersion
valentinePV :: MajorProtocolVersion
valentinePV = Int -> MajorProtocolVersion
MajorProtocolVersion Int
8
changPV :: MajorProtocolVersion
changPV :: MajorProtocolVersion
changPV = Int -> MajorProtocolVersion
MajorProtocolVersion Int
9
changPlus1PV :: MajorProtocolVersion
changPlus1PV :: MajorProtocolVersion
changPlus1PV = Int -> MajorProtocolVersion
MajorProtocolVersion Int
10
knownPVs :: Set.Set MajorProtocolVersion
knownPVs :: Set MajorProtocolVersion
knownPVs =
[MajorProtocolVersion] -> Set MajorProtocolVersion
forall a. Ord a => [a] -> Set a
Set.fromList
[ MajorProtocolVersion
shelleyPV
, MajorProtocolVersion
allegraPV
, MajorProtocolVersion
maryPV
, MajorProtocolVersion
alonzoPV
, MajorProtocolVersion
vasilPV
, MajorProtocolVersion
valentinePV
, MajorProtocolVersion
changPV
, MajorProtocolVersion
changPlus1PV
]
futurePV :: MajorProtocolVersion
futurePV :: MajorProtocolVersion
futurePV = Int -> MajorProtocolVersion
MajorProtocolVersion Int
forall a. Bounded a => a
maxBound