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 TxOut
- utxosAtSearch :: (MonadBlockChainBalancing m, ToAddress addr) => addr -> UtxoSearch m TxOut
- utxosFromCardanoTxSearch :: Monad m => CardanoTx -> UtxoSearch m TxOut
- txOutByRefSearch :: MonadBlockChainBalancing m => [TxOutRef] -> UtxoSearch m TxOut
- 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 TxOut -> (Value -> Bool) -> UtxoSearch m Value
- filterWithOnlyAda :: Monad m => UtxoSearch m TxOut -> UtxoSearch m Value
- filterWithNotOnlyAda :: Monad m => UtxoSearch m TxOut -> UtxoSearch m Value
- onlyValueOutputsAtSearch :: (MonadBlockChainBalancing m, ToAddress addr) => addr -> UtxoSearch m (ConcreteOutput Credential () Value ScriptHash)
- vanillaOutputsAtSearch :: (MonadBlockChainBalancing m, ToAddress addr) => addr -> UtxoSearch m (ConcreteOutput Credential () Lovelace ScriptHash)
- filterWithAlways :: Monad m => UtxoSearch m a -> (a -> b) -> UtxoSearch m b
- scriptOutputsSearch :: (MonadBlockChain m, ToScriptHash s) => s -> UtxoSearch m (ConcreteOutput s OutputDatum Value ScriptHash)
- referenceScriptOutputsSearch :: (MonadBlockChain m, ToScriptHash s) => s -> UtxoSearch m (ConcreteOutput Credential OutputDatum Value ScriptHash)
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 #
utxosAtSearch :: (MonadBlockChainBalancing m, ToAddress addr) => addr -> UtxoSearch m TxOut Source #
utxosFromCardanoTxSearch :: Monad m => CardanoTx -> UtxoSearch m TxOut Source #
txOutByRefSearch :: MonadBlockChainBalancing m => [TxOutRef] -> UtxoSearch m TxOut 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 TxOut -> (Value -> Bool) -> UtxoSearch m Value Source #
A specific version of filterWithPred
where outputs must me of type
TxOut
and the predicate only relies on their value
filterWithOnlyAda :: Monad m => UtxoSearch m TxOut -> UtxoSearch m Value Source #
A specific version of filterWithValuePred
when TxOut
s are only kept
when they contain only ADA
filterWithNotOnlyAda :: Monad m => UtxoSearch m TxOut -> UtxoSearch m Value Source #
A specific version of filterWithValuePred
when TxOut
s are only kept
when they contain non-ADA assets
onlyValueOutputsAtSearch :: (MonadBlockChainBalancing m, ToAddress addr) => addr -> UtxoSearch m (ConcreteOutput Credential () Value ScriptHash) 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 (ConcreteOutput Credential () Lovelace ScriptHash) 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
scriptOutputsSearch :: (MonadBlockChain m, ToScriptHash s) => s -> UtxoSearch m (ConcreteOutput s OutputDatum Value ScriptHash) Source #
Searches for all outputs belonging to a given script
referenceScriptOutputsSearch :: (MonadBlockChain m, ToScriptHash s) => s -> UtxoSearch m (ConcreteOutput Credential OutputDatum Value ScriptHash) Source #
Searches for all outputs containing a given script as reference script