Skip to content

Commit ebdf176

Browse files
committed
wip - Remove ToExprs
1 parent ead6bdf commit ebdf176

File tree

46 files changed

+626
-503
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+626
-503
lines changed

eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Era.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE TypeOperators #-}
12
{-# LANGUAGE UndecidableSuperClasses #-}
23
{-# OPTIONS_GHC -Wno-orphans #-}
34

@@ -19,6 +20,7 @@ class
1920
, AllegraEraTxBody era
2021
, AllegraEraTxAuxData era
2122
, AllegraEraScript era
23+
, NativeScript era ~ Timelock era
2224
) =>
2325
AllegraEraTest era
2426

eras/alonzo/impl/src/Cardano/Ledger/Alonzo/UTxO.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE BangPatterns #-}
22
{-# LANGUAGE DataKinds #-}
3+
{-# LANGUAGE DeriveGeneric #-}
34
{-# LANGUAGE FlexibleContexts #-}
45
{-# LANGUAGE FlexibleInstances #-}
56
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
@@ -64,13 +65,14 @@ import qualified Data.Map.Strict as Map
6465
import Data.Maybe (catMaybes, fromMaybe, isJust)
6566
import qualified Data.Set as Set
6667
import Data.Word (Word32)
68+
import GHC.Generics
6769
import Lens.Micro ((^.))
6870
import Lens.Micro.Extras (view)
6971

7072
-- | Alonzo era style `ScriptsNeeded` require also a `PlutusPurpose`, not only the `ScriptHash`
7173
newtype AlonzoScriptsNeeded era
7274
= AlonzoScriptsNeeded [(PlutusPurpose AsIxItem era, ScriptHash)]
73-
deriving (Monoid, Semigroup)
75+
deriving (Monoid, Semigroup, Generic)
7476

7577
deriving instance AlonzoEraScript era => Eq (AlonzoScriptsNeeded era)
7678
deriving instance AlonzoEraScript era => Show (AlonzoScriptsNeeded era)

eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Era.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class
2626
, AlonzoEraTxAuxData era
2727
, AlonzoEraUTxO era
2828
, ToExpr (PlutusScript era)
29+
, ToExpr (PlutusPurpose AsIx era)
30+
, ToExpr (PlutusPurpose AsIxItem era)
2931
, Script era ~ AlonzoScript era
3032
) =>
3133
AlonzoEraTest era

eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/TreeDiff.hs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import Cardano.Ledger.Alonzo.Tx
2525
import Cardano.Ledger.Alonzo.TxAuxData
2626
import Cardano.Ledger.Alonzo.TxBody
2727
import Cardano.Ledger.Alonzo.TxWits
28+
import Cardano.Ledger.Alonzo.UTxO
2829
import Cardano.Ledger.BaseTypes
2930
import Cardano.Ledger.Compactible
3031
import Cardano.Ledger.Plutus.Evaluate (PlutusWithContext (..))
@@ -45,6 +46,12 @@ deriving newtype instance ToExpr ix => ToExpr (AsIx ix it)
4546

4647
deriving newtype instance ToExpr it => ToExpr (AsItem ix it)
4748

49+
instance (ToExpr ix, ToExpr it) => ToExpr (AsIxItem ix it)
50+
51+
instance ToExpr (PlutusPurpose AsIxItem era) => ToExpr (AlonzoScriptsNeeded era)
52+
53+
instance ToExpr (TxCert era) => ToExpr (AlonzoPlutusPurpose AsIxItem era)
54+
4855
-- Core
4956
deriving newtype instance ToExpr CoinPerWord
5057

@@ -168,3 +175,7 @@ instance
168175
, ("pwcExUnits", toExpr pwcExUnits)
169176
, ("pwcCostModel", toExpr pwcCostModel)
170177
]
178+
179+
instance
180+
ToExpr (PredicateFailure (EraRule "LEDGERS" era)) =>
181+
ToExpr (AlonzoBbodyPredFailure era)

eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Era.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE FlexibleContexts #-}
12
{-# LANGUAGE UndecidableSuperClasses #-}
23
{-# OPTIONS_GHC -Wno-orphans #-}
34

eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/TreeDiff.hs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ instance
4646
) =>
4747
ToExpr (ConwayPlutusPurpose AsItem era)
4848

49+
instance
50+
( ToExpr (TxCert era)
51+
, ToExpr (PParamsHKD StrictMaybe era)
52+
) =>
53+
ToExpr (ConwayPlutusPurpose AsIxItem era)
54+
4955
-- PlutusContext
5056
instance
5157
( Era era
@@ -127,6 +133,18 @@ instance
127133
where
128134
(a, b) = finishDRepPulser x
129135

136+
-- TODO: consider this
137+
instance
138+
( EraStake era
139+
, EraPParams era
140+
, ToExpr (DRepPulsingState era)
141+
, ToExpr (RatifyState era)
142+
, ToExpr (PParamsHKD StrictMaybe era)
143+
) =>
144+
ToExpr (DRepPulser era Identity (RatifyState era))
145+
where
146+
toExpr = toExpr . finishDRepPulser . DRPulsing
147+
130148
instance ToExpr (InstantStake era) => ToExpr (RatifyEnv era) where
131149
toExpr (RatifyEnv stake pool drep dstate ep cs delegatees poolps) =
132150
App
@@ -293,3 +311,7 @@ instance
293311
instance ToExpr (VState era)
294312

295313
instance ConwayEraCertState era => ToExpr (ConwayCertState era)
314+
315+
instance
316+
ToExpr (PredicateFailure (EraRule "LEDGERS" era)) =>
317+
ToExpr (ConwayBbodyPredFailure era)

eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/TreeDiff.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ instance ToExpr AssetName where
3030

3131
deriving newtype instance ToExpr (CompactForm MaryValue)
3232

33-
instance ToExpr (TxBody MaryEra)
33+
instance ToExpr (TxBody MaryEra) -- TODO: investigate

eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Bbody.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import NoThunks.Class (NoThunks (..))
6666

6767
data ShelleyBbodyState era
6868
= BbodyState !(State (EraRule "LEDGERS" era)) !BlocksMade
69+
deriving (Generic)
6970

7071
deriving stock instance Show (State (EraRule "LEDGERS" era)) => Show (ShelleyBbodyState era)
7172

eras/shelley/impl/src/Cardano/Ledger/Shelley/UTxO.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{-# LANGUAGE BlockArguments #-}
44
{-# LANGUAGE ConstraintKinds #-}
55
{-# LANGUAGE DataKinds #-}
6+
{-# LANGUAGE DeriveGeneric #-}
67
{-# LANGUAGE DerivingVia #-}
78
{-# LANGUAGE FlexibleContexts #-}
89
{-# LANGUAGE FlexibleInstances #-}
@@ -80,6 +81,7 @@ import Data.Foldable (Foldable (fold), foldr', toList)
8081
import qualified Data.Map.Strict as Map
8182
import Data.Set (Set)
8283
import qualified Data.Set as Set
84+
import GHC.Generics (Generic)
8385
import Lens.Micro ((^.))
8486

8587
-- | Compute the subset of inputs of the set 'txIns' for which each input is
@@ -173,7 +175,7 @@ getConsumedCoin pp lookupRefund utxo txBody =
173175
withdrawals = fold . unWithdrawals $ txBody ^. withdrawalsTxBodyL
174176

175177
newtype ShelleyScriptsNeeded era = ShelleyScriptsNeeded (Set ScriptHash)
176-
deriving (Eq, Show)
178+
deriving (Eq, Show, Generic)
177179

178180
instance EraUTxO ShelleyEra where
179181
type ScriptsNeeded ShelleyEra = ShelleyScriptsNeeded ShelleyEra

eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Era.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module Test.Cardano.Ledger.Shelley.Era (
1010
import Cardano.Ledger.Shelley
1111
import Cardano.Ledger.Shelley.LedgerState
1212
import Cardano.Ledger.Shelley.Scripts
13+
import Cardano.Ledger.State
1314
import Data.Default
1415
import Test.Cardano.Ledger.Common
1516
import Test.Cardano.Ledger.Era
@@ -25,6 +26,7 @@ class
2526
, NFData (StashedAVVMAddresses era)
2627
, Default (StashedAVVMAddresses era)
2728
, Arbitrary (StashedAVVMAddresses era)
29+
, ToExpr (ScriptsNeeded era)
2830
) =>
2931
ShelleyEraTest era
3032

eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/TreeDiff.hs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import Cardano.Ledger.Shelley.TxBody
2626
import Cardano.Ledger.Shelley.TxCert
2727
import Cardano.Ledger.Shelley.TxOut
2828
import Cardano.Ledger.Shelley.TxWits
29+
import Cardano.Ledger.Shelley.UTxO
2930
import Test.Cardano.Ledger.TreeDiff
3031

3132
-- PParams
@@ -154,6 +155,8 @@ instance
154155

155156
instance ToExpr (ShelleyInstantStake era)
156157

158+
instance ToExpr (ShelleyScriptsNeeded era)
159+
157160
-- Rules/Utxo
158161
instance
159162
( ToExpr (EraRuleFailure "PPUP" era)
@@ -274,3 +277,42 @@ instance
274277
ToExpr (ShelleyLedgersPredFailure era)
275278

276279
instance EraCertState era => ToExpr (ShelleyCertState era)
280+
281+
instance
282+
ToExpr (PredicateFailure (EraRule "LEDGERS" era)) =>
283+
ToExpr (ShelleyBbodyPredFailure era)
284+
285+
instance
286+
ToExpr (State (EraRule "LEDGERS" era)) =>
287+
ToExpr (ShelleyBbodyState era)
288+
289+
instance
290+
( ToExpr (PredicateFailure (EraRule "NEWEPOCH" era))
291+
, ToExpr (PredicateFailure (EraRule "RUPD" era))
292+
) =>
293+
ToExpr (ShelleyTickPredFailure era)
294+
295+
instance
296+
( ToExpr (PredicateFailure (EraRule "EPOCH" era))
297+
, ToExpr (PredicateFailure (EraRule "MIR" era))
298+
) =>
299+
ToExpr (ShelleyNewEpochPredFailure era)
300+
301+
instance
302+
( ToExpr (UpecPredFailure era)
303+
, ToExpr (PredicateFailure (EraRule "POOLREAP" era))
304+
, ToExpr (PredicateFailure (EraRule "SNAP" era))
305+
) =>
306+
ToExpr (ShelleyEpochPredFailure era)
307+
308+
instance ToExpr (ShelleyUpecPredFailure era)
309+
310+
instance ToExpr (ShelleyPoolreapPredFailure era)
311+
312+
instance ToExpr (ShelleySnapPredFailure era)
313+
314+
instance ToExpr (ShelleyMirPredFailure era)
315+
316+
instance ToExpr (ShelleyRupdPredFailure era)
317+
318+
-- instance ToExpr (UpecPredFailurePV (ProtVerLow era) era)

0 commit comments

Comments
 (0)