-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce SomeProtocolVersion definition
Showing
4 changed files
with
77 additions
and
3 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,63 @@ | ||
{-# LANGUAGE ConstraintKinds #-} | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
{-# LANGUAGE TypeOperators #-} | ||
|
||
|
||
|
||
module Cardano.Api.Protocol.Version where | ||
|
||
import Cardano.Api.Eon.ShelleyBasedEra | ||
import qualified Cardano.Api.Eras.Core as Api | ||
import Cardano.Api.Script | ||
import Cardano.Api.TxBody | ||
|
||
import qualified Data.Set as Set | ||
import GHC.TypeLits | ||
|
||
-- Users interacting with Cardano are likely only interested in using the latest | ||
-- features available on mainnet and experimenting with the upcoming era as this becomes | ||
-- available. Therefore we restrict the choices of protocol version to what is currently | ||
-- on mainnet and what is in the upcoming era. | ||
|
||
-- | Minimum supported version. Corresponds to Babbage era. | ||
type MinSupportedVersion = 8 :: Nat | ||
|
||
-- | Maximum supported version. Corresponds to Conway era. | ||
type MaxSupportedVersion = 9 :: Nat | ||
|
||
type BabbageEra = 8 :: Nat | ||
type ConwayEra = 9 :: Nat | ||
|
||
type SupportedProtocolVersionRange version = | ||
( MinSupportedVersion <= version | ||
, version <= MaxSupportedVersion | ||
) | ||
|
||
data SomeProtocolVersion version where | ||
CurrentProtocolVersion | ||
:: SupportedProtocolVersionRange BabbageEra | ||
=> SomeProtocolVersion BabbageEra | ||
ExperimentalProtocolVersion | ||
:: SupportedProtocolVersionRange ConwayEra | ||
=> SomeProtocolVersion ConwayEra | ||
|
||
|
||
type family VersionToEra version where | ||
VersionToEra BabbageEra = Api.BabbageEra | ||
VersionToEra ConwayEra = Api.ConwayEra | ||
|
||
protocolVersionToSbe | ||
:: VersionToEra version ~ era | ||
=> SomeProtocolVersion version | ||
-> ShelleyBasedEra era | ||
protocolVersionToSbe CurrentProtocolVersion = ShelleyBasedEraBabbage | ||
protocolVersionToSbe ExperimentalProtocolVersion = ShelleyBasedEraConway | ||
|
||
createSingleProtVerProxy | ||
:: Proxy version -> SingleProtVer version | ||
createSingleProtVerProxy _ = SingleProtVer |
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