Skip to content

Commit

Permalink
Fix incorect constraint and cleanup Transaction translation a little
Browse files Browse the repository at this point in the history
  • Loading branch information
lehins committed Feb 7, 2023
1 parent 3172844 commit c32b6c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
7 changes: 1 addition & 6 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Translation.hs
Expand Up @@ -71,12 +71,7 @@ instance Crypto c => TranslateEra (AlonzoEra c) Core.PParams where

newtype Tx era = Tx {unTx :: Core.Tx era}

instance
( Crypto c
, Core.Tx (AlonzoEra c) ~ AlonzoTx (AlonzoEra c)
) =>
TranslateEra (AlonzoEra c) Tx
where
instance Crypto c => TranslateEra (AlonzoEra c) Tx where
type TranslationError (AlonzoEra c) Tx = DecoderError
translateEra _ctxt (Tx tx) = do
-- Note that this does not preserve the hidden bytes field of the transaction.
Expand Down
16 changes: 6 additions & 10 deletions eras/babbage/impl/src/Cardano/Ledger/Babbage/Translation.hs
Expand Up @@ -30,6 +30,7 @@ import Cardano.Ledger.Shelley.API (
)
import qualified Cardano.Ledger.Shelley.API as API
import qualified Data.Map.Strict as Map
import Lens.Micro

--------------------------------------------------------------------------------
-- Translation from Alonzo to Babbage
Expand Down Expand Up @@ -66,23 +67,18 @@ instance

newtype Tx era = Tx {unTx :: Core.Tx era}

instance
( Crypto c
, Tx (BabbageEra c) ~ AlonzoTx (BabbageEra c)
) =>
TranslateEra (BabbageEra c) Tx
where
instance Crypto c => TranslateEra (BabbageEra c) Tx where
type TranslationError (BabbageEra c) Tx = DecoderError
translateEra _ctxt (Tx tx) = do
-- Note that this does not preserve the hidden bytes field of the transaction.
-- This is under the premise that this is irrelevant for TxInBlocks, which are
-- not transmitted as contiguous chunks.
txBody <- translateEraThroughCBOR "TxBody" $ Alonzo.body tx
txWits <- translateEraThroughCBOR "TxWitness" $ Alonzo.wits tx
auxData <- case Alonzo.auxiliaryData tx of
txBody <- translateEraThroughCBOR "TxBody" $ tx ^. bodyTxL
txWits <- translateEraThroughCBOR "TxWitness" $ tx ^. witsTxL
auxData <- case tx ^. auxDataTxL of
SNothing -> pure SNothing
SJust auxData -> SJust <$> translateEraThroughCBOR "AuxData" auxData
let validating = Alonzo.isValid tx
let validating = tx ^. Alonzo.isValidTxL
pure $ Tx $ AlonzoTx txBody txWits validating auxData

--------------------------------------------------------------------------------
Expand Down

0 comments on commit c32b6c8

Please sign in to comment.