Skip to content

Commit

Permalink
Add field names to query command types
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Sep 29, 2023
1 parent fbb316f commit 6397a0c
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 224 deletions.
179 changes: 90 additions & 89 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE LambdaCase #-}

module Cardano.CLI.EraBased.Commands.Query
Expand All @@ -12,7 +13,7 @@ module Cardano.CLI.EraBased.Commands.Query
, QueryStakeDistributionCmdArgs(..)
, QueryStakeAddressInfoCmdArgs(..)
, QueryUTxOCmdArgs(..)
, QueryDebugLedgerStateCmdArgs(..)
, QueryLedgerStateCmdArgs(..)
, QueryProtocolStateCmdArgs(..)
, QueryStakeSnapshotCmdArgs(..)
, QueryKesPeriodInfoCmdArgs(..)
Expand Down Expand Up @@ -40,7 +41,7 @@ data QueryCmds era
| QueryStakeDistributionCmd !QueryStakeDistributionCmdArgs
| QueryStakeAddressInfoCmd !QueryStakeAddressInfoCmdArgs
| QueryUTxOCmd !QueryUTxOCmdArgs
| QueryDebugLedgerStateCmd !QueryDebugLedgerStateCmdArgs
| QueryLedgerStateCmd !QueryLedgerStateCmdArgs
| QueryProtocolStateCmd !QueryProtocolStateCmdArgs
| QueryStakeSnapshotCmd !QueryStakeSnapshotCmdArgs
| QueryKesPeriodInfoCmd !QueryKesPeriodInfoCmdArgs
Expand All @@ -50,119 +51,119 @@ data QueryCmds era
deriving (Generic, Show)

data QueryLeadershipScheduleCmdArgs = QueryLeadershipScheduleCmdArgs
!SocketPath
!AnyConsensusModeParams
!NetworkId
!GenesisFile
!(VerificationKeyOrHashOrFile StakePoolKey)
!(SigningKeyFile In)
!EpochLeadershipSchedule
!(Maybe (File () Out))
deriving (Generic, Show)
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, network :: !NetworkId
, genesisFp :: !GenesisFile
, poolId :: !(VerificationKeyOrHashOrFile StakePoolKey)
, vrkSkeyFp :: !(SigningKeyFile In)
, whichSchedule :: !EpochLeadershipSchedule
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryProtocolParametersCmdArgs = QueryProtocolParametersCmdArgs
!SocketPath
!AnyConsensusModeParams
!NetworkId
!(Maybe (File () Out))
deriving (Generic, Show)
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, network :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryConstitutionHashCmdArgs = QueryConstitutionHashCmdArgs
!SocketPath
!AnyConsensusModeParams
!NetworkId
!(Maybe (File () Out))
deriving (Generic, Show)
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, network :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryTipCmdArgs = QueryTipCmdArgs
!SocketPath
!AnyConsensusModeParams
!NetworkId
!(Maybe (File () Out))
deriving (Generic, Show)
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, network :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryStakePoolsCmdArgs = QueryStakePoolsCmdArgs
!SocketPath
!AnyConsensusModeParams
!NetworkId
!(Maybe (File () Out))
deriving (Generic, Show)
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, network :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryStakeDistributionCmdArgs = QueryStakeDistributionCmdArgs
!SocketPath
!AnyConsensusModeParams
!NetworkId
!(Maybe (File () Out))
deriving (Generic, Show)
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, network :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryStakeAddressInfoCmdArgs = QueryStakeAddressInfoCmdArgs
!SocketPath
!AnyConsensusModeParams
!StakeAddress
!NetworkId
!(Maybe (File () Out))
deriving (Generic, Show)
{ mNodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, addr :: !StakeAddress
, network :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryUTxOCmdArgs = QueryUTxOCmdArgs
!SocketPath
!AnyConsensusModeParams
!QueryUTxOFilter
!NetworkId
!(Maybe (File () Out))
deriving (Generic, Show)

data QueryDebugLedgerStateCmdArgs = QueryDebugLedgerStateCmdArgs
!SocketPath
!AnyConsensusModeParams
!NetworkId
!(Maybe (File () Out))
deriving (Generic, Show)
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, queryFilter :: !QueryUTxOFilter
, networkId :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryLedgerStateCmdArgs = QueryLedgerStateCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, network :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryProtocolStateCmdArgs = QueryProtocolStateCmdArgs
!SocketPath
!AnyConsensusModeParams
!NetworkId
!(Maybe (File () Out))
deriving (Generic, Show)
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, network :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryStakeSnapshotCmdArgs = QueryStakeSnapshotCmdArgs
!SocketPath
!AnyConsensusModeParams
!NetworkId
!(AllOrOnly [Hash StakePoolKey])
!(Maybe (File () Out))
deriving (Generic, Show)
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, network :: !NetworkId
, allOrOnlyPoolIds :: !(AllOrOnly [Hash StakePoolKey])
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryKesPeriodInfoCmdArgs = QueryKesPeriodInfoCmdArgs
!SocketPath
!AnyConsensusModeParams
!NetworkId
!(File () In)
-- ^ Node operational certificate
!(Maybe (File () Out))
deriving (Generic, Show)
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, network :: !NetworkId
, nodeOpCert :: !(File () In) -- ^ Node operational certificate
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

data QueryPoolStateCmdArgs = QueryPoolStateCmdArgs
!SocketPath
!AnyConsensusModeParams
!NetworkId
![Hash StakePoolKey]
deriving (Generic, Show)
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, network :: !NetworkId
, poolid :: ![Hash StakePoolKey]
} deriving (Generic, Show)

data QueryTxMempoolCmdArgs = QueryTxMempoolCmdArgs
!SocketPath
!AnyConsensusModeParams
!NetworkId
!TxMempoolQuery
!(Maybe (File () Out))
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, network :: !NetworkId
, op :: !TxMempoolQuery
, mOutFile :: !(Maybe (File () Out))
}
deriving (Generic, Show)

data QuerySlotNumberCmdArgs = QuerySlotNumberCmdArgs
!SocketPath
!AnyConsensusModeParams
!NetworkId
!UTCTime
deriving (Generic, Show)
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, network :: !NetworkId
, utcTime :: !UTCTime
} deriving (Generic, Show)

renderQueryCmds :: QueryCmds era -> Text
renderQueryCmds = \case
Expand All @@ -182,7 +183,7 @@ renderQueryCmds = \case
"query stake-address-info"
QueryUTxOCmd {} ->
"query utxo"
QueryDebugLedgerStateCmd {} ->
QueryLedgerStateCmd {} ->
"query ledger-state"
QueryProtocolStateCmd {} ->
"query protocol-state"
Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ pQueryStakeAddressInfoCmd envCli =

pQueryLedgerStateCmd :: EnvCli -> Parser (QueryCmds era)
pQueryLedgerStateCmd envCli =
fmap QueryDebugLedgerStateCmd $
QueryDebugLedgerStateCmdArgs
fmap QueryLedgerStateCmd $
QueryLedgerStateCmdArgs
<$> pSocketPath envCli
<*> pConsensusModeParams
<*> pNetworkId envCli
Expand Down
34 changes: 17 additions & 17 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import Cardano.Api.Byron hiding (QueryInShelleyBasedEra (..))
import qualified Cardano.Api.Ledger as Ledger
import Cardano.Api.Shelley hiding (QueryInShelleyBasedEra (..))

import Cardano.CLI.EraBased.Commands.Query
import qualified Cardano.CLI.EraBased.Commands.Query as Cmd
import Cardano.CLI.EraBased.Run.Genesis (readAndDecodeShelleyGenesis)
import Cardano.CLI.Helpers (pPrintCBOR)
import Cardano.CLI.Pretty
Expand Down Expand Up @@ -104,37 +104,37 @@ import Text.Printf (printf)
{- HLINT ignore "Move brackets to avoid $" -}
{- HLINT ignore "Redundant flip" -}

runQueryCmds :: QueryCmds era -> ExceptT QueryCmdError IO ()
runQueryCmds :: Cmd.QueryCmds era -> ExceptT QueryCmdError IO ()
runQueryCmds = \case
QueryLeadershipScheduleCmd (QueryLeadershipScheduleCmdArgs mNodeSocketPath consensusModeParams network shelleyGenFp poolid vrkSkeyFp whichSchedule outputAs) ->
Cmd.QueryLeadershipScheduleCmd (Cmd.QueryLeadershipScheduleCmdArgs mNodeSocketPath consensusModeParams network shelleyGenFp poolid vrkSkeyFp whichSchedule outputAs) ->
runQueryLeadershipScheduleCmd mNodeSocketPath consensusModeParams network shelleyGenFp poolid vrkSkeyFp whichSchedule outputAs
QueryProtocolParametersCmd (QueryProtocolParametersCmdArgs mNodeSocketPath consensusModeParams network mOutFile) ->
Cmd.QueryProtocolParametersCmd (Cmd.QueryProtocolParametersCmdArgs mNodeSocketPath consensusModeParams network mOutFile) ->
runQueryProtocolParametersCmd mNodeSocketPath consensusModeParams network mOutFile
QueryConstitutionHashCmd (QueryConstitutionHashCmdArgs mNodeSocketPath consensusModeParams network mOutFile) ->
Cmd.QueryConstitutionHashCmd (Cmd.QueryConstitutionHashCmdArgs mNodeSocketPath consensusModeParams network mOutFile) ->
runQueryConstitutionHashCmd mNodeSocketPath consensusModeParams network mOutFile
QueryTipCmd (QueryTipCmdArgs mNodeSocketPath consensusModeParams network mOutFile) ->
Cmd.QueryTipCmd (Cmd.QueryTipCmdArgs mNodeSocketPath consensusModeParams network mOutFile) ->
runQueryTipCmd mNodeSocketPath consensusModeParams network mOutFile
QueryStakePoolsCmd (QueryStakePoolsCmdArgs mNodeSocketPath consensusModeParams network mOutFile) ->
Cmd.QueryStakePoolsCmd (Cmd.QueryStakePoolsCmdArgs mNodeSocketPath consensusModeParams network mOutFile) ->
runQueryStakePoolsCmd mNodeSocketPath consensusModeParams network mOutFile
QueryStakeDistributionCmd (QueryStakeDistributionCmdArgs mNodeSocketPath consensusModeParams network mOutFile) ->
Cmd.QueryStakeDistributionCmd (Cmd.QueryStakeDistributionCmdArgs mNodeSocketPath consensusModeParams network mOutFile) ->
runQueryStakeDistributionCmd mNodeSocketPath consensusModeParams network mOutFile
QueryStakeAddressInfoCmd (QueryStakeAddressInfoCmdArgs mNodeSocketPath consensusModeParams addr network mOutFile) ->
Cmd.QueryStakeAddressInfoCmd (Cmd.QueryStakeAddressInfoCmdArgs mNodeSocketPath consensusModeParams addr network mOutFile) ->
runQueryStakeAddressInfoCmd mNodeSocketPath consensusModeParams addr network mOutFile
QueryDebugLedgerStateCmd (QueryDebugLedgerStateCmdArgs mNodeSocketPath consensusModeParams network mOutFile) ->
Cmd.QueryLedgerStateCmd (Cmd.QueryLedgerStateCmdArgs mNodeSocketPath consensusModeParams network mOutFile) ->
runQueryLedgerStateCmd mNodeSocketPath consensusModeParams network mOutFile
QueryStakeSnapshotCmd (QueryStakeSnapshotCmdArgs mNodeSocketPath consensusModeParams network allOrOnlyPoolIds mOutFile) ->
Cmd.QueryStakeSnapshotCmd (Cmd.QueryStakeSnapshotCmdArgs mNodeSocketPath consensusModeParams network allOrOnlyPoolIds mOutFile) ->
runQueryStakeSnapshotCmd mNodeSocketPath consensusModeParams network allOrOnlyPoolIds mOutFile
QueryProtocolStateCmd (QueryProtocolStateCmdArgs mNodeSocketPath consensusModeParams network mOutFile) ->
Cmd.QueryProtocolStateCmd (Cmd.QueryProtocolStateCmdArgs mNodeSocketPath consensusModeParams network mOutFile) ->
runQueryProtocolStateCmd mNodeSocketPath consensusModeParams network mOutFile
QueryUTxOCmd (QueryUTxOCmdArgs mNodeSocketPath consensusModeParams qFilter networkId mOutFile) ->
Cmd.QueryUTxOCmd (Cmd.QueryUTxOCmdArgs mNodeSocketPath consensusModeParams qFilter networkId mOutFile) ->
runQueryUTxOCmd mNodeSocketPath consensusModeParams qFilter networkId mOutFile
QueryKesPeriodInfoCmd (QueryKesPeriodInfoCmdArgs mNodeSocketPath consensusModeParams network nodeOpCert mOutFile) ->
Cmd.QueryKesPeriodInfoCmd (Cmd.QueryKesPeriodInfoCmdArgs mNodeSocketPath consensusModeParams network nodeOpCert mOutFile) ->
runQueryKesPeriodInfoCmd mNodeSocketPath consensusModeParams network nodeOpCert mOutFile
QueryPoolStateCmd (QueryPoolStateCmdArgs mNodeSocketPath consensusModeParams network poolid) ->
Cmd.QueryPoolStateCmd (Cmd.QueryPoolStateCmdArgs mNodeSocketPath consensusModeParams network poolid) ->
runQueryPoolStateCmd mNodeSocketPath consensusModeParams network poolid
QueryTxMempoolCmd (QueryTxMempoolCmdArgs mNodeSocketPath consensusModeParams network op mOutFile) ->
Cmd.QueryTxMempoolCmd (Cmd.QueryTxMempoolCmdArgs mNodeSocketPath consensusModeParams network op mOutFile) ->
runQueryTxMempoolCmd mNodeSocketPath consensusModeParams network op mOutFile
QuerySlotNumberCmd (QuerySlotNumberCmdArgs mNodeSocketPath consensusModeParams network utcTime) ->
Cmd.QuerySlotNumberCmd (Cmd.QuerySlotNumberCmdArgs mNodeSocketPath consensusModeParams network utcTime) ->
runQuerySlotNumberCmd mNodeSocketPath consensusModeParams network utcTime

runQueryConstitutionHashCmd
Expand Down
Loading

0 comments on commit 6397a0c

Please sign in to comment.