Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cardano-api/src/Cardano/Api/TxSubmit.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ data TxSubmitResult
= TxSubmitSuccess
| TxSubmitFailureByron (ApplyTxErr ByronBlock)
| TxSubmitFailureShelley (ApplyTxErr (ShelleyBlock TPraosStandardCrypto))
deriving Show

submitTx
:: Network
Expand Down
12 changes: 7 additions & 5 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Cardano.Config.Types (CertificateFile (..))
import Control.Monad.Trans.Except (ExceptT)
import Control.Monad.Trans.Except.Extra
(bimapExceptT, firstExceptT, handleIOExceptT, hoistEither,
newExceptT, right)
left, newExceptT, right)

import qualified Data.Aeson as Aeson
import qualified Data.ByteString.Lazy.Char8 as LBS
Expand All @@ -45,6 +45,7 @@ data ShelleyTxCmdError
| ShelleyTxSignKeyError !KeyError
| ShelleyTxWriteSignedTxError !ApiError
| ShelleyTxWriteUnsignedTxError !ApiError
| ShelleyTxSubmitError !TxSubmitResult
deriving Show

renderShelleyTxCmdError :: ShelleyTxCmdError -> Text
Expand All @@ -69,6 +70,8 @@ renderShelleyTxCmdError err =
"Error while writing signed shelley tx: " <> renderApiError apiError
ShelleyTxWriteUnsignedTxError apiError ->
"Error while writing unsigned shelley tx: " <> renderApiError apiError
ShelleyTxSubmitError txSubmitRes ->
"Error while submitting Shelley tx: " <> textShow txSubmitRes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should write a renderTxSubmitError function here to provide more context with the errors vs just showing them.


runTransactionCmd :: TransactionCmd -> ExceptT ShelleyTxCmdError IO ()
runTransactionCmd cmd =
Expand Down Expand Up @@ -120,10 +123,9 @@ runTxSubmit txFp network = do
signedTx <- firstExceptT ShelleyTxReadSignedTxError . newExceptT $ readTxSigned txFp
result <- liftIO $ submitTx network sktFp signedTx
case result of
TxSubmitSuccess -> return ()
--TODO: use the Cardano.Api.TxSubmit.ErrorRender here
TxSubmitFailureByron err -> liftIO $ print err
TxSubmitFailureShelley err -> liftIO $ print err
TxSubmitSuccess -> return ()
TxSubmitFailureShelley _ -> left (ShelleyTxSubmitError result)
TxSubmitFailureByron _ -> left (ShelleyTxSubmitError result)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not odd that we're able to submit Byron transactions from this command?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should get sorted out as we flesh out the typed API


runTxCalculateMinFee
:: TxInCount
Expand Down