Skip to content

Commit 658a875

Browse files
committed
fix typo and other improvements
1 parent b46a679 commit 658a875

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/BotPlutusInterface/Collateral.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import BotPlutusInterface.Types (
1515
unCollateralVar,
1616
)
1717
import Cardano.Prelude (Void)
18-
import Control.Concurrent.STM (atomically, modifyTVar', readTVarIO)
18+
import Control.Concurrent.STM (atomically, writeTVar, readTVarIO)
1919
import Data.Kind (Type)
2020
import Data.Map (Map)
2121
import Data.Map qualified as Map
@@ -30,7 +30,7 @@ getInMemCollateral = readTVarIO . unCollateralVar . ceCollateral
3030
setInMemCollateral :: forall (w :: Type). ContractEnvironment w -> CollateralUtxo -> IO ()
3131
setInMemCollateral cEnv txOutRef = do
3232
let cVar = unCollateralVar $ ceCollateral cEnv
33-
atomically $ modifyTVar' cVar (const (Just txOutRef))
33+
atomically $ writeTVar cVar (Just txOutRef)
3434

3535
mkCollateralTx :: PABConfig -> Either Constraints.MkTxError Constraints.UnbalancedTx
3636
mkCollateralTx pabConf = Constraints.mkTx @Void mempty txc

src/BotPlutusInterface/Contract.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import Control.Monad.Trans.Either (EitherT, eitherT, firstEitherT, hoistEither,
5151
import Control.Monad.Trans.Except (ExceptT, throwE)
5252
import Data.Aeson (ToJSON, Value (Array, Bool, Null, Number, Object, String))
5353
import Data.Aeson.Extras (encodeByteString)
54-
import Data.Either.Combinators (maybeToRight, swapEither)
54+
import Data.Either.Combinators (maybeToLeft, swapEither)
5555
import Data.Function (fix)
5656
import Data.HashMap.Strict qualified as HM
5757
import Data.Kind (Type)
@@ -452,7 +452,7 @@ handleCollateral cEnv = do
452452
do
453453
collateralNotInMem <-
454454
newEitherT $
455-
swapEither . maybeToRight "Collateral UTxO not found in contract env."
455+
maybeToLeft "Collateral UTxO not found in contract env."
456456
<$> getInMemCollateral @w
457457

458458
helperLog collateralNotInMem
@@ -463,7 +463,7 @@ handleCollateral cEnv = do
463463
("Collateral UTxO not found or failed to be found in wallet: " <> pretty collateralNotInWallet)
464464

465465
helperLog "Creating collateral UTxO."
466-
--
466+
467467
notCreatedCollateral <- newEitherT $ swapEither <$> makeCollateral @w cEnv
468468

469469
helperLog
@@ -520,12 +520,12 @@ findCollateralAtOwnPKH cEnv =
520520
changeAddr =
521521
Ledger.pubKeyHashAddress
522522
(PaymentPubKeyHash pabConf.pcOwnPubKeyHash)
523-
(pabConf.pcOwnStakePubKeyHash)
523+
pabConf.pcOwnStakePubKeyHash
524524

525525
r <- newEitherT $ CardanoCLI.utxosAt @w pabConf changeAddr
526526
let refsAndOuts = Map.toList $ Tx.toTxOut <$> r
527527
hoistEither $ case filter check refsAndOuts of
528-
[] -> Left "Couldn't find colalteral UTxO"
528+
[] -> Left "Couldn't find collateral UTxO"
529529
((oref, _) : _) -> Right oref
530530
where
531531
check (_, txOut) = Tx.txOutValue txOut == collateralValue (cePABConfig cEnv)

0 commit comments

Comments
 (0)