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

cardano-api-internal: ProposeNewCommittee: StakeKey -> CommitteeColdKey #264

Merged
Merged
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
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
smelc marked this conversation as resolved.
Show resolved Hide resolved
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have labelled this with TODO: Conway not a big deal though.