diff --git a/cardano-cli/src/Cardano/CLI/Commands/Governance.hs b/cardano-cli/src/Cardano/CLI/Commands/Governance.hs index 998c705e96..bcfeb4a9f1 100644 --- a/cardano-cli/src/Cardano/CLI/Commands/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/Commands/Governance.hs @@ -199,7 +199,7 @@ runGovernanceCreateActionCmd network anyEra deposit depositReturnAddr govAction deposit depositReturnAddr govAction - (error "Current proposal Anchor") + (uncurry createAnchor (fmap Text.encodeUtf8 propAnchor)) firstExceptT WriteFileError . newExceptT $ shelleyBasedEraConstraints sbe diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs index 1b95697d76..c9b4b0b6ea 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs @@ -56,7 +56,7 @@ data EraBasedNewCommittee , ebOldCommittee :: [AnyStakeIdentifier] , ebNewCommittee :: [(AnyStakeIdentifier, EpochNo)] , ebRequiredQuorum :: Rational - , ebPreviousGovActionId :: TxIn + , ebPreviousGovActionId :: Maybe (TxId, Word32) , ebFilePath :: File () Out } deriving Show @@ -75,6 +75,7 @@ data EraBasedNoConfidence { ncNetwork :: Ledger.Network , ncDeposit :: Lovelace , ncStakeCredential :: AnyStakeIdentifier + , ncProposalAnchor :: (Ledger.Url, Text) , ncGovAct :: TxId , ncGovActIndex :: Word32 , ncFilePath :: File () Out diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index 8c14e7d671..361b958880 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -707,24 +707,24 @@ pConstitution :: Parser Constitution pConstitution = asum [ ConstitutionFromText - <$> pUrl + <$> pUrl "Constitution URL." <*> Opt.strOption (mconcat [ Opt.long "constitution" , Opt.metavar "TEXT" , Opt.help "Input constitution as UTF-8 encoded text." ]) , ConstitutionFromFile - <$> pUrl + <$> pUrl "Constitution URL." <*> pFileInDirection "constitution-file" "Input constitution as a text file." ] -pUrl :: Parser Ledger.Url -pUrl = fromMaybe (error "Url longer than 64 bytes") +pUrl :: String -> Parser Ledger.Url +pUrl h = fromMaybe (error "Url longer than 64 bytes") . Ledger.textToUrl <$> Opt.strOption (mconcat [ Opt.long "url" , Opt.metavar "TEXT" - , Opt.help "Input constitution as UTF-8 encoded text." + , Opt.help h ]) pGovActionDeposit :: Parser Lovelace @@ -2607,6 +2607,9 @@ pGoveranceActionIdentifier h = pVotingCredential :: Parser (VerificationKeyOrFile StakePoolKey) pVotingCredential = pStakePoolVerificationKeyOrFile +pProposalAnchor :: Parser (Ledger.Url, Text) +pProposalAnchor = undefined + pPreviousGovernanceAction :: Parser (Maybe (TxId, Word32)) pPreviousGovernanceAction = optional $ diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs index 61881f1e32..c6d69c9b4c 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs @@ -56,6 +56,7 @@ pGovernanceActionNewConstitution = <*> pGovActionDeposit <*> pAnyStakeIdentifier <*> pPreviousGovernanceAction + <*> pProposalAnchor <*> pConstitution <*> pFileOutDirection "out-file" "Output filepath of the constitution." @@ -77,10 +78,11 @@ pEraBasedNewCommittee = <$> pNetwork <*> pGovActionDeposit <*> pAnyStakeIdentifier + <*> pProposalAnchor <*> many pAnyStakeIdentifier <*> many ((,) <$> pAnyStakeIdentifier <*> pEpochNo "Committee member expiry epoch") <*> pRational "quorum" "Quorum of the committee that is necessary for a successful vote." - <*> pGoveranceActionIdentifier "Previous governance action id of `NewCommittee` or `NoConfidence` type" + <*> pPreviousGovernanceAction <*> pOutputFile @@ -99,6 +101,7 @@ pGovernanceActionNoConfidence = <$> pNetwork <*> pGovActionDeposit <*> pAnyStakeIdentifier + <*> pProposalAnchor <*> pTxId "governance-action-tx-id" "Previous txid of `NoConfidence` or `NewCommittee` governance action." <*> pWord32 "goverenance-action-index" "Previous tx's governance action index of `NoConfidence` or `NewCommittee` governance action." <*> pFileOutDirection "out-file" "Output filepath of the no confidence proposal." @@ -298,6 +301,7 @@ pGovernanceActionTreasuryWithdrawal = <$> pNetwork <*> pGovActionDeposit <*> pAnyStakeIdentifier + <*> pProposalAnchor <*> many ((,) <$> pAnyStakeIdentifier <*> pTransferAmt) <*> pFileOutDirection "out-file" "Output filepath of the treasury withdrawal." diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs index a01fd53ed6..09e4cff0bf 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs @@ -80,7 +80,7 @@ runGovernanceActionCreateNoConfidence :: ConwayEraOnwards era -> EraBasedNoConfidence -> ExceptT GovernanceActionsError IO () -runGovernanceActionCreateNoConfidence cOn (EraBasedNoConfidence network deposit returnAddr _txid _ind outFp) = do +runGovernanceActionCreateNoConfidence cOn (EraBasedNoConfidence network deposit returnAddr propAnchor txid ind outFp) = do returnKeyHash <- readStakeKeyHash returnAddr let sbe = conwayEraOnwardsToShelleyBasedEra cOn -- TODO: Left off here, fix type errors and update cardano-api with helper functions @@ -89,8 +89,8 @@ runGovernanceActionCreateNoConfidence cOn (EraBasedNoConfidence network deposit network deposit returnKeyHash - (MotionOfNoConfidence (error "Previous governance action id")) - (error "Current proposal Anchor") + (MotionOfNoConfidence . Ledger.SJust $ createPreviousGovernanceActionId txid ind) + (uncurry createAnchor (fmap Text.encodeUtf8 propAnchor)) firstExceptT GovernanceActionsCmdWriteFileError . newExceptT $ conwayEraOnwardsConstraints cOn @@ -119,7 +119,7 @@ runGovernanceActionCreateConstitution cOn (EraBasedNewConstitution network depos deposit stakeKeyHash govAct - (error "Current proposal Anchor") + (uncurry createAnchor (fmap Text.encodeUtf8 propAnchor)) firstExceptT GovernanceActionsCmdWriteFileError . newExceptT $ conwayEraOnwardsConstraints cOn @@ -138,7 +138,7 @@ runGovernanceActionCreateConstitution cOn (EraBasedNewConstitution network depos deposit stakeKeyHash govAct - (error "Current proposal Anchor") + (uncurry createAnchor (fmap Text.encodeUtf8 propAnchor)) firstExceptT GovernanceActionsCmdWriteFileError . newExceptT $ conwayEraOnwardsConstraints cOn @@ -150,9 +150,9 @@ runGovernanceActionCreateNewCommittee :: ConwayEraOnwards era -> EraBasedNewCommittee -> ExceptT GovernanceActionsError IO () -runGovernanceActionCreateNewCommittee cOn (EraBasedNewCommittee deposit retAddr old new q _prevActId oFp) = do +runGovernanceActionCreateNewCommittee cOn (EraBasedNewCommittee network deposit retAddr old new q prevActId oFp) = do let sbe = conwayEraOnwardsToShelleyBasedEra cOn -- TODO: Conway era - update vote creation related function to take ConwayEraOnwards - _govActIdentifier = makeGoveranceActionId sbe (error "TxId") (error "Gov action index") + govActIdentifier = Ledger.maybeToStrictMaybe $ uncurry createPreviousGovernanceActionId <$> prevActId quorumRational = toRational q _oldCommitteeKeyHashes <- mapM readStakeKeyHash old @@ -161,17 +161,17 @@ runGovernanceActionCreateNewCommittee cOn (EraBasedNewCommittee deposit retAddr returnKeyHash <- readStakeKeyHash retAddr let proposeNewCommittee = ProposeNewCommittee - (error "Previous governance action id") + govActIdentifier (error "old committee key hashes" ) (error "new committee key hashes with expiration epochs") quorumRational proposal = createProposalProcedure sbe - (error "Network") + network deposit returnKeyHash proposeNewCommittee - (error "Current proposal Anchor") + (uncurry createAnchor (fmap Text.encodeUtf8 propAnchor)) firstExceptT GovernanceActionsCmdWriteFileError . newExceptT $ conwayEraOnwardsConstraints cOn @@ -230,7 +230,7 @@ runGovernanceActionTreasuryWithdrawal cOn (EraBasedTreasuryWithdrawal network de deposit returnKeyHash (TreasuryWithdrawal (error "[(Network, StakeCredential, Lovelace)]")) - (error "Current proposal Anchor") + (uncurry createAnchor (fmap Text.encodeUtf8 propAnchor)) firstExceptT GovernanceActionsCmdWriteFileError . newExceptT $ conwayEraOnwardsConstraints cOn diff --git a/cardano-cli/src/Cardano/CLI/Types/Governance.hs b/cardano-cli/src/Cardano/CLI/Types/Governance.hs index 289da586f0..4f03c1338a 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Governance.hs @@ -10,6 +10,7 @@ import Cardano.Api.Shelley import Cardano.CLI.Types.Common import Cardano.CLI.Types.Key (VerificationKeyOrFile, VerificationKeyOrHashOrFile) +import Data.Text (Text) import Data.Word type VoteFile = File ConwayVote @@ -33,6 +34,7 @@ data NewConstitution , ncDeposit :: Lovelace , ncVotingStakeCredential :: VerificationKeyOrFile StakePoolKey , ncPrevGovActIf :: Maybe (TxId, Word32) + , ncPropAnchor :: (Ledger.Url, Text) , ncConstitution :: Constitution , ncFilePath :: NewConstitutionFile Out } deriving Show