{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Test.Cardano.Ledger.Conformance.SpecTranslate.Conway.Utxo () where
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Conway.Core (EraPParams (..), EraRule, PParams, Value)
import Cardano.Ledger.Conway.Rules (ConwayUtxoPredFailure)
import Cardano.Ledger.Core (EraTxOut (..))
import Cardano.Ledger.Shelley.Rules (UtxoEnv (..))
import Control.State.Transition.Extended (STS (..))
import Data.Functor.Identity (Identity)
import qualified Lib as Agda
import Test.Cardano.Ledger.Conformance (OpaqueErrorString (..))
import Test.Cardano.Ledger.Conformance.SpecTranslate.Conway.Base (SpecTranslate (..))
import Test.Cardano.Ledger.Conformance.SpecTranslate.Conway.Cert ()
import Test.Cardano.Ledger.Conway.TreeDiff (ToExpr (..))
instance
( SpecRep (PParams era) ~ Agda.PParams
, SpecTranslate ctx (PParamsHKD Identity era)
) =>
SpecTranslate ctx (UtxoEnv era)
where
type SpecRep (UtxoEnv era) = Agda.UTxOEnv
toSpecRep :: UtxoEnv era -> SpecTransM ctx (SpecRep (UtxoEnv era))
toSpecRep UtxoEnv era
x =
Integer -> PParams -> Integer -> UTxOEnv
Agda.MkUTxOEnv
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall ctx a.
SpecTranslate ctx a =>
a -> SpecTransM ctx (SpecRep a)
toSpecRep (forall era. UtxoEnv era -> SlotNo
ueSlot UtxoEnv era
x)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall ctx a.
SpecTranslate ctx a =>
a -> SpecTransM ctx (SpecRep a)
toSpecRep (forall era. UtxoEnv era -> PParams era
uePParams UtxoEnv era
x)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall ctx a.
SpecTranslate ctx a =>
a -> SpecTransM ctx (SpecRep a)
toSpecRep (Integer -> Coin
Coin Integer
10_000_000)
instance
( ToExpr (Value era)
, ToExpr (TxOut era)
, ToExpr (PredicateFailure (EraRule "UTXOS" era))
) =>
SpecTranslate ctx (ConwayUtxoPredFailure era)
where
type SpecRep (ConwayUtxoPredFailure era) = OpaqueErrorString
toSpecRep :: ConwayUtxoPredFailure era
-> SpecTransM ctx (SpecRep (ConwayUtxoPredFailure era))
toSpecRep ConwayUtxoPredFailure era
e = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> OpaqueErrorString
OpaqueErrorString forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> String
show forall a b. (a -> b) -> a -> b
$ forall a. ToExpr a => a -> Expr
toExpr ConwayUtxoPredFailure era
e