Skip to content

Commit

Permalink
Handle eraCast errors with onLeft
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Feb 8, 2023
1 parent a67df70 commit 09c5c21
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,7 @@ runTxBuildCmd
-- Why do we cast the era? The user can specify an era prior to the era that the node is currently in.
-- We cannot use the user specified era to construct a query against a node because it may differ
-- from the node's era and this will result in the 'QueryEraMismatch' failure.
txEraUtxo <- case first ShelleyTxCmdTxEraCastErr (eraCast cEra nodeEraUTxO) of
Right txEraUtxo -> return txEraUtxo
Left e -> left e
txEraUtxo <- firstExceptT ShelleyTxCmdTxEraCastErr $ hoistEither (eraCast cEra nodeEraUTxO)

scriptExecUnitsMap <- firstExceptT ShelleyTxCmdTxExecUnitsErr $ hoistEither
$ evaluateTransactionExecutionUnits
Expand Down Expand Up @@ -738,10 +736,7 @@ runTxBuild era (AnyConsensusModeParams cModeParams) networkId mScriptValidity
-- Why do we cast the era? The user can specify an era prior to the era that the node is currently in.
-- We cannot use the user specified era to construct a query against a node because it may differ
-- from the node's era and this will result in the 'QueryEraMismatch' failure.
txEraUtxo <- case first ShelleyTxCmdTxEraCastErr (eraCast era nodeEraUTxO) of
Right txEraUtxo -> return txEraUtxo
Left e -> left e

txEraUtxo <- pure (eraCast era nodeEraUTxO) & onLeft (left . ShelleyTxCmdTxEraCastErr)

balancedTxBody@(BalancedTxBody _ _ _ fee) <-
firstExceptT ShelleyTxCmdBalanceTxBody
Expand Down

0 comments on commit 09c5c21

Please sign in to comment.