Skip to content

Commit

Permalink
Merge pull request #871 from IntersectMBO/cleanup-query-constitution-…
Browse files Browse the repository at this point in the history
…hash-remainings

Clean-up remainings of `query constitution-hash`
  • Loading branch information
erikd authored Aug 22, 2024
2 parents e3aa173 + cb7ba0d commit fd7a3d0
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 60 deletions.
13 changes: 0 additions & 13 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module Cardano.CLI.EraBased.Commands.Query
, QueryCommitteeMembersStateCmdArgs (..)
, QueryLeadershipScheduleCmdArgs (..)
, QueryProtocolParametersCmdArgs (..)
, QueryConstitutionHashCmdArgs (..)
, QueryTipCmdArgs (..)
, QueryStakePoolsCmdArgs (..)
, QueryStakeDistributionCmdArgs (..)
Expand Down Expand Up @@ -46,7 +45,6 @@ import GHC.Generics
data QueryCmds era
= QueryLeadershipScheduleCmd !QueryLeadershipScheduleCmdArgs
| QueryProtocolParametersCmd !QueryProtocolParametersCmdArgs
| QueryConstitutionHashCmd !QueryConstitutionHashCmdArgs
| QueryTipCmd !QueryTipCmdArgs
| QueryStakePoolsCmd !QueryStakePoolsCmdArgs
| QueryStakeDistributionCmd !QueryStakeDistributionCmdArgs
Expand Down Expand Up @@ -91,15 +89,6 @@ data QueryProtocolParametersCmdArgs = QueryProtocolParametersCmdArgs
}
deriving (Generic, Show)

data QueryConstitutionHashCmdArgs = QueryConstitutionHashCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
, target :: !(Consensus.Target ChainPoint)
, mOutFile :: !(Maybe (File () Out))
}
deriving (Generic, Show)

data QueryTipCmdArgs = QueryTipCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
Expand Down Expand Up @@ -301,8 +290,6 @@ renderQueryCmds = \case
"query leadership-schedule"
QueryProtocolParametersCmd{} ->
"query protocol-parameters "
QueryConstitutionHashCmd{} ->
"query constitution-hash "
QueryTipCmd{} ->
"query tip"
QueryStakePoolsCmd{} ->
Expand Down
38 changes: 0 additions & 38 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

module Cardano.CLI.EraBased.Run.Query
( runQueryCmds
, runQueryConstitutionHashCmd
, runQueryKesPeriodInfoCmd
, runQueryLeadershipScheduleCmd
, runQueryLedgerStateCmd
Expand Down Expand Up @@ -105,7 +104,6 @@ runQueryCmds :: Cmd.QueryCmds era -> ExceptT QueryCmdError IO ()
runQueryCmds = \case
Cmd.QueryLeadershipScheduleCmd args -> runQueryLeadershipScheduleCmd args
Cmd.QueryProtocolParametersCmd args -> runQueryProtocolParametersCmd args
Cmd.QueryConstitutionHashCmd args -> runQueryConstitutionHashCmd args
Cmd.QueryTipCmd args -> runQueryTipCmd args
Cmd.QueryStakePoolsCmd args -> runQueryStakePoolsCmd args
Cmd.QueryStakeDistributionCmd args -> runQueryStakeDistributionCmd args
Expand All @@ -127,42 +125,6 @@ runQueryCmds = \case
Cmd.QueryCommitteeMembersStateCmd args -> runQueryCommitteeMembersState args
Cmd.QueryTreasuryValueCmd args -> runQueryTreasuryValue args

runQueryConstitutionHashCmd
:: ()
=> Cmd.QueryConstitutionHashCmdArgs
-> ExceptT QueryCmdError IO ()
runQueryConstitutionHashCmd
Cmd.QueryConstitutionHashCmdArgs
{ Cmd.nodeSocketPath
, Cmd.consensusModeParams
, Cmd.networkId
, Cmd.target
, Cmd.mOutFile
} = do
let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath

result <- liftIO $ executeLocalStateQueryExpr localNodeConnInfo target $ runExceptT $ do
AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion)

sbe <-
requireShelleyBasedEra era
& onNothing (left QueryCmdByronEra)

lift (shelleyBasedEraConstraints sbe (queryConstitutionHash sbe))
& onLeft (left . QueryCmdUnsupportedNtcVersion)
& onLeft (left . QueryCmdEraMismatch)

writeConstitutionHash mOutFile =<< except (join (first QueryCmdAcquireFailure result))
where
writeConstitutionHash
:: Maybe (File () Out)
-> L.SafeHash L.StandardCrypto L.AnchorData
-> ExceptT QueryCmdError IO ()
writeConstitutionHash mOutFile' cHash =
firstExceptT QueryCmdWriteFileError . newExceptT $
writeLazyByteStringOutput mOutFile' $
encodePretty cHash

runQueryProtocolParametersCmd
:: ()
=> Cmd.QueryProtocolParametersCmdArgs
Expand Down
9 changes: 0 additions & 9 deletions cardano-cli/src/Cardano/CLI/Legacy/Commands/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module Cardano.CLI.Legacy.Commands.Query
( LegacyQueryCmds (..)
, LegacyQueryLeadershipScheduleCmdArgs (..)
, LegacyQueryProtocolParametersCmdArgs (..)
, LegacyQueryConstitutionHashCmdArgs (..)
, LegacyQueryTipCmdArgs (..)
, LegacyQueryStakePoolsCmdArgs (..)
, LegacyQueryStakeDistributionCmdArgs (..)
Expand Down Expand Up @@ -71,14 +70,6 @@ data LegacyQueryProtocolParametersCmdArgs = LegacyQueryProtocolParametersCmdArgs
}
deriving (Generic, Show)

data LegacyQueryConstitutionHashCmdArgs = LegacyQueryConstitutionHashCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
}
deriving (Generic, Show)

data LegacyQueryTipCmdArgs = LegacyQueryTipCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
Expand Down

0 comments on commit fd7a3d0

Please sign in to comment.