Skip to content

Commit

Permalink
Handle readFileTx with onLeft
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Mar 19, 2023
1 parent 54ba7a3 commit 4964118
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1070,9 +1070,9 @@ runTxSign txOrTxBody witSigningData mnw (TxFile outTxFile) = do
let (sksByron, sksShelley) = partitionSomeWitnesses $ map categoriseSomeWitness sks

case txOrTxBody of
(InputTxFile (TxFile inputTxFilePath)) -> do
InputTxFile (TxFile inputTxFilePath) -> do
inputTxFile <- liftIO $ fileOrPipe inputTxFilePath
anyTx <- firstExceptT ShelleyTxCmdCddlError . newExceptT $ readFileTx inputTxFile
anyTx <- lift (readFileTx inputTxFile) & onLeft (left . ShelleyTxCmdCddlError)

InAnyShelleyBasedEra _era tx <-
onlyInShelleyBasedEras "sign for Byron era transactions" anyTx
Expand All @@ -1090,7 +1090,7 @@ runTxSign txOrTxBody witSigningData mnw (TxFile outTxFile) = do
firstExceptT ShelleyTxCmdWriteFileError . newExceptT $
writeTxFileTextEnvelopeCddl outTxFile signedTx

(InputTxBodyFile (TxBodyFile txbodyFilePath)) -> do
InputTxBodyFile (TxBodyFile txbodyFilePath) -> do
txbodyFile <- liftIO $ fileOrPipe txbodyFilePath
unwitnessed <- firstExceptT ShelleyTxCmdCddlError . newExceptT
$ readFileTxBody txbodyFile
Expand Down Expand Up @@ -1143,8 +1143,7 @@ runTxSubmit (AnyConsensusModeParams cModeParams) network txFilePath = do
SocketPath sockPath <- lift readEnvSocketPath & onLeft (left . ShelleyTxCmdSocketEnvError)

txFile <- liftIO $ fileOrPipe txFilePath
InAnyCardanoEra era tx <- firstExceptT ShelleyTxCmdCddlError . newExceptT
$ readFileTx txFile
InAnyCardanoEra era tx <- lift (readFileTx txFile) & onLeft (left . ShelleyTxCmdCddlError)
let cMode = AnyConsensusMode $ consensusModeOnly cModeParams
eraInMode <- hoistMaybe
(ShelleyTxCmdEraConsensusModeMismatch (Just txFilePath) cMode (AnyCardanoEra era))
Expand Down Expand Up @@ -1336,8 +1335,7 @@ runTxGetTxId txfile = do

InputTxFile (TxFile txFilePath) -> do
txFile <- liftIO $ fileOrPipe txFilePath
InAnyCardanoEra era tx <- firstExceptT ShelleyTxCmdCddlError . newExceptT
$ readFileTx txFile
InAnyCardanoEra era tx <- lift (readFileTx txFile) & onLeft (left . ShelleyTxCmdCddlError)
return . InAnyCardanoEra era $ getTxBody tx

liftIO $ BS.putStrLn $ serialiseToRawBytesHex (getTxId txbody)
Expand All @@ -1359,8 +1357,7 @@ runTxView = \case
liftIO $ BS.putStr $ friendlyTxBodyBS era txbody
InputTxFile (TxFile txFilePath) -> do
txFile <- liftIO $ fileOrPipe txFilePath
InAnyCardanoEra era tx <- firstExceptT ShelleyTxCmdCddlError . newExceptT
$ readFileTx txFile
InAnyCardanoEra era tx <- lift (readFileTx txFile) & onLeft (left . ShelleyTxCmdCddlError)
liftIO $ BS.putStr $ friendlyTxBS era tx


Expand Down

0 comments on commit 4964118

Please sign in to comment.