File tree Expand file tree Collapse file tree
src/Cardano/Api/Experimental
test/cardano-api-test/Test/Cardano/Api/Experimental Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,7 +78,9 @@ module Cardano.Api.Experimental.Tx
7878 -- 'TxBodyContent' that we defined earlier:
7979 --
8080 -- @
81- -- let (Right unsignedTx) = Exp.makeUnsignedTx era txBodyContent
81+ -- case Exp.makeUnsignedTx era txBodyContent of
82+ -- Left err -> error (show err)
83+ -- Right unsignedTx -> ...
8284 -- @
8385 --
8486 -- Next, use the key witness to sign the unsigned transaction with the 'makeKeyWitness' function:
Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ import Cardano.Api.Governance.Internal.Action.VotingProcedure
107107import Cardano.Api.Key.Internal
108108import Cardano.Api.Ledger.Internal.Reexport (StrictMaybe (.. ))
109109import Cardano.Api.Ledger.Internal.Reexport qualified as L
110+ import Cardano.Api.Monad.Error (liftMaybe )
110111import Cardano.Api.Plutus.Internal.Script
111112 ( PlutusScript (.. )
112113 , PlutusScriptVersion (.. )
@@ -313,7 +314,7 @@ convPParamsToScriptIntegrityHash mTxProtocolParams redeemers datums languages =
313314 && null languages
314315 if shouldCalculateHash
315316 then do
316- pp <- maybe ( Left MakeUnsignedTxMissingProtocolParams ) Right mTxProtocolParams
317+ pp <- liftMaybe MakeUnsignedTxMissingProtocolParams mTxProtocolParams
317318 pure $
318319 SJust $
319320 L. hashScriptIntegrity $
Original file line number Diff line number Diff line change @@ -15,12 +15,14 @@ import Cardano.Api.Experimental qualified as Exp
1515import Cardano.Api.Experimental.Era (convert )
1616import Cardano.Api.Experimental.Tx qualified as Exp
1717import Cardano.Api.Ledger qualified as L
18+ import Cardano.Api.Monad.Error (failEither )
1819
1920import Cardano.Ledger.Api qualified as UnexportedLedger
2021import Cardano.Ledger.Core qualified as L
2122import Cardano.Ledger.Mary.Value qualified as Mary
2223import Cardano.Ledger.Tools qualified as L (calcMinFeeTx )
2324
25+ import Data.Bifunctor (first )
2426import Data.Foldable (toList )
2527import Data.Map.Strict qualified as Map
2628import Data.Sequence.Strict qualified as Seq
@@ -387,9 +389,8 @@ genTinySurplusTx era = Exp.obtainCommonConstraints era $ do
387389 & Exp. setTxIns [(txIn, Exp. AnyKeyWitnessPlaceholder )]
388390 & Exp. setTxOuts [sendTxOut]
389391 & Exp. setTxFee 0
390- unsignedTx <- case Exp. makeUnsignedTx era txBodyContent of
391- Left err -> fail $ " makeUnsignedTx: " <> show err
392- Right tx -> return tx
392+ unsignedTx <-
393+ failEither . first ((" makeUnsignedTx: " <> ) . show ) $ Exp. makeUnsignedTx era txBodyContent
393394 let
394395 -- Compute F1 via case match on UnsignedTx (needed to bring EraTx into scope)
395396 L. Coin f1 = case unsignedTx of
You can’t perform that action at this time.
0 commit comments