Skip to content

Commit

Permalink
Merge pull request #264 from input-output-hk/smelc/new-committee-use-…
Browse files Browse the repository at this point in the history
…committee-cold-key-insteadof-stake-key

cardano-api-internal: ProposeNewCommittee: StakeKey -> CommitteeColdKey
  • Loading branch information
smelc authored Sep 25, 2023
2 parents db67e88 + 9a19558 commit ddd7627
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import Cardano.Ledger.Core (EraCrypto)
import qualified Cardano.Ledger.Core as Shelley
import qualified Cardano.Ledger.Credential as L
import Cardano.Ledger.Crypto (StandardCrypto)
import Cardano.Ledger.Keys (HasKeyRole (coerceKeyRole), KeyRole (ColdCommitteeRole))
import Cardano.Ledger.Keys (KeyRole (ColdCommitteeRole))

import Data.ByteString (ByteString)
import Data.Map.Strict (Map)
Expand All @@ -54,8 +54,8 @@ data GovernanceAction
(Ledger.Anchor StandardCrypto)
| ProposeNewCommittee
(StrictMaybe (Ledger.PrevGovActionId Ledger.CommitteePurpose StandardCrypto))
[Hash StakeKey] -- ^ Old constitutional committee
(Map (Hash StakeKey) EpochNo) -- ^ New committee members with epoch number when each of them expires
[Hash CommitteeColdKey] -- ^ Old constitutional committee
(Map (Hash CommitteeColdKey) EpochNo) -- ^ New committee members with epoch number when each of them expires
Rational -- ^ Quorum of the committee that is necessary for a successful vote
| InfoAct
| TreasuryWithdrawal [(Network, StakeCredential, Lovelace)]
Expand Down Expand Up @@ -224,12 +224,12 @@ createAnchor url anchorData =
-- TODO conversions that likely need to live elsewhere and may even deserve
-- additional wrapper types

toCommitteeMember :: Hash StakeKey -> L.Credential ColdCommitteeRole StandardCrypto
toCommitteeMember (StakeKeyHash keyhash) = coerceKeyRole $ L.KeyHashObj keyhash
toCommitteeMember :: Hash CommitteeColdKey -> L.Credential ColdCommitteeRole StandardCrypto
toCommitteeMember (CommitteeColdKeyHash keyhash) = L.KeyHashObj keyhash

fromCommitteeMember :: L.Credential ColdCommitteeRole StandardCrypto -> Hash StakeKey
fromCommitteeMember = (. coerceKeyRole) $ \case
L.KeyHashObj keyhash -> StakeKeyHash keyhash
fromCommitteeMember :: L.Credential ColdCommitteeRole StandardCrypto -> Hash CommitteeColdKey
fromCommitteeMember = \case
L.KeyHashObj keyhash -> CommitteeColdKeyHash keyhash
L.ScriptHashObj _scripthash -> error "TODO script committee members not yet supported"


0 comments on commit ddd7627

Please sign in to comment.