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 () Ada 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 #
Search all currently known TxOutRef
s together with their corresponding
TxInfo
-TxOut
.
utxosAtSearch :: (MonadBlockChainBalancing m, ToAddress addr) => addr -> UtxoSearch m TxOut Source #
Search all TxOutRef
s at a certain address, together with their
TxInfo
-TxOut
.
utxosFromCardanoTxSearch :: Monad m => CardanoTx -> UtxoSearch m TxOut Source #
Search all TxOutRef
s of a transaction, together with their
TxInfo
-TxOut
.
txOutByRefSearch :: MonadBlockChainBalancing m => [TxOutRef] -> UtxoSearch m TxOut Source #
Search all TxInfo
-TxOut
s corresponding to given the list of
TxOutRef
s. 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 #
filterWithOptic :: (Is k An_AffineFold, Monad m) => UtxoSearch m a -> Optic' k is a b -> UtxoSearch m b Source #
filterWithPred :: Monad m => UtxoSearch m a -> (a -> Bool) -> UtxoSearch m a Source #
filterWithValuePred :: Monad m => UtxoSearch m TxOut -> (Value -> Bool) -> UtxoSearch m Value Source #
filterWithOnlyAda :: Monad m => UtxoSearch m TxOut -> UtxoSearch m Value Source #
filterWithNotOnlyAda :: Monad m => UtxoSearch m TxOut -> UtxoSearch m Value 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 #
scriptOutputsSearch :: (MonadBlockChain m, ToScriptHash s) => s -> UtxoSearch m (ConcreteOutput s OutputDatum Value ScriptHash) Source #
referenceScriptOutputsSearch :: (MonadBlockChain m, ToScriptHash s) => s -> UtxoSearch m (ConcreteOutput Credential OutputDatum Value ScriptHash) Source #