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

Move "conway governance hash" commands to "hash" #787

Merged
merged 5 commits into from
Jul 2, 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
11 changes: 6 additions & 5 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ library
Cardano.CLI.Byron.UpdateProposal
Cardano.CLI.Byron.Vote
Cardano.CLI.Commands
Cardano.CLI.Commands.Hash
Cardano.CLI.Commands.Ping
Cardano.CLI.Commands.Debug
Cardano.CLI.Commands.Debug.LogEpochState
Expand All @@ -67,7 +68,6 @@ library
Cardano.CLI.EraBased.Commands.Governance.Actions
Cardano.CLI.EraBased.Commands.Governance.Committee
Cardano.CLI.EraBased.Commands.Governance.DRep
Cardano.CLI.EraBased.Commands.Governance.Hash
Cardano.CLI.EraBased.Commands.Governance.Poll
Cardano.CLI.EraBased.Commands.Governance.Vote
Cardano.CLI.EraBased.Commands.Key
Expand All @@ -84,7 +84,6 @@ library
Cardano.CLI.EraBased.Options.Governance.Actions
Cardano.CLI.EraBased.Options.Governance.Committee
Cardano.CLI.EraBased.Options.Governance.DRep
Cardano.CLI.EraBased.Options.Governance.Hash
Cardano.CLI.EraBased.Options.Governance.Poll
Cardano.CLI.EraBased.Options.Governance.Vote
Cardano.CLI.EraBased.Options.Key
Expand All @@ -103,7 +102,6 @@ library
Cardano.CLI.EraBased.Run.Governance.Actions
Cardano.CLI.EraBased.Run.Governance.Committee
Cardano.CLI.EraBased.Run.Governance.DRep
Cardano.CLI.EraBased.Run.Governance.Hash
Cardano.CLI.EraBased.Run.Governance.GenesisKeyDelegationCertificate
Cardano.CLI.EraBased.Run.Governance.Poll
Cardano.CLI.EraBased.Run.Governance.Vote
Expand Down Expand Up @@ -143,6 +141,7 @@ library
Cardano.CLI.Legacy.Run.Transaction
Cardano.CLI.Options
Cardano.CLI.Options.Debug
Cardano.CLI.Options.Hash
Cardano.CLI.Options.Ping
Cardano.CLI.Orphans
Cardano.CLI.OS.Posix
Expand All @@ -153,6 +152,7 @@ library
Cardano.CLI.Run
Cardano.CLI.Run.Debug
Cardano.CLI.Run.Debug.LogEpochState
Cardano.CLI.Run.Hash
Cardano.CLI.Run.Ping
Cardano.CLI.TopHandler
Cardano.CLI.Types.Common
Expand All @@ -167,9 +167,9 @@ library
Cardano.CLI.Types.Errors.GovernanceActionsError
Cardano.CLI.Types.Errors.GovernanceCmdError
Cardano.CLI.Types.Errors.GovernanceCommitteeError
Cardano.CLI.Types.Errors.GovernanceHashError
Cardano.CLI.Types.Errors.GovernanceQueryError
Cardano.CLI.Types.Errors.GovernanceVoteCmdError
Cardano.CLI.Types.Errors.HashCmdError
Cardano.CLI.Types.Errors.ItnKeyConversionError
Cardano.CLI.Types.Errors.KeyCmdError
Cardano.CLI.Types.Errors.NodeCmdError
Expand Down Expand Up @@ -334,6 +334,7 @@ test-suite cardano-cli-test
Test.Cli.Pioneers.Exercise6
Test.Cli.Pipes
Test.Cli.VerificationKey
Test.Cli.Shelley.Run.Hash
Test.Cli.Shelley.Run.Query
Test.Cli.Shelley.Transaction.Build

Expand Down Expand Up @@ -394,9 +395,9 @@ test-suite cardano-cli-golden
Test.Golden.Governance.Action
Test.Golden.Governance.Committee
Test.Golden.Governance.DRep
Test.Golden.Governance.Hash
Test.Golden.Governance.StakeAddress
Test.Golden.Governance.Vote
Test.Golden.Hash.Hash
Test.Golden.Help
Test.Golden.Key.NonExtendedKey
Test.Golden.Shelley.Address.Build
Expand Down
4 changes: 4 additions & 0 deletions cardano-cli/src/Cardano/CLI/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Cardano.CLI.Commands

import Cardano.CLI.Byron.Commands (ByronCommand)
import Cardano.CLI.Commands.Debug
import Cardano.CLI.Commands.Hash (HashCmds)
import Cardano.CLI.Commands.Ping (PingCmd (..))
import Cardano.CLI.EraBased.Commands
import Cardano.CLI.Legacy.Commands
Expand All @@ -19,6 +20,9 @@ data ClientCommand =
-- | Byron Related Commands
| ByronCommand ByronCommand

-- | Era-agnostic hashing commands
| HashCmds HashCmds

-- | Legacy shelley-based Commands
| LegacyCmds LegacyCmds

Expand Down
44 changes: 44 additions & 0 deletions cardano-cli/src/Cardano/CLI/Commands/Hash.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE LambdaCase #-}

module Cardano.CLI.Commands.Hash
( HashCmds (..)
, HashAnchorDataCmdArgs (..)
, HashScriptCmdArgs (..)
, AnchorDataHashSource (..)
, renderHashCmds
) where

import Cardano.Api

import Cardano.CLI.Types.Common

import Data.Text (Text)

data HashCmds
= HashAnchorDataCmd !HashAnchorDataCmdArgs
| HashScriptCmd !HashScriptCmdArgs

data HashAnchorDataCmdArgs
= HashAnchorDataCmdArgs {
toHash :: !AnchorDataHashSource
, mOutFile :: !(Maybe (File () Out)) -- ^ The output file to which the hash is written
} deriving Show

data AnchorDataHashSource
= AnchorDataHashSourceBinaryFile (File ProposalBinary In)
| AnchorDataHashSourceTextFile (File ProposalText In)
| AnchorDataHashSourceText Text
deriving Show

data HashScriptCmdArgs
= HashScriptCmdArgs {
toHash :: !ScriptFile
, mOutFile :: !(Maybe (File () Out)) -- ^ The output file to which the hash is written
} deriving Show

renderHashCmds :: HashCmds -> Text
renderHashCmds = \case
HashAnchorDataCmd {} -> "hash anchor-data"
HashScriptCmd {} -> "hash script"
5 changes: 0 additions & 5 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Cardano.Api.Shelley (VrfKey)
import Cardano.CLI.EraBased.Commands.Governance.Actions
import Cardano.CLI.EraBased.Commands.Governance.Committee
import Cardano.CLI.EraBased.Commands.Governance.DRep
import Cardano.CLI.EraBased.Commands.Governance.Hash
import Cardano.CLI.EraBased.Commands.Governance.Poll
import Cardano.CLI.EraBased.Commands.Governance.Vote
import Cardano.CLI.Types.Key (VerificationKeyOrHashOrFile)
Expand Down Expand Up @@ -48,8 +47,6 @@ data GovernanceCmds era
(GovernanceCommitteeCmds era)
| GovernanceDRepCmds
(GovernanceDRepCmds era)
| GovernanceHashCmds
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I would break this immediately. Better to deprecate it first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to go through a deprecation period, as per @CarlosLopezDeLara's comment below 👇

(GovernanceHashCmds era)
| GovernancePollCmds
(GovernancePollCmds era)
| GovernanceVoteCmds
Expand All @@ -71,8 +68,6 @@ renderGovernanceCmds = \case
renderGovernanceCommitteeCmds cmds
GovernanceDRepCmds cmds ->
renderGovernanceDRepCmds cmds
GovernanceHashCmds cmds ->
renderGovernanceHashCmds cmds
GovernancePollCmds cmds ->
renderGovernancePollCmds cmds
GovernanceVoteCmds cmds ->
Expand Down
47 changes: 0 additions & 47 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Hash.hs

This file was deleted.

12 changes: 6 additions & 6 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ pAddCommitteeColdVerificationKeySource =
, VkhfshScriptHash <$>
pScriptHash
"add-cc-cold-script-hash"
"Cold Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli conway governance hash script ...\"."
"Cold Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli hash script ...\"."
]

pAddCommitteeColdVerificationKeyHash :: Parser (Hash CommitteeColdKey)
Expand Down Expand Up @@ -698,7 +698,7 @@ pRemoveCommitteeColdVerificationKeySource =
, VkhfshScriptHash <$>
pScriptHash
"remove-cc-cold-script-hash"
"Cold Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli conway governance hash script ...\"."
"Cold Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli hash script ...\"."
]

pScriptHash
Expand Down Expand Up @@ -920,7 +920,7 @@ pCommitteeHotVerificationKeyOrHashOrVerificationFileOrScriptHash =
, VkhfshScriptHash <$>
pScriptHash
"cc-hot-script-hash"
"Cold Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli conway governance hash script ...\"."
"Cold Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli hash script ...\"."
]

catCommands :: [Parser a] -> Maybe (Parser a)
Expand Down Expand Up @@ -3233,13 +3233,13 @@ pDRepScriptHash :: Parser ScriptHash
pDRepScriptHash =
pScriptHash
"drep-script-hash"
"DRep script hash (hex-encoded). Obtain it with \"cardano-cli conway governance hash script ...\"."
"DRep script hash (hex-encoded). Obtain it with \"cardano-cli hash script ...\"."

pConstitutionScriptHash :: Parser ScriptHash
pConstitutionScriptHash =
pScriptHash
"constitution-script-hash"
"Constitution script hash (hex-encoded). Obtain it with \"cardano-cli conway governance hash script ...\"."
"Constitution script hash (hex-encoded). Obtain it with \"cardano-cli hash script ...\"."

pDRepVerificationKeyOrHashOrFile
:: Parser (VerificationKeyOrHashOrFile DRepKey)
Expand All @@ -3257,7 +3257,7 @@ pDRepVerificationKeyOrHashOrFileOrScriptHash =
, VkhfshScriptHash <$>
pScriptHash
"drep-script-hash"
"Cold Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli conway governance hash script ...\"."
"Cold Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli hash script ...\"."
]

pAllOrOnlyDRepHashSource
Expand Down
2 changes: 0 additions & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Cardano.CLI.EraBased.Options.Common
import Cardano.CLI.EraBased.Options.Governance.Actions
import Cardano.CLI.EraBased.Options.Governance.Committee
import Cardano.CLI.EraBased.Options.Governance.DRep
import Cardano.CLI.EraBased.Options.Governance.Hash
import Cardano.CLI.EraBased.Options.Governance.Poll
import Cardano.CLI.EraBased.Options.Governance.Vote

Expand All @@ -37,7 +36,6 @@ pGovernanceCmds era =
, fmap GovernanceActionCmds <$> pGovernanceActionCmds era
, fmap GovernanceCommitteeCmds <$> pGovernanceCommitteeCmds era
, fmap GovernanceDRepCmds <$> pGovernanceDRepCmds era
, fmap GovernanceHashCmds <$> pGovernanceHashCmds era
, fmap GovernancePollCmds <$> pGovernancePollCmds era
, fmap GovernanceVoteCmds <$> pGovernanceVoteCmds era
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pColdCredential =
, VksScriptHash <$>
pScriptHash
"cold-script-hash"
"Committee cold Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli conway governance hash script ...\"."
"Committee cold Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli hash script ...\"."
, VksScript <$> pScriptFor "cold-script-file" Nothing "Cold Native or Plutus script file"
]

Expand Down
76 changes: 0 additions & 76 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Hash.hs

This file was deleted.

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 @@ -428,7 +428,7 @@ pQueryGetCommitteeStateCmd era envCli = do
, VkhfshScriptHash <$>
pScriptHash
"cold-script-hash"
"Cold Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli conway governance hash script ...\"."
"Cold Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli hash script ...\"."
]

pCommitteeHotKeyOrHashOrFileOrScriptHash :: Parser (VerificationKeyOrHashOrFileOrScriptHash CommitteeHotKey)
Expand All @@ -438,7 +438,7 @@ pQueryGetCommitteeStateCmd era envCli = do
, VkhfshScriptHash <$>
pScriptHash
"hot-script-hash"
"Hot Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli conway governance hash script ...\"."
"Hot Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli hash script ...\"."
]

pMemberStatus :: Parser MemberStatus
Expand Down
Loading
Loading