@@ -14,21 +14,21 @@ module Wst.Offchain.BuildTx.Failing(
14
14
import Cardano.Api.Experimental (IsEra )
15
15
import Cardano.Api.Shelley qualified as C
16
16
import Control.Lens (set )
17
- import Control.Monad.Except (MonadError , throwError )
17
+ import Control.Monad.Error.Lens (throwing , throwing_ )
18
+ import Control.Monad.Except (MonadError )
18
19
import Control.Monad.Reader (MonadReader , asks )
19
20
import Convex.BuildTx (BuildTxT )
20
21
import Convex.BuildTx qualified as BuildTx
21
22
import Convex.CardanoApi.Lenses qualified as L
22
23
import Convex.Class (MonadBlockchain , queryProtocolParameters )
23
24
import Convex.CoinSelection qualified as CoinSelection
24
25
import Convex.PlutusLedger.V1 (transCredential )
25
- import Convex.Utils (mapError )
26
26
import Convex.Utxos (BalanceChanges )
27
27
import Convex.Utxos qualified as Utxos
28
28
import Convex.Wallet.Operator (returnOutputFor )
29
29
import Data.Aeson (FromJSON , ToJSON )
30
30
import GHC.Generics (Generic )
31
- import Wst.AppError (AppError (.. ))
31
+ import Wst.AppError (AsProgrammableTokensError (.. ))
32
32
import Wst.Offchain.BuildTx.TransferLogic (FindProofResult (.. ))
33
33
import Wst.Offchain.Env (HasOperatorEnv (.. ), OperatorEnv (.. ))
34
34
import Wst.Offchain.Query (UTxODat (.. ))
@@ -43,7 +43,7 @@ data BlacklistedTransferPolicy
43
43
44
44
{-| Balance a transaction using the operator's funds and return output
45
45
-}
46
- balanceTxEnvFailing :: forall era env m . (MonadBlockchain era m , MonadReader env m , HasOperatorEnv era env , MonadError ( AppError era ) m , C. IsBabbageBasedEra era ) => BlacklistedTransferPolicy -> BuildTxT era m (FindProofResult era ) -> m (C. BalancedTxBody era , BalanceChanges )
46
+ balanceTxEnvFailing :: forall era env err m . (MonadBlockchain era m , MonadReader env m , HasOperatorEnv era env , MonadError err m , C. IsBabbageBasedEra era , AsProgrammableTokensError err , CoinSelection. AsCoinSelectionError err , CoinSelection. AsBalancingError err era ) => BlacklistedTransferPolicy -> BuildTxT era m (FindProofResult era ) -> m (C. BalancedTxBody era , BalanceChanges )
47
47
balanceTxEnvFailing policy btx = do
48
48
OperatorEnv {bteOperatorUtxos, bteOperator} <- asks operatorEnv
49
49
params <- queryProtocolParameters
@@ -54,14 +54,14 @@ balanceTxEnvFailing policy btx = do
54
54
output <- returnOutputFor credential
55
55
(balBody, balChanges) <- case r of
56
56
CredentialNotBlacklisted {} -> do
57
- mapError BalancingError ( CoinSelection. balanceTx mempty output (Utxos. fromApiUtxo bteOperatorUtxos) txBuilder CoinSelection. TrailingChange)
57
+ CoinSelection. balanceTx mempty output (Utxos. fromApiUtxo bteOperatorUtxos) txBuilder CoinSelection. TrailingChange
58
58
CredentialBlacklisted UTxODat {}
59
59
| policy == SubmitFailingTx -> do
60
60
-- deliberately set the script validity flag to false
61
61
-- this means we will be losing the collateral!
62
62
let builder' = txBuilder <> BuildTx. liftTxBodyEndo (set L. txScriptValidity (C. TxScriptValidity C. alonzoBasedEra C. ScriptInvalid ))
63
- mapError BalancingError ( CoinSelection. balanceTx mempty output (Utxos. fromApiUtxo bteOperatorUtxos) builder' CoinSelection. TrailingChange)
63
+ CoinSelection. balanceTx mempty output (Utxos. fromApiUtxo bteOperatorUtxos) builder' CoinSelection. TrailingChange
64
64
| otherwise -> do
65
- throwError ( TransferBlacklistedCredential (transCredential credential) )
66
- NoBlacklistNodes -> throwError BlacklistNodeNotFound
65
+ throwing _TransferBlacklistedCredential (transCredential credential)
66
+ NoBlacklistNodes -> throwing_ _BlacklistNodeNotFound
67
67
pure (balBody, balChanges)
0 commit comments