|
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 |
@@ -969,19 +970,20 @@ protocolInfoCardano paramsCardano |
969 | 970 |
|
970 | 971 | registerAny :: NP (LedgerState -.-> LedgerState) (CardanoShelleyEras c) |
971 | 972 | registerAny = |
972 | | - injectIntoTestState transitionConfigShelley |
973 | | - :* injectIntoTestState transitionConfigAllegra |
974 | | - :* injectIntoTestState transitionConfigMary |
975 | | - :* injectIntoTestState transitionConfigAlonzo |
976 | | - :* injectIntoTestState transitionConfigBabbage |
977 | | - :* injectIntoTestState transitionConfigConway |
978 | | - :* Nil |
| 973 | + hcmap (Proxy @IsShelleyBlock) injectIntoTestState $ |
| 974 | + WrapTransitionConfig transitionConfigShelley |
| 975 | + :* WrapTransitionConfig transitionConfigAllegra |
| 976 | + :* WrapTransitionConfig transitionConfigMary |
| 977 | + :* WrapTransitionConfig transitionConfigAlonzo |
| 978 | + :* WrapTransitionConfig transitionConfigBabbage |
| 979 | + :* WrapTransitionConfig transitionConfigConway |
| 980 | + :* Nil |
979 | 981 |
|
980 | 982 | injectIntoTestState :: |
981 | 983 | L.EraTransition era |
982 | | - => L.TransitionConfig era |
| 984 | + => WrapTransitionConfig (ShelleyBlock proto era) |
983 | 985 | -> (LedgerState -.-> LedgerState) (ShelleyBlock proto era) |
984 | | - injectIntoTestState cfg = fn $ \st -> st { |
| 986 | + injectIntoTestState (WrapTransitionConfig cfg) = fn $ \st -> st { |
985 | 987 | Shelley.shelleyLedgerState = L.injectIntoTestState cfg (Shelley.shelleyLedgerState st) |
986 | 988 | } |
987 | 989 |
|
@@ -1110,3 +1112,16 @@ mkPartialLedgerConfigShelley transitionConfig maxMajorProtVer shelleyTriggerHard |
1110 | 1112 | maxMajorProtVer |
1111 | 1113 | , shelleyTriggerHardFork = shelleyTriggerHardFork |
1112 | 1114 | } |
| 1115 | + |
| 1116 | +class |
| 1117 | + ( ShelleyBasedEra (ShelleyBlockLedgerEra blk) |
| 1118 | + , blk ~ ShelleyBlock (BlockProtocol blk) (ShelleyBlockLedgerEra blk) |
| 1119 | + ) => IsShelleyBlock blk |
| 1120 | +instance ShelleyBasedEra era => IsShelleyBlock (ShelleyBlock proto era) |
| 1121 | + |
| 1122 | +type family ShelleyBlockLedgerEra blk where |
| 1123 | + ShelleyBlockLedgerEra (ShelleyBlock proto era) = era |
| 1124 | + |
| 1125 | +-- | We need this wrapper to partially apply a 'TransitionConfig' in an NP. |
| 1126 | +newtype WrapTransitionConfig blk = |
| 1127 | + WrapTransitionConfig (L.TransitionConfig (ShelleyBlockLedgerEra blk)) |
0 commit comments