Skip to content

Commit

Permalink
create-constitution: align flags with #420
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed Nov 17, 2023
1 parent 4dcfd59 commit 734bca8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ data GovernanceActionCreateConstitutionCmdArgs era
, proposalUrl :: !ProposalUrl
, proposalHash :: !(Ledger.SafeHash Crypto.StandardCrypto Ledger.AnchorData)
, constitutionUrl :: !ConstitutionUrl
, constitutionHashSource :: !ConstitutionHashSource
, constitutionHash :: !(Ledger.SafeHash Crypto.StandardCrypto Ledger.AnchorData)
, outFile :: !(File () Out)
} deriving Show

Expand Down
23 changes: 3 additions & 20 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -875,31 +875,14 @@ catCommands = \case
pConstitutionUrl :: Parser ConstitutionUrl
pConstitutionUrl =
ConstitutionUrl
<$> pUrl "constitution-anchor-url" "Constitution anchor URL."

pConstitutionHashSource :: Parser ConstitutionHashSource
pConstitutionHashSource =
asum
[ ConstitutionHashSourceText
<$> Opt.strOption
( mconcat
[ Opt.long "constitution-anchor-metadata"
, Opt.metavar "TEXT"
, Opt.help "Constitution anchor contents as UTF-8 encoded text."
]
)
, ConstitutionHashSourceFile
<$> pFileInDirection "constitution-anchor-metadata-file" "Constitution anchor contents as a text file."
, ConstitutionHashSourceHash
<$> pConstitutionHash
]
<$> pUrl "constitution-url" "Constitution URL."

pConstitutionHash :: Parser (L.SafeHash Crypto.StandardCrypto L.AnchorData)
pConstitutionHash =
Opt.option readSafeHash $ mconcat
[ Opt.long "constitution-anchor-metadata-hash"
[ Opt.long "constitution-hash"
, Opt.metavar "HASH"
, Opt.help "Hash of the constitution anchor data."
, Opt.help "Hash of the constitution data (obtain it with \"cardano-cli conway governance hash ...\")."
]

pUrl :: String -> String -> Parser Ledger.Url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pGovernanceActionNewConstitutionCmd era = do
<*> pAnchorUrl
<*> pAnchorDataHash
<*> pConstitutionUrl
<*> pConstitutionHashSource
<*> pConstitutionHash
<*> pFileOutDirection "out-file" "Output filepath of the constitution."
)
$ Opt.progDesc "Create a constitution."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ runGovernanceActionCreateConstitutionCmd
, Cmd.proposalUrl
, Cmd.proposalHash
, Cmd.constitutionUrl
, Cmd.constitutionHashSource
, Cmd.constitutionHash
, Cmd.outFile
} = do

Expand All @@ -157,10 +157,6 @@ runGovernanceActionCreateConstitutionCmd
, Ledger.anchorDataHash = proposalHash
}

constitutionHash <-
constitutionHashSourceToHash constitutionHashSource
& firstExceptT GovernanceActionsCmdConstitutionError

let prevGovActId = Ledger.maybeToStrictMaybe $ uncurry createPreviousGovernanceActionId <$> mPrevGovernanceActionId
constitutionAnchor = Ledger.Anchor
{ Ledger.anchorUrl = unConstitutionUrl constitutionUrl
Expand Down

0 comments on commit 734bca8

Please sign in to comment.