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

Change constitution to proposal in transaction build #219

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
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Legacy/Commands/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ data LegacyTransactionCmds
[MetadataFile]
(Maybe UpdateProposalFile)
[VoteFile In]
[NewConstitutionFile In]
[ProposalFile In]
TxBuildOutputOptions
| TxSign
InputTxBodyOrTxFile
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Legacy/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ pTransaction envCli =
<*> many pMetadataFile
<*> optional pUpdateProposalFile
<*> many (pFileInDirection "vote-file" "Filepath of the vote.")
<*> many (pFileInDirection "constitution-file" "Filepath of the constitution.")
<*> many (pFileInDirection "proposal-file" "Filepath of the proposal.")
<*> (OutputTxBodyOnly <$> pTxBodyFileOut <|> pCalculatePlutusScriptCost)

pChangeAddress :: Parser TxOutChangeAddress
Expand Down
7 changes: 3 additions & 4 deletions cardano-cli/src/Cardano/CLI/Legacy/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ runTxBuildCmd
-> [MetadataFile]
-> Maybe UpdateProposalFile
-> [VoteFile In]
-> [NewConstitutionFile In] -- TODO: Conway era - we should replace this with a sumtype that handles all governance actions
-> [ProposalFile In]
-> TxBuildOutputOptions
-> ExceptT ShelleyTxCmdError IO ()
runTxBuildCmd
socketPath (AnyCardanoEra cEra) consensusModeParams@(AnyConsensusModeParams cModeParams) nid
mScriptValidity mOverrideWits txins readOnlyRefIns reqSigners txinsc mReturnColl mTotCollateral txouts
changeAddr mValue mLowBound mUpperBound certs wdrls metadataSchema scriptFiles metadataFiles mUpProp
conwayVotes newConstitutions outputOptions = do
conwayVotes newProposals outputOptions = do

-- The user can specify an era prior to the era that the node is currently in.
-- We cannot use the user specified era to construct a query against a node because it may differ
Expand Down Expand Up @@ -179,8 +179,7 @@ runTxBuildCmd
cEra

proposals <- newExceptT $ first ShelleyTxCmdConstitutionError
<$> readTxNewConstitutionActions cEra newConstitutions

<$> readTxGovernanceActions cEra newProposals

-- the same collateral input can be used for several plutus scripts
let filteredTxinsc = Set.toList $ Set.fromList txinsc
Expand Down
20 changes: 10 additions & 10 deletions cardano-cli/src/Cardano/CLI/Read.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module Cardano.CLI.Read
-- * Governance related
, ConstitutionError(..)
, VoteError (..)
, readTxNewConstitutionActions
, readTxGovernanceActions

-- * FileOrPipe
, FileOrPipe
Expand Down Expand Up @@ -776,22 +776,22 @@ data ConstitutionError
| ConstitutionsNotSupportedInEra AnyCardanoEra
deriving Show

readTxNewConstitutionActions
readTxGovernanceActions
:: CardanoEra era
-> [NewConstitutionFile In]
-> [ProposalFile In]
-> IO (Either ConstitutionError (TxGovernanceActions era))
readTxNewConstitutionActions _ [] = return $ Right TxGovernanceActionsNone
readTxNewConstitutionActions era files = runExceptT $ do
readTxGovernanceActions _ [] = return $ Right TxGovernanceActionsNone
readTxGovernanceActions era files = runExceptT $ do
w <- maybeFeatureInEra era
& hoistMaybe (ConstitutionsNotSupportedInEra $ cardanoEraConstraints era $ AnyCardanoEra era)
constitutions <- newExceptT $ sequence <$> mapM (readConstitution w) files
pure $ TxGovernanceActions w constitutions
proposals <- newExceptT $ sequence <$> mapM (readProposal w) files
pure $ TxGovernanceActions w proposals

readConstitution
readProposal
:: ConwayEraOnwards era
-> NewConstitutionFile In
-> ProposalFile In
-> IO (Either ConstitutionError (Proposal era))
readConstitution w fp =
readProposal w fp =
first ConstitutionErrorFile
<$> conwayEraOnwardsConstraints w (readFileTextEnvelope AsProposal fp)

Expand Down
3 changes: 3 additions & 0 deletions cardano-cli/src/Cardano/CLI/Types/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module Cardano.CLI.Types.Common
, ParserFileDirection (..)
, IdOutputFormat (..)
, PrivKeyFile(..)
, ProposalFile
, ProtocolParamsFile(..)
, ReferenceScriptAnyEra (..)
, RequiredSigner (..)
Expand Down Expand Up @@ -270,6 +271,8 @@ instance Crypto.Crypto crypto => ToJSON (Params crypto) where

type SigningKeyFile = File (SigningKey ())

type ProposalFile = File ()

newtype UpdateProposalFile = UpdateProposalFile { unUpdateProposalFile :: FilePath }
deriving newtype (Eq, Show)

Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -2234,7 +2234,7 @@ Usage: cardano-cli legacy transaction build --socket-path SOCKET_PATH
]
[--update-proposal-file FILE]
[--vote-file FILE]
[--constitution-file FILE]
[--proposal-file FILE]
( --out-file FILE
| --calculate-plutus-script-cost FILE
)
Expand Down Expand Up @@ -3548,7 +3548,7 @@ Usage: cardano-cli transaction build --socket-path SOCKET_PATH
]
[--update-proposal-file FILE]
[--vote-file FILE]
[--constitution-file FILE]
[--proposal-file FILE]
( --out-file FILE
| --calculate-plutus-script-cost FILE
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Usage: cardano-cli legacy transaction build --socket-path SOCKET_PATH
]
[--update-proposal-file FILE]
[--vote-file FILE]
[--constitution-file FILE]
[--proposal-file FILE]
( --out-file FILE
| --calculate-plutus-script-cost FILE
)
Expand Down Expand Up @@ -400,7 +400,7 @@ Available options:
--update-proposal-file FILE
Filepath of the update proposal.
--vote-file FILE Filepath of the vote.
--constitution-file FILE Filepath of the constitution.
--proposal-file FILE Filepath of the proposal.
--out-file FILE Output filepath of the JSON TxBody.
--calculate-plutus-script-cost FILE
(File () Out) filepath of the script cost
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Usage: cardano-cli transaction build --socket-path SOCKET_PATH
]
[--update-proposal-file FILE]
[--vote-file FILE]
[--constitution-file FILE]
[--proposal-file FILE]
( --out-file FILE
| --calculate-plutus-script-cost FILE
)
Expand Down Expand Up @@ -393,7 +393,7 @@ Available options:
--update-proposal-file FILE
Filepath of the update proposal.
--vote-file FILE Filepath of the vote.
--constitution-file FILE Filepath of the constitution.
--proposal-file FILE Filepath of the proposal.
--out-file FILE Output filepath of the JSON TxBody.
--calculate-plutus-script-cost FILE
(File () Out) filepath of the script cost
Expand Down
Loading