-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
conway governance hash -> conway hash
- Loading branch information
Showing
15 changed files
with
186 additions
and
195 deletions.
There are no files selected for viewing
This file contains 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 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 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
47 changes: 0 additions & 47 deletions
47
cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Hash.hs
This file was deleted.
Oops, something went wrong.
This file contains 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,47 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DuplicateRecordFields #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
|
||
module Cardano.CLI.EraBased.Commands.Hash | ||
( | ||
HashCmds (..), | ||
HashAnchorDataCmdArgs (..), | ||
HashScriptCmdArgs (..), | ||
AnchorDataHashSource (..), | ||
renderHashCmds | ||
) where | ||
|
||
import Cardano.Api | ||
|
||
import Cardano.CLI.Types.Common | ||
|
||
import Data.Text (Text) | ||
|
||
data HashCmds era | ||
= HashAnchorDataCmd !(HashAnchorDataCmdArgs era) | ||
| HashScriptCmd !(HashScriptCmdArgs era) | ||
|
||
data HashAnchorDataCmdArgs era | ||
= HashAnchorDataCmdArgs { | ||
eon :: !(ConwayEraOnwards era) | ||
, toHash :: !AnchorDataHashSource | ||
, moutFile :: !(Maybe (File () Out)) -- ^ The output file to which the hash is written | ||
} deriving Show | ||
|
||
data AnchorDataHashSource | ||
= AnchorDataHashSourceBinaryFile (File ProposalBinary In) | ||
| AnchorDataHashSourceTextFile (File ProposalText In) | ||
| AnchorDataHashSourceText Text | ||
deriving Show | ||
|
||
data HashScriptCmdArgs era | ||
= HashScriptCmdArgs { | ||
eon :: !(ConwayEraOnwards era) | ||
, toHash :: !ScriptFile | ||
, moutFile :: !(Maybe (File () Out)) -- ^ The output file to which the hash is written | ||
} deriving Show | ||
|
||
renderHashCmds :: HashCmds era -> Text | ||
renderHashCmds = \case | ||
HashAnchorDataCmd {} -> "hash anchor-data" | ||
HashScriptCmd {} -> "hash script" |
This file contains 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
54 changes: 27 additions & 27 deletions
54
...o/CLI/EraBased/Options/Governance/Hash.hs → .../src/Cardano/CLI/EraBased/Options/Hash.hs
This file contains 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 |
---|---|---|
@@ -1,76 +1,76 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE GADTs #-} | ||
|
||
module Cardano.CLI.EraBased.Options.Governance.Hash | ||
module Cardano.CLI.EraBased.Options.Hash | ||
( | ||
pGovernanceHashCmds, | ||
pHashCmds, | ||
) where | ||
|
||
import Cardano.Api | ||
|
||
import qualified Cardano.CLI.EraBased.Commands.Governance.Hash as Cmd | ||
import qualified Cardano.CLI.EraBased.Commands.Hash as Cmd | ||
import Cardano.CLI.EraBased.Options.Common | ||
|
||
import Data.Foldable | ||
import Options.Applicative | ||
import qualified Options.Applicative as Opt | ||
|
||
pGovernanceHashCmds | ||
pHashCmds | ||
:: CardanoEra era | ||
-> Maybe (Parser (Cmd.GovernanceHashCmds era)) | ||
pGovernanceHashCmds era = | ||
-> Maybe (Parser (Cmd.HashCmds era)) | ||
pHashCmds era = | ||
subInfoParser "hash" | ||
( Opt.progDesc | ||
$ mconcat | ||
[ "Compute the hash to pass to the various --*-hash arguments of governance commands." | ||
[ "Compute the hash to pass to the various --*-hash arguments of commands." | ||
] | ||
) | ||
[ pGovernanceHashAnchorDataCmd era | ||
, pGovernanceHashScriptCmd era | ||
[ pHashAnchorDataCmd era | ||
, pHashScriptCmd era | ||
] | ||
|
||
pGovernanceHashAnchorDataCmd :: () | ||
pHashAnchorDataCmd :: () | ||
=> CardanoEra era | ||
-> Maybe (Parser (Cmd.GovernanceHashCmds era)) | ||
pGovernanceHashAnchorDataCmd era = do | ||
-> Maybe (Parser (Cmd.HashCmds era)) | ||
pHashAnchorDataCmd era = do | ||
eon <- forEraMaybeEon era | ||
return | ||
$ subParser "anchor-data" | ||
$ Opt.info | ||
( fmap Cmd.GovernanceHashAnchorDataCmd | ||
(Cmd.GovernanceHashAnchorDataCmdArgs eon | ||
<$> pGovernanceAnchorDataHashSource | ||
( fmap Cmd.HashAnchorDataCmd | ||
(Cmd.HashAnchorDataCmdArgs eon | ||
<$> pAnchorDataHashSource | ||
<*> optional pOutputFile)) | ||
$ Opt.progDesc "Compute the hash of some anchor data (to then pass it to other governance commands)." | ||
$ Opt.progDesc "Compute the hash of some anchor data (to then pass it to other commands)." | ||
|
||
pGovernanceAnchorDataHashSource :: Parser Cmd.GovernanceAnchorDataHashSource | ||
pGovernanceAnchorDataHashSource = | ||
pAnchorDataHashSource :: Parser Cmd.AnchorDataHashSource | ||
pAnchorDataHashSource = | ||
asum | ||
[ | ||
Cmd.GovernanceAnchorDataHashSourceText | ||
Cmd.AnchorDataHashSourceText | ||
<$> Opt.strOption | ||
( mconcat | ||
[ Opt.long "text" | ||
, Opt.metavar "TEXT" | ||
, Opt.help "Text to hash as UTF-8" | ||
] | ||
) | ||
, Cmd.GovernanceAnchorDataHashSourceBinaryFile | ||
, Cmd.AnchorDataHashSourceBinaryFile | ||
<$> pFileInDirection "file-binary" "Binary file to hash" | ||
, Cmd.GovernanceAnchorDataHashSourceTextFile | ||
, Cmd.AnchorDataHashSourceTextFile | ||
<$> pFileInDirection "file-text" "Text file to hash" | ||
] | ||
|
||
pGovernanceHashScriptCmd :: () | ||
pHashScriptCmd :: () | ||
=> CardanoEra era | ||
-> Maybe (Parser (Cmd.GovernanceHashCmds era)) | ||
pGovernanceHashScriptCmd era = do | ||
-> Maybe (Parser (Cmd.HashCmds era)) | ||
pHashScriptCmd era = do | ||
eon <- forEraMaybeEon era | ||
return | ||
$ subParser "script" | ||
$ Opt.info | ||
( fmap Cmd.GovernanceHashScriptCmd | ||
(Cmd.GovernanceHashScriptCmdArgs eon | ||
( fmap Cmd.HashScriptCmd | ||
(Cmd.HashScriptCmdArgs eon | ||
<$> pScript | ||
<*> optional pOutputFile)) | ||
$ Opt.progDesc "Compute the hash of a script (to then pass it to other governance commands)." | ||
$ Opt.progDesc "Compute the hash of a script (to then pass it to other commands)." |
This file contains 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 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
Oops, something went wrong.