From fd3b5dcff0dfa0554d17f5a137c08eded3882b9b Mon Sep 17 00:00:00 2001 From: John Ky Date: Mon, 9 Oct 2023 22:57:55 +1100 Subject: [PATCH] Delete EraCast instance for Certificate --- .../internal/Cardano/Api/Certificate.hs | 148 ------------------ 1 file changed, 148 deletions(-) diff --git a/cardano-api/internal/Cardano/Api/Certificate.hs b/cardano-api/internal/Cardano/Api/Certificate.hs index 9f9febfe36..f753e1a0ff 100644 --- a/cardano-api/internal/Cardano/Api/Certificate.hs +++ b/cardano-api/internal/Cardano/Api/Certificate.hs @@ -77,7 +77,6 @@ import Cardano.Api.DRepMetadata import Cardano.Api.Eon.ConwayEraOnwards import Cardano.Api.Eon.ShelleyBasedEra import Cardano.Api.Eon.ShelleyToBabbageEra -import Cardano.Api.EraCast import Cardano.Api.Eras import Cardano.Api.Eras.Constraints import Cardano.Api.Governance.Actions.VotingProcedure @@ -182,153 +181,6 @@ instance ConwayCertificate _ (Ledger.ConwayTxCertPool Ledger.RegPool{}) -> "Pool registration" ConwayCertificate _ (Ledger.ConwayTxCertPool Ledger.RetirePool{}) -> "Pool retirement" -castShelleyTxCert :: () - => EraCrypto srcLedgerEra ~ StandardCrypto - => EraCrypto tgtLedgerEra ~ StandardCrypto - => Ledger.ShelleyTxCert srcLedgerEra - -> Ledger.ShelleyTxCert tgtLedgerEra -castShelleyTxCert = \case - Ledger.ShelleyTxCertDelegCert c -> - Ledger.ShelleyTxCertDelegCert c - Ledger.ShelleyTxCertPool c -> - Ledger.ShelleyTxCertPool c - Ledger.ShelleyTxCertGenesisDeleg c -> - Ledger.ShelleyTxCertGenesisDeleg c - Ledger.ShelleyTxCertMir c -> - Ledger.ShelleyTxCertMir c - -castConwayTxCert :: () - => EraCrypto srcLedgerEra ~ StandardCrypto - => EraCrypto tgtLedgerEra ~ StandardCrypto - => Ledger.ConwayTxCert srcLedgerEra - -> Ledger.ConwayTxCert tgtLedgerEra -castConwayTxCert = \case - Ledger.ConwayTxCertDeleg c -> - Ledger.ConwayTxCertDeleg c - Ledger.ConwayTxCertPool c -> - Ledger.ConwayTxCertPool c - Ledger.ConwayTxCertGov c -> - Ledger.ConwayTxCertGov c - -castShelleyToConwayTxCert :: () - => EraCrypto srcLedgerEra ~ StandardCrypto - => EraCrypto tgtLedgerEra ~ StandardCrypto - => Ledger.ShelleyTxCert srcLedgerEra - -> Maybe (Ledger.ConwayTxCert tgtLedgerEra) -castShelleyToConwayTxCert = \case - Ledger.ShelleyTxCertDelegCert c -> - fmap Ledger.ConwayTxCertDeleg - $ case c of - Ledger.ShelleyRegCert sc -> - Just $ Ledger.ConwayRegCert sc Ledger.SNothing - Ledger.ShelleyUnRegCert sc -> - Just $ Ledger.ConwayUnRegCert sc Ledger.SNothing - Ledger.ShelleyDelegCert sc ph -> - Just $ Ledger.ConwayDelegCert sc (Ledger.DelegStake ph) - Ledger.ShelleyTxCertPool c -> - Just $ Ledger.ConwayTxCertPool c - Ledger.ShelleyTxCertGenesisDeleg _ -> - Nothing - Ledger.ShelleyTxCertMir _ -> - Nothing - -castConwayToShelleyTxCert :: () - => EraCrypto srcLedgerEra ~ StandardCrypto - => EraCrypto tgtLedgerEra ~ StandardCrypto - => Ledger.ConwayTxCert srcLedgerEra - -> Maybe (Ledger.ShelleyTxCert tgtLedgerEra) -castConwayToShelleyTxCert = \case - Ledger.ConwayTxCertDeleg txCert -> - fmap Ledger.ShelleyTxCertDelegCert - $ case txCert of - Ledger.ConwayRegCert stakeCred mCoin -> - case mCoin of - Ledger.SNothing -> - Just $ Ledger.ShelleyRegCert stakeCred - Ledger.SJust {} -> - Nothing - Ledger.ConwayUnRegCert stakeCred mCoin -> - case mCoin of - Ledger.SNothing -> - Just $ Ledger.ShelleyUnRegCert stakeCred - Ledger.SJust {} -> - Nothing - Ledger.ConwayDelegCert stakeCred delegCert -> - case delegCert of - Ledger.DelegStake poolHash -> - Just $ Ledger.ShelleyDelegCert stakeCred poolHash - Ledger.DelegVote {} -> - Nothing - Ledger.DelegStakeVote {} -> - Nothing - Ledger.ConwayRegDelegCert {} -> - Nothing - Ledger.ConwayTxCertPool poolCert -> - Just $ Ledger.ShelleyTxCertPool poolCert - Ledger.ConwayTxCertGov {} -> - Nothing - -instance EraCast Certificate where - eraCast targetEra cert = - case cert of - ShelleyRelatedCertificate sourceWit sourceLedgerCert -> - shelleyToBabbageEraConstraints sourceWit - $ forEraInEon targetEra - ( forEraInEon targetEra - ( Left $ EraCastError - { originalValue = cert - , fromEra = shelleyToBabbageEraToCardanoEra sourceWit - , toEra = targetEra - } - ) - (\tgtw -> - conwayEraOnwardsConstraints tgtw - $ case castShelleyToConwayTxCert sourceLedgerCert of - Just targetLedgerCert -> Right $ ConwayCertificate tgtw targetLedgerCert - Nothing -> - Left $ EraCastError - { originalValue = cert - , fromEra = shelleyToBabbageEraToCardanoEra sourceWit - , toEra = targetEra - } - ) - ) - (\targetWit -> - Right - $ ShelleyRelatedCertificate targetWit - $ shelleyToBabbageEraConstraints targetWit - $ castShelleyTxCert sourceLedgerCert - ) - - ConwayCertificate sourceWit sourceLedgerCert -> - conwayEraOnwardsConstraints sourceWit - $ forEraInEon targetEra - ( forEraInEon targetEra - ( Left $ EraCastError - { originalValue = cert - , fromEra = conwayEraOnwardsToCardanoEra sourceWit - , toEra = targetEra - } - ) - (\targetWit -> - shelleyToBabbageEraConstraints targetWit - $ case castConwayToShelleyTxCert sourceLedgerCert of - Just targetLedgerCert -> Right $ ShelleyRelatedCertificate targetWit targetLedgerCert - Nothing -> - Left $ EraCastError - { originalValue = cert - , fromEra = conwayEraOnwardsToCardanoEra sourceWit - , toEra = targetEra - } - ) - ) - (\targetWit -> - Right - $ ConwayCertificate targetWit - $ conwayEraOnwardsConstraints targetWit - $ castConwayTxCert sourceLedgerCert - ) - -- ---------------------------------------------------------------------------- -- Stake pool parameters --