Skip to content

Commit

Permalink
Improve and unify L1 submit error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
uhbif19 committed May 28, 2024
1 parent b99a5bf commit 8d684fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Cardano/CEM/Monads.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import PlutusLedgerApi.V2 (
)

import Cardano.Api hiding (Address, In, Out, queryUtxo, txIns)
import Cardano.Api.IPC (TxValidationError)
import Cardano.Api.Shelley (PoolId)
import Cardano.Ledger.Core (PParams)
import Cardano.Ledger.Shelley.API (ApplyTxError (..))

import Cardano.Extras

Expand Down Expand Up @@ -70,7 +70,7 @@ data TxSubmittingError
= WrongSlot WrongSlotKind Integer
| TxInOutdated [TxIn]
| UnhandledAutobalanceError (TxBodyErrorAutoBalance Era)
| UnhandledNodeSubmissionError (TxValidationError Era)
| UnhandledNodeSubmissionError (ApplyTxError LedgerEra)
deriving stock (Show)

-- | Ability to send transaction to chain
Expand Down
9 changes: 6 additions & 3 deletions src/Cardano/CEM/Monads/L1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import Control.Monad.Reader (MonadReader (..), ReaderT (..))
import Control.Monad.Trans (MonadIO (..))
import Data.ByteString qualified as BS
import Data.Set qualified as Set
import Unsafe.Coerce (unsafeCoerce)

-- Cardano imports
import Cardano.Api hiding (queryUtxo)
import Cardano.Api.InMode (TxValidationError (..), fromConsensusApplyTxErr)
import Ouroboros.Network.Protocol.LocalStateQuery.Type (Target (..))

-- Project imports
Expand Down Expand Up @@ -105,8 +105,11 @@ instance MonadSubmitTx L1Runner where
submitTxToNodeLocal ci txInMode >>= \case
SubmitSuccess ->
return $ Right $ getTxId body
SubmitFail (TxValidationErrorInCardanoMode e) ->
return $ Left $ UnhandledNodeSubmissionError $ unsafeCoerce e
-- FIXME: check other eras support
SubmitFail (TxValidationErrorInCardanoMode (ShelleyTxValidationError ShelleyBasedEraBabbage e)) ->
return $ Left $ UnhandledNodeSubmissionError e
SubmitFail (TxValidationErrorInCardanoMode _) ->
error "Era mismatch error"
SubmitFail (TxValidationEraMismatch _) ->
error "Era mismatch error"
Left e -> return $ Left $ UnhandledAutobalanceError e
Expand Down

0 comments on commit 8d684fa

Please sign in to comment.