Skip to content

Commit

Permalink
Updated types with current proposal anchor
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Aug 21, 2023
1 parent 59aadcf commit a92fb89
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 19 deletions.
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Commands/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ data EraBasedNewCommittee
, ebOldCommittee :: [AnyStakeIdentifier]
, ebNewCommittee :: [(AnyStakeIdentifier, EpochNo)]
, ebRequiredQuorum :: Rational
, ebPreviousGovActionId :: TxIn
, ebPreviousGovActionId :: Maybe (TxId, Word32)
, ebFilePath :: File () Out
} deriving Show

Expand All @@ -75,6 +75,7 @@ data EraBasedNoConfidence
{ ncNetwork :: Ledger.Network
, ncDeposit :: Lovelace
, ncStakeCredential :: AnyStakeIdentifier
, ncProposalAnchor :: (Ledger.Url, Text)
, ncGovAct :: TxId
, ncGovActIndex :: Word32
, ncFilePath :: File () Out
Expand Down
13 changes: 8 additions & 5 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 $
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pGovernanceActionNewConstitution =
<*> pGovActionDeposit
<*> pAnyStakeIdentifier
<*> pPreviousGovernanceAction
<*> pProposalAnchor
<*> pConstitution
<*> pFileOutDirection "out-file" "Output filepath of the constitution."

Expand All @@ -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


Expand All @@ -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."
Expand Down Expand Up @@ -298,6 +301,7 @@ pGovernanceActionTreasuryWithdrawal =
<$> pNetwork
<*> pGovActionDeposit
<*> pAnyStakeIdentifier
<*> pProposalAnchor
<*> many ((,) <$> pAnyStakeIdentifier <*> pTransferAmt)
<*> pFileOutDirection "out-file" "Output filepath of the treasury withdrawal."

Expand Down
22 changes: 11 additions & 11 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cardano-cli/src/Cardano/CLI/Types/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit a92fb89

Please sign in to comment.