cooked-validators-4.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cooked.Output

Description

This module provide abstractions around the notion of outputs. The idea is to use types to carry additional information on which data is carried by various kinds of concrete outputs used in cooked specifically or in Plutus as a whole, such as TxSkelOut or TxOut.

Synopsis

Documentation

class IsAbstractOutput o Source #

A generalisation of TxOut: With the four type families, we can lift some information about

  • who owns the output (a public key, a script...?)
  • what kind of datum is there (do we have an inline datum, a datum hash, nothing...?)
  • what kind of value does the output hold (pure Ada ...?)
  • what information do we have on the reference script (only a hash, a complete script, a typed validator...?)

to the type level.

Instances

Instances details
IsAbstractOutput TxOut Source # 
Instance details

Defined in Cooked.Output

IsAbstractOutput (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # 
Instance details

Defined in Cooked.Output

Associated Types

type OwnerType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source #

type DatumType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source #

type ValueType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source #

type ReferenceScriptType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source #

Methods

outputOwnerL :: Lens' (ConcreteOutput ownerType datumType valueType referenceScriptType) (OwnerType (ConcreteOutput ownerType datumType valueType referenceScriptType)) Source #

outputStakingCredentialL :: Lens' (ConcreteOutput ownerType datumType valueType referenceScriptType) (Maybe StakingCredential) Source #

outputDatumL :: Lens' (ConcreteOutput ownerType datumType valueType referenceScriptType) (DatumType (ConcreteOutput ownerType datumType valueType referenceScriptType)) Source #

outputValueL :: Lens' (ConcreteOutput ownerType datumType valueType referenceScriptType) (ValueType (ConcreteOutput ownerType datumType valueType referenceScriptType)) Source #

outputReferenceScriptL :: Lens' (ConcreteOutput ownerType datumType valueType referenceScriptType) (Maybe (ReferenceScriptType (ConcreteOutput ownerType datumType valueType referenceScriptType))) Source #

type family OwnerType o Source #

Instances

Instances details
type OwnerType TxOut Source # 
Instance details

Defined in Cooked.Output

type OwnerType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # 
Instance details

Defined in Cooked.Output

type OwnerType (ConcreteOutput ownerType datumType valueType referenceScriptType) = ownerType

type family DatumType o Source #

Instances

Instances details
type DatumType TxOut Source # 
Instance details

Defined in Cooked.Output

type DatumType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # 
Instance details

Defined in Cooked.Output

type DatumType (ConcreteOutput ownerType datumType valueType referenceScriptType) = datumType

type family ValueType o Source #

Instances

Instances details
type ValueType TxOut Source # 
Instance details

Defined in Cooked.Output

type ValueType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # 
Instance details

Defined in Cooked.Output

type ValueType (ConcreteOutput ownerType datumType valueType referenceScriptType) = valueType

type family ReferenceScriptType o Source #

Instances

Instances details
type ReferenceScriptType TxOut Source # 
Instance details

Defined in Cooked.Output

type ReferenceScriptType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # 
Instance details

Defined in Cooked.Output

type ReferenceScriptType (ConcreteOutput ownerType datumType valueType referenceScriptType) = referenceScriptType

type IsTxInfoOutput o = (IsAbstractOutput o, ToCredential (OwnerType o), ToOutputDatum (DatumType o), ToValue (ValueType o), ToScriptHash (ReferenceScriptType o)) Source #

An output that can be translated into its script-perspective (as seen on the TxInfo) representation

outputTxOut :: IsTxInfoOutput o => o -> TxOut Source #

Return the output as it is seen by a validator on the TxInfo.

data ConcreteOutput ownerType datumType valueType referenceScriptType where Source #

A type constructed to be the most general instance of IsAbstractOutput.

Constructors

ConcreteOutput 

Fields

Instances

Instances details
(Show ownerType, Show datumType, Show valueType, Show referenceScriptType) => Show (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # 
Instance details

Defined in Cooked.Output

Methods

showsPrec :: Int -> ConcreteOutput ownerType datumType valueType referenceScriptType -> ShowS #

show :: ConcreteOutput ownerType datumType valueType referenceScriptType -> String #

showList :: [ConcreteOutput ownerType datumType valueType referenceScriptType] -> ShowS #

IsAbstractOutput (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # 
Instance details

Defined in Cooked.Output

Associated Types

type OwnerType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source #

type DatumType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source #

type ValueType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source #

type ReferenceScriptType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source #

Methods

outputOwnerL :: Lens' (ConcreteOutput ownerType datumType valueType referenceScriptType) (OwnerType (ConcreteOutput ownerType datumType valueType referenceScriptType)) Source #

outputStakingCredentialL :: Lens' (ConcreteOutput ownerType datumType valueType referenceScriptType) (Maybe StakingCredential) Source #

outputDatumL :: Lens' (ConcreteOutput ownerType datumType valueType referenceScriptType) (DatumType (ConcreteOutput ownerType datumType valueType referenceScriptType)) Source #

outputValueL :: Lens' (ConcreteOutput ownerType datumType valueType referenceScriptType) (ValueType (ConcreteOutput ownerType datumType valueType referenceScriptType)) Source #

outputReferenceScriptL :: Lens' (ConcreteOutput ownerType datumType valueType referenceScriptType) (Maybe (ReferenceScriptType (ConcreteOutput ownerType datumType valueType referenceScriptType))) Source #

(Eq ownerType, Eq datumType, Eq valueType, Eq referenceScriptType) => Eq (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # 
Instance details

Defined in Cooked.Output

Methods

(==) :: ConcreteOutput ownerType datumType valueType referenceScriptType -> ConcreteOutput ownerType datumType valueType referenceScriptType -> Bool #

(/=) :: ConcreteOutput ownerType datumType valueType referenceScriptType -> ConcreteOutput ownerType datumType valueType referenceScriptType -> Bool #

type DatumType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # 
Instance details

Defined in Cooked.Output

type DatumType (ConcreteOutput ownerType datumType valueType referenceScriptType) = datumType
type OwnerType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # 
Instance details

Defined in Cooked.Output

type OwnerType (ConcreteOutput ownerType datumType valueType referenceScriptType) = ownerType
type ReferenceScriptType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # 
Instance details

Defined in Cooked.Output

type ReferenceScriptType (ConcreteOutput ownerType datumType valueType referenceScriptType) = referenceScriptType
type ValueType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # 
Instance details

Defined in Cooked.Output

type ValueType (ConcreteOutput ownerType datumType valueType referenceScriptType) = valueType

toOutputWithReferenceScriptHash :: IsTxInfoOutput out => out -> ConcreteOutput (OwnerType out) (DatumType out) (ValueType out) ScriptHash Source #

Convert the reference script type on the output to ScriptHash.

isOutputWithoutDatum :: IsTxInfoOutput out => out -> Maybe (ConcreteOutput (OwnerType out) () (ValueType out) (ReferenceScriptType out)) Source #

Test if there is no datum on an output.

isOutputWithInlineDatum :: IsTxInfoOutput out => out -> Maybe (ConcreteOutput (OwnerType out) Datum (ValueType out) (ReferenceScriptType out)) Source #

Test if the output carries some inlined datum.

isOutputWithDatumHash :: IsTxInfoOutput out => out -> Maybe (ConcreteOutput (OwnerType out) DatumHash (ValueType out) (ReferenceScriptType out)) Source #

Test if the output carries some datum hash.

isOutputWithInlineDatumOfType :: (FromData a, IsTxInfoOutput out) => out -> Maybe (ConcreteOutput (OwnerType out) a (ValueType out) (ReferenceScriptType out)) Source #

Test if the output carries some inlined datum that can be parsed from builtin data on to something of a specific type.

isScriptOutputFrom :: (IsTxInfoOutput out, ToScriptHash s) => s -> out -> Maybe (ConcreteOutput s (DatumType out) (ValueType out) (ReferenceScriptType out)) Source #

Test if the owner of an output is a specific script

isPKOutputFrom :: IsTxInfoOutput out => PubKeyHash -> out -> Maybe (ConcreteOutput PubKeyHash (DatumType out) (ValueType out) (ReferenceScriptType out)) Source #

Test if the owner of an output is a specific public key

isOnlyAdaOutput :: IsTxInfoOutput out => out -> Maybe (ConcreteOutput (OwnerType out) (DatumType out) Ada (ReferenceScriptType out)) Source #

Test if the value on an output contains only Ada.

fromAbstractOutput :: IsAbstractOutput out => out -> ConcreteOutput (OwnerType out) (DatumType out) (ValueType out) (ReferenceScriptType out) Source #

Creates a generic concrete instance of any kind of abstract output

isReferenceScriptOutputFrom :: (IsTxInfoOutput out, ToScriptHash s) => s -> out -> Maybe (ConcreteOutput (OwnerType out) (DatumType out) (ValueType out) ScriptHash) Source #

Test if the reference script in an output is a specific script

isStakingCredentialOutputFrom :: (IsTxInfoOutput out, ToCredential cred) => cred -> out -> Maybe (ConcreteOutput (OwnerType out) (DatumType out) (ValueType out) (ReferenceScriptType out)) Source #

Test if the given output possesses a certain staking credential

isEmptyStakingCredentialOutput :: IsTxInfoOutput out => out -> Maybe (ConcreteOutput (OwnerType out) (DatumType out) (ValueType out) (ReferenceScriptType out)) Source #

Test if the give output does not possess any staking credential

isScriptOutput :: IsTxInfoOutput out => out -> Maybe (ConcreteOutput ScriptHash (DatumType out) (ValueType out) (ReferenceScriptType out)) Source #

Test if the owner of an output is a script