cardano-ledger-core-1.17.0.0: Core components of Cardano ledgers from the Shelley release on.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Ledger.Plutus.Language

Description

This module provides data structures and operations for talking about Non-native Script languages. It is expected that new languages (or new versions of old languages) will be added here.

Synopsis

Plutus Script

newtype Plutus (l ∷ Language) Source #

Serialized representation of a Plutus script that distinguishes the language version at the type level. When encoded in CBOR language version is also encoded.

Constructors

Plutus 

Instances

Instances details
Generic (Plutus l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Associated Types

type Rep (Plutus l) ∷ TypeType Source #

Methods

fromPlutus l → Rep (Plutus l) x Source #

toRep (Plutus l) x → Plutus l Source #

Show (Plutus l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

showsPrecIntPlutus l → ShowS Source #

showPlutus l → String Source #

showList ∷ [Plutus l] → ShowS Source #

PlutusLanguage l ⇒ DecCBOR (Plutus l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

decCBORDecoder s (Plutus l) Source #

dropCBORProxy (Plutus l) → Decoder s () Source #

labelProxy (Plutus l) → Text Source #

PlutusLanguage l ⇒ EncCBOR (Plutus l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

encCBORPlutus l → Encoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy (Plutus l) → Size Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [Plutus l] → Size Source #

SafeToHash (Plutus l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

NFData (Plutus l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

rnfPlutus l → () Source #

Eq (Plutus l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

(==)Plutus l → Plutus l → Bool Source #

(/=)Plutus l → Plutus l → Bool Source #

Ord (Plutus l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

comparePlutus l → Plutus l → Ordering Source #

(<)Plutus l → Plutus l → Bool Source #

(<=)Plutus l → Plutus l → Bool Source #

(>)Plutus l → Plutus l → Bool Source #

(>=)Plutus l → Plutus l → Bool Source #

maxPlutus l → Plutus l → Plutus l Source #

minPlutus l → Plutus l → Plutus l Source #

NoThunks (Plutus l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

type Rep (Plutus l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

type Rep (Plutus l) = D1 ('MetaData "Plutus" "Cardano.Ledger.Plutus.Language" "cardano-ledger-core-1.17.0.0-inplace" 'True) (C1 ('MetaCons "Plutus" 'PrefixI 'True) (S1 ('MetaSel ('Just "plutusBinary") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PlutusBinary)))

isValidPlutusPlutusLanguage l ⇒ VersionPlutus l → Bool Source #

Verify that the binary version of the Plutus script is deserializable.

newtype PlutusBinary Source #

Binary representation of a Plutus script.

Instances

Instances details
Generic PlutusBinary Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Associated Types

type Rep PlutusBinaryTypeType Source #

Show PlutusBinary Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

FromCBOR PlutusBinary Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

ToCBOR PlutusBinary Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

toCBORPlutusBinaryEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy PlutusBinarySize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [PlutusBinary] → Size Source #

DecCBOR PlutusBinary Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

EncCBOR PlutusBinary Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

SafeToHash PlutusBinary Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

NFData PlutusBinary Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

rnfPlutusBinary → () Source #

Eq PlutusBinary Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Ord PlutusBinary Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

NoThunks PlutusBinary Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

DecCBOR (Annotator PlutusBinary) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

type Rep PlutusBinary Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

type Rep PlutusBinary = D1 ('MetaData "PlutusBinary" "Cardano.Ledger.Plutus.Language" "cardano-ledger-core-1.17.0.0-inplace" 'True) (C1 ('MetaCons "PlutusBinary" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPlutusBinary") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ShortByteString)))

newtype PlutusRunnable (l ∷ Language) Source #

This is a deserialized version of the Plutus type that can be used directly with evaluation functions that rely on evaluatePlutusRunnable.

The only way to obtain this type is by the means of deserializing Plutus with decodePlutusRunnable

Instances

Instances details
Generic (PlutusRunnable l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Associated Types

type Rep (PlutusRunnable l) ∷ TypeType Source #

Show (PlutusRunnable l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

PlutusLanguage l ⇒ DecCBOR (PlutusRunnable l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

PlutusLanguage l ⇒ EncCBOR (PlutusRunnable l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

encCBORPlutusRunnable l → Encoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy (PlutusRunnable l) → Size Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [PlutusRunnable l] → Size Source #

NFData (PlutusRunnable l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

rnfPlutusRunnable l → () Source #

Eq (PlutusRunnable l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

NoThunks (PlutusRunnable l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

type Rep (PlutusRunnable l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

type Rep (PlutusRunnable l) = D1 ('MetaData "PlutusRunnable" "Cardano.Ledger.Plutus.Language" "cardano-ledger-core-1.17.0.0-inplace" 'True) (C1 ('MetaCons "PlutusRunnable" 'PrefixI 'True) (S1 ('MetaSel ('Just "plutusRunnable") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ScriptForEvaluation)))

plutusFromRunnablePlutusRunnable l → Plutus l Source #

Serialize the runnable version of the plutus script

decodePlutusRunnable majVer (plutusFromRunnable pr) == Right pr

decodeWithPlutus ∷ (∀ si l. PlutusLanguage l ⇒ Plutus l → Decoder si a) → Decoder so a Source #

Plutus script decoder that will enforce the type level language equals the one included in the serialization

hashPlutusScript ∷ ∀ l. PlutusLanguage l ⇒ Plutus l → ScriptHash Source #

Compute a ScriptHash of a Plutus script. This function is equivalent to hashScript, except it is restricted to Plutus scripts

Value level Plutus Language version

data Language Source #

Non-Native Plutus Script language. This is expected to be an open type. We will add new Constuctors to this type as additional Plutus language versions as are added. We use an enumerated type for two reasons.

  1. We can write total functions by case analysis over the constructors
  2. We use DataKinds to make some datatypes indexed by Language.

Note that the the serialization of Language depends on the ordering.

Constructors

PlutusV1 
PlutusV2 
PlutusV3 

Instances

Instances details
FromJSON Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

FromJSONKey Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

ToJSON Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

ToJSONKey Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Bounded Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Enum Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Generic Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Associated Types

type Rep LanguageTypeType Source #

Ix Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Read Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Show Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

FromCBOR Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

ToCBOR Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

toCBORLanguageEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy LanguageSize Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [Language] → Size Source #

DecCBOR Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

EncCBOR Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

encCBORLanguageEncoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy LanguageSize Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [Language] → Size Source #

NFData Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

rnfLanguage → () Source #

Eq Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Ord Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

NoThunks Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Random Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

randomRRandomGen g ⇒ (Language, Language) → g → (Language, g) Source #

randomRandomGen g ⇒ g → (Language, g) Source #

randomRsRandomGen g ⇒ (Language, Language) → g → [Language] Source #

randomsRandomGen g ⇒ g → [Language] Source #

Uniform Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

uniformMStatefulGen g m ⇒ g → m Language Source #

UniformRange Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

uniformRMStatefulGen g m ⇒ (Language, Language) → g → m Language Source #

type Rep Language Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

type Rep Language = D1 ('MetaData "Language" "Cardano.Ledger.Plutus.Language" "cardano-ledger-core-1.17.0.0-inplace" 'False) (C1 ('MetaCons "PlutusV1" 'PrefixI 'False) (U1TypeType) :+: (C1 ('MetaCons "PlutusV2" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "PlutusV3" 'PrefixI 'False) (U1TypeType)))

mkLanguageEnumIntMaybe Language Source #

Make a language from its Enum index.

guardPlutusLanguageDecoder s () Source #

Prevent decoding a version of Plutus until the appropriate protocol version.

Type level Plutus Language version

data SLanguage (l ∷ Language) where Source #

Singleton for 'Language'

Instances

Instances details
Show (SLanguage l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

PlutusLanguage l ⇒ FromCBOR (SLanguage l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

PlutusLanguage l ⇒ ToCBOR (SLanguage l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

toCBORSLanguage l → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (SLanguage l) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [SLanguage l] → Size Source #

PlutusLanguage l ⇒ DecCBOR (SLanguage l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

PlutusLanguage l ⇒ EncCBOR (SLanguage l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

encCBORSLanguage l → Encoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy (SLanguage l) → Size Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [SLanguage l] → Size Source #

Eq (SLanguage l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

(==)SLanguage l → SLanguage l → Bool Source #

(/=)SLanguage l → SLanguage l → Bool Source #

class (Typeable l, NFData (PlutusArgs l), EncCBOR (PlutusArgs l), DecCBOR (PlutusArgs l), Pretty (PlutusArgs l), Show (PlutusArgs l), Eq (PlutusArgs l)) ⇒ PlutusLanguage (l ∷ Language) where Source #

For implicit reflection on 'SLanguage' See Cardano.Ledger.Alonzo.Plutus.TxInfo for example usage

Associated Types

data PlutusArgs l ∷ Type Source #

Methods

isLanguageSLanguage l Source #

plutusLanguageTagPlutus l → Word8 Source #

Tag that will be used as a prefix to compute the ScriptHash

decodePlutusRunnable Source #

Arguments

Version

Which major protocol version to use for deserialization and further execution

Plutus l

Binary version of the script that will be deserialized

Either ScriptDecodeError (PlutusRunnable l) 

evaluatePlutusRunnable Source #

Arguments

Version

Which major protocol version to use for script execution

VerboseMode

Whether to produce log output

EvaluationContext

Includes the cost model to use for tallying up the execution costs

ExBudget

The resource budget which must not be exceeded during evaluation

PlutusRunnable l

The script to evaluate

PlutusArgs l

The arguments to the script

→ (LogOutput, Either EvaluationError ExBudget) 

evaluatePlutusRunnableBudget Source #

Arguments

Version

Which major protocol version to use for script execution

VerboseMode

Whether to produce log output

EvaluationContext

Includes the cost model to use for tallying up the execution costs

PlutusRunnable l

The script to evaluate

PlutusArgs l

The arguments to the script

→ (LogOutput, Either EvaluationError ExBudget) 

Similar to evaluatePlutusRunnable, except does not require ExBudget to be provided as input and instead computes it as output. This function is meant to be used for testing.

mkTermToEvaluate Source #

Arguments

Version

Which major protocol version to use for script execution

PlutusRunnable l

The script to evaluate

PlutusArgs l

The arguments to the script

Either EvaluationError (Term NamedDeBruijn DefaultUni DefaultFun ()) 

Instances

Instances details
PlutusLanguage 'PlutusV1 Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Associated Types

data PlutusArgs 'PlutusV1 Source #

PlutusLanguage 'PlutusV2 Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Associated Types

data PlutusArgs 'PlutusV2 Source #

PlutusLanguage 'PlutusV3 Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Associated Types

data PlutusArgs 'PlutusV3 Source #

plutusLanguage ∷ ∀ l proxy. PlutusLanguage l ⇒ proxy l → Language Source #

Construct value level laguage version from the type level

toSLanguage ∷ ∀ l m. (PlutusLanguage l, MonadFail m) ⇒ Language → m (SLanguage l) Source #

withSLanguageLanguage → (∀ l. PlutusLanguage l ⇒ SLanguage l → a) → a Source #

asSLanguageSLanguage l → proxy l → proxy l Source #

withSamePlutusLanguage ∷ ∀ f1 f2 l1 l2 a. (PlutusLanguage l1, PlutusLanguage l2) ⇒ f1 l1 → f2 l2 → (∀ l. PlutusLanguage l ⇒ f1 l → f2 l → a) → Maybe a Source #

Plutus Script Context

data LegacyPlutusArgs l Source #

Constructors

LegacyPlutusArgs2

Scripts that require 2 arguments.

Fields

LegacyPlutusArgs3

Scripts that require 3 arguments. Which is only PlutusV1/V2 spending scripts

Fields

Instances

Instances details
Show (PlutusScriptContext l) ⇒ Show (LegacyPlutusArgs l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

(PlutusLanguage l, FromData (PlutusScriptContext l)) ⇒ DecCBOR (LegacyPlutusArgs l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

(PlutusLanguage l, ToData (PlutusScriptContext l)) ⇒ EncCBOR (LegacyPlutusArgs l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

NFData (PlutusScriptContext l) ⇒ NFData (LegacyPlutusArgs l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Methods

rnfLegacyPlutusArgs l → () Source #

Eq (PlutusScriptContext l) ⇒ Eq (LegacyPlutusArgs l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Pretty (PlutusScriptContext l) ⇒ Pretty (LegacyPlutusArgs l) Source # 
Instance details

Defined in Cardano.Ledger.Plutus.Language

Orphan instances

NFData ScriptContext Source # 
Instance details

Methods

rnfScriptContext → () Source #

NFData ScriptContext Source # 
Instance details

Methods

rnfScriptContext → () Source #

NFData ScriptContext Source # 
Instance details

Methods

rnfScriptContext → () Source #