diff --git a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs index 6bcf9d154a..748028f905 100644 --- a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs +++ b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs @@ -571,12 +571,9 @@ genTxMetadataInEra = genTxAuxScripts :: CardanoEra era -> Gen (TxAuxScripts era) genTxAuxScripts era = - case auxScriptsSupportedInEra era of - Nothing -> pure TxAuxScriptsNone - Just supported -> - TxAuxScripts supported <$> - Gen.list (Range.linear 0 3) - (genScriptInEra era) + forEraInEon era + (pure TxAuxScriptsNone) + (\w -> TxAuxScripts w <$> Gen.list (Range.linear 0 3) (genScriptInEra era)) genTxWithdrawals :: CardanoEra era -> Gen (TxWithdrawals BuildTx era) genTxWithdrawals = diff --git a/cardano-api/internal/Cardano/Api/Eras/Case.hs b/cardano-api/internal/Cardano/Api/Eras/Case.hs index 4e07229754..31fe6eb19e 100644 --- a/cardano-api/internal/Cardano/Api/Eras/Case.hs +++ b/cardano-api/internal/Cardano/Api/Eras/Case.hs @@ -13,6 +13,7 @@ module Cardano.Api.Eras.Case , caseByronAndAllegraEraOnwardsOrShelleyEraOnly -- Case on ShelleyBasedEra + , caseShelleyEraOnlyOrAllegraEraOnwards , caseShelleyToAllegraOrMaryEraOnwards , caseShelleyToMaryOrAlonzoEraOnwards , caseShelleyToAlonzoOrBabbageEraOnwards @@ -25,6 +26,7 @@ module Cardano.Api.Eras.Case , alonzoEraOnwardsToMaryEraOnwards ) where +import Cardano.Api.Eon.AllegraEraOnwards import Cardano.Api.Eon.AlonzoEraOnwards import Cardano.Api.Eon.BabbageEraOnwards import Cardano.Api.Eon.ByronAndAllegraEraOnwards @@ -113,6 +115,18 @@ caseByronAndAllegraEraOnwardsOrShelleyEraOnly l r = \case BabbageEra -> l ByronAndAllegraEraOnwardsBabbage ConwayEra -> l ByronAndAllegraEraOnwardsConway +caseShelleyEraOnlyOrAllegraEraOnwards :: () + => (ShelleyEraOnlyConstraints era => ShelleyEraOnly era -> a) + -> (AllegraEraOnwardsConstraints era => AllegraEraOnwards era -> a) + -> ShelleyBasedEra era + -> a +caseShelleyEraOnlyOrAllegraEraOnwards l r = \case + ShelleyBasedEraShelley -> l ShelleyEraOnlyShelley + ShelleyBasedEraAllegra -> r AllegraEraOnwardsAllegra + ShelleyBasedEraMary -> r AllegraEraOnwardsMary + ShelleyBasedEraAlonzo -> r AllegraEraOnwardsAlonzo + ShelleyBasedEraBabbage -> r AllegraEraOnwardsBabbage + ShelleyBasedEraConway -> r AllegraEraOnwardsConway caseShelleyToAllegraOrMaryEraOnwards :: () => (ShelleyToAllegraEraConstraints era => ShelleyToAllegraEra era -> a) diff --git a/cardano-api/internal/Cardano/Api/TxBody.hs b/cardano-api/internal/Cardano/Api/TxBody.hs index 7a39429027..7226b1e224 100644 --- a/cardano-api/internal/Cardano/Api/TxBody.hs +++ b/cardano-api/internal/Cardano/Api/TxBody.hs @@ -112,9 +112,6 @@ module Cardano.Api.TxBody ( BuildTx, ViewTx, - -- * Era-dependent transaction body features - auxScriptsSupportedInEra, - -- * Inspecting 'ScriptWitness'es AnyScriptWitness(..), ScriptWitnessIndex(..), @@ -840,38 +837,6 @@ fromBabbageTxOutDatum _ w (Babbage.Datum binData) = TxOutDatumInline w $ binaryDataToScriptData w binData - --- ---------------------------------------------------------------------------- --- Era-dependent transaction body features --- - --- | A representation of whether the era supports auxiliary scripts in --- transactions. --- --- Auxiliary scripts are supported from the Allegra era onwards. --- -data AuxScriptsSupportedInEra era where - - AuxScriptsInAllegraEra :: AuxScriptsSupportedInEra AllegraEra - AuxScriptsInMaryEra :: AuxScriptsSupportedInEra MaryEra - AuxScriptsInAlonzoEra :: AuxScriptsSupportedInEra AlonzoEra - AuxScriptsInBabbageEra :: AuxScriptsSupportedInEra BabbageEra - AuxScriptsInConwayEra :: AuxScriptsSupportedInEra ConwayEra - -deriving instance Eq (AuxScriptsSupportedInEra era) -deriving instance Show (AuxScriptsSupportedInEra era) - -auxScriptsSupportedInEra :: CardanoEra era - -> Maybe (AuxScriptsSupportedInEra era) -auxScriptsSupportedInEra ByronEra = Nothing -auxScriptsSupportedInEra ShelleyEra = Nothing -auxScriptsSupportedInEra AllegraEra = Just AuxScriptsInAllegraEra -auxScriptsSupportedInEra MaryEra = Just AuxScriptsInMaryEra -auxScriptsSupportedInEra AlonzoEra = Just AuxScriptsInAlonzoEra -auxScriptsSupportedInEra BabbageEra = Just AuxScriptsInBabbageEra -auxScriptsSupportedInEra ConwayEra = Just AuxScriptsInConwayEra - - -- ---------------------------------------------------------------------------- -- Building vs viewing transactions -- @@ -1197,11 +1162,13 @@ deriving instance Show (TxMetadataInEra era) data TxAuxScripts era where - TxAuxScriptsNone :: TxAuxScripts era + TxAuxScriptsNone + :: TxAuxScripts era - TxAuxScripts :: AuxScriptsSupportedInEra era - -> [ScriptInEra era] - -> TxAuxScripts era + TxAuxScripts + :: AllegraEraOnwards era + -> [ScriptInEra era] + -> TxAuxScripts era deriving instance Eq (TxAuxScripts era) deriving instance Show (TxAuxScripts era) @@ -2596,29 +2563,14 @@ fromLedgerTxAuxiliaryData sbe (Just auxData) = metadata = if null ms then TxMetadataNone else TxMetadataInEra sbe $ TxMetadata ms auxdata = - case sbe of - ShelleyBasedEraShelley -> - TxAuxScriptsNone - ShelleyBasedEraAllegra -> - case ss of - [] -> TxAuxScriptsNone - _ -> TxAuxScripts AuxScriptsInAllegraEra ss - ShelleyBasedEraMary -> - case ss of - [] -> TxAuxScriptsNone - _ -> TxAuxScripts AuxScriptsInMaryEra ss - ShelleyBasedEraAlonzo -> + caseShelleyEraOnlyOrAllegraEraOnwards + (const TxAuxScriptsNone) + (\w -> case ss of [] -> TxAuxScriptsNone - _ -> TxAuxScripts AuxScriptsInAlonzoEra ss - ShelleyBasedEraBabbage -> - case ss of - [] -> TxAuxScriptsNone - _ -> TxAuxScripts AuxScriptsInBabbageEra ss - ShelleyBasedEraConway -> - case ss of - [] -> TxAuxScriptsNone - _ -> TxAuxScripts AuxScriptsInConwayEra ss + _ -> TxAuxScripts w ss + ) + sbe (ms, ss) = fromLedgerAuxiliaryData sbe auxData diff --git a/cardano-api/src/Cardano/Api.hs b/cardano-api/src/Cardano/Api.hs index 813dacdeea..2c382bd9cd 100644 --- a/cardano-api/src/Cardano/Api.hs +++ b/cardano-api/src/Cardano/Api.hs @@ -145,11 +145,12 @@ module Cardano.Api ( -- ** Case on CardanoEra caseByronOrShelleyBasedEra, - - -- ** Case on ShelleyBasedEra caseByronToAllegraOrMaryEraOnwards, caseByronToMaryOrAlonzoEraOnwards, caseByronToAlonzoOrBabbageEraOnwards, + + -- ** Case on ShelleyBasedEra + caseShelleyEraOnlyOrAllegraEraOnwards, caseShelleyToAllegraOrMaryEraOnwards, caseShelleyToMaryOrAlonzoEraOnwards, caseShelleyToAlonzoOrBabbageEraOnwards, @@ -383,9 +384,6 @@ module Cardano.Api ( BuildTx, ViewTx, - -- ** Era-dependent transaction body features - auxScriptsSupportedInEra, - -- ** Era-dependent protocol features ProtocolUTxOCostPerByteFeature(..), ProtocolUTxOCostPerWordFeature(..),