Skip to content

Commit

Permalink
Handle anyAddressInEra with onLeft
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Feb 13, 2023
1 parent 9c4549a commit 14b6b93
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ module Cardano.CLI.Shelley.Run.Transaction
, toTxOutInAnyEra
) where

import Control.Monad (forM_)
import Control.Monad (forM, forM_)
import Control.Monad.IO.Class (MonadIO (..))
import Control.Monad.Trans.Except (ExceptT)
import Control.Monad.Trans (MonadTrans (..))
import Control.Monad.Trans.Except (ExceptT, throwE)
import Control.Monad.Trans.Except.Extra (firstExceptT, hoistEither, hoistMaybe, left,
newExceptT, onLeft, onNothing)
import Data.Aeson.Encode.Pretty (encodePretty)
Expand All @@ -29,6 +30,7 @@ import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as LBS
import Data.Data ((:~:) (..))
import Data.Foldable (Foldable (..))
import Data.Function ((&))
import qualified Data.List as List
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
Expand Down Expand Up @@ -736,9 +738,8 @@ runTxBuild era (AnyConsensusModeParams cModeParams) networkId mScriptValidity
firstExceptT ShelleyTxCmdQueryNotScriptLocked
. hoistEither $ notScriptLockedTxIns txinsc nodeEraUTxO

let cAddr = case anyAddressInEra era changeAddr of
Right addr -> addr
Left _ -> error $ "runTxBuild: Byron address used: " <> show changeAddr
cAddr <- pure (anyAddressInEra era changeAddr)
& onLeft (error $ "runTxBuild: Byron address used: " <> show changeAddr) -- should this throw instead?

-- 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
Expand Down

0 comments on commit 14b6b93

Please sign in to comment.