From 978cd0c8e5fce97792faa8d8794feae06852b39f Mon Sep 17 00:00:00 2001 From: John Ky Date: Sat, 29 Jul 2023 13:23:24 +1000 Subject: [PATCH] Deprecate TxVotesSupportedInEra --- cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs | 11 +++++------ .../Cardano/Api/Governance/Actions/VotingProcedure.hs | 7 ++++--- cardano-api/internal/Cardano/Api/TxBody.hs | 11 ++++++----- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs index d02693e062..546315331e 100644 --- a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs +++ b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs @@ -1124,11 +1124,10 @@ genTxGovernanceActions era = fromMaybe (pure TxGovernanceActionsNone) $ do genTxVotes :: CardanoEra era -> Gen (TxVotes era) genTxVotes era = fromMaybe (pure TxVotesNone) $ do - sbe <- join $ requireShelleyBasedEra era - supported <- votesSupportedInEra sbe - let votes = Gen.list (Range.constant 0 10) $ genVote sbe - pure $ TxVotes supported <$> votes + w <- featureInEra Nothing Just era + let votes = Gen.list (Range.constant 0 10) $ genVote w + pure $ TxVotes w <$> votes where - genVote :: ShelleyBasedEra era -> Gen (VotingProcedure era) - genVote sbe = obtainEraConstraints sbe $ VotingProcedure <$> Q.arbitrary + genVote :: ConwayEraOnwards era -> Gen (VotingProcedure era) + genVote w = conwayEraOnwardsConstraints w $ VotingProcedure <$> Q.arbitrary diff --git a/cardano-api/internal/Cardano/Api/Governance/Actions/VotingProcedure.hs b/cardano-api/internal/Cardano/Api/Governance/Actions/VotingProcedure.hs index 076ecbd216..423041d077 100644 --- a/cardano-api/internal/Cardano/Api/Governance/Actions/VotingProcedure.hs +++ b/cardano-api/internal/Cardano/Api/Governance/Actions/VotingProcedure.hs @@ -17,6 +17,7 @@ module Cardano.Api.Governance.Actions.VotingProcedure where import Cardano.Api.Address import Cardano.Api.Eras +import Cardano.Api.Feature.ConwayEraOnwards import Cardano.Api.HasTypeProxy import Cardano.Api.Keys.Shelley import Cardano.Api.Script @@ -47,7 +48,7 @@ data TxVotes era where TxVotesNone :: TxVotes era TxVotes - :: TxVotesSupportedInEra era + :: ConwayEraOnwards era -> [VotingProcedure era] -> TxVotes era @@ -61,11 +62,11 @@ deriving instance Eq (TxVotes era) -- data TxVotesSupportedInEra era where VotesSupportedInConwayEra :: TxVotesSupportedInEra ConwayEra +{-# DEPRECATED TxVotesSupportedInEra "Use ConwayEraOnwards instead" #-} deriving instance Show (TxVotesSupportedInEra era) deriving instance Eq (TxVotesSupportedInEra era) - votesSupportedInEra :: ShelleyBasedEra era -> Maybe (TxVotesSupportedInEra era) votesSupportedInEra ShelleyBasedEraShelley = Nothing votesSupportedInEra ShelleyBasedEraAllegra = Nothing @@ -73,7 +74,7 @@ votesSupportedInEra ShelleyBasedEraMary = Nothing votesSupportedInEra ShelleyBasedEraAlonzo = Nothing votesSupportedInEra ShelleyBasedEraBabbage = Nothing votesSupportedInEra ShelleyBasedEraConway = Just VotesSupportedInConwayEra - +{-# DEPRECATED votesSupportedInEra "Use conwayEraOnwardsConstraints instead" #-} newtype GovernanceActionId ledgerera = GovernanceActionId { unGovernanceActionId :: Ledger.GovernanceActionId (EraCrypto ledgerera) diff --git a/cardano-api/internal/Cardano/Api/TxBody.hs b/cardano-api/internal/Cardano/Api/TxBody.hs index 3c5b73a9b7..c2b5867d45 100644 --- a/cardano-api/internal/Cardano/Api/TxBody.hs +++ b/cardano-api/internal/Cardano/Api/TxBody.hs @@ -190,6 +190,7 @@ import Cardano.Api.Convenience.Constraints import Cardano.Api.EraCast import Cardano.Api.Eras import Cardano.Api.Error +import Cardano.Api.Feature.ConwayEraOnwards import Cardano.Api.Governance.Actions.ProposalProcedure import Cardano.Api.Governance.Actions.VotingProcedure import Cardano.Api.Hash @@ -2753,14 +2754,14 @@ fromLedgerProposalProcedure sbe body = fromLedgerTxVotes :: ShelleyBasedEra era -> Ledger.TxBody (ShelleyLedgerEra era) -> TxVotes era fromLedgerTxVotes sbe body = - case votesSupportedInEra sbe of - Nothing -> TxVotesNone - Just vsice -> TxVotes vsice (getVotes vsice body) + case featureInShelleyBasedEra Nothing Just sbe of + Nothing -> TxVotesNone + Just w -> TxVotes w (getVotes w body) where - getVotes :: TxVotesSupportedInEra era + getVotes :: ConwayEraOnwards era -> Ledger.TxBody (ShelleyLedgerEra era) -> [VotingProcedure era] - getVotes VotesSupportedInConwayEra body_ = fmap VotingProcedure . toList $ body_ ^. L.votingProceduresTxBodyL + getVotes ConwayEraOnwardsConway body_ = fmap VotingProcedure . toList $ body_ ^. L.votingProceduresTxBodyL fromLedgerTxIns :: forall era.