| Safe Haskell | Safe-Inferred | 
|---|---|
| Language | Haskell2010 | 
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
- type UtxoSearch m a = ListT m (TxOutRef, a)
 - runUtxoSearch :: Monad m => UtxoSearch m a -> m [(TxOutRef, a)]
 - allUtxosSearch :: MonadBlockChain m => UtxoSearch m TxSkelOut
 - utxosOwnedBySearch :: (MonadBlockChainBalancing m, ToAddress addr) => addr -> UtxoSearch m TxSkelOut
 - utxosFromCardanoTxSearch :: MonadBlockChainBalancing m => CardanoTx -> UtxoSearch m TxSkelOut
 - txSkelOutByRefSearch :: MonadBlockChainBalancing m => [TxOutRef] -> UtxoSearch m TxSkelOut
 - filterWith :: Monad m => UtxoSearch m a -> (a -> m (Maybe b)) -> UtxoSearch m b
 - filterWithPure :: Monad m => UtxoSearch m a -> (a -> Maybe b) -> UtxoSearch m b
 - filterWithOptic :: (Is k An_AffineFold, Monad m) => UtxoSearch m a -> Optic' k is a b -> UtxoSearch m b
 - filterWithPred :: Monad m => UtxoSearch m a -> (a -> Bool) -> UtxoSearch m a
 - filterWithValuePred :: Monad m => UtxoSearch m TxSkelOut -> (Value -> Bool) -> UtxoSearch m TxSkelOut
 - filterWithOnlyAda :: Monad m => UtxoSearch m TxSkelOut -> UtxoSearch m TxSkelOut
 - filterWithNotOnlyAda :: Monad m => UtxoSearch m TxSkelOut -> UtxoSearch m TxSkelOut
 - onlyValueOutputsAtSearch :: (MonadBlockChainBalancing m, ToAddress addr) => addr -> UtxoSearch m TxSkelOut
 - vanillaOutputsAtSearch :: (MonadBlockChainBalancing m, ToAddress addr) => addr -> UtxoSearch m TxSkelOut
 - filterWithAlways :: Monad m => UtxoSearch m a -> (a -> b) -> UtxoSearch m b
 - referenceScriptOutputsSearch :: (MonadBlockChain m, ToScriptHash s) => s -> UtxoSearch m TxSkelOut
 - filterWithPureRev :: Monad m => UtxoSearch m a -> (a -> Maybe b) -> UtxoSearch m a
 
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 TxSkelOut Source #
utxosOwnedBySearch :: (MonadBlockChainBalancing m, ToAddress addr) => addr -> UtxoSearch m TxSkelOut Source #
utxosFromCardanoTxSearch :: MonadBlockChainBalancing m => CardanoTx -> UtxoSearch m TxSkelOut Source #
txSkelOutByRefSearch :: MonadBlockChainBalancing m => [TxOutRef] -> UtxoSearch m TxSkelOut Source #
filterWith :: Monad m => UtxoSearch m a -> (a -> m (Maybe b)) -> UtxoSearch m b Source #
Transform a UtxoSearch by applying a possibly partial monadic
 transformation on each output in the stream
filterWithPure :: Monad m => UtxoSearch m a -> (a -> Maybe b) -> UtxoSearch m b Source #
Same as filterWith but with a pure transformation
filterWithOptic :: (Is k An_AffineFold, Monad m) => UtxoSearch m a -> Optic' k is a b -> UtxoSearch m b Source #
Some as filterWithPure, but the transformation is taken from an optic
filterWithPred :: Monad m => UtxoSearch m a -> (a -> Bool) -> UtxoSearch m a Source #
Same as filterWithPure but the outputs are selected using a boolean
 predicate, and not modified
filterWithValuePred :: Monad m => UtxoSearch m TxSkelOut -> (Value -> Bool) -> UtxoSearch m TxSkelOut Source #
A specific version of filterWithPred where outputs must me of type
 TxSkelOut and the predicate only relies on their value
filterWithOnlyAda :: Monad m => UtxoSearch m TxSkelOut -> UtxoSearch m TxSkelOut Source #
A specific version of filterWithValuePred when TxSkelOuts are only kept
 when they contain only ADA
filterWithNotOnlyAda :: Monad m => UtxoSearch m TxSkelOut -> UtxoSearch m TxSkelOut Source #
A specific version of filterWithValuePred when TxSkelOuts are only kept
 when they contain non-ADA assets
onlyValueOutputsAtSearch :: (MonadBlockChainBalancing m, ToAddress addr) => addr -> UtxoSearch m TxSkelOut Source #
Search for UTxOs at a specific address, which only carry address and value information (no datum, staking credential, or reference script).
vanillaOutputsAtSearch :: (MonadBlockChainBalancing m, ToAddress addr) => addr -> UtxoSearch m TxSkelOut Source #
Same as onlyValueOutputsAtSearch, but also ensures the returned outputs
 do not contain non-ADA assets. These "vanilla" outputs are perfect candidates
 to be used for balancing transaction and attaching collaterals.
filterWithAlways :: Monad m => UtxoSearch m a -> (a -> b) -> UtxoSearch m b Source #
Some as filterWithPure but with a total transformation
referenceScriptOutputsSearch :: (MonadBlockChain m, ToScriptHash s) => s -> UtxoSearch m TxSkelOut Source #
Searches for all outputs containing a given script as reference script
filterWithPureRev :: Monad m => UtxoSearch m a -> (a -> Maybe b) -> UtxoSearch m a Source #
Same as filterWithPure but inverses the predicate