Skip to content

Commit

Permalink
Merge pull request #174 from input-output-hk/nfrisby/preparing-8.3.0-pre
Browse files Browse the repository at this point in the history
Bump CHaP index in preparation for  8.3.0 pre
  • Loading branch information
disassembler authored Aug 23, 2023
2 parents eeacebe + cda202d commit 4589924
Show file tree
Hide file tree
Showing 39 changed files with 690 additions and 235 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

env:
# Modify this value to "invalidate" the cabal cache.
CABAL_CACHE_VERSION: "2023-08-14"
CABAL_CACHE_VERSION: "2023-08-23"

concurrency:
group: >
Expand Down
3 changes: 2 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repository cardano-haskell-packages
-- you need to run if you change them
index-state:
, hackage.haskell.org 2023-08-08T19:56:09Z
, cardano-haskell-packages 2023-08-15T15:38:21Z
, cardano-haskell-packages 2023-08-23T09:29:34Z

packages:
cardano-cli
Expand Down Expand Up @@ -43,3 +43,4 @@ write-ghc-environment-files: always
-- IMPORTANT
-- Do NOT add more source-repository-package stanzas here unless they are strictly
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.

12 changes: 6 additions & 6 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ library
, binary
, bytestring
, canonical-json
, cardano-api ^>= 8.14
, cardano-api ^>= 8.16
, cardano-binary
, cardano-crypto
, cardano-crypto-class >= 2.1.1
, cardano-crypto-class ^>= 2.1.2
, cardano-crypto-wrapper ^>= 1.5
, cardano-data >= 1.0
, cardano-git-rev
Expand Down Expand Up @@ -200,7 +200,7 @@ library
, network
, optparse-applicative-fork
, ouroboros-consensus >= 0.9
, ouroboros-consensus-cardano >= 0.7
, ouroboros-consensus-cardano >= 0.8
, ouroboros-consensus-protocol >= 0.5.0.4
, ouroboros-network-api
, ouroboros-network-protocols
Expand All @@ -226,7 +226,7 @@ executable cardano-cli
ghc-options: -threaded -rtsopts "-with-rtsopts=-T"

build-depends: cardano-cli
, cardano-crypto-class ^>= 2.1
, cardano-crypto-class ^>= 2.1.2
, optparse-applicative-fork
, transformers-except

Expand Down Expand Up @@ -258,7 +258,7 @@ test-suite cardano-cli-test
, base16-bytestring
, bech32 >= 1.1.0
, bytestring
, cardano-api:{cardano-api, internal} ^>= 8.14
, cardano-api:{cardano-api, internal} ^>= 8.16
, cardano-api-gen ^>= 8.1.1.0
, cardano-cli
, cardano-cli:cardano-cli-test-lib
Expand Down Expand Up @@ -302,7 +302,7 @@ test-suite cardano-cli-golden
build-depends: aeson >= 1.5.6.0
, base16-bytestring
, bytestring
, cardano-api:{cardano-api, gen} ^>= 8.14
, cardano-api:{cardano-api, gen} ^>= 8.16
, cardano-binary
, cardano-cli
, cardano-cli:cardano-cli-test-lib
Expand Down
79 changes: 57 additions & 22 deletions cardano-cli/src/Cardano/CLI/Commands/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
module Cardano.CLI.Commands.Governance where

import Cardano.Api
import qualified Cardano.Api.Ledger as Ledger
import Cardano.Api.Shelley

import Cardano.CLI.Types.Common
Expand All @@ -16,74 +17,108 @@ import Control.Monad.Trans.Except (ExceptT)
import Control.Monad.Trans.Except.Extra (firstExceptT, hoistEither, newExceptT)
import Data.Bifunctor
import qualified Data.ByteString as BS
import Data.Text (Text)
import qualified Data.Text.Encoding as Text
import Data.Word

