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

Add older eras deprecation notice. #879

Merged
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
15 changes: 8 additions & 7 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ import Cardano.CLI.EraBased.Options.Transaction
import Data.Foldable
import Data.Maybe
import Data.Text (Text)
import Data.Typeable (Typeable)
import Options.Applicative (Parser)
import qualified Options.Applicative as Opt

data AnyEraCommand where
AnyEraCommandOf :: ShelleyBasedEra era -> Cmds era -> AnyEraCommand
AnyEraCommandOf :: Typeable era => ShelleyBasedEra era -> Cmds era -> AnyEraCommand

renderAnyEraCommand :: AnyEraCommand -> Text
renderAnyEraCommand = \case
Expand Down Expand Up @@ -90,25 +91,25 @@ pAnyEraCommand envCli =

subParser "shelley" $
Opt.info (AnyEraCommandOf ShelleyBasedEraShelley <$> pCmds ShelleyBasedEraShelley envCli) $
Opt.progDesc "Shelley era commands"
Opt.progDesc ("Shelley era commands" <> deprecationText)
, subParser "allegra" $
Opt.info (AnyEraCommandOf ShelleyBasedEraAllegra <$> pCmds ShelleyBasedEraAllegra envCli) $
Opt.progDesc "Allegra era commands"
Opt.progDesc ("Allegra era commands" <> deprecationText)
, subParser "mary" $
Opt.info (AnyEraCommandOf ShelleyBasedEraMary <$> pCmds ShelleyBasedEraMary envCli) $
Opt.progDesc "Mary era commands"
Opt.progDesc ("Mary era commands" <> deprecationText)
, subParser "alonzo" $
Opt.info (AnyEraCommandOf ShelleyBasedEraAlonzo <$> pCmds ShelleyBasedEraAlonzo envCli) $
Opt.progDesc "Alonzo era commands"
Opt.progDesc ("Alonzo era commands" <> deprecationText)
, subParser "babbage" $
Opt.info (AnyEraCommandOf ShelleyBasedEraBabbage <$> pCmds ShelleyBasedEraBabbage envCli) $
Opt.progDesc "Babbage era commands"
Opt.progDesc ("Babbage era commands" <> deprecationText)
, subParser "conway" $
Opt.info (AnyEraCommandOf ShelleyBasedEraConway <$> pCmds ShelleyBasedEraConway envCli) $
Opt.progDesc "Conway era commands"
, subParser "latest" $
Opt.info (AnyEraCommandOf ShelleyBasedEraBabbage <$> pCmds ShelleyBasedEraBabbage envCli) $
Opt.progDesc "Latest era commands (Babbage)"
Opt.progDesc ("Latest era commands (Babbage)" <> deprecationText)
]

pCmds :: ShelleyBasedEra era -> EnvCli -> Parser (Cmds era)
Expand Down
43 changes: 20 additions & 23 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ import qualified Text.Parsec.String as Parsec
import qualified Text.Parsec.Token as Parsec
import Text.Read (readEither, readMaybe)

defaultShelleyBasedEra :: EraInEon ShelleyBasedEra
defaultShelleyBasedEra = EraInEon ShelleyBasedEraBabbage

defaultShelleyToBabbageEra :: EraInEon ShelleyToBabbageEra
defaultShelleyToBabbageEra = EraInEon ShelleyToBabbageEraBabbage

command' :: String -> String -> Parser a -> Mod CommandFields a
command' c descr p =
mconcat
Expand Down Expand Up @@ -373,40 +367,43 @@ pAnyShelleyBasedEra envCli =
mconcat
[
[ Opt.flag' (EraInEon ShelleyBasedEraShelley) $
mconcat [Opt.long "shelley-era", Opt.help "Specify the Shelley era"]
mconcat [Opt.long "shelley-era", Opt.help $ "Specify the Shelley era" <> deprecationText]
, Opt.flag' (EraInEon ShelleyBasedEraAllegra) $
mconcat [Opt.long "allegra-era", Opt.help "Specify the Allegra era"]
mconcat [Opt.long "allegra-era", Opt.help $ "Specify the Allegra era" <> deprecationText]
, Opt.flag' (EraInEon ShelleyBasedEraMary) $
mconcat [Opt.long "mary-era", Opt.help "Specify the Mary era"]
mconcat [Opt.long "mary-era", Opt.help $ "Specify the Mary era" <> deprecationText]
, Opt.flag' (EraInEon ShelleyBasedEraAlonzo) $
mconcat [Opt.long "alonzo-era", Opt.help "Specify the Alonzo era"]
mconcat [Opt.long "alonzo-era", Opt.help $ "Specify the Alonzo era" <> deprecationText]
, Opt.flag' (EraInEon ShelleyBasedEraBabbage) $
mconcat [Opt.long "babbage-era", Opt.help "Specify the Babbage era (default)"]
mconcat [Opt.long "babbage-era", Opt.help $ "Specify the Babbage era (default)" <> deprecationText]
, Opt.flag' (EraInEon ShelleyBasedEraConway) $
mconcat [Opt.long "conway-era", Opt.help "Specify the Conway era"]
]
, maybeToList $ pure <$> envCliAnyShelleyBasedEra envCli
, pure $ pure defaultShelleyBasedEra
, pure . pure $ EraInEon ShelleyBasedEraBabbage
]

deprecationText :: String
deprecationText = " - DEPRECATED - will be removed in the future"

pAnyShelleyToBabbageEra :: EnvCli -> Parser (EraInEon ShelleyToBabbageEra)
pAnyShelleyToBabbageEra envCli =
asum $
mconcat
[
[ Opt.flag' (EraInEon ShelleyToBabbageEraShelley) $
mconcat [Opt.long "shelley-era", Opt.help "Specify the Shelley era"]
mconcat [Opt.long "shelley-era", Opt.help $ "Specify the Shelley era" <> deprecationText]
, Opt.flag' (EraInEon ShelleyToBabbageEraAllegra) $
mconcat [Opt.long "allegra-era", Opt.help "Specify the Allegra era"]
mconcat [Opt.long "allegra-era", Opt.help $ "Specify the Allegra era" <> deprecationText]
, Opt.flag' (EraInEon ShelleyToBabbageEraMary) $
mconcat [Opt.long "mary-era", Opt.help "Specify the Mary era"]
mconcat [Opt.long "mary-era", Opt.help $ "Specify the Mary era" <> deprecationText]
, Opt.flag' (EraInEon ShelleyToBabbageEraAlonzo) $
mconcat [Opt.long "alonzo-era", Opt.help "Specify the Alonzo era"]
mconcat [Opt.long "alonzo-era", Opt.help $ "Specify the Alonzo era" <> deprecationText]
, Opt.flag' (EraInEon ShelleyToBabbageEraBabbage) $
mconcat [Opt.long "babbage-era", Opt.help "Specify the Babbage era (default)"]
mconcat [Opt.long "babbage-era", Opt.help $ "Specify the Babbage era (default)" <> deprecationText]
]
, maybeToList $ pure <$> envCliAnyShelleyToBabbageEra envCli
, pure $ pure defaultShelleyToBabbageEra
, pure . pure $ EraInEon ShelleyToBabbageEraBabbage
]

pShelleyBasedShelley :: EnvCli -> Parser (EraInEon ShelleyBasedEra)
Expand All @@ -415,7 +412,7 @@ pShelleyBasedShelley envCli =
mconcat
[
[ Opt.flag' (EraInEon ShelleyBasedEraShelley) $
mconcat [Opt.long "shelley-era", Opt.help "Specify the Shelley era"]
mconcat [Opt.long "shelley-era", Opt.help $ "Specify the Shelley era" <> deprecationText]
]
, maybeToList $
fmap pure $
Expand All @@ -429,7 +426,7 @@ pShelleyBasedAllegra envCli =
mconcat
[
[ Opt.flag' (EraInEon ShelleyBasedEraAllegra) $
mconcat [Opt.long "allegra-era", Opt.help "Specify the Allegra era"]
mconcat [Opt.long "allegra-era", Opt.help $ "Specify the Allegra era" <> deprecationText]
]
, maybeToList $
fmap pure $
Expand All @@ -443,7 +440,7 @@ pShelleyBasedMary envCli =
mconcat
[
[ Opt.flag' (EraInEon ShelleyBasedEraMary) $
mconcat [Opt.long "mary-era", Opt.help "Specify the Mary era"]
mconcat [Opt.long "mary-era", Opt.help $ "Specify the Mary era" <> deprecationText]
]
, maybeToList $
fmap pure $
Expand All @@ -457,7 +454,7 @@ pShelleyBasedAlonzo envCli =
mconcat
[
[ Opt.flag' (EraInEon ShelleyBasedEraAlonzo) $
mconcat [Opt.long "alonzo-era", Opt.help "Specify the Alonzo era"]
mconcat [Opt.long "alonzo-era", Opt.help $ "Specify the Alonzo era" <> deprecationText]
]
, maybeToList $
fmap pure $
Expand All @@ -471,7 +468,7 @@ pShelleyBasedBabbage envCli =
mconcat
[
[ Opt.flag' (EraInEon ShelleyBasedEraBabbage) $
mconcat [Opt.long "babbage-era", Opt.help "Specify the Babbage era (default)"]
mconcat [Opt.long "babbage-era", Opt.help $ "Specify the Babbage era" <> deprecationText]
]
, maybeToList $
fmap pure $
Expand Down
8 changes: 7 additions & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,22 @@ import Cardano.CLI.EraBased.Run.StakeAddress
import Cardano.CLI.EraBased.Run.StakePool
import Cardano.CLI.EraBased.Run.TextView
import Cardano.CLI.EraBased.Run.Transaction
import Cardano.CLI.Helpers (printWarning)
import Cardano.CLI.Types.Errors.CmdError

import Control.Monad
import Data.Function ((&))

runAnyEraCommand
:: ()
=> AnyEraCommand
-> ExceptT CmdError IO ()
runAnyEraCommand = \case
AnyEraCommandOf sbe cmd ->
AnyEraCommandOf sbe cmd -> do
let selectedEraNum = fromEnum $ AnyShelleyBasedEra sbe
currentEraNum = fromEnum $ AnyShelleyBasedEra ShelleyBasedEraConway
when (selectedEraNum < currentEraNum) $
printWarning "Selected era is deprecated and will be removed in the future."
shelleyBasedEraConstraints sbe $ runCmds cmd

runCmds
Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/Helpers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ decodeCBOR
decodeCBOR bs decoder =
first CBORDecodingError $ deserialiseFromBytes decoder bs

printWarning :: String -> IO ()
printWarning warning = do
printWarning :: MonadIO m => String -> m ()
printWarning warning = liftIO $ do
ANSI.hSetSGR IO.stderr [SetColor Foreground Vivid Yellow]
IO.hPutStrLn IO.stderr $ "WARNING: " <> warning
ANSI.hSetSGR IO.stderr [Reset]
Expand Down
33 changes: 13 additions & 20 deletions cardano-cli/src/Cardano/CLI/Legacy/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import Cardano.CLI.Parser
import Cardano.CLI.Types.Common

import Data.Foldable
import Data.Function
import Data.Maybe (fromMaybe, maybeToList)
import Data.Word (Word64)
import Options.Applicative hiding (help, str)
Expand Down Expand Up @@ -1303,43 +1302,37 @@ pLegacyCardanoEra envCli =
[ Opt.flag' (AnyCardanoEra ByronEra) $
mconcat
[ Opt.long "byron-era"
, Opt.help "Specify the Byron era"
, Opt.help $ "Specify the Byron era" <> deprecationText
]
, Opt.flag' (AnyCardanoEra ShelleyEra) $
mconcat
[ Opt.long "shelley-era"
, Opt.help "Specify the Shelley era"
, Opt.help $ "Specify the Shelley era" <> deprecationText
]
, Opt.flag' (AnyCardanoEra AllegraEra) $
mconcat
[ Opt.long "allegra-era"
, Opt.help "Specify the Allegra era"
, Opt.help $ "Specify the Allegra era" <> deprecationText
]
, Opt.flag' (AnyCardanoEra MaryEra) $
mconcat
[ Opt.long "mary-era"
, Opt.help "Specify the Mary era"
, Opt.help $ "Specify the Mary era" <> deprecationText
]
, Opt.flag' (AnyCardanoEra AlonzoEra) $
mconcat
[ Opt.long "alonzo-era"
, Opt.help "Specify the Alonzo era"
, Opt.help $ "Specify the Alonzo era" <> deprecationText
]
, Opt.flag' (AnyCardanoEra BabbageEra) $
mconcat
[ Opt.long "babbage-era"
, Opt.help "Specify the Babbage era (default)"
, Opt.help $ "Specify the Babbage era (default)" <> deprecationText
]
]
, maybeToList $ pure <$> envCliAnyCardanoEra envCli
, -- TODO is this default needed anymore?
pure $ pure defaultCardanoEra
, pure . pure $ AnyCardanoEra BabbageEra
]
where
defaultCardanoEra =
defaultShelleyBasedEra & \(EraInEon era) ->
let cera = toCardanoEra era
in cardanoEraConstraints cera (AnyCardanoEra cera)

pLegacyShelleyBasedEra :: EnvCli -> Parser (EraInEon ShelleyBasedEra)
pLegacyShelleyBasedEra envCli =
Expand All @@ -1349,29 +1342,29 @@ pLegacyShelleyBasedEra envCli =
[ Opt.flag' (EraInEon ShelleyBasedEraShelley) $
mconcat
[ Opt.long "shelley-era"
, Opt.help "Specify the Shelley era"
, Opt.help $ "Specify the Shelley era" <> deprecationText
]
, Opt.flag' (EraInEon ShelleyBasedEraAllegra) $
mconcat
[ Opt.long "allegra-era"
, Opt.help "Specify the Allegra era"
, Opt.help $ "Specify the Allegra era" <> deprecationText
]
, Opt.flag' (EraInEon ShelleyBasedEraMary) $
mconcat
[ Opt.long "mary-era"
, Opt.help "Specify the Mary era"
, Opt.help $ "Specify the Mary era" <> deprecationText
]
, Opt.flag' (EraInEon ShelleyBasedEraAlonzo) $
mconcat
[ Opt.long "alonzo-era"
, Opt.help "Specify the Alonzo era"
, Opt.help $ "Specify the Alonzo era" <> deprecationText
]
, Opt.flag' (EraInEon ShelleyBasedEraBabbage) $
mconcat
[ Opt.long "babbage-era"
, Opt.help "Specify the Babbage era (default)"
, Opt.help $ "Specify the Babbage era (default)" <> deprecationText
]
]
, maybeToList $ pure <$> envCliAnyShelleyBasedEra envCli
, pure $ pure defaultShelleyBasedEra
, pure . pure $ EraInEon ShelleyBasedEraBabbage
]
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ parseLegacy :: EnvCli -> Parser ClientCommand
parseLegacy envCli =
subParser "legacy" $
Opt.info (LegacyCmds <$> parseLegacyCmds envCli) $
Opt.progDesc "Legacy commands"
Opt.progDesc ("Legacy commands" <> deprecationText)

_parseTopLevelLatest :: EnvCli -> Parser ClientCommand
_parseTopLevelLatest envCli =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

module Test.Golden.Shelley.TextEnvelope.Certificates.StakeAddress where

import Cardano.Api (AsType (..), CardanoEra (..), textEnvelopeTypeInEra)
import Cardano.Api

import Control.Monad (void)
import Data.Char (toLower)

import Test.Cardano.CLI.Util

Expand All @@ -20,6 +21,7 @@ import qualified Hedgehog.Extras.Test.File as H
hprop_golden_shelleyStakeAddressCertificates :: Property
hprop_golden_shelleyStakeAddressCertificates = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
let era = BabbageEra
eraStr = map toLower . docToString $ pretty era

-- Reference files
referenceRegistrationCertificate <-
Expand All @@ -42,7 +44,8 @@ hprop_golden_shelleyStakeAddressCertificates = propertyOnce . H.moduleWorkspace
-- Generate stake verification key
void $
execCardanoCLI
[ "stake-address"
[ eraStr
, "stake-address"
, "key-gen"
, "--verification-key-file"
, verKey
Expand All @@ -55,7 +58,7 @@ hprop_golden_shelleyStakeAddressCertificates = propertyOnce . H.moduleWorkspace
-- Create stake address registration certificate
void $
execCardanoCLI
[ "babbage"
[ eraStr
, "stake-address"
, "registration-certificate"
, "--stake-verification-key-file"
Expand All @@ -76,7 +79,7 @@ hprop_golden_shelleyStakeAddressCertificates = propertyOnce . H.moduleWorkspace
-- Create stake address deregistration certificate
void $
execCardanoCLI
[ "babbage"
[ eraStr
, "stake-address"
, "deregistration-certificate"
, "--stake-verification-key-file"
Expand All @@ -95,8 +98,9 @@ hprop_golden_shelleyStakeAddressCertificates = propertyOnce . H.moduleWorkspace
-- Create stake address delegation certificate
void $
execCardanoCLI
[ "stake-address"
, "delegation-certificate"
[ eraStr
, "stake-address"
, "stake-delegation-certificate"
, "--stake-verification-key-file"
, verKey
, "--cold-verification-key-file"
Expand Down
Loading
Loading