diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index ada7e46dcd..eaf67ad6bb 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -73,7 +73,6 @@ library internal Cardano.Api.Eon.ShelleyToAlonzoEra Cardano.Api.Eon.ShelleyToBabbageEra Cardano.Api.Eon.ShelleyToMaryEra - Cardano.Api.EraCast Cardano.Api.Eras Cardano.Api.Eras.Case Cardano.Api.Eras.Constraints diff --git a/cardano-api/internal/Cardano/Api/Address.hs b/cardano-api/internal/Cardano/Api/Address.hs index 3027bdbbdd..df00798c2b 100644 --- a/cardano-api/internal/Cardano/Api/Address.hs +++ b/cardano-api/internal/Cardano/Api/Address.hs @@ -80,7 +80,6 @@ module Cardano.Api.Address ( ) where import Cardano.Api.Eon.ShelleyBasedEra -import Cardano.Api.EraCast import Cardano.Api.Eras import Cardano.Api.Hash import Cardano.Api.HasTypeProxy @@ -378,11 +377,6 @@ instance IsShelleyBasedEra era => FromJSON (AddressInEra era) where addressAny <- runParsecParser parseAddressAny txt pure $ anyAddressInShelleyBasedEra addressAny -instance EraCast AddressInEra where - eraCast toEra' (AddressInEra addressTypeInEra address) = AddressInEra - <$> eraCast toEra' addressTypeInEra - <*> pure address - parseAddressAny :: Parsec.Parser AddressAny parseAddressAny = do str <- lexPlausibleAddressString @@ -469,14 +463,6 @@ instance IsCardanoEra era => SerialiseAddress (AddressInEra era) where deserialiseAddress _ t = rightToMaybe . anyAddressInEra cardanoEra =<< deserialiseAddress AsAddressAny t -instance EraCast (AddressTypeInEra addrtype) where - eraCast toEra' v = case v of - ByronAddressInAnyEra -> pure ByronAddressInAnyEra - ShelleyAddressInEra previousEra -> - case cardanoEraStyle toEra' of - LegacyByronEra -> Left $ EraCastError v (shelleyBasedToCardanoEra previousEra) toEra' - ShelleyBasedEra newSbe -> Right $ ShelleyAddressInEra newSbe - byronAddressInEra :: Address ByronAddr -> AddressInEra era byronAddressInEra = AddressInEra ByronAddressInAnyEra diff --git a/cardano-api/internal/Cardano/Api/EraCast.hs b/cardano-api/internal/Cardano/Api/EraCast.hs deleted file mode 100644 index 8e2a911a4d..0000000000 --- a/cardano-api/internal/Cardano/Api/EraCast.hs +++ /dev/null @@ -1,28 +0,0 @@ -{-# LANGUAGE GADTs #-} -{-# LANGUAGE KindSignatures #-} - -module Cardano.Api.EraCast - ( EraCast(..) - , EraCastError(..) - ) where - -import Cardano.Api.Eras (CardanoEra (..), IsCardanoEra) - -import Data.Kind (Type) - -data EraCastError = forall fromEra toEra value. - ( IsCardanoEra fromEra - , IsCardanoEra toEra - , Show value - ) => - EraCastError - { originalValue :: value - , fromEra :: CardanoEra fromEra - , toEra :: CardanoEra toEra - } - -class EraCast (f :: Type -> Type) where - eraCast :: (IsCardanoEra fromEra, IsCardanoEra toEra) - => CardanoEra toEra - -> f fromEra - -> Either EraCastError (f toEra) diff --git a/cardano-api/internal/Cardano/Api/Query.hs b/cardano-api/internal/Cardano/Api/Query.hs index 11527ebd54..24180e29cb 100644 --- a/cardano-api/internal/Cardano/Api/Query.hs +++ b/cardano-api/internal/Cardano/Api/Query.hs @@ -82,7 +82,6 @@ import Cardano.Api.Address import Cardano.Api.Block import Cardano.Api.Certificate import Cardano.Api.Eon.ShelleyBasedEra -import Cardano.Api.EraCast import Cardano.Api.Eras.Constraints import Cardano.Api.Eras.Core import Cardano.Api.GenesisParameters @@ -127,7 +126,6 @@ import Ouroboros.Network.Block (Serialised (..)) import Ouroboros.Network.NodeToClient.Version (NodeToClientVersion (..)) import Ouroboros.Network.Protocol.LocalStateQuery.Client (Some (..)) -import Control.Monad (forM) import Control.Monad.Trans.Except import Data.Aeson (FromJSON (..), ToJSON (..), withObject) import qualified Data.Aeson as Aeson @@ -377,9 +375,6 @@ newtype ByronUpdateState = ByronUpdateState Byron.Update.State newtype UTxO era = UTxO { unUTxO :: Map TxIn (TxOut CtxUTxO era) } deriving (Eq, Show) -instance EraCast UTxO where - eraCast toEra' (UTxO m) = UTxO <$> forM m (eraCast toEra') - data UTxOInAnyEra where UTxOInAnyEra :: CardanoEra era -> UTxO era diff --git a/cardano-api/internal/Cardano/Api/Script.hs b/cardano-api/internal/Cardano/Api/Script.hs index bd107ff2f4..008cf6ed06 100644 --- a/cardano-api/internal/Cardano/Api/Script.hs +++ b/cardano-api/internal/Cardano/Api/Script.hs @@ -110,7 +110,6 @@ module Cardano.Api.Script ( import Cardano.Api.Eon.BabbageEraOnwards import Cardano.Api.Eon.ShelleyBasedEra -import Cardano.Api.EraCast import Cardano.Api.Eras.Case import Cardano.Api.Eras.Core import Cardano.Api.Error @@ -1400,15 +1399,6 @@ instance IsCardanoEra era => FromJSON (ReferenceScript era) where (\w -> ReferenceScript w <$> o .: "referenceScript") (cardanoEra :: CardanoEra era) -instance EraCast ReferenceScript where - eraCast toEra = \case - ReferenceScriptNone -> pure ReferenceScriptNone - v@(ReferenceScript ws scriptInAnyLang) -> - caseByronToAlonzoOrBabbageEraOnwards - (const (Left $ EraCastError v (babbageEraOnwardsToCardanoEra ws) toEra)) - (\wt -> Right $ ReferenceScript wt scriptInAnyLang) - toEra - refScriptToShelleyScript :: CardanoEra era -> ReferenceScript era diff --git a/cardano-api/internal/Cardano/Api/TxBody.hs b/cardano-api/internal/Cardano/Api/TxBody.hs index da06416aff..da87ed11a7 100644 --- a/cardano-api/internal/Cardano/Api/TxBody.hs +++ b/cardano-api/internal/Cardano/Api/TxBody.hs @@ -160,7 +160,6 @@ import Cardano.Api.Eon.MaryEraOnwards import Cardano.Api.Eon.ShelleyBasedEra import Cardano.Api.Eon.ShelleyEraOnly import Cardano.Api.Eon.ShelleyToBabbageEra -import Cardano.Api.EraCast import Cardano.Api.Eras.Case import Cardano.Api.Eras.Constraints import Cardano.Api.Eras.Core @@ -327,14 +326,6 @@ data TxOut ctx era = TxOut (AddressInEra era) deriving instance Eq (TxOut ctx era) deriving instance Show (TxOut ctx era) -instance EraCast (TxOut ctx) where - eraCast toEra (TxOut addressInEra txOutValue txOutDatum referenceScript) = - TxOut - <$> eraCast toEra addressInEra - <*> eraCast toEra txOutValue - <*> eraCast toEra txOutDatum - <*> eraCast toEra referenceScript - data TxOutInAnyEra where TxOutInAnyEra :: CardanoEra era -> TxOut CtxTx era @@ -895,19 +886,6 @@ data TxOutValue era where TxOutValue :: MaryEraOnwards era -> Value -> TxOutValue era -instance EraCast TxOutValue where - eraCast toEra v = case v of - TxOutAdaOnly _previousEra lovelace -> - caseByronToAllegraOrMaryEraOnwards - (\w -> Right $ TxOutAdaOnly w lovelace) - (\w -> Right $ TxOutValue w $ lovelaceToValue lovelace) - toEra - TxOutValue (_ :: MaryEraOnwards fromEra) value -> - caseByronToAllegraOrMaryEraOnwards - (const (Left $ EraCastError v (cardanoEra @fromEra) toEra)) - (\w -> Right $ TxOutValue w value) - toEra - deriving instance Eq (TxOutValue era) deriving instance Show (TxOutValue era) deriving instance Generic (TxOutValue era) @@ -1045,25 +1023,6 @@ data TxOutDatum ctx era where deriving instance Eq (TxOutDatum ctx era) deriving instance Show (TxOutDatum ctx era) -instance EraCast (TxOutDatum ctx) where - eraCast toEra v = case v of - TxOutDatumNone -> pure TxOutDatumNone - TxOutDatumHash ws hash -> - caseByronToMaryOrAlonzoEraOnwards - (const (Left $ EraCastError v (alonzoEraOnwardsToCardanoEra ws) toEra)) - (\wt -> Right $ TxOutDatumHash wt hash) - toEra - TxOutDatumInTx' ws scriptData hash -> - caseByronToMaryOrAlonzoEraOnwards - (const (Left $ EraCastError v (alonzoEraOnwardsToCardanoEra ws) toEra)) - (\wt -> Right $ TxOutDatumInTx' wt scriptData hash) - toEra - TxOutDatumInline ws scriptData -> - caseByronToAlonzoOrBabbageEraOnwards - (const (Left $ EraCastError v (babbageEraOnwardsToCardanoEra ws) toEra)) - (\wt -> Right $ TxOutDatumInline wt scriptData) - toEra - pattern TxOutDatumInTx :: AlonzoEraOnwards era -> HashableScriptData diff --git a/cardano-api/src/Cardano/Api.hs b/cardano-api/src/Cardano/Api.hs index a3aeb131ae..8f550b97b1 100644 --- a/cardano-api/src/Cardano/Api.hs +++ b/cardano-api/src/Cardano/Api.hs @@ -934,10 +934,6 @@ module Cardano.Api ( parseFilePath, writeSecrets, - -- ** Cast functions - EraCast (..), - EraCastError (..), - -- * Convenience functions -- ** Transaction construction @@ -1037,7 +1033,6 @@ import Cardano.Api.Eon.ShelleyToAllegraEra import Cardano.Api.Eon.ShelleyToAlonzoEra import Cardano.Api.Eon.ShelleyToBabbageEra import Cardano.Api.Eon.ShelleyToMaryEra -import Cardano.Api.EraCast import Cardano.Api.Eras import Cardano.Api.Eras.Case import Cardano.Api.Eras.Constraints