Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
- class IsAbstractOutput o
- type family OwnerType o
- type family DatumType o
- type family ValueType o
- type family ReferenceScriptType o
- outputOwnerL :: IsAbstractOutput o => Lens' o (OwnerType o)
- outputStakingCredentialL :: IsAbstractOutput o => Lens' o (Maybe StakingCredential)
- outputDatumL :: IsAbstractOutput o => Lens' o (DatumType o)
- outputValueL :: IsAbstractOutput o => Lens' o (ValueType o)
- outputReferenceScriptL :: IsAbstractOutput o => Lens' o (Maybe (ReferenceScriptType o))
- type IsTxInfoOutput o = (IsAbstractOutput o, ToCredential (OwnerType o), ToOutputDatum (DatumType o), ToValue (ValueType o), ToScriptHash (ReferenceScriptType o))
- outputAddress :: (IsAbstractOutput o, ToCredential (OwnerType o)) => o -> Address
- outputOutputDatum :: (IsAbstractOutput o, ToOutputDatum (DatumType o)) => o -> OutputDatum
- outputValue :: (IsAbstractOutput o, ToValue (ValueType o)) => o -> Value
- outputReferenceScriptHash :: (IsAbstractOutput o, ToScriptHash (ReferenceScriptType o)) => o -> Maybe ScriptHash
- outputTxOut :: IsTxInfoOutput o => o -> TxOut
- data ConcreteOutput ownerType datumType valueType referenceScriptType where
- ConcreteOutput :: {..} -> ConcreteOutput ownerType datumType valueType referenceScriptType
- toOutputWithReferenceScriptHash :: IsTxInfoOutput out => out -> ConcreteOutput (OwnerType out) (DatumType out) (ValueType out) ScriptHash
- isOutputWithoutDatum :: IsTxInfoOutput out => out -> Maybe (ConcreteOutput (OwnerType out) () (ValueType out) (ReferenceScriptType out))
- isOutputWithInlineDatum :: IsTxInfoOutput out => out -> Maybe (ConcreteOutput (OwnerType out) Datum (ValueType out) (ReferenceScriptType out))
- isOutputWithDatumHash :: IsTxInfoOutput out => out -> Maybe (ConcreteOutput (OwnerType out) DatumHash (ValueType out) (ReferenceScriptType out))
- isOutputWithInlineDatumOfType :: (FromData a, IsTxInfoOutput out) => out -> Maybe (ConcreteOutput (OwnerType out) a (ValueType out) (ReferenceScriptType out))
- isScriptOutputFrom :: (IsTxInfoOutput out, ToScriptHash s) => s -> out -> Maybe (ConcreteOutput s (DatumType out) (ValueType out) (ReferenceScriptType out))
- isPKOutputFrom :: IsTxInfoOutput out => PubKeyHash -> out -> Maybe (ConcreteOutput PubKeyHash (DatumType out) (ValueType out) (ReferenceScriptType out))
- isOnlyAdaOutput :: IsTxInfoOutput out => out -> Maybe (ConcreteOutput (OwnerType out) (DatumType out) Ada (ReferenceScriptType out))
- fromAbstractOutput :: IsAbstractOutput out => out -> ConcreteOutput (OwnerType out) (DatumType out) (ValueType out) (ReferenceScriptType out)
- isReferenceScriptOutputFrom :: (IsTxInfoOutput out, ToScriptHash s) => s -> out -> Maybe (ConcreteOutput (OwnerType out) (DatumType out) (ValueType out) ScriptHash)
- isStakingCredentialOutputFrom :: (IsTxInfoOutput out, ToCredential cred) => cred -> out -> Maybe (ConcreteOutput (OwnerType out) (DatumType out) (ValueType out) (ReferenceScriptType out))
- isEmptyStakingCredentialOutput :: IsTxInfoOutput out => out -> Maybe (ConcreteOutput (OwnerType out) (DatumType out) (ValueType out) (ReferenceScriptType out))
- isPKOutput :: IsTxInfoOutput out => out -> Maybe (ConcreteOutput PubKeyHash (DatumType out) (ValueType out) (ReferenceScriptType out))
- isScriptOutput :: IsTxInfoOutput out => out -> Maybe (ConcreteOutput ScriptHash (DatumType out) (ValueType out) (ReferenceScriptType out))
- setDatum :: IsAbstractOutput out => out -> dat -> ConcreteOutput (OwnerType out) dat (ValueType out) (ReferenceScriptType out)
- setOwner :: IsAbstractOutput out => out -> owner -> ConcreteOutput owner (DatumType out) (ValueType out) (ReferenceScriptType out)
- setReferenceScript :: IsAbstractOutput out => out -> ref -> ConcreteOutput (OwnerType out) (DatumType out) (ValueType out) ref
- setValue :: IsAbstractOutput out => out -> val -> ConcreteOutput (OwnerType out) (DatumType out) val (ReferenceScriptType out)
- setStakingCredential :: IsAbstractOutput out => out -> StakingCredential -> ConcreteOutput (OwnerType out) (DatumType out) (ValueType out) (ReferenceScriptType out)
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.
Minimal complete definition
outputOwnerL, outputStakingCredentialL, outputDatumL, outputValueL, outputReferenceScriptL
Instances
IsAbstractOutput TxOut Source # | |
Defined in Cooked.Output Associated Types type ReferenceScriptType TxOut Source # Methods outputOwnerL :: Lens' TxOut (OwnerType TxOut) Source # outputStakingCredentialL :: Lens' TxOut (Maybe StakingCredential) Source # outputDatumL :: Lens' TxOut (DatumType TxOut) Source # outputValueL :: Lens' TxOut (ValueType TxOut) Source # outputReferenceScriptL :: Lens' TxOut (Maybe (ReferenceScriptType TxOut)) Source # | |
IsAbstractOutput (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # | |
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
type OwnerType TxOut Source # | |
Defined in Cooked.Output | |
type OwnerType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # | |
Defined in Cooked.Output |
type family DatumType o Source #
Instances
type DatumType TxOut Source # | |
Defined in Cooked.Output | |
type DatumType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # | |
Defined in Cooked.Output |
type family ValueType o Source #
Instances
type ValueType TxOut Source # | |
Defined in Cooked.Output | |
type ValueType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # | |
Defined in Cooked.Output |
type family ReferenceScriptType o Source #
Instances
type ReferenceScriptType TxOut Source # | |
Defined in Cooked.Output | |
type ReferenceScriptType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # | |
Defined in Cooked.Output type ReferenceScriptType (ConcreteOutput ownerType datumType valueType referenceScriptType) = referenceScriptType |
outputOwnerL :: IsAbstractOutput o => Lens' o (OwnerType o) Source #
outputDatumL :: IsAbstractOutput o => Lens' o (DatumType o) Source #
outputValueL :: IsAbstractOutput o => Lens' o (ValueType o) Source #
outputReferenceScriptL :: IsAbstractOutput o => Lens' o (Maybe (ReferenceScriptType o)) Source #
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 #
outputOutputDatum :: (IsAbstractOutput o, ToOutputDatum (DatumType o)) => o -> OutputDatum Source #
outputValue :: (IsAbstractOutput o, ToValue (ValueType o)) => o -> Value Source #
outputReferenceScriptHash :: (IsAbstractOutput o, ToScriptHash (ReferenceScriptType o)) => o -> Maybe ScriptHash Source #
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
(Show ownerType, Show datumType, Show valueType, Show referenceScriptType) => Show (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # | |
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 # | |
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 # | |
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 # | |
Defined in Cooked.Output | |
type OwnerType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # | |
Defined in Cooked.Output | |
type ReferenceScriptType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # | |
Defined in Cooked.Output type ReferenceScriptType (ConcreteOutput ownerType datumType valueType referenceScriptType) = referenceScriptType | |
type ValueType (ConcreteOutput ownerType datumType valueType referenceScriptType) Source # | |
Defined in Cooked.Output |
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
isPKOutput :: IsTxInfoOutput out => out -> Maybe (ConcreteOutput PubKeyHash (DatumType out) (ValueType out) (ReferenceScriptType out)) Source #
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 #
setOwner :: IsAbstractOutput out => out -> owner -> ConcreteOutput owner (DatumType out) (ValueType out) (ReferenceScriptType out) Source #
setReferenceScript :: IsAbstractOutput out => out -> ref -> ConcreteOutput (OwnerType out) (DatumType out) (ValueType out) ref Source #
setValue :: IsAbstractOutput out => out -> val -> ConcreteOutput (OwnerType out) (DatumType out) val (ReferenceScriptType out) Source #
setStakingCredential :: IsAbstractOutput out => out -> StakingCredential -> ConcreteOutput (OwnerType out) (DatumType out) (ValueType out) (ReferenceScriptType out) Source #