Skip to content

Commit

Permalink
add query future pparams
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc authored and CarlosLopezDeLara committed Jan 29, 2025
1 parent 10b410b commit e83d900
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cardano-api/internal/Cardano/Api/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ data QueryInShelleyBasedEra era result where
:: QueryInShelleyBasedEra era (L.Constitution (ShelleyLedgerEra era))
QueryGovState
:: QueryInShelleyBasedEra era (L.GovState (ShelleyLedgerEra era))
QueryFuturePParams
:: QueryInShelleyBasedEra era (Maybe (Core.PParams (ShelleyLedgerEra era)))
QueryDRepState
:: Set (Shelley.Credential Shelley.DRepRole StandardCrypto)
-> QueryInShelleyBasedEra
Expand Down Expand Up @@ -337,6 +339,7 @@ instance NodeToClientVersionOf (QueryInShelleyBasedEra era result) where
nodeToClientVersionOf QueryCommitteeMembersState{} = NodeToClientV_16
nodeToClientVersionOf QueryStakeVoteDelegatees{} = NodeToClientV_16
nodeToClientVersionOf QueryProposals{} = NodeToClientV_17
nodeToClientVersionOf QueryFuturePParams{} = NodeToClientV_18
nodeToClientVersionOf QueryLedgerPeerSnapshot = NodeToClientV_19

deriving instance Show (QueryInShelleyBasedEra era result)
Expand Down Expand Up @@ -673,6 +676,11 @@ toConsensusQueryShelleyBased sbe = \case
Some (consensusQueryInEraInMode era Consensus.GetAccountState)
QueryGovState ->
Some (consensusQueryInEraInMode era Consensus.GetGovState)
QueryFuturePParams ->
caseShelleyToBabbageOrConwayEraOnwards
(const $ error "toConsensusQueryShelleyBased: QueryRatifyState is only available in the Conway era")
(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 @@ -986,6 +994,11 @@ fromConsensusQueryResultShelleyBased sbe sbeQuery q' r' =
Consensus.GetGovState{} ->
r'
_ -> fromConsensusQueryResultMismatch
QueryFuturePParams{} ->
case q' of
Consensus.GetFuturePParams{} ->
r'
_ -> fromConsensusQueryResultMismatch
QueryDRepState{} ->
case q' of
Consensus.GetDRepState{} ->
Expand Down
15 changes: 15 additions & 0 deletions cardano-api/internal/Cardano/Api/Query/Expr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module Cardano.Api.Query.Expr
, querySPOStakeDistribution
, queryDRepState
, queryGovState
, queryFuturePParams
, queryStakeVoteDelegatees
, queryProposals
)
Expand Down Expand Up @@ -401,6 +402,20 @@ queryGovState era = do
let sbe = convert era
queryExpr $ QueryInEra $ QueryInShelleyBasedEra sbe QueryGovState

queryFuturePParams
:: ()
=> ConwayEraOnwards era
-> LocalStateQueryExpr
block
point
QueryInMode
r
IO
(Either UnsupportedNtcVersionError (Either EraMismatch (Maybe (L.PParams (ShelleyLedgerEra era)))))
queryFuturePParams era = do
let sbe = convert era
queryExpr $ QueryInEra $ QueryInShelleyBasedEra sbe QueryFuturePParams

queryDRepState
:: ConwayEraOnwards era
-> Set (L.Credential L.DRepRole L.StandardCrypto)
Expand Down
1 change: 1 addition & 0 deletions cardano-api/src/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,7 @@ module Cardano.Api
, queryUtxo
, queryConstitution
, queryGovState
, queryFuturePParams
, queryDRepState
, queryDRepStakeDistribution
, querySPOStakeDistribution
Expand Down

0 comments on commit e83d900

Please sign in to comment.