cooked-validators-4.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cooked.MockChain.MinAda

Description

This module provides functions to ensure skeleton outputs contain enough ada to satisfy the minimum ada constraint.

Synopsis

Documentation

toTxSkelOutWithMinAda :: Params -> TxSkelOut -> Either GenerateTxError TxSkelOut Source #

This transforms an output into another output which necessarily contains at least the minimal required ada. If the previous quantity of ada was sufficient, it remains unchanged. This requires an iterative process, as adding ada into an output can potentially increase its size and thus make it require more minimal ada (although this remains to be witnessed in practice). This approach was inspired by https://github.com/input-output-hk/plutus-apps/blob/8706e6c7c525b4973a7b6d2ed7c9d0ef9cd4ef46/plutus-ledger/src/Ledger/Index.hs#L124

toTxSkelWithMinAda :: MonadBlockChainBalancing m => TxSkel -> m TxSkel Source #

This transforms a skeleton by replacing all its TxSkelOut by their updated variants with their minimal amount of required ada. Any error raised in the transformation process is transformed into an MCEGenerationError

getTxSkelOutMinAda :: Params -> TxSkelOut -> Either GenerateTxError Integer Source #

This provides the minimum amount of ada required in a given TxSkelOut. As we need to transform our output into a Cardano output to compute this value, this function can fail.