-
Notifications
You must be signed in to change notification settings - Fork 19
Incorporate CIP-129 #1087
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
Merged
Merged
Incorporate CIP-129 #1087
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
daca467
Add Cardano.CLI.EraIndependent.Cip.Common
Jimbo4350 7ce5a5b
Add parsing options for cip-129
Jimbo4350 2052f6b
Add cip-129 command
Jimbo4350 7de8b7a
Add conversion functions and cip command run functions
Jimbo4350 ad54fb3
Replace IdOutputFormat with FormatHex and FormatBech32
Jimbo4350 1347d5a
Add read functions for committee hot keys, committee cold keys, dreps
Jimbo4350 be39835
Misc changes
Jimbo4350 8f29e3b
Update golden files
Jimbo4350 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
cardano-cli/src/Cardano/CLI/EraIndependent/Cip/Cip129/Command.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Cardano.CLI.EraIndependent.Cip.Cip129.Command | ||
( Cip129 (..) | ||
, renderCip129Command | ||
) | ||
where | ||
|
||
import Cardano.CLI.EraIndependent.Cip.Common | ||
|
||
import Data.Text (Text) | ||
|
||
data Cip129 | ||
= Cip129DRep Input Output | ||
| Cip129CommitteeHotKey Input Output | ||
| Cip129CommitteeColdKey Input Output | ||
| Cip129GovernanceAction Input Output | ||
|
||
renderCip129Command :: Cip129 -> Text | ||
renderCip129Command (Cip129DRep{}) = "cip-129 drep" | ||
renderCip129Command (Cip129CommitteeHotKey{}) = "cip-129 committee-hot-key" | ||
renderCip129Command (Cip129CommitteeColdKey{}) = "cip-129 committee-cold-key" | ||
renderCip129Command (Cip129GovernanceAction{}) = "cip-129 governance-action-id" |
63 changes: 63 additions & 0 deletions
63
cardano-cli/src/Cardano/CLI/EraIndependent/Cip/Cip129/Internal/Conversion.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
|
||
module Cardano.CLI.EraIndependent.Cip.Cip129.Internal.Conversion | ||
( encodeCip129DrepVerficationKeyText | ||
, encodeCip129CommitteeColdVerficationKeyText | ||
, encodeCip129CommitteeHotVerficationKeyText | ||
, encodeCip129GovernanceActionIdText | ||
) | ||
where | ||
|
||
import Cardano.Api.Ledger qualified as L | ||
import Cardano.Api.Shelley | ||
|
||
import Cardano.CLI.Read.Committee.ColdKey | ||
import Cardano.CLI.Read.Committee.HotKey | ||
import Cardano.CLI.Read.DRep | ||
|
||
import Data.Text | ||
|
||
encodeCip129DrepVerficationKeyText :: AnyDrepVerificationKey -> Text | ||
encodeCip129DrepVerficationKeyText = serialiseToBech32Cip129 . anyDrepVerificationKeyToCredential | ||
|
||
anyDrepVerificationKeyToCredential | ||
:: AnyDrepVerificationKey -> L.Credential L.DRepRole | ||
anyDrepVerificationKeyToCredential drepKey = | ||
case drepKey of | ||
AnyDrepVerificationKey vk -> | ||
let DRepKeyHash hash = verificationKeyHash vk | ||
in L.KeyHashObj hash | ||
AnyDrepExtendedVerificationKey vk -> | ||
let DRepExtendedKeyHash hash = verificationKeyHash vk | ||
in L.KeyHashObj hash | ||
|
||
encodeCip129CommitteeHotVerficationKeyText :: AnyCommitteeHotVerificationKey -> Text | ||
encodeCip129CommitteeHotVerficationKeyText = serialiseToBech32Cip129 . anyCommitteeHotVerificationKeyToCredential | ||
|
||
anyCommitteeHotVerificationKeyToCredential | ||
:: AnyCommitteeHotVerificationKey -> L.Credential L.HotCommitteeRole | ||
anyCommitteeHotVerificationKeyToCredential committeeHotKey = | ||
case committeeHotKey of | ||
AnyCommitteeHotVerificationKey vk -> | ||
let CommitteeHotKeyHash hash = verificationKeyHash vk | ||
in L.KeyHashObj hash | ||
AnyCommitteeHotExtendedVerificationKey vk -> | ||
let CommitteeHotExtendedKeyHash hash = verificationKeyHash vk | ||
in L.KeyHashObj hash | ||
|
||
encodeCip129CommitteeColdVerficationKeyText :: AnyCommitteeColdVerificationKey -> Text | ||
encodeCip129CommitteeColdVerficationKeyText = serialiseToBech32Cip129 . anyCommitteeColdVerificationKeyToCredential | ||
|
||
anyCommitteeColdVerificationKeyToCredential | ||
:: AnyCommitteeColdVerificationKey -> L.Credential L.ColdCommitteeRole | ||
anyCommitteeColdVerificationKeyToCredential committeeColdKey = | ||
case committeeColdKey of | ||
AnyCommitteeColdVerificationKey vk -> | ||
let CommitteeColdKeyHash hash = verificationKeyHash vk | ||
in L.KeyHashObj hash | ||
AnyCommitteeColdExtendedVerificationKey vk -> | ||
let CommitteeColdExtendedKeyHash hash = verificationKeyHash vk | ||
in L.KeyHashObj hash | ||
|
||
encodeCip129GovernanceActionIdText :: L.GovActionId -> Text | ||
encodeCip129GovernanceActionIdText = serialiseGovActionIdToBech32Cip129 |
93 changes: 93 additions & 0 deletions
93
cardano-cli/src/Cardano/CLI/EraIndependent/Cip/Cip129/Option.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
module Cardano.CLI.EraIndependent.Cip.Cip129.Option | ||
( pCip129 | ||
) | ||
where | ||
|
||
import Cardano.CLI.EraIndependent.Cip.Command | ||
import Cardano.CLI.EraIndependent.Cip.Common | ||
import Cardano.CLI.Parser | ||
|
||
import Data.Foldable | ||
import Options.Applicative qualified as Opt | ||
|
||
-- Add sub parsers | ||
pCip129 :: Opt.Parser CipFormatCmds | ||
pCip129 = | ||
Cip129 | ||
<$> asum | ||
[ Opt.hsubparser $ | ||
commandWithMetavar "drep" $ | ||
Opt.info pCip129Drep $ | ||
Opt.progDesc "Convert drep verification key to the cip-129 compliant format" | ||
, Opt.hsubparser $ | ||
commandWithMetavar "committee-hot-key" $ | ||
Opt.info pCip129CommitteeHotKey $ | ||
Opt.progDesc "Convert committee hot key to the cip-129 compliant format" | ||
, Opt.hsubparser $ | ||
commandWithMetavar "committee-cold-key" $ | ||
Opt.info pCip129CommitteeColdKey $ | ||
Opt.progDesc "Convert committee cold key to the cip-129 compliant format" | ||
, Opt.hsubparser $ | ||
commandWithMetavar "governance-action-id" $ | ||
Opt.info pCip129GovernanceAction $ | ||
Opt.progDesc "Convert governance action id to the cip-129 compliant format" | ||
] | ||
|
||
pCip129Drep :: Opt.Parser Cip129 | ||
pCip129Drep = | ||
Cip129DRep | ||
<$> pInput | ||
<*> pOutput | ||
where | ||
pInput = | ||
asum | ||
[ pInputFile "drep-file" "Input hex/bech32/text envelope drep file" | ||
, pInputHexText "drep-hex" "HEX" "Input hex encoded drep" | ||
, pInputBech32Text "drep-bech32" "BECH32" "Input bech32 encoded drep" | ||
] | ||
|
||
pCip129CommitteeHotKey :: Opt.Parser Cip129 | ||
pCip129CommitteeHotKey = | ||
Cip129CommitteeHotKey | ||
<$> pInput | ||
<*> pOutput | ||
where | ||
pInput = | ||
asum | ||
[ pInputFile "committee-hot-key-file" "Input hex/bech32/text envelope committee hot key file" | ||
, pInputHexText "committee-hot-key-hex" "HEX" "Input hex encoded committee hot key" | ||
, pInputBech32Text "committee-hot-key-bech32" "BECH32" "Input bech32 encoded committee hot key" | ||
] | ||
|
||
pCip129CommitteeColdKey :: Opt.Parser Cip129 | ||
pCip129CommitteeColdKey = | ||
Cip129CommitteeColdKey | ||
<$> pInput | ||
<*> pOutput | ||
where | ||
pInput = | ||
asum | ||
[ pInputFile "committee-cold-key-file" "Input hex/bech32/text envelope committee cold key file" | ||
, pInputHexText "committee-cold-key-hex" "HEX" "Input hex encoded committee cold key" | ||
, pInputBech32Text "committee-cold-key-bech32" "BECH32" "Input bech32 encoded committee cold key" | ||
] | ||
|
||
pCip129GovernanceAction :: Opt.Parser Cip129 | ||
pCip129GovernanceAction = | ||
Cip129GovernanceAction | ||
<$> pInput | ||
<*> pOutput | ||
where | ||
pInput = | ||
asum | ||
[ pInputFile "governance-action-file" "Input hex/bech32/text envelope governance action file" | ||
, pInputHexText "governance-action-hex" "HEX" "Input hex encoded governance action" | ||
, pInputBech32Text "governance-action-bech32" "BECH32" "Input bech32 encoded governance action" | ||
] | ||
|
||
pOutput :: Opt.Parser Output | ||
pOutput = | ||
asum | ||
[ pOutputFile "output-file" "Output file" | ||
, pOutputText "output-text" "Output text" | ||
] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.