From 4eba92a0af9aa8394072051fdf015233b6ccfb00 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Tue, 8 Oct 2024 15:48:40 -0400 Subject: [PATCH 1/6] Remove era type variable from AddressCmds data definition --- .../src/Cardano/CLI/EraBased/Commands.hs | 4 +- .../Cardano/CLI/EraBased/Commands/Address.hs | 4 +- .../Cardano/CLI/EraBased/Options/Address.hs | 63 +++++++++---------- .../src/Cardano/CLI/EraBased/Run/Address.hs | 2 +- 4 files changed, 35 insertions(+), 38 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs index 5dcbb1e078..074a3309c3 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs @@ -50,7 +50,7 @@ renderAnyEraCommand = \case AnyEraCommandOf _ cmd -> renderCmds cmd data Cmds era - = AddressCmds (AddressCmds era) + = AddressCmds AddressCmds | KeyCmds KeyCmds | GenesisCmds (GenesisCmds era) | GovernanceCmds (GovernanceCmds era) @@ -117,7 +117,7 @@ pCmds sbe' envCli = do let cEra = toCardanoEra sbe' asum $ catMaybes - [ fmap AddressCmds <$> pAddressCmds cEra envCli + [ Just (AddressCmds <$> pAddressCmds envCli) , Just (KeyCmds <$> pKeyCmds) , fmap GenesisCmds <$> pGenesisCmds cEra envCli , fmap GovernanceCmds <$> pGovernanceCmds cEra diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Address.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Address.hs index 66d16ee1e2..7981bfdcd4 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Address.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Address.hs @@ -16,7 +16,7 @@ import Prelude import Data.Text (Text) -data AddressCmds era +data AddressCmds = AddressKeyGen KeyOutputFormat AddressKeyType @@ -35,7 +35,7 @@ data AddressCmds era (Maybe (File () Out)) deriving Show -renderAddressCmds :: AddressCmds era -> Text +renderAddressCmds :: AddressCmds -> Text renderAddressCmds = \case AddressKeyGen{} -> "address key-gen" AddressKeyHash{} -> "address key-hash" diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Address.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Address.hs index 6d112b36e9..9fa658100f 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Address.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Address.hs @@ -8,8 +8,6 @@ module Cardano.CLI.EraBased.Options.Address ) where -import Cardano.Api - import Cardano.CLI.Environment (EnvCli (..)) import Cardano.CLI.EraBased.Commands.Address import Cardano.CLI.EraBased.Options.Common @@ -19,36 +17,35 @@ import qualified Options.Applicative as Opt pAddressCmds :: () - => CardanoEra era - -> EnvCli - -> Maybe (Parser (AddressCmds era)) -pAddressCmds _ envCli = - subInfoParser - "address" - ( Opt.progDesc $ - mconcat - [ "Payment address commands." + => EnvCli + -> Parser AddressCmds +pAddressCmds envCli = + let addressParsers = + asum + [ subParser "key-gen" $ + Opt.info pAddressKeyGen $ + Opt.progDesc "Create an address key pair." + , subParser "key-hash" $ + Opt.info pAddressKeyHash $ + Opt.progDesc "Print the hash of an address key." + , subParser "build" $ + Opt.info (pAddressBuild envCli) $ + Opt.progDesc "Build a Shelley payment address, with optional delegation to a stake address." + , subParser "info" $ + Opt.info pAddressInfo $ + Opt.progDesc "Print information about an address." ] - ) - [ Just $ - subParser "key-gen" $ - Opt.info pAddressKeyGen $ - Opt.progDesc "Create an address key pair." - , Just $ - subParser "key-hash" $ - Opt.info pAddressKeyHash $ - Opt.progDesc "Print the hash of an address key." - , Just $ - subParser "build" $ - Opt.info (pAddressBuild envCli) $ - Opt.progDesc "Build a Shelley payment address, with optional delegation to a stake address." - , Just $ - subParser "info" $ - Opt.info pAddressInfo $ - Opt.progDesc "Print information about an address." - ] + in subParser + "address" + $ Opt.info + addressParsers + ( Opt.progDesc $ + mconcat + [ "Payment address commands." + ] + ) -pAddressKeyGen :: Parser (AddressCmds era) +pAddressKeyGen :: Parser AddressCmds pAddressKeyGen = AddressKeyGen <$> pKeyOutputFormat @@ -56,13 +53,13 @@ pAddressKeyGen = <*> pVerificationKeyFileOut <*> pSigningKeyFileOut -pAddressKeyHash :: Parser (AddressCmds era) +pAddressKeyHash :: Parser AddressCmds pAddressKeyHash = AddressKeyHash <$> pPaymentVerificationKeyTextOrFile <*> pMaybeOutputFile -pAddressBuild :: EnvCli -> Parser (AddressCmds era) +pAddressBuild :: EnvCli -> Parser AddressCmds pAddressBuild envCli = AddressBuild <$> pPaymentVerifier @@ -70,7 +67,7 @@ pAddressBuild envCli = <*> pNetworkId envCli <*> pMaybeOutputFile -pAddressInfo :: Parser (AddressCmds era) +pAddressInfo :: Parser AddressCmds pAddressInfo = AddressInfo <$> pAddress diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs index 97e32bae74..f54cbc65ae 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs @@ -35,7 +35,7 @@ import qualified Data.Text.IO as Text runAddressCmds :: () - => AddressCmds era + => AddressCmds -> ExceptT AddressCmdError IO () runAddressCmds = \case AddressKeyGen fmt kt vkf skf -> From 810c42136545b385031e1d3d8ed14791b0b75ced Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Thu, 10 Oct 2024 15:29:19 -0400 Subject: [PATCH 2/6] Move and rename Cardano.CLI.EraBased.Options.Address to Cardano.CLI.Options.Address --- cardano-cli/cardano-cli.cabal | 2 +- cardano-cli/src/Cardano/CLI/EraBased/Commands.hs | 2 +- cardano-cli/src/Cardano/CLI/{EraBased => }/Options/Address.hs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename cardano-cli/src/Cardano/CLI/{EraBased => }/Options/Address.hs (97%) diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 532d5fbf12..b0e5a3b4a9 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -80,7 +80,6 @@ library Cardano.CLI.EraBased.Commands.StakePool Cardano.CLI.EraBased.Commands.TextView Cardano.CLI.EraBased.Commands.Transaction - Cardano.CLI.EraBased.Options.Address Cardano.CLI.EraBased.Options.Common Cardano.CLI.EraBased.Options.Genesis Cardano.CLI.EraBased.Options.Governance @@ -125,6 +124,7 @@ library Cardano.CLI.Legacy.Run.Governance Cardano.CLI.OS.Posix Cardano.CLI.Options + Cardano.CLI.Options.Address Cardano.CLI.Options.Debug Cardano.CLI.Options.Hash Cardano.CLI.Options.Key diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs index 074a3309c3..196a82751e 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs @@ -23,7 +23,6 @@ import Cardano.CLI.EraBased.Commands.StakeAddress import Cardano.CLI.EraBased.Commands.StakePool hiding (sbe) import Cardano.CLI.EraBased.Commands.TextView import Cardano.CLI.EraBased.Commands.Transaction -import Cardano.CLI.EraBased.Options.Address import Cardano.CLI.EraBased.Options.Common import Cardano.CLI.EraBased.Options.Genesis import Cardano.CLI.EraBased.Options.Governance @@ -32,6 +31,7 @@ import Cardano.CLI.EraBased.Options.StakeAddress import Cardano.CLI.EraBased.Options.StakePool import Cardano.CLI.EraBased.Options.TextView import Cardano.CLI.EraBased.Options.Transaction +import Cardano.CLI.Options.Address import Cardano.CLI.Options.Key import Cardano.CLI.Options.Node diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Address.hs b/cardano-cli/src/Cardano/CLI/Options/Address.hs similarity index 97% rename from cardano-cli/src/Cardano/CLI/EraBased/Options/Address.hs rename to cardano-cli/src/Cardano/CLI/Options/Address.hs index 9fa658100f..7ca04f3b9d 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Address.hs +++ b/cardano-cli/src/Cardano/CLI/Options/Address.hs @@ -3,7 +3,7 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE ScopedTypeVariables #-} -module Cardano.CLI.EraBased.Options.Address +module Cardano.CLI.Options.Address ( pAddressCmds ) where From 04d8bd3276fa3cab61c88bad4f0b707b1af63b4b Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Thu, 10 Oct 2024 15:30:40 -0400 Subject: [PATCH 3/6] Rename and move Cardano.CLI.EraBased.Commands.Address to Cardano.CLI.Commands.Address --- cardano-cli/cardano-cli.cabal | 2 +- cardano-cli/src/Cardano/CLI/{EraBased => }/Commands/Address.hs | 2 +- cardano-cli/src/Cardano/CLI/EraBased/Commands.hs | 2 +- cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs | 2 +- cardano-cli/src/Cardano/CLI/Options/Address.hs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename cardano-cli/src/Cardano/CLI/{EraBased => }/Commands/Address.hs (95%) diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index b0e5a3b4a9..9b5da1db17 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -58,6 +58,7 @@ library Cardano.CLI.Byron.UpdateProposal Cardano.CLI.Byron.Vote Cardano.CLI.Commands + Cardano.CLI.Commands.Address Cardano.CLI.Commands.Debug Cardano.CLI.Commands.Debug.LogEpochState Cardano.CLI.Commands.Debug.TransactionView @@ -67,7 +68,6 @@ library Cardano.CLI.Commands.Ping Cardano.CLI.Environment Cardano.CLI.EraBased.Commands - Cardano.CLI.EraBased.Commands.Address Cardano.CLI.EraBased.Commands.Genesis Cardano.CLI.EraBased.Commands.Governance Cardano.CLI.EraBased.Commands.Governance.Actions diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Address.hs b/cardano-cli/src/Cardano/CLI/Commands/Address.hs similarity index 95% rename from cardano-cli/src/Cardano/CLI/EraBased/Commands/Address.hs rename to cardano-cli/src/Cardano/CLI/Commands/Address.hs index 7981bfdcd4..76b4c0ccb3 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Address.hs +++ b/cardano-cli/src/Cardano/CLI/Commands/Address.hs @@ -1,7 +1,7 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE LambdaCase #-} -module Cardano.CLI.EraBased.Commands.Address +module Cardano.CLI.Commands.Address ( AddressCmds (..) , renderAddressCmds ) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs index 196a82751e..6c6fae6f24 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs @@ -13,10 +13,10 @@ where import Cardano.Api (ShelleyBasedEra (..), toCardanoEra) +import Cardano.CLI.Commands.Address import Cardano.CLI.Commands.Key import Cardano.CLI.Commands.Node import Cardano.CLI.Environment -import Cardano.CLI.EraBased.Commands.Address import Cardano.CLI.EraBased.Commands.Genesis import Cardano.CLI.EraBased.Commands.Query import Cardano.CLI.EraBased.Commands.StakeAddress diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs index f54cbc65ae..989d215920 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs @@ -18,7 +18,7 @@ where import Cardano.Api import Cardano.Api.Shelley -import Cardano.CLI.EraBased.Commands.Address +import Cardano.CLI.Commands.Address import Cardano.CLI.EraBased.Run.Address.Info import Cardano.CLI.Read import qualified Cardano.CLI.Run.Key as Key diff --git a/cardano-cli/src/Cardano/CLI/Options/Address.hs b/cardano-cli/src/Cardano/CLI/Options/Address.hs index 7ca04f3b9d..e910f30028 100644 --- a/cardano-cli/src/Cardano/CLI/Options/Address.hs +++ b/cardano-cli/src/Cardano/CLI/Options/Address.hs @@ -8,8 +8,8 @@ module Cardano.CLI.Options.Address ) where +import Cardano.CLI.Commands.Address import Cardano.CLI.Environment (EnvCli (..)) -import Cardano.CLI.EraBased.Commands.Address import Cardano.CLI.EraBased.Options.Common import Options.Applicative hiding (help, str) From 1bdaddda27dd072f485b5182b2330cb9207e701d Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Thu, 10 Oct 2024 15:54:21 -0400 Subject: [PATCH 4/6] Rename and move Cardano.CLI.EraBased.Run.Address and Cardano.CLI.EraBased.Run.Address.Info to Cardano.CLI.Run.Address and Cardano.CLI.Run.Address.Info --- cardano-cli/cardano-cli.cabal | 4 ++-- cardano-cli/src/Cardano/CLI/EraBased/Run.hs | 2 +- .../src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs | 2 +- cardano-cli/src/Cardano/CLI/{EraBased => }/Run/Address.hs | 4 ++-- .../src/Cardano/CLI/{EraBased => }/Run/Address/Info.hs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) rename cardano-cli/src/Cardano/CLI/{EraBased => }/Run/Address.hs (98%) rename cardano-cli/src/Cardano/CLI/{EraBased => }/Run/Address/Info.hs (97%) diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 9b5da1db17..68ce748551 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -94,8 +94,6 @@ library Cardano.CLI.EraBased.Options.TextView Cardano.CLI.EraBased.Options.Transaction Cardano.CLI.EraBased.Run - Cardano.CLI.EraBased.Run.Address - Cardano.CLI.EraBased.Run.Address.Info Cardano.CLI.EraBased.Run.Genesis Cardano.CLI.EraBased.Run.Genesis.Common Cardano.CLI.EraBased.Run.Genesis.CreateTestnetData @@ -136,6 +134,8 @@ library Cardano.CLI.Read Cardano.CLI.Render Cardano.CLI.Run + Cardano.CLI.Run.Address + Cardano.CLI.Run.Address.Info Cardano.CLI.Run.Debug Cardano.CLI.Run.Debug.LogEpochState Cardano.CLI.Run.Debug.TransactionView diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run.hs index ad7e9f4970..57b97c488c 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run.hs @@ -11,7 +11,6 @@ where import Cardano.Api import Cardano.CLI.EraBased.Commands -import Cardano.CLI.EraBased.Run.Address import Cardano.CLI.EraBased.Run.Genesis import Cardano.CLI.EraBased.Run.Governance import Cardano.CLI.EraBased.Run.Query @@ -20,6 +19,7 @@ import Cardano.CLI.EraBased.Run.StakePool import Cardano.CLI.EraBased.Run.TextView import Cardano.CLI.EraBased.Run.Transaction import Cardano.CLI.Helpers (printEraDeprecationWarning) +import Cardano.CLI.Run.Address import Cardano.CLI.Run.Key import Cardano.CLI.Run.Node import Cardano.CLI.Types.Errors.CmdError diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs index 46c6cffd36..1bf2d1038a 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs @@ -36,11 +36,11 @@ import Cardano.Api.Shelley import qualified Cardano.CLI.Commands.Node as Cmd import Cardano.CLI.EraBased.Commands.Genesis as Cmd import qualified Cardano.CLI.EraBased.Commands.Governance.DRep as DRep -import Cardano.CLI.EraBased.Run.Address (generateAndWriteKeyFiles) import Cardano.CLI.EraBased.Run.Genesis.Common import qualified Cardano.CLI.EraBased.Run.Governance.DRep as DRep import Cardano.CLI.EraBased.Run.StakeAddress (runStakeAddressKeyGenCmd) import qualified Cardano.CLI.IO.Lazy as Lazy +import Cardano.CLI.Run.Address (generateAndWriteKeyFiles) import qualified Cardano.CLI.Run.Key as Key import Cardano.CLI.Run.Node (runNodeIssueOpCertCmd, runNodeKeyGenColdCmd, runNodeKeyGenKesCmd, runNodeKeyGenVrfCmd) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs b/cardano-cli/src/Cardano/CLI/Run/Address.hs similarity index 98% rename from cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs rename to cardano-cli/src/Cardano/CLI/Run/Address.hs index 989d215920..5cd1fcf537 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs +++ b/cardano-cli/src/Cardano/CLI/Run/Address.hs @@ -5,7 +5,7 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} -module Cardano.CLI.EraBased.Run.Address +module Cardano.CLI.Run.Address ( runAddressCmds , runAddressBuildCmd , runAddressKeyGenCmd @@ -19,7 +19,7 @@ import Cardano.Api import Cardano.Api.Shelley import Cardano.CLI.Commands.Address -import Cardano.CLI.EraBased.Run.Address.Info +import Cardano.CLI.Run.Address.Info import Cardano.CLI.Read import qualified Cardano.CLI.Run.Key as Key import Cardano.CLI.Types.Common diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Address/Info.hs b/cardano-cli/src/Cardano/CLI/Run/Address/Info.hs similarity index 97% rename from cardano-cli/src/Cardano/CLI/EraBased/Run/Address/Info.hs rename to cardano-cli/src/Cardano/CLI/Run/Address/Info.hs index ba3623c02b..de097478d3 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Address/Info.hs +++ b/cardano-cli/src/Cardano/CLI/Run/Address/Info.hs @@ -1,7 +1,7 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} -module Cardano.CLI.EraBased.Run.Address.Info +module Cardano.CLI.Run.Address.Info ( runAddressInfoCmd ) where From 30c923307e4dc850a641ebc08a6bd5848e5964ec Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Thu, 10 Oct 2024 16:04:44 -0400 Subject: [PATCH 5/6] Expose address commands at cli top level --- cardano-cli/src/Cardano/CLI/Commands.hs | 2 ++ cardano-cli/src/Cardano/CLI/Options.hs | 7 ++++++- cardano-cli/src/Cardano/CLI/Options/Address.hs | 1 + cardano-cli/src/Cardano/CLI/Run.hs | 7 +++++++ cardano-cli/src/Cardano/CLI/Run/Address.hs | 2 +- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/Commands.hs b/cardano-cli/src/Cardano/CLI/Commands.hs index eda4ed836c..e49e627e50 100644 --- a/cardano-cli/src/Cardano/CLI/Commands.hs +++ b/cardano-cli/src/Cardano/CLI/Commands.hs @@ -6,6 +6,7 @@ module Cardano.CLI.Commands where import Cardano.CLI.Byron.Commands (ByronCommand) +import Cardano.CLI.Commands.Address import Cardano.CLI.Commands.Debug import Cardano.CLI.Commands.Hash (HashCmds) import Cardano.CLI.Commands.Key @@ -19,6 +20,7 @@ import Options.Applicative.Types (ParserInfo (..), ParserPrefs (..)) -- | Sub-commands of 'cardano-cli'. data ClientCommand = AnyEraCommand AnyEraCommand + | AddressCommand AddressCmds | -- | Byron Related Commands ByronCommand ByronCommand | -- | Era agnostic hashing commands diff --git a/cardano-cli/src/Cardano/CLI/Options.hs b/cardano-cli/src/Cardano/CLI/Options.hs index 6b8a7f43c4..1b0d3a66b8 100644 --- a/cardano-cli/src/Cardano/CLI/Options.hs +++ b/cardano-cli/src/Cardano/CLI/Options.hs @@ -14,6 +14,7 @@ import Cardano.CLI.Environment (EnvCli) import Cardano.CLI.EraBased.Commands import Cardano.CLI.EraBased.Options.Common import Cardano.CLI.Legacy.Options (parseLegacyCmds) +import Cardano.CLI.Options.Address import Cardano.CLI.Options.Debug import Cardano.CLI.Options.Hash import Cardano.CLI.Options.Key @@ -49,6 +50,9 @@ pref = , helpRenderHelp customRenderHelp ] +addressCmdsTopLevel :: EnvCli -> Parser ClientCommand +addressCmdsTopLevel envCli = AddressCommand <$> pAddressCmds envCli + -- The node related commands are shelley era agnostic for the time being. -- There is no need to guard them by the era argument. nodeCmdsTopLevel :: Parser ClientCommand @@ -63,7 +67,8 @@ parseClientCommand envCli = -- There are name clashes between Shelley commands and the Byron backwards -- compat commands (e.g. "genesis"), and we need to prefer the Shelley ones -- so we list it first. - [ keyCmdsTopLevel + [ addressCmdsTopLevel envCli + , keyCmdsTopLevel , nodeCmdsTopLevel , parseLegacy envCli , parseByron envCli diff --git a/cardano-cli/src/Cardano/CLI/Options/Address.hs b/cardano-cli/src/Cardano/CLI/Options/Address.hs index e910f30028..4ad3cb3aa6 100644 --- a/cardano-cli/src/Cardano/CLI/Options/Address.hs +++ b/cardano-cli/src/Cardano/CLI/Options/Address.hs @@ -12,6 +12,7 @@ import Cardano.CLI.Commands.Address import Cardano.CLI.Environment (EnvCli (..)) import Cardano.CLI.EraBased.Options.Common +import Data.Foldable import Options.Applicative hiding (help, str) import qualified Options.Applicative as Opt diff --git a/cardano-cli/src/Cardano/CLI/Run.hs b/cardano-cli/src/Cardano/CLI/Run.hs index 1e9dd469e6..8eff7479e5 100644 --- a/cardano-cli/src/Cardano/CLI/Run.hs +++ b/cardano-cli/src/Cardano/CLI/Run.hs @@ -21,12 +21,14 @@ import Cardano.CLI.EraBased.Run import Cardano.CLI.Legacy.Commands import Cardano.CLI.Legacy.Run (runLegacyCmds) import Cardano.CLI.Render (customRenderHelp) +import Cardano.CLI.Run.Address import Cardano.CLI.Run.Debug import Cardano.CLI.Run.Hash (runHashCmds) import Cardano.CLI.Run.Key import Cardano.CLI.Run.Node import Cardano.CLI.Run.Ping (PingClientCmdError (..), renderPingClientCmdError, runPingCmd) +import Cardano.CLI.Types.Errors.AddressCmdError import Cardano.CLI.Types.Errors.CmdError import Cardano.CLI.Types.Errors.HashCmdError import Cardano.CLI.Types.Errors.KeyCmdError @@ -50,6 +52,7 @@ import Paths_cardano_cli (version) data ClientCommandErrors = ByronClientError ByronClientCmdError + | AddressCmdError AddressCmdError | CmdError Text CmdError | HashCmdError HashCmdError | KeyCmdError KeyCmdError @@ -61,6 +64,8 @@ runClientCommand :: ClientCommand -> ExceptT ClientCommandErrors IO () runClientCommand = \case AnyEraCommand cmds -> firstExceptT (CmdError (renderAnyEraCommand cmds)) $ runAnyEraCommand cmds + AddressCommand cmds -> + firstExceptT AddressCmdError $ runAddressCmds cmds NodeCommands cmds -> runNodeCmds cmds & firstExceptT NodeCmdError @@ -87,6 +92,8 @@ renderClientCommandError = \case renderCmdError cmdText err ByronClientError err -> renderByronClientCmdError err + AddressCmdError err -> + renderAddressCmdError err HashCmdError err -> prettyError err NodeCmdError err -> diff --git a/cardano-cli/src/Cardano/CLI/Run/Address.hs b/cardano-cli/src/Cardano/CLI/Run/Address.hs index 5cd1fcf537..b4987074ed 100644 --- a/cardano-cli/src/Cardano/CLI/Run/Address.hs +++ b/cardano-cli/src/Cardano/CLI/Run/Address.hs @@ -19,8 +19,8 @@ import Cardano.Api import Cardano.Api.Shelley import Cardano.CLI.Commands.Address -import Cardano.CLI.Run.Address.Info import Cardano.CLI.Read +import Cardano.CLI.Run.Address.Info import qualified Cardano.CLI.Run.Key as Key import Cardano.CLI.Types.Common import Cardano.CLI.Types.Errors.AddressCmdError From 1464112093bd3af22d87b70c8649f536f962ac49 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Thu, 10 Oct 2024 16:06:03 -0400 Subject: [PATCH 6/6] Update golden files --- .../cardano-cli-golden/files/golden/help.cli | 45 ++++++++++++++++++- .../files/golden/help/address.cli | 13 ++++++ .../files/golden/help/address_build.cli | 37 +++++++++++++++ .../files/golden/help/address_info.cli | 8 ++++ .../files/golden/help/address_key-gen.cli | 23 ++++++++++ .../files/golden/help/address_key-hash.cli | 15 +++++++ 6 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/help/address.cli create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/help/address_build.cli create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/help/address_info.cli create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/help/address_key-gen.cli create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/help/address_key-hash.cli diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli index 92a25f98bc..47995ac98d 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -1,5 +1,6 @@ Usage: cardano-cli - ( key + ( address + | key | node | legacy | byron @@ -16,6 +17,48 @@ Usage: cardano-cli | version ) +Usage: cardano-cli address (key-gen | key-hash | build | info) + + Payment address commands. + +Usage: cardano-cli address key-gen [--key-output-format STRING] + [ --normal-key + | --extended-key + | --byron-key + ] + --verification-key-file FILEPATH + --signing-key-file FILEPATH + + Create an address key pair. + +Usage: cardano-cli address key-hash + ( --payment-verification-key STRING + | --payment-verification-key-file FILEPATH + ) + [--out-file FILEPATH] + + Print the hash of an address key. + +Usage: cardano-cli address build + ( --payment-verification-key STRING + | --payment-verification-key-file FILEPATH + | --payment-script-file FILEPATH + ) + [ --stake-verification-key STRING + | --stake-verification-key-file FILEPATH + | --stake-key-hash HASH + | --stake-script-file FILEPATH + | --stake-address ADDRESS + ] + (--mainnet | --testnet-magic NATURAL) + [--out-file FILEPATH] + + Build a Shelley payment address, with optional delegation to a stake address. + +Usage: cardano-cli address info --address ADDRESS [--out-file FILEPATH] + + Print information about an address. + Usage: cardano-cli key ( verification-key | non-extended-key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/address.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/address.cli new file mode 100644 index 0000000000..42a4854636 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/address.cli @@ -0,0 +1,13 @@ +Usage: cardano-cli address (key-gen | key-hash | build | info) + + Payment address commands. + +Available options: + -h,--help Show this help text + +Available commands: + key-gen Create an address key pair. + key-hash Print the hash of an address key. + build Build a Shelley payment address, with optional + delegation to a stake address. + info Print information about an address. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/address_build.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/address_build.cli new file mode 100644 index 0000000000..82f6a7f340 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/address_build.cli @@ -0,0 +1,37 @@ +Usage: cardano-cli address build + ( --payment-verification-key STRING + | --payment-verification-key-file FILEPATH + | --payment-script-file FILEPATH + ) + [ --stake-verification-key STRING + | --stake-verification-key-file FILEPATH + | --stake-key-hash HASH + | --stake-script-file FILEPATH + | --stake-address ADDRESS + ] + (--mainnet | --testnet-magic NATURAL) + [--out-file FILEPATH] + + Build a Shelley payment address, with optional delegation to a stake address. + +Available options: + --payment-verification-key STRING + Payment verification key (Bech32-encoded) + --payment-verification-key-file FILEPATH + Filepath of the payment verification key. + --payment-script-file FILEPATH + Filepath of the payment script. + --stake-verification-key STRING + Stake verification key (Bech32 or hex-encoded). + --stake-verification-key-file FILEPATH + Filepath of the staking verification key. + --stake-key-hash HASH Stake verification key hash (hex-encoded). + --stake-script-file FILEPATH + Filepath of the staking script. + --stake-address ADDRESS Target stake address (bech32 format). + --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 + --out-file FILEPATH Optional output file. Default is to write to stdout. + -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/address_info.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/address_info.cli new file mode 100644 index 0000000000..3367ff824d --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/address_info.cli @@ -0,0 +1,8 @@ +Usage: cardano-cli address info --address ADDRESS [--out-file FILEPATH] + + Print information about an address. + +Available options: + --address ADDRESS A Cardano address + --out-file FILEPATH Optional output file. Default is to write to stdout. + -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/address_key-gen.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/address_key-gen.cli new file mode 100644 index 0000000000..b29878f8b7 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/address_key-gen.cli @@ -0,0 +1,23 @@ +Usage: cardano-cli address key-gen [--key-output-format STRING] + [ --normal-key + | --extended-key + | --byron-key + ] + --verification-key-file FILEPATH + --signing-key-file FILEPATH + + Create an address key pair. + +Available options: + --key-output-format STRING + Optional key output format. Accepted output formats + are "text-envelope" and "bech32" (default is + "text-envelope"). + --normal-key Use a normal Shelley-era key (default). + --extended-key Use an extended ed25519 Shelley-era key. + --byron-key Use a Byron-era key. + --verification-key-file FILEPATH + Output filepath of the verification key. + --signing-key-file FILEPATH + Output filepath of the signing key. + -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/address_key-hash.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/address_key-hash.cli new file mode 100644 index 0000000000..c5de318e95 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/address_key-hash.cli @@ -0,0 +1,15 @@ +Usage: cardano-cli address key-hash + ( --payment-verification-key STRING + | --payment-verification-key-file FILEPATH + ) + [--out-file FILEPATH] + + Print the hash of an address key. + +Available options: + --payment-verification-key STRING + Payment verification key (Bech32-encoded) + --payment-verification-key-file FILEPATH + Filepath of the payment verification key. + --out-file FILEPATH Optional output file. Default is to write to stdout. + -h,--help Show this help text