Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type SerialisedScript = ShortByteString
- serialiseCompiledCode ∷ ∀ a. CompiledCode a → SerialisedScript
- serialiseUPLC ∷ Program DeBruijn DefaultUni DefaultFun () → SerialisedScript
- uncheckedDeserialiseUPLC ∷ SerialisedScript → Program DeBruijn DefaultUni DefaultFun ()
- scriptCBORDecoder ∷ PlutusLedgerLanguage → MajorProtocolVersion → Decoder s ScriptNamedDeBruijn
- newtype ScriptNamedDeBruijn = ScriptNamedDeBruijn (Program NamedDeBruijn DefaultUni DefaultFun ())
- data ScriptForEvaluation
- data ScriptDecodeError
- class AsScriptDecodeError r where
- _ScriptDecodeError ∷ Prism' r ScriptDecodeError
- _CBORDeserialiseError ∷ Prism' r DeserialiseFailureInfo
- _RemainderError ∷ Prism' r ByteString
- _LedgerLanguageNotAvailableError ∷ Prism' r (PlutusLedgerLanguage, MajorProtocolVersion, MajorProtocolVersion)
- _PlutusCoreLanguageNotAvailableError ∷ Prism' r (Version, PlutusLedgerLanguage, MajorProtocolVersion)
- data DeserialiseFailureInfo = DeserialiseFailureInfo {}
- data DeserialiseFailureReason
- deserialiseScript ∷ ∀ m. MonadError ScriptDecodeError m ⇒ PlutusLedgerLanguage → MajorProtocolVersion → SerialisedScript → m ScriptForEvaluation
- serialisedScript ∷ ScriptForEvaluation → SerialisedScript
- deserialisedScript ∷ ScriptForEvaluation → ScriptNamedDeBruijn
Documentation
type SerialisedScript = ShortByteString Source #
Scripts to the ledger are serialised bytestrings.
serialiseCompiledCode ∷ ∀ a. CompiledCode a → SerialisedScript Source #
Turns a program which was compiled using the 'PlutusTx' toolchain into a binary format that is understood by the network and can be stored on-chain.
serialiseUPLC ∷ Program DeBruijn DefaultUni DefaultFun () → SerialisedScript Source #
Turns a program's AST (most likely manually constructed) into a binary format that is understood by the network and can be stored on-chain.
uncheckedDeserialiseUPLC ∷ SerialisedScript → Program DeBruijn DefaultUni DefaultFun () Source #
Deserialises a SerialisedScript
back into an AST. Does *not* do
ledger-language-version-specific checks like for allowable builtins.
scriptCBORDecoder ∷ PlutusLedgerLanguage → MajorProtocolVersion → Decoder s ScriptNamedDeBruijn Source #
This decoder decodes the names directly into NamedDeBruijn
s rather than DeBruijn
s.
This is needed because the CEK machine expects NameDeBruijn
s, but there are obviously no
names in the serialised form of a Script
. Rather than traversing the term and inserting
fake names after deserialising, this lets us do at the same time as deserialising.
newtype ScriptNamedDeBruijn Source #
A script with named de-bruijn indices.
Instances
Generic ScriptNamedDeBruijn Source # | |
Defined in PlutusLedgerApi.Common.SerialisedScript | |
Show ScriptNamedDeBruijn Source # | |
Defined in PlutusLedgerApi.Common.SerialisedScript | |
NFData ScriptNamedDeBruijn Source # | |
Defined in PlutusLedgerApi.Common.SerialisedScript rnf ∷ ScriptNamedDeBruijn → () Source # | |
Eq ScriptNamedDeBruijn Source # | |
type Rep ScriptNamedDeBruijn Source # | |
Defined in PlutusLedgerApi.Common.SerialisedScript type Rep ScriptNamedDeBruijn = D1 ('MetaData "ScriptNamedDeBruijn" "PlutusLedgerApi.Common.SerialisedScript" "plutus-ledger-api-1.38.0.0-inplace" 'True) (C1 ('MetaCons "ScriptNamedDeBruijn" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Program NamedDeBruijn DefaultUni DefaultFun ())))) |
data ScriptForEvaluation Source #
A Plutus script ready to be evaluated on-chain, via evaluateScriptRestricting
.
Instances
Generic ScriptForEvaluation Source # | |
Defined in PlutusLedgerApi.Common.SerialisedScript | |
Show ScriptForEvaluation Source # | |
Defined in PlutusLedgerApi.Common.SerialisedScript | |
NFData ScriptForEvaluation Source # | |
Defined in PlutusLedgerApi.Common.SerialisedScript rnf ∷ ScriptForEvaluation → () Source # | |
Eq ScriptForEvaluation Source # | |
NoThunks ScriptForEvaluation Source # | |
Defined in PlutusLedgerApi.Common.SerialisedScript | |
type Rep ScriptForEvaluation Source # | |
Defined in PlutusLedgerApi.Common.SerialisedScript type Rep ScriptForEvaluation = D1 ('MetaData "ScriptForEvaluation" "PlutusLedgerApi.Common.SerialisedScript" "plutus-ledger-api-1.38.0.0-inplace" 'False) (C1 ('MetaCons "UnsafeScriptForEvaluation" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SerialisedScript) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ScriptNamedDeBruijn))) |
data ScriptDecodeError Source #
An error that occurred during script deserialization.
CBORDeserialiseError !DeserialiseFailureInfo | an error from the underlying CBOR/serialise library |
RemainderError !ByteString | Script was successfully parsed, but more (runaway) bytes encountered after script's position |
LedgerLanguageNotAvailableError | the plutus version of the given script is not enabled yet |
| |
PlutusCoreLanguageNotAvailableError | |
|
Instances
class AsScriptDecodeError r where Source #
_ScriptDecodeError ∷ Prism' r ScriptDecodeError Source #
_CBORDeserialiseError ∷ Prism' r DeserialiseFailureInfo Source #
_RemainderError ∷ Prism' r ByteString Source #
_LedgerLanguageNotAvailableError ∷ Prism' r (PlutusLedgerLanguage, MajorProtocolVersion, MajorProtocolVersion) Source #
_PlutusCoreLanguageNotAvailableError ∷ Prism' r (Version, PlutusLedgerLanguage, MajorProtocolVersion) Source #
Instances
data DeserialiseFailureInfo Source #
Similar to DeserialiseFailure
, with the difference that plain
string reason messages are turned into the datatype: DeserialiseFailureReason
.
Instances
Show DeserialiseFailureInfo | |
Defined in Codec.Extras.SerialiseViaFlat | |
Eq DeserialiseFailureInfo | |
Pretty DeserialiseFailureInfo | |
Defined in Codec.Extras.SerialiseViaFlat pretty ∷ DeserialiseFailureInfo → Doc ann Source # prettyList ∷ [DeserialiseFailureInfo] → Doc ann Source # |
data DeserialiseFailureReason Source #
The reason of the cbor failure as a datatype, not as a plain string.
EndOfInput | Not enough input provided |
ExpectedBytes | The bytes inside the input are malformed. |
OtherReason String | This is either a cbor failure that we (plutus) are not aware of,
or an underlying flat failure. We use whatever message |
Instances
∷ ∀ m. MonadError ScriptDecodeError m | |
⇒ PlutusLedgerLanguage | the Plutus ledger language of the script. |
→ MajorProtocolVersion | which major protocol version the script was submitted in. |
→ SerialisedScript | the script to deserialise. |
→ m ScriptForEvaluation |
The deserialization from a serialised script into a ScriptForEvaluation
,
ready to be evaluated on-chain.
Called inside phase-1 validation (i.e., deserialisation error is a phase-1 error).
serialisedScript ∷ ScriptForEvaluation → SerialisedScript Source #
Get a SerialisedScript
from a ScriptForEvaluation
. O(1).
deserialisedScript ∷ ScriptForEvaluation → ScriptNamedDeBruijn Source #
Get a ScriptNamedDeBruijn
from a ScriptForEvaluation
. O(1).