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) Lovelace (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 its content
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 # | Concrete outputs are abstract outputs |
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
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 #
The datum stored in the output. Is a nothing, an OutputDatum
, a
TxSkelOutDatum
...?
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 #
The value in the output. Does it contain pure ADA? Other assets?
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 #
The reference script in the output. Is it a hash, a typed validator...?
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 #
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
(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 # | Concrete outputs are abstract outputs |
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) 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