-- editorconfig-checker-disable-file
{-# LANGUAGE BlockArguments    #-}
{-# LANGUAGE DeriveAnyClass    #-}
{-# LANGUAGE DerivingVia       #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell   #-}
{-# LANGUAGE TypeApplications  #-}
{-# OPTIONS_GHC -fno-specialise #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

-- | Functions for working with scripts on the ledger.
module PlutusLedgerApi.V1.Scripts (
  ScriptError (..),
  Redeemer (..),
  Datum (..),
  Context (..),
  DatumHash (..),
  RedeemerHash (..),
  ScriptHash (..),
) where

import PlutusTx.Prelude
import Prelude qualified as Haskell

import Codec.Serialise (Serialise (..))
import Control.DeepSeq (NFData)
import Data.String (IsString)
import Data.Text (Text)
import Data.Typeable (Typeable)
import GHC.Generics (Generic)
import PlutusLedgerApi.V1.Bytes (LedgerBytes (..))
import PlutusTx (FromData (..), ToData (..), UnsafeFromData (..), makeLift)
import PlutusTx.Blueprint.Class (HasBlueprintSchema (..))
import PlutusTx.Blueprint.Definition (HasBlueprintDefinition (..))
import PlutusTx.Blueprint.Schema (Schema (..), emptyBytesSchema)
import PlutusTx.Blueprint.Schema.Annotation (SchemaInfo (..), emptySchemaInfo)
import PlutusTx.Builtins qualified as Builtins
import PlutusTx.Builtins.Internal as BI
import PlutusTx.Show (deriveShow)
import Prettyprinter (Pretty)

{- Note [Serialise instances for Datum and Redeemer]
The `Serialise` instances for `Datum` and `Redeemer` exist for several reasons:

- They are useful for the indexers in plutus-apps
- There's clearly only one sensible way to encode `Datum` and `Redeemer` into CBOR,
  since they just wrap `PLC.Data`.
- The encoders and decoders are annoying to implement downstream, because one would
  have to import `BuiltinData` which is from a different package.
-}

-- | A higher-level evaluation error.
data ScriptError
  = -- | Expected behavior of the engine (e.g. user-provided error)
    EvaluationError ![Text] !Haskell.String
  | -- | Unexpected behavior of the engine (a bug)
    EvaluationException !Haskell.String !Haskell.String
  deriving stock (Int -> ScriptError -> ShowS
[ScriptError] -> ShowS
ScriptError -> String
(Int -> ScriptError -> ShowS)
-> (ScriptError -> String)
-> ([ScriptError] -> ShowS)
-> Show ScriptError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScriptError -> ShowS
showsPrec :: Int -> ScriptError -> ShowS
$cshow :: ScriptError -> String
show :: ScriptError -> String
$cshowList :: [ScriptError] -> ShowS
showList :: [ScriptError] -> ShowS
Haskell.Show, ScriptError -> ScriptError -> Bool
(ScriptError -> ScriptError -> Bool)
-> (ScriptError -> ScriptError -> Bool) -> Eq ScriptError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScriptError -> ScriptError -> Bool
== :: ScriptError -> ScriptError -> Bool
$c/= :: ScriptError -> ScriptError -> Bool
/= :: ScriptError -> ScriptError -> Bool
Haskell.Eq, (forall x. ScriptError -> Rep ScriptError x)
-> (forall x. Rep ScriptError x -> ScriptError)
-> Generic ScriptError
forall x. Rep ScriptError x -> ScriptError
forall x. ScriptError -> Rep ScriptError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ScriptError -> Rep ScriptError x
from :: forall x. ScriptError -> Rep ScriptError x
$cto :: forall x. Rep ScriptError x -> ScriptError
to :: forall x. Rep ScriptError x -> ScriptError
Generic, Typeable)
  deriving anyclass (ScriptError -> ()
(ScriptError -> ()) -> NFData ScriptError
forall a. (a -> ()) -> NFData a
$crnf :: ScriptError -> ()
rnf :: ScriptError -> ()
NFData, DefinitionId
DefinitionId -> HasBlueprintDefinition ScriptError
forall t. DefinitionId -> HasBlueprintDefinition t
$cdefinitionId :: DefinitionId
definitionId :: DefinitionId
HasBlueprintDefinition)

-- | 'Datum' is a wrapper around 'Data' values which are used as data in transaction outputs.
newtype Datum = Datum {Datum -> BuiltinData
getDatum :: BuiltinData}
  deriving stock ((forall x. Datum -> Rep Datum x)
-> (forall x. Rep Datum x -> Datum) -> Generic Datum
forall x. Rep Datum x -> Datum
forall x. Datum -> Rep Datum x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Datum -> Rep Datum x
from :: forall x. Datum -> Rep Datum x
$cto :: forall x. Rep Datum x -> Datum
to :: forall x. Rep Datum x -> Datum
Generic, Typeable, Int -> Datum -> ShowS
[Datum] -> ShowS
Datum -> String
(Int -> Datum -> ShowS)
-> (Datum -> String) -> ([Datum] -> ShowS) -> Show Datum
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Datum -> ShowS
showsPrec :: Int -> Datum -> ShowS
$cshow :: Datum -> String
show :: Datum -> String
$cshowList :: [Datum] -> ShowS
showList :: [Datum] -> ShowS
Haskell.Show)
  deriving newtype (Datum -> Datum -> Bool
(Datum -> Datum -> Bool) -> (Datum -> Datum -> Bool) -> Eq Datum
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Datum -> Datum -> Bool
== :: Datum -> Datum -> Bool
$c/= :: Datum -> Datum -> Bool
/= :: Datum -> Datum -> Bool
Haskell.Eq, Eq Datum
Eq Datum =>
(Datum -> Datum -> Ordering)
-> (Datum -> Datum -> Bool)
-> (Datum -> Datum -> Bool)
-> (Datum -> Datum -> Bool)
-> (Datum -> Datum -> Bool)
-> (Datum -> Datum -> Datum)
-> (Datum -> Datum -> Datum)
-> Ord Datum
Datum -> Datum -> Bool
Datum -> Datum -> Ordering
Datum -> Datum -> Datum
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Datum -> Datum -> Ordering
compare :: Datum -> Datum -> Ordering
$c< :: Datum -> Datum -> Bool
< :: Datum -> Datum -> Bool
$c<= :: Datum -> Datum -> Bool
<= :: Datum -> Datum -> Bool
$c> :: Datum -> Datum -> Bool
> :: Datum -> Datum -> Bool
$c>= :: Datum -> Datum -> Bool
>= :: Datum -> Datum -> Bool
$cmax :: Datum -> Datum -> Datum
max :: Datum -> Datum -> Datum
$cmin :: Datum -> Datum -> Datum
min :: Datum -> Datum -> Datum
Haskell.Ord, Datum -> Datum -> Bool
(Datum -> Datum -> Bool) -> Eq Datum
forall a. (a -> a -> Bool) -> Eq a
$c== :: Datum -> Datum -> Bool
== :: Datum -> Datum -> Bool
Eq, Datum -> BuiltinData
(Datum -> BuiltinData) -> ToData Datum
forall a. (a -> BuiltinData) -> ToData a
$ctoBuiltinData :: Datum -> BuiltinData
toBuiltinData :: Datum -> BuiltinData
ToData, BuiltinData -> Maybe Datum
(BuiltinData -> Maybe Datum) -> FromData Datum
forall a. (BuiltinData -> Maybe a) -> FromData a
$cfromBuiltinData :: BuiltinData -> Maybe Datum
fromBuiltinData :: BuiltinData -> Maybe Datum
FromData, BuiltinData -> Datum
(BuiltinData -> Datum) -> UnsafeFromData Datum
forall a. (BuiltinData -> a) -> UnsafeFromData a
$cunsafeFromBuiltinData :: BuiltinData -> Datum
unsafeFromBuiltinData :: BuiltinData -> Datum
UnsafeFromData, (forall ann. Datum -> Doc ann)
-> (forall ann. [Datum] -> Doc ann) -> Pretty Datum
forall ann. [Datum] -> Doc ann
forall ann. Datum -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. Datum -> Doc ann
pretty :: forall ann. Datum -> Doc ann
$cprettyList :: forall ann. [Datum] -> Doc ann
prettyList :: forall ann. [Datum] -> Doc ann
Pretty)
  deriving anyclass (Datum -> ()
(Datum -> ()) -> NFData Datum
forall a. (a -> ()) -> NFData a
$crnf :: Datum -> ()
rnf :: Datum -> ()
NFData, DefinitionId
DefinitionId -> HasBlueprintDefinition Datum
forall t. DefinitionId -> HasBlueprintDefinition t
$cdefinitionId :: DefinitionId
definitionId :: DefinitionId
HasBlueprintDefinition)

instance HasBlueprintSchema Datum referencedTypes where
  schema :: Schema referencedTypes
schema = SchemaInfo -> Schema referencedTypes
forall (referencedTypes :: [*]).
SchemaInfo -> Schema referencedTypes
SchemaBuiltInData SchemaInfo
emptySchemaInfo{title = Just "Datum"}

-- See Note [Serialise instances for Datum and Redeemer]
instance Serialise Datum where
  encode :: Datum -> Encoding
encode (Datum (BuiltinData Data
d)) = Data -> Encoding
forall a. Serialise a => a -> Encoding
encode Data
d
  decode :: forall s. Decoder s Datum
decode = BuiltinData -> Datum
Datum (BuiltinData -> Datum) -> (Data -> BuiltinData) -> Data -> Datum
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Data -> BuiltinData
BuiltinData (Data -> Datum) -> Decoder s Data -> Decoder s Datum
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Haskell.<$> Decoder s Data
forall s. Decoder s Data
forall a s. Serialise a => Decoder s a
decode

-- | 'Redeemer' is a wrapper around 'Data' values that are used as redeemers in transaction inputs.
newtype Redeemer = Redeemer {Redeemer -> BuiltinData
getRedeemer :: BuiltinData}
  deriving stock ((forall x. Redeemer -> Rep Redeemer x)
-> (forall x. Rep Redeemer x -> Redeemer) -> Generic Redeemer
forall x. Rep Redeemer x -> Redeemer
forall x. Redeemer -> Rep Redeemer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Redeemer -> Rep Redeemer x
from :: forall x. Redeemer -> Rep Redeemer x
$cto :: forall x. Rep Redeemer x -> Redeemer
to :: forall x. Rep Redeemer x -> Redeemer
Generic, Int -> Redeemer -> ShowS
[Redeemer] -> ShowS
Redeemer -> String
(Int -> Redeemer -> ShowS)
-> (Redeemer -> String) -> ([Redeemer] -> ShowS) -> Show Redeemer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Redeemer -> ShowS
showsPrec :: Int -> Redeemer -> ShowS
$cshow :: Redeemer -> String
show :: Redeemer -> String
$cshowList :: [Redeemer] -> ShowS
showList :: [Redeemer] -> ShowS
Haskell.Show, Typeable)
  deriving newtype (Redeemer -> Redeemer -> Bool
(Redeemer -> Redeemer -> Bool)
-> (Redeemer -> Redeemer -> Bool) -> Eq Redeemer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Redeemer -> Redeemer -> Bool
== :: Redeemer -> Redeemer -> Bool
$c/= :: Redeemer -> Redeemer -> Bool
/= :: Redeemer -> Redeemer -> Bool
Haskell.Eq, Eq Redeemer
Eq Redeemer =>
(Redeemer -> Redeemer -> Ordering)
-> (Redeemer -> Redeemer -> Bool)
-> (Redeemer -> Redeemer -> Bool)
-> (Redeemer -> Redeemer -> Bool)
-> (Redeemer -> Redeemer -> Bool)
-> (Redeemer -> Redeemer -> Redeemer)
-> (Redeemer -> Redeemer -> Redeemer)
-> Ord Redeemer
Redeemer -> Redeemer -> Bool
Redeemer -> Redeemer -> Ordering
Redeemer -> Redeemer -> Redeemer
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Redeemer -> Redeemer -> Ordering
compare :: Redeemer -> Redeemer -> Ordering
$c< :: Redeemer -> Redeemer -> Bool
< :: Redeemer -> Redeemer -> Bool
$c<= :: Redeemer -> Redeemer -> Bool
<= :: Redeemer -> Redeemer -> Bool
$c> :: Redeemer -> Redeemer -> Bool
> :: Redeemer -> Redeemer -> Bool
$c>= :: Redeemer -> Redeemer -> Bool
>= :: Redeemer -> Redeemer -> Bool
$cmax :: Redeemer -> Redeemer -> Redeemer
max :: Redeemer -> Redeemer -> Redeemer
$cmin :: Redeemer -> Redeemer -> Redeemer
min :: Redeemer -> Redeemer -> Redeemer
Haskell.Ord, Redeemer -> Redeemer -> Bool
(Redeemer -> Redeemer -> Bool) -> Eq Redeemer
forall a. (a -> a -> Bool) -> Eq a
$c== :: Redeemer -> Redeemer -> Bool
== :: Redeemer -> Redeemer -> Bool
Eq, Redeemer -> BuiltinData
(Redeemer -> BuiltinData) -> ToData Redeemer
forall a. (a -> BuiltinData) -> ToData a
$ctoBuiltinData :: Redeemer -> BuiltinData
toBuiltinData :: Redeemer -> BuiltinData
ToData, BuiltinData -> Maybe Redeemer
(BuiltinData -> Maybe Redeemer) -> FromData Redeemer
forall a. (BuiltinData -> Maybe a) -> FromData a
$cfromBuiltinData :: BuiltinData -> Maybe Redeemer
fromBuiltinData :: BuiltinData -> Maybe Redeemer
FromData, BuiltinData -> Redeemer
(BuiltinData -> Redeemer) -> UnsafeFromData Redeemer
forall a. (BuiltinData -> a) -> UnsafeFromData a
$cunsafeFromBuiltinData :: BuiltinData -> Redeemer
unsafeFromBuiltinData :: BuiltinData -> Redeemer
UnsafeFromData, (forall ann. Redeemer -> Doc ann)
-> (forall ann. [Redeemer] -> Doc ann) -> Pretty Redeemer
forall ann. [Redeemer] -> Doc ann
forall ann. Redeemer -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. Redeemer -> Doc ann
pretty :: forall ann. Redeemer -> Doc ann
$cprettyList :: forall ann. [Redeemer] -> Doc ann
prettyList :: forall ann. [Redeemer] -> Doc ann
Pretty)
  deriving anyclass (Redeemer -> ()
(Redeemer -> ()) -> NFData Redeemer
forall a. (a -> ()) -> NFData a
$crnf :: Redeemer -> ()
rnf :: Redeemer -> ()
NFData, DefinitionId
DefinitionId -> HasBlueprintDefinition Redeemer
forall t. DefinitionId -> HasBlueprintDefinition t
$cdefinitionId :: DefinitionId
definitionId :: DefinitionId
HasBlueprintDefinition)

instance HasBlueprintSchema Redeemer referencedTypes where
  schema :: Schema referencedTypes
schema = SchemaInfo -> Schema referencedTypes
forall (referencedTypes :: [*]).
SchemaInfo -> Schema referencedTypes
SchemaBuiltInData SchemaInfo
emptySchemaInfo{title = Just "Redeemer"}

-- See Note [Serialise instances for Datum and Redeemer]
instance Serialise Redeemer where
  encode :: Redeemer -> Encoding
encode (Redeemer (BuiltinData Data
d)) = Data -> Encoding
forall a. Serialise a => a -> Encoding
encode Data
d
  decode :: forall s. Decoder s Redeemer
decode = BuiltinData -> Redeemer
Redeemer (BuiltinData -> Redeemer)
-> (Data -> BuiltinData) -> Data -> Redeemer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Data -> BuiltinData
BuiltinData (Data -> Redeemer) -> Decoder s Data -> Decoder s Redeemer
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Haskell.<$> Decoder s Data
forall s. Decoder s Data
forall a s. Serialise a => Decoder s a
decode

{- | Type representing the /BLAKE2b-224/ hash of a script. 28 bytes.

This is a simple type without any validation, __use with caution__.
You may want to add checks for its invariants.
See the [Shelley ledger specification](https://github.com/IntersectMBO/cardano-ledger/releases/download/cardano-ledger-spec-2023-04-03/shelley-ledger.pdf).
-}
newtype ScriptHash = ScriptHash {ScriptHash -> BuiltinByteString
getScriptHash :: Builtins.BuiltinByteString}
  deriving
    ( -- | from hex encoding
      String -> ScriptHash
(String -> ScriptHash) -> IsString ScriptHash
forall a. (String -> a) -> IsString a
$cfromString :: String -> ScriptHash
fromString :: String -> ScriptHash
IsString
    , -- | using hex encoding
      Int -> ScriptHash -> ShowS
[ScriptHash] -> ShowS
ScriptHash -> String
(Int -> ScriptHash -> ShowS)
-> (ScriptHash -> String)
-> ([ScriptHash] -> ShowS)
-> Show ScriptHash
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScriptHash -> ShowS
showsPrec :: Int -> ScriptHash -> ShowS
$cshow :: ScriptHash -> String
show :: ScriptHash -> String
$cshowList :: [ScriptHash] -> ShowS
showList :: [ScriptHash] -> ShowS
Haskell.Show
    , -- | using hex encoding
      (forall ann. ScriptHash -> Doc ann)
-> (forall ann. [ScriptHash] -> Doc ann) -> Pretty ScriptHash
forall ann. [ScriptHash] -> Doc ann
forall ann. ScriptHash -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. ScriptHash -> Doc ann
pretty :: forall ann. ScriptHash -> Doc ann
$cprettyList :: forall ann. [ScriptHash] -> Doc ann
prettyList :: forall ann. [ScriptHash] -> Doc ann
Pretty
    )
    via LedgerBytes
  deriving stock ((forall x. ScriptHash -> Rep ScriptHash x)
-> (forall x. Rep ScriptHash x -> ScriptHash) -> Generic ScriptHash
forall x. Rep ScriptHash x -> ScriptHash
forall x. ScriptHash -> Rep ScriptHash x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ScriptHash -> Rep ScriptHash x
from :: forall x. ScriptHash -> Rep ScriptHash x
$cto :: forall x. Rep ScriptHash x -> ScriptHash
to :: forall x. Rep ScriptHash x -> ScriptHash
Generic, Typeable)
  deriving newtype (ScriptHash -> ScriptHash -> Bool
(ScriptHash -> ScriptHash -> Bool)
-> (ScriptHash -> ScriptHash -> Bool) -> Eq ScriptHash
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScriptHash -> ScriptHash -> Bool
== :: ScriptHash -> ScriptHash -> Bool
$c/= :: ScriptHash -> ScriptHash -> Bool
/= :: ScriptHash -> ScriptHash -> Bool
Haskell.Eq, Eq ScriptHash
Eq ScriptHash =>
(ScriptHash -> ScriptHash -> Ordering)
-> (ScriptHash -> ScriptHash -> Bool)
-> (ScriptHash -> ScriptHash -> Bool)
-> (ScriptHash -> ScriptHash -> Bool)
-> (ScriptHash -> ScriptHash -> Bool)
-> (ScriptHash -> ScriptHash -> ScriptHash)
-> (ScriptHash -> ScriptHash -> ScriptHash)
-> Ord ScriptHash
ScriptHash -> ScriptHash -> Bool
ScriptHash -> ScriptHash -> Ordering
ScriptHash -> ScriptHash -> ScriptHash
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ScriptHash -> ScriptHash -> Ordering
compare :: ScriptHash -> ScriptHash -> Ordering
$c< :: ScriptHash -> ScriptHash -> Bool
< :: ScriptHash -> ScriptHash -> Bool
$c<= :: ScriptHash -> ScriptHash -> Bool
<= :: ScriptHash -> ScriptHash -> Bool
$c> :: ScriptHash -> ScriptHash -> Bool
> :: ScriptHash -> ScriptHash -> Bool
$c>= :: ScriptHash -> ScriptHash -> Bool
>= :: ScriptHash -> ScriptHash -> Bool
$cmax :: ScriptHash -> ScriptHash -> ScriptHash
max :: ScriptHash -> ScriptHash -> ScriptHash
$cmin :: ScriptHash -> ScriptHash -> ScriptHash
min :: ScriptHash -> ScriptHash -> ScriptHash
Haskell.Ord, ScriptHash -> ScriptHash -> Bool
(ScriptHash -> ScriptHash -> Bool) -> Eq ScriptHash
forall a. (a -> a -> Bool) -> Eq a
$c== :: ScriptHash -> ScriptHash -> Bool
== :: ScriptHash -> ScriptHash -> Bool
Eq, Eq ScriptHash
Eq ScriptHash =>
(ScriptHash -> ScriptHash -> Ordering)
-> (ScriptHash -> ScriptHash -> Bool)
-> (ScriptHash -> ScriptHash -> Bool)
-> (ScriptHash -> ScriptHash -> Bool)
-> (ScriptHash -> ScriptHash -> Bool)
-> (ScriptHash -> ScriptHash -> ScriptHash)
-> (ScriptHash -> ScriptHash -> ScriptHash)
-> Ord ScriptHash
ScriptHash -> ScriptHash -> Bool
ScriptHash -> ScriptHash -> Ordering
ScriptHash -> ScriptHash -> ScriptHash
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ScriptHash -> ScriptHash -> Ordering
compare :: ScriptHash -> ScriptHash -> Ordering
$c< :: ScriptHash -> ScriptHash -> Bool
< :: ScriptHash -> ScriptHash -> Bool
$c<= :: ScriptHash -> ScriptHash -> Bool
<= :: ScriptHash -> ScriptHash -> Bool
$c> :: ScriptHash -> ScriptHash -> Bool
> :: ScriptHash -> ScriptHash -> Bool
$c>= :: ScriptHash -> ScriptHash -> Bool
>= :: ScriptHash -> ScriptHash -> Bool
$cmax :: ScriptHash -> ScriptHash -> ScriptHash
max :: ScriptHash -> ScriptHash -> ScriptHash
$cmin :: ScriptHash -> ScriptHash -> ScriptHash
min :: ScriptHash -> ScriptHash -> ScriptHash
Ord, ScriptHash -> BuiltinData
(ScriptHash -> BuiltinData) -> ToData ScriptHash
forall a. (a -> BuiltinData) -> ToData a
$ctoBuiltinData :: ScriptHash -> BuiltinData
toBuiltinData :: ScriptHash -> BuiltinData
ToData, BuiltinData -> Maybe ScriptHash
(BuiltinData -> Maybe ScriptHash) -> FromData ScriptHash
forall a. (BuiltinData -> Maybe a) -> FromData a
$cfromBuiltinData :: BuiltinData -> Maybe ScriptHash
fromBuiltinData :: BuiltinData -> Maybe ScriptHash
FromData, BuiltinData -> ScriptHash
(BuiltinData -> ScriptHash) -> UnsafeFromData ScriptHash
forall a. (BuiltinData -> a) -> UnsafeFromData a
$cunsafeFromBuiltinData :: BuiltinData -> ScriptHash
unsafeFromBuiltinData :: BuiltinData -> ScriptHash
UnsafeFromData)
  deriving anyclass (ScriptHash -> ()
(ScriptHash -> ()) -> NFData ScriptHash
forall a. (a -> ()) -> NFData a
$crnf :: ScriptHash -> ()
rnf :: ScriptHash -> ()
NFData, DefinitionId
DefinitionId -> HasBlueprintDefinition ScriptHash
forall t. DefinitionId -> HasBlueprintDefinition t
$cdefinitionId :: DefinitionId
definitionId :: DefinitionId
HasBlueprintDefinition)

instance HasBlueprintSchema ScriptHash referencedTypes where
  schema :: Schema referencedTypes
schema = SchemaInfo -> BytesSchema -> Schema referencedTypes
forall (referencedTypes :: [*]).
SchemaInfo -> BytesSchema -> Schema referencedTypes
SchemaBytes SchemaInfo
emptySchemaInfo{title = Just "ScriptHash"} BytesSchema
emptyBytesSchema

{- | Type representing the /BLAKE2b-256/ hash of a datum. 32 bytes.

This is a simple type without any validation, __use with caution__.
You may want to add checks for its invariants.
See the [Shelley ledger specification](https://github.com/IntersectMBO/cardano-ledger/releases/download/cardano-ledger-spec-2023-04-03/shelley-ledger.pdf).
-}
newtype DatumHash = DatumHash Builtins.BuiltinByteString
  deriving
    ( -- | from hex encoding
      String -> DatumHash
(String -> DatumHash) -> IsString DatumHash
forall a. (String -> a) -> IsString a
$cfromString :: String -> DatumHash
fromString :: String -> DatumHash
IsString
    , -- | using hex encoding
      Int -> DatumHash -> ShowS
[DatumHash] -> ShowS
DatumHash -> String
(Int -> DatumHash -> ShowS)
-> (DatumHash -> String)
-> ([DatumHash] -> ShowS)
-> Show DatumHash
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DatumHash -> ShowS
showsPrec :: Int -> DatumHash -> ShowS
$cshow :: DatumHash -> String
show :: DatumHash -> String
$cshowList :: [DatumHash] -> ShowS
showList :: [DatumHash] -> ShowS
Haskell.Show
    , -- | using hex encoding
      (forall ann. DatumHash -> Doc ann)
-> (forall ann. [DatumHash] -> Doc ann) -> Pretty DatumHash
forall ann. [DatumHash] -> Doc ann
forall ann. DatumHash -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. DatumHash -> Doc ann
pretty :: forall ann. DatumHash -> Doc ann
$cprettyList :: forall ann. [DatumHash] -> Doc ann
prettyList :: forall ann. [DatumHash] -> Doc ann
Pretty
    )
    via LedgerBytes
  deriving stock ((forall x. DatumHash -> Rep DatumHash x)
-> (forall x. Rep DatumHash x -> DatumHash) -> Generic DatumHash
forall x. Rep DatumHash x -> DatumHash
forall x. DatumHash -> Rep DatumHash x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DatumHash -> Rep DatumHash x
from :: forall x. DatumHash -> Rep DatumHash x
$cto :: forall x. Rep DatumHash x -> DatumHash
to :: forall x. Rep DatumHash x -> DatumHash
Generic, Typeable)
  deriving newtype (DatumHash -> DatumHash -> Bool
(DatumHash -> DatumHash -> Bool)
-> (DatumHash -> DatumHash -> Bool) -> Eq DatumHash
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DatumHash -> DatumHash -> Bool
== :: DatumHash -> DatumHash -> Bool
$c/= :: DatumHash -> DatumHash -> Bool
/= :: DatumHash -> DatumHash -> Bool
Haskell.Eq, Eq DatumHash
Eq DatumHash =>
(DatumHash -> DatumHash -> Ordering)
-> (DatumHash -> DatumHash -> Bool)
-> (DatumHash -> DatumHash -> Bool)
-> (DatumHash -> DatumHash -> Bool)
-> (DatumHash -> DatumHash -> Bool)
-> (DatumHash -> DatumHash -> DatumHash)
-> (DatumHash -> DatumHash -> DatumHash)
-> Ord DatumHash
DatumHash -> DatumHash -> Bool
DatumHash -> DatumHash -> Ordering
DatumHash -> DatumHash -> DatumHash
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: DatumHash -> DatumHash -> Ordering
compare :: DatumHash -> DatumHash -> Ordering
$c< :: DatumHash -> DatumHash -> Bool
< :: DatumHash -> DatumHash -> Bool
$c<= :: DatumHash -> DatumHash -> Bool
<= :: DatumHash -> DatumHash -> Bool
$c> :: DatumHash -> DatumHash -> Bool
> :: DatumHash -> DatumHash -> Bool
$c>= :: DatumHash -> DatumHash -> Bool
>= :: DatumHash -> DatumHash -> Bool
$cmax :: DatumHash -> DatumHash -> DatumHash
max :: DatumHash -> DatumHash -> DatumHash
$cmin :: DatumHash -> DatumHash -> DatumHash
min :: DatumHash -> DatumHash -> DatumHash
Haskell.Ord, DatumHash -> DatumHash -> Bool
(DatumHash -> DatumHash -> Bool) -> Eq DatumHash
forall a. (a -> a -> Bool) -> Eq a
$c== :: DatumHash -> DatumHash -> Bool
== :: DatumHash -> DatumHash -> Bool
Eq, Eq DatumHash
Eq DatumHash =>
(DatumHash -> DatumHash -> Ordering)
-> (DatumHash -> DatumHash -> Bool)
-> (DatumHash -> DatumHash -> Bool)
-> (DatumHash -> DatumHash -> Bool)
-> (DatumHash -> DatumHash -> Bool)
-> (DatumHash -> DatumHash -> DatumHash)
-> (DatumHash -> DatumHash -> DatumHash)
-> Ord DatumHash
DatumHash -> DatumHash -> Bool
DatumHash -> DatumHash -> Ordering
DatumHash -> DatumHash -> DatumHash
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: DatumHash -> DatumHash -> Ordering
compare :: DatumHash -> DatumHash -> Ordering
$c< :: DatumHash -> DatumHash -> Bool
< :: DatumHash -> DatumHash -> Bool
$c<= :: DatumHash -> DatumHash -> Bool
<= :: DatumHash -> DatumHash -> Bool
$c> :: DatumHash -> DatumHash -> Bool
> :: DatumHash -> DatumHash -> Bool
$c>= :: DatumHash -> DatumHash -> Bool
>= :: DatumHash -> DatumHash -> Bool
$cmax :: DatumHash -> DatumHash -> DatumHash
max :: DatumHash -> DatumHash -> DatumHash
$cmin :: DatumHash -> DatumHash -> DatumHash
min :: DatumHash -> DatumHash -> DatumHash
Ord, DatumHash -> BuiltinData
(DatumHash -> BuiltinData) -> ToData DatumHash
forall a. (a -> BuiltinData) -> ToData a
$ctoBuiltinData :: DatumHash -> BuiltinData
toBuiltinData :: DatumHash -> BuiltinData
ToData, BuiltinData -> Maybe DatumHash
(BuiltinData -> Maybe DatumHash) -> FromData DatumHash
forall a. (BuiltinData -> Maybe a) -> FromData a
$cfromBuiltinData :: BuiltinData -> Maybe DatumHash
fromBuiltinData :: BuiltinData -> Maybe DatumHash
FromData, BuiltinData -> DatumHash
(BuiltinData -> DatumHash) -> UnsafeFromData DatumHash
forall a. (BuiltinData -> a) -> UnsafeFromData a
$cunsafeFromBuiltinData :: BuiltinData -> DatumHash
unsafeFromBuiltinData :: BuiltinData -> DatumHash
UnsafeFromData)
  deriving anyclass (DatumHash -> ()
(DatumHash -> ()) -> NFData DatumHash
forall a. (a -> ()) -> NFData a
$crnf :: DatumHash -> ()
rnf :: DatumHash -> ()
NFData, DefinitionId
DefinitionId -> HasBlueprintDefinition DatumHash
forall t. DefinitionId -> HasBlueprintDefinition t
$cdefinitionId :: DefinitionId
definitionId :: DefinitionId
HasBlueprintDefinition)

instance HasBlueprintSchema DatumHash referencedTypes where
  schema :: Schema referencedTypes
schema = SchemaInfo -> BytesSchema -> Schema referencedTypes
forall (referencedTypes :: [*]).
SchemaInfo -> BytesSchema -> Schema referencedTypes
SchemaBytes SchemaInfo
emptySchemaInfo{title = Just "DatumHash"} BytesSchema
emptyBytesSchema

{- | Type representing the /BLAKE2b-256/ hash of a redeemer. 32 bytes.

This is a simple type without any validation, __use with caution__.
You may want to add checks for its invariants.
See the [Shelley ledger specification](https://github.com/IntersectMBO/cardano-ledger/releases/download/cardano-ledger-spec-2023-04-03/shelley-ledger.pdf).
-}
newtype RedeemerHash = RedeemerHash Builtins.BuiltinByteString
  deriving
    ( -- | from hex encoding
      String -> RedeemerHash
(String -> RedeemerHash) -> IsString RedeemerHash
forall a. (String -> a) -> IsString a
$cfromString :: String -> RedeemerHash
fromString :: String -> RedeemerHash
IsString
    , -- | using hex encoding
      Int -> RedeemerHash -> ShowS
[RedeemerHash] -> ShowS
RedeemerHash -> String
(Int -> RedeemerHash -> ShowS)
-> (RedeemerHash -> String)
-> ([RedeemerHash] -> ShowS)
-> Show RedeemerHash
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RedeemerHash -> ShowS
showsPrec :: Int -> RedeemerHash -> ShowS
$cshow :: RedeemerHash -> String
show :: RedeemerHash -> String
$cshowList :: [RedeemerHash] -> ShowS
showList :: [RedeemerHash] -> ShowS
Haskell.Show
    , -- | using hex encoding
      (forall ann. RedeemerHash -> Doc ann)
-> (forall ann. [RedeemerHash] -> Doc ann) -> Pretty RedeemerHash
forall ann. [RedeemerHash] -> Doc ann
forall ann. RedeemerHash -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. RedeemerHash -> Doc ann
pretty :: forall ann. RedeemerHash -> Doc ann
$cprettyList :: forall ann. [RedeemerHash] -> Doc ann
prettyList :: forall ann. [RedeemerHash] -> Doc ann
Pretty
    )
    via LedgerBytes
  deriving stock ((forall x. RedeemerHash -> Rep RedeemerHash x)
-> (forall x. Rep RedeemerHash x -> RedeemerHash)
-> Generic RedeemerHash
forall x. Rep RedeemerHash x -> RedeemerHash
forall x. RedeemerHash -> Rep RedeemerHash x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RedeemerHash -> Rep RedeemerHash x
from :: forall x. RedeemerHash -> Rep RedeemerHash x
$cto :: forall x. Rep RedeemerHash x -> RedeemerHash
to :: forall x. Rep RedeemerHash x -> RedeemerHash
Generic, Typeable)
  deriving newtype (RedeemerHash -> RedeemerHash -> Bool
(RedeemerHash -> RedeemerHash -> Bool)
-> (RedeemerHash -> RedeemerHash -> Bool) -> Eq RedeemerHash
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RedeemerHash -> RedeemerHash -> Bool
== :: RedeemerHash -> RedeemerHash -> Bool
$c/= :: RedeemerHash -> RedeemerHash -> Bool
/= :: RedeemerHash -> RedeemerHash -> Bool
Haskell.Eq, Eq RedeemerHash
Eq RedeemerHash =>
(RedeemerHash -> RedeemerHash -> Ordering)
-> (RedeemerHash -> RedeemerHash -> Bool)
-> (RedeemerHash -> RedeemerHash -> Bool)
-> (RedeemerHash -> RedeemerHash -> Bool)
-> (RedeemerHash -> RedeemerHash -> Bool)
-> (RedeemerHash -> RedeemerHash -> RedeemerHash)
-> (RedeemerHash -> RedeemerHash -> RedeemerHash)
-> Ord RedeemerHash
RedeemerHash -> RedeemerHash -> Bool
RedeemerHash -> RedeemerHash -> Ordering
RedeemerHash -> RedeemerHash -> RedeemerHash
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: RedeemerHash -> RedeemerHash -> Ordering
compare :: RedeemerHash -> RedeemerHash -> Ordering
$c< :: RedeemerHash -> RedeemerHash -> Bool
< :: RedeemerHash -> RedeemerHash -> Bool
$c<= :: RedeemerHash -> RedeemerHash -> Bool
<= :: RedeemerHash -> RedeemerHash -> Bool
$c> :: RedeemerHash -> RedeemerHash -> Bool
> :: RedeemerHash -> RedeemerHash -> Bool
$c>= :: RedeemerHash -> RedeemerHash -> Bool
>= :: RedeemerHash -> RedeemerHash -> Bool
$cmax :: RedeemerHash -> RedeemerHash -> RedeemerHash
max :: RedeemerHash -> RedeemerHash -> RedeemerHash
$cmin :: RedeemerHash -> RedeemerHash -> RedeemerHash
min :: RedeemerHash -> RedeemerHash -> RedeemerHash
Haskell.Ord, RedeemerHash -> RedeemerHash -> Bool
(RedeemerHash -> RedeemerHash -> Bool) -> Eq RedeemerHash
forall a. (a -> a -> Bool) -> Eq a
$c== :: RedeemerHash -> RedeemerHash -> Bool
== :: RedeemerHash -> RedeemerHash -> Bool
Eq, Eq RedeemerHash
Eq RedeemerHash =>
(RedeemerHash -> RedeemerHash -> Ordering)
-> (RedeemerHash -> RedeemerHash -> Bool)
-> (RedeemerHash -> RedeemerHash -> Bool)
-> (RedeemerHash -> RedeemerHash -> Bool)
-> (RedeemerHash -> RedeemerHash -> Bool)
-> (RedeemerHash -> RedeemerHash -> RedeemerHash)
-> (RedeemerHash -> RedeemerHash -> RedeemerHash)
-> Ord RedeemerHash
RedeemerHash -> RedeemerHash -> Bool
RedeemerHash -> RedeemerHash -> Ordering
RedeemerHash -> RedeemerHash -> RedeemerHash
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: RedeemerHash -> RedeemerHash -> Ordering
compare :: RedeemerHash -> RedeemerHash -> Ordering
$c< :: RedeemerHash -> RedeemerHash -> Bool
< :: RedeemerHash -> RedeemerHash -> Bool
$c<= :: RedeemerHash -> RedeemerHash -> Bool
<= :: RedeemerHash -> RedeemerHash -> Bool
$c> :: RedeemerHash -> RedeemerHash -> Bool
> :: RedeemerHash -> RedeemerHash -> Bool
$c>= :: RedeemerHash -> RedeemerHash -> Bool
>= :: RedeemerHash -> RedeemerHash -> Bool
$cmax :: RedeemerHash -> RedeemerHash -> RedeemerHash
max :: RedeemerHash -> RedeemerHash -> RedeemerHash
$cmin :: RedeemerHash -> RedeemerHash -> RedeemerHash
min :: RedeemerHash -> RedeemerHash -> RedeemerHash
Ord, RedeemerHash -> BuiltinData
(RedeemerHash -> BuiltinData) -> ToData RedeemerHash
forall a. (a -> BuiltinData) -> ToData a
$ctoBuiltinData :: RedeemerHash -> BuiltinData
toBuiltinData :: RedeemerHash -> BuiltinData
ToData, BuiltinData -> Maybe RedeemerHash
(BuiltinData -> Maybe RedeemerHash) -> FromData RedeemerHash
forall a. (BuiltinData -> Maybe a) -> FromData a
$cfromBuiltinData :: BuiltinData -> Maybe RedeemerHash
fromBuiltinData :: BuiltinData -> Maybe RedeemerHash
FromData, BuiltinData -> RedeemerHash
(BuiltinData -> RedeemerHash) -> UnsafeFromData RedeemerHash
forall a. (BuiltinData -> a) -> UnsafeFromData a
$cunsafeFromBuiltinData :: BuiltinData -> RedeemerHash
unsafeFromBuiltinData :: BuiltinData -> RedeemerHash
UnsafeFromData)
  deriving anyclass (RedeemerHash -> ()
(RedeemerHash -> ()) -> NFData RedeemerHash
forall a. (a -> ()) -> NFData a
$crnf :: RedeemerHash -> ()
rnf :: RedeemerHash -> ()
NFData, DefinitionId
DefinitionId -> HasBlueprintDefinition RedeemerHash
forall t. DefinitionId -> HasBlueprintDefinition t
$cdefinitionId :: DefinitionId
definitionId :: DefinitionId
HasBlueprintDefinition)

instance HasBlueprintSchema RedeemerHash referencedTypes where
  schema :: Schema referencedTypes
schema = SchemaInfo -> BytesSchema -> Schema referencedTypes
forall (referencedTypes :: [*]).
SchemaInfo -> BytesSchema -> Schema referencedTypes
SchemaBytes SchemaInfo
emptySchemaInfo{title = Just "RedeemerHash"} BytesSchema
emptyBytesSchema

{- | Information about the state of the blockchain and about the transaction
  that is currently being validated, represented as a value in 'Data'.
-}
newtype Context = Context BuiltinData
  deriving newtype ((forall ann. Context -> Doc ann)
-> (forall ann. [Context] -> Doc ann) -> Pretty Context
forall ann. [Context] -> Doc ann
forall ann. Context -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. Context -> Doc ann
pretty :: forall ann. Context -> Doc ann
$cprettyList :: forall ann. [Context] -> Doc ann
prettyList :: forall ann. [Context] -> Doc ann
Pretty, Int -> Context -> ShowS
[Context] -> ShowS
Context -> String
(Int -> Context -> ShowS)
-> (Context -> String) -> ([Context] -> ShowS) -> Show Context
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Context -> ShowS
showsPrec :: Int -> Context -> ShowS
$cshow :: Context -> String
show :: Context -> String
$cshowList :: [Context] -> ShowS
showList :: [Context] -> ShowS
Haskell.Show)

----------------------------------------------------------------------------------------------------
-- TH Splices --------------------------------------------------------------------------------------

makeLift ''ScriptHash
makeLift ''DatumHash
makeLift ''RedeemerHash
makeLift ''Datum
makeLift ''Redeemer

deriveShow ''ScriptHash
deriveShow ''DatumHash
deriveShow ''RedeemerHash
deriveShow ''Datum
deriveShow ''Redeemer