Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean-up remainings of query constitution-hash #871

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading