Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data ScriptLookups a = ScriptLookups {
- slTxOutputs :: Map TxOutRef DecoratedTxOut
- slOtherScripts :: Map ScriptHash (Versioned Script)
- slOtherData :: Map DatumHash Datum
- slPaymentPubKeyHashes :: Set PaymentPubKeyHash
- slTypedValidator :: Maybe (TypedValidator a)
- slOwnPaymentPubKeyHash :: Maybe PaymentPubKeyHash
- slOwnStakingCredential :: Maybe StakingCredential
- typedValidatorLookups :: TypedValidator a -> ScriptLookups a
- generalise :: ScriptLookups a -> ScriptLookups Any
- unspentOutputs :: Map TxOutRef DecoratedTxOut -> ScriptLookups a
- mintingPolicy :: Versioned MintingPolicy -> ScriptLookups a
- plutusV1MintingPolicy :: MintingPolicy -> ScriptLookups a
- plutusV2MintingPolicy :: MintingPolicy -> ScriptLookups a
- otherScript :: Versioned Validator -> ScriptLookups a
- plutusV1OtherScript :: Validator -> ScriptLookups a
- plutusV2OtherScript :: Validator -> ScriptLookups a
- otherData :: Datum -> ScriptLookups a
- paymentPubKey :: PaymentPubKey -> ScriptLookups a
- paymentPubKeyHash :: PaymentPubKeyHash -> ScriptLookups a
- data SomeLookupsAndConstraints where
- SomeLookupsAndConstraints :: forall a. (FromData (DatumType a), ToData (DatumType a), ToData (RedeemerType a)) => ScriptLookups a -> TxConstraints (RedeemerType a) (DatumType a) -> SomeLookupsAndConstraints
- data UnbalancedTx = UnbalancedCardanoTx {
- unBalancedCardanoBuildTx :: CardanoBuildTx
- unBalancedTxUtxoIndex :: UtxoIndex
- tx :: Traversal' UnbalancedTx CardanoBuildTx
- txInsCollateral :: Lens' CardanoBuildTx [TxIn]
- txValidityRange :: Lens' CardanoBuildTx (TxValidityLowerBound BabbageEra, TxValidityUpperBound BabbageEra)
- txOuts :: Lens' CardanoBuildTx [TxOut]
- utxoIndex :: Lens' UnbalancedTx UtxoIndex
- emptyUnbalancedTx :: Params -> UnbalancedTx
- adjustUnbalancedTx :: PParams -> UnbalancedTx -> ([Lovelace], UnbalancedTx)
- mkTx :: (FromData (DatumType a), ToData (DatumType a), ToData (RedeemerType a)) => Params -> ScriptLookups a -> TxConstraints (RedeemerType a) (DatumType a) -> Either MkTxError UnbalancedTx
- mkTxWithParams :: (FromData (DatumType a), ToData (DatumType a), ToData (RedeemerType a)) => Params -> ScriptLookups a -> TxConstraints (RedeemerType a) (DatumType a) -> Either MkTxError UnbalancedTx
- mkSomeTx :: Params -> [SomeLookupsAndConstraints] -> Either MkTxError UnbalancedTx
- data MkTxError
- = TypeCheckFailed ConnectionError
- | ToCardanoError ToCardanoError
- | TxOutRefNotFound TxOutRef
- | TxOutRefWrongType TxOutRef
- | TxOutRefNoReferenceScript TxOutRef
- | DatumNotFound DatumHash
- | DeclaredInputMismatch Value
- | DeclaredOutputMismatch Value
- | MintingPolicyNotFound MintingPolicyHash
- | ScriptHashNotFound ScriptHash
- | TypedValidatorMissing
- | DatumWrongHash DatumHash Datum
- | CannotSatisfyAny
- | NoMatchingOutputFound ValidatorHash
- | MultipleMatchingOutputsFound ValidatorHash
- | AmbiguousRedeemer TxOutRef [Redeemer]
- | AmbiguousReferenceScript TxOutRef [TxOutRef]
- _TypeCheckFailed :: AsMkTxError r => Prism' r ConnectionError
- _ToCardanoError :: AsMkTxError r => Prism' r ToCardanoError
- _TxOutRefNotFound :: AsMkTxError r => Prism' r TxOutRef
- _TxOutRefWrongType :: AsMkTxError r => Prism' r TxOutRef
- _TxOutRefNoReferenceScript :: AsMkTxError r => Prism' r TxOutRef
- _DatumNotFound :: AsMkTxError r => Prism' r DatumHash
- _DeclaredInputMismatch :: AsMkTxError r => Prism' r Value
- _MintingPolicyNotFound :: AsMkTxError r => Prism' r MintingPolicyHash
- _ScriptHashNotFound :: AsMkTxError r => Prism' r ScriptHash
- _TypedValidatorMissing :: AsMkTxError r => Prism' r ()
- _DatumWrongHash :: AsMkTxError r => Prism' r (DatumHash, Datum)
- _CannotSatisfyAny :: AsMkTxError r => Prism' r ()
- _NoMatchingOutputFound :: AsMkTxError r => Prism' r ValidatorHash
- _MultipleMatchingOutputsFound :: AsMkTxError r => Prism' r ValidatorHash
- data ValueSpentBalances = ValueSpentBalances {
- vbsRequired :: Value
- vbsProvided :: Value
- provided :: Value -> ValueSpentBalances
- required :: Value -> ValueSpentBalances
- missingValueSpent :: ValueSpentBalances -> Value
- data ConstraintProcessingState = ConstraintProcessingState {}
- unbalancedTx :: Lens' ConstraintProcessingState UnbalancedTx
- valueSpentInputs :: Lens' ConstraintProcessingState ValueSpentBalances
- valueSpentOutputs :: Lens' ConstraintProcessingState ValueSpentBalances
- paramsL :: Lens' ConstraintProcessingState Params
- processConstraintFun :: TxConstraintFun -> ReaderT (ScriptLookups a) (StateT ConstraintProcessingState (Except MkTxError)) ()
- addOwnInput :: (MonadReader (ScriptLookups a) m, MonadError MkTxError m, FromData (DatumType a), ToData (DatumType a), ToData (RedeemerType a)) => ScriptInputConstraint (RedeemerType a) -> m TxConstraint
- addOwnOutput :: (MonadReader (ScriptLookups a) m, MonadError MkTxError m, ToData (DatumType a)) => ScriptOutputConstraint (DatumType a) -> m TxConstraint
- updateUtxoIndex :: (MonadReader (ScriptLookups a) m, MonadState ConstraintProcessingState m, MonadError MkTxError m) => m ()
- lookupTxOutRef :: TxOutRef -> ReaderT (ScriptLookups a) (StateT ConstraintProcessingState (Except MkTxError)) DecoratedTxOut
- lookupMintingPolicy :: MintingPolicyHash -> ReaderT (ScriptLookups a) (StateT ConstraintProcessingState (Except MkTxError)) (Versioned MintingPolicy)
- lookupScript :: (MonadReader (ScriptLookups a) m, MonadError MkTxError m) => ScriptHash -> m (Versioned Script)
- lookupScriptAsReferenceScript :: Maybe ScriptHash -> ReaderT (ScriptLookups a) (StateT ConstraintProcessingState (Except MkTxError)) (ReferenceScript BabbageEra)
- prepareConstraints :: (FromData (DatumType a), ToData (DatumType a), ToData (RedeemerType a)) => [ScriptInputConstraint (RedeemerType a)] -> [ScriptOutputConstraint (DatumType a)] -> [TxConstraint] -> ReaderT (ScriptLookups a) (StateT ConstraintProcessingState (Except MkTxError)) SortedConstraints
- resolveScriptTxOut :: (MonadReader (ScriptLookups a) m, MonadError MkTxError m) => DecoratedTxOut -> m (Maybe (Versioned Validator, DatumWithOrigin, Value))
- resolveScriptTxOutValidator :: (MonadReader (ScriptLookups a) m, MonadError MkTxError m) => DecoratedTxOut -> m (Maybe (Versioned Validator))
- resolveScriptTxOutDatumAndValue :: (MonadReader (ScriptLookups a) m, MonadError MkTxError m) => DecoratedTxOut -> m (Maybe (DatumWithOrigin, Value))
- data DatumWithOrigin
- = DatumInTx {
- getDatum :: Datum
- | DatumInline {
- getDatum :: Datum
- = DatumInTx {
- datumWitness :: DatumWithOrigin -> Maybe Datum
- checkValueSpent :: (MonadReader (ScriptLookups a) m, MonadState ConstraintProcessingState m, MonadError MkTxError m) => m ()
- data SortedConstraints = MkSortedConstraints {
- rangeConstraints :: [POSIXTimeRange]
- otherConstraints :: [TxConstraint]
- initialState :: Params -> ConstraintProcessingState
Lookups
data ScriptLookups a Source #
ScriptLookups | |
|
Instances
typedValidatorLookups :: TypedValidator a -> ScriptLookups a Source #
A script lookups value with a script instance. For convenience this also includes the minting policy script that forwards all checks to the instance's validator.
If called multiple times, only the first typed validator is kept:
typedValidatorLookups tv1 <> typedValidatorLookups tv2 <> ... == typedValidatorLookups tv1
generalise :: ScriptLookups a -> ScriptLookups Any Source #
unspentOutputs :: Map TxOutRef DecoratedTxOut -> ScriptLookups a Source #
A script lookups value that uses the map of unspent outputs to resolve input constraints.
mintingPolicy :: Versioned MintingPolicy -> ScriptLookups a Source #
A script lookups value with a versioned minting policy script.
plutusV1MintingPolicy :: MintingPolicy -> ScriptLookups a Source #
A script lookups value with a PlutusV1 minting policy script.
plutusV2MintingPolicy :: MintingPolicy -> ScriptLookups a Source #
A script lookups value with a PlutusV2 minting policy script.
otherScript :: Versioned Validator -> ScriptLookups a Source #
A script lookups value with a versioned validator script.
plutusV1OtherScript :: Validator -> ScriptLookups a Source #
A script lookups value with a PlutusV1 validator script.
plutusV2OtherScript :: Validator -> ScriptLookups a Source #
A script lookups value with a PlutusV2 validator script.
otherData :: Datum -> ScriptLookups a Source #
A script lookups value with a datum.
paymentPubKey :: PaymentPubKey -> ScriptLookups a Source #
A script lookups value with a payment public key
paymentPubKeyHash :: PaymentPubKeyHash -> ScriptLookups a Source #
A script lookups value with a payment public key
Constraints resolution
data SomeLookupsAndConstraints where Source #
Some typed TxConstraints
and the ScriptLookups
needed to turn them
into an UnbalancedTx
.
SomeLookupsAndConstraints :: forall a. (FromData (DatumType a), ToData (DatumType a), ToData (RedeemerType a)) => ScriptLookups a -> TxConstraints (RedeemerType a) (DatumType a) -> SomeLookupsAndConstraints |
data UnbalancedTx Source #
An unbalanced transaction. It needs to be balanced and signed before it
can be submitted to the ledger. See note [Submitting transactions from
Plutus contracts] in Wallet
.
UnbalancedCardanoTx | |
|
Instances
tx :: Traversal' UnbalancedTx CardanoBuildTx Source #
txInsCollateral :: Lens' CardanoBuildTx [TxIn] Source #
txValidityRange :: Lens' CardanoBuildTx (TxValidityLowerBound BabbageEra, TxValidityUpperBound BabbageEra) Source #
utxoIndex :: Lens' UnbalancedTx UtxoIndex Source #
emptyUnbalancedTx :: Params -> UnbalancedTx Source #
adjustUnbalancedTx :: PParams -> UnbalancedTx -> ([Lovelace], UnbalancedTx) Source #
Each transaction output should contain a minimum amount of Ada (this is a restriction on the real Cardano network).
mkTx :: (FromData (DatumType a), ToData (DatumType a), ToData (RedeemerType a)) => Params -> ScriptLookups a -> TxConstraints (RedeemerType a) (DatumType a) -> Either MkTxError UnbalancedTx Source #
Turn a TxConstraints
value into an unbalanced transaction that satisfies
the constraints. To use this in a contract, see
submitTxConstraints
and related functions.
mkTxWithParams :: (FromData (DatumType a), ToData (DatumType a), ToData (RedeemerType a)) => Params -> ScriptLookups a -> TxConstraints (RedeemerType a) (DatumType a) -> Either MkTxError UnbalancedTx Source #
Turn a TxConstraints
value into an unbalanced transaction that satisfies
the constraints. To use this in a contract, see
submitTxConstraints
and related functions.
mkSomeTx :: Params -> [SomeLookupsAndConstraints] -> Either MkTxError UnbalancedTx Source #
Given a list of SomeLookupsAndConstraints
describing the constraints
for several scripts, build a single transaction that runs all the scripts.
TypeCheckFailed ConnectionError | |
ToCardanoError ToCardanoError | |
TxOutRefNotFound TxOutRef | |
TxOutRefWrongType TxOutRef | |
TxOutRefNoReferenceScript TxOutRef | |
DatumNotFound DatumHash | |
DeclaredInputMismatch Value | |
DeclaredOutputMismatch Value | |
MintingPolicyNotFound MintingPolicyHash | |
ScriptHashNotFound ScriptHash | |
TypedValidatorMissing | |
DatumWrongHash DatumHash Datum | |
CannotSatisfyAny | |
NoMatchingOutputFound ValidatorHash | |
MultipleMatchingOutputsFound ValidatorHash | |
AmbiguousRedeemer TxOutRef [Redeemer] | |
AmbiguousReferenceScript TxOutRef [TxOutRef] |
Instances
_TypeCheckFailed :: AsMkTxError r => Prism' r ConnectionError Source #
_ToCardanoError :: AsMkTxError r => Prism' r ToCardanoError Source #
_TxOutRefNotFound :: AsMkTxError r => Prism' r TxOutRef Source #
_TxOutRefWrongType :: AsMkTxError r => Prism' r TxOutRef Source #
_TxOutRefNoReferenceScript :: AsMkTxError r => Prism' r TxOutRef Source #
_DatumNotFound :: AsMkTxError r => Prism' r DatumHash Source #
_DeclaredInputMismatch :: AsMkTxError r => Prism' r Value Source #
_MintingPolicyNotFound :: AsMkTxError r => Prism' r MintingPolicyHash Source #
_ScriptHashNotFound :: AsMkTxError r => Prism' r ScriptHash Source #
_TypedValidatorMissing :: AsMkTxError r => Prism' r () Source #
_DatumWrongHash :: AsMkTxError r => Prism' r (DatumHash, Datum) Source #
_CannotSatisfyAny :: AsMkTxError r => Prism' r () Source #
_NoMatchingOutputFound :: AsMkTxError r => Prism' r ValidatorHash Source #
_MultipleMatchingOutputsFound :: AsMkTxError r => Prism' r ValidatorHash Source #
Internals exposed for testing
data ValueSpentBalances Source #
The balances we track for computing the missing Value
(if any)
that needs to be added to the transaction.
See note [Balance of value spent].
ValueSpentBalances | |
|
Instances
provided :: Value -> ValueSpentBalances Source #
required :: Value -> ValueSpentBalances Source #
missingValueSpent :: ValueSpentBalances -> Value Source #
data ConstraintProcessingState Source #
ConstraintProcessingState | |
|
paramsL :: Lens' ConstraintProcessingState Params Source #
processConstraintFun :: TxConstraintFun -> ReaderT (ScriptLookups a) (StateT ConstraintProcessingState (Except MkTxError)) () Source #
addOwnInput :: (MonadReader (ScriptLookups a) m, MonadError MkTxError m, FromData (DatumType a), ToData (DatumType a), ToData (RedeemerType a)) => ScriptInputConstraint (RedeemerType a) -> m TxConstraint Source #
Add a typed input, checking the type of the output it spends. Return the value of the spent output.
addOwnOutput :: (MonadReader (ScriptLookups a) m, MonadError MkTxError m, ToData (DatumType a)) => ScriptOutputConstraint (DatumType a) -> m TxConstraint Source #
Convert a ScriptOutputConstraint
into a TxConstraint
.
updateUtxoIndex :: (MonadReader (ScriptLookups a) m, MonadState ConstraintProcessingState m, MonadError MkTxError m) => m () Source #
lookupTxOutRef :: TxOutRef -> ReaderT (ScriptLookups a) (StateT ConstraintProcessingState (Except MkTxError)) DecoratedTxOut Source #
lookupMintingPolicy :: MintingPolicyHash -> ReaderT (ScriptLookups a) (StateT ConstraintProcessingState (Except MkTxError)) (Versioned MintingPolicy) Source #
lookupScript :: (MonadReader (ScriptLookups a) m, MonadError MkTxError m) => ScriptHash -> m (Versioned Script) Source #
lookupScriptAsReferenceScript :: Maybe ScriptHash -> ReaderT (ScriptLookups a) (StateT ConstraintProcessingState (Except MkTxError)) (ReferenceScript BabbageEra) Source #
prepareConstraints :: (FromData (DatumType a), ToData (DatumType a), ToData (RedeemerType a)) => [ScriptInputConstraint (RedeemerType a)] -> [ScriptOutputConstraint (DatumType a)] -> [TxConstraint] -> ReaderT (ScriptLookups a) (StateT ConstraintProcessingState (Except MkTxError)) SortedConstraints Source #
resolveScriptTxOut :: (MonadReader (ScriptLookups a) m, MonadError MkTxError m) => DecoratedTxOut -> m (Maybe (Versioned Validator, DatumWithOrigin, Value)) Source #
resolveScriptTxOutValidator :: (MonadReader (ScriptLookups a) m, MonadError MkTxError m) => DecoratedTxOut -> m (Maybe (Versioned Validator)) Source #
resolveScriptTxOutDatumAndValue :: (MonadReader (ScriptLookups a) m, MonadError MkTxError m) => DecoratedTxOut -> m (Maybe (DatumWithOrigin, Value)) Source #
data DatumWithOrigin Source #
DatumInTx | |
| |
DatumInline | |
|
datumWitness :: DatumWithOrigin -> Maybe Datum Source #
checkValueSpent :: (MonadReader (ScriptLookups a) m, MonadState ConstraintProcessingState m, MonadError MkTxError m) => m () Source #
data SortedConstraints Source #
MkSortedConstraints | |
|
Instances
Eq SortedConstraints Source # | |
Defined in Ledger.Tx.Constraints.OffChain (==) :: SortedConstraints -> SortedConstraints -> Bool Source # (/=) :: SortedConstraints -> SortedConstraints -> Bool Source # | |
Show SortedConstraints Source # | |
Defined in Ledger.Tx.Constraints.OffChain |
initialState :: Params -> ConstraintProcessingState Source #