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

Share code in fields of queries #985

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
121 changes: 27 additions & 94 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

module Cardano.CLI.EraBased.Commands.Query
( QueryCmds (..)
, QueryCommons (..)
, QueryCommitteeMembersStateCmdArgs (..)
, QueryLeadershipScheduleCmdArgs (..)
, QueryProtocolParametersCmdArgs (..)
Expand Down Expand Up @@ -67,17 +68,23 @@ data QueryCmds era
| QueryTreasuryValueCmd !(QueryTreasuryValueCmdArgs era)
deriving (Generic, Show)

data QueryLeadershipScheduleCmdArgs = QueryLeadershipScheduleCmdArgs
-- | Fields that are common to most queries
data QueryCommons = QueryCommons
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
, target :: !(Consensus.Target ChainPoint)
, mOutFile :: !(Maybe (File () Out))
}
deriving (Generic, Show)

data QueryLeadershipScheduleCmdArgs = QueryLeadershipScheduleCmdArgs
{ commons :: !QueryCommons
, genesisFp :: !GenesisFile
, poolColdVerKeyFile :: !(VerificationKeyOrHashOrFile StakePoolKey)
, vrkSkeyFp :: !(SigningKeyFile In)
, whichSchedule :: !EpochLeadershipSchedule
, target :: !(Consensus.Target ChainPoint)
, format :: Maybe OutputFormatJsonOrText
, mOutFile :: !(Maybe (File () Out))
}
deriving (Generic, Show)

Expand All @@ -89,102 +96,56 @@ data QueryProtocolParametersCmdArgs = QueryProtocolParametersCmdArgs
}
deriving (Generic, Show)

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

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

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

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

data QueryUTxOCmdArgs = QueryUTxOCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
{ commons :: !QueryCommons
, queryFilter :: !QueryUTxOFilter
, networkId :: !NetworkId
, target :: !(Consensus.Target ChainPoint)
, format :: Maybe OutputFormatJsonOrText
, mOutFile :: !(Maybe (File () Out))
}
deriving (Generic, Show)

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

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

data QueryStakeSnapshotCmdArgs = QueryStakeSnapshotCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
{ commons :: !QueryCommons
, allOrOnlyPoolIds :: !(AllOrOnly (Hash StakePoolKey))
, target :: !(Consensus.Target ChainPoint)
, mOutFile :: !(Maybe (File () Out))
}
deriving (Generic, Show)

data QueryKesPeriodInfoCmdArgs = QueryKesPeriodInfoCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
{ commons :: !QueryCommons
, nodeOpCertFp :: !(File () In)
-- ^ Node operational certificate
, target :: !(Consensus.Target ChainPoint)
, mOutFile :: !(Maybe (File () Out))
}
deriving (Generic, Show)

data QueryPoolStateCmdArgs = QueryPoolStateCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
{ commons :: !QueryCommons
, allOrOnlyPoolIds :: !(AllOrOnly (Hash StakePoolKey))
, target :: !(Consensus.Target ChainPoint)
, mOutFile :: !(Maybe (File () Out))
}
deriving (Generic, Show)

Expand All @@ -207,80 +168,52 @@ data QuerySlotNumberCmdArgs = QuerySlotNumberCmdArgs
deriving (Generic, Show)

data QueryRefScriptSizeCmdArgs = QueryRefScriptSizeCmdArgs
{ nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
{ commons :: !QueryCommons
, transactionInputs :: !(Set TxIn)
, networkId :: !NetworkId
, target :: !(Consensus.Target ChainPoint)
, format :: Maybe OutputFormatJsonOrText
, mOutFile :: !(Maybe (File () Out))
}
deriving (Generic, Show)

data QueryNoArgCmdArgs era = QueryNoArgCmdArgs
{ eon :: !(ConwayEraOnwards era)
, nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
, target :: !(Consensus.Target ChainPoint)
, mOutFile :: !(Maybe (File () Out))
, commons :: !QueryCommons
}
deriving Show

data QueryDRepStateCmdArgs era = QueryDRepStateCmdArgs
{ eon :: !(ConwayEraOnwards era)
, nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
, commons :: !QueryCommons
, drepHashSources :: !(AllOrOnly DRepHashSource)
, includeStake :: !IncludeStake
, target :: !(Consensus.Target ChainPoint)
, mOutFile :: !(Maybe (File () Out))
}
deriving Show

data QueryDRepStakeDistributionCmdArgs era = QueryDRepStakeDistributionCmdArgs
{ eon :: !(ConwayEraOnwards era)
, nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
, commons :: !QueryCommons
, drepHashSources :: !(AllOrOnly DRepHashSource)
, target :: !(Consensus.Target ChainPoint)
, mOutFile :: !(Maybe (File () Out))
}
deriving Show

data QuerySPOStakeDistributionCmdArgs era = QuerySPOStakeDistributionCmdArgs
{ eon :: !(ConwayEraOnwards era)
, nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
, commons :: !QueryCommons
, spoHashSources :: !(AllOrOnly SPOHashSource)
, target :: !(Consensus.Target ChainPoint)
, mOutFile :: !(Maybe (File () Out))
}
deriving Show

data QueryCommitteeMembersStateCmdArgs era = QueryCommitteeMembersStateCmdArgs
{ eon :: !(ConwayEraOnwards era)
, nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
, commons :: !QueryCommons
, committeeColdKeys :: ![VerificationKeyOrHashOrFileOrScriptHash CommitteeColdKey]
, committeeHotKeys :: ![VerificationKeyOrHashOrFileOrScriptHash CommitteeHotKey]
, memberStatuses :: ![MemberStatus]
, target :: !(Consensus.Target ChainPoint)
, mOutFile :: !(Maybe (File () Out))
}
deriving Show

data QueryTreasuryValueCmdArgs era = QueryTreasuryValueCmdArgs
{ eon :: !(ConwayEraOnwards era)
, nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
, target :: !(Consensus.Target ChainPoint)
, mOutFile :: !(Maybe (File () Out))
, commons :: !QueryCommons
}
deriving Show

Expand Down
Loading
Loading