|
13 | 13 | {-# LANGUAGE TypeApplications #-} |
14 | 14 | {-# LANGUAGE TypeFamilies #-} |
15 | 15 | {-# LANGUAGE TypeOperators #-} |
| 16 | +{-# LANGUAGE UndecidableSuperClasses #-} |
16 | 17 | {-# OPTIONS_GHC -Wno-orphans #-} |
17 | 18 |
|
18 | 19 | -- Disable completeness checks on GHC versions pre-9.6, where this can be |
@@ -953,19 +954,20 @@ protocolInfoCardano paramsCardano |
953 | 954 |
|
954 | 955 | registerAny :: NP (LedgerState -.-> LedgerState) (CardanoShelleyEras c) |
955 | 956 | registerAny = |
956 | | - injectIntoTestState transitionConfigShelley |
957 | | - :* injectIntoTestState transitionConfigAllegra |
958 | | - :* injectIntoTestState transitionConfigMary |
959 | | - :* injectIntoTestState transitionConfigAlonzo |
960 | | - :* injectIntoTestState transitionConfigBabbage |
961 | | - :* injectIntoTestState transitionConfigConway |
962 | | - :* Nil |
| 957 | + hcmap (Proxy @IsShelleyBlock) injectIntoTestState $ |
| 958 | + WrapTransitionConfig transitionConfigShelley |
| 959 | + :* WrapTransitionConfig transitionConfigAllegra |
| 960 | + :* WrapTransitionConfig transitionConfigMary |
| 961 | + :* WrapTransitionConfig transitionConfigAlonzo |
| 962 | + :* WrapTransitionConfig transitionConfigBabbage |
| 963 | + :* WrapTransitionConfig transitionConfigConway |
| 964 | + :* Nil |
963 | 965 |
|
964 | 966 | injectIntoTestState :: |
965 | 967 | L.EraTransition era |
966 | | - => L.TransitionConfig era |
| 968 | + => WrapTransitionConfig (ShelleyBlock proto era) |
967 | 969 | -> (LedgerState -.-> LedgerState) (ShelleyBlock proto era) |
968 | | - injectIntoTestState cfg = fn $ \st -> st { |
| 970 | + injectIntoTestState (WrapTransitionConfig cfg) = fn $ \st -> st { |
969 | 971 | Shelley.shelleyLedgerState = L.injectIntoTestState cfg (Shelley.shelleyLedgerState st) |
970 | 972 | } |
971 | 973 |
|
@@ -1094,3 +1096,16 @@ mkPartialLedgerConfigShelley transitionConfig maxMajorProtVer shelleyTriggerHard |
1094 | 1096 | maxMajorProtVer |
1095 | 1097 | , shelleyTriggerHardFork = shelleyTriggerHardFork |
1096 | 1098 | } |
| 1099 | + |
| 1100 | +class |
| 1101 | + ( ShelleyBasedEra (ShelleyBlockLedgerEra blk) |
| 1102 | + , blk ~ ShelleyBlock (BlockProtocol blk) (ShelleyBlockLedgerEra blk) |
| 1103 | + ) => IsShelleyBlock blk |
| 1104 | +instance ShelleyBasedEra era => IsShelleyBlock (ShelleyBlock proto era) |
| 1105 | + |
| 1106 | +type family ShelleyBlockLedgerEra blk where |
| 1107 | + ShelleyBlockLedgerEra (ShelleyBlock proto era) = era |
| 1108 | + |
| 1109 | +-- | We need this wrapper to partially apply a 'TransitionConfig' in an NP. |
| 1110 | +newtype WrapTransitionConfig blk = |
| 1111 | + WrapTransitionConfig (L.TransitionConfig (ShelleyBlockLedgerEra blk)) |
0 commit comments