cooked-validators
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cooked.Tweak.Labels

Description

This module provides tweaks operating on transaction labels

Synopsis

Documentation

labelled :: MonadTweak m => Text -> m a -> m a Source #

labelled' specialised to Text labels.

someEndpoint = do
  ...
  validateTxSkel' txSkelTemplate
     { txSkelLabels =
        [ "InitialMinting"
        , "AuctionWorkflow"
        , "Spending"
        , label SomeLabelType]
     }

someTest = someEndpoint & somewhere (labelled "Spending" doubleSatAttack)

labelled' :: (MonadTweak m, LabelConstrs lbl) => lbl -> m a -> m a Source #

Apply a tweak to a given transaction if it has a specific label. This can be useful to apply a tweak to every (or any) transaction in a set of associated transactions.

someEndpoint = do
  ...
  validateTxSkel' txSkelTemplate
     { txSkelLabels =
        [ "InitialMinting"
        , "AuctionWorkflow"
        , label SomeLabelType]
     }

someTest = someEndpoint & eveywhere (labelled' SomeLabelType someTweak)
anotherTest = someEndpoint & somewhere (labelled' SomeLabelType someTweak)

addLabelTweak :: (MonadTweak m, LabelConstrs x) => x -> m () Source #

Adds a label to a TxSkel.

removeLabelTweak :: (MonadTweak m, LabelConstrs x) => x -> m () Source #

Removes a label from a TxSkel when possible, fails otherwise

hasLabelTweak :: (MonadTweak m, LabelConstrs x) => x -> m Bool Source #

Checks if a given label is present in the TxSkel

ensureLabelTweak :: (MonadTweak m, LabelConstrs x) => x -> m () Source #

Ensures a given label is present in the TxSkel