cooked-validators-4.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cooked.MockChain.UtxoSearch

Description

This module provides a convenient framework to look through UTxOs and search relevant ones based on predicates. For instance, it makes it very convenient to gather all UTxOs at a certain address.

Synopsis

Documentation

type UtxoSearch m a = ListT m (TxOutRef, a) Source #

If a UTxO is a TxOutRef with some additional information, this type captures a "stream" of UTxOs.

runUtxoSearch :: Monad m => UtxoSearch m a -> m [(TxOutRef, a)] Source #

Given a UTxO search, we can run it to obtain a list of UTxOs.

allUtxosSearch :: MonadBlockChain m => UtxoSearch m TxOut Source #

Search all currently known TxOutRefs together with their corresponding TxInfo-TxOut.

utxosAtSearch :: (MonadBlockChainBalancing m, ToAddress addr) => addr -> UtxoSearch m TxOut Source #

Search all TxOutRefs at a certain address, together with their TxInfo-TxOut.

utxosFromCardanoTxSearch :: Monad m => CardanoTx -> UtxoSearch m TxOut Source #

Search all TxOutRefs of a transaction, together with their TxInfo-TxOut.

txOutByRefSearch :: MonadBlockChainBalancing m => [TxOutRef] -> UtxoSearch m TxOut Source #

Search all TxInfo-TxOuts corresponding to given the list of TxOutRefs. Any TxOutRef that doesn't correspond to a known output will be filtered out.

filterWith :: Monad m => UtxoSearch m a -> (a -> m (Maybe b)) -> UtxoSearch m b Source #

Transform a UtxoSearch by applying a possibly failing monadic "lookup" on every output.

filterWithPure :: Monad m => UtxoSearch m a -> (a -> Maybe b) -> UtxoSearch m b Source #

filterWithPred :: Monad m => UtxoSearch m a -> (a -> Bool) -> UtxoSearch m a Source #

onlyValueOutputsAtSearch :: (MonadBlockChainBalancing m, ToAddress addr) => addr -> UtxoSearch m (ConcreteOutput Credential () Value ScriptHash) Source #

Search for UTxOs which only carry address and value information (no datum, staking credential, or reference script).

vanillaOutputsAtSearch :: (MonadBlockChainBalancing m, ToAddress addr) => addr -> UtxoSearch m (ConcreteOutput Credential () Ada ScriptHash) Source #

A vanilla output only possesses an ada-only value and does not have a staking credential, a datum or a reference script. A vanilla UTxO is a perfect candidate to be used for fee, balancing or collateral.

filterWithAlways :: Monad m => UtxoSearch m a -> (a -> b) -> UtxoSearch m b Source #