Skip to content

Commit

Permalink
Merge pull request #935 from IntersectMBO/jordan/remove-unnecessary-e…
Browse files Browse the repository at this point in the history
…ra-parameters

Remove unnecessary era parameters and use ShelleyBasedEra era
  • Loading branch information
Jimbo4350 authored Oct 15, 2024
2 parents 746a580 + 5574be2 commit 6c2e1c2
Show file tree
Hide file tree
Showing 14 changed files with 212 additions and 225 deletions.
22 changes: 11 additions & 11 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Cardano.CLI.EraBased.Commands
)
where

import Cardano.Api (ShelleyBasedEra (..), toCardanoEra)
import Cardano.Api (ShelleyBasedEra (..))

import Cardano.CLI.Commands.Address
import Cardano.CLI.Commands.Key
Expand All @@ -20,12 +20,13 @@ import Cardano.CLI.Environment
import Cardano.CLI.EraBased.Commands.Genesis
import Cardano.CLI.EraBased.Commands.Query
import Cardano.CLI.EraBased.Commands.StakeAddress
import Cardano.CLI.EraBased.Commands.StakePool hiding (sbe)
import Cardano.CLI.EraBased.Commands.StakePool
import Cardano.CLI.EraBased.Commands.TextView
import Cardano.CLI.EraBased.Commands.Transaction
import Cardano.CLI.EraBased.Options.Common
import Cardano.CLI.EraBased.Options.Genesis
import Cardano.CLI.EraBased.Options.Governance
import Cardano.CLI.EraBased.Options.Governance (GovernanceCmds, pGovernanceCmds,
renderGovernanceCmds)
import Cardano.CLI.EraBased.Options.Query
import Cardano.CLI.EraBased.Options.StakeAddress
import Cardano.CLI.EraBased.Options.StakePool
Expand Down Expand Up @@ -113,18 +114,17 @@ pAnyEraCommand envCli =
]

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

data StakeAddressCmds era
= StakeAddressKeyGenCmd
(ShelleyBasedEra era)
KeyOutputFormat
(VerificationKeyFile Out)
(SigningKeyFile Out)
| StakeAddressKeyHashCmd
(ShelleyBasedEra era)
(VerificationKeyOrFile StakeKey)
(Maybe (File () Out))
| StakeAddressBuildCmd
(ShelleyBasedEra era)
StakeVerifier
NetworkId
(Maybe (File () Out))
Expand Down
5 changes: 3 additions & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ pNetworkId envCli =
pure <$> maybeToList (envCliNetworkId envCli)
]

pTarget :: CardanoEra era -> Parser (Consensus.Target ChainPoint)
pTarget = inEonForEra (pure Consensus.VolatileTip) pTargetFromConway
pTarget :: ShelleyBasedEra era -> Parser (Consensus.Target ChainPoint)
pTarget sbe =
maybe (pure Consensus.VolatileTip) pTargetFromConway (forShelleyBasedEraMaybeEon sbe)
where
pTargetFromConway :: ConwayEraOnwards era -> Parser (Consensus.Target ChainPoint)
pTargetFromConway _ =
Expand Down
27 changes: 15 additions & 12 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import qualified Options.Applicative as Opt

pGenesisCmds
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> EnvCli
-> Maybe (Parser (GenesisCmds era))
pGenesisCmds era envCli =
Expand Down Expand Up @@ -65,31 +65,34 @@ pGenesisCmds era envCli =
subParser "initial-txin" $
Opt.info (pGenesisTxIn envCli) $
Opt.progDesc "Get the TxIn for an initial UTxO based on the verification key"
, forEraInEonMaybe era $ \sbe ->
subParser "create-cardano" $
Opt.info (pGenesisCreateCardano sbe envCli) $
Opt.progDesc $
mconcat
[ "Create a Byron and Shelley genesis file from a genesis "
, "template and genesis/delegation/spending keys."
]
, forEraInEonMaybe era $ \sbe ->
, forShelleyBasedEraInEonMaybe
era
( \sbe ->
subParser "create-cardano" $
Opt.info (pGenesisCreateCardano sbe envCli) $
Opt.progDesc $
mconcat
[ "Create a Byron and Shelley genesis file from a genesis "
, "template and genesis/delegation/spending keys."
]
)
, forShelleyBasedEraInEonMaybe era $ \sbe ->
subParser "create" $
Opt.info (pGenesisCreate sbe envCli) $
Opt.progDesc $
mconcat
[ "Create a Shelley genesis file from a genesis "
, "template and genesis/delegation/spending keys."
]
, forEraInEonMaybe era $ \sbe ->
, forShelleyBasedEraInEonMaybe era $ \sbe ->
subParser "create-staked" $
Opt.info (pGenesisCreateStaked sbe envCli) $
Opt.progDesc $
mconcat
[ "Create a staked Shelley genesis file from a genesis "
, "template and genesis/delegation/spending keys."
]
, forEraInEonMaybe era $ \sbe ->
, forShelleyBasedEraInEonMaybe era $ \sbe ->
subParser "create-testnet-data" $
Opt.info (pGenesisCreateTestNetData sbe envCli) $
Opt.progDesc $
Expand Down
10 changes: 5 additions & 5 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import qualified Options.Applicative as Opt

pGovernanceCmds
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceCmds era))
pGovernanceCmds era =
subInfoParser
Expand All @@ -43,9 +43,9 @@ pGovernanceCmds era =
, fmap GovernanceVoteCmds <$> pGovernanceVoteCmds era
]

pCreateMirCertificatesCmds :: CardanoEra era -> Maybe (Parser (GovernanceCmds era))
pCreateMirCertificatesCmds :: ShelleyBasedEra era -> Maybe (Parser (GovernanceCmds era))
pCreateMirCertificatesCmds era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure $
subParser "create-mir-certificate" $
Opt.info (pMIRPayStakeAddresses w <|> mirCertParsers w) $
Expand Down Expand Up @@ -99,10 +99,10 @@ pGovernanceCreateMirCertificateTransferToReservesCmd w =

pGovernanceGenesisKeyDelegationCertificate
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceCmds era))
pGovernanceGenesisKeyDelegationCertificate era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure $
subParser "create-genesis-key-delegation-certificate" $
Opt.info (parser w) $
Expand Down
34 changes: 17 additions & 17 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import qualified Options.Applicative as Opt

pGovernanceActionCmds
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionCmds era =
subInfoParser
Expand All @@ -44,10 +44,10 @@ pGovernanceActionCmds era =
]

pGovernanceActionViewCmd
:: CardanoEra era
:: ShelleyBasedEra era
-> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionViewCmd era = do
eon <- forEraMaybeEon era
eon <- forShelleyBasedEraMaybeEon era
return
$ subParser "view"
$ Opt.info
Expand All @@ -60,10 +60,10 @@ pGovernanceActionViewCmd era = do
$ Opt.progDesc "View a governance action."

pGovernanceActionNewInfoCmd
:: CardanoEra era
:: ShelleyBasedEra era
-> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionNewInfoCmd era = do
eon <- forEraMaybeEon era
eon <- forShelleyBasedEraMaybeEon era
pure
$ subParser "create-info"
$ Opt.info
Expand All @@ -80,10 +80,10 @@ pGovernanceActionNewInfoCmd era = do
$ Opt.progDesc "Create an info action."

pGovernanceActionNewConstitutionCmd
:: CardanoEra era
:: ShelleyBasedEra era
-> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionNewConstitutionCmd era = do
eon <- forEraMaybeEon era
eon <- forShelleyBasedEraMaybeEon era
pure
$ subParser "create-constitution"
$ Opt.info
Expand All @@ -105,10 +105,10 @@ pGovernanceActionNewConstitutionCmd era = do
$ Opt.progDesc "Create a constitution."

pGovernanceActionUpdateCommitteeCmd
:: CardanoEra era
:: ShelleyBasedEra era
-> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionUpdateCommitteeCmd era = do
eon <- forEraMaybeEon era
eon <- forShelleyBasedEraMaybeEon era
pure
$ subParser "update-committee"
$ Opt.info
Expand Down Expand Up @@ -140,10 +140,10 @@ pUpdateCommitteeCmd eon =
<*> pOutputFile

pGovernanceActionNoConfidenceCmd
:: CardanoEra era
:: ShelleyBasedEra era
-> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionNoConfidenceCmd era = do
eon <- forEraMaybeEon era
eon <- forShelleyBasedEraMaybeEon era
pure
$ subParser "create-no-confidence"
$ Opt.info
Expand Down Expand Up @@ -226,10 +226,10 @@ pCostModelsFile =

pGovernanceActionProtocolParametersUpdateCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionProtocolParametersUpdateCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure $
Cmd.GovernanceActionProtocolParametersUpdateCmd
<$> pUpdateProtocolParametersCmd w
Expand Down Expand Up @@ -371,9 +371,9 @@ dpGovActionProtocolParametersUpdate = \case
<*> pIntroducedInConwayPParams

pGovernanceActionTreasuryWithdrawalCmd
:: CardanoEra era -> Maybe (Parser (Cmd.GovernanceActionCmds era))
:: ShelleyBasedEra era -> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionTreasuryWithdrawalCmd era = do
eon <- forEraMaybeEon era
eon <- forShelleyBasedEraMaybeEon era
pure
$ subParser "create-treasury-withdrawal"
$ Opt.info
Expand Down Expand Up @@ -413,10 +413,10 @@ pPV :: Parser L.ProtVer
pPV = mkProtocolVersionOrErr <$> pProtocolVersion

pGovernanceActionHardforkInitCmd
:: CardanoEra era
:: ShelleyBasedEra era
-> Maybe (Parser (Cmd.GovernanceActionCmds era))
pGovernanceActionHardforkInitCmd era = do
eon <- forEraMaybeEon era
eon <- forShelleyBasedEraMaybeEon era
pure
$ subParser "create-hardfork"
$ Opt.info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import qualified Options.Applicative as Opt

pGovernanceCommitteeCmds
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceCommitteeCmds era))
pGovernanceCommitteeCmds era =
subInfoParser
Expand All @@ -39,10 +39,10 @@ pGovernanceCommitteeCmds era =

pGovernanceCommitteeKeyGenColdCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceCommitteeCmds era))
pGovernanceCommitteeKeyGenColdCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure $
subParser "key-gen-cold" $
Opt.info (pCmd w) $
Expand All @@ -63,10 +63,10 @@ pGovernanceCommitteeKeyGenColdCmd era = do

pGovernanceCommitteeKeyGenHotCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceCommitteeCmds era))
pGovernanceCommitteeKeyGenHotCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure $
subParser "key-gen-hot" $
Opt.info (pCmd w) $
Expand All @@ -87,10 +87,10 @@ pGovernanceCommitteeKeyGenHotCmd era = do

pGovernanceCommitteeKeyHashCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceCommitteeCmds era))
pGovernanceCommitteeKeyHashCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure
$ subParser "key-hash"
$ Opt.info
Expand All @@ -105,10 +105,10 @@ pGovernanceCommitteeKeyHashCmd era = do

pGovernanceCommitteeCreateHotKeyAuthorizationCertificateCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceCommitteeCmds era))
pGovernanceCommitteeCreateHotKeyAuthorizationCertificateCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure
$ subParser "create-hot-key-authorization-certificate"
$ Opt.info
Expand All @@ -125,10 +125,10 @@ pGovernanceCommitteeCreateHotKeyAuthorizationCertificateCmd era = do

pGovernanceCommitteeCreateColdKeyResignationCertificateCmd
:: ()
=> CardanoEra era
=> ShelleyBasedEra era
-> Maybe (Parser (GovernanceCommitteeCmds era))
pGovernanceCommitteeCreateColdKeyResignationCertificateCmd era = do
w <- forEraMaybeEon era
w <- forShelleyBasedEraMaybeEon era
pure $
subParser "create-cold-key-resignation-certificate" $
Opt.info (conwayEraOnwardsConstraints w $ mkParser w) $
Expand Down
Loading

0 comments on commit 6c2e1c2

Please sign in to comment.