diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs index e5b93d1d76..ff01ddcf0e 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs @@ -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 diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index 55de5b44d0..19487f995f 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -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 diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs index e67f2a126d..b4a7453a73 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs @@ -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." diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs index 7ac56b078b..ea6895e9c6 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs @@ -146,7 +146,7 @@ runGovernanceActionCreateConstitutionCmd , Cmd.proposalUrl , Cmd.proposalHash , Cmd.constitutionUrl - , Cmd.constitutionHashSource + , Cmd.constitutionHash , Cmd.outFile } = do @@ -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 diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs index 3b7059da0b..9bc61d6816 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs @@ -29,7 +29,11 @@ hprop_golden_governance_action_create_constitution = proposalHash <- execCardanoCLI [ "conway", "governance", "hash" - , "--text", "whatever "] + , "--text", "whatever"] + + constitutionHash <- execCardanoCLI + [ "conway", "governance", "hash" + , "--text", "something else"] void $ execCardanoCLI [ "conway", "governance", "action", "create-constitution" @@ -39,8 +43,8 @@ hprop_golden_governance_action_create_constitution = , "--governance-action-deposit", "10" , "--stake-verification-key-file", stakeAddressVKeyFile , "--out-file", actionFile - , "--constitution-anchor-url", "constitution-dummy-url" - , "--constitution-anchor-metadata", "This is a test constitution." + , "--constitution-url", "constitution-dummy-url" + , "--constitution-hash", constitutionHash ] goldenActionFile <- H.note "test/cardano-cli-golden/files/golden/governance/action/create-constitution-for-stake-address.action.golden" @@ -67,6 +71,11 @@ hprop_golden_conway_governance_action_view_constitution_json = proposalHash <- H.readFile hashFile + constitutionHash <- execCardanoCLI + [ "conway", "governance", "hash" + , "--text", "nonAsciiInput: 你好 and some more: こんにちは" + ] + void $ execCardanoCLI [ "conway", "governance", "action", "create-constitution" , "--mainnet" @@ -75,8 +84,8 @@ hprop_golden_conway_governance_action_view_constitution_json = , "--governance-action-deposit", "10" , "--stake-verification-key-file", stakeAddressVKeyFile , "--out-file", actionFile - , "--constitution-anchor-url", "constitution-dummy-url" - , "--constitution-anchor-metadata", "This is a test constitution." + , "--constitution-url", "http://my-great-constitution.rocks" + , "--constitution-hash", constitutionHash ] goldenActionViewFile <- H.note "test/cardano-cli-golden/files/golden/governance/action/view/create-constitution.action.view" diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/action/view/create-constitution.action.view b/cardano-cli/test/cardano-cli-golden/files/golden/governance/action/view/create-constitution.action.view index 0a21699f6f..2dcdf99ead 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/governance/action/view/create-constitution.action.view +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/action/view/create-constitution.action.view @@ -9,8 +9,8 @@ null, { "anchor": { - "dataHash": "42cb2e410023679943d26c23ce2b5046eb7dfc5883c69fb91cc8a3c9c9a99a99", - "url": "constitution-dummy-url" + "dataHash": "913844423a72d4ff4cffe1ca2bed8e7f354dba7563df9e630e5b6a86fa72659a", + "url": "http://my-great-constitution.rocks" } } ], diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli index 06ad51b7b7..d46937f2f3 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -5923,11 +5923,8 @@ Usage: cardano-cli conway governance action create-constitution --governance-action-index WORD32] --anchor-url TEXT --anchor-data-hash HASH - --constitution-anchor-url TEXT - ( --constitution-anchor-metadata TEXT - | --constitution-anchor-metadata-file FILE - | --constitution-anchor-metadata-hash HASH - ) + --constitution-url TEXT + --constitution-hash HASH --out-file FILE Create a constitution. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-constitution.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-constitution.cli index bc5ea30913..b2547834a2 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-constitution.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-constitution.cli @@ -11,11 +11,8 @@ Usage: cardano-cli conway governance action create-constitution --governance-action-index WORD32] --anchor-url TEXT --anchor-data-hash HASH - --constitution-anchor-url TEXT - ( --constitution-anchor-metadata TEXT - | --constitution-anchor-metadata-file FILE - | --constitution-anchor-metadata-hash HASH - ) + --constitution-url TEXT + --constitution-hash HASH --out-file FILE Create a constitution. @@ -37,13 +34,8 @@ Available options: --anchor-url TEXT Anchor URL --anchor-data-hash HASH Proposal anchor data hash (obtain it with "cardano-cli conway governance hash ...") - --constitution-anchor-url TEXT - Constitution anchor URL. - --constitution-anchor-metadata TEXT - Constitution anchor contents as UTF-8 encoded text. - --constitution-anchor-metadata-file FILE - Constitution anchor contents as a text file. - --constitution-anchor-metadata-hash HASH - Hash of the constitution anchor data. + --constitution-url TEXT Constitution URL. + --constitution-hash HASH Hash of the constitution data (obtain it with + "cardano-cli conway governance hash ..."). --out-file FILE Output filepath of the constitution. -h,--help Show this help text