Skip to content

Commit

Permalink
Deprecate TxVotesSupportedInEra
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Jul 29, 2023
1 parent 7e17da2 commit 822ca83
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
11 changes: 5 additions & 6 deletions cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -47,7 +48,7 @@ data TxVotes era where
TxVotesNone :: TxVotes era

TxVotes
:: TxVotesSupportedInEra era
:: ConwayEraOnwards era
-> [VotingProcedure era]
-> TxVotes era

Expand All @@ -61,19 +62,19 @@ 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
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)
Expand Down
11 changes: 6 additions & 5 deletions cardano-api/internal/Cardano/Api/TxBody.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 822ca83

Please sign in to comment.