Skip to content

Commit

Permalink
Improve the way query command arg types are used
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Sep 29, 2023
1 parent 6397a0c commit db889d2
Show file tree
Hide file tree
Showing 4 changed files with 298 additions and 346 deletions.
42 changes: 21 additions & 21 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ data QueryCmds era
data QueryLeadershipScheduleCmdArgs = QueryLeadershipScheduleCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, network :: !NetworkId
, networkId :: !NetworkId
, genesisFp :: !GenesisFile
, poolId :: !(VerificationKeyOrHashOrFile StakePoolKey)
, poolColdVerKeyFile :: !(VerificationKeyOrHashOrFile StakePoolKey)
, vrkSkeyFp :: !(SigningKeyFile In)
, whichSchedule :: !EpochLeadershipSchedule
, mOutFile :: !(Maybe (File () Out))
Expand All @@ -64,43 +64,43 @@ data QueryLeadershipScheduleCmdArgs = QueryLeadershipScheduleCmdArgs
data QueryProtocolParametersCmdArgs = QueryProtocolParametersCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, network :: !NetworkId
, networkId :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

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

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

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

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

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

Expand All @@ -115,53 +115,53 @@ data QueryUTxOCmdArgs = QueryUTxOCmdArgs
data QueryLedgerStateCmdArgs = QueryLedgerStateCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !AnyConsensusModeParams
, network :: !NetworkId
, networkId :: !NetworkId
, mOutFile :: !(Maybe (File () Out))
} deriving (Generic, Show)

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

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

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

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

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

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

Expand Down Expand Up @@ -193,8 +193,8 @@ renderQueryCmds = \case
"query kes-period-info"
QueryPoolStateCmd {} ->
"query pool-state"
QueryTxMempoolCmd (QueryTxMempoolCmdArgs _ _ _ query _) ->
"query tx-mempool" <> renderTxMempoolQuery query
QueryTxMempoolCmd (QueryTxMempoolCmdArgs _ _ _ q _) ->
"query tx-mempool" <> renderTxMempoolQuery q
QuerySlotNumberCmd {} ->
"query slot-number"

Expand Down
Loading

0 comments on commit db889d2

Please sign in to comment.