cometa-0.1.0.0: Idiomatic Haskell bindings to cardano-c
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cometa.Script

Description

Native and versioned Plutus script alternatives. The combined CBOR form is [language, payload], where native is zero and Plutus versions are 1 through 4. The envelope is normalized on encoding; each payload retains its exact bytes, which determine script identity and hashing.

import qualified Cometa.Script as Script
import qualified Cometa.Script.Native as Native

script :: Script.Script
script = Script.Native (Native.allOf [])
Synopsis

Documentation

data Script Source #

Script alternatives with Haskell-owned payloads. Equality and ordering compare the alternative then its payload representation; native comes first.

Constructors

Native !NativeScript

A signaturetimeguard native script.

Plutus !PlutusScript

A compiled Plutus script carrying its language version.

Instances

Instances details
Show Script Source # 
Instance details

Defined in Cometa.Script

Eq Script Source # 
Instance details

Defined in Cometa.Script

Methods

(==) :: Script -> Script -> Bool #

(/=) :: Script -> Script -> Bool #

Ord Script Source # 
Instance details

Defined in Cometa.Script

encodeCbor :: Script -> ByteString Source #

Encode a definite two-element array and minimal language tag, preserving the payload's exact encoding. Nonminimal imported envelopes normalize on encoding; they do not contribute to the script hash.

decodeCbor :: ByteString -> Either Error Script Source #

Decode exactly one two-element native/Plutus envelope. Unknown language tags, incorrect arity, malformed payloads and trailing bytes return InvalidScriptCbor. Payload validators also retain their documented errors. The envelope's encoding is not retained; the payload's encoding is exact.

hash :: Script -> IO (Either Error ScriptHash) Source #

Hash using the native prefix zero or the declared Plutus version prefix. The combined envelope is excluded. Native failures return NativeError.