Skip to content

Commit

Permalink
Merge pull request #1036 from IntersectMBO/smelc/new-ratify-state-query
Browse files Browse the repository at this point in the history
Add the ratify-state query
  • Loading branch information
smelc authored Feb 5, 2025
2 parents a30e3aa + 8807f00 commit dc09bb9
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ data QueryCmds era
| QueryRefScriptSizeCmd !QueryRefScriptSizeCmdArgs
| QueryConstitutionCmd !(QueryNoArgCmdArgs era)
| QueryGovStateCmd !(QueryNoArgCmdArgs era)
| QueryRatifyStateCmd !(QueryNoArgCmdArgs era)
| QueryDRepStateCmd !(QueryDRepStateCmdArgs era)
| QueryDRepStakeDistributionCmd !(QueryDRepStakeDistributionCmdArgs era)
| QuerySPOStakeDistributionCmd !(QuerySPOStakeDistributionCmdArgs era)
Expand Down Expand Up @@ -291,6 +292,8 @@ renderQueryCmds = \case
"constitution"
QueryGovStateCmd{} ->
"gov-state"
QueryRatifyStateCmd{} ->
"ratify-state"
QueryDRepStateCmd{} ->
"drep-state"
QueryDRepStakeDistributionCmd{} ->
Expand Down
13 changes: 13 additions & 0 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ pQueryCmds era envCli =
$ Opt.progDesc "Calculate the reference input scripts size in bytes for provided transaction inputs."
, pQueryGetConstitutionCmd era envCli
, pQueryGetGovStateCmd era envCli
, pQueryGetRatifyStateCmd era envCli
, pQueryDRepStateCmd era envCli
, pQueryDRepStakeDistributionCmd era envCli
, pQuerySPOStakeDistributionCmd era envCli
Expand Down Expand Up @@ -500,6 +501,18 @@ pQueryGetGovStateCmd era envCli = do
Opt.info (QueryGovStateCmd <$> pQueryNoArgCmdArgs w envCli) $
Opt.progDesc "Get the governance state"

pQueryGetRatifyStateCmd
:: ()
=> ShelleyBasedEra era
-> EnvCli
-> Maybe (Parser (QueryCmds era))
pQueryGetRatifyStateCmd era envCli = do
w <- forShelleyBasedEraMaybeEon era
pure $
subParser "ratify-state" $
Opt.info (QueryRatifyStateCmd <$> pQueryNoArgCmdArgs w envCli) $
Opt.progDesc "Get the ratification state"

-- TODO Conway: DRep State and DRep Stake Distribution parsers use DRep keys to obtain DRep credentials. This only
-- makes use of 'KeyHashObj' constructor of 'Credential kr c'. Should we also support here 'ScriptHashObj'?
-- What about 'DRep c' - this means that only 'KeyHash' constructor is in use here: should also
Expand Down
17 changes: 17 additions & 0 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ runQueryCmds = \case
Cmd.QueryRefScriptSizeCmd args -> runQueryRefScriptSizeCmd args
Cmd.QueryConstitutionCmd args -> runQueryConstitution args
Cmd.QueryGovStateCmd args -> runQueryGovState args
Cmd.QueryRatifyStateCmd args -> runQueryRatifyState args
Cmd.QueryDRepStateCmd args -> runQueryDRepState args
Cmd.QueryDRepStakeDistributionCmd args -> runQueryDRepStakeDistribution args
Cmd.QuerySPOStakeDistributionCmd args -> runQuerySPOStakeDistribution args
Expand Down Expand Up @@ -1562,6 +1563,22 @@ runQueryGovState
govState <- runQuery nodeConnInfo target $ queryGovState eon
writeOutput mOutFile govState

runQueryRatifyState
:: Cmd.QueryNoArgCmdArgs era
-> ExceptT QueryCmdError IO ()
runQueryRatifyState
Cmd.QueryNoArgCmdArgs
{ Cmd.eon
, Cmd.commons =
Cmd.QueryCommons
{ Cmd.nodeConnInfo
, Cmd.target
}
, Cmd.mOutFile
} = conwayEraOnwardsConstraints eon $ do
ratifyState <- runQuery nodeConnInfo target $ queryRatifyState eon
writeOutput mOutFile ratifyState

runQueryDRepState
:: Cmd.QueryDRepStateCmdArgs era
-> ExceptT QueryCmdError IO ()
Expand Down
30 changes: 30 additions & 0 deletions cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -7409,6 +7409,7 @@ Usage: cardano-cli conway query
| ref-script-size
| constitution
| gov-state
| ratify-state
| drep-state
| drep-stake-distribution
| spo-stake-distribution
Expand Down Expand Up @@ -7711,6 +7712,20 @@ Usage: cardano-cli conway query gov-state [--cardano-mode [--epoch-slots SLOTS]]

Get the governance state

Usage: cardano-cli conway query ratify-state
[--cardano-mode
[--epoch-slots SLOTS]]
( --mainnet
| --testnet-magic NATURAL
)
--socket-path SOCKET_PATH
[ --volatile-tip
| --immutable-tip
]
[--out-file FILEPATH]

Get the ratification state

Usage: cardano-cli conway query drep-state
[--cardano-mode
[--epoch-slots SLOTS]]
Expand Down Expand Up @@ -9464,6 +9479,7 @@ Usage: cardano-cli latest query
| ref-script-size
| constitution
| gov-state
| ratify-state
| drep-state
| drep-stake-distribution
| spo-stake-distribution
Expand Down Expand Up @@ -9766,6 +9782,20 @@ Usage: cardano-cli latest query gov-state [--cardano-mode [--epoch-slots SLOTS]]

Get the governance state

Usage: cardano-cli latest query ratify-state
[--cardano-mode
[--epoch-slots SLOTS]]
( --mainnet
| --testnet-magic NATURAL
)
--socket-path SOCKET_PATH
[ --volatile-tip
| --immutable-tip
]
[--out-file FILEPATH]

Get the ratification state

Usage: cardano-cli latest query drep-state
[--cardano-mode
[--epoch-slots SLOTS]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Usage: cardano-cli conway query
| ref-script-size
| constitution
| gov-state
| ratify-state
| drep-state
| drep-stake-distribution
| spo-stake-distribution
Expand Down Expand Up @@ -64,6 +65,7 @@ Available commands:
for provided transaction inputs.
constitution Get the constitution
gov-state Get the governance state
ratify-state Get the ratification state
drep-state Get the DRep state.
drep-stake-distribution Get the DRep stake distribution.
spo-stake-distribution Get the SPO stake distribution.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Usage: cardano-cli conway query ratify-state
[--cardano-mode
[--epoch-slots SLOTS]]
( --mainnet
| --testnet-magic NATURAL
)
--socket-path SOCKET_PATH
[ --volatile-tip
| --immutable-tip
]
[--out-file FILEPATH]

Get the ratification state

Available options:
--cardano-mode For talking to a node running in full Cardano mode
(default).
--epoch-slots SLOTS The number of slots per epoch for the Byron era.
(default: 21600)
--mainnet Use the mainnet magic id. This overrides the
CARDANO_NODE_NETWORK_ID environment variable
--testnet-magic NATURAL Specify a testnet magic id. This overrides the
CARDANO_NODE_NETWORK_ID environment variable
--socket-path SOCKET_PATH
Path to the node socket. This overrides the
CARDANO_NODE_SOCKET_PATH environment variable. The
argument is optional if CARDANO_NODE_SOCKET_PATH is
defined and mandatory otherwise.
--volatile-tip Use the volatile tip as a target. (This is the
default)
--immutable-tip Use the immutable tip as a target.
--out-file FILEPATH Optional output file. Default is to write to stdout.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Usage: cardano-cli latest query
| ref-script-size
| constitution
| gov-state
| ratify-state
| drep-state
| drep-stake-distribution
| spo-stake-distribution
Expand Down Expand Up @@ -64,6 +65,7 @@ Available commands:
for provided transaction inputs.
constitution Get the constitution
gov-state Get the governance state
ratify-state Get the ratification state
drep-state Get the DRep state.
drep-stake-distribution Get the DRep stake distribution.
spo-stake-distribution Get the SPO stake distribution.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Usage: cardano-cli latest query ratify-state
[--cardano-mode
[--epoch-slots SLOTS]]
( --mainnet
| --testnet-magic NATURAL
)
--socket-path SOCKET_PATH
[ --volatile-tip
| --immutable-tip
]
[--out-file FILEPATH]

Get the ratification state

Available options:
--cardano-mode For talking to a node running in full Cardano mode
(default).
--epoch-slots SLOTS The number of slots per epoch for the Byron era.
(default: 21600)
--mainnet Use the mainnet magic id. This overrides the
CARDANO_NODE_NETWORK_ID environment variable
--testnet-magic NATURAL Specify a testnet magic id. This overrides the
CARDANO_NODE_NETWORK_ID environment variable
--socket-path SOCKET_PATH
Path to the node socket. This overrides the
CARDANO_NODE_SOCKET_PATH environment variable. The
argument is optional if CARDANO_NODE_SOCKET_PATH is
defined and mandatory otherwise.
--volatile-tip Use the volatile tip as a target. (This is the
default)
--immutable-tip Use the immutable tip as a target.
--out-file FILEPATH Optional output file. Default is to write to stdout.
-h,--help Show this help text

0 comments on commit dc09bb9

Please sign in to comment.