cooked-validators
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cooked.Tweak.Outputs

Description

Tweaks working on the outputs of a skeleton

Synopsis

Documentation

ensureOutputTweak :: MonadTweak m => TxSkelOut -> m (Maybe TxSkelOut) Source #

Ensure that a certain output is produced by a transaction. The return value will be Just the added output, when applicable.

addOutputTweak :: MonadTweak m => TxSkelOut -> m () Source #

Add a transaction output, at the end of the current list of outputs, thus retaining the initial outputs order.

removeOutputTweak :: MonadTweak m => (TxSkelOut -> Bool) -> m [TxSkelOut] Source #

Remove transaction outputs according to some predicate. The returned list contains all the removed outputs.

tamperDatumTweak :: forall a m. (MonadTweak m, FromData a, Typeable a) => (a -> Maybe a) -> m [a] Source #

A tweak that tries to change the datum on outputs carrying datums of a certain type with a prescribed tampering function. The tampering function ignores datums of other types and those for which it returns Nothing.

The tweak returns a list of the modified datums, as they were *before* the modification was applied to them.

malformDatumTweak :: forall a m. (MonadTweak m, Typeable a) => (a -> [BuiltinData]) -> m () Source #

A tweak that tries to change the datum on outputs carrying datums of a certain type with a prescribed tampering function. There are two main differences with tamperDatumTweak. First, the tampering function returns BuiltinData, allowing it to do pretty much anything with the datums. Second, for every output datum there are zero or more options for how to modify it, and all combinations of these modifications are tried.

That is, if there are n output datums, for which there are 'k_1,...,k_n' possible modifications, this tweak will try

  k_1 + ... + k_n
+ k_1 * k_2 + ... + k_{n-1} * k_n
+ k_1 * k_2 * k_3 + ... + k_{n-2} * k_{n-1} * k_n
+ ...
+ k_1 * k_2 * ... * k_{n-1} * k_n
== (k_1 + 1) * ... * (k_n + 1) - 1

modified transactions.