Skip to content

Commit

Permalink
Merge pull request #878 from IntersectMBO/mgalazyn/feature/remove-old…
Browse files Browse the repository at this point in the history
…er-eras-transaction-build

Remove eras older than Babbage support in `transaction build` and `transaction build-estimate`
  • Loading branch information
carbolymer authored Sep 20, 2024
2 parents ddcf25f + 20fa071 commit a157c49
Show file tree
Hide file tree
Showing 31 changed files with 441 additions and 3,737 deletions.
21 changes: 11 additions & 10 deletions cardano-cli/src/Cardano/CLI/Environment.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
-- | This module defines constants derived from the environment.
module Cardano.CLI.Environment
( EnvCli (..)
, envCliAnyShelleyBasedEra
, envCliAnyShelleyToBabbageEra
, envCliSomeEra
, envCliAnyEon
, getEnvCli
, getEnvNetworkId
, getEnvSocketPath
)
where

import Cardano.Api (AnyCardanoEra (..), CardanoEra (..), EraInEon (..), NetworkId (..),
NetworkMagic (..), ShelleyBasedEra (..), ShelleyToBabbageEra (..),
forEraInEonMaybe)
import Cardano.Api (AnyCardanoEra (..), CardanoEra (..), Eon, EraInEon (..),
NetworkId (..), NetworkMagic (..), forEraInEonMaybe)
import qualified Cardano.Api.Experimental as Exp

import Data.Typeable
import Data.Word (Word32)
import qualified System.Environment as IO
import qualified System.IO as IO
Expand All @@ -40,13 +41,13 @@ getEnvCli = do
, envCliAnyCardanoEra = mCardanoEra
}

envCliAnyShelleyBasedEra :: EnvCli -> Maybe (EraInEon ShelleyBasedEra)
envCliAnyShelleyBasedEra envCli = do
envCliSomeEra :: EnvCli -> Maybe (Exp.Some Exp.Era)
envCliSomeEra envCli = do
AnyCardanoEra era <- envCliAnyCardanoEra envCli
forEraInEonMaybe era EraInEon
forEraInEonMaybe era Exp.Some

envCliAnyShelleyToBabbageEra :: EnvCli -> Maybe (EraInEon ShelleyToBabbageEra)
envCliAnyShelleyToBabbageEra envCli = do
envCliAnyEon :: Typeable eon => Eon eon => EnvCli -> Maybe (EraInEon eon)
envCliAnyEon envCli = do
AnyCardanoEra era <- envCliAnyCardanoEra envCli
forEraInEonMaybe era EraInEon

Expand Down
19 changes: 10 additions & 9 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Cardano.CLI.EraBased.Commands.Key
import Cardano.CLI.EraBased.Commands.Node
import Cardano.CLI.EraBased.Commands.Query
import Cardano.CLI.EraBased.Commands.StakeAddress
import Cardano.CLI.EraBased.Commands.StakePool
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
Expand Down Expand Up @@ -113,17 +113,18 @@ pAnyEraCommand envCli =
]

pCmds :: ShelleyBasedEra era -> EnvCli -> Parser (Cmds era)
pCmds era envCli =
pCmds sbe' envCli = do
let cEra = toCardanoEra sbe'
asum $
catMaybes
[ fmap AddressCmds <$> pAddressCmds (toCardanoEra era) envCli
[ fmap AddressCmds <$> pAddressCmds cEra envCli
, fmap KeyCmds <$> pKeyCmds
, fmap GenesisCmds <$> pGenesisCmds (toCardanoEra era) envCli
, fmap GovernanceCmds <$> pGovernanceCmds (toCardanoEra era)
, fmap GenesisCmds <$> pGenesisCmds cEra envCli
, fmap GovernanceCmds <$> pGovernanceCmds cEra
, fmap NodeCmds <$> pNodeCmds
, fmap QueryCmds <$> pQueryCmds (toCardanoEra era) envCli
, fmap StakeAddressCmds <$> pStakeAddressCmds (toCardanoEra era) envCli
, fmap StakePoolCmds <$> pStakePoolCmds (toCardanoEra era) envCli
, fmap QueryCmds <$> pQueryCmds cEra envCli
, fmap StakeAddressCmds <$> pStakeAddressCmds cEra envCli
, fmap StakePoolCmds <$> pStakePoolCmds cEra envCli
, fmap TextViewCmds <$> pTextViewCmds
, fmap TransactionCmds <$> pTransactionCmds era envCli
, fmap TransactionCmds <$> pTransactionCmds sbe' envCli
]
5 changes: 3 additions & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module Cardano.CLI.EraBased.Commands.Transaction
)
where

import qualified Cardano.Api.Experimental as Exp
import Cardano.Api.Ledger (Coin)
import Cardano.Api.Shelley

Expand Down Expand Up @@ -87,7 +88,7 @@ data TransactionBuildRawCmdArgs era = TransactionBuildRawCmdArgs

-- | Like 'TransactionBuildRaw' but without the fee, and with a change output.
data TransactionBuildCmdArgs era = TransactionBuildCmdArgs
{ eon :: !(ShelleyBasedEra era)
{ currentEra :: !(Exp.Era era)
, nodeSocketPath :: !SocketPath
, consensusModeParams :: !ConsensusModeParams
, networkId :: !NetworkId
Expand Down Expand Up @@ -135,7 +136,7 @@ data TransactionBuildCmdArgs era = TransactionBuildCmdArgs

-- | Like 'TransactionBuildCmd' but does not require explicit access to a running node
data TransactionBuildEstimateCmdArgs era = TransactionBuildEstimateCmdArgs
{ eon :: !(MaryEraOnwards era)
{ currentEra :: !(Exp.Era era)
, mScriptValidity :: !(Maybe ScriptValidity)
-- ^ Mark script as expected to pass or fail validation
, shelleyWitnesses :: !Int
Expand Down
95 changes: 5 additions & 90 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import Cardano.Api hiding (bounded, parseFilePath)
import qualified Cardano.Api.Ledger as L
import Cardano.Api.Shelley hiding (bounded, parseFilePath)

import Cardano.CLI.Environment (EnvCli (..), envCliAnyShelleyBasedEra,
envCliAnyShelleyToBabbageEra)
import Cardano.CLI.Environment (EnvCli (..), envCliAnyEon)
import Cardano.CLI.Parser
import Cardano.CLI.Read
import Cardano.CLI.Types.Common
Expand All @@ -26,7 +25,7 @@ import Cardano.CLI.Types.Key
import Cardano.CLI.Types.Key.VerificationKey
import qualified Ouroboros.Network.Protocol.LocalStateQuery.Type as Consensus

import Control.Monad (mfilter, void, when)
import Control.Monad (void, when)
import qualified Data.Aeson as Aeson
import Data.Bifunctor
import Data.Bits (Bits, toIntegralSized)
Expand Down Expand Up @@ -385,8 +384,8 @@ pAnyShelleyBasedEra envCli =
, Opt.flag' (EraInEon ShelleyBasedEraConway) $
mconcat [Opt.long "conway-era", Opt.help "Specify the Conway era"]
]
, maybeToList $ pure <$> envCliAnyShelleyBasedEra envCli
, pure . pure $ EraInEon ShelleyBasedEraBabbage
, maybeToList $ pure <$> envCliAnyEon envCli
, pure $ pure $ EraInEon ShelleyBasedEraBabbage
]

deprecationText :: String
Expand All @@ -408,94 +407,10 @@ pAnyShelleyToBabbageEra envCli =
, Opt.flag' (EraInEon ShelleyToBabbageEraBabbage) $
mconcat [Opt.long "babbage-era", Opt.help $ "Specify the Babbage era (default)" <> deprecationText]
]
, maybeToList $ pure <$> envCliAnyShelleyToBabbageEra envCli
, maybeToList $ pure <$> envCliAnyEon envCli
, pure . pure $ EraInEon ShelleyToBabbageEraBabbage
]

pShelleyBasedShelley :: EnvCli -> Parser (EraInEon ShelleyBasedEra)
pShelleyBasedShelley envCli =
asum $
mconcat
[
[ Opt.flag' (EraInEon ShelleyBasedEraShelley) $
mconcat [Opt.long "shelley-era", Opt.help $ "Specify the Shelley era" <> deprecationText]
]
, maybeToList $
fmap pure $
mfilter (== EraInEon ShelleyBasedEraShelley) $
envCliAnyShelleyBasedEra envCli
]

pShelleyBasedAllegra :: EnvCli -> Parser (EraInEon ShelleyBasedEra)
pShelleyBasedAllegra envCli =
asum $
mconcat
[
[ Opt.flag' (EraInEon ShelleyBasedEraAllegra) $
mconcat [Opt.long "allegra-era", Opt.help $ "Specify the Allegra era" <> deprecationText]
]
, maybeToList $
fmap pure $
mfilter (== EraInEon ShelleyBasedEraAllegra) $
envCliAnyShelleyBasedEra envCli
]

pShelleyBasedMary :: EnvCli -> Parser (EraInEon ShelleyBasedEra)
pShelleyBasedMary envCli =
asum $
mconcat
[
[ Opt.flag' (EraInEon ShelleyBasedEraMary) $
mconcat [Opt.long "mary-era", Opt.help $ "Specify the Mary era" <> deprecationText]
]
, maybeToList $
fmap pure $
mfilter (== EraInEon ShelleyBasedEraMary) $
envCliAnyShelleyBasedEra envCli
]

pShelleyBasedAlonzo :: EnvCli -> Parser (EraInEon ShelleyBasedEra)
pShelleyBasedAlonzo envCli =
asum $
mconcat
[
[ Opt.flag' (EraInEon ShelleyBasedEraAlonzo) $
mconcat [Opt.long "alonzo-era", Opt.help $ "Specify the Alonzo era" <> deprecationText]
]
, maybeToList $
fmap pure $
mfilter (== EraInEon ShelleyBasedEraAlonzo) $
envCliAnyShelleyBasedEra envCli
]

pShelleyBasedBabbage :: EnvCli -> Parser (EraInEon ShelleyBasedEra)
pShelleyBasedBabbage envCli =
asum $
mconcat
[
[ Opt.flag' (EraInEon ShelleyBasedEraBabbage) $
mconcat [Opt.long "babbage-era", Opt.help $ "Specify the Babbage era" <> deprecationText]
]
, maybeToList $
fmap pure $
mfilter (== EraInEon ShelleyBasedEraBabbage) $
envCliAnyShelleyBasedEra envCli
]

pShelleyBasedConway :: EnvCli -> Parser (EraInEon ShelleyBasedEra)
pShelleyBasedConway envCli =
asum $
mconcat
[
[ Opt.flag' (EraInEon ShelleyBasedEraConway) $
mconcat [Opt.long "conway-era", Opt.help "Specify the Conway era"]
]
, maybeToList $
fmap pure $
mfilter (== EraInEon ShelleyBasedEraConway) $
envCliAnyShelleyBasedEra envCli
]

pFileOutDirection :: String -> String -> Parser (File a Out)
pFileOutDirection l h = File <$> parseFilePath l h

Expand Down
Loading

0 comments on commit a157c49

Please sign in to comment.