@@ -35,6 +35,7 @@ import BotPlutusInterface.Types (
3535 CollateralUtxo (CollateralUtxo ),
3636 ContractEnvironment (.. ),
3737 LogLevel (Debug , Notice , Warn ),
38+ LogType (PABLog , CollateralLog ),
3839 Tip (block , slot ),
3940 TxFile (Signed ),
4041 collateralValue ,
@@ -174,7 +175,7 @@ handlePABReq ::
174175 PABReq ->
175176 Eff effs PABResp
176177handlePABReq contractEnv req = do
177- printBpiLog @ w Debug $ pretty req
178+ printBpiLog @ w ( Debug PABLog ) $ pretty req
178179 resp <- case req of
179180 ----------------------
180181 -- Handled requests --
@@ -208,7 +209,7 @@ handlePABReq contractEnv req = do
208209 -- YieldUnbalancedTxReq UnbalancedTx
209210 unsupported -> error (" Unsupported PAB effect: " ++ show unsupported)
210211
211- printBpiLog @ w Debug $ pretty resp
212+ printBpiLog @ w ( Debug PABLog ) $ pretty resp
212213 pure resp
213214
214215{- | Await till transaction status change to something from `Unknown`.
@@ -227,7 +228,7 @@ awaitTxStatusChange ::
227228 Eff effs TxStatus
228229awaitTxStatusChange contractEnv txId = do
229230 checkStartedBlock <- currentBlock contractEnv
230- printBpiLog @ w Debug $ pretty $ " Awaiting status change for " ++ show txId
231+ printBpiLog @ w ( Debug PABLog ) $ pretty $ " Awaiting status change for " ++ show txId
231232
232233 let txStatusPolling = contractEnv. cePABConfig. pcTxStatusPolling
233234 pollInterval = fromIntegral $ txStatusPolling. spInterval
@@ -239,7 +240,7 @@ awaitTxStatusChange contractEnv txId = do
239240 txStatus <- getStatus
240241 case (txStatus, currBlock > cutOffBlock) of
241242 (status, True ) -> do
242- logDebug . mconcat . fmap mconcat $
243+ helperLog ( Debug PABLog ) . mconcat . fmap mconcat $
243244 [ [" Timeout for waiting `TxId " , show txId, " ` status change reached" ]
244245 , [" - waited " , show pollTimeout, " blocks." ]
245246 , [" Current status: " , show status]
@@ -254,17 +255,17 @@ awaitTxStatusChange contractEnv txId = do
254255 mTx <- queryChainIndexForTxState
255256 case mTx of
256257 Nothing -> do
257- logDebug $ " TxId " ++ show txId ++ " not found in index"
258+ helperLog ( Debug PABLog ) $ " TxId " ++ show txId ++ " not found in index"
258259 pure Unknown
259260 Just txState -> do
260- logDebug $ " TxId " ++ show txId ++ " found in index, checking status"
261+ helperLog ( Debug PABLog ) $ " TxId " ++ show txId ++ " found in index, checking status"
261262 blk <- fromInteger <$> currentBlock contractEnv
262263 case transactionStatus blk txState txId of
263264 Left e -> do
264- logDebug $ " Status check for TxId " ++ show txId ++ " failed with " ++ show e
265+ helperLog ( Debug PABLog ) $ " Status check for TxId " ++ show txId ++ " failed with " ++ show e
265266 pure Unknown
266267 Right st -> do
267- logDebug $ " Status for TxId " ++ show txId ++ " is " ++ show st
268+ helperLog ( Debug PABLog ) $ " Status for TxId " ++ show txId ++ " is " ++ show st
268269 pure st
269270
270271 queryChainIndexForTxState :: Eff effs (Maybe TxIdState )
@@ -276,7 +277,8 @@ awaitTxStatusChange contractEnv txId = do
276277 pure . Just $ fromTx blk tx
277278 Nothing -> pure Nothing
278279
279- logDebug = printBpiLog @ w Debug . pretty
280+ helperLog :: LogLevel -> String -> Eff effs ()
281+ helperLog (Debug a) = printBpiLog @ w (Debug a) . pretty
280282
281283-- | This will FULLY balance a transaction
282284balanceTx ::
@@ -400,7 +402,8 @@ awaitSlot contractEnv s@(Slot n) = do
400402 _ -> awaitSlot contractEnv s
401403
402404{- | Wait at least until the given time. Uses the awaitSlot under the hood, so the same constraints
403- are applying here as well.
405+ are applying here as well. PubKeyCredential: 8cf10ef973d90f42c386cbdbceb1d731c9af1ec71b
406+ 47329f8be130cf (no staking crede
404407-}
405408awaitTime ::
406409 forall (w :: Type ) (effs :: [Type -> Type ]).
@@ -474,12 +477,12 @@ handleCollateral cEnv = do
474477 case result of
475478 Right collteralUtxo ->
476479 setInMemCollateral @ w collteralUtxo
477- >> Right <$> printBpiLog @ w Debug " successfully set the collateral utxo in env."
480+ >> Right <$> printBpiLog @ w ( Debug PABLog ) " successfully set the collateral utxo in env."
478481 Left err -> pure $ Left $ " Failed to make collateral: " <> err
479482 where
480483 --
481484 helperLog :: PP. Doc () -> ExceptT CollateralUtxo (Eff effs ) ()
482- helperLog msg = newEitherT $ Right <$> printBpiLog @ w Debug msg
485+ helperLog msg = newEitherT $ Right <$> printBpiLog @ w ( Debug CollateralLog ) msg
483486
484487{- | Create collateral UTxO by submitting Tx.
485488 Then try to find created UTxO at own PKH address.
0 commit comments