diff --git a/src/Cooked/Attack/AddToken.hs b/src/Cooked/Attack/AddToken.hs index 355f5d867..1c676f304 100644 --- a/src/Cooked/Attack/AddToken.hs +++ b/src/Cooked/Attack/AddToken.hs @@ -18,7 +18,7 @@ import qualified PlutusTx.Numeric as Pl -- This attack adds an 'AddTokenLbl' with the token name of the additional -- minted token(s). It returns additional value minted. addTokenAttack :: - MonadTweak m => + (MonadTweak m) => -- | For each policy that occurs in some 'Mints' constraint, return a list of -- token names together with how many tokens with that name should be -- minted. diff --git a/src/Cooked/Attack/DoubleSat.hs b/src/Cooked/Attack/DoubleSat.hs index 367dcbda2..e49f28e90 100644 --- a/src/Cooked/Attack/DoubleSat.hs +++ b/src/Cooked/Attack/DoubleSat.hs @@ -122,7 +122,7 @@ doubleSatAttack groupings optic change attacker = do addLabelTweak DoubleSatLbl where -- for each triple of additional inputs, outputs, and mints, calculate its balance - deltaBalance :: MonadTweak m => DoubleSatDelta -> m Pl.Value + deltaBalance :: (MonadTweak m) => DoubleSatDelta -> m Pl.Value deltaBalance (inputs, outputs, mints) = do inValue <- foldMap (outputValue . snd) . filter ((`elem` Map.keys inputs) . fst) <$> allUtxos return $ inValue <> Pl.negate outValue <> mintValue @@ -131,7 +131,7 @@ doubleSatAttack groupings optic change attacker = do mintValue = txSkelMintsValue mints -- Helper tweak to add a 'DoubleSatDelta' to a transaction - addDoubleSatDeltaTweak :: MonadTweak m => DoubleSatDelta -> m () + addDoubleSatDeltaTweak :: (MonadTweak m) => DoubleSatDelta -> m () addDoubleSatDeltaTweak (ins, outs, mints) = mapM_ (uncurry addInputTweak) (Map.toList ins) >> mapM_ addOutputTweak outs diff --git a/src/Cooked/Attack/DupToken.hs b/src/Cooked/Attack/DupToken.hs index dd94d5966..7dcb4ef95 100644 --- a/src/Cooked/Attack/DupToken.hs +++ b/src/Cooked/Attack/DupToken.hs @@ -18,7 +18,7 @@ import qualified PlutusTx.Numeric as Pl -- transaction using 'addLabel'. Returns the 'Value' by which the minted value -- was increased. dupTokenAttack :: - MonadTweak m => + (MonadTweak m) => -- | A function describing how the amount of tokens specified by a 'Mints' -- constraint should be changed, depending on the asset class and the amount -- specified by the constraint. The given function @f@ should probably satisfy @@ -37,7 +37,7 @@ dupTokenAttack change attacker = do addLabelTweak DupTokenLbl return totalIncrement where - changeMintAmountsTweak :: MonadTweak m => m Pl.Value + changeMintAmountsTweak :: (MonadTweak m) => m Pl.Value changeMintAmountsTweak = do oldMintsList <- viewTweak $ txSkelMintsL % to txSkelMintsToList let newMintsList = diff --git a/src/Cooked/Ltl.hs b/src/Cooked/Ltl.hs index 19a7872eb..cec267cf0 100644 --- a/src/Cooked/Ltl.hs +++ b/src/Cooked/Ltl.hs @@ -86,7 +86,7 @@ data Ltl a -- <> b@ as the modification that first applies @b@ and then @a@. Attention: -- Since we use '<>' to define conjunction, if '<>' is not commutative, -- conjunction will also fail to be commutative! -nowLater :: Monoid a => Ltl a -> [(a, Ltl a)] +nowLater :: (Monoid a) => Ltl a -> [(a, Ltl a)] nowLater LtlTruth = [(mempty, LtlTruth)] nowLater LtlFalsity = [] nowLater (LtlAtom g) = [(g, LtlTruth)] @@ -120,7 +120,7 @@ finished (LtlRelease _ _) = True -- then the third and so on. We'd still like to compute a list of @(doNow, -- doLater)@ pairs as in 'nowLater', only that the @doLater@ should again be a -- list of formulas. -nowLaterList :: Monoid a => [Ltl a] -> [(a, [Ltl a])] +nowLaterList :: (Monoid a) => [Ltl a] -> [(a, [Ltl a])] nowLaterList = joinNowLaters . map nowLater where joinNowLaters [] = [(mempty, [])] @@ -251,7 +251,7 @@ instance Monad (Staged op) where -- (But to write this, @modification@ has to be a 'Monoid' to make -- 'nowLaterList' work!) Look at the tests for this module and at -- "Cooked.MockChain.Monad.Staged" for examples of how to use this type class. -class MonadPlus m => InterpLtl modification builtin m where +class (MonadPlus m) => InterpLtl modification builtin m where interpBuiltin :: builtin a -> StateT [Ltl modification] m a -- | Interpret a 'Staged' computation into a suitable domain, using the function @@ -297,7 +297,7 @@ interpLtlAndPruneUnfinished f = do -- LTL modifications beside the method above. -- | Monads that allow modificaitons with LTL formulas. -class Monad m => MonadModal m where +class (Monad m) => MonadModal m where type Modification m :: Type modifyLtl :: Ltl (Modification m) -> m a -> m a diff --git a/src/Cooked/MockChain/Balancing.hs b/src/Cooked/MockChain/Balancing.hs index 93200139b..b3aa8e0c1 100644 --- a/src/Cooked/MockChain/Balancing.hs +++ b/src/Cooked/MockChain/Balancing.hs @@ -42,7 +42,7 @@ import qualified Plutus.Script.Utils.Value as Pl import qualified Plutus.V2.Ledger.Api as PV2 import qualified PlutusTx.Numeric as Pl -balancedTxSkel :: MonadBlockChainBalancing m => TxSkel -> m (TxSkel, Fee, Set PV2.TxOutRef) +balancedTxSkel :: (MonadBlockChainBalancing m) => TxSkel -> m (TxSkel, Fee, Set PV2.TxOutRef) balancedTxSkel skelUnbal = do let balancingWallet = case txOptBalanceWallet . txSkelOpts $ skelUnbal of @@ -63,7 +63,7 @@ balancedTxSkel skelUnbal = do -- | Take the output of 'balancedTxSkel' and turn it into an actual Cardano -- transaction. -balancedTx :: MonadBlockChainBalancing m => (TxSkel, Fee, Set PV2.TxOutRef) -> m (C.Tx C.BabbageEra) +balancedTx :: (MonadBlockChainBalancing m) => (TxSkel, Fee, Set PV2.TxOutRef) -> m (C.Tx C.BabbageEra) balancedTx (skel, fee, collateralInputs) = do params <- applyEmulatorParamsModification (txOptEmulatorParamsModification . txSkelOpts $ skel) <$> getParams consumedData <- txSkelInputData skel @@ -89,7 +89,7 @@ balancedTx (skel, fee, collateralInputs) = do -- | Ensure that the transaction outputs have the necessary minimum amount of -- Ada on them. This will only be applied if the 'txOptEnsureMinAda' is set to -- @True@. -ensureTxSkelOutsMinAda :: MonadBlockChainBalancing m => TxSkel -> m TxSkel +ensureTxSkelOutsMinAda :: (MonadBlockChainBalancing m) => TxSkel -> m TxSkel ensureTxSkelOutsMinAda skel = do theParams <- applyEmulatorParamsModification (txOptEmulatorParamsModification . txSkelOpts $ skel) <$> getParams case mapM (ensureTxSkelOutHasMinAda theParams) $ skel ^. txSkelOutsL of @@ -116,16 +116,16 @@ ensureTxSkelOutsMinAda skel = do then ensureTxSkelOutHasMinAda theParams updatedTxSkelOut else return txSkelOut -txSkelInputUtxosPV2 :: MonadBlockChainBalancing m => TxSkel -> m (Map PV2.TxOutRef PV2.TxOut) +txSkelInputUtxosPV2 :: (MonadBlockChainBalancing m) => TxSkel -> m (Map PV2.TxOutRef PV2.TxOut) txSkelInputUtxosPV2 = lookupUtxosPV2 . Map.keys . txSkelIns -txSkelInputUtxos :: MonadBlockChainBalancing m => TxSkel -> m (Map PV2.TxOutRef Ledger.TxOut) +txSkelInputUtxos :: (MonadBlockChainBalancing m) => TxSkel -> m (Map PV2.TxOutRef Ledger.TxOut) txSkelInputUtxos = lookupUtxos . Map.keys . txSkelIns -txSkelReferenceInputUtxosPV2 :: MonadBlockChainBalancing m => TxSkel -> m (Map PV2.TxOutRef PV2.TxOut) +txSkelReferenceInputUtxosPV2 :: (MonadBlockChainBalancing m) => TxSkel -> m (Map PV2.TxOutRef PV2.TxOut) txSkelReferenceInputUtxosPV2 skel = Map.map txOutV2FromLedger <$> txSkelReferenceInputUtxos skel -txSkelReferenceInputUtxos :: MonadBlockChainBalancing m => TxSkel -> m (Map PV2.TxOutRef Ledger.TxOut) +txSkelReferenceInputUtxos :: (MonadBlockChainBalancing m) => TxSkel -> m (Map PV2.TxOutRef Ledger.TxOut) txSkelReferenceInputUtxos skel = lookupUtxos $ mapMaybe @@ -137,7 +137,7 @@ txSkelReferenceInputUtxos skel = ++ (Set.toList . txSkelInsReference $ skel) -- | All validators which protect transaction inputs -txSkelInputValidators :: MonadBlockChainBalancing m => TxSkel -> m (Map PV2.ValidatorHash (Pl.Versioned PV2.Validator)) +txSkelInputValidators :: (MonadBlockChainBalancing m) => TxSkel -> m (Map PV2.ValidatorHash (Pl.Versioned PV2.Validator)) txSkelInputValidators skel = do utxos <- Map.toList <$> lookupUtxosPV2 (Map.keys . txSkelIns $ skel) mValidators <- @@ -160,10 +160,10 @@ txSkelInputValidators skel = do -- Go through all of the 'PV2.TxOutRef's in the list and look them up in the -- state of the blockchain. If any 'PV2.TxOutRef' can't be resolved, throw an -- error. -lookupUtxosPV2 :: MonadBlockChainBalancing m => [PV2.TxOutRef] -> m (Map PV2.TxOutRef PV2.TxOut) +lookupUtxosPV2 :: (MonadBlockChainBalancing m) => [PV2.TxOutRef] -> m (Map PV2.TxOutRef PV2.TxOut) lookupUtxosPV2 outRefs = Map.map txOutV2FromLedger <$> lookupUtxos outRefs -lookupUtxos :: MonadBlockChainBalancing m => [PV2.TxOutRef] -> m (Map PV2.TxOutRef Ledger.TxOut) +lookupUtxos :: (MonadBlockChainBalancing m) => [PV2.TxOutRef] -> m (Map PV2.TxOutRef Ledger.TxOut) lookupUtxos outRefs = do Map.fromList <$> mapM @@ -182,13 +182,13 @@ lookupUtxos outRefs = do -- | look up the UTxOs the transaction consumes, and sum the value contained in -- them. -txSkelInputValue :: MonadBlockChainBalancing m => TxSkel -> m PV2.Value +txSkelInputValue :: (MonadBlockChainBalancing m) => TxSkel -> m PV2.Value txSkelInputValue skel = do txSkelInputs <- txSkelInputUtxos skel return $ foldMap (PV2.txOutValue . txOutV2FromLedger) txSkelInputs -- | Look up the data on UTxOs the transaction consumes. -txSkelInputData :: MonadBlockChainBalancing m => TxSkel -> m (Map PV2.DatumHash PV2.Datum) +txSkelInputData :: (MonadBlockChainBalancing m) => TxSkel -> m (Map PV2.DatumHash PV2.Datum) txSkelInputData skel = do txSkelInputs <- Map.elems <$> txSkelInputUtxosPV2 skel mDatums <- @@ -205,7 +205,7 @@ txSkelInputData skel = do txSkelInputs return . Map.fromList . catMaybes $ mDatums where - datumFromHashWithError :: MonadBlockChainBalancing m => Pl.DatumHash -> m PV2.Datum + datumFromHashWithError :: (MonadBlockChainBalancing m) => Pl.DatumHash -> m PV2.Datum datumFromHashWithError dHash = do mDatum <- datumFromHash dHash case mDatum of @@ -237,7 +237,7 @@ getEmulatorUTxO m = -- -- This function also adjusts the transaction outputs to contain at least the -- minimum Ada amount, if the 'txOptEnsureMinAda option is @True@. -setFeeAndBalance :: MonadBlockChainBalancing m => Wallet -> TxSkel -> m (TxSkel, Fee) +setFeeAndBalance :: (MonadBlockChainBalancing m) => Wallet -> TxSkel -> m (TxSkel, Fee) setFeeAndBalance balanceWallet skel0 = do -- do the min Ada adjustment if it's requested skel <- @@ -287,7 +287,7 @@ setFeeAndBalance balanceWallet skel0 = do -- Inspired by https://github.com/input-output-hk/plutus-apps/blob/d4255f05477fd8477ee9673e850ebb9ebb8c9657/plutus-contract/src/Wallet/Emulator/Wallet.hs#L329 calcFee :: - MonadBlockChainBalancing m => + (MonadBlockChainBalancing m) => Int -> Fee -> Emulator.UTxO Emulator.EmulatorEra -> @@ -346,7 +346,7 @@ estimateTxSkelFee params cUtxoIndex managedData managedTxOuts managedValidators C.Lovelace fee -> pure $ Fee fee -- | Calculates the collateral for a transaction -calcCollateral :: MonadBlockChainBalancing m => Wallet -> m (Set PV2.TxOutRef) +calcCollateral :: (MonadBlockChainBalancing m) => Wallet -> m (Set PV2.TxOutRef) calcCollateral w = do souts <- runUtxoSearch $ @@ -360,7 +360,7 @@ calcCollateral w = do -- investigated further for a better approach? return $ Set.fromList $ take 1 (fst <$> souts) -balanceTxFromAux :: MonadBlockChainBalancing m => Wallet -> TxSkel -> Fee -> m TxSkel +balanceTxFromAux :: (MonadBlockChainBalancing m) => Wallet -> TxSkel -> Fee -> m TxSkel balanceTxFromAux balanceWallet txskel fee = do bres@(BalanceTxRes {newInputs, returnValue, availableUtxos}) <- calcBalanceTx balanceWallet txskel fee case applyBalanceTx (walletPKHash balanceWallet) bres txskel of @@ -397,7 +397,7 @@ data BalanceTxRes = BalanceTxRes -- | Calculate the changes needed to balance a transaction with money from a -- given wallet. Every transaction that is sent to the chain must be balanced, -- that is: @inputs + mints == outputs + fee + burns@. -calcBalanceTx :: MonadBlockChainBalancing m => Wallet -> TxSkel -> Fee -> m BalanceTxRes +calcBalanceTx :: (MonadBlockChainBalancing m) => Wallet -> TxSkel -> Fee -> m BalanceTxRes calcBalanceTx balanceWallet skel fee = do inValue <- (<> positivePart (txSkelMintsValue $ txSkelMints skel)) <$> txSkelInputValue skel -- transaction inputs + minted value let outValue = txSkelOutputValue skel fee -- transaction outputs + fee + burned value diff --git a/src/Cooked/MockChain/BlockChain.hs b/src/Cooked/MockChain/BlockChain.hs index 9c32b8900..77952e888 100644 --- a/src/Cooked/MockChain/BlockChain.hs +++ b/src/Cooked/MockChain/BlockChain.hs @@ -122,7 +122,7 @@ class (MonadFail m, MonadError MockChainError m) => MonadBlockChainBalancing m w -- | Returns an output given a reference to it txOutByRefLedger :: PV2.TxOutRef -> m (Maybe Ledger.TxOut) -class MonadBlockChainBalancing m => MonadBlockChainWithoutValidation m where +class (MonadBlockChainBalancing m) => MonadBlockChainWithoutValidation m where -- | Returns a list of all currently known outputs. allUtxosLedger :: m [(PV2.TxOutRef, Ledger.TxOut)] @@ -137,7 +137,7 @@ class MonadBlockChainBalancing m => MonadBlockChainWithoutValidation m where awaitSlot :: Ledger.Slot -> m Ledger.Slot -- | The main abstraction of the blockchain. -class MonadBlockChainWithoutValidation m => MonadBlockChain m where +class (MonadBlockChainWithoutValidation m) => MonadBlockChain m where -- | Generates, balances and validates a transaction from a skeleton. -- It returns the validated transaction and updates the state of the -- blockchain. In 'MockChainT', this means: @@ -148,13 +148,13 @@ class MonadBlockChainWithoutValidation m => MonadBlockChain m where -- - adds the validators on outputs to the 'mcstValidators'. validateTxSkel :: TxSkel -> m Ledger.CardanoTx -allUtxos :: MonadBlockChainWithoutValidation m => m [(PV2.TxOutRef, PV2.TxOut)] +allUtxos :: (MonadBlockChainWithoutValidation m) => m [(PV2.TxOutRef, PV2.TxOut)] allUtxos = fmap (second txOutV2FromLedger) <$> allUtxosLedger -utxosAt :: MonadBlockChainBalancing m => PV2.Address -> m [(PV2.TxOutRef, PV2.TxOut)] +utxosAt :: (MonadBlockChainBalancing m) => PV2.Address -> m [(PV2.TxOutRef, PV2.TxOut)] utxosAt address = fmap (second txOutV2FromLedger) <$> utxosAtLedger address -txOutByRef :: MonadBlockChainBalancing m => PV2.TxOutRef -> m (Maybe PV2.TxOut) +txOutByRef :: (MonadBlockChainBalancing m) => PV2.TxOutRef -> m (Maybe PV2.TxOut) txOutByRef oref = fmap txOutV2FromLedger <$> txOutByRefLedger oref -- | Retrieve the ordered list of outputs of the given "CardanoTx". @@ -279,14 +279,14 @@ resolveReferenceScript out = (out ^. outputDatumL) (Just val) -outputDatumFromTxOutRef :: MonadBlockChainWithoutValidation m => PV2.TxOutRef -> m (Maybe PV2.OutputDatum) +outputDatumFromTxOutRef :: (MonadBlockChainWithoutValidation m) => PV2.TxOutRef -> m (Maybe PV2.OutputDatum) outputDatumFromTxOutRef oref = do mOut <- txOutByRef oref case mOut of Nothing -> return Nothing Just out -> return . Just $ outputOutputDatum out -datumFromTxOutRef :: MonadBlockChainWithoutValidation m => PV2.TxOutRef -> m (Maybe PV2.Datum) +datumFromTxOutRef :: (MonadBlockChainWithoutValidation m) => PV2.TxOutRef -> m (Maybe PV2.Datum) datumFromTxOutRef oref = do mOutputDatum <- outputDatumFromTxOutRef oref case mOutputDatum of @@ -306,7 +306,7 @@ typedDatumFromTxOutRef oref = do Nothing -> return Nothing Just (PV2.Datum datum) -> return $ PV2.fromBuiltinData datum -valueFromTxOutRef :: MonadBlockChainWithoutValidation m => PV2.TxOutRef -> m (Maybe PV2.Value) +valueFromTxOutRef :: (MonadBlockChainWithoutValidation m) => PV2.TxOutRef -> m (Maybe PV2.Value) valueFromTxOutRef oref = do mOut <- txOutByRef oref case mOut of @@ -373,7 +373,7 @@ awaitEnclosingSlot :: (MonadBlockChainWithoutValidation m) => PV2.POSIXTime -> m awaitEnclosingSlot = awaitSlot <=< getEnclosingSlot -- | The infinite range of slots ending before or at the given POSIX time -slotRangeBefore :: MonadBlockChainWithoutValidation m => PV2.POSIXTime -> m Ledger.SlotRange +slotRangeBefore :: (MonadBlockChainWithoutValidation m) => PV2.POSIXTime -> m Ledger.SlotRange slotRangeBefore t = do n <- getEnclosingSlot t (_, b) <- slotToTimeInterval n @@ -386,7 +386,7 @@ slotRangeBefore t = do else return $ PV2.to (n - 1) -- | The infinite range of slots starting after or at the given POSIX time -slotRangeAfter :: MonadBlockChainWithoutValidation m => PV2.POSIXTime -> m Ledger.SlotRange +slotRangeAfter :: (MonadBlockChainWithoutValidation m) => PV2.POSIXTime -> m Ledger.SlotRange slotRangeAfter t = do n <- getEnclosingSlot t (a, _) <- slotToTimeInterval n @@ -435,17 +435,17 @@ deriving via (AsTrans (WriterT w) m) instance (Monoid w, MonadBlockChainWithoutV deriving via (AsTrans (WriterT w) m) instance (Monoid w, MonadBlockChain m) => MonadBlockChain (WriterT w m) -deriving via (AsTrans (ReaderT r) m) instance MonadBlockChainBalancing m => MonadBlockChainBalancing (ReaderT r m) +deriving via (AsTrans (ReaderT r) m) instance (MonadBlockChainBalancing m) => MonadBlockChainBalancing (ReaderT r m) -deriving via (AsTrans (ReaderT r) m) instance MonadBlockChainWithoutValidation m => MonadBlockChainWithoutValidation (ReaderT r m) +deriving via (AsTrans (ReaderT r) m) instance (MonadBlockChainWithoutValidation m) => MonadBlockChainWithoutValidation (ReaderT r m) -deriving via (AsTrans (ReaderT r) m) instance MonadBlockChain m => MonadBlockChain (ReaderT r m) +deriving via (AsTrans (ReaderT r) m) instance (MonadBlockChain m) => MonadBlockChain (ReaderT r m) -deriving via (AsTrans (StateT s) m) instance MonadBlockChainBalancing m => MonadBlockChainBalancing (StateT s m) +deriving via (AsTrans (StateT s) m) instance (MonadBlockChainBalancing m) => MonadBlockChainBalancing (StateT s m) -deriving via (AsTrans (StateT s) m) instance MonadBlockChainWithoutValidation m => MonadBlockChainWithoutValidation (StateT s m) +deriving via (AsTrans (StateT s) m) instance (MonadBlockChainWithoutValidation m) => MonadBlockChainWithoutValidation (StateT s m) -deriving via (AsTrans (StateT s) m) instance MonadBlockChain m => MonadBlockChain (StateT s m) +deriving via (AsTrans (StateT s) m) instance (MonadBlockChain m) => MonadBlockChain (StateT s m) -- 'ListT' has no 'MonadTransControl' instance, so the @deriving via ...@ -- machinery is unusable here. However, there is @@ -456,17 +456,17 @@ deriving via (AsTrans (StateT s) m) instance MonadBlockChain m => MonadBlockChai -- 'MonadBlockChainWithoutValidation' and 'MonadBlockChain' instances for -- 'ListT', instead of more black magic... -instance MonadBlockChainBalancing m => MonadBlockChainBalancing (ListT m) where +instance (MonadBlockChainBalancing m) => MonadBlockChainBalancing (ListT m) where getParams = lift getParams validatorFromHash = lift . validatorFromHash utxosAtLedger = lift . utxosAtLedger txOutByRefLedger = lift . txOutByRefLedger datumFromHash = lift . datumFromHash -instance MonadBlockChainWithoutValidation m => MonadBlockChainWithoutValidation (ListT m) where +instance (MonadBlockChainWithoutValidation m) => MonadBlockChainWithoutValidation (ListT m) where allUtxosLedger = lift allUtxosLedger currentSlot = lift currentSlot awaitSlot = lift . awaitSlot -instance MonadBlockChain m => MonadBlockChain (ListT m) where +instance (MonadBlockChain m) => MonadBlockChain (ListT m) where validateTxSkel = lift . validateTxSkel diff --git a/src/Cooked/MockChain/Direct.hs b/src/Cooked/MockChain/Direct.hs index 39108afaf..3776fe3fc 100644 --- a/src/Cooked/MockChain/Direct.hs +++ b/src/Cooked/MockChain/Direct.hs @@ -251,7 +251,7 @@ utxoIndex0From i0 = Ledger.initialise [[Ledger.Valid $ initialTxFor i0]] initUtxosFor w v = txOut (walletAddress w) v (Nothing @()) - fromRight' :: Show e => Either e a -> a + fromRight' :: (Show e) => Either e a -> a fromRight' x = case x of Left err -> error $ show err Right res -> res @@ -305,21 +305,21 @@ getIndex = C.TxOutDatumInline s sd -> C.TxOutDatumInline s sd in C.TxOut addr val dat refS -instance Monad m => MonadBlockChainBalancing (MockChainT m) where +instance (Monad m) => MonadBlockChainBalancing (MockChainT m) where getParams = asks mceParams validatorFromHash valHash = gets $ Map.lookup valHash . mcstValidators txOutByRefLedger outref = gets $ Map.lookup outref . getIndex . mcstIndex datumFromHash datumHash = (txSkelOutUntypedDatum <=< Just . fst <=< Map.lookup datumHash) <$> gets mcstDatums utxosAtLedger addr = filter ((addr ==) . outputAddress . txOutV2FromLedger . snd) <$> allUtxosLedger -instance Monad m => MonadBlockChainWithoutValidation (MockChainT m) where +instance (Monad m) => MonadBlockChainWithoutValidation (MockChainT m) where allUtxosLedger = gets $ Map.toList . getIndex . mcstIndex currentSlot = gets mcstCurrentSlot awaitSlot s = modify' (\st -> st {mcstCurrentSlot = max s (mcstCurrentSlot st)}) >> currentSlot -instance Monad m => MonadBlockChain (MockChainT m) where +instance (Monad m) => MonadBlockChain (MockChainT m) where validateTxSkel skelUnbal = do (skel, fee, collateralInputs) <- balancedTxSkel skelUnbal tx <- balancedTx (skel, fee, collateralInputs) @@ -338,7 +338,7 @@ instance Monad m => MonadBlockChain (MockChainT m) where return someCardanoTx runTransactionValidation :: - Monad m => + (Monad m) => -- | The emulator parameters to use. They might have been changed by the 'txOptEmulatorParamsModification'. Emulator.Params -> -- | The transaction to validate. It should already be balanced, and include diff --git a/src/Cooked/MockChain/Staged.hs b/src/Cooked/MockChain/Staged.hs index 9e9fd2517..9f85879b7 100644 --- a/src/Cooked/MockChain/Staged.hs +++ b/src/Cooked/MockChain/Staged.hs @@ -51,7 +51,7 @@ import qualified Plutus.V2.Ledger.Api as Pl -- custom function. This can be used, for example, to supply a custom -- 'InitialDistribution' by providing 'runMockChainTFrom'. interpretAndRunWith :: - (forall m. Monad m => MockChainT m a -> m res) -> + (forall m. (Monad m) => MockChainT m a -> m res) -> StagedMockChain a -> [(res, MockChainLog)] interpretAndRunWith f smc = runWriterT $ f $ interpret smc @@ -129,7 +129,7 @@ instance MonadFail StagedMockChain where -- * 'InterpLtl' instance -instance MonadPlus m => MonadPlus (MockChainT m) where +instance (MonadPlus m) => MonadPlus (MockChainT m) where mzero = lift mzero mplus = combineMockChainT mplus @@ -200,17 +200,17 @@ type MonadModalBlockChain m = (MonadBlockChain m, MonadModal m, Modification m ~ -- | Apply a 'Tweak' to some transaction in the given Trace. The tweak must -- apply at least once. -somewhere :: MonadModalBlockChain m => Tweak InterpMockChain b -> m a -> m a +somewhere :: (MonadModalBlockChain m) => Tweak InterpMockChain b -> m a -> m a somewhere = modifyLtl . LtlUntil LtlTruth . LtlAtom . UntypedTweak -- | Apply a 'Tweak' to every transaction in a given trace. This is also -- successful if there are no transactions at all. -everywhere :: MonadModalBlockChain m => Tweak InterpMockChain b -> m a -> m a +everywhere :: (MonadModalBlockChain m) => Tweak InterpMockChain b -> m a -> m a everywhere = modifyLtl . LtlRelease LtlFalsity . LtlAtom . UntypedTweak -- | Apply a 'Tweak' to the nth transaction in a given trace, 0 indexed. -- Only successful when this transaction exists and can be modified. -there :: MonadModalBlockChain m => Integer -> Tweak InterpMockChain b -> m a -> m a +there :: (MonadModalBlockChain m) => Integer -> Tweak InterpMockChain b -> m a -> m a there n = modifyLtl . mkLtlFormula n where mkLtlFormula x = @@ -229,7 +229,7 @@ there n = modifyLtl . mkLtlFormula n -- where @endpoint@ builds and validates a single transaction depending on the -- given @arguments@. Then `withTweak` says "I want to modify the transaction -- returned by this endpoint in the following way". -withTweak :: MonadModalBlockChain m => m x -> Tweak InterpMockChain a -> m x +withTweak :: (MonadModalBlockChain m) => m x -> Tweak InterpMockChain a -> m x withTweak = flip (there 0) -- * 'MonadBlockChain' and 'MonadMockChain' instances diff --git a/src/Cooked/MockChain/UtxoSearch.hs b/src/Cooked/MockChain/UtxoSearch.hs index 719832af5..4a8bf1b0c 100644 --- a/src/Cooked/MockChain/UtxoSearch.hs +++ b/src/Cooked/MockChain/UtxoSearch.hs @@ -36,38 +36,38 @@ import qualified Plutus.V2.Ledger.Api as Pl2 type UtxoSearch m a = ListT m (Pl2.TxOutRef, a) -- | Given a UTxO search, we can run it to obtain a list of UTxOs. -runUtxoSearch :: Monad m => UtxoSearch m a -> m [(Pl2.TxOutRef, a)] +runUtxoSearch :: (Monad m) => UtxoSearch m a -> m [(Pl2.TxOutRef, a)] runUtxoSearch = ListT.toList -- | Search all currently known 'TxOutRef's together with their corresponding -- 'TxInfo'-'TxOut'. -allUtxosSearch :: MonadBlockChain m => UtxoSearch m Pl2.TxOut +allUtxosSearch :: (MonadBlockChain m) => UtxoSearch m Pl2.TxOut allUtxosSearch = allUtxos >>= ListT.fromFoldable -- | Like 'allUtxosSearch', but returns a Ledger-level representation of the -- transaction outputs, which might contain more information. -allUtxosLedgerSearch :: MonadBlockChain m => UtxoSearch m Ledger.TxOut +allUtxosLedgerSearch :: (MonadBlockChain m) => UtxoSearch m Ledger.TxOut allUtxosLedgerSearch = allUtxosLedger >>= ListT.fromFoldable -- | Search all 'TxOutRef's at a certain address, together with their -- 'TxInfo'-'TxOut'. -utxosAtSearch :: MonadBlockChainBalancing m => Pl2.Address -> UtxoSearch m Pl2.TxOut +utxosAtSearch :: (MonadBlockChainBalancing m) => Pl2.Address -> UtxoSearch m Pl2.TxOut utxosAtSearch = utxosAt >=> ListT.fromFoldable -- | Like 'utxosAtSearch', but returns a Ledger-level representation of the -- transaction outputs, which might contain more information. -utxosAtLedgerSearch :: MonadBlockChainBalancing m => Pl2.Address -> UtxoSearch m Ledger.TxOut +utxosAtLedgerSearch :: (MonadBlockChainBalancing m) => Pl2.Address -> UtxoSearch m Ledger.TxOut utxosAtLedgerSearch = utxosAtLedger >=> ListT.fromFoldable -- | Search all 'TxOutRef's of a transaction, together with their -- 'TxInfo'-'TxOut'. -utxosFromCardanoTxSearch :: Monad m => Ledger.CardanoTx -> UtxoSearch m Pl2.TxOut +utxosFromCardanoTxSearch :: (Monad m) => Ledger.CardanoTx -> UtxoSearch m Pl2.TxOut utxosFromCardanoTxSearch = ListT.fromFoldable . utxosFromCardanoTx -- | 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. -txOutByRefSearch :: MonadBlockChainBalancing m => [Pl2.TxOutRef] -> UtxoSearch m Pl2.TxOut +txOutByRefSearch :: (MonadBlockChainBalancing m) => [Pl2.TxOutRef] -> UtxoSearch m Pl2.TxOut txOutByRefSearch orefs = ListT.traverse (\o -> return (o, o)) (ListT.fromFoldable orefs) `filterWith` txOutByRef @@ -76,7 +76,7 @@ txOutByRefSearch orefs = -- | Transform a 'UtxoSearch' by applying a possibly failing monadic "lookup" -- on every output. -filterWith :: Monad m => UtxoSearch m a -> (a -> m (Maybe b)) -> UtxoSearch m b +filterWith :: (Monad m) => UtxoSearch m a -> (a -> m (Maybe b)) -> UtxoSearch m b filterWith (ListT as) f = ListT $ as >>= \case @@ -87,21 +87,21 @@ filterWith (ListT as) f = Nothing -> bs Just b -> return $ Just ((oref, b), filteredRest) -filterWithPure :: Monad m => UtxoSearch m a -> (a -> Maybe b) -> UtxoSearch m b +filterWithPure :: (Monad m) => UtxoSearch m a -> (a -> Maybe b) -> UtxoSearch m b filterWithPure as f = filterWith as (return . f) filterWithOptic :: (Is k An_AffineFold, Monad m) => UtxoSearch m a -> Optic' k is a b -> UtxoSearch m b filterWithOptic as optic = filterWithPure as (^? optic) -filterWithPred :: Monad m => UtxoSearch m a -> (a -> Bool) -> UtxoSearch m a +filterWithPred :: (Monad m) => UtxoSearch m a -> (a -> Bool) -> UtxoSearch m a filterWithPred as f = filterWithPure as $ \a -> if f a then Just a else Nothing -filterWithValuePred :: Monad m => UtxoSearch m Pl2.TxOut -> (Pl2.Value -> Bool) -> UtxoSearch m Pl2.Value +filterWithValuePred :: (Monad m) => UtxoSearch m Pl2.TxOut -> (Pl2.Value -> Bool) -> UtxoSearch m Pl2.Value filterWithValuePred as p = filterWithPure as $ \txOut -> let val = Pl2.txOutValue txOut in if p val then Just val else Nothing -filterWithOnlyAda :: Monad m => UtxoSearch m Pl2.TxOut -> UtxoSearch m Pl2.Value +filterWithOnlyAda :: (Monad m) => UtxoSearch m Pl2.TxOut -> UtxoSearch m Pl2.Value filterWithOnlyAda as = filterWithValuePred as $ (1 ==) . length . Pl2.flattenValue -filterWithNotOnlyAda :: Monad m => UtxoSearch m Pl2.TxOut -> UtxoSearch m Pl2.Value +filterWithNotOnlyAda :: (Monad m) => UtxoSearch m Pl2.TxOut -> UtxoSearch m Pl2.Value filterWithNotOnlyAda as = filterWithValuePred as $ (1 <) . length . Pl2.flattenValue diff --git a/src/Cooked/Output.hs b/src/Cooked/Output.hs index c82ac032d..c675c9ca2 100644 --- a/src/Cooked/Output.hs +++ b/src/Cooked/Output.hs @@ -163,7 +163,7 @@ outputReferenceScriptHash :: (IsAbstractOutput o, ToScriptHash (ReferenceScriptT outputReferenceScriptHash = (toScriptHash <$>) . (^. outputReferenceScriptL) -- | Return the output as it is seen by a validator on the 'TxInfo'. -outputTxOut :: IsTxInfoOutput o => o -> Pl.TxOut +outputTxOut :: (IsTxInfoOutput o) => o -> Pl.TxOut outputTxOut o = Pl.TxOut (outputAddress o) @@ -227,7 +227,7 @@ instance IsAbstractOutput (ConcreteOutput ownerType datumType valueType referenc -- | Test if there is no datum on an output. isOutputWithoutDatum :: - IsTxInfoOutput output => + (IsTxInfoOutput output) => output -> Maybe (ConcreteOutput (OwnerType output) () (ValueType output) (ReferenceScriptType output)) isOutputWithoutDatum out = case outputOutputDatum out of @@ -260,7 +260,7 @@ isOutputWithInlineDatumOfType out = -- | Test if the output carries some inlined datum. isOutputWithInlineDatum :: - IsTxInfoOutput output => + (IsTxInfoOutput output) => output -> Maybe (ConcreteOutput (OwnerType output) Pl.Datum (ValueType output) (ReferenceScriptType output)) isOutputWithInlineDatum out = @@ -277,7 +277,7 @@ isOutputWithInlineDatum out = -- | Test if the output carries some datum hash. isOutputWithDatumHash :: - IsTxInfoOutput output => + (IsTxInfoOutput output) => output -> Maybe (ConcreteOutput (OwnerType output) Pl.DatumHash (ValueType output) (ReferenceScriptType output)) isOutputWithDatumHash out = @@ -297,7 +297,7 @@ isOutputWithDatumHash out = -- | Test if the owner of an output is a specific typed validator. If it is, -- return an output with the validator type as its 'OwnerType'. isScriptOutputFrom :: - IsTxInfoOutput output => + (IsTxInfoOutput output) => Pl.TypedValidator a -> output -> Maybe (ConcreteOutput (Pl.TypedValidator a) (DatumType output) (ValueType output) (ReferenceScriptType output)) @@ -320,7 +320,7 @@ isScriptOutputFrom validator out = -- an output of the same 'DatumType', but with 'Pl.PubKeyHash' as its -- 'OwnerType'. isPKOutputFrom :: - IsTxInfoOutput output => + (IsTxInfoOutput output) => Pl.PubKeyHash -> output -> Maybe (ConcreteOutput Pl.PubKeyHash (DatumType output) (ValueType output) (ReferenceScriptType output)) @@ -342,7 +342,7 @@ isPKOutputFrom pkh out = case outputAddress out of -- | Test if the value on an output contains only Ada. isOnlyAdaOutput :: - IsTxInfoOutput output => + (IsTxInfoOutput output) => output -> Maybe (ConcreteOutput (OwnerType output) (DatumType output) Pl.Ada (ReferenceScriptType output)) isOnlyAdaOutput out = diff --git a/src/Cooked/Pretty/Class.hs b/src/Cooked/Pretty/Class.hs index 4f39fb605..5aa98f927 100644 --- a/src/Cooked/Pretty/Class.hs +++ b/src/Cooked/Pretty/Class.hs @@ -39,11 +39,11 @@ class PrettyCooked a where -- when dealing with pretty-printable cooked values. -- -- For example, @printCookedOpt def runMockChain i0 foo@ -printCookedOpt :: PrettyCooked a => PrettyCookedOpts -> a -> IO () +printCookedOpt :: (PrettyCooked a) => PrettyCookedOpts -> a -> IO () printCookedOpt opts e = PP.putDoc $ prettyCookedOpt opts e <+> PP.line -- | Version of 'printCookedOpt' that uses default pretty printing options. -printCooked :: PrettyCooked a => a -> IO () +printCooked :: (PrettyCooked a) => a -> IO () printCooked = printCookedOpt def instance PrettyCooked Pl.TxId where @@ -134,7 +134,7 @@ instance PrettyCooked Pl.POSIXTime where instance PrettyCooked Pl.ScriptHash where prettyCookedOpt opts = prettyHash (pcOptPrintedHashLength opts) -instance PrettyCooked a => PrettyCooked [a] where +instance (PrettyCooked a) => PrettyCooked [a] where prettyCookedOpt opts = prettyItemizeNoTitle "-" . map (prettyCookedOpt opts) instance PrettyCooked Int where diff --git a/src/Cooked/Pretty/Cooked.hs b/src/Cooked/Pretty/Cooked.hs index f9098bb44..cfdd7ca7f 100644 --- a/src/Cooked/Pretty/Cooked.hs +++ b/src/Cooked/Pretty/Cooked.hs @@ -145,14 +145,14 @@ instance PrettyCooked MockChainError where "-" [PP.viaShow err] -instance Show a => PrettyCooked (a, UtxoState) where +instance (Show a) => PrettyCooked (a, UtxoState) where prettyCookedOpt opts (res, state) = prettyItemize "End state:" "-" ["Returns:" <+> PP.viaShow res, prettyCookedOpt opts state] -instance Show a => PrettyCooked (Either MockChainError (a, UtxoState)) where +instance (Show a) => PrettyCooked (Either MockChainError (a, UtxoState)) where prettyCookedOpt opts (Left err) = "🔴" <+> prettyCookedOpt opts err prettyCookedOpt opts (Right endState) = "🟢" <+> prettyCookedOpt opts endState @@ -380,7 +380,7 @@ mPrettyTxOpts prettyIfNot def prettyEmulatorParamsModification txOptEmulatorParamsModification ] where - prettyIfNot :: Eq a => a -> (a -> DocCooked) -> a -> Maybe DocCooked + prettyIfNot :: (Eq a) => a -> (a -> DocCooked) -> a -> Maybe DocCooked prettyIfNot defaultValue f x | x == defaultValue && not (pcOptPrintDefaultTxOpts opts) = Nothing | otherwise = Just $ f x diff --git a/src/Cooked/ShowBS.hs b/src/Cooked/ShowBS.hs index 016d24548..7b10976cf 100644 --- a/src/Cooked/ShowBS.hs +++ b/src/Cooked/ShowBS.hs @@ -37,7 +37,7 @@ class ShowBS a where -- | analogue of 'shows' {-# INLINEABLE showBSs #-} -showBSs :: ShowBS a => a -> BuiltinString -> BuiltinString +showBSs :: (ShowBS a) => a -> BuiltinString -> BuiltinString showBSs = showBSsPrec 0 -- | Precedence of function applications @@ -62,7 +62,7 @@ showBSParen True s = literal "(" . s . literal ")" -- | print an application of a constructor to an argument {-# INLINEABLE application1 #-} -application1 :: ShowBS a => Integer -> BuiltinString -> a -> BuiltinString -> BuiltinString +application1 :: (ShowBS a) => Integer -> BuiltinString -> a -> BuiltinString -> BuiltinString application1 prec f x = showBSParen (app_prec <= prec) $ literal f . literal " " . showBSsPrec app_prec x -- | like 'application1' with two arguments @@ -134,7 +134,7 @@ digitToBS x | x == 9 = "9" | otherwise = "?" -instance ShowBS a => ShowBS [a] where +instance (ShowBS a) => ShowBS [a] where {-# INLINEABLE showBSsPrec #-} showBSsPrec _ = catList "[" "," "]" showBSs @@ -155,7 +155,7 @@ instance ShowBS Bool where showBSsPrec _ True = literal "True" showBSsPrec _ False = literal "False" -instance ShowBS a => ShowBS (Maybe a) where +instance (ShowBS a) => ShowBS (Maybe a) where {-# INLINEABLE showBSsPrec #-} showBSsPrec _ Nothing = literal "Nothing" showBSsPrec p (Just x) = application1 p "Just" x @@ -299,21 +299,21 @@ instance ShowBS POSIXTime where {-# INLINEABLE showBSsPrec #-} showBSsPrec p (POSIXTime t) = application1 p "POSIXTime" t -instance ShowBS a => ShowBS (Extended a) where +instance (ShowBS a) => ShowBS (Extended a) where {-# INLINEABLE showBSsPrec #-} showBSsPrec _ NegInf = literal "NegInf" showBSsPrec _ PosInf = literal "PosInf" showBSsPrec p (Finite x) = application1 p "Finite" x -instance ShowBS a => ShowBS (LowerBound a) where +instance (ShowBS a) => ShowBS (LowerBound a) where {-# INLINEABLE showBSsPrec #-} showBSsPrec p (LowerBound x closure) = application2 p "LowerBound" x closure -instance ShowBS a => ShowBS (UpperBound a) where +instance (ShowBS a) => ShowBS (UpperBound a) where {-# INLINEABLE showBSsPrec #-} showBSsPrec p (UpperBound x closure) = application2 p "UpperBound" x closure -instance ShowBS a => ShowBS (Interval a) where +instance (ShowBS a) => ShowBS (Interval a) where {-# INLINEABLE showBSsPrec #-} showBSsPrec p (Interval lb ub) = application2 p "Interval" lb ub diff --git a/src/Cooked/Skeleton.hs b/src/Cooked/Skeleton.hs index dde722270..3711e572f 100644 --- a/src/Cooked/Skeleton.hs +++ b/src/Cooked/Skeleton.hs @@ -121,7 +121,7 @@ import Type.Reflection type LabelConstrs x = (Show x, Typeable x, Eq x, Ord x) data TxLabel where - TxLabel :: LabelConstrs x => x -> TxLabel + TxLabel :: (LabelConstrs x) => x -> TxLabel instance Eq TxLabel where a == x = compare a x == EQ @@ -337,7 +337,7 @@ type MintsConstrs redeemer = -- corresponds to the redeemer @()@ on-chain. data MintsRedeemer where NoMintsRedeemer :: MintsRedeemer - SomeMintsRedeemer :: MintsConstrs redeemer => redeemer -> MintsRedeemer + SomeMintsRedeemer :: (MintsConstrs redeemer) => redeemer -> MintsRedeemer instance Show MintsRedeemer where show NoMintsRedeemer = "NoMintsRedeemer" @@ -580,13 +580,13 @@ data TxSkelOutDatum where -- | use no datum TxSkelOutNoDatum :: TxSkelOutDatum -- | only include the hash on the transaction - TxSkelOutDatumHash :: TxSkelOutDatumConstrs a => a -> TxSkelOutDatum + TxSkelOutDatumHash :: (TxSkelOutDatumConstrs a) => a -> TxSkelOutDatum -- | use a 'Pl.OutputDatumHash' on the transaction output, but generate the -- transaction in such a way that the complete datum is included in the -- 'txInfoData' seen by validators - TxSkelOutDatum :: TxSkelOutDatumConstrs a => a -> TxSkelOutDatum + TxSkelOutDatum :: (TxSkelOutDatumConstrs a) => a -> TxSkelOutDatum -- | use an inline datum - TxSkelOutInlineDatum :: TxSkelOutDatumConstrs a => a -> TxSkelOutDatum + TxSkelOutInlineDatum :: (TxSkelOutDatumConstrs a) => a -> TxSkelOutDatum deriving instance Show TxSkelOutDatum @@ -625,7 +625,7 @@ txSkelOutUntypedDatum = \case TxSkelOutDatum x -> Just (Pl.Datum $ Pl.toBuiltinData x) TxSkelOutInlineDatum x -> Just (Pl.Datum $ Pl.toBuiltinData x) -txSkelOutTypedDatum :: Pl.FromData a => TxSkelOutDatum -> Maybe a +txSkelOutTypedDatum :: (Pl.FromData a) => TxSkelOutDatum -> Maybe a txSkelOutTypedDatum = Pl.fromBuiltinData . Pl.getDatum <=< txSkelOutUntypedDatum -- ** Smart constructors for transaction outputs @@ -716,7 +716,7 @@ paysScriptDatumHash validator datum value = -- | Pays a script a certain value without any datum. Intended to be used with -- 'withDatum', 'withDatumHash', or 'withInlineDatum' to try a datum whose type -- does not match the validator's. -paysScriptNoDatum :: Typeable a => Pl.TypedValidator a -> Pl.Value -> TxSkelOut +paysScriptNoDatum :: (Typeable a) => Pl.TypedValidator a -> Pl.Value -> TxSkelOut paysScriptNoDatum validator value = Pays ( ConcreteOutput @@ -833,12 +833,12 @@ type SpendsScriptConstrs redeemer = data TxSkelRedeemer where TxSkelNoRedeemerForPK :: TxSkelRedeemer - TxSkelRedeemerForScript :: SpendsScriptConstrs redeemer => redeemer -> TxSkelRedeemer + TxSkelRedeemerForScript :: (SpendsScriptConstrs redeemer) => redeemer -> TxSkelRedeemer -- | The first argument is a reference to the output where the referenced -- script is stored. - TxSkelRedeemerForReferencedScript :: SpendsScriptConstrs redeemer => Pl.TxOutRef -> redeemer -> TxSkelRedeemer + TxSkelRedeemerForReferencedScript :: (SpendsScriptConstrs redeemer) => Pl.TxOutRef -> redeemer -> TxSkelRedeemer -txSkelTypedRedeemer :: Pl.FromData (Pl.RedeemerType a) => TxSkelRedeemer -> Maybe (Pl.RedeemerType a) +txSkelTypedRedeemer :: (Pl.FromData (Pl.RedeemerType a)) => TxSkelRedeemer -> Maybe (Pl.RedeemerType a) txSkelTypedRedeemer (TxSkelRedeemerForScript redeemer) = Pl.fromData . Pl.toData $ redeemer txSkelTypedRedeemer (TxSkelRedeemerForReferencedScript _ redeemer) = Pl.fromData . Pl.toData $ redeemer txSkelTypedRedeemer _ = Nothing diff --git a/src/Cooked/Tweak/AddInputsAndOutputs.hs b/src/Cooked/Tweak/AddInputsAndOutputs.hs index 6ad30d7cf..6c6e8d54c 100644 --- a/src/Cooked/Tweak/AddInputsAndOutputs.hs +++ b/src/Cooked/Tweak/AddInputsAndOutputs.hs @@ -31,7 +31,7 @@ import qualified Plutus.V2.Ledger.Api as Pl -- | Ensure that a given 'Pl.TxOutRef' is being spent with a given -- 'TxSkelRedeemer'. The return value will be @Just@ the added data, if anything -- changed. -ensureInputTweak :: MonadTweak m => Pl.TxOutRef -> TxSkelRedeemer -> m (Maybe (Pl.TxOutRef, TxSkelRedeemer)) +ensureInputTweak :: (MonadTweak m) => Pl.TxOutRef -> TxSkelRedeemer -> m (Maybe (Pl.TxOutRef, TxSkelRedeemer)) ensureInputTweak oref howConsumed = do presentInputs <- viewTweak txSkelInsL if presentInputs Map.!? oref == Just howConsumed @@ -42,7 +42,7 @@ ensureInputTweak oref howConsumed = do -- | Add an input to a transaction. If the given 'Pl.TxOutRef' is already being -- consumed by the transaction, fail. -addInputTweak :: MonadTweak m => Pl.TxOutRef -> TxSkelRedeemer -> m () +addInputTweak :: (MonadTweak m) => Pl.TxOutRef -> TxSkelRedeemer -> m () addInputTweak oref howConsumed = do presentInputs <- viewTweak txSkelInsL guard (Map.notMember oref presentInputs) @@ -50,7 +50,7 @@ addInputTweak oref howConsumed = do -- | Remove transaction inputs according to a given predicate. The returned list -- contains all removed inputs. -removeInputTweak :: MonadTweak m => (Pl.TxOutRef -> TxSkelRedeemer -> Bool) -> m [(Pl.TxOutRef, TxSkelRedeemer)] +removeInputTweak :: (MonadTweak m) => (Pl.TxOutRef -> TxSkelRedeemer -> Bool) -> m [(Pl.TxOutRef, TxSkelRedeemer)] removeInputTweak removePred = do presentInputs <- viewTweak txSkelInsL let (removed, kept) = Map.partitionWithKey removePred presentInputs @@ -61,7 +61,7 @@ removeInputTweak removePred = do -- | Ensure that a certain output is produced by a transaction. The return value -- will be @Just@ the added output, if there was any change. -ensureOutputTweak :: MonadTweak m => TxSkelOut -> m (Maybe TxSkelOut) +ensureOutputTweak :: (MonadTweak m) => TxSkelOut -> m (Maybe TxSkelOut) ensureOutputTweak txSkelOut = do presentOutputs <- viewTweak txSkelOutsL if txSkelOut `elem` presentOutputs @@ -72,12 +72,12 @@ ensureOutputTweak txSkelOut = do -- | Add a transaction output, at the end of the current list of outputs, -- thus retaining the order in which they have been specified. -addOutputTweak :: MonadTweak m => TxSkelOut -> m () +addOutputTweak :: (MonadTweak m) => TxSkelOut -> m () addOutputTweak txSkelOut = overTweak txSkelOutsL (++ [txSkelOut]) -- | Remove transaction outputs according to some predicate. The returned list -- contains all the removed outputs. -removeOutputTweak :: MonadTweak m => (TxSkelOut -> Bool) -> m [TxSkelOut] +removeOutputTweak :: (MonadTweak m) => (TxSkelOut -> Bool) -> m [TxSkelOut] removeOutputTweak removePred = do presentOutputs <- viewTweak txSkelOutsL let (removed, kept) = partition removePred presentOutputs @@ -89,13 +89,13 @@ removeOutputTweak removePred = do -- | Add a new entry to the 'TxSkelMints' of the transaction skeleton under -- modification. As this is implemented in terms of 'addToTxSkelMints', the same -- caveats apply as do to that function! -addMintTweak :: MonadTweak m => (Pl.Versioned Pl.MintingPolicy, MintsRedeemer, Pl.TokenName, Integer) -> m () +addMintTweak :: (MonadTweak m) => (Pl.Versioned Pl.MintingPolicy, MintsRedeemer, Pl.TokenName, Integer) -> m () addMintTweak mint = overTweak txSkelMintsL $ addToTxSkelMints mint -- | Remove some entries from the 'TxSkelMints' of a transaction, according to -- some predicate. The returned list holds the removed entries. removeMintTweak :: - MonadTweak m => + (MonadTweak m) => ((Pl.Versioned Pl.MintingPolicy, MintsRedeemer, Pl.TokenName, Integer) -> Bool) -> m [(Pl.Versioned Pl.MintingPolicy, MintsRedeemer, Pl.TokenName, Integer)] removeMintTweak removePred = do diff --git a/src/Cooked/Tweak/Common.hs b/src/Cooked/Tweak/Common.hs index 60d507b8f..286e6ad6e 100644 --- a/src/Cooked/Tweak/Common.hs +++ b/src/Cooked/Tweak/Common.hs @@ -48,7 +48,7 @@ class (MonadPlus m, MonadBlockChainWithoutValidation m) => MonadTweak m where type Tweak m = StateT TxSkel (ListT m) -instance MonadBlockChainWithoutValidation m => MonadTweak (Tweak m) where +instance (MonadBlockChainWithoutValidation m) => MonadTweak (Tweak m) where getTxSkel = get putTxSkel = put @@ -82,7 +82,7 @@ runTweakInChain tweak skel = ListT.alternate $ runStateT tweak skel -- If you're trying to apply a tweak to a transaction directly before it's -- modified, consider using 'MonadModalBlockChain' and idioms like 'withTweak', -- 'somewhere', or 'everywhere'. -runTweakInChain' :: MonadBlockChainWithoutValidation m => Tweak m a -> TxSkel -> m [(a, TxSkel)] +runTweakInChain' :: (MonadBlockChainWithoutValidation m) => Tweak m a -> TxSkel -> m [(a, TxSkel)] runTweakInChain' tweak skel = ListT.toList $ runStateT tweak skel -- | This is a wrapper type used in the implementation of the Staged monad. You @@ -90,21 +90,21 @@ runTweakInChain' tweak skel = ListT.toList $ runStateT tweak skel data UntypedTweak m where UntypedTweak :: Tweak m a -> UntypedTweak m -instance Monad m => Semigroup (UntypedTweak m) where +instance (Monad m) => Semigroup (UntypedTweak m) where -- The right tweak is applied first UntypedTweak f <> UntypedTweak g = UntypedTweak $ g >> f -instance Monad m => Monoid (UntypedTweak m) where +instance (Monad m) => Monoid (UntypedTweak m) where mempty = UntypedTweak $ return () -- * A few fundamental tweaks -- | The never-applicable tweak. -failingTweak :: MonadTweak m => m a +failingTweak :: (MonadTweak m) => m a failingTweak = mzero -- | The tweak that always applies and leaves the transaction unchanged. -doNothingTweak :: MonadTweak m => m () +doNothingTweak :: (MonadTweak m) => m () doNothingTweak = return () -- * Constructing Tweaks from Optics diff --git a/src/Cooked/Tweak/OutPermutations.hs b/src/Cooked/Tweak/OutPermutations.hs index dc25247f2..0b049ecb4 100644 --- a/src/Cooked/Tweak/OutPermutations.hs +++ b/src/Cooked/Tweak/OutPermutations.hs @@ -35,7 +35,7 @@ data PermutOutTweakMode = KeepIdentity (Maybe Int) | OmitIdentity (Maybe Int) -- -- (In particular, this is clever enough to generate only the distinct -- permutations, even if some outputs are identical.) -allOutPermutsTweak :: MonadTweak m => PermutOutTweakMode -> m () +allOutPermutsTweak :: (MonadTweak m) => PermutOutTweakMode -> m () allOutPermutsTweak mode = do oldOut <- viewTweak txSkelOutsL msum $ @@ -51,19 +51,19 @@ allOutPermutsTweak mode = do -- This is implemented so that duplicate entries in the input list don't give -- rise to duplicate permutations. -distinctPermutations :: Eq a => [a] -> [[a]] +distinctPermutations :: (Eq a) => [a] -> [[a]] distinctPermutations = foldr (concatMap . insertSomewhere) [[]] . groupEq where -- group all equal elements. If we had @Ord a@, we could implement this more -- effifiently as @group . sort@. - groupEq :: Eq a => [a] -> [[a]] + groupEq :: (Eq a) => [a] -> [[a]] groupEq l = map (\x -> replicate (count x l) x) $ makeUnique l where - count :: Eq a => a -> [a] -> Int + count :: (Eq a) => a -> [a] -> Int count _ [] = 0 count a (b : bs) = if a /= b then count a bs else 1 + count a bs - makeUnique :: Eq a => [a] -> [a] + makeUnique :: (Eq a) => [a] -> [a] makeUnique [] = [] makeUnique (x : xs) = let xs' = makeUnique xs @@ -77,16 +77,16 @@ distinctPermutations = foldr (concatMap . insertSomewhere) [[]] . groupEq insertSomewhere l@(x : xs) r@(y : ys) = map (x :) (insertSomewhere xs r) ++ map (y :) (insertSomewhere l ys) -nonIdentityPermutations :: Eq a => [a] -> [[a]] +nonIdentityPermutations :: (Eq a) => [a] -> [[a]] nonIdentityPermutations l = removeFirst l $ distinctPermutations l where - removeFirst :: Eq a => a -> [a] -> [a] + removeFirst :: (Eq a) => a -> [a] -> [a] removeFirst _ [] = [] removeFirst x (y : ys) = if x == y then ys else y : removeFirst x ys -- | This randomly permutes the outputs of a transaction with a given seed -- Can be used to assess if a certain validator is order-dependant -singleOutPermutTweak :: MonadTweak m => Int -> m () +singleOutPermutTweak :: (MonadTweak m) => Int -> m () singleOutPermutTweak seed = do outputs <- viewTweak txSkelOutsL let outputs' = shuffle' outputs (length outputs) (mkStdGen seed) diff --git a/src/Cooked/Tweak/Signers.hs b/src/Cooked/Tweak/Signers.hs index cbb1eed90..2eb1fcb18 100644 --- a/src/Cooked/Tweak/Signers.hs +++ b/src/Cooked/Tweak/Signers.hs @@ -25,58 +25,58 @@ import Cooked.Wallet (Wallet) import Data.List (delete, (\\)) -- | Returns the current list of signers -getSignersTweak :: MonadTweak m => m [Wallet] +getSignersTweak :: (MonadTweak m) => m [Wallet] getSignersTweak = viewTweak txSkelSignersL -- | Apply a function to the list of signers and return the old ones -modifySignersTweak :: MonadTweak m => ([Wallet] -> [Wallet]) -> m [Wallet] +modifySignersTweak :: (MonadTweak m) => ([Wallet] -> [Wallet]) -> m [Wallet] modifySignersTweak f = do oldSigners <- getSignersTweak setTweak txSkelSignersL (f oldSigners) return oldSigners -- | Change the current signers and return the old ones -setSignersTweak :: MonadTweak m => [Wallet] -> m [Wallet] +setSignersTweak :: (MonadTweak m) => [Wallet] -> m [Wallet] setSignersTweak = modifySignersTweak . const -- | Check if the signers satisfy a certain predicate -signersSatisfyTweak :: MonadTweak m => ([Wallet] -> Bool) -> m Bool +signersSatisfyTweak :: (MonadTweak m) => ([Wallet] -> Bool) -> m Bool signersSatisfyTweak = (<$> getSignersTweak) -- | Check if a wallet signs a transaction -isSignerTweak :: MonadTweak m => Wallet -> m Bool +isSignerTweak :: (MonadTweak m) => Wallet -> m Bool isSignerTweak = signersSatisfyTweak . elem -- | Check if the transaction has at least a signer -hasSignersTweak :: MonadTweak m => m Bool +hasSignersTweak :: (MonadTweak m) => m Bool hasSignersTweak = signersSatisfyTweak (not . null) -- | Add a signer to the transaction, at the head of the list of signers, and -- return the old list of signers -addFirstSignerTweak :: MonadTweak m => Wallet -> m [Wallet] +addFirstSignerTweak :: (MonadTweak m) => Wallet -> m [Wallet] addFirstSignerTweak = modifySignersTweak . (:) -- | Add signers at the end of the list of signers, and return the old list of -- signers -addSignersTweak :: MonadTweak m => [Wallet] -> m [Wallet] +addSignersTweak :: (MonadTweak m) => [Wallet] -> m [Wallet] addSignersTweak = modifySignersTweak . (<>) -- | Add a signer to the transaction, at the end of the list of signers, and -- return the old list of signers -addLastSignerTweak :: MonadTweak m => Wallet -> m [Wallet] +addLastSignerTweak :: (MonadTweak m) => Wallet -> m [Wallet] addLastSignerTweak = addSignersTweak . (: []) -- | Remove signers from the transaction and return the old list of signers -removeSignersTweak :: MonadTweak m => [Wallet] -> m [Wallet] +removeSignersTweak :: (MonadTweak m) => [Wallet] -> m [Wallet] removeSignersTweak = modifySignersTweak . (\\) -- | Remove a signer from the transaction and return the old list of signers -removeSignerTweak :: MonadTweak m => Wallet -> m [Wallet] +removeSignerTweak :: (MonadTweak m) => Wallet -> m [Wallet] removeSignerTweak = modifySignersTweak . delete -- | Changes the first signer (adds it if there are no signers) and return the -- old list of signers. -replaceFirstSignerTweak :: MonadTweak m => Wallet -> m [Wallet] +replaceFirstSignerTweak :: (MonadTweak m) => Wallet -> m [Wallet] replaceFirstSignerTweak = modifySignersTweak . ( \newSigner -> \case diff --git a/src/Cooked/Tweak/TamperDatum.hs b/src/Cooked/Tweak/TamperDatum.hs index 72d68e808..4f33b6857 100644 --- a/src/Cooked/Tweak/TamperDatum.hs +++ b/src/Cooked/Tweak/TamperDatum.hs @@ -112,7 +112,7 @@ malformDatumTweak change = do changeTxSkelOutDatum (TxSkelOutDatumHash datum) = map TxSkelOutDatumHash $ changeOnCorrectType datum changeTxSkelOutDatum (TxSkelOutInlineDatum datum) = map TxSkelOutInlineDatum $ changeOnCorrectType datum - changeOnCorrectType :: Typeable b => b -> [Pl.BuiltinData] + changeOnCorrectType :: (Typeable b) => b -> [Pl.BuiltinData] changeOnCorrectType datum = case typeOf datum `eqTypeRep` (typeRep @a) of Just HRefl -> change datum Nothing -> [] diff --git a/src/Cooked/Tweak/ValidityRange.hs b/src/Cooked/Tweak/ValidityRange.hs index ce0e8e898..a91ee6ba4 100644 --- a/src/Cooked/Tweak/ValidityRange.hs +++ b/src/Cooked/Tweak/ValidityRange.hs @@ -9,55 +9,55 @@ import Ledger (before, contains, intersection, interval, isEmpty, member, never, import Ledger.Slot (Slot (Slot), SlotRange) import Plutus.V2.Ledger.Api (Extended (Finite), Interval (..), LowerBound (..), UpperBound (..), always) -getValidityRangeTweak :: MonadTweak m => m SlotRange +getValidityRangeTweak :: (MonadTweak m) => m SlotRange getValidityRangeTweak = viewTweak txSkelValidityRangeL -- | Changes the current validity range, returning the old one -setValidityRangeTweak :: MonadTweak m => SlotRange -> m SlotRange +setValidityRangeTweak :: (MonadTweak m) => SlotRange -> m SlotRange setValidityRangeTweak newRange = do oldRange <- getValidityRangeTweak setTweak txSkelValidityRangeL newRange return oldRange -- | Ensures the skeleton makes for an unconstrained validity range -setAlwaysValidRangeTweak :: MonadTweak m => m SlotRange +setAlwaysValidRangeTweak :: (MonadTweak m) => m SlotRange setAlwaysValidRangeTweak = setValidityRangeTweak always -- | Sets the left bound of the validity range. Leaves the right bound unchanged -setValidityStartTweak :: MonadTweak m => Slot -> m SlotRange +setValidityStartTweak :: (MonadTweak m) => Slot -> m SlotRange setValidityStartTweak left = getValidityRangeTweak >>= setValidityRangeTweak . Interval (LowerBound (Finite left) True) . ivTo -- | Sets the right bound of the validity range. Leaves the left bound unchanged -setValidityEndTweak :: MonadTweak m => Slot -> m SlotRange +setValidityEndTweak :: (MonadTweak m) => Slot -> m SlotRange setValidityEndTweak right = getValidityRangeTweak >>= setValidityRangeTweak . flip Interval (UpperBound (Finite right) True) . ivFrom -- | Checks if the validity range satisfies a certain predicate -validityRangeSatisfiesTweak :: MonadTweak m => (SlotRange -> Bool) -> m Bool +validityRangeSatisfiesTweak :: (MonadTweak m) => (SlotRange -> Bool) -> m Bool validityRangeSatisfiesTweak = (<$> getValidityRangeTweak) -- | Checks if a given time belongs to the validity range of a transaction -isValidAtTweak :: MonadTweak m => Slot -> m Bool +isValidAtTweak :: (MonadTweak m) => Slot -> m Bool isValidAtTweak = validityRangeSatisfiesTweak . member -- | Checks if the current validity range includes the current time -isValidNowTweak :: MonadTweak m => m Bool +isValidNowTweak :: (MonadTweak m) => m Bool isValidNowTweak = currentSlot >>= isValidAtTweak -- | Checks if a given range is included in the validity range of a transaction -isValidDuringTweak :: MonadTweak m => SlotRange -> m Bool +isValidDuringTweak :: (MonadTweak m) => SlotRange -> m Bool isValidDuringTweak = validityRangeSatisfiesTweak . flip contains -- | Checks if the validity range is empty -hasEmptyTimeRangeTweak :: MonadTweak m => m Bool +hasEmptyTimeRangeTweak :: (MonadTweak m) => m Bool hasEmptyTimeRangeTweak = validityRangeSatisfiesTweak isEmpty -- | Checks if the validity range is unconstrained -hasFullTimeRangeTweak :: MonadTweak m => m Bool +hasFullTimeRangeTweak :: (MonadTweak m) => m Bool hasFullTimeRangeTweak = validityRangeSatisfiesTweak (always ==) -- | Adds a constraint to the current validity range -- Returns the old range, and fails is the resulting interval is empty -intersectValidityRangeTweak :: MonadTweak m => SlotRange -> m SlotRange +intersectValidityRangeTweak :: (MonadTweak m) => SlotRange -> m SlotRange intersectValidityRangeTweak newRange = do oldRange <- viewTweak txSkelValidityRangeL let combinedRange = intersection newRange oldRange @@ -66,7 +66,7 @@ intersectValidityRangeTweak newRange = do return oldRange -- | Centers the validity range around a value with a certain radius -centerAroundValidityRangeTweak :: MonadTweak m => Slot -> Integer -> m SlotRange +centerAroundValidityRangeTweak :: (MonadTweak m) => Slot -> Integer -> m SlotRange centerAroundValidityRangeTweak t r = do let radius = Slot r left = t - radius @@ -75,17 +75,17 @@ centerAroundValidityRangeTweak t r = do setValidityRangeTweak newRange -- | Makes a transaction range equal to a singleton -makeValidityRangeSingletonTweak :: MonadTweak m => Slot -> m SlotRange +makeValidityRangeSingletonTweak :: (MonadTweak m) => Slot -> m SlotRange makeValidityRangeSingletonTweak = setValidityRangeTweak . singleton -- | Makes the transaction validity range comply with the current time -makeValidityRangeNowTweak :: MonadTweak m => m SlotRange +makeValidityRangeNowTweak :: (MonadTweak m) => m SlotRange makeValidityRangeNowTweak = currentSlot >>= makeValidityRangeSingletonTweak -- | Makes current time comply with the validity range of the transaction under -- modification. Returns the new current time after the modification; fails if -- current time is already after the validity range. -waitUntilValidTweak :: MonadTweak m => m Slot +waitUntilValidTweak :: (MonadTweak m) => m Slot waitUntilValidTweak = do now <- currentSlot vRange <- getValidityRangeTweak diff --git a/src/Cooked/ValueUtils.hs b/src/Cooked/ValueUtils.hs index d5fb6d6f4..f374dc598 100644 --- a/src/Cooked/ValueUtils.hs +++ b/src/Cooked/ValueUtils.hs @@ -47,5 +47,5 @@ adaL = value ) where - insertAssocList :: Eq a => [(a, b)] -> a -> b -> [(a, b)] + insertAssocList :: (Eq a) => [(a, b)] -> a -> b -> [(a, b)] insertAssocList l a b = (a, b) : filter ((/= a) . fst) l diff --git a/tests/Cooked/Attack/DatumHijackingSpec.hs b/tests/Cooked/Attack/DatumHijackingSpec.hs index 512eff70b..84cc29c00 100644 --- a/tests/Cooked/Attack/DatumHijackingSpec.hs +++ b/tests/Cooked/Attack/DatumHijackingSpec.hs @@ -71,7 +71,7 @@ lockTxSkel o v = txSkelSigners = [wallet 1] } -txLock :: MonadBlockChain m => Pl.TypedValidator MockContract -> m () +txLock :: (MonadBlockChain m) => Pl.TypedValidator MockContract -> m () txLock v = do (oref, _) : _ <- runUtxoSearch $ @@ -89,7 +89,7 @@ relockTxSkel v o = } txRelock :: - MonadBlockChain m => + (MonadBlockChain m) => Pl.TypedValidator MockContract -> m () txRelock v = do @@ -101,7 +101,7 @@ txRelock v = do `filterWithPred` ((FirstLock ==) . (^. outputDatumL)) void $ validateTxSkel $ relockTxSkel v oref -datumHijackingTrace :: MonadBlockChain m => Pl.TypedValidator MockContract -> m () +datumHijackingTrace :: (MonadBlockChain m) => Pl.TypedValidator MockContract -> m () datumHijackingTrace v = do txLock v txRelock v @@ -190,9 +190,9 @@ tests = Pl.validatorHash val1 == Pl.validatorHash v && d - == TxSkelOutInlineDatum SecondLock + == TxSkelOutInlineDatum SecondLock && bound - `Pl.geq` x + `Pl.geq` x ) select ) diff --git a/tests/Cooked/Attack/DupTokenSpec.hs b/tests/Cooked/Attack/DupTokenSpec.hs index dc7faec38..8e9e637f7 100644 --- a/tests/Cooked/Attack/DupTokenSpec.hs +++ b/tests/Cooked/Attack/DupTokenSpec.hs @@ -52,7 +52,7 @@ carelessPolicy = Pl.mkMintingPolicyScript $$(Pl.compile [||Pl.mkUntypedMintingPolicy mkCarelessPolicy||]) -dupTokenTrace :: MonadBlockChain m => Pl.Versioned Pl.MintingPolicy -> Pl.TokenName -> Integer -> Wallet -> m () +dupTokenTrace :: (MonadBlockChain m) => Pl.Versioned Pl.MintingPolicy -> Pl.TokenName -> Integer -> Wallet -> m () dupTokenTrace pol tName amount recipient = void $ validateTxSkel skel where skel = diff --git a/tests/Cooked/LtlSpec.hs b/tests/Cooked/LtlSpec.hs index 058d24418..ad025192c 100644 --- a/tests/Cooked/LtlSpec.hs +++ b/tests/Cooked/LtlSpec.hs @@ -24,7 +24,7 @@ instance {-# OVERLAPS #-} Semigroup TestModification where instance {-# OVERLAPS #-} Monoid TestModification where mempty = id -instance MonadPlus m => InterpLtl TestModification TestBuiltin (WriterT [Integer] m) where +instance (MonadPlus m) => InterpLtl TestModification TestBuiltin (WriterT [Integer] m) where interpBuiltin GetInteger = return 42 interpBuiltin (EmitInteger i) = get @@ -55,10 +55,10 @@ my opinion. -} -somewhere :: MonadModal m => Modification m -> m a -> m a +somewhere :: (MonadModal m) => Modification m -> m a -> m a somewhere x = modifyLtl $ LtlTruth `LtlUntil` LtlAtom x -everywhere :: MonadModal m => Modification m -> m a -> m a +everywhere :: (MonadModal m) => Modification m -> m a -> m a everywhere x = modifyLtl $ LtlFalsity `LtlRelease` LtlAtom x emitInteger :: Integer -> Staged (LtlOp TestModification TestBuiltin) () diff --git a/tests/Cooked/MinAdaSpec.hs b/tests/Cooked/MinAdaSpec.hs index 7f6aec5fd..9378c9706 100644 --- a/tests/Cooked/MinAdaSpec.hs +++ b/tests/Cooked/MinAdaSpec.hs @@ -19,7 +19,7 @@ import Test.Tasty.HUnit heavyDatum :: [Integer] heavyDatum = take 100 [0 ..] -paymentWithMinAda :: MonadBlockChain m => m Integer +paymentWithMinAda :: (MonadBlockChain m) => m Integer paymentWithMinAda = do Pl.getLovelace . (^. adaL) . outputValue . snd . (!! 0) . utxosFromCardanoTx <$> validateTxSkel @@ -34,7 +34,7 @@ paymentWithMinAda = do txSkelSigners = [wallet 1] } -paymentWithoutMinAda :: MonadBlockChain m => Integer -> m () +paymentWithoutMinAda :: (MonadBlockChain m) => Integer -> m () paymentWithoutMinAda paidLovelaces = do void $ validateTxSkel diff --git a/tests/Cooked/ReferenceInputsSpec.hs b/tests/Cooked/ReferenceInputsSpec.hs index 8ea091331..ac7a2aa1c 100644 --- a/tests/Cooked/ReferenceInputsSpec.hs +++ b/tests/Cooked/ReferenceInputsSpec.hs @@ -96,7 +96,7 @@ barTypedValidator = $$(Pl.compile [||barValidator||]) $$(Pl.compile [||wrap||]) -trace1 :: MonadBlockChain m => m () +trace1 :: (MonadBlockChain m) => m () trace1 = do (txOutRefFoo, _) : (txOutRefBar, _) : _ <- utxosFromCardanoTx diff --git a/tests/Cooked/ReferenceScriptsSpec.hs b/tests/Cooked/ReferenceScriptsSpec.hs index 4399e7c17..0e75f1677 100644 --- a/tests/Cooked/ReferenceScriptsSpec.hs +++ b/tests/Cooked/ReferenceScriptsSpec.hs @@ -92,7 +92,7 @@ requireRefScriptValidator = wrap = Pl.mkUntypedValidator putRefScriptOnWalletOutput :: - MonadBlockChain m => + (MonadBlockChain m) => Wallet -> Pl.TypedValidator MockContract -> m Pl.TxOutRef @@ -111,7 +111,7 @@ putRefScriptOnWalletOutput recipient referencedScript = } putRefScriptOnScriptOutput :: - MonadBlockChain m => + (MonadBlockChain m) => Pl.TypedValidator MockContract -> Pl.TypedValidator MockContract -> m Pl.TxOutRef @@ -130,7 +130,7 @@ putRefScriptOnScriptOutput recipient referencedScript = txSkelSigners = [wallet 1] } -retrieveRefScriptHash :: MonadBlockChain m => Pl.TxOutRef -> m (Maybe Pl.ScriptHash) +retrieveRefScriptHash :: (MonadBlockChain m) => Pl.TxOutRef -> m (Maybe Pl.ScriptHash) retrieveRefScriptHash oref = do mOut <- txOutByRef oref case mOut of @@ -138,7 +138,7 @@ retrieveRefScriptHash oref = do Just out -> return $ out ^. outputReferenceScriptL checkReferenceScriptOnOref :: - MonadBlockChain m => + (MonadBlockChain m) => Pl.ScriptHash -> Pl.TxOutRef -> m () @@ -163,7 +163,7 @@ checkReferenceScriptOnOref expectedScriptHash refScriptOref = do txSkelSigners = [wallet 1] } -useReferenceScript :: MonadBlockChain m => Wallet -> Pl.TypedValidator MockContract -> m () +useReferenceScript :: (MonadBlockChain m) => Wallet -> Pl.TypedValidator MockContract -> m () useReferenceScript spendingSubmitter theScript = do scriptOref <- putRefScriptOnWalletOutput (wallet 3) theScript (oref, _) : _ <- diff --git a/tests/Cooked/ShowBSSpec.hs b/tests/Cooked/ShowBSSpec.hs index 48e943c40..0fd258a06 100644 --- a/tests/Cooked/ShowBSSpec.hs +++ b/tests/Cooked/ShowBSSpec.hs @@ -40,7 +40,7 @@ printValidator = wrap = Pl.mkUntypedValidator print _ _ ctx = Pl.trace (showBS . Pl.scriptContextTxInfo Pl.$ ctx) False -printTrace :: MonadBlockChain m => m () +printTrace :: (MonadBlockChain m) => m () printTrace = do (oref, _) : _ <- utxosFromCardanoTx diff --git a/tests/Cooked/Tweak/ValidityRangeSpec.hs b/tests/Cooked/Tweak/ValidityRangeSpec.hs index 1a950d1b3..5443a16c9 100644 --- a/tests/Cooked/Tweak/ValidityRangeSpec.hs +++ b/tests/Cooked/Tweak/ValidityRangeSpec.hs @@ -22,7 +22,7 @@ toSlotRangeTranslate translation a b = getSingleResult = fst . head . rights . flip runTweak txSkelTemplate -checkIsValidDuring :: MonadTweak m => m Assertion +checkIsValidDuring :: (MonadTweak m) => m Assertion checkIsValidDuring = do b <- hasFullTimeRangeTweak b1 <- isValidDuringTweak $ toSlotRange 101 1015 @@ -33,7 +33,7 @@ checkIsValidDuring = do assertBool "interval inclusions are wrong" $ b && b1 && b2 && not b3 -checkAddToValidityRange :: MonadTweak m => m Assertion +checkAddToValidityRange :: (MonadTweak m) => m Assertion checkAddToValidityRange = do timeOrigin <- currentSlot centerAroundValidityRangeTweak (timeOrigin + Slot 100) 80 @@ -52,7 +52,7 @@ checkAddToValidityRange = do assertBool "interval intersection is wrong" $ b && b1 && b2 && not b3 && b4 -checkMoveCurrentSlot :: MonadTweak m => m Assertion +checkMoveCurrentSlot :: (MonadTweak m) => m Assertion checkMoveCurrentSlot = do setValidityRangeTweak $ toSlotRange 10 20 waitUntilValidTweak