{-# LANGUAGE DataKinds           #-}
{-# LANGUAGE DeriveAnyClass      #-}
{-# LANGUAGE DeriveGeneric       #-}
{-# LANGUAGE DerivingVia         #-}
{-# LANGUAGE FlexibleContexts    #-}
{-# LANGUAGE FlexibleInstances   #-}
{-# LANGUAGE LambdaCase          #-}
{-# LANGUAGE NoImplicitPrelude   #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE PatternSynonyms     #-}
{-# LANGUAGE RankNTypes          #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell     #-}
{-# LANGUAGE TypeApplications    #-}
{-# LANGUAGE TypeOperators       #-}
{-# LANGUAGE ViewPatterns        #-}

{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -fno-specialise #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}

-- | Functions for working with scripts on the ledger.
module Plutus.V1.Ledger.Scripts(
    -- * Scripts
    Script (..),
    scriptSize,
    fromCompiledCode,
    ScriptError (..),
    evaluateScript,
    runScript,
    runMintingPolicyScript,
    runStakeValidatorScript,
    applyValidator,
    applyMintingPolicyScript,
    applyStakeValidatorScript,
    applyArguments,
    -- * Script wrappers
    mkValidatorScript,
    Validator (..),
    unValidatorScript,
    Redeemer(..),
    Datum(..),
    mkMintingPolicyScript,
    MintingPolicy (..),
    unMintingPolicyScript,
    mkStakeValidatorScript,
    StakeValidator (..),
    unStakeValidatorScript,
    Context(..),
    -- * Hashes
    DatumHash(..),
    RedeemerHash(..),
    ScriptHash(..),
    ValidatorHash(..),
    MintingPolicyHash (..),
    StakeValidatorHash (..),
    -- * Example scripts
    unitRedeemer,
    unitDatum,
    ) where

import Prelude qualified as Haskell

import Codec.CBOR.Decoding (decodeBytes)
import Codec.Serialise (Serialise, decode, encode, serialise)
import Control.DeepSeq (NFData)
import Control.Monad.Except (MonadError, throwError)
import Data.Aeson (FromJSON, FromJSONKey, ToJSON, ToJSONKey)
import Data.Aeson qualified as JSON
import Data.Aeson.Extras qualified as JSON
import Data.ByteArray qualified as BA
import Data.ByteString.Lazy qualified as BSL
import Data.Hashable (Hashable)
import Data.String
import Data.Text (Text)
import Flat qualified
import GHC.Generics (Generic)
import Plutus.V1.Ledger.Bytes (LedgerBytes (..))
import Plutus.V1.Ledger.Orphans ()
import PlutusCore qualified as PLC
import PlutusCore.Data qualified as PLC
import PlutusCore.Evaluation.Machine.ExBudget qualified as PLC
import PlutusCore.Evaluation.Machine.Exception (ErrorWithCause (..), EvaluationError (..))
import PlutusCore.MkPlc qualified as PLC
import PlutusTx (CompiledCode, FromData (..), ToData (..), UnsafeFromData (..), getPlc, makeLift)
import PlutusTx.Builtins as Builtins
import PlutusTx.Builtins.Internal as BI
import PlutusTx.Prelude
import Prettyprinter
import Prettyprinter.Extras
import UntypedPlutusCore qualified as UPLC
import UntypedPlutusCore.Check.Scope qualified as UPLC
import UntypedPlutusCore.Evaluation.Machine.Cek qualified as UPLC

-- | A script on the chain. This is an opaque type as far as the chain is concerned.
newtype Script = Script { Script -> Program DeBruijn DefaultUni DefaultFun ()
unScript :: UPLC.Program UPLC.DeBruijn PLC.DefaultUni PLC.DefaultFun () }
  deriving stock (forall x. Script -> Rep Script x)
-> (forall x. Rep Script x -> Script) -> Generic Script
forall x. Rep Script x -> Script
forall x. Script -> Rep Script x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Script x -> Script
$cfrom :: forall x. Script -> Rep Script x
Generic
  -- See Note [Using Flat inside CBOR instance of Script]
  -- Important to go via 'WithSizeLimits' to ensure we enforce the size limits for constants
  deriving Decoder s Script
Decoder s [Script]
[Script] -> Encoding
Script -> Encoding
(Script -> Encoding)
-> (forall s. Decoder s Script)
-> ([Script] -> Encoding)
-> (forall s. Decoder s [Script])
-> Serialise Script
forall s. Decoder s [Script]
forall s. Decoder s Script
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: Decoder s [Script]
$cdecodeList :: forall s. Decoder s [Script]
encodeList :: [Script] -> Encoding
$cencodeList :: [Script] -> Encoding
decode :: Decoder s Script
$cdecode :: forall s. Decoder s Script
encode :: Script -> Encoding
$cencode :: Script -> Encoding
Serialise via (SerialiseViaFlat (UPLC.WithSizeLimits 64 (UPLC.Program UPLC.DeBruijn PLC.DefaultUni PLC.DefaultFun ())))

{-| Note [Using Flat inside CBOR instance of Script]
`plutus-ledger` uses CBOR for data serialisation and `plutus-core` uses Flat. The
choice to use Flat was made to have a more efficient (most wins are in uncompressed
size) data serialisation format and use less space on-chain.

To make `plutus-ledger` work with scripts serialised with Flat, and keep the CBOR
format otherwise we have defined a Serialise instance for Script, which is a wrapper
over Programs serialised with Flat. The instance will see programs as an opaque
ByteString, which is the result of encoding programs using Flat.

Because Flat is not self-describing and it gets used in the encoding of Programs,
data structures that include scripts (for example, transactions) no-longer benefit
for CBOR's ability to self-describe it's format.
-}

-- | Newtype for to provide 'Serialise' instances for types with a 'Flat' instance that
-- just encodes the flat-serialized value as a CBOR bytestring
newtype SerialiseViaFlat a = SerialiseViaFlat a
instance Flat.Flat a => Serialise (SerialiseViaFlat a) where
  encode :: SerialiseViaFlat a -> Encoding
encode (SerialiseViaFlat a
a) = ByteString -> Encoding
forall a. Serialise a => a -> Encoding
encode (ByteString -> Encoding) -> ByteString -> Encoding
forall a b. (a -> b) -> a -> b
$ a -> ByteString
forall a. Flat a => a -> ByteString
Flat.flat a
a
  decode :: Decoder s (SerialiseViaFlat a)
decode = do
    ByteString
bs <- Decoder s ByteString
forall s. Decoder s ByteString
decodeBytes
    case ByteString -> Decoded a
forall a b. (Flat a, AsByteString b) => b -> Decoded a
Flat.unflat ByteString
bs of
      Left  DecodeException
err -> String -> Decoder s (SerialiseViaFlat a)
forall (m :: * -> *) a. MonadFail m => String -> m a
Haskell.fail (DecodeException -> String
forall a. Show a => a -> String
Haskell.show DecodeException
err)
      Right a
v   -> SerialiseViaFlat a -> Decoder s (SerialiseViaFlat a)
forall (m :: * -> *) a. Monad m => a -> m a
Haskell.return (a -> SerialiseViaFlat a
forall a. a -> SerialiseViaFlat a
SerialiseViaFlat a
v)

{- Note [Eq and Ord for Scripts]
We need `Eq` and `Ord` instances for `Script`s mostly so we can put them in `Set`s.
However, the `Eq` instance for `Program`s is *alpha-equivalence*, and we don't
have a compatible `Ord` instance, nor is it easy to derive one.

So we piggyback off a different representation. In this instance we have two
options:
- Use the serialized form
- Use a hash
The problem with the latter is that we don't want to add a derived `Hashable` instance
for `Program`s that's not compatible with the `Eq` instance. We *could* add a derived
instance for `Program`s with de Bruijn indices, since in that case the derived `Eq`
coincides with alpha-equivalence. However, this might be faster.

For the moment we use the serialized form. We used to store the serialized form directly
in `Script`, but that led to a lot of deserializing and reserializing in `applyProgram`.
Here we have to serialize when we do `Eq` or `Ord` operations, but this happens comparatively
infrequently (I believe).
-}
instance Haskell.Eq Script where
    Script
a == :: Script -> Script -> Bool
== Script
b = ByteString -> BuiltinByteString
forall a arep. ToBuiltin a arep => a -> arep
Builtins.toBuiltin (ByteString -> ByteString
BSL.toStrict (Script -> ByteString
forall a. Serialise a => a -> ByteString
serialise Script
a)) BuiltinByteString -> BuiltinByteString -> Bool
forall a. Eq a => a -> a -> Bool
== ByteString -> BuiltinByteString
forall a arep. ToBuiltin a arep => a -> arep
Builtins.toBuiltin (ByteString -> ByteString
BSL.toStrict (Script -> ByteString
forall a. Serialise a => a -> ByteString
serialise Script
b))

instance Haskell.Ord Script where
    Script
a compare :: Script -> Script -> Ordering
`compare` Script
b = ByteString -> BuiltinByteString
forall a arep. ToBuiltin a arep => a -> arep
Builtins.toBuiltin (ByteString -> ByteString
BSL.toStrict (Script -> ByteString
forall a. Serialise a => a -> ByteString
serialise Script
a)) BuiltinByteString -> BuiltinByteString -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` ByteString -> BuiltinByteString
forall a arep. ToBuiltin a arep => a -> arep
Builtins.toBuiltin (ByteString -> ByteString
BSL.toStrict (Script -> ByteString
forall a. Serialise a => a -> ByteString
serialise Script
b))

instance Haskell.Show Script where
    showsPrec :: Int -> Script -> ShowS
showsPrec Int
_ Script
_ = String -> ShowS
Haskell.showString String
"<Script>"

instance NFData Script

-- | The size of a 'Script'. No particular interpretation is given to this, other than that it is
-- proportional to the serialized size of the script.
scriptSize :: Script -> Integer
scriptSize :: Script -> Integer
scriptSize (Script Program DeBruijn DefaultUni DefaultFun ()
s) = Program DeBruijn DefaultUni DefaultFun () -> Integer
forall name (uni :: * -> *) fun ann.
Program name uni fun ann -> Integer
UPLC.programSize Program DeBruijn DefaultUni DefaultFun ()
s

-- See Note [Normalized types in Scripts]
-- | Turn a 'CompiledCode' (usually produced by 'compile') into a 'Script' for use with this package.
fromCompiledCode :: CompiledCode a -> Script
fromCompiledCode :: CompiledCode a -> Script
fromCompiledCode = Program NamedDeBruijn DefaultUni DefaultFun () -> Script
fromPlc (Program NamedDeBruijn DefaultUni DefaultFun () -> Script)
-> (CompiledCode a
    -> Program NamedDeBruijn DefaultUni DefaultFun ())
-> CompiledCode a
-> Script
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CompiledCode a -> Program NamedDeBruijn DefaultUni DefaultFun ()
forall (uni :: * -> *) fun a.
(Closed uni, Everywhere uni Flat, Flat fun,
 Everywhere uni PrettyConst, GShow uni, Pretty fun) =>
CompiledCodeIn uni fun a -> Program NamedDeBruijn uni fun ()
getPlc

fromPlc :: UPLC.Program UPLC.NamedDeBruijn PLC.DefaultUni PLC.DefaultFun () -> Script
fromPlc :: Program NamedDeBruijn DefaultUni DefaultFun () -> Script
fromPlc (UPLC.Program ()
a Version ()
v Term NamedDeBruijn DefaultUni DefaultFun ()
t) =
    let nameless :: Term DeBruijn DefaultUni DefaultFun ()
nameless = (NamedDeBruijn -> DeBruijn)
-> Term NamedDeBruijn DefaultUni DefaultFun ()
-> Term DeBruijn DefaultUni DefaultFun ()
forall name name' (uni :: * -> *) fun ann.
(name -> name') -> Term name uni fun ann -> Term name' uni fun ann
UPLC.termMapNames NamedDeBruijn -> DeBruijn
UPLC.unNameDeBruijn Term NamedDeBruijn DefaultUni DefaultFun ()
t
    in Program DeBruijn DefaultUni DefaultFun () -> Script
Script (Program DeBruijn DefaultUni DefaultFun () -> Script)
-> Program DeBruijn DefaultUni DefaultFun () -> Script
forall a b. (a -> b) -> a -> b
$ ()
-> Version ()
-> Term DeBruijn DefaultUni DefaultFun ()
-> Program DeBruijn DefaultUni DefaultFun ()
forall name (uni :: * -> *) fun ann.
ann
-> Version ann -> Term name uni fun ann -> Program name uni fun ann
UPLC.Program ()
a Version ()
v Term DeBruijn DefaultUni DefaultFun ()
nameless

data ScriptError =
    EvaluationError [Text] Haskell.String -- ^ Expected behavior of the engine (e.g. user-provided error)
    | EvaluationException Haskell.String Haskell.String -- ^ Unexpected behavior of the engine (a bug)
    deriving (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
showList :: [ScriptError] -> ShowS
$cshowList :: [ScriptError] -> ShowS
show :: ScriptError -> String
$cshow :: ScriptError -> String
showsPrec :: Int -> ScriptError -> ShowS
$cshowsPrec :: Int -> 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
/= :: ScriptError -> ScriptError -> Bool
$c/= :: ScriptError -> ScriptError -> Bool
== :: ScriptError -> ScriptError -> Bool
$c== :: 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
$cto :: forall x. Rep ScriptError x -> ScriptError
$cfrom :: forall x. ScriptError -> Rep ScriptError x
Generic, ScriptError -> ()
(ScriptError -> ()) -> NFData ScriptError
forall a. (a -> ()) -> NFData a
rnf :: ScriptError -> ()
$crnf :: ScriptError -> ()
NFData)
    deriving anyclass ([ScriptError] -> Encoding
[ScriptError] -> Value
ScriptError -> Encoding
ScriptError -> Value
(ScriptError -> Value)
-> (ScriptError -> Encoding)
-> ([ScriptError] -> Value)
-> ([ScriptError] -> Encoding)
-> ToJSON ScriptError
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ScriptError] -> Encoding
$ctoEncodingList :: [ScriptError] -> Encoding
toJSONList :: [ScriptError] -> Value
$ctoJSONList :: [ScriptError] -> Value
toEncoding :: ScriptError -> Encoding
$ctoEncoding :: ScriptError -> Encoding
toJSON :: ScriptError -> Value
$ctoJSON :: ScriptError -> Value
ToJSON, Value -> Parser [ScriptError]
Value -> Parser ScriptError
(Value -> Parser ScriptError)
-> (Value -> Parser [ScriptError]) -> FromJSON ScriptError
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ScriptError]
$cparseJSONList :: Value -> Parser [ScriptError]
parseJSON :: Value -> Parser ScriptError
$cparseJSON :: Value -> Parser ScriptError
FromJSON)

applyArguments :: Script -> [PLC.Data] -> Script
applyArguments :: Script -> [Data] -> Script
applyArguments (Script (UPLC.Program ()
a Version ()
v Term DeBruijn DefaultUni DefaultFun ()
t)) [Data]
args =
    let termArgs :: [Term DeBruijn DefaultUni DefaultFun ()]
termArgs = (Data -> Term DeBruijn DefaultUni DefaultFun ())
-> [Data] -> [Term DeBruijn DefaultUni DefaultFun ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Haskell.fmap (() -> Data -> Term DeBruijn DefaultUni DefaultFun ()
forall a (uni :: * -> *) fun (term :: * -> *) tyname name ann.
(TermLike term tyname name uni fun, Includes uni a) =>
ann -> a -> term ann
PLC.mkConstant ()) [Data]
args
        applied :: Term DeBruijn DefaultUni DefaultFun ()
applied = ()
-> Term DeBruijn DefaultUni DefaultFun ()
-> [Term DeBruijn DefaultUni DefaultFun ()]
-> Term DeBruijn DefaultUni DefaultFun ()
forall (term :: * -> *) tyname name (uni :: * -> *) fun ann.
TermLike term tyname name uni fun =>
ann -> term ann -> [term ann] -> term ann
PLC.mkIterApp () Term DeBruijn DefaultUni DefaultFun ()
t [Term DeBruijn DefaultUni DefaultFun ()]
termArgs
    in Program DeBruijn DefaultUni DefaultFun () -> Script
Script (()
-> Version ()
-> Term DeBruijn DefaultUni DefaultFun ()
-> Program DeBruijn DefaultUni DefaultFun ()
forall name (uni :: * -> *) fun ann.
ann
-> Version ann -> Term name uni fun ann -> Program name uni fun ann
UPLC.Program ()
a Version ()
v Term DeBruijn DefaultUni DefaultFun ()
applied)

-- | Evaluate a script, returning the trace log.
evaluateScript :: forall m . (MonadError ScriptError m) => Script -> m (PLC.ExBudget, [Text])
evaluateScript :: Script -> m (ExBudget, [Text])
evaluateScript Script
s =
    let namedT :: Term NamedDeBruijn DefaultUni DefaultFun ()
namedT = (DeBruijn -> NamedDeBruijn)
-> Term DeBruijn DefaultUni DefaultFun ()
-> Term NamedDeBruijn DefaultUni DefaultFun ()
forall name name' (uni :: * -> *) fun ann.
(name -> name') -> Term name uni fun ann -> Term name' uni fun ann
UPLC.termMapNames DeBruijn -> NamedDeBruijn
UPLC.fakeNameDeBruijn (Term DeBruijn DefaultUni DefaultFun ()
 -> Term NamedDeBruijn DefaultUni DefaultFun ())
-> Term DeBruijn DefaultUni DefaultFun ()
-> Term NamedDeBruijn DefaultUni DefaultFun ()
forall a b. (a -> b) -> a -> b
$ Program DeBruijn DefaultUni DefaultFun ()
-> Term DeBruijn DefaultUni DefaultFun ()
forall name (uni :: * -> *) fun ann.
Program name uni fun ann -> Term name uni fun ann
UPLC._progTerm (Program DeBruijn DefaultUni DefaultFun ()
 -> Term DeBruijn DefaultUni DefaultFun ())
-> Program DeBruijn DefaultUni DefaultFun ()
-> Term DeBruijn DefaultUni DefaultFun ()
forall a b. (a -> b) -> a -> b
$ Script -> Program DeBruijn DefaultUni DefaultFun ()
unScript Script
s
    in case Term NamedDeBruijn DefaultUni DefaultFun ()
-> Either FreeVariableError ()
forall e (m :: * -> *) name (uni :: * -> *) fun a.
(HasIndex name, MonadError e m, AsFreeVariableError e) =>
Term name uni fun a -> m ()
UPLC.checkScope @UPLC.FreeVariableError Term NamedDeBruijn DefaultUni DefaultFun ()
namedT of
        Left FreeVariableError
fvError -> ScriptError -> m (ExBudget, [Text])
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (ScriptError -> m (ExBudget, [Text]))
-> ScriptError -> m (ExBudget, [Text])
forall a b. (a -> b) -> a -> b
$ [Text] -> String -> ScriptError
EvaluationError [] (String
"FreeVariableFailure of" String -> ShowS
forall a. [a] -> [a] -> [a]
++ FreeVariableError -> String
forall a. Show a => a -> String
Haskell.show FreeVariableError
fvError)
        Either FreeVariableError ()
_ -> let (Either
  (CekEvaluationException NamedDeBruijn DefaultUni DefaultFun)
  (Term NamedDeBruijn DefaultUni DefaultFun ())
result, UPLC.TallyingSt CekExTally DefaultFun
_ ExBudget
budget, [Text]
logOut) = MachineParameters CekMachineCosts CekValue DefaultUni DefaultFun
-> ExBudgetMode (TallyingSt DefaultFun) DefaultUni DefaultFun
-> EmitterMode DefaultUni DefaultFun
-> Term NamedDeBruijn DefaultUni DefaultFun ()
-> (Either
      (CekEvaluationException NamedDeBruijn DefaultUni DefaultFun)
      (Term NamedDeBruijn DefaultUni DefaultFun ()),
    TallyingSt DefaultFun, [Text])
forall (uni :: * -> *) fun cost.
(Everywhere uni ExMemoryUsage, Ix fun, PrettyUni uni fun) =>
MachineParameters CekMachineCosts CekValue uni fun
-> ExBudgetMode cost uni fun
-> EmitterMode uni fun
-> Term NamedDeBruijn uni fun ()
-> (Either
      (CekEvaluationException NamedDeBruijn uni fun)
      (Term NamedDeBruijn uni fun ()),
    cost, [Text])
UPLC.runCekDeBruijn MachineParameters CekMachineCosts CekValue DefaultUni DefaultFun
PLC.defaultCekParameters ExBudgetMode (TallyingSt DefaultFun) DefaultUni DefaultFun
forall fun (uni :: * -> *).
(Eq fun, Hashable fun) =>
ExBudgetMode (TallyingSt fun) uni fun
UPLC.tallying EmitterMode DefaultUni DefaultFun
forall (uni :: * -> *) fun. EmitterMode uni fun
UPLC.logEmitter Term NamedDeBruijn DefaultUni DefaultFun ()
namedT
            in case Either
  (CekEvaluationException NamedDeBruijn DefaultUni DefaultFun)
  (Term NamedDeBruijn DefaultUni DefaultFun ())
result of
                 Right Term NamedDeBruijn DefaultUni DefaultFun ()
_ -> (ExBudget, [Text]) -> m (ExBudget, [Text])
forall (f :: * -> *) a. Applicative f => a -> f a
Haskell.pure (ExBudget
budget, [Text]
logOut)
                 Left errWithCause :: CekEvaluationException NamedDeBruijn DefaultUni DefaultFun
errWithCause@(ErrorWithCause EvaluationError CekUserError (MachineError DefaultFun)
err Maybe (Term NamedDeBruijn DefaultUni DefaultFun ())
cause) -> ScriptError -> m (ExBudget, [Text])
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (ScriptError -> m (ExBudget, [Text]))
-> ScriptError -> m (ExBudget, [Text])
forall a b. (a -> b) -> a -> b
$ case EvaluationError CekUserError (MachineError DefaultFun)
err of
                     InternalEvaluationError MachineError DefaultFun
internalEvalError -> String -> String -> ScriptError
EvaluationException (CekEvaluationException NamedDeBruijn DefaultUni DefaultFun
-> String
forall a. Show a => a -> String
Haskell.show CekEvaluationException NamedDeBruijn DefaultUni DefaultFun
errWithCause) (MachineError DefaultFun -> String
forall a. Show a => a -> String
PLC.show MachineError DefaultFun
internalEvalError)
                     UserEvaluationError CekUserError
evalError -> [Text] -> String -> ScriptError
EvaluationError [Text]
logOut (CekUserError
-> Maybe (Term NamedDeBruijn DefaultUni DefaultFun ()) -> String
mkError CekUserError
evalError Maybe (Term NamedDeBruijn DefaultUni DefaultFun ())
cause) -- TODO fix this error channel fuckery

-- | Create an error message from the contents of an ErrorWithCause.
-- If the cause of an error is a `Just t` where `t = b v0 v1 .. vn` for some builtin `b` then
-- the error will be a "BuiltinEvaluationFailure" otherwise it will be `PLC.show evalError`
mkError :: UPLC.CekUserError -> Maybe (UPLC.Term UPLC.NamedDeBruijn PLC.DefaultUni PLC.DefaultFun ()) -> String
mkError :: CekUserError
-> Maybe (Term NamedDeBruijn DefaultUni DefaultFun ()) -> String
mkError CekUserError
evalError Maybe (Term NamedDeBruijn DefaultUni DefaultFun ())
Nothing = CekUserError -> String
forall a. Show a => a -> String
PLC.show CekUserError
evalError
mkError CekUserError
evalError (Just Term NamedDeBruijn DefaultUni DefaultFun ()
t) =
  case Term NamedDeBruijn DefaultUni DefaultFun () -> Maybe DefaultFun
findBuiltin Term NamedDeBruijn DefaultUni DefaultFun ()
t of
    Just DefaultFun
b  -> String
"BuiltinEvaluationFailure of " String -> ShowS
forall a. [a] -> [a] -> [a]
++ DefaultFun -> String
forall a. Show a => a -> String
Haskell.show DefaultFun
b
    Maybe DefaultFun
Nothing -> CekUserError -> String
forall a. Show a => a -> String
PLC.show CekUserError
evalError
  where
    findBuiltin :: UPLC.Term UPLC.NamedDeBruijn PLC.DefaultUni PLC.DefaultFun () -> Maybe PLC.DefaultFun
    findBuiltin :: Term NamedDeBruijn DefaultUni DefaultFun () -> Maybe DefaultFun
findBuiltin Term NamedDeBruijn DefaultUni DefaultFun ()
t = case Term NamedDeBruijn DefaultUni DefaultFun ()
t of
       UPLC.Apply ()
_ Term NamedDeBruijn DefaultUni DefaultFun ()
t Term NamedDeBruijn DefaultUni DefaultFun ()
_   -> Term NamedDeBruijn DefaultUni DefaultFun () -> Maybe DefaultFun
findBuiltin Term NamedDeBruijn DefaultUni DefaultFun ()
t
       UPLC.Builtin ()
_ DefaultFun
fun -> DefaultFun -> Maybe DefaultFun
forall a. a -> Maybe a
Just DefaultFun
fun
       -- These two *really shouldn't* appear but
       -- we are future proofing for a day when they do
       UPLC.Force ()
_ Term NamedDeBruijn DefaultUni DefaultFun ()
t     -> Term NamedDeBruijn DefaultUni DefaultFun () -> Maybe DefaultFun
findBuiltin Term NamedDeBruijn DefaultUni DefaultFun ()
t
       UPLC.Delay ()
_ Term NamedDeBruijn DefaultUni DefaultFun ()
t     -> Term NamedDeBruijn DefaultUni DefaultFun () -> Maybe DefaultFun
findBuiltin Term NamedDeBruijn DefaultUni DefaultFun ()
t
       -- Future proofing for eta-expanded builtins
       UPLC.LamAbs ()
_ NamedDeBruijn
_ Term NamedDeBruijn DefaultUni DefaultFun ()
t  -> Term NamedDeBruijn DefaultUni DefaultFun () -> Maybe DefaultFun
findBuiltin Term NamedDeBruijn DefaultUni DefaultFun ()
t
       UPLC.Var ()
_ NamedDeBruijn
_       -> Maybe DefaultFun
forall a. Maybe a
Nothing
       UPLC.Constant ()
_ Some (ValueOf DefaultUni)
_  -> Maybe DefaultFun
forall a. Maybe a
Nothing
       UPLC.Error ()
_       -> Maybe DefaultFun
forall a. Maybe a
Nothing

{- Note [JSON instances for Script]
The JSON instances for Script are partially hand-written rather than going via the Serialise
instance directly. The reason for this is to *avoid* the size checks that are in place in the
Serialise instance. These are only useful for deserialisation checks on-chain, whereas the
JSON instances are used for e.g. transmitting validation events, which often include scripts
with the data arguments applied (which can be very big!).
-}

instance ToJSON Script where
    -- See note [JSON instances for Script]
    toJSON :: Script -> Value
toJSON (Script Program DeBruijn DefaultUni DefaultFun ()
p) = Text -> Value
JSON.String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ SerialiseViaFlat (Program DeBruijn DefaultUni DefaultFun ())
-> Text
forall a. Serialise a => a -> Text
JSON.encodeSerialise (Program DeBruijn DefaultUni DefaultFun ()
-> SerialiseViaFlat (Program DeBruijn DefaultUni DefaultFun ())
forall a. a -> SerialiseViaFlat a
SerialiseViaFlat Program DeBruijn DefaultUni DefaultFun ()
p)

instance FromJSON Script where
    -- See note [JSON instances for Script]
    parseJSON :: Value -> Parser Script
parseJSON Value
v = do
        (SerialiseViaFlat Program DeBruijn DefaultUni DefaultFun ()
p) <- Value
-> Parser
     (SerialiseViaFlat (Program DeBruijn DefaultUni DefaultFun ()))
forall a. Serialise a => Value -> Parser a
JSON.decodeSerialise Value
v
        Script -> Parser Script
forall (m :: * -> *) a. Monad m => a -> m a
Haskell.return (Script -> Parser Script) -> Script -> Parser Script
forall a b. (a -> b) -> a -> b
$ Program DeBruijn DefaultUni DefaultFun () -> Script
Script Program DeBruijn DefaultUni DefaultFun ()
p

deriving via (JSON.JSONViaSerialise PLC.Data) instance ToJSON PLC.Data
deriving via (JSON.JSONViaSerialise PLC.Data) instance FromJSON PLC.Data

mkValidatorScript :: CompiledCode (BuiltinData -> BuiltinData -> BuiltinData -> ()) -> Validator
mkValidatorScript :: CompiledCode (BuiltinData -> BuiltinData -> BuiltinData -> ())
-> Validator
mkValidatorScript = Script -> Validator
Validator (Script -> Validator)
-> (CompiledCode (BuiltinData -> BuiltinData -> BuiltinData -> ())
    -> Script)
-> CompiledCode (BuiltinData -> BuiltinData -> BuiltinData -> ())
-> Validator
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CompiledCode (BuiltinData -> BuiltinData -> BuiltinData -> ())
-> Script
forall a. CompiledCode a -> Script
fromCompiledCode

unValidatorScript :: Validator -> Script
unValidatorScript :: Validator -> Script
unValidatorScript = Validator -> Script
getValidator

mkMintingPolicyScript :: CompiledCode (BuiltinData -> BuiltinData -> ()) -> MintingPolicy
mkMintingPolicyScript :: CompiledCode (BuiltinData -> BuiltinData -> ()) -> MintingPolicy
mkMintingPolicyScript = Script -> MintingPolicy
MintingPolicy (Script -> MintingPolicy)
-> (CompiledCode (BuiltinData -> BuiltinData -> ()) -> Script)
-> CompiledCode (BuiltinData -> BuiltinData -> ())
-> MintingPolicy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CompiledCode (BuiltinData -> BuiltinData -> ()) -> Script
forall a. CompiledCode a -> Script
fromCompiledCode

unMintingPolicyScript :: MintingPolicy -> Script
unMintingPolicyScript :: MintingPolicy -> Script
unMintingPolicyScript = MintingPolicy -> Script
getMintingPolicy

mkStakeValidatorScript :: CompiledCode (BuiltinData -> BuiltinData -> ()) -> StakeValidator
mkStakeValidatorScript :: CompiledCode (BuiltinData -> BuiltinData -> ()) -> StakeValidator
mkStakeValidatorScript = Script -> StakeValidator
StakeValidator (Script -> StakeValidator)
-> (CompiledCode (BuiltinData -> BuiltinData -> ()) -> Script)
-> CompiledCode (BuiltinData -> BuiltinData -> ())
-> StakeValidator
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CompiledCode (BuiltinData -> BuiltinData -> ()) -> Script
forall a. CompiledCode a -> Script
fromCompiledCode

unStakeValidatorScript :: StakeValidator -> Script
unStakeValidatorScript :: StakeValidator -> Script
unStakeValidatorScript = StakeValidator -> Script
getStakeValidator

-- | 'Validator' is a wrapper around 'Script's which are used as validators in transaction outputs.
newtype Validator = Validator { Validator -> Script
getValidator :: Script }
  deriving stock ((forall x. Validator -> Rep Validator x)
-> (forall x. Rep Validator x -> Validator) -> Generic Validator
forall x. Rep Validator x -> Validator
forall x. Validator -> Rep Validator x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Validator x -> Validator
$cfrom :: forall x. Validator -> Rep Validator x
Generic)
  deriving newtype (Validator -> Validator -> Bool
(Validator -> Validator -> Bool)
-> (Validator -> Validator -> Bool) -> Eq Validator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Validator -> Validator -> Bool
$c/= :: Validator -> Validator -> Bool
== :: Validator -> Validator -> Bool
$c== :: Validator -> Validator -> Bool
Haskell.Eq, Eq Validator
Eq Validator
-> (Validator -> Validator -> Ordering)
-> (Validator -> Validator -> Bool)
-> (Validator -> Validator -> Bool)
-> (Validator -> Validator -> Bool)
-> (Validator -> Validator -> Bool)
-> (Validator -> Validator -> Validator)
-> (Validator -> Validator -> Validator)
-> Ord Validator
Validator -> Validator -> Bool
Validator -> Validator -> Ordering
Validator -> Validator -> Validator
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
min :: Validator -> Validator -> Validator
$cmin :: Validator -> Validator -> Validator
max :: Validator -> Validator -> Validator
$cmax :: Validator -> Validator -> Validator
>= :: Validator -> Validator -> Bool
$c>= :: Validator -> Validator -> Bool
> :: Validator -> Validator -> Bool
$c> :: Validator -> Validator -> Bool
<= :: Validator -> Validator -> Bool
$c<= :: Validator -> Validator -> Bool
< :: Validator -> Validator -> Bool
$c< :: Validator -> Validator -> Bool
compare :: Validator -> Validator -> Ordering
$ccompare :: Validator -> Validator -> Ordering
$cp1Ord :: Eq Validator
Haskell.Ord, Decoder s Validator
Decoder s [Validator]
[Validator] -> Encoding
Validator -> Encoding
(Validator -> Encoding)
-> (forall s. Decoder s Validator)
-> ([Validator] -> Encoding)
-> (forall s. Decoder s [Validator])
-> Serialise Validator
forall s. Decoder s [Validator]
forall s. Decoder s Validator
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: Decoder s [Validator]
$cdecodeList :: forall s. Decoder s [Validator]
encodeList :: [Validator] -> Encoding
$cencodeList :: [Validator] -> Encoding
decode :: Decoder s Validator
$cdecode :: forall s. Decoder s Validator
encode :: Validator -> Encoding
$cencode :: Validator -> Encoding
Serialise)
  deriving anyclass ([Validator] -> Encoding
[Validator] -> Value
Validator -> Encoding
Validator -> Value
(Validator -> Value)
-> (Validator -> Encoding)
-> ([Validator] -> Value)
-> ([Validator] -> Encoding)
-> ToJSON Validator
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Validator] -> Encoding
$ctoEncodingList :: [Validator] -> Encoding
toJSONList :: [Validator] -> Value
$ctoJSONList :: [Validator] -> Value
toEncoding :: Validator -> Encoding
$ctoEncoding :: Validator -> Encoding
toJSON :: Validator -> Value
$ctoJSON :: Validator -> Value
ToJSON, Value -> Parser [Validator]
Value -> Parser Validator
(Value -> Parser Validator)
-> (Value -> Parser [Validator]) -> FromJSON Validator
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [Validator]
$cparseJSONList :: Value -> Parser [Validator]
parseJSON :: Value -> Parser Validator
$cparseJSON :: Value -> Parser Validator
FromJSON, Validator -> ()
(Validator -> ()) -> NFData Validator
forall a. (a -> ()) -> NFData a
rnf :: Validator -> ()
$crnf :: Validator -> ()
NFData)
  deriving [Validator] -> Doc ann
Validator -> Doc ann
(forall ann. Validator -> Doc ann)
-> (forall ann. [Validator] -> Doc ann) -> Pretty Validator
forall ann. [Validator] -> Doc ann
forall ann. Validator -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
prettyList :: [Validator] -> Doc ann
$cprettyList :: forall ann. [Validator] -> Doc ann
pretty :: Validator -> Doc ann
$cpretty :: forall ann. Validator -> Doc ann
Pretty via (PrettyShow Validator)

instance Haskell.Show Validator where
    show :: Validator -> String
show = String -> Validator -> String
forall a b. a -> b -> a
const String
"Validator { <script> }"

instance BA.ByteArrayAccess Validator where
    length :: Validator -> Int
length =
        ByteString -> Int
forall ba. ByteArrayAccess ba => ba -> Int
BA.length (ByteString -> Int)
-> (Validator -> ByteString) -> Validator -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BSL.toStrict (ByteString -> ByteString)
-> (Validator -> ByteString) -> Validator -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Validator -> ByteString
forall a. Serialise a => a -> ByteString
serialise
    withByteArray :: Validator -> (Ptr p -> IO a) -> IO a
withByteArray =
        ByteString -> (Ptr p -> IO a) -> IO a
forall ba p a. ByteArrayAccess ba => ba -> (Ptr p -> IO a) -> IO a
BA.withByteArray (ByteString -> (Ptr p -> IO a) -> IO a)
-> (Validator -> ByteString)
-> Validator
-> (Ptr p -> IO a)
-> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BSL.toStrict (ByteString -> ByteString)
-> (Validator -> ByteString) -> Validator -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Validator -> ByteString
forall a. Serialise a => a -> ByteString
serialise

-- | '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
$cto :: forall x. Rep Datum x -> Datum
$cfrom :: forall x. Datum -> Rep Datum x
Generic, 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
showList :: [Datum] -> ShowS
$cshowList :: [Datum] -> ShowS
show :: Datum -> String
$cshow :: Datum -> String
showsPrec :: Int -> Datum -> ShowS
$cshowsPrec :: Int -> 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
/= :: Datum -> Datum -> Bool
$c/= :: Datum -> Datum -> Bool
== :: Datum -> Datum -> Bool
$c== :: 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
min :: Datum -> Datum -> Datum
$cmin :: Datum -> Datum -> Datum
max :: Datum -> Datum -> Datum
$cmax :: Datum -> Datum -> Datum
>= :: Datum -> Datum -> Bool
$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
compare :: Datum -> Datum -> Ordering
$ccompare :: Datum -> Datum -> Ordering
$cp1Ord :: Eq Datum
Haskell.Ord, Datum -> Datum -> Bool
(Datum -> Datum -> Bool) -> Eq Datum
forall a. (a -> a -> Bool) -> Eq a
== :: Datum -> Datum -> Bool
$c== :: Datum -> Datum -> Bool
Eq, Datum -> BuiltinData
(Datum -> BuiltinData) -> ToData Datum
forall a. (a -> BuiltinData) -> ToData a
toBuiltinData :: Datum -> BuiltinData
$ctoBuiltinData :: Datum -> BuiltinData
ToData, BuiltinData -> Maybe Datum
(BuiltinData -> Maybe Datum) -> FromData Datum
forall a. (BuiltinData -> Maybe a) -> FromData a
fromBuiltinData :: BuiltinData -> Maybe Datum
$cfromBuiltinData :: BuiltinData -> Maybe Datum
FromData, BuiltinData -> Datum
(BuiltinData -> Datum) -> UnsafeFromData Datum
forall a. (BuiltinData -> a) -> UnsafeFromData a
unsafeFromBuiltinData :: BuiltinData -> Datum
$cunsafeFromBuiltinData :: BuiltinData -> Datum
UnsafeFromData)
  deriving ([Datum] -> Encoding
[Datum] -> Value
Datum -> Encoding
Datum -> Value
(Datum -> Value)
-> (Datum -> Encoding)
-> ([Datum] -> Value)
-> ([Datum] -> Encoding)
-> ToJSON Datum
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Datum] -> Encoding
$ctoEncodingList :: [Datum] -> Encoding
toJSONList :: [Datum] -> Value
$ctoJSONList :: [Datum] -> Value
toEncoding :: Datum -> Encoding
$ctoEncoding :: Datum -> Encoding
toJSON :: Datum -> Value
$ctoJSON :: Datum -> Value
ToJSON, Value -> Parser [Datum]
Value -> Parser Datum
(Value -> Parser Datum)
-> (Value -> Parser [Datum]) -> FromJSON Datum
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [Datum]
$cparseJSONList :: Value -> Parser [Datum]
parseJSON :: Value -> Parser Datum
$cparseJSON :: Value -> Parser Datum
FromJSON, Decoder s Datum
Decoder s [Datum]
[Datum] -> Encoding
Datum -> Encoding
(Datum -> Encoding)
-> (forall s. Decoder s Datum)
-> ([Datum] -> Encoding)
-> (forall s. Decoder s [Datum])
-> Serialise Datum
forall s. Decoder s [Datum]
forall s. Decoder s Datum
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: Decoder s [Datum]
$cdecodeList :: forall s. Decoder s [Datum]
encodeList :: [Datum] -> Encoding
$cencodeList :: [Datum] -> Encoding
decode :: Decoder s Datum
$cdecode :: forall s. Decoder s Datum
encode :: Datum -> Encoding
$cencode :: Datum -> Encoding
Serialise, Datum -> ()
(Datum -> ()) -> NFData Datum
forall a. (a -> ()) -> NFData a
rnf :: Datum -> ()
$crnf :: Datum -> ()
NFData) via PLC.Data
  deriving [Datum] -> Doc ann
Datum -> Doc ann
(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
prettyList :: [Datum] -> Doc ann
$cprettyList :: forall ann. [Datum] -> Doc ann
pretty :: Datum -> Doc ann
$cpretty :: forall ann. Datum -> Doc ann
Pretty via PLC.Data

instance BA.ByteArrayAccess Datum where
    length :: Datum -> Int
length =
        ByteString -> Int
forall ba. ByteArrayAccess ba => ba -> Int
BA.length (ByteString -> Int) -> (Datum -> ByteString) -> Datum -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BSL.toStrict (ByteString -> ByteString)
-> (Datum -> ByteString) -> Datum -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Datum -> ByteString
forall a. Serialise a => a -> ByteString
serialise
    withByteArray :: Datum -> (Ptr p -> IO a) -> IO a
withByteArray =
        ByteString -> (Ptr p -> IO a) -> IO a
forall ba p a. ByteArrayAccess ba => ba -> (Ptr p -> IO a) -> IO a
BA.withByteArray (ByteString -> (Ptr p -> IO a) -> IO a)
-> (Datum -> ByteString) -> Datum -> (Ptr p -> IO a) -> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BSL.toStrict (ByteString -> ByteString)
-> (Datum -> ByteString) -> Datum -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Datum -> ByteString
forall a. Serialise a => a -> ByteString
serialise

-- | '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
$cto :: forall x. Rep Redeemer x -> Redeemer
$cfrom :: forall x. Redeemer -> Rep Redeemer x
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
showList :: [Redeemer] -> ShowS
$cshowList :: [Redeemer] -> ShowS
show :: Redeemer -> String
$cshow :: Redeemer -> String
showsPrec :: Int -> Redeemer -> ShowS
$cshowsPrec :: Int -> Redeemer -> ShowS
Haskell.Show)
  deriving newtype (Redeemer -> Redeemer -> Bool
(Redeemer -> Redeemer -> Bool)
-> (Redeemer -> Redeemer -> Bool) -> Eq Redeemer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Redeemer -> Redeemer -> Bool
$c/= :: Redeemer -> Redeemer -> Bool
== :: Redeemer -> Redeemer -> Bool
$c== :: 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
min :: Redeemer -> Redeemer -> Redeemer
$cmin :: Redeemer -> Redeemer -> Redeemer
max :: Redeemer -> Redeemer -> Redeemer
$cmax :: Redeemer -> Redeemer -> Redeemer
>= :: Redeemer -> Redeemer -> Bool
$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
compare :: Redeemer -> Redeemer -> Ordering
$ccompare :: Redeemer -> Redeemer -> Ordering
$cp1Ord :: Eq Redeemer
Haskell.Ord, Redeemer -> Redeemer -> Bool
(Redeemer -> Redeemer -> Bool) -> Eq Redeemer
forall a. (a -> a -> Bool) -> Eq a
== :: Redeemer -> Redeemer -> Bool
$c== :: Redeemer -> Redeemer -> Bool
Eq, Redeemer -> BuiltinData
(Redeemer -> BuiltinData) -> ToData Redeemer
forall a. (a -> BuiltinData) -> ToData a
toBuiltinData :: Redeemer -> BuiltinData
$ctoBuiltinData :: Redeemer -> BuiltinData
ToData, BuiltinData -> Maybe Redeemer
(BuiltinData -> Maybe Redeemer) -> FromData Redeemer
forall a. (BuiltinData -> Maybe a) -> FromData a
fromBuiltinData :: BuiltinData -> Maybe Redeemer
$cfromBuiltinData :: BuiltinData -> Maybe Redeemer
FromData, BuiltinData -> Redeemer
(BuiltinData -> Redeemer) -> UnsafeFromData Redeemer
forall a. (BuiltinData -> a) -> UnsafeFromData a
unsafeFromBuiltinData :: BuiltinData -> Redeemer
$cunsafeFromBuiltinData :: BuiltinData -> Redeemer
UnsafeFromData)
  deriving ([Redeemer] -> Encoding
[Redeemer] -> Value
Redeemer -> Encoding
Redeemer -> Value
(Redeemer -> Value)
-> (Redeemer -> Encoding)
-> ([Redeemer] -> Value)
-> ([Redeemer] -> Encoding)
-> ToJSON Redeemer
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Redeemer] -> Encoding
$ctoEncodingList :: [Redeemer] -> Encoding
toJSONList :: [Redeemer] -> Value
$ctoJSONList :: [Redeemer] -> Value
toEncoding :: Redeemer -> Encoding
$ctoEncoding :: Redeemer -> Encoding
toJSON :: Redeemer -> Value
$ctoJSON :: Redeemer -> Value
ToJSON, Value -> Parser [Redeemer]
Value -> Parser Redeemer
(Value -> Parser Redeemer)
-> (Value -> Parser [Redeemer]) -> FromJSON Redeemer
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [Redeemer]
$cparseJSONList :: Value -> Parser [Redeemer]
parseJSON :: Value -> Parser Redeemer
$cparseJSON :: Value -> Parser Redeemer
FromJSON, Decoder s Redeemer
Decoder s [Redeemer]
[Redeemer] -> Encoding
Redeemer -> Encoding
(Redeemer -> Encoding)
-> (forall s. Decoder s Redeemer)
-> ([Redeemer] -> Encoding)
-> (forall s. Decoder s [Redeemer])
-> Serialise Redeemer
forall s. Decoder s [Redeemer]
forall s. Decoder s Redeemer
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: Decoder s [Redeemer]
$cdecodeList :: forall s. Decoder s [Redeemer]
encodeList :: [Redeemer] -> Encoding
$cencodeList :: [Redeemer] -> Encoding
decode :: Decoder s Redeemer
$cdecode :: forall s. Decoder s Redeemer
encode :: Redeemer -> Encoding
$cencode :: Redeemer -> Encoding
Serialise, Redeemer -> ()
(Redeemer -> ()) -> NFData Redeemer
forall a. (a -> ()) -> NFData a
rnf :: Redeemer -> ()
$crnf :: Redeemer -> ()
NFData, [Redeemer] -> Doc ann
Redeemer -> Doc ann
(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
prettyList :: [Redeemer] -> Doc ann
$cprettyList :: forall ann. [Redeemer] -> Doc ann
pretty :: Redeemer -> Doc ann
$cpretty :: forall ann. Redeemer -> Doc ann
Pretty) via PLC.Data

instance BA.ByteArrayAccess Redeemer where
    length :: Redeemer -> Int
length =
        ByteString -> Int
forall ba. ByteArrayAccess ba => ba -> Int
BA.length (ByteString -> Int) -> (Redeemer -> ByteString) -> Redeemer -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BSL.toStrict (ByteString -> ByteString)
-> (Redeemer -> ByteString) -> Redeemer -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Redeemer -> ByteString
forall a. Serialise a => a -> ByteString
serialise
    withByteArray :: Redeemer -> (Ptr p -> IO a) -> IO a
withByteArray =
        ByteString -> (Ptr p -> IO a) -> IO a
forall ba p a. ByteArrayAccess ba => ba -> (Ptr p -> IO a) -> IO a
BA.withByteArray (ByteString -> (Ptr p -> IO a) -> IO a)
-> (Redeemer -> ByteString) -> Redeemer -> (Ptr p -> IO a) -> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BSL.toStrict (ByteString -> ByteString)
-> (Redeemer -> ByteString) -> Redeemer -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Redeemer -> ByteString
forall a. Serialise a => a -> ByteString
serialise

-- | 'MintingPolicy' is a wrapper around 'Script's which are used as validators for minting constraints.
newtype MintingPolicy = MintingPolicy { MintingPolicy -> Script
getMintingPolicy :: Script }
  deriving stock ((forall x. MintingPolicy -> Rep MintingPolicy x)
-> (forall x. Rep MintingPolicy x -> MintingPolicy)
-> Generic MintingPolicy
forall x. Rep MintingPolicy x -> MintingPolicy
forall x. MintingPolicy -> Rep MintingPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MintingPolicy x -> MintingPolicy
$cfrom :: forall x. MintingPolicy -> Rep MintingPolicy x
Generic)
  deriving newtype (MintingPolicy -> MintingPolicy -> Bool
(MintingPolicy -> MintingPolicy -> Bool)
-> (MintingPolicy -> MintingPolicy -> Bool) -> Eq MintingPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MintingPolicy -> MintingPolicy -> Bool
$c/= :: MintingPolicy -> MintingPolicy -> Bool
== :: MintingPolicy -> MintingPolicy -> Bool
$c== :: MintingPolicy -> MintingPolicy -> Bool
Haskell.Eq, Eq MintingPolicy
Eq MintingPolicy
-> (MintingPolicy -> MintingPolicy -> Ordering)
-> (MintingPolicy -> MintingPolicy -> Bool)
-> (MintingPolicy -> MintingPolicy -> Bool)
-> (MintingPolicy -> MintingPolicy -> Bool)
-> (MintingPolicy -> MintingPolicy -> Bool)
-> (MintingPolicy -> MintingPolicy -> MintingPolicy)
-> (MintingPolicy -> MintingPolicy -> MintingPolicy)
-> Ord MintingPolicy
MintingPolicy -> MintingPolicy -> Bool
MintingPolicy -> MintingPolicy -> Ordering
MintingPolicy -> MintingPolicy -> MintingPolicy
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
min :: MintingPolicy -> MintingPolicy -> MintingPolicy
$cmin :: MintingPolicy -> MintingPolicy -> MintingPolicy
max :: MintingPolicy -> MintingPolicy -> MintingPolicy
$cmax :: MintingPolicy -> MintingPolicy -> MintingPolicy
>= :: MintingPolicy -> MintingPolicy -> Bool
$c>= :: MintingPolicy -> MintingPolicy -> Bool
> :: MintingPolicy -> MintingPolicy -> Bool
$c> :: MintingPolicy -> MintingPolicy -> Bool
<= :: MintingPolicy -> MintingPolicy -> Bool
$c<= :: MintingPolicy -> MintingPolicy -> Bool
< :: MintingPolicy -> MintingPolicy -> Bool
$c< :: MintingPolicy -> MintingPolicy -> Bool
compare :: MintingPolicy -> MintingPolicy -> Ordering
$ccompare :: MintingPolicy -> MintingPolicy -> Ordering
$cp1Ord :: Eq MintingPolicy
Haskell.Ord, Decoder s MintingPolicy
Decoder s [MintingPolicy]
[MintingPolicy] -> Encoding
MintingPolicy -> Encoding
(MintingPolicy -> Encoding)
-> (forall s. Decoder s MintingPolicy)
-> ([MintingPolicy] -> Encoding)
-> (forall s. Decoder s [MintingPolicy])
-> Serialise MintingPolicy
forall s. Decoder s [MintingPolicy]
forall s. Decoder s MintingPolicy
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: Decoder s [MintingPolicy]
$cdecodeList :: forall s. Decoder s [MintingPolicy]
encodeList :: [MintingPolicy] -> Encoding
$cencodeList :: [MintingPolicy] -> Encoding
decode :: Decoder s MintingPolicy
$cdecode :: forall s. Decoder s MintingPolicy
encode :: MintingPolicy -> Encoding
$cencode :: MintingPolicy -> Encoding
Serialise)
  deriving anyclass ([MintingPolicy] -> Encoding
[MintingPolicy] -> Value
MintingPolicy -> Encoding
MintingPolicy -> Value
(MintingPolicy -> Value)
-> (MintingPolicy -> Encoding)
-> ([MintingPolicy] -> Value)
-> ([MintingPolicy] -> Encoding)
-> ToJSON MintingPolicy
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [MintingPolicy] -> Encoding
$ctoEncodingList :: [MintingPolicy] -> Encoding
toJSONList :: [MintingPolicy] -> Value
$ctoJSONList :: [MintingPolicy] -> Value
toEncoding :: MintingPolicy -> Encoding
$ctoEncoding :: MintingPolicy -> Encoding
toJSON :: MintingPolicy -> Value
$ctoJSON :: MintingPolicy -> Value
ToJSON, Value -> Parser [MintingPolicy]
Value -> Parser MintingPolicy
(Value -> Parser MintingPolicy)
-> (Value -> Parser [MintingPolicy]) -> FromJSON MintingPolicy
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [MintingPolicy]
$cparseJSONList :: Value -> Parser [MintingPolicy]
parseJSON :: Value -> Parser MintingPolicy
$cparseJSON :: Value -> Parser MintingPolicy
FromJSON, MintingPolicy -> ()
(MintingPolicy -> ()) -> NFData MintingPolicy
forall a. (a -> ()) -> NFData a
rnf :: MintingPolicy -> ()
$crnf :: MintingPolicy -> ()
NFData)
  deriving [MintingPolicy] -> Doc ann
MintingPolicy -> Doc ann
(forall ann. MintingPolicy -> Doc ann)
-> (forall ann. [MintingPolicy] -> Doc ann) -> Pretty MintingPolicy
forall ann. [MintingPolicy] -> Doc ann
forall ann. MintingPolicy -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
prettyList :: [MintingPolicy] -> Doc ann
$cprettyList :: forall ann. [MintingPolicy] -> Doc ann
pretty :: MintingPolicy -> Doc ann
$cpretty :: forall ann. MintingPolicy -> Doc ann
Pretty via (PrettyShow MintingPolicy)

instance Haskell.Show MintingPolicy where
    show :: MintingPolicy -> String
show = String -> MintingPolicy -> String
forall a b. a -> b -> a
const String
"MintingPolicy { <script> }"

instance BA.ByteArrayAccess MintingPolicy where
    length :: MintingPolicy -> Int
length =
        ByteString -> Int
forall ba. ByteArrayAccess ba => ba -> Int
BA.length (ByteString -> Int)
-> (MintingPolicy -> ByteString) -> MintingPolicy -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BSL.toStrict (ByteString -> ByteString)
-> (MintingPolicy -> ByteString) -> MintingPolicy -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MintingPolicy -> ByteString
forall a. Serialise a => a -> ByteString
serialise
    withByteArray :: MintingPolicy -> (Ptr p -> IO a) -> IO a
withByteArray =
        ByteString -> (Ptr p -> IO a) -> IO a
forall ba p a. ByteArrayAccess ba => ba -> (Ptr p -> IO a) -> IO a
BA.withByteArray (ByteString -> (Ptr p -> IO a) -> IO a)
-> (MintingPolicy -> ByteString)
-> MintingPolicy
-> (Ptr p -> IO a)
-> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BSL.toStrict (ByteString -> ByteString)
-> (MintingPolicy -> ByteString) -> MintingPolicy -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MintingPolicy -> ByteString
forall a. Serialise a => a -> ByteString
serialise

-- | 'StakeValidator' is a wrapper around 'Script's which are used as validators for withdrawals and stake address certificates.
newtype StakeValidator = StakeValidator { StakeValidator -> Script
getStakeValidator :: Script }
  deriving stock ((forall x. StakeValidator -> Rep StakeValidator x)
-> (forall x. Rep StakeValidator x -> StakeValidator)
-> Generic StakeValidator
forall x. Rep StakeValidator x -> StakeValidator
forall x. StakeValidator -> Rep StakeValidator x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StakeValidator x -> StakeValidator
$cfrom :: forall x. StakeValidator -> Rep StakeValidator x
Generic)
  deriving newtype (StakeValidator -> StakeValidator -> Bool
(StakeValidator -> StakeValidator -> Bool)
-> (StakeValidator -> StakeValidator -> Bool) -> Eq StakeValidator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StakeValidator -> StakeValidator -> Bool
$c/= :: StakeValidator -> StakeValidator -> Bool
== :: StakeValidator -> StakeValidator -> Bool
$c== :: StakeValidator -> StakeValidator -> Bool
Haskell.Eq, Eq StakeValidator
Eq StakeValidator
-> (StakeValidator -> StakeValidator -> Ordering)
-> (StakeValidator -> StakeValidator -> Bool)
-> (StakeValidator -> StakeValidator -> Bool)
-> (StakeValidator -> StakeValidator -> Bool)
-> (StakeValidator -> StakeValidator -> Bool)
-> (StakeValidator -> StakeValidator -> StakeValidator)
-> (StakeValidator -> StakeValidator -> StakeValidator)
-> Ord StakeValidator
StakeValidator -> StakeValidator -> Bool
StakeValidator -> StakeValidator -> Ordering
StakeValidator -> StakeValidator -> StakeValidator
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
min :: StakeValidator -> StakeValidator -> StakeValidator
$cmin :: StakeValidator -> StakeValidator -> StakeValidator
max :: StakeValidator -> StakeValidator -> StakeValidator
$cmax :: StakeValidator -> StakeValidator -> StakeValidator
>= :: StakeValidator -> StakeValidator -> Bool
$c>= :: StakeValidator -> StakeValidator -> Bool
> :: StakeValidator -> StakeValidator -> Bool
$c> :: StakeValidator -> StakeValidator -> Bool
<= :: StakeValidator -> StakeValidator -> Bool
$c<= :: StakeValidator -> StakeValidator -> Bool
< :: StakeValidator -> StakeValidator -> Bool
$c< :: StakeValidator -> StakeValidator -> Bool
compare :: StakeValidator -> StakeValidator -> Ordering
$ccompare :: StakeValidator -> StakeValidator -> Ordering
$cp1Ord :: Eq StakeValidator
Haskell.Ord, Decoder s StakeValidator
Decoder s [StakeValidator]
[StakeValidator] -> Encoding
StakeValidator -> Encoding
(StakeValidator -> Encoding)
-> (forall s. Decoder s StakeValidator)
-> ([StakeValidator] -> Encoding)
-> (forall s. Decoder s [StakeValidator])
-> Serialise StakeValidator
forall s. Decoder s [StakeValidator]
forall s. Decoder s StakeValidator
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: Decoder s [StakeValidator]
$cdecodeList :: forall s. Decoder s [StakeValidator]
encodeList :: [StakeValidator] -> Encoding
$cencodeList :: [StakeValidator] -> Encoding
decode :: Decoder s StakeValidator
$cdecode :: forall s. Decoder s StakeValidator
encode :: StakeValidator -> Encoding
$cencode :: StakeValidator -> Encoding
Serialise)
  deriving anyclass ([StakeValidator] -> Encoding
[StakeValidator] -> Value
StakeValidator -> Encoding
StakeValidator -> Value
(StakeValidator -> Value)
-> (StakeValidator -> Encoding)
-> ([StakeValidator] -> Value)
-> ([StakeValidator] -> Encoding)
-> ToJSON StakeValidator
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [StakeValidator] -> Encoding
$ctoEncodingList :: [StakeValidator] -> Encoding
toJSONList :: [StakeValidator] -> Value
$ctoJSONList :: [StakeValidator] -> Value
toEncoding :: StakeValidator -> Encoding
$ctoEncoding :: StakeValidator -> Encoding
toJSON :: StakeValidator -> Value
$ctoJSON :: StakeValidator -> Value
ToJSON, Value -> Parser [StakeValidator]
Value -> Parser StakeValidator
(Value -> Parser StakeValidator)
-> (Value -> Parser [StakeValidator]) -> FromJSON StakeValidator
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [StakeValidator]
$cparseJSONList :: Value -> Parser [StakeValidator]
parseJSON :: Value -> Parser StakeValidator
$cparseJSON :: Value -> Parser StakeValidator
FromJSON, StakeValidator -> ()
(StakeValidator -> ()) -> NFData StakeValidator
forall a. (a -> ()) -> NFData a
rnf :: StakeValidator -> ()
$crnf :: StakeValidator -> ()
NFData)
  deriving [StakeValidator] -> Doc ann
StakeValidator -> Doc ann
(forall ann. StakeValidator -> Doc ann)
-> (forall ann. [StakeValidator] -> Doc ann)
-> Pretty StakeValidator
forall ann. [StakeValidator] -> Doc ann
forall ann. StakeValidator -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
prettyList :: [StakeValidator] -> Doc ann
$cprettyList :: forall ann. [StakeValidator] -> Doc ann
pretty :: StakeValidator -> Doc ann
$cpretty :: forall ann. StakeValidator -> Doc ann
Pretty via (PrettyShow MintingPolicy)

instance Haskell.Show StakeValidator where
    show :: StakeValidator -> String
show = String -> StakeValidator -> String
forall a b. a -> b -> a
const String
"StakeValidator { <script> }"

instance BA.ByteArrayAccess StakeValidator where
    length :: StakeValidator -> Int
length =
        ByteString -> Int
forall ba. ByteArrayAccess ba => ba -> Int
BA.length (ByteString -> Int)
-> (StakeValidator -> ByteString) -> StakeValidator -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BSL.toStrict (ByteString -> ByteString)
-> (StakeValidator -> ByteString) -> StakeValidator -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StakeValidator -> ByteString
forall a. Serialise a => a -> ByteString
serialise
    withByteArray :: StakeValidator -> (Ptr p -> IO a) -> IO a
withByteArray =
        ByteString -> (Ptr p -> IO a) -> IO a
forall ba p a. ByteArrayAccess ba => ba -> (Ptr p -> IO a) -> IO a
BA.withByteArray (ByteString -> (Ptr p -> IO a) -> IO a)
-> (StakeValidator -> ByteString)
-> StakeValidator
-> (Ptr p -> IO a)
-> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BSL.toStrict (ByteString -> ByteString)
-> (StakeValidator -> ByteString) -> StakeValidator -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StakeValidator -> ByteString
forall a. Serialise a => a -> ByteString
serialise

-- | Script runtime representation of a @Digest SHA256@.
newtype ScriptHash =
    ScriptHash { ScriptHash -> BuiltinByteString
getScriptHash :: Builtins.BuiltinByteString }
    deriving (String -> ScriptHash
(String -> ScriptHash) -> IsString ScriptHash
forall a. (String -> a) -> IsString a
fromString :: String -> ScriptHash
$cfromString :: String -> ScriptHash
IsString, 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
showList :: [ScriptHash] -> ShowS
$cshowList :: [ScriptHash] -> ShowS
show :: ScriptHash -> String
$cshow :: ScriptHash -> String
showsPrec :: Int -> ScriptHash -> ShowS
$cshowsPrec :: Int -> ScriptHash -> ShowS
Haskell.Show, Decoder s ScriptHash
Decoder s [ScriptHash]
[ScriptHash] -> Encoding
ScriptHash -> Encoding
(ScriptHash -> Encoding)
-> (forall s. Decoder s ScriptHash)
-> ([ScriptHash] -> Encoding)
-> (forall s. Decoder s [ScriptHash])
-> Serialise ScriptHash
forall s. Decoder s [ScriptHash]
forall s. Decoder s ScriptHash
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: Decoder s [ScriptHash]
$cdecodeList :: forall s. Decoder s [ScriptHash]
encodeList :: [ScriptHash] -> Encoding
$cencodeList :: [ScriptHash] -> Encoding
decode :: Decoder s ScriptHash
$cdecode :: forall s. Decoder s ScriptHash
encode :: ScriptHash -> Encoding
$cencode :: ScriptHash -> Encoding
Serialise, [ScriptHash] -> Doc ann
ScriptHash -> Doc ann
(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
prettyList :: [ScriptHash] -> Doc ann
$cprettyList :: forall ann. [ScriptHash] -> Doc ann
pretty :: ScriptHash -> Doc ann
$cpretty :: 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
$cto :: forall x. Rep ScriptHash x -> ScriptHash
$cfrom :: forall x. ScriptHash -> Rep ScriptHash x
Generic)
    deriving newtype (ScriptHash -> ScriptHash -> Bool
(ScriptHash -> ScriptHash -> Bool)
-> (ScriptHash -> ScriptHash -> Bool) -> Eq ScriptHash
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScriptHash -> ScriptHash -> Bool
$c/= :: ScriptHash -> ScriptHash -> Bool
== :: ScriptHash -> ScriptHash -> Bool
$c== :: 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
min :: ScriptHash -> ScriptHash -> ScriptHash
$cmin :: ScriptHash -> ScriptHash -> ScriptHash
max :: ScriptHash -> ScriptHash -> ScriptHash
$cmax :: ScriptHash -> ScriptHash -> ScriptHash
>= :: ScriptHash -> ScriptHash -> Bool
$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
compare :: ScriptHash -> ScriptHash -> Ordering
$ccompare :: ScriptHash -> ScriptHash -> Ordering
$cp1Ord :: Eq ScriptHash
Haskell.Ord, ScriptHash -> ScriptHash -> Bool
(ScriptHash -> ScriptHash -> Bool) -> Eq ScriptHash
forall a. (a -> a -> Bool) -> Eq a
== :: ScriptHash -> ScriptHash -> Bool
$c== :: 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
min :: ScriptHash -> ScriptHash -> ScriptHash
$cmin :: ScriptHash -> ScriptHash -> ScriptHash
max :: ScriptHash -> ScriptHash -> ScriptHash
$cmax :: ScriptHash -> ScriptHash -> ScriptHash
>= :: ScriptHash -> ScriptHash -> Bool
$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
compare :: ScriptHash -> ScriptHash -> Ordering
$ccompare :: ScriptHash -> ScriptHash -> Ordering
$cp1Ord :: Eq ScriptHash
Ord, Int -> ScriptHash -> Int
ScriptHash -> Int
(Int -> ScriptHash -> Int)
-> (ScriptHash -> Int) -> Hashable ScriptHash
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: ScriptHash -> Int
$chash :: ScriptHash -> Int
hashWithSalt :: Int -> ScriptHash -> Int
$chashWithSalt :: Int -> ScriptHash -> Int
Hashable, ScriptHash -> BuiltinData
(ScriptHash -> BuiltinData) -> ToData ScriptHash
forall a. (a -> BuiltinData) -> ToData a
toBuiltinData :: ScriptHash -> BuiltinData
$ctoBuiltinData :: ScriptHash -> BuiltinData
ToData, BuiltinData -> Maybe ScriptHash
(BuiltinData -> Maybe ScriptHash) -> FromData ScriptHash
forall a. (BuiltinData -> Maybe a) -> FromData a
fromBuiltinData :: BuiltinData -> Maybe ScriptHash
$cfromBuiltinData :: BuiltinData -> Maybe ScriptHash
FromData, BuiltinData -> ScriptHash
(BuiltinData -> ScriptHash) -> UnsafeFromData ScriptHash
forall a. (BuiltinData -> a) -> UnsafeFromData a
unsafeFromBuiltinData :: BuiltinData -> ScriptHash
$cunsafeFromBuiltinData :: BuiltinData -> ScriptHash
UnsafeFromData)
    deriving anyclass (Value -> Parser [ScriptHash]
Value -> Parser ScriptHash
(Value -> Parser ScriptHash)
-> (Value -> Parser [ScriptHash]) -> FromJSON ScriptHash
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ScriptHash]
$cparseJSONList :: Value -> Parser [ScriptHash]
parseJSON :: Value -> Parser ScriptHash
$cparseJSON :: Value -> Parser ScriptHash
FromJSON, [ScriptHash] -> Encoding
[ScriptHash] -> Value
ScriptHash -> Encoding
ScriptHash -> Value
(ScriptHash -> Value)
-> (ScriptHash -> Encoding)
-> ([ScriptHash] -> Value)
-> ([ScriptHash] -> Encoding)
-> ToJSON ScriptHash
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ScriptHash] -> Encoding
$ctoEncodingList :: [ScriptHash] -> Encoding
toJSONList :: [ScriptHash] -> Value
$ctoJSONList :: [ScriptHash] -> Value
toEncoding :: ScriptHash -> Encoding
$ctoEncoding :: ScriptHash -> Encoding
toJSON :: ScriptHash -> Value
$ctoJSON :: ScriptHash -> Value
ToJSON, ToJSONKeyFunction [ScriptHash]
ToJSONKeyFunction ScriptHash
ToJSONKeyFunction ScriptHash
-> ToJSONKeyFunction [ScriptHash] -> ToJSONKey ScriptHash
forall a.
ToJSONKeyFunction a -> ToJSONKeyFunction [a] -> ToJSONKey a
toJSONKeyList :: ToJSONKeyFunction [ScriptHash]
$ctoJSONKeyList :: ToJSONKeyFunction [ScriptHash]
toJSONKey :: ToJSONKeyFunction ScriptHash
$ctoJSONKey :: ToJSONKeyFunction ScriptHash
ToJSONKey, FromJSONKeyFunction [ScriptHash]
FromJSONKeyFunction ScriptHash
FromJSONKeyFunction ScriptHash
-> FromJSONKeyFunction [ScriptHash] -> FromJSONKey ScriptHash
forall a.
FromJSONKeyFunction a -> FromJSONKeyFunction [a] -> FromJSONKey a
fromJSONKeyList :: FromJSONKeyFunction [ScriptHash]
$cfromJSONKeyList :: FromJSONKeyFunction [ScriptHash]
fromJSONKey :: FromJSONKeyFunction ScriptHash
$cfromJSONKey :: FromJSONKeyFunction ScriptHash
FromJSONKey, ScriptHash -> ()
(ScriptHash -> ()) -> NFData ScriptHash
forall a. (a -> ()) -> NFData a
rnf :: ScriptHash -> ()
$crnf :: ScriptHash -> ()
NFData)

-- | Script runtime representation of a @Digest SHA256@.
newtype ValidatorHash =
    ValidatorHash Builtins.BuiltinByteString
    deriving (String -> ValidatorHash
(String -> ValidatorHash) -> IsString ValidatorHash
forall a. (String -> a) -> IsString a
fromString :: String -> ValidatorHash
$cfromString :: String -> ValidatorHash
IsString, Int -> ValidatorHash -> ShowS
[ValidatorHash] -> ShowS
ValidatorHash -> String
(Int -> ValidatorHash -> ShowS)
-> (ValidatorHash -> String)
-> ([ValidatorHash] -> ShowS)
-> Show ValidatorHash
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ValidatorHash] -> ShowS
$cshowList :: [ValidatorHash] -> ShowS
show :: ValidatorHash -> String
$cshow :: ValidatorHash -> String
showsPrec :: Int -> ValidatorHash -> ShowS
$cshowsPrec :: Int -> ValidatorHash -> ShowS
Haskell.Show, Decoder s ValidatorHash
Decoder s [ValidatorHash]
[ValidatorHash] -> Encoding
ValidatorHash -> Encoding
(ValidatorHash -> Encoding)
-> (forall s. Decoder s ValidatorHash)
-> ([ValidatorHash] -> Encoding)
-> (forall s. Decoder s [ValidatorHash])
-> Serialise ValidatorHash
forall s. Decoder s [ValidatorHash]
forall s. Decoder s ValidatorHash
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: Decoder s [ValidatorHash]
$cdecodeList :: forall s. Decoder s [ValidatorHash]
encodeList :: [ValidatorHash] -> Encoding
$cencodeList :: [ValidatorHash] -> Encoding
decode :: Decoder s ValidatorHash
$cdecode :: forall s. Decoder s ValidatorHash
encode :: ValidatorHash -> Encoding
$cencode :: ValidatorHash -> Encoding
Serialise, [ValidatorHash] -> Doc ann
ValidatorHash -> Doc ann
(forall ann. ValidatorHash -> Doc ann)
-> (forall ann. [ValidatorHash] -> Doc ann) -> Pretty ValidatorHash
forall ann. [ValidatorHash] -> Doc ann
forall ann. ValidatorHash -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
prettyList :: [ValidatorHash] -> Doc ann
$cprettyList :: forall ann. [ValidatorHash] -> Doc ann
pretty :: ValidatorHash -> Doc ann
$cpretty :: forall ann. ValidatorHash -> Doc ann
Pretty) via LedgerBytes
    deriving stock ((forall x. ValidatorHash -> Rep ValidatorHash x)
-> (forall x. Rep ValidatorHash x -> ValidatorHash)
-> Generic ValidatorHash
forall x. Rep ValidatorHash x -> ValidatorHash
forall x. ValidatorHash -> Rep ValidatorHash x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ValidatorHash x -> ValidatorHash
$cfrom :: forall x. ValidatorHash -> Rep ValidatorHash x
Generic)
    deriving newtype (ValidatorHash -> ValidatorHash -> Bool
(ValidatorHash -> ValidatorHash -> Bool)
-> (ValidatorHash -> ValidatorHash -> Bool) -> Eq ValidatorHash
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ValidatorHash -> ValidatorHash -> Bool
$c/= :: ValidatorHash -> ValidatorHash -> Bool
== :: ValidatorHash -> ValidatorHash -> Bool
$c== :: ValidatorHash -> ValidatorHash -> Bool
Haskell.Eq, Eq ValidatorHash
Eq ValidatorHash
-> (ValidatorHash -> ValidatorHash -> Ordering)
-> (ValidatorHash -> ValidatorHash -> Bool)
-> (ValidatorHash -> ValidatorHash -> Bool)
-> (ValidatorHash -> ValidatorHash -> Bool)
-> (ValidatorHash -> ValidatorHash -> Bool)
-> (ValidatorHash -> ValidatorHash -> ValidatorHash)
-> (ValidatorHash -> ValidatorHash -> ValidatorHash)
-> Ord ValidatorHash
ValidatorHash -> ValidatorHash -> Bool
ValidatorHash -> ValidatorHash -> Ordering
ValidatorHash -> ValidatorHash -> ValidatorHash
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
min :: ValidatorHash -> ValidatorHash -> ValidatorHash
$cmin :: ValidatorHash -> ValidatorHash -> ValidatorHash
max :: ValidatorHash -> ValidatorHash -> ValidatorHash
$cmax :: ValidatorHash -> ValidatorHash -> ValidatorHash
>= :: ValidatorHash -> ValidatorHash -> Bool
$c>= :: ValidatorHash -> ValidatorHash -> Bool
> :: ValidatorHash -> ValidatorHash -> Bool
$c> :: ValidatorHash -> ValidatorHash -> Bool
<= :: ValidatorHash -> ValidatorHash -> Bool
$c<= :: ValidatorHash -> ValidatorHash -> Bool
< :: ValidatorHash -> ValidatorHash -> Bool
$c< :: ValidatorHash -> ValidatorHash -> Bool
compare :: ValidatorHash -> ValidatorHash -> Ordering
$ccompare :: ValidatorHash -> ValidatorHash -> Ordering
$cp1Ord :: Eq ValidatorHash
Haskell.Ord, ValidatorHash -> ValidatorHash -> Bool
(ValidatorHash -> ValidatorHash -> Bool) -> Eq ValidatorHash
forall a. (a -> a -> Bool) -> Eq a
== :: ValidatorHash -> ValidatorHash -> Bool
$c== :: ValidatorHash -> ValidatorHash -> Bool
Eq, Eq ValidatorHash
Eq ValidatorHash
-> (ValidatorHash -> ValidatorHash -> Ordering)
-> (ValidatorHash -> ValidatorHash -> Bool)
-> (ValidatorHash -> ValidatorHash -> Bool)
-> (ValidatorHash -> ValidatorHash -> Bool)
-> (ValidatorHash -> ValidatorHash -> Bool)
-> (ValidatorHash -> ValidatorHash -> ValidatorHash)
-> (ValidatorHash -> ValidatorHash -> ValidatorHash)
-> Ord ValidatorHash
ValidatorHash -> ValidatorHash -> Bool
ValidatorHash -> ValidatorHash -> Ordering
ValidatorHash -> ValidatorHash -> ValidatorHash
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
min :: ValidatorHash -> ValidatorHash -> ValidatorHash
$cmin :: ValidatorHash -> ValidatorHash -> ValidatorHash
max :: ValidatorHash -> ValidatorHash -> ValidatorHash
$cmax :: ValidatorHash -> ValidatorHash -> ValidatorHash
>= :: ValidatorHash -> ValidatorHash -> Bool
$c>= :: ValidatorHash -> ValidatorHash -> Bool
> :: ValidatorHash -> ValidatorHash -> Bool
$c> :: ValidatorHash -> ValidatorHash -> Bool
<= :: ValidatorHash -> ValidatorHash -> Bool
$c<= :: ValidatorHash -> ValidatorHash -> Bool
< :: ValidatorHash -> ValidatorHash -> Bool
$c< :: ValidatorHash -> ValidatorHash -> Bool
compare :: ValidatorHash -> ValidatorHash -> Ordering
$ccompare :: ValidatorHash -> ValidatorHash -> Ordering
$cp1Ord :: Eq ValidatorHash
Ord, Int -> ValidatorHash -> Int
ValidatorHash -> Int
(Int -> ValidatorHash -> Int)
-> (ValidatorHash -> Int) -> Hashable ValidatorHash
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: ValidatorHash -> Int
$chash :: ValidatorHash -> Int
hashWithSalt :: Int -> ValidatorHash -> Int
$chashWithSalt :: Int -> ValidatorHash -> Int
Hashable, ValidatorHash -> BuiltinData
(ValidatorHash -> BuiltinData) -> ToData ValidatorHash
forall a. (a -> BuiltinData) -> ToData a
toBuiltinData :: ValidatorHash -> BuiltinData
$ctoBuiltinData :: ValidatorHash -> BuiltinData
ToData, BuiltinData -> Maybe ValidatorHash
(BuiltinData -> Maybe ValidatorHash) -> FromData ValidatorHash
forall a. (BuiltinData -> Maybe a) -> FromData a
fromBuiltinData :: BuiltinData -> Maybe ValidatorHash
$cfromBuiltinData :: BuiltinData -> Maybe ValidatorHash
FromData, BuiltinData -> ValidatorHash
(BuiltinData -> ValidatorHash) -> UnsafeFromData ValidatorHash
forall a. (BuiltinData -> a) -> UnsafeFromData a
unsafeFromBuiltinData :: BuiltinData -> ValidatorHash
$cunsafeFromBuiltinData :: BuiltinData -> ValidatorHash
UnsafeFromData)
    deriving anyclass (Value -> Parser [ValidatorHash]
Value -> Parser ValidatorHash
(Value -> Parser ValidatorHash)
-> (Value -> Parser [ValidatorHash]) -> FromJSON ValidatorHash
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ValidatorHash]
$cparseJSONList :: Value -> Parser [ValidatorHash]
parseJSON :: Value -> Parser ValidatorHash
$cparseJSON :: Value -> Parser ValidatorHash
FromJSON, [ValidatorHash] -> Encoding
[ValidatorHash] -> Value
ValidatorHash -> Encoding
ValidatorHash -> Value
(ValidatorHash -> Value)
-> (ValidatorHash -> Encoding)
-> ([ValidatorHash] -> Value)
-> ([ValidatorHash] -> Encoding)
-> ToJSON ValidatorHash
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ValidatorHash] -> Encoding
$ctoEncodingList :: [ValidatorHash] -> Encoding
toJSONList :: [ValidatorHash] -> Value
$ctoJSONList :: [ValidatorHash] -> Value
toEncoding :: ValidatorHash -> Encoding
$ctoEncoding :: ValidatorHash -> Encoding
toJSON :: ValidatorHash -> Value
$ctoJSON :: ValidatorHash -> Value
ToJSON, ToJSONKeyFunction [ValidatorHash]
ToJSONKeyFunction ValidatorHash
ToJSONKeyFunction ValidatorHash
-> ToJSONKeyFunction [ValidatorHash] -> ToJSONKey ValidatorHash
forall a.
ToJSONKeyFunction a -> ToJSONKeyFunction [a] -> ToJSONKey a
toJSONKeyList :: ToJSONKeyFunction [ValidatorHash]
$ctoJSONKeyList :: ToJSONKeyFunction [ValidatorHash]
toJSONKey :: ToJSONKeyFunction ValidatorHash
$ctoJSONKey :: ToJSONKeyFunction ValidatorHash
ToJSONKey, FromJSONKeyFunction [ValidatorHash]
FromJSONKeyFunction ValidatorHash
FromJSONKeyFunction ValidatorHash
-> FromJSONKeyFunction [ValidatorHash] -> FromJSONKey ValidatorHash
forall a.
FromJSONKeyFunction a -> FromJSONKeyFunction [a] -> FromJSONKey a
fromJSONKeyList :: FromJSONKeyFunction [ValidatorHash]
$cfromJSONKeyList :: FromJSONKeyFunction [ValidatorHash]
fromJSONKey :: FromJSONKeyFunction ValidatorHash
$cfromJSONKey :: FromJSONKeyFunction ValidatorHash
FromJSONKey, ValidatorHash -> ()
(ValidatorHash -> ()) -> NFData ValidatorHash
forall a. (a -> ()) -> NFData a
rnf :: ValidatorHash -> ()
$crnf :: ValidatorHash -> ()
NFData)

-- | Script runtime representation of a @Digest SHA256@.
newtype DatumHash =
    DatumHash Builtins.BuiltinByteString
    deriving (String -> DatumHash
(String -> DatumHash) -> IsString DatumHash
forall a. (String -> a) -> IsString a
fromString :: String -> DatumHash
$cfromString :: String -> DatumHash
IsString, 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
showList :: [DatumHash] -> ShowS
$cshowList :: [DatumHash] -> ShowS
show :: DatumHash -> String
$cshow :: DatumHash -> String
showsPrec :: Int -> DatumHash -> ShowS
$cshowsPrec :: Int -> DatumHash -> ShowS
Haskell.Show, Decoder s DatumHash
Decoder s [DatumHash]
[DatumHash] -> Encoding
DatumHash -> Encoding
(DatumHash -> Encoding)
-> (forall s. Decoder s DatumHash)
-> ([DatumHash] -> Encoding)
-> (forall s. Decoder s [DatumHash])
-> Serialise DatumHash
forall s. Decoder s [DatumHash]
forall s. Decoder s DatumHash
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: Decoder s [DatumHash]
$cdecodeList :: forall s. Decoder s [DatumHash]
encodeList :: [DatumHash] -> Encoding
$cencodeList :: [DatumHash] -> Encoding
decode :: Decoder s DatumHash
$cdecode :: forall s. Decoder s DatumHash
encode :: DatumHash -> Encoding
$cencode :: DatumHash -> Encoding
Serialise, [DatumHash] -> Doc ann
DatumHash -> Doc ann
(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
prettyList :: [DatumHash] -> Doc ann
$cprettyList :: forall ann. [DatumHash] -> Doc ann
pretty :: DatumHash -> Doc ann
$cpretty :: 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
$cto :: forall x. Rep DatumHash x -> DatumHash
$cfrom :: forall x. DatumHash -> Rep DatumHash x
Generic)
    deriving newtype (DatumHash -> DatumHash -> Bool
(DatumHash -> DatumHash -> Bool)
-> (DatumHash -> DatumHash -> Bool) -> Eq DatumHash
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DatumHash -> DatumHash -> Bool
$c/= :: DatumHash -> DatumHash -> Bool
== :: DatumHash -> DatumHash -> Bool
$c== :: 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
min :: DatumHash -> DatumHash -> DatumHash
$cmin :: DatumHash -> DatumHash -> DatumHash
max :: DatumHash -> DatumHash -> DatumHash
$cmax :: DatumHash -> DatumHash -> DatumHash
>= :: DatumHash -> DatumHash -> Bool
$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
compare :: DatumHash -> DatumHash -> Ordering
$ccompare :: DatumHash -> DatumHash -> Ordering
$cp1Ord :: Eq DatumHash
Haskell.Ord, DatumHash -> DatumHash -> Bool
(DatumHash -> DatumHash -> Bool) -> Eq DatumHash
forall a. (a -> a -> Bool) -> Eq a
== :: DatumHash -> DatumHash -> Bool
$c== :: 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
min :: DatumHash -> DatumHash -> DatumHash
$cmin :: DatumHash -> DatumHash -> DatumHash
max :: DatumHash -> DatumHash -> DatumHash
$cmax :: DatumHash -> DatumHash -> DatumHash
>= :: DatumHash -> DatumHash -> Bool
$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
compare :: DatumHash -> DatumHash -> Ordering
$ccompare :: DatumHash -> DatumHash -> Ordering
$cp1Ord :: Eq DatumHash
Ord, Int -> DatumHash -> Int
DatumHash -> Int
(Int -> DatumHash -> Int)
-> (DatumHash -> Int) -> Hashable DatumHash
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: DatumHash -> Int
$chash :: DatumHash -> Int
hashWithSalt :: Int -> DatumHash -> Int
$chashWithSalt :: Int -> DatumHash -> Int
Hashable, DatumHash -> BuiltinData
(DatumHash -> BuiltinData) -> ToData DatumHash
forall a. (a -> BuiltinData) -> ToData a
toBuiltinData :: DatumHash -> BuiltinData
$ctoBuiltinData :: DatumHash -> BuiltinData
ToData, BuiltinData -> Maybe DatumHash
(BuiltinData -> Maybe DatumHash) -> FromData DatumHash
forall a. (BuiltinData -> Maybe a) -> FromData a
fromBuiltinData :: BuiltinData -> Maybe DatumHash
$cfromBuiltinData :: BuiltinData -> Maybe DatumHash
FromData, BuiltinData -> DatumHash
(BuiltinData -> DatumHash) -> UnsafeFromData DatumHash
forall a. (BuiltinData -> a) -> UnsafeFromData a
unsafeFromBuiltinData :: BuiltinData -> DatumHash
$cunsafeFromBuiltinData :: BuiltinData -> DatumHash
UnsafeFromData)
    deriving anyclass (Value -> Parser [DatumHash]
Value -> Parser DatumHash
(Value -> Parser DatumHash)
-> (Value -> Parser [DatumHash]) -> FromJSON DatumHash
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [DatumHash]
$cparseJSONList :: Value -> Parser [DatumHash]
parseJSON :: Value -> Parser DatumHash
$cparseJSON :: Value -> Parser DatumHash
FromJSON, [DatumHash] -> Encoding
[DatumHash] -> Value
DatumHash -> Encoding
DatumHash -> Value
(DatumHash -> Value)
-> (DatumHash -> Encoding)
-> ([DatumHash] -> Value)
-> ([DatumHash] -> Encoding)
-> ToJSON DatumHash
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [DatumHash] -> Encoding
$ctoEncodingList :: [DatumHash] -> Encoding
toJSONList :: [DatumHash] -> Value
$ctoJSONList :: [DatumHash] -> Value
toEncoding :: DatumHash -> Encoding
$ctoEncoding :: DatumHash -> Encoding
toJSON :: DatumHash -> Value
$ctoJSON :: DatumHash -> Value
ToJSON, ToJSONKeyFunction [DatumHash]
ToJSONKeyFunction DatumHash
ToJSONKeyFunction DatumHash
-> ToJSONKeyFunction [DatumHash] -> ToJSONKey DatumHash
forall a.
ToJSONKeyFunction a -> ToJSONKeyFunction [a] -> ToJSONKey a
toJSONKeyList :: ToJSONKeyFunction [DatumHash]
$ctoJSONKeyList :: ToJSONKeyFunction [DatumHash]
toJSONKey :: ToJSONKeyFunction DatumHash
$ctoJSONKey :: ToJSONKeyFunction DatumHash
ToJSONKey, FromJSONKeyFunction [DatumHash]
FromJSONKeyFunction DatumHash
FromJSONKeyFunction DatumHash
-> FromJSONKeyFunction [DatumHash] -> FromJSONKey DatumHash
forall a.
FromJSONKeyFunction a -> FromJSONKeyFunction [a] -> FromJSONKey a
fromJSONKeyList :: FromJSONKeyFunction [DatumHash]
$cfromJSONKeyList :: FromJSONKeyFunction [DatumHash]
fromJSONKey :: FromJSONKeyFunction DatumHash
$cfromJSONKey :: FromJSONKeyFunction DatumHash
FromJSONKey, DatumHash -> ()
(DatumHash -> ()) -> NFData DatumHash
forall a. (a -> ()) -> NFData a
rnf :: DatumHash -> ()
$crnf :: DatumHash -> ()
NFData)

-- | Script runtime representation of a @Digest SHA256@.
newtype RedeemerHash =
    RedeemerHash Builtins.BuiltinByteString
    deriving (String -> RedeemerHash
(String -> RedeemerHash) -> IsString RedeemerHash
forall a. (String -> a) -> IsString a
fromString :: String -> RedeemerHash
$cfromString :: String -> RedeemerHash
IsString, 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
showList :: [RedeemerHash] -> ShowS
$cshowList :: [RedeemerHash] -> ShowS
show :: RedeemerHash -> String
$cshow :: RedeemerHash -> String
showsPrec :: Int -> RedeemerHash -> ShowS
$cshowsPrec :: Int -> RedeemerHash -> ShowS
Haskell.Show, Decoder s RedeemerHash
Decoder s [RedeemerHash]
[RedeemerHash] -> Encoding
RedeemerHash -> Encoding
(RedeemerHash -> Encoding)
-> (forall s. Decoder s RedeemerHash)
-> ([RedeemerHash] -> Encoding)
-> (forall s. Decoder s [RedeemerHash])
-> Serialise RedeemerHash
forall s. Decoder s [RedeemerHash]
forall s. Decoder s RedeemerHash
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: Decoder s [RedeemerHash]
$cdecodeList :: forall s. Decoder s [RedeemerHash]
encodeList :: [RedeemerHash] -> Encoding
$cencodeList :: [RedeemerHash] -> Encoding
decode :: Decoder s RedeemerHash
$cdecode :: forall s. Decoder s RedeemerHash
encode :: RedeemerHash -> Encoding
$cencode :: RedeemerHash -> Encoding
Serialise, [RedeemerHash] -> Doc ann
RedeemerHash -> Doc ann
(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
prettyList :: [RedeemerHash] -> Doc ann
$cprettyList :: forall ann. [RedeemerHash] -> Doc ann
pretty :: RedeemerHash -> Doc ann
$cpretty :: 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
$cto :: forall x. Rep RedeemerHash x -> RedeemerHash
$cfrom :: forall x. RedeemerHash -> Rep RedeemerHash x
Generic)
    deriving newtype (RedeemerHash -> RedeemerHash -> Bool
(RedeemerHash -> RedeemerHash -> Bool)
-> (RedeemerHash -> RedeemerHash -> Bool) -> Eq RedeemerHash
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RedeemerHash -> RedeemerHash -> Bool
$c/= :: RedeemerHash -> RedeemerHash -> Bool
== :: RedeemerHash -> RedeemerHash -> Bool
$c== :: 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
min :: RedeemerHash -> RedeemerHash -> RedeemerHash
$cmin :: RedeemerHash -> RedeemerHash -> RedeemerHash
max :: RedeemerHash -> RedeemerHash -> RedeemerHash
$cmax :: RedeemerHash -> RedeemerHash -> RedeemerHash
>= :: RedeemerHash -> RedeemerHash -> Bool
$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
compare :: RedeemerHash -> RedeemerHash -> Ordering
$ccompare :: RedeemerHash -> RedeemerHash -> Ordering
$cp1Ord :: Eq RedeemerHash
Haskell.Ord, RedeemerHash -> RedeemerHash -> Bool
(RedeemerHash -> RedeemerHash -> Bool) -> Eq RedeemerHash
forall a. (a -> a -> Bool) -> Eq a
== :: RedeemerHash -> RedeemerHash -> Bool
$c== :: 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
min :: RedeemerHash -> RedeemerHash -> RedeemerHash
$cmin :: RedeemerHash -> RedeemerHash -> RedeemerHash
max :: RedeemerHash -> RedeemerHash -> RedeemerHash
$cmax :: RedeemerHash -> RedeemerHash -> RedeemerHash
>= :: RedeemerHash -> RedeemerHash -> Bool
$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
compare :: RedeemerHash -> RedeemerHash -> Ordering
$ccompare :: RedeemerHash -> RedeemerHash -> Ordering
$cp1Ord :: Eq RedeemerHash
Ord, Int -> RedeemerHash -> Int
RedeemerHash -> Int
(Int -> RedeemerHash -> Int)
-> (RedeemerHash -> Int) -> Hashable RedeemerHash
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: RedeemerHash -> Int
$chash :: RedeemerHash -> Int
hashWithSalt :: Int -> RedeemerHash -> Int
$chashWithSalt :: Int -> RedeemerHash -> Int
Hashable, RedeemerHash -> BuiltinData
(RedeemerHash -> BuiltinData) -> ToData RedeemerHash
forall a. (a -> BuiltinData) -> ToData a
toBuiltinData :: RedeemerHash -> BuiltinData
$ctoBuiltinData :: RedeemerHash -> BuiltinData
ToData, BuiltinData -> Maybe RedeemerHash
(BuiltinData -> Maybe RedeemerHash) -> FromData RedeemerHash
forall a. (BuiltinData -> Maybe a) -> FromData a
fromBuiltinData :: BuiltinData -> Maybe RedeemerHash
$cfromBuiltinData :: BuiltinData -> Maybe RedeemerHash
FromData, BuiltinData -> RedeemerHash
(BuiltinData -> RedeemerHash) -> UnsafeFromData RedeemerHash
forall a. (BuiltinData -> a) -> UnsafeFromData a
unsafeFromBuiltinData :: BuiltinData -> RedeemerHash
$cunsafeFromBuiltinData :: BuiltinData -> RedeemerHash
UnsafeFromData)
    deriving anyclass (Value -> Parser [RedeemerHash]
Value -> Parser RedeemerHash
(Value -> Parser RedeemerHash)
-> (Value -> Parser [RedeemerHash]) -> FromJSON RedeemerHash
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [RedeemerHash]
$cparseJSONList :: Value -> Parser [RedeemerHash]
parseJSON :: Value -> Parser RedeemerHash
$cparseJSON :: Value -> Parser RedeemerHash
FromJSON, [RedeemerHash] -> Encoding
[RedeemerHash] -> Value
RedeemerHash -> Encoding
RedeemerHash -> Value
(RedeemerHash -> Value)
-> (RedeemerHash -> Encoding)
-> ([RedeemerHash] -> Value)
-> ([RedeemerHash] -> Encoding)
-> ToJSON RedeemerHash
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [RedeemerHash] -> Encoding
$ctoEncodingList :: [RedeemerHash] -> Encoding
toJSONList :: [RedeemerHash] -> Value
$ctoJSONList :: [RedeemerHash] -> Value
toEncoding :: RedeemerHash -> Encoding
$ctoEncoding :: RedeemerHash -> Encoding
toJSON :: RedeemerHash -> Value
$ctoJSON :: RedeemerHash -> Value
ToJSON, ToJSONKeyFunction [RedeemerHash]
ToJSONKeyFunction RedeemerHash
ToJSONKeyFunction RedeemerHash
-> ToJSONKeyFunction [RedeemerHash] -> ToJSONKey RedeemerHash
forall a.
ToJSONKeyFunction a -> ToJSONKeyFunction [a] -> ToJSONKey a
toJSONKeyList :: ToJSONKeyFunction [RedeemerHash]
$ctoJSONKeyList :: ToJSONKeyFunction [RedeemerHash]
toJSONKey :: ToJSONKeyFunction RedeemerHash
$ctoJSONKey :: ToJSONKeyFunction RedeemerHash
ToJSONKey, FromJSONKeyFunction [RedeemerHash]
FromJSONKeyFunction RedeemerHash
FromJSONKeyFunction RedeemerHash
-> FromJSONKeyFunction [RedeemerHash] -> FromJSONKey RedeemerHash
forall a.
FromJSONKeyFunction a -> FromJSONKeyFunction [a] -> FromJSONKey a
fromJSONKeyList :: FromJSONKeyFunction [RedeemerHash]
$cfromJSONKeyList :: FromJSONKeyFunction [RedeemerHash]
fromJSONKey :: FromJSONKeyFunction RedeemerHash
$cfromJSONKey :: FromJSONKeyFunction RedeemerHash
FromJSONKey, RedeemerHash -> ()
(RedeemerHash -> ()) -> NFData RedeemerHash
forall a. (a -> ()) -> NFData a
rnf :: RedeemerHash -> ()
$crnf :: RedeemerHash -> ()
NFData)

-- | Script runtime representation of a @Digest SHA256@.
newtype MintingPolicyHash =
    MintingPolicyHash Builtins.BuiltinByteString
    deriving (String -> MintingPolicyHash
(String -> MintingPolicyHash) -> IsString MintingPolicyHash
forall a. (String -> a) -> IsString a
fromString :: String -> MintingPolicyHash
$cfromString :: String -> MintingPolicyHash
IsString, Int -> MintingPolicyHash -> ShowS
[MintingPolicyHash] -> ShowS
MintingPolicyHash -> String
(Int -> MintingPolicyHash -> ShowS)
-> (MintingPolicyHash -> String)
-> ([MintingPolicyHash] -> ShowS)
-> Show MintingPolicyHash
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MintingPolicyHash] -> ShowS
$cshowList :: [MintingPolicyHash] -> ShowS
show :: MintingPolicyHash -> String
$cshow :: MintingPolicyHash -> String
showsPrec :: Int -> MintingPolicyHash -> ShowS
$cshowsPrec :: Int -> MintingPolicyHash -> ShowS
Haskell.Show, Decoder s MintingPolicyHash
Decoder s [MintingPolicyHash]
[MintingPolicyHash] -> Encoding
MintingPolicyHash -> Encoding
(MintingPolicyHash -> Encoding)
-> (forall s. Decoder s MintingPolicyHash)
-> ([MintingPolicyHash] -> Encoding)
-> (forall s. Decoder s [MintingPolicyHash])
-> Serialise MintingPolicyHash
forall s. Decoder s [MintingPolicyHash]
forall s. Decoder s MintingPolicyHash
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: Decoder s [MintingPolicyHash]
$cdecodeList :: forall s. Decoder s [MintingPolicyHash]
encodeList :: [MintingPolicyHash] -> Encoding
$cencodeList :: [MintingPolicyHash] -> Encoding
decode :: Decoder s MintingPolicyHash
$cdecode :: forall s. Decoder s MintingPolicyHash
encode :: MintingPolicyHash -> Encoding
$cencode :: MintingPolicyHash -> Encoding
Serialise, [MintingPolicyHash] -> Doc ann
MintingPolicyHash -> Doc ann
(forall ann. MintingPolicyHash -> Doc ann)
-> (forall ann. [MintingPolicyHash] -> Doc ann)
-> Pretty MintingPolicyHash
forall ann. [MintingPolicyHash] -> Doc ann
forall ann. MintingPolicyHash -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
prettyList :: [MintingPolicyHash] -> Doc ann
$cprettyList :: forall ann. [MintingPolicyHash] -> Doc ann
pretty :: MintingPolicyHash -> Doc ann
$cpretty :: forall ann. MintingPolicyHash -> Doc ann
Pretty) via LedgerBytes
    deriving stock ((forall x. MintingPolicyHash -> Rep MintingPolicyHash x)
-> (forall x. Rep MintingPolicyHash x -> MintingPolicyHash)
-> Generic MintingPolicyHash
forall x. Rep MintingPolicyHash x -> MintingPolicyHash
forall x. MintingPolicyHash -> Rep MintingPolicyHash x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MintingPolicyHash x -> MintingPolicyHash
$cfrom :: forall x. MintingPolicyHash -> Rep MintingPolicyHash x
Generic)
    deriving newtype (MintingPolicyHash -> MintingPolicyHash -> Bool
(MintingPolicyHash -> MintingPolicyHash -> Bool)
-> (MintingPolicyHash -> MintingPolicyHash -> Bool)
-> Eq MintingPolicyHash
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MintingPolicyHash -> MintingPolicyHash -> Bool
$c/= :: MintingPolicyHash -> MintingPolicyHash -> Bool
== :: MintingPolicyHash -> MintingPolicyHash -> Bool
$c== :: MintingPolicyHash -> MintingPolicyHash -> Bool
Haskell.Eq, Eq MintingPolicyHash
Eq MintingPolicyHash
-> (MintingPolicyHash -> MintingPolicyHash -> Ordering)
-> (MintingPolicyHash -> MintingPolicyHash -> Bool)
-> (MintingPolicyHash -> MintingPolicyHash -> Bool)
-> (MintingPolicyHash -> MintingPolicyHash -> Bool)
-> (MintingPolicyHash -> MintingPolicyHash -> Bool)
-> (MintingPolicyHash -> MintingPolicyHash -> MintingPolicyHash)
-> (MintingPolicyHash -> MintingPolicyHash -> MintingPolicyHash)
-> Ord MintingPolicyHash
MintingPolicyHash -> MintingPolicyHash -> Bool
MintingPolicyHash -> MintingPolicyHash -> Ordering
MintingPolicyHash -> MintingPolicyHash -> MintingPolicyHash
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
min :: MintingPolicyHash -> MintingPolicyHash -> MintingPolicyHash
$cmin :: MintingPolicyHash -> MintingPolicyHash -> MintingPolicyHash
max :: MintingPolicyHash -> MintingPolicyHash -> MintingPolicyHash
$cmax :: MintingPolicyHash -> MintingPolicyHash -> MintingPolicyHash
>= :: MintingPolicyHash -> MintingPolicyHash -> Bool
$c>= :: MintingPolicyHash -> MintingPolicyHash -> Bool
> :: MintingPolicyHash -> MintingPolicyHash -> Bool
$c> :: MintingPolicyHash -> MintingPolicyHash -> Bool
<= :: MintingPolicyHash -> MintingPolicyHash -> Bool
$c<= :: MintingPolicyHash -> MintingPolicyHash -> Bool
< :: MintingPolicyHash -> MintingPolicyHash -> Bool
$c< :: MintingPolicyHash -> MintingPolicyHash -> Bool
compare :: MintingPolicyHash -> MintingPolicyHash -> Ordering
$ccompare :: MintingPolicyHash -> MintingPolicyHash -> Ordering
$cp1Ord :: Eq MintingPolicyHash
Haskell.Ord, MintingPolicyHash -> MintingPolicyHash -> Bool
(MintingPolicyHash -> MintingPolicyHash -> Bool)
-> Eq MintingPolicyHash
forall a. (a -> a -> Bool) -> Eq a
== :: MintingPolicyHash -> MintingPolicyHash -> Bool
$c== :: MintingPolicyHash -> MintingPolicyHash -> Bool
Eq, Eq MintingPolicyHash
Eq MintingPolicyHash
-> (MintingPolicyHash -> MintingPolicyHash -> Ordering)
-> (MintingPolicyHash -> MintingPolicyHash -> Bool)
-> (MintingPolicyHash -> MintingPolicyHash -> Bool)
-> (MintingPolicyHash -> MintingPolicyHash -> Bool)
-> (MintingPolicyHash -> MintingPolicyHash -> Bool)
-> (MintingPolicyHash -> MintingPolicyHash -> MintingPolicyHash)
-> (MintingPolicyHash -> MintingPolicyHash -> MintingPolicyHash)
-> Ord MintingPolicyHash
MintingPolicyHash -> MintingPolicyHash -> Bool
MintingPolicyHash -> MintingPolicyHash -> Ordering
MintingPolicyHash -> MintingPolicyHash -> MintingPolicyHash
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
min :: MintingPolicyHash -> MintingPolicyHash -> MintingPolicyHash
$cmin :: MintingPolicyHash -> MintingPolicyHash -> MintingPolicyHash
max :: MintingPolicyHash -> MintingPolicyHash -> MintingPolicyHash
$cmax :: MintingPolicyHash -> MintingPolicyHash -> MintingPolicyHash
>= :: MintingPolicyHash -> MintingPolicyHash -> Bool
$c>= :: MintingPolicyHash -> MintingPolicyHash -> Bool
> :: MintingPolicyHash -> MintingPolicyHash -> Bool
$c> :: MintingPolicyHash -> MintingPolicyHash -> Bool
<= :: MintingPolicyHash -> MintingPolicyHash -> Bool
$c<= :: MintingPolicyHash -> MintingPolicyHash -> Bool
< :: MintingPolicyHash -> MintingPolicyHash -> Bool
$c< :: MintingPolicyHash -> MintingPolicyHash -> Bool
compare :: MintingPolicyHash -> MintingPolicyHash -> Ordering
$ccompare :: MintingPolicyHash -> MintingPolicyHash -> Ordering
$cp1Ord :: Eq MintingPolicyHash
Ord, Int -> MintingPolicyHash -> Int
MintingPolicyHash -> Int
(Int -> MintingPolicyHash -> Int)
-> (MintingPolicyHash -> Int) -> Hashable MintingPolicyHash
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: MintingPolicyHash -> Int
$chash :: MintingPolicyHash -> Int
hashWithSalt :: Int -> MintingPolicyHash -> Int
$chashWithSalt :: Int -> MintingPolicyHash -> Int
Hashable, MintingPolicyHash -> BuiltinData
(MintingPolicyHash -> BuiltinData) -> ToData MintingPolicyHash
forall a. (a -> BuiltinData) -> ToData a
toBuiltinData :: MintingPolicyHash -> BuiltinData
$ctoBuiltinData :: MintingPolicyHash -> BuiltinData
ToData, BuiltinData -> Maybe MintingPolicyHash
(BuiltinData -> Maybe MintingPolicyHash)
-> FromData MintingPolicyHash
forall a. (BuiltinData -> Maybe a) -> FromData a
fromBuiltinData :: BuiltinData -> Maybe MintingPolicyHash
$cfromBuiltinData :: BuiltinData -> Maybe MintingPolicyHash
FromData, BuiltinData -> MintingPolicyHash
(BuiltinData -> MintingPolicyHash)
-> UnsafeFromData MintingPolicyHash
forall a. (BuiltinData -> a) -> UnsafeFromData a
unsafeFromBuiltinData :: BuiltinData -> MintingPolicyHash
$cunsafeFromBuiltinData :: BuiltinData -> MintingPolicyHash
UnsafeFromData)
    deriving anyclass (Value -> Parser [MintingPolicyHash]
Value -> Parser MintingPolicyHash
(Value -> Parser MintingPolicyHash)
-> (Value -> Parser [MintingPolicyHash])
-> FromJSON MintingPolicyHash
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [MintingPolicyHash]
$cparseJSONList :: Value -> Parser [MintingPolicyHash]
parseJSON :: Value -> Parser MintingPolicyHash
$cparseJSON :: Value -> Parser MintingPolicyHash
FromJSON, [MintingPolicyHash] -> Encoding
[MintingPolicyHash] -> Value
MintingPolicyHash -> Encoding
MintingPolicyHash -> Value
(MintingPolicyHash -> Value)
-> (MintingPolicyHash -> Encoding)
-> ([MintingPolicyHash] -> Value)
-> ([MintingPolicyHash] -> Encoding)
-> ToJSON MintingPolicyHash
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [MintingPolicyHash] -> Encoding
$ctoEncodingList :: [MintingPolicyHash] -> Encoding
toJSONList :: [MintingPolicyHash] -> Value
$ctoJSONList :: [MintingPolicyHash] -> Value
toEncoding :: MintingPolicyHash -> Encoding
$ctoEncoding :: MintingPolicyHash -> Encoding
toJSON :: MintingPolicyHash -> Value
$ctoJSON :: MintingPolicyHash -> Value
ToJSON, ToJSONKeyFunction [MintingPolicyHash]
ToJSONKeyFunction MintingPolicyHash
ToJSONKeyFunction MintingPolicyHash
-> ToJSONKeyFunction [MintingPolicyHash]
-> ToJSONKey MintingPolicyHash
forall a.
ToJSONKeyFunction a -> ToJSONKeyFunction [a] -> ToJSONKey a
toJSONKeyList :: ToJSONKeyFunction [MintingPolicyHash]
$ctoJSONKeyList :: ToJSONKeyFunction [MintingPolicyHash]
toJSONKey :: ToJSONKeyFunction MintingPolicyHash
$ctoJSONKey :: ToJSONKeyFunction MintingPolicyHash
ToJSONKey, FromJSONKeyFunction [MintingPolicyHash]
FromJSONKeyFunction MintingPolicyHash
FromJSONKeyFunction MintingPolicyHash
-> FromJSONKeyFunction [MintingPolicyHash]
-> FromJSONKey MintingPolicyHash
forall a.
FromJSONKeyFunction a -> FromJSONKeyFunction [a] -> FromJSONKey a
fromJSONKeyList :: FromJSONKeyFunction [MintingPolicyHash]
$cfromJSONKeyList :: FromJSONKeyFunction [MintingPolicyHash]
fromJSONKey :: FromJSONKeyFunction MintingPolicyHash
$cfromJSONKey :: FromJSONKeyFunction MintingPolicyHash
FromJSONKey)

-- | Script runtime representation of a @Digest SHA256@.
newtype StakeValidatorHash =
    StakeValidatorHash Builtins.BuiltinByteString
    deriving (String -> StakeValidatorHash
(String -> StakeValidatorHash) -> IsString StakeValidatorHash
forall a. (String -> a) -> IsString a
fromString :: String -> StakeValidatorHash
$cfromString :: String -> StakeValidatorHash
IsString, Int -> StakeValidatorHash -> ShowS
[StakeValidatorHash] -> ShowS
StakeValidatorHash -> String
(Int -> StakeValidatorHash -> ShowS)
-> (StakeValidatorHash -> String)
-> ([StakeValidatorHash] -> ShowS)
-> Show StakeValidatorHash
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StakeValidatorHash] -> ShowS
$cshowList :: [StakeValidatorHash] -> ShowS
show :: StakeValidatorHash -> String
$cshow :: StakeValidatorHash -> String
showsPrec :: Int -> StakeValidatorHash -> ShowS
$cshowsPrec :: Int -> StakeValidatorHash -> ShowS
Haskell.Show, Decoder s StakeValidatorHash
Decoder s [StakeValidatorHash]
[StakeValidatorHash] -> Encoding
StakeValidatorHash -> Encoding
(StakeValidatorHash -> Encoding)
-> (forall s. Decoder s StakeValidatorHash)
-> ([StakeValidatorHash] -> Encoding)
-> (forall s. Decoder s [StakeValidatorHash])
-> Serialise StakeValidatorHash
forall s. Decoder s [StakeValidatorHash]
forall s. Decoder s StakeValidatorHash
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: Decoder s [StakeValidatorHash]
$cdecodeList :: forall s. Decoder s [StakeValidatorHash]
encodeList :: [StakeValidatorHash] -> Encoding
$cencodeList :: [StakeValidatorHash] -> Encoding
decode :: Decoder s StakeValidatorHash
$cdecode :: forall s. Decoder s StakeValidatorHash
encode :: StakeValidatorHash -> Encoding
$cencode :: StakeValidatorHash -> Encoding
Serialise, [StakeValidatorHash] -> Doc ann
StakeValidatorHash -> Doc ann
(forall ann. StakeValidatorHash -> Doc ann)
-> (forall ann. [StakeValidatorHash] -> Doc ann)
-> Pretty StakeValidatorHash
forall ann. [StakeValidatorHash] -> Doc ann
forall ann. StakeValidatorHash -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
prettyList :: [StakeValidatorHash] -> Doc ann
$cprettyList :: forall ann. [StakeValidatorHash] -> Doc ann
pretty :: StakeValidatorHash -> Doc ann
$cpretty :: forall ann. StakeValidatorHash -> Doc ann
Pretty) via LedgerBytes
    deriving stock ((forall x. StakeValidatorHash -> Rep StakeValidatorHash x)
-> (forall x. Rep StakeValidatorHash x -> StakeValidatorHash)
-> Generic StakeValidatorHash
forall x. Rep StakeValidatorHash x -> StakeValidatorHash
forall x. StakeValidatorHash -> Rep StakeValidatorHash x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StakeValidatorHash x -> StakeValidatorHash
$cfrom :: forall x. StakeValidatorHash -> Rep StakeValidatorHash x
Generic)
    deriving newtype (StakeValidatorHash -> StakeValidatorHash -> Bool
(StakeValidatorHash -> StakeValidatorHash -> Bool)
-> (StakeValidatorHash -> StakeValidatorHash -> Bool)
-> Eq StakeValidatorHash
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StakeValidatorHash -> StakeValidatorHash -> Bool
$c/= :: StakeValidatorHash -> StakeValidatorHash -> Bool
== :: StakeValidatorHash -> StakeValidatorHash -> Bool
$c== :: StakeValidatorHash -> StakeValidatorHash -> Bool
Haskell.Eq, Eq StakeValidatorHash
Eq StakeValidatorHash
-> (StakeValidatorHash -> StakeValidatorHash -> Ordering)
-> (StakeValidatorHash -> StakeValidatorHash -> Bool)
-> (StakeValidatorHash -> StakeValidatorHash -> Bool)
-> (StakeValidatorHash -> StakeValidatorHash -> Bool)
-> (StakeValidatorHash -> StakeValidatorHash -> Bool)
-> (StakeValidatorHash -> StakeValidatorHash -> StakeValidatorHash)
-> (StakeValidatorHash -> StakeValidatorHash -> StakeValidatorHash)
-> Ord StakeValidatorHash
StakeValidatorHash -> StakeValidatorHash -> Bool
StakeValidatorHash -> StakeValidatorHash -> Ordering
StakeValidatorHash -> StakeValidatorHash -> StakeValidatorHash
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
min :: StakeValidatorHash -> StakeValidatorHash -> StakeValidatorHash
$cmin :: StakeValidatorHash -> StakeValidatorHash -> StakeValidatorHash
max :: StakeValidatorHash -> StakeValidatorHash -> StakeValidatorHash
$cmax :: StakeValidatorHash -> StakeValidatorHash -> StakeValidatorHash
>= :: StakeValidatorHash -> StakeValidatorHash -> Bool
$c>= :: StakeValidatorHash -> StakeValidatorHash -> Bool
> :: StakeValidatorHash -> StakeValidatorHash -> Bool
$c> :: StakeValidatorHash -> StakeValidatorHash -> Bool
<= :: StakeValidatorHash -> StakeValidatorHash -> Bool
$c<= :: StakeValidatorHash -> StakeValidatorHash -> Bool
< :: StakeValidatorHash -> StakeValidatorHash -> Bool
$c< :: StakeValidatorHash -> StakeValidatorHash -> Bool
compare :: StakeValidatorHash -> StakeValidatorHash -> Ordering
$ccompare :: StakeValidatorHash -> StakeValidatorHash -> Ordering
$cp1Ord :: Eq StakeValidatorHash
Haskell.Ord, StakeValidatorHash -> StakeValidatorHash -> Bool
(StakeValidatorHash -> StakeValidatorHash -> Bool)
-> Eq StakeValidatorHash
forall a. (a -> a -> Bool) -> Eq a
== :: StakeValidatorHash -> StakeValidatorHash -> Bool
$c== :: StakeValidatorHash -> StakeValidatorHash -> Bool
Eq, Eq StakeValidatorHash
Eq StakeValidatorHash
-> (StakeValidatorHash -> StakeValidatorHash -> Ordering)
-> (StakeValidatorHash -> StakeValidatorHash -> Bool)
-> (StakeValidatorHash -> StakeValidatorHash -> Bool)
-> (StakeValidatorHash -> StakeValidatorHash -> Bool)
-> (StakeValidatorHash -> StakeValidatorHash -> Bool)
-> (StakeValidatorHash -> StakeValidatorHash -> StakeValidatorHash)
-> (StakeValidatorHash -> StakeValidatorHash -> StakeValidatorHash)
-> Ord StakeValidatorHash
StakeValidatorHash -> StakeValidatorHash -> Bool
StakeValidatorHash -> StakeValidatorHash -> Ordering
StakeValidatorHash -> StakeValidatorHash -> StakeValidatorHash
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
min :: StakeValidatorHash -> StakeValidatorHash -> StakeValidatorHash
$cmin :: StakeValidatorHash -> StakeValidatorHash -> StakeValidatorHash
max :: StakeValidatorHash -> StakeValidatorHash -> StakeValidatorHash
$cmax :: StakeValidatorHash -> StakeValidatorHash -> StakeValidatorHash
>= :: StakeValidatorHash -> StakeValidatorHash -> Bool
$c>= :: StakeValidatorHash -> StakeValidatorHash -> Bool
> :: StakeValidatorHash -> StakeValidatorHash -> Bool
$c> :: StakeValidatorHash -> StakeValidatorHash -> Bool
<= :: StakeValidatorHash -> StakeValidatorHash -> Bool
$c<= :: StakeValidatorHash -> StakeValidatorHash -> Bool
< :: StakeValidatorHash -> StakeValidatorHash -> Bool
$c< :: StakeValidatorHash -> StakeValidatorHash -> Bool
compare :: StakeValidatorHash -> StakeValidatorHash -> Ordering
$ccompare :: StakeValidatorHash -> StakeValidatorHash -> Ordering
$cp1Ord :: Eq StakeValidatorHash
Ord, Int -> StakeValidatorHash -> Int
StakeValidatorHash -> Int
(Int -> StakeValidatorHash -> Int)
-> (StakeValidatorHash -> Int) -> Hashable StakeValidatorHash
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: StakeValidatorHash -> Int
$chash :: StakeValidatorHash -> Int
hashWithSalt :: Int -> StakeValidatorHash -> Int
$chashWithSalt :: Int -> StakeValidatorHash -> Int
Hashable, StakeValidatorHash -> BuiltinData
(StakeValidatorHash -> BuiltinData) -> ToData StakeValidatorHash
forall a. (a -> BuiltinData) -> ToData a
toBuiltinData :: StakeValidatorHash -> BuiltinData
$ctoBuiltinData :: StakeValidatorHash -> BuiltinData
ToData, BuiltinData -> Maybe StakeValidatorHash
(BuiltinData -> Maybe StakeValidatorHash)
-> FromData StakeValidatorHash
forall a. (BuiltinData -> Maybe a) -> FromData a
fromBuiltinData :: BuiltinData -> Maybe StakeValidatorHash
$cfromBuiltinData :: BuiltinData -> Maybe StakeValidatorHash
FromData, BuiltinData -> StakeValidatorHash
(BuiltinData -> StakeValidatorHash)
-> UnsafeFromData StakeValidatorHash
forall a. (BuiltinData -> a) -> UnsafeFromData a
unsafeFromBuiltinData :: BuiltinData -> StakeValidatorHash
$cunsafeFromBuiltinData :: BuiltinData -> StakeValidatorHash
UnsafeFromData)
    deriving anyclass (Value -> Parser [StakeValidatorHash]
Value -> Parser StakeValidatorHash
(Value -> Parser StakeValidatorHash)
-> (Value -> Parser [StakeValidatorHash])
-> FromJSON StakeValidatorHash
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [StakeValidatorHash]
$cparseJSONList :: Value -> Parser [StakeValidatorHash]
parseJSON :: Value -> Parser StakeValidatorHash
$cparseJSON :: Value -> Parser StakeValidatorHash
FromJSON, [StakeValidatorHash] -> Encoding
[StakeValidatorHash] -> Value
StakeValidatorHash -> Encoding
StakeValidatorHash -> Value
(StakeValidatorHash -> Value)
-> (StakeValidatorHash -> Encoding)
-> ([StakeValidatorHash] -> Value)
-> ([StakeValidatorHash] -> Encoding)
-> ToJSON StakeValidatorHash
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [StakeValidatorHash] -> Encoding
$ctoEncodingList :: [StakeValidatorHash] -> Encoding
toJSONList :: [StakeValidatorHash] -> Value
$ctoJSONList :: [StakeValidatorHash] -> Value
toEncoding :: StakeValidatorHash -> Encoding
$ctoEncoding :: StakeValidatorHash -> Encoding
toJSON :: StakeValidatorHash -> Value
$ctoJSON :: StakeValidatorHash -> Value
ToJSON, ToJSONKeyFunction [StakeValidatorHash]
ToJSONKeyFunction StakeValidatorHash
ToJSONKeyFunction StakeValidatorHash
-> ToJSONKeyFunction [StakeValidatorHash]
-> ToJSONKey StakeValidatorHash
forall a.
ToJSONKeyFunction a -> ToJSONKeyFunction [a] -> ToJSONKey a
toJSONKeyList :: ToJSONKeyFunction [StakeValidatorHash]
$ctoJSONKeyList :: ToJSONKeyFunction [StakeValidatorHash]
toJSONKey :: ToJSONKeyFunction StakeValidatorHash
$ctoJSONKey :: ToJSONKeyFunction StakeValidatorHash
ToJSONKey, FromJSONKeyFunction [StakeValidatorHash]
FromJSONKeyFunction StakeValidatorHash
FromJSONKeyFunction StakeValidatorHash
-> FromJSONKeyFunction [StakeValidatorHash]
-> FromJSONKey StakeValidatorHash
forall a.
FromJSONKeyFunction a -> FromJSONKeyFunction [a] -> FromJSONKey a
fromJSONKeyList :: FromJSONKeyFunction [StakeValidatorHash]
$cfromJSONKeyList :: FromJSONKeyFunction [StakeValidatorHash]
fromJSONKey :: FromJSONKeyFunction StakeValidatorHash
$cfromJSONKey :: FromJSONKeyFunction StakeValidatorHash
FromJSONKey)

-- | 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 ([Context] -> Encoding
[Context] -> Value
Context -> Encoding
Context -> Value
(Context -> Value)
-> (Context -> Encoding)
-> ([Context] -> Value)
-> ([Context] -> Encoding)
-> ToJSON Context
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Context] -> Encoding
$ctoEncodingList :: [Context] -> Encoding
toJSONList :: [Context] -> Value
$ctoJSONList :: [Context] -> Value
toEncoding :: Context -> Encoding
$ctoEncoding :: Context -> Encoding
toJSON :: Context -> Value
$ctoJSON :: Context -> Value
ToJSON, Value -> Parser [Context]
Value -> Parser Context
(Value -> Parser Context)
-> (Value -> Parser [Context]) -> FromJSON Context
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [Context]
$cparseJSONList :: Value -> Parser [Context]
parseJSON :: Value -> Parser Context
$cparseJSON :: Value -> Parser Context
FromJSON, [Context] -> Doc ann
Context -> Doc ann
(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
prettyList :: [Context] -> Doc ann
$cprettyList :: forall ann. [Context] -> Doc ann
pretty :: Context -> Doc ann
$cpretty :: 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
showList :: [Context] -> ShowS
$cshowList :: [Context] -> ShowS
show :: Context -> String
$cshow :: Context -> String
showsPrec :: Int -> Context -> ShowS
$cshowsPrec :: Int -> Context -> ShowS
Haskell.Show) via PLC.Data

-- | Apply a 'Validator' to its 'Context', 'Datum', and 'Redeemer'.
applyValidator
    :: Context
    -> Validator
    -> Datum
    -> Redeemer
    -> Script
applyValidator :: Context -> Validator -> Datum -> Redeemer -> Script
applyValidator (Context (BuiltinData Data
valData)) (Validator Script
validator) (Datum (BuiltinData Data
datum)) (Redeemer (BuiltinData Data
redeemer)) =
    Script -> [Data] -> Script
applyArguments Script
validator [Data
datum, Data
redeemer, Data
valData]

-- | Evaluate a 'Validator' with its 'Context', 'Datum', and 'Redeemer', returning the log.
runScript
    :: (MonadError ScriptError m)
    => Context
    -> Validator
    -> Datum
    -> Redeemer
    -> m (PLC.ExBudget, [Text])
runScript :: Context -> Validator -> Datum -> Redeemer -> m (ExBudget, [Text])
runScript Context
context Validator
validator Datum
datum Redeemer
redeemer =
    Script -> m (ExBudget, [Text])
forall (m :: * -> *).
MonadError ScriptError m =>
Script -> m (ExBudget, [Text])
evaluateScript (Context -> Validator -> Datum -> Redeemer -> Script
applyValidator Context
context Validator
validator Datum
datum Redeemer
redeemer)

-- | Apply 'MintingPolicy' to its 'Context' and 'Redeemer'.
applyMintingPolicyScript
    :: Context
    -> MintingPolicy
    -> Redeemer
    -> Script
applyMintingPolicyScript :: Context -> MintingPolicy -> Redeemer -> Script
applyMintingPolicyScript (Context (BuiltinData Data
valData)) (MintingPolicy Script
validator) (Redeemer (BuiltinData Data
red)) =
    Script -> [Data] -> Script
applyArguments Script
validator [Data
red, Data
valData]

-- | Evaluate a 'MintingPolicy' with its 'Context' and 'Redeemer', returning the log.
runMintingPolicyScript
    :: (MonadError ScriptError m)
    => Context
    -> MintingPolicy
    -> Redeemer
    -> m (PLC.ExBudget, [Text])
runMintingPolicyScript :: Context -> MintingPolicy -> Redeemer -> m (ExBudget, [Text])
runMintingPolicyScript Context
context MintingPolicy
mps Redeemer
red =
    Script -> m (ExBudget, [Text])
forall (m :: * -> *).
MonadError ScriptError m =>
Script -> m (ExBudget, [Text])
evaluateScript (Context -> MintingPolicy -> Redeemer -> Script
applyMintingPolicyScript Context
context MintingPolicy
mps Redeemer
red)

-- | Apply 'StakeValidator' to its 'Context' and 'Redeemer'.
applyStakeValidatorScript
    :: Context
    -> StakeValidator
    -> Redeemer
    -> Script
applyStakeValidatorScript :: Context -> StakeValidator -> Redeemer -> Script
applyStakeValidatorScript (Context (BuiltinData Data
valData)) (StakeValidator Script
validator) (Redeemer (BuiltinData Data
red)) =
    Script -> [Data] -> Script
applyArguments Script
validator [Data
red, Data
valData]

-- | Evaluate a 'StakeValidator' with its 'Context' and 'Redeemer', returning the log.
runStakeValidatorScript
    :: (MonadError ScriptError m)
    => Context
    -> StakeValidator
    -> Redeemer
    -> m (PLC.ExBudget, [Text])
runStakeValidatorScript :: Context -> StakeValidator -> Redeemer -> m (ExBudget, [Text])
runStakeValidatorScript Context
context StakeValidator
wps Redeemer
red =
    Script -> m (ExBudget, [Text])
forall (m :: * -> *).
MonadError ScriptError m =>
Script -> m (ExBudget, [Text])
evaluateScript (Context -> StakeValidator -> Redeemer -> Script
applyStakeValidatorScript Context
context StakeValidator
wps Redeemer
red)

-- | @()@ as a datum.
unitDatum :: Datum
unitDatum :: Datum
unitDatum = BuiltinData -> Datum
Datum (BuiltinData -> Datum) -> BuiltinData -> Datum
forall a b. (a -> b) -> a -> b
$ () -> BuiltinData
forall a. ToData a => a -> BuiltinData
toBuiltinData ()

-- | @()@ as a redeemer.
unitRedeemer :: Redeemer
unitRedeemer :: Redeemer
unitRedeemer = BuiltinData -> Redeemer
Redeemer (BuiltinData -> Redeemer) -> BuiltinData -> Redeemer
forall a b. (a -> b) -> a -> b
$ () -> BuiltinData
forall a. ToData a => a -> BuiltinData
toBuiltinData ()

makeLift ''ValidatorHash

makeLift ''MintingPolicyHash

makeLift ''StakeValidatorHash

makeLift ''DatumHash

makeLift ''RedeemerHash

makeLift ''Datum

makeLift ''Redeemer