runGovernanceCreateVoteCmd
:: AnyShelleyBasedEra
-> Vote
-> VType
-> TxIn
-> (TxId, Word32)
-> VerificationKeyOrFile StakePoolKey
-> VoteFile Out
-> ExceptT GovernanceCmdError IO ()
runGovernanceCreateVoteCmd anyEra vChoice vType govActionTxIn votingStakeCred oFp = do
runGovernanceCreateVoteCmd anyEra vChoice vType (govActionTxId, govActionIndex) votingStakeCred oFp = do
AnyShelleyBasedEra sbe <- pure anyEra
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 govActIdentifier = makeGoveranceActionId sbe govActionTxIn
voteProcedure = createVotingProcedure sbe vChoice (VoterCommittee votingCred) govActIdentifier
firstExceptT WriteFileError . newExceptT $ shelleyBasedEraConstraints sbe $ writeFileTextEnvelope oFp Nothing voteProcedure
let voter = VoterCommittee votingCred
govActIdentifier = shelleyBasedEraConstraints sbe $ createGovernanceActionId govActionTxId govActionIndex
voteProcedure = createVotingProcedure sbe vChoice Nothing
votingEntry = VotingEntry { votingEntryVoter = voter
, votingEntryGovActionId = GovernanceActionId govActIdentifier
, votingEntryVotingProcedure = voteProcedure
}
firstExceptT WriteFileError . newExceptT $ shelleyBasedEraConstraints sbe $ writeFileTextEnvelope oFp Nothing votingEntry

VDR -> do
votingCred <- hoistEither $ first VotingCredentialDecodeGovCmdEror $ toVotingCredential sbe vStakeCred
let govActIdentifier = makeGoveranceActionId sbe govActionTxIn
voteProcedure = createVotingProcedure sbe vChoice (VoterDRep votingCred) govActIdentifier
firstExceptT WriteFileError . newExceptT $ shelleyBasedEraConstraints sbe $ writeFileTextEnvelope oFp Nothing voteProcedure
let voter = VoterDRep votingCred
govActIdentifier = shelleyBasedEraConstraints sbe $ createGovernanceActionId govActionTxId govActionIndex
voteProcedure = createVotingProcedure sbe vChoice Nothing
votingEntry = VotingEntry { votingEntryVoter = voter
, votingEntryGovActionId = GovernanceActionId govActIdentifier
, votingEntryVotingProcedure = voteProcedure
}
firstExceptT WriteFileError . newExceptT $ shelleyBasedEraConstraints sbe $ writeFileTextEnvelope oFp Nothing votingEntry

VSP -> do
let govActIdentifier = makeGoveranceActionId sbe govActionTxIn
voteProcedure = createVotingProcedure sbe vChoice (VoterSpo stakePoolKeyHash) govActIdentifier
firstExceptT WriteFileError . newExceptT $ shelleyBasedEraConstraints sbe $ writeFileTextEnvelope oFp Nothing voteProcedure
let voter = VoterSpo stakePoolKeyHash
govActIdentifier = shelleyBasedEraConstraints sbe $ createGovernanceActionId govActionTxId govActionIndex
voteProcedure = createVotingProcedure sbe vChoice Nothing
votingEntry = VotingEntry { votingEntryVoter = voter
, votingEntryGovActionId = GovernanceActionId govActIdentifier
, votingEntryVotingProcedure = voteProcedure
}
firstExceptT WriteFileError . newExceptT $ shelleyBasedEraConstraints sbe $ writeFileTextEnvelope oFp Nothing votingEntry


runGovernanceNewConstitutionCmd
:: AnyShelleyBasedEra
:: Ledger.Network
-> AnyShelleyBasedEra
-> Lovelace
-> VerificationKeyOrFile StakePoolKey
-> Maybe (TxId, Word32)
-> (Ledger.Url, Text)
-> Constitution
-> NewConstitutionFile Out
-> ExceptT GovernanceCmdError IO ()
runGovernanceNewConstitutionCmd sbe deposit stakeVoteCred constitution oFp = do
runGovernanceNewConstitutionCmd network sbe deposit stakeVoteCred mPrevGovAct propAnchor constitution oFp = do
vStakePoolKeyHash
<- fmap (verificationKeyHash . castVerificationKey)
<$> firstExceptT ReadFileError . newExceptT
$ readVerificationKeyOrFile AsStakePoolKey stakeVoteCred
case constitution of
ConstitutionFromFile fp -> do
ConstitutionFromFile url fp -> do
cBs <- liftIO $ BS.readFile $ unFile fp
_utf8EncodedText <- firstExceptT NonUtf8EncodedConstitution . hoistEither $ Text.decodeUtf8' cBs
let govAct = ProposeNewConstitution cBs
runGovernanceCreateActionCmd sbe deposit vStakePoolKeyHash govAct oFp
let prevGovActId = Ledger.maybeToStrictMaybe $ uncurry createPreviousGovernanceActionId <$> mPrevGovAct
govAct = ProposeNewConstitution
prevGovActId
(createAnchor url cBs) -- TODO: Conway era - this is wrong, create `AnchorData` then hash that with hashAnchorData
runGovernanceCreateActionCmd network sbe deposit vStakePoolKeyHash propAnchor govAct oFp

ConstitutionFromText c -> do
ConstitutionFromText url c -> do
let constitBs = Text.encodeUtf8 c
govAct = ProposeNewConstitution constitBs
runGovernanceCreateActionCmd sbe deposit vStakePoolKeyHash govAct oFp
prevGovActId = Ledger.maybeToStrictMaybe $ uncurry createPreviousGovernanceActionId <$> mPrevGovAct
govAct = ProposeNewConstitution
prevGovActId
(createAnchor url constitBs)
runGovernanceCreateActionCmd network sbe deposit vStakePoolKeyHash propAnchor govAct oFp

runGovernanceCreateActionCmd
:: AnyShelleyBasedEra
:: Ledger.Network
-> AnyShelleyBasedEra
-> Lovelace
-> Hash StakeKey
-> (Ledger.Url, Text)
-> GovernanceAction
-> File a Out
-> ExceptT GovernanceCmdError IO ()
runGovernanceCreateActionCmd anyEra deposit depositReturnAddr govAction oFp = do
runGovernanceCreateActionCmd network anyEra deposit depositReturnAddr propAnchor govAction oFp = do
AnyShelleyBasedEra sbe <- pure anyEra
let proposal = createProposalProcedure sbe deposit depositReturnAddr govAction
let proposal = createProposalProcedure
sbe
network
deposit
depositReturnAddr
govAction
(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 @@ -14,9 +14,10 @@ module Cardano.CLI.EraBased.Commands.Governance.Actions
) where

import Cardano.Api
import qualified Cardano.Api.Ledger as Ledger
import Cardano.Api.Shelley

import Cardano.CLI.Types.Common
import Cardano.CLI.Types.Common (Constitution, VerificationKeyFile)
import Cardano.CLI.Types.Key

import Data.Text (Text)
Expand Down Expand Up @@ -49,36 +50,45 @@ data GovernanceActionCmds era

data EraBasedNewCommittee
= EraBasedNewCommittee
{ ebDeposit :: Lovelace
{ ebNetwork :: Ledger.Network
, ebDeposit :: Lovelace
, ebReturnAddress :: AnyStakeIdentifier
, ebPropAnchor :: (Ledger.Url, Text)
, ebOldCommittee :: [AnyStakeIdentifier]
, ebNewCommittee :: [(AnyStakeIdentifier, EpochNo)]
, ebRequiredQuorum :: Rational
, ebPreviousGovActionId :: TxIn
, ebPreviousGovActionId :: Maybe (TxId, Word32)
, ebFilePath :: File () Out
} deriving Show

data EraBasedNewConstitution
= EraBasedNewConstitution
{ encDeposit :: Lovelace
{ encNetwork :: Ledger.Network
, encDeposit :: Lovelace
, encStakeCredential :: AnyStakeIdentifier
, encPrevGovActId :: Maybe (TxId, Word32)
, encPropAnchor :: (Ledger.Url, Text)
, encConstitution :: Constitution
, encFilePath :: File () Out
} deriving Show

data EraBasedNoConfidence
= EraBasedNoConfidence
{ ncDeposit :: Lovelace
{ ncNetwork :: Ledger.Network
, ncDeposit :: Lovelace
, ncStakeCredential :: AnyStakeIdentifier
, ncProposalAnchor :: (Ledger.Url, Text)
, ncGovAct :: TxId
, ncGovActIndex :: Word32
, ncFilePath :: File () Out
} deriving Show

data EraBasedTreasuryWithdrawal where
EraBasedTreasuryWithdrawal
:: Lovelace -- ^ Deposit
:: Ledger.Network
-> Lovelace -- ^ Deposit
-> AnyStakeIdentifier -- ^ Return address
-> (Ledger.Url, Text) -- ^ Proposal anchor
-> [(AnyStakeIdentifier, Lovelace)]
-> File () Out
-> EraBasedTreasuryWithdrawal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ module Cardano.CLI.EraBased.Commands.Governance.Vote
, renderGovernanceVoteCmds
) where

import Cardano.Api

import Cardano.CLI.Types.Governance

import Data.Text (Text)

data GovernanceVoteCmds era
newtype GovernanceVoteCmds era
= GovernanceVoteCreateCmd
AnyVote
(File () Out)

renderGovernanceVoteCmds :: ()
=> GovernanceVoteCmds era
Expand Down
Loading

0 comments on commit 4589924

Please sign in to comment.