cooked-validators
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 its content

Instances

Instances details
IsAbstractOutput TxOut Source #

TxOuts are abstract outputs

Instance details

Defined in Cooked.Output

IsAbstractOutput (ConcreteOutput ownerType datumType valueType referenceScriptType) Source #

Concrete outputs are abstract outputs

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 #

The owner of the output. Is it a public key, as script...?

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 #

The datum stored in the output. Is a nothing, an OutputDatum, a TxSkelOutDatum...?

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 #

The value in the output. Does it contain pure ADA? Other assets?

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 #

The reference script in the output. Is it a hash, a typed validator...?

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

outputOwnerL :: IsAbstractOutput o => Lens' o (OwnerType o) Source #

Getting or setting the owner of this output

outputStakingCredentialL :: IsAbstractOutput o => Lens' o (Maybe StakingCredential) Source #

Getting or setting the staking credential of this output

outputDatumL :: IsAbstractOutput o => Lens' o (DatumType o) Source #

Getting or setting the datum of this output

outputValueL :: IsAbstractOutput o => Lens' o (ValueType o) Source #

Getting or setting the value of this output

outputReferenceScriptL :: IsAbstractOutput o => Lens' o (Maybe (ReferenceScriptType o)) Source #

Getting or setting the reference script of this output

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

outputAddress :: (IsAbstractOutput o, ToCredential (OwnerType o)) => o -> Address Source #

Retrieve the Address of a script-translatable output

outputOutputDatum :: (IsAbstractOutput o, ToOutputDatum (DatumType o)) => o -> OutputDatum Source #

Retrieves the OutputDatum of a script-translatable output

outputValue :: (IsAbstractOutput o, ToValue (ValueType o)) => o -> Value Source #

Retrieves the Value of a script-translatable output

outputReferenceScriptHash :: (IsAbstractOutput o, ToScriptHash (ReferenceScriptType o)) => o -> Maybe ScriptHash Source #

Retrieves the optional ScriptHash of a script-translatable output

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

Translates a script-translatable output into an TxOut

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 #

Concrete outputs are abstract outputs

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) Lovelace (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

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

Test if the owner of an output is a public key

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

Test if the owner of an output is a script

setDatum :: IsAbstractOutput out => out -> dat -> ConcreteOutput (OwnerType out) dat (ValueType out) (ReferenceScriptType out) Source #

Type-changing setter for an abstract output datum

setOwner :: IsAbstractOutput out => out -> owner -> ConcreteOutput owner (DatumType out) (ValueType out) (ReferenceScriptType out) Source #

Type-changing setter for an abstract output owner

setReferenceScript :: IsAbstractOutput out => out -> ref -> ConcreteOutput (OwnerType out) (DatumType out) (ValueType out) ref Source #

Type-changing setter for an abstract output reference script

setValue :: IsAbstractOutput out => out -> val -> ConcreteOutput (OwnerType out) (DatumType out) val (ReferenceScriptType out) Source #

Type-changing setter for an abstract output value

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

Type-changing setter for an abstract output staking scredential