Skip to content

Commit

Permalink
Merge pull request #739 from IntersectMBO/clr/add-future-pparams-query
Browse files Browse the repository at this point in the history
add query future pparams
  • Loading branch information
CarlosLopezDeLara authored Feb 1, 2025
2 parents 72a3ec0 + d09090d commit f1a1af3
Show file tree
Hide file tree
Showing 3 changed files with 232 additions and 201 deletions.
27 changes: 21 additions & 6 deletions cardano-api/internal/Cardano/Api/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ data QueryInShelleyBasedEra era result where
:: QueryInShelleyBasedEra era (Ledger.PParams (ShelleyLedgerEra era))
QueryProtocolParametersUpdate
:: QueryInShelleyBasedEra
era
(Map (Hash GenesisKey) ProtocolParametersUpdate)
era
(Map (Hash GenesisKey) ProtocolParametersUpdate)
QueryStakeDistribution
:: QueryInShelleyBasedEra era (Map (Hash StakePoolKey) Rational)
QueryUTxO
Expand Down Expand Up @@ -282,11 +282,13 @@ data QueryInShelleyBasedEra era result where
:: QueryInShelleyBasedEra era (L.GovState (ShelleyLedgerEra era))
QueryRatifyState
:: QueryInShelleyBasedEra era (L.RatifyState (ShelleyLedgerEra era))
QueryFuturePParams
:: QueryInShelleyBasedEra era (Maybe (Core.PParams (ShelleyLedgerEra era)))
QueryDRepState
:: Set (Shelley.Credential Shelley.DRepRole StandardCrypto)
-> QueryInShelleyBasedEra
era
(Map (Shelley.Credential Shelley.DRepRole StandardCrypto) (L.DRepState StandardCrypto))
era
(Map (Shelley.Credential Shelley.DRepRole StandardCrypto) (L.DRepState StandardCrypto))
QueryDRepStakeDistr
:: Set (Ledger.DRep StandardCrypto)
-> QueryInShelleyBasedEra era (Map (Ledger.DRep StandardCrypto) L.Coin)
Expand Down Expand Up @@ -340,6 +342,7 @@ instance NodeToClientVersionOf (QueryInShelleyBasedEra era result) where
nodeToClientVersionOf QueryStakeVoteDelegatees{} = NodeToClientV_16
nodeToClientVersionOf QueryProposals{} = NodeToClientV_17
nodeToClientVersionOf QueryRatifyState{} = NodeToClientV_17
nodeToClientVersionOf QueryFuturePParams{} = NodeToClientV_18
nodeToClientVersionOf QueryLedgerPeerSnapshot = NodeToClientV_19

deriving instance Show (QueryInShelleyBasedEra era result)
Expand Down Expand Up @@ -538,8 +541,8 @@ fromShelleyPoolDistr =

fromShelleyDelegations
:: Map
(Shelley.Credential Shelley.Staking StandardCrypto)
(Shelley.KeyHash Shelley.StakePool StandardCrypto)
(Shelley.Credential Shelley.Staking StandardCrypto)
(Shelley.KeyHash Shelley.StakePool StandardCrypto)
-> Map StakeCredential PoolId
fromShelleyDelegations =
-- TODO: write an appropriate property to show it is safe to use
Expand Down Expand Up @@ -681,6 +684,13 @@ toConsensusQueryShelleyBased sbe = \case
(const $ error "toConsensusQueryShelleyBased: QueryRatifyState is only available in the Conway era")
(const $ Some (consensusQueryInEraInMode era Consensus.GetRatifyState))
sbe
QueryFuturePParams ->
caseShelleyToBabbageOrConwayEraOnwards
( const $
error "toConsensusQueryShelleyBased: QueryFuturePParams is only available in the Conway era onwards"
)
(const $ Some (consensusQueryInEraInMode era Consensus.GetFuturePParams))
sbe
QueryDRepState creds ->
caseShelleyToBabbageOrConwayEraOnwards
(const $ error "toConsensusQueryShelleyBased: QueryDRepState is only available in the Conway era")
Expand Down Expand Up @@ -999,6 +1009,11 @@ fromConsensusQueryResultShelleyBased sbe sbeQuery q' r' =
Consensus.GetRatifyState{} ->
r'
_ -> fromConsensusQueryResultMismatch
QueryFuturePParams{} ->
case q' of
Consensus.GetFuturePParams{} ->
r'
_ -> fromConsensusQueryResultMismatch
QueryDRepState{} ->
case q' of
Consensus.GetDRepState{} ->
Expand Down
Loading

0 comments on commit f1a1af3

Please sign in to comment.