Skip to content

Commit fcf379c

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

File tree

30 files changed

+341
-323
lines changed

30 files changed

+341
-323
lines changed

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

+2
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

+3-1
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

+2
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

+7
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

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

+1
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

+18
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

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

+3-1
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

+2
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

+3
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)

0 commit comments

Comments
 (0)