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

Delete legacy conway governance commands #231

Merged
merged 1 commit into from
Sep 4, 2023
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
6 changes: 1 addition & 5 deletions cardano-cli/src/Cardano/CLI/Legacy/Commands/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import Options.Applicative hiding (help, str)
import qualified Options.Applicative as Opt

data LegacyGovernanceCmds
= GovernanceVoteCmd VoteCmd
| GovernanceActionCmd ActionCmd
| GovernanceMIRPayStakeAddressesCertificate
= GovernanceMIRPayStakeAddressesCertificate
AnyShelleyToBabbageEra
MIRPot
[StakeAddress]
Expand Down Expand Up @@ -62,8 +60,6 @@ data LegacyGovernanceCmds

renderLegacyGovernanceCmds :: LegacyGovernanceCmds -> Text
renderLegacyGovernanceCmds = \case
GovernanceVoteCmd {} -> "governance vote"
GovernanceActionCmd {} -> "governance action"
GovernanceGenesisKeyDelegationCertificate {} -> "governance create-genesis-key-delegation-certificate"
GovernanceMIRPayStakeAddressesCertificate {} -> "governance create-mir-certificate stake-addresses"
GovernanceMIRTransfer _ _ _ TransferToTreasury -> "governance create-mir-certificate transfer-to-treasury"
Expand Down
6 changes: 0 additions & 6 deletions cardano-cli/src/Cardano/CLI/Legacy/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,12 +1014,6 @@ pGovernanceCmds envCli =
, subParser "verify-poll"
$ Opt.info pGovernanceVerifyPoll
$ Opt.progDesc "Verify an answer to a given SPO poll"
, fmap GovernanceVoteCmd $ subParser "vote"
$ Opt.info (pVoteCommmands envCli)
$ Opt.progDesc "Vote related commands."
, fmap GovernanceActionCmd $ subParser "action"
$ Opt.info (pActionCommmands envCli)
$ Opt.progDesc "Governance action related commands."
]
where
mirCertParsers :: Parser LegacyGovernanceCmds
Expand Down
107 changes: 0 additions & 107 deletions cardano-cli/src/Cardano/CLI/Legacy/Run/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ import Cardano.CLI.Legacy.Commands.Governance
import Cardano.CLI.Read
import Cardano.CLI.Types.Common
import Cardano.CLI.Types.Errors.GovernanceCmdError
import Cardano.CLI.Types.Governance
import Cardano.CLI.Types.Key
import qualified Cardano.Ledger.Conway.Governance as Ledger

import Control.Monad
import Control.Monad.IO.Class
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Except (ExceptT)
import Control.Monad.Trans.Except.Extra
import Data.Aeson (eitherDecode)
import Data.Bifunctor
import qualified Data.ByteString.Char8 as BSC
import qualified Data.ByteString.Lazy as LB
import Data.Function ((&))
Expand All @@ -38,16 +35,11 @@ import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import qualified Data.Text.IO as Text
import qualified Data.Text.Read as Text
import Data.Word
import qualified System.IO as IO
import System.IO (stderr, stdin, stdout)

runLegacyGovernanceCmds :: LegacyGovernanceCmds -> ExceptT GovernanceCmdError IO ()
runLegacyGovernanceCmds = \case
GovernanceVoteCmd (CreateVoteCmd (ConwayVote voteChoice voteType govActTcIn voteStakeCred sbe fp)) ->
runLegacyGovernanceCreateVoteCmd sbe voteChoice voteType govActTcIn voteStakeCred fp
GovernanceActionCmd (CreateConstitution network sbe deposit voteStakeCred mPrevGovActId proposalUrl proposalHashSource constitutionUrl constitutionHashSource fp) ->
runLegacyGovernanceNewConstitutionCmd network sbe deposit voteStakeCred mPrevGovActId proposalUrl proposalHashSource constitutionUrl constitutionHashSource fp
GovernanceMIRPayStakeAddressesCertificate anyEra mirpot vKeys rewards out ->
runLegacyGovernanceMIRCertificatePayStakeAddrs anyEra mirpot vKeys rewards out
GovernanceMIRTransfer anyEra amt out direction -> do
Expand All @@ -63,77 +55,6 @@ runLegacyGovernanceCmds = \case
GovernanceVerifyPoll poll metadata mOutFile ->
runLegacyGovernanceVerifyPoll poll metadata mOutFile

runLegacyGovernanceCreateVoteCmd :: ()
=> AnyShelleyBasedEra
-> Vote
-> VType
-> (TxId, Word32)
-> VerificationKeyOrFile StakePoolKey
-> VoteFile Out
-> ExceptT GovernanceCmdError IO ()
runLegacyGovernanceCreateVoteCmd anyEra vChoice vType (govActionTxId, govActionIndex) votingStakeCred oFp = do
AnyShelleyBasedEra sbe <- pure anyEra

shelleyBasedEraConstraints sbe $ do
vStakePoolKey <- firstExceptT ReadFileError . newExceptT $ readVerificationKeyOrFile AsStakePoolKey votingStakeCred
let stakePoolKeyHash = verificationKeyHash vStakePoolKey
vStakeCred = StakeCredentialByKey . (verificationKeyHash . castVerificationKey) $ vStakePoolKey
case vType of
VCC -> do
votingCred <- hoistEither $ first VotingCredentialDecodeGovCmdEror $ toVotingCredential sbe vStakeCred
let voter = Ledger.CommitteeVoter (Ledger.coerceKeyRole (unVotingCredential votingCred)) -- TODO Conway - remove coerceKeyRole
govActIdentifier = createGovernanceActionId govActionTxId govActionIndex
voteProcedure = createVotingProcedure sbe vChoice Nothing
votingProcedures = singletonVotingProcedures sbe voter govActIdentifier (unVotingProcedure voteProcedure)
firstExceptT WriteFileError . newExceptT $ writeFileTextEnvelope oFp Nothing votingProcedures

VDR -> do
votingCred <- hoistEither $ first VotingCredentialDecodeGovCmdEror $ toVotingCredential sbe vStakeCred
let voter = Ledger.DRepVoter (unVotingCredential votingCred)
govActIdentifier = createGovernanceActionId govActionTxId govActionIndex
voteProcedure = createVotingProcedure sbe vChoice Nothing
votingProcedures = singletonVotingProcedures sbe voter govActIdentifier (unVotingProcedure voteProcedure)
firstExceptT WriteFileError . newExceptT $ writeFileTextEnvelope oFp Nothing votingProcedures

VSP -> do
let voter = Ledger.StakePoolVoter (unStakePoolKeyHash stakePoolKeyHash)
govActIdentifier = createGovernanceActionId govActionTxId govActionIndex
voteProcedure = createVotingProcedure sbe vChoice Nothing
votingProcedures = singletonVotingProcedures sbe voter govActIdentifier (unVotingProcedure voteProcedure)
firstExceptT WriteFileError . newExceptT $ writeFileTextEnvelope oFp Nothing votingProcedures

runLegacyGovernanceNewConstitutionCmd :: ()
=> Ledger.Network
-> AnyShelleyBasedEra
-> Lovelace
-> VerificationKeyOrFile StakePoolKey
-> Maybe (TxId, Word32)
-> ProposalUrl
-> ProposalHashSource
-> ConstitutionUrl
-> ConstitutionHashSource
-> File ConstitutionText Out
-> ExceptT GovernanceCmdError IO ()
runLegacyGovernanceNewConstitutionCmd network sbe deposit stakeVoteCred mPrevGovAct proposalUrl proposalHashSource constitutionUrl constitutionHashSource oFp = do
vStakePoolKeyHash
<- fmap (verificationKeyHash . castVerificationKey)
<$> firstExceptT ReadFileError . newExceptT
$ readVerificationKeyOrFile AsStakePoolKey stakeVoteCred

constitutionHash <-
constitutionHashSourceToHash constitutionHashSource
& firstExceptT GovernanceCmdConstitutionError

let constitutionAnchor = Ledger.Anchor
{ Ledger.anchorUrl = unConstitutionUrl constitutionUrl
, Ledger.anchorDataHash = constitutionHash
}

let prevGovActId = Ledger.maybeToStrictMaybe $ uncurry createPreviousGovernanceActionId <$> mPrevGovAct
let govAct = ProposeNewConstitution prevGovActId constitutionAnchor

runLegacyGovernanceCreateActionCmd network sbe deposit vStakePoolKeyHash proposalUrl proposalHashSource govAct oFp

runLegacyGovernanceMIRCertificatePayStakeAddrs
:: AnyShelleyToBabbageEra
-> Ledger.MIRPot
Expand All @@ -153,34 +74,6 @@ runLegacyGovernanceMIRCertificateTransfer
runLegacyGovernanceMIRCertificateTransfer (AnyShelleyToBabbageEra w) =
runGovernanceMIRCertificateTransfer w

runLegacyGovernanceCreateActionCmd
:: Ledger.Network
-> AnyShelleyBasedEra
-> Lovelace
-> Hash StakeKey
-> ProposalUrl
-> ProposalHashSource
-> GovernanceAction
-> File a Out
-> ExceptT GovernanceCmdError IO ()
runLegacyGovernanceCreateActionCmd network anyEra deposit depositReturnAddr proposalUrl proposalHashSource govAction oFp = do
AnyShelleyBasedEra sbe <- pure anyEra

proposalHash <-
proposalHashSourceToHash proposalHashSource
& firstExceptT GovernanceCmdProposalError

let proposalAnchor = Ledger.Anchor
{ Ledger.anchorUrl = unProposalUrl proposalUrl
, Ledger.anchorDataHash = proposalHash
}

let proposal = createProposalProcedure sbe network deposit depositReturnAddr govAction proposalAnchor

firstExceptT WriteFileError . newExceptT
$ shelleyBasedEraConstraints sbe
$ writeFileTextEnvelope oFp Nothing proposal

runLegacyGovernanceGenesisKeyDelegationCertificate
:: AnyShelleyBasedEra
-> VerificationKeyOrHashOrFile GenesisKey
Expand Down
108 changes: 0 additions & 108 deletions cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -1259,8 +1259,6 @@ Usage: cardano-cli legacy governance
| create-poll
| answer-poll
| verify-poll
| vote
| action
)

Governance commands
Expand Down Expand Up @@ -1406,58 +1404,6 @@ Usage: cardano-cli legacy governance verify-poll --poll-file FILE

Verify an answer to a given SPO poll

Usage: cardano-cli legacy governance vote create-vote

Vote related commands.

Usage: cardano-cli legacy governance vote create-vote (--yes | --no | --abstain)
( --constitutional-committee-member
| --drep
| --spo
)
--governance-action-tx-id TXID
--governance-action-index WORD32
( --stake-pool-verification-key STRING
| --cold-verification-key-file FILE
)
[--conway-era]
--out-file FILE

Create a vote for a proposed governance action.

Usage: cardano-cli legacy governance action create-action

Governance action related commands.

Usage: cardano-cli legacy governance action create-action create-constitution

Create a governance action.

Usage: cardano-cli legacy governance action create-action create-constitution
( --mainnet
| --testnet
)
[--conway-era]
--governance-action-deposit NATURAL
( --stake-pool-verification-key STRING
| --cold-verification-key-file FILE
)
[--governance-action-tx-id TXID
--governance-action-index WORD32]
--proposal-url TEXT
( --proposal-text TEXT
| --proposal-file FILE
| --proposal-hash HASH
)
--constitution-url TEXT
( --constitution-text TEXT
| --constitution-file FILE
| --constitution-hash HASH
)
--out-file FILE

Create a constitution.

Usage: cardano-cli legacy genesis
( key-gen-genesis
| key-gen-delegate
Expand Down Expand Up @@ -2628,8 +2574,6 @@ Usage: cardano-cli governance
| create-poll
| answer-poll
| verify-poll
| vote
| action
)

Governance commands
Expand Down Expand Up @@ -2775,58 +2719,6 @@ Usage: cardano-cli governance verify-poll --poll-file FILE

Verify an answer to a given SPO poll

Usage: cardano-cli governance vote create-vote

Vote related commands.

Usage: cardano-cli governance vote create-vote (--yes | --no | --abstain)
( --constitutional-committee-member
| --drep
| --spo
)
--governance-action-tx-id TXID
--governance-action-index WORD32
( --stake-pool-verification-key STRING
| --cold-verification-key-file FILE
)
[--conway-era]
--out-file FILE

Create a vote for a proposed governance action.

Usage: cardano-cli governance action create-action

Governance action related commands.

Usage: cardano-cli governance action create-action create-constitution

Create a governance action.

Usage: cardano-cli governance action create-action create-constitution
( --mainnet
| --testnet
)
[--conway-era]
--governance-action-deposit NATURAL
( --stake-pool-verification-key STRING
| --cold-verification-key-file FILE
)
[--governance-action-tx-id TXID
--governance-action-index WORD32]
--proposal-url TEXT
( --proposal-text TEXT
| --proposal-file FILE
| --proposal-hash HASH
)
--constitution-url TEXT
( --constitution-text TEXT
| --constitution-file FILE
| --constitution-hash HASH
)
--out-file FILE

Create a constitution.

Usage: cardano-cli genesis
( key-gen-genesis
| key-gen-delegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ Usage: cardano-cli governance
| create-poll
| answer-poll
| verify-poll
| vote
| action
)

Governance commands
Expand All @@ -23,5 +21,3 @@ Available commands:
create-poll Create an SPO poll
answer-poll Answer an SPO poll
verify-poll Verify an answer to a given SPO poll
vote Vote related commands.
action Governance action related commands.

This file was deleted.

Loading