diff --git a/CODEOWNERS b/CODEOWNERS index 2d0efd6e8d..3eef494f96 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -21,5 +21,5 @@ README.* @input-output-hk/d *.nix @input-output-hk/core-tech-devx @input-output-hk/core-tech-release flake.lock @input-output-hk/core-tech-devx @input-output-hk/core-tech-release -.github/workflows @input-output-hk/core-tech-devx @input-output-hk/core-tech-release @input-output-hk/core-tech +.github/workflows @input-output-hk/core-tech-devx @input-output-hk/core-tech-release configuration/ @input-output-hk/core-tech-devx @input-output-hk/core-tech-release diff --git a/cabal.project b/cabal.project index 52f8d616cb..0981840564 100644 --- a/cabal.project +++ b/cabal.project @@ -14,7 +14,7 @@ repository cardano-haskell-packages -- you need to run if you change them index-state: , hackage.haskell.org 2023-08-08T19:56:09Z - , cardano-haskell-packages 2023-09-27T09:51:59Z + , cardano-haskell-packages 2023-10-05T18:49:55Z packages: cardano-cli diff --git a/cardano-cli/CHANGELOG.md b/cardano-cli/CHANGELOG.md index ff2f0d9434..30c0bd976d 100644 --- a/cardano-cli/CHANGELOG.md +++ b/cardano-cli/CHANGELOG.md @@ -1,5 +1,84 @@ # Changelog for cardano-cli +## 8.12.0.0 + +- Add support for committee hot key witnesses + (feature, compatible) + [PR 338](https://github.com/input-output-hk/cardano-cli/pull/338) + +- Make it possible to use cc hot keys for `conway governance vote create` + (feature, compatible) + [PR 337](https://github.com/input-output-hk/cardano-cli/pull/337) + +- Move files that are not golden files into `input` directory + (compatible, improvement) + [PR 327](https://github.com/input-output-hk/cardano-cli/pull/327) + +- create-poll, answer-poll, verify-poll: move to 'babbage governance' block + (breaking, improvement) + [PR 322](https://github.com/input-output-hk/cardano-cli/pull/322) + +## 8.11.0.0 + +- Fix missing redeemers in certificate delegation and deregistration + (bugfix) + [PR 306](https://github.com/input-output-hk/cardano-cli/pull/306) + +- Upgrade to `cardano-api-8.25.0.1` + (compatible, maintenance) + [PR 329](https://github.com/input-output-hk/cardano-cli/pull/329) + +- Update to cardano-api-8.24 + (feature) + [PR 324](https://github.com/input-output-hk/cardano-cli/pull/324) + +- Add Cold Committee Key text envelope + (bugfix) + [PR 323](https://github.com/input-output-hk/cardano-cli/pull/323) + +- Update to `cardano-api-8.23.1.0` + (feature, compatible) + [PR 320](https://github.com/input-output-hk/cardano-cli/pull/320) + +- Tidy up query command structure + (compatible, improvement) + [PR 318](https://github.com/input-output-hk/cardano-cli/pull/318) + +- - Remove SPO registration bits from drep registration-certificate command + - Remove drep command from eras before Conway + - Remove `AnyRegistrationTarget` + - Remove `RegistrationTarget` + (breaking, improvement) + [PR 309](https://github.com/input-output-hk/cardano-cli/pull/309) + +- Use `caseShelleyToBabbageOrConwayEraOnwards` from `cardano-api` + (compatible, improvement) + [PR 317](https://github.com/input-output-hk/cardano-cli/pull/317) + +- Remove redundant conversions in JSON friendly instances + (improvement) + [PR 280](https://github.com/input-output-hk/cardano-cli/pull/280) + +- Regularise era based command structure + (improvement) + [PR 279](https://github.com/input-output-hk/cardano-cli/pull/279) + +- Simplify era handling + (improvement) + [PR 277](https://github.com/input-output-hk/cardano-cli/pull/277) + +- A number of flags appeared in the parameters of new-committee multiple times, with the same long flag, making the parser break. This PR disambiguates the repeated occurences. + (breaking) + [PR 302](https://github.com/input-output-hk/cardano-cli/pull/302) + +- Implementation of the create-info command + (feature) + [PR 292](https://github.com/input-output-hk/cardano-cli/pull/292) + +- Update to the pre-commit script, so that it fails on hlint errors + (improvement) + [PR 296](https://github.com/input-output-hk/cardano-cli/pull/296) + ## 8.10.0.0 - Rename `SomeWitness` to `SomeSigningWitness`. Rename constructors to avoid name conflicts. Move to `Key` module. diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 962dbbaee2..ab43c9cce8 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -1,7 +1,7 @@ cabal-version: 3.4 name: cardano-cli -version: 8.10.0.0 +version: 8.12.0.0 synopsis: The Cardano command-line interface description: The Cardano command-line interface. copyright: 2020-2023 Input Output Global Inc (IOG). @@ -75,6 +75,7 @@ library Cardano.CLI.EraBased.Commands.Governance.Actions Cardano.CLI.EraBased.Commands.Governance.Committee Cardano.CLI.EraBased.Commands.Governance.DRep + Cardano.CLI.EraBased.Commands.Governance.Poll Cardano.CLI.EraBased.Commands.Governance.Query Cardano.CLI.EraBased.Commands.Governance.Vote Cardano.CLI.EraBased.Commands.Key @@ -91,6 +92,7 @@ library Cardano.CLI.EraBased.Options.Governance.Actions Cardano.CLI.EraBased.Options.Governance.Committee Cardano.CLI.EraBased.Options.Governance.DRep + Cardano.CLI.EraBased.Options.Governance.Poll Cardano.CLI.EraBased.Options.Governance.Query Cardano.CLI.EraBased.Options.Governance.Vote Cardano.CLI.EraBased.Options.Key @@ -108,6 +110,7 @@ library Cardano.CLI.EraBased.Run.Governance.Actions Cardano.CLI.EraBased.Run.Governance.Committee Cardano.CLI.EraBased.Run.Governance.DRep + Cardano.CLI.EraBased.Run.Governance.Poll Cardano.CLI.EraBased.Run.Governance.Query Cardano.CLI.EraBased.Run.Governance.Vote Cardano.CLI.EraBased.Run.Key @@ -200,7 +203,7 @@ library , binary , bytestring , canonical-json - , cardano-api ^>= 8.22 + , cardano-api ^>= 8.25.2.0 , cardano-binary , cardano-crypto , cardano-crypto-class ^>= 2.1.2 @@ -231,8 +234,8 @@ library , microlens , network , optparse-applicative-fork - , ouroboros-consensus >= 0.9 - , ouroboros-consensus-cardano >= 0.8 + , ouroboros-consensus >= 0.12 + , ouroboros-consensus-cardano >= 0.10 , ouroboros-consensus-protocol >= 0.5.0.4 , ouroboros-network-api , ouroboros-network-protocols @@ -271,7 +274,9 @@ library cardano-cli-test-lib , bytestring , cardano-api , cardano-cli + , directory , exceptions + , filepath , hedgehog , hedgehog-extras ^>= 0.4.7.0 , process @@ -361,6 +366,9 @@ test-suite cardano-cli-golden Test.Golden.Byron.UpdateProposal Test.Golden.Byron.Vote Test.Golden.Byron.Witness + Test.Golden.EraBased.Governance.AnswerPoll + Test.Golden.EraBased.Governance.CreatePoll + Test.Golden.EraBased.Governance.VerifyPoll Test.Golden.ErrorsSpec Test.Golden.Governance.Action Test.Golden.Governance.Committee @@ -376,9 +384,6 @@ test-suite cardano-cli-golden Test.Golden.Shelley.Genesis.KeyGenGenesis Test.Golden.Shelley.Genesis.KeyGenUtxo Test.Golden.Shelley.Genesis.KeyHash - Test.Golden.Shelley.Governance.AnswerPoll - Test.Golden.Shelley.Governance.CreatePoll - Test.Golden.Shelley.Governance.VerifyPoll Test.Golden.Shelley.Key.ConvertCardanoAddressKey Test.Golden.Shelley.Metadata.StakePoolMetadata Test.Golden.Shelley.MultiSig.Address diff --git a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs index 843f4cf8a9..1f4788ddcb 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs @@ -160,7 +160,7 @@ txSpendGenesisUTxOByronPBFT gc nId sk (ByronAddress bAddr) outs = do , txFee = TxFeeImplicit ByronEraOnlyByron , txValidityRange = ( TxValidityNoLowerBound - , TxValidityNoUpperBound ValidityNoUpperBoundInByronEra + , defaultTxValidityUpperBound ) , txMetadata = TxMetadataNone , txAuxScripts = TxAuxScriptsNone @@ -209,7 +209,7 @@ txSpendUTxOByronPBFT nId sk txIns outs = do , txFee = TxFeeImplicit ByronEraOnlyByron , txValidityRange = ( TxValidityNoLowerBound - , TxValidityNoUpperBound ValidityNoUpperBoundInByronEra + , defaultTxValidityUpperBound ) , txMetadata = TxMetadataNone , txAuxScripts = TxAuxScriptsNone diff --git a/cardano-cli/src/Cardano/CLI/Environment.hs b/cardano-cli/src/Cardano/CLI/Environment.hs index 932bdf71eb..f82ab99520 100644 --- a/cardano-cli/src/Cardano/CLI/Environment.hs +++ b/cardano-cli/src/Cardano/CLI/Environment.hs @@ -11,9 +11,9 @@ module Cardano.CLI.Environment , getEnvSocketPath ) where -import Cardano.Api (AnyCardanoEra (..), AnyShelleyBasedEra (..), - AnyShelleyToBabbageEra (..), CardanoEra (..), NetworkId (..), NetworkMagic (..), - ShelleyBasedEra (..), ShelleyToBabbageEra (..)) +import Cardano.Api (AnyCardanoEra (..), CardanoEra (..), EraInEon (..), NetworkId (..), + NetworkMagic (..), ShelleyBasedEra (..), ShelleyToBabbageEra (..), + forEraInEonMaybe) import Data.Word (Word32) import qualified System.Environment as IO @@ -38,31 +38,15 @@ getEnvCli = do , envCliAnyCardanoEra = mCardanoEra } -envCliAnyShelleyBasedEra :: EnvCli -> Maybe AnyShelleyBasedEra +envCliAnyShelleyBasedEra :: EnvCli -> Maybe (EraInEon ShelleyBasedEra) envCliAnyShelleyBasedEra envCli = do AnyCardanoEra era <- envCliAnyCardanoEra envCli + forEraInEonMaybe era EraInEon - case era of - ByronEra -> Nothing - ShelleyEra -> Just $ AnyShelleyBasedEra ShelleyBasedEraShelley - AllegraEra -> Just $ AnyShelleyBasedEra ShelleyBasedEraAllegra - MaryEra -> Just $ AnyShelleyBasedEra ShelleyBasedEraMary - AlonzoEra -> Just $ AnyShelleyBasedEra ShelleyBasedEraAlonzo - BabbageEra -> Just $ AnyShelleyBasedEra ShelleyBasedEraBabbage - ConwayEra -> Just $ AnyShelleyBasedEra ShelleyBasedEraConway - -envCliAnyShelleyToBabbageEra :: EnvCli -> Maybe AnyShelleyToBabbageEra +envCliAnyShelleyToBabbageEra :: EnvCli -> Maybe (EraInEon ShelleyToBabbageEra) envCliAnyShelleyToBabbageEra envCli = do AnyCardanoEra era <- envCliAnyCardanoEra envCli - - case era of - ByronEra -> Nothing - ShelleyEra -> Just $ AnyShelleyToBabbageEra ShelleyToBabbageEraShelley - AllegraEra -> Just $ AnyShelleyToBabbageEra ShelleyToBabbageEraAllegra - MaryEra -> Just $ AnyShelleyToBabbageEra ShelleyToBabbageEraMary - AlonzoEra -> Just $ AnyShelleyToBabbageEra ShelleyToBabbageEraAlonzo - BabbageEra -> Just $ AnyShelleyToBabbageEra ShelleyToBabbageEraBabbage - ConwayEra -> Nothing + forEraInEonMaybe era EraInEon -- | If the environment variable @CARDANO_NODE_NETWORK_ID@ is set, then return the network id therein. -- Otherwise, return 'Nothing'. diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs index 79033712e8..1532c01e9c 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs @@ -13,6 +13,7 @@ import Cardano.CLI.EraBased.Commands.Governance.Actions import Cardano.CLI.EraBased.Commands.Governance.Committee import Cardano.CLI.EraBased.Commands.Governance.DRep import Cardano.CLI.EraBased.Commands.Governance.Query +import Cardano.CLI.EraBased.Commands.Governance.Poll import Cardano.CLI.EraBased.Commands.Governance.Vote import Cardano.CLI.Types.Common @@ -36,6 +37,8 @@ data GovernanceCmds era (GovernanceCommitteeCmds era) | GovernanceDRepCmds (GovernanceDRepCmds era) + | GovernancePollCmds + (GovernancePollCmds era) | GovernanceVoteCmds (GovernanceVoteCmds era) | GovernanceQueryCmds @@ -55,6 +58,8 @@ renderGovernanceCmds = \case renderGovernanceCommitteeCmds cmds GovernanceDRepCmds cmds -> renderGovernanceDRepCmds cmds + GovernancePollCmds cmds -> + renderGovernancePollCmds cmds GovernanceVoteCmds cmds -> renderGovernanceVoteCmds cmds GovernanceQueryCmds cmds -> diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/DRep.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/DRep.hs index c008005be8..2ba5d263a4 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/DRep.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/DRep.hs @@ -7,6 +7,8 @@ module Cardano.CLI.EraBased.Commands.Governance.DRep ) where import Cardano.Api +import qualified Cardano.Api.Ledger as Ledger +import Cardano.Api.Shelley import Cardano.CLI.Types.Common import Cardano.CLI.Types.Key @@ -27,6 +29,7 @@ data GovernanceDRepCmds era (ConwayEraOnwards era) (VerificationKeyOrHashOrFile DRepKey) Lovelace + (Maybe (Ledger.Anchor (Ledger.EraCrypto (ShelleyLedgerEra era)))) (File () Out) renderGovernanceDRepCmds :: () diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Poll.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Poll.hs new file mode 100644 index 0000000000..e2a6886e6d --- /dev/null +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Poll.hs @@ -0,0 +1,37 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE LambdaCase #-} + +module Cardano.CLI.EraBased.Commands.Governance.Poll + ( GovernancePollCmds(..) , renderGovernancePollCmds) where + +import Cardano.Api +import Cardano.Api.Shelley + +import Data.Text (Text) + +data GovernancePollCmds era + = GovernanceCreatePoll -- ^ Create a SPO poll + (BabbageEraOnwards era) {- TODO smelc, use BabbageEraOnly here instead -} + Text -- ^ Prompt + [Text] -- ^ Choices + (Maybe Word) -- ^ Nonce + (File GovernancePoll Out) + | GovernanceAnswerPoll -- ^ Answer a SPO poll + (BabbageEraOnwards era) {- TODO smelc, use BabbageEraOnly here instead -} + (File GovernancePoll In) -- ^ Poll file + (Maybe Word) -- ^ Answer index + (Maybe (File () Out)) -- ^ Tx file + | GovernanceVerifyPoll -- ^ Verify answer to a given SPO poll + (BabbageEraOnwards era) {- TODO smelc, use BabbageEraOnly here instead -} + (File GovernancePoll In) -- Poll file + (File (Tx ()) In) -- Tx file + (Maybe (File () Out)) -- Tx file + + +renderGovernancePollCmds :: () + => GovernancePollCmds era + -> Text +renderGovernancePollCmds = \case + GovernanceCreatePoll {} -> "governance create-poll" + GovernanceAnswerPoll {} -> "governance answer-poll" + GovernanceVerifyPoll {} -> "governance verify-poll" diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs index 99d4b1fe14..f4fbb6b612 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs @@ -1,8 +1,25 @@ {-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE LambdaCase #-} module Cardano.CLI.EraBased.Commands.Query ( QueryCmds (..) + , QueryLeadershipScheduleCmdArgs(..) + , QueryProtocolParametersCmdArgs(..) + , QueryConstitutionHashCmdArgs(..) + , QueryTipCmdArgs(..) + , QueryStakePoolsCmdArgs(..) + , QueryStakeDistributionCmdArgs(..) + , QueryStakeAddressInfoCmdArgs(..) + , QueryUTxOCmdArgs(..) + , QueryLedgerStateCmdArgs(..) + , QueryProtocolStateCmdArgs(..) + , QueryStakeSnapshotCmdArgs(..) + , QueryKesPeriodInfoCmdArgs(..) + , QueryPoolStateCmdArgs(..) + , QueryTxMempoolCmdArgs(..) + , QuerySlotNumberCmdArgs(..) , renderQueryCmds ) where @@ -13,126 +30,172 @@ import Cardano.CLI.Types.Key import Data.Text (Text) import Data.Time.Clock +import GHC.Generics -data QueryCmds era = - QueryLeadershipSchedule - SocketPath - AnyConsensusModeParams - NetworkId - GenesisFile - (VerificationKeyOrHashOrFile StakePoolKey) - (SigningKeyFile In) - EpochLeadershipSchedule - (Maybe (File () Out)) - | QueryProtocolParameters' - SocketPath - AnyConsensusModeParams - NetworkId - (Maybe (File () Out)) - | QueryConstitutionHash - SocketPath - AnyConsensusModeParams - NetworkId - (Maybe (File () Out)) - | QueryTip - SocketPath - AnyConsensusModeParams - NetworkId - (Maybe (File () Out)) - | QueryStakePools' - SocketPath - AnyConsensusModeParams - NetworkId - (Maybe (File () Out)) - | QueryStakeDistribution' - SocketPath - AnyConsensusModeParams - NetworkId - (Maybe (File () Out)) - | QueryStakeAddressInfo - SocketPath - AnyConsensusModeParams - StakeAddress - NetworkId - (Maybe (File () Out)) - | QueryUTxO' - SocketPath - AnyConsensusModeParams - QueryUTxOFilter - NetworkId - (Maybe (File () Out)) - | QueryDebugLedgerState' - SocketPath - AnyConsensusModeParams - NetworkId - (Maybe (File () Out)) - | QueryProtocolState' - SocketPath - AnyConsensusModeParams - NetworkId - (Maybe (File () Out)) - | QueryStakeSnapshot' - SocketPath - AnyConsensusModeParams - NetworkId - (AllOrOnly [Hash StakePoolKey]) - (Maybe (File () Out)) - | QueryKesPeriodInfo - SocketPath - AnyConsensusModeParams - NetworkId - (File () In) - -- ^ Node operational certificate - (Maybe (File () Out)) - | QueryPoolState' - SocketPath - AnyConsensusModeParams - NetworkId - [Hash StakePoolKey] - | QueryTxMempool - SocketPath - AnyConsensusModeParams - NetworkId - TxMempoolQuery - (Maybe (File () Out)) - | QuerySlotNumber - SocketPath - AnyConsensusModeParams - NetworkId - UTCTime - deriving Show +data QueryCmds era + = QueryLeadershipScheduleCmd !QueryLeadershipScheduleCmdArgs + | QueryProtocolParametersCmd !QueryProtocolParametersCmdArgs + | QueryConstitutionHashCmd !QueryConstitutionHashCmdArgs + | QueryTipCmd !QueryTipCmdArgs + | QueryStakePoolsCmd !QueryStakePoolsCmdArgs + | QueryStakeDistributionCmd !QueryStakeDistributionCmdArgs + | QueryStakeAddressInfoCmd !QueryStakeAddressInfoCmdArgs + | QueryUTxOCmd !QueryUTxOCmdArgs + | QueryLedgerStateCmd !QueryLedgerStateCmdArgs + | QueryProtocolStateCmd !QueryProtocolStateCmdArgs + | QueryStakeSnapshotCmd !QueryStakeSnapshotCmdArgs + | QueryKesPeriodInfoCmd !QueryKesPeriodInfoCmdArgs + | QueryPoolStateCmd !QueryPoolStateCmdArgs + | QueryTxMempoolCmd !QueryTxMempoolCmdArgs + | QuerySlotNumberCmd !QuerySlotNumberCmdArgs + deriving (Generic, Show) + +data QueryLeadershipScheduleCmdArgs = QueryLeadershipScheduleCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , genesisFp :: !GenesisFile + , poolColdVerKeyFile :: !(VerificationKeyOrHashOrFile StakePoolKey) + , vrkSkeyFp :: !(SigningKeyFile In) + , whichSchedule :: !EpochLeadershipSchedule + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data QueryProtocolParametersCmdArgs = QueryProtocolParametersCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data QueryConstitutionHashCmdArgs = QueryConstitutionHashCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data QueryTipCmdArgs = QueryTipCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data QueryStakePoolsCmdArgs = QueryStakePoolsCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data QueryStakeDistributionCmdArgs = QueryStakeDistributionCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data QueryStakeAddressInfoCmdArgs = QueryStakeAddressInfoCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , addr :: !StakeAddress + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data QueryUTxOCmdArgs = QueryUTxOCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , queryFilter :: !QueryUTxOFilter + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data QueryLedgerStateCmdArgs = QueryLedgerStateCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data QueryProtocolStateCmdArgs = QueryProtocolStateCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data QueryStakeSnapshotCmdArgs = QueryStakeSnapshotCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , allOrOnlyPoolIds :: !(AllOrOnly [Hash StakePoolKey]) + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data QueryKesPeriodInfoCmdArgs = QueryKesPeriodInfoCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , nodeOpCertFp :: !(File () In) -- ^ Node operational certificate + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data QueryPoolStateCmdArgs = QueryPoolStateCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , poolIds :: ![Hash StakePoolKey] + } deriving (Generic, Show) + +data QueryTxMempoolCmdArgs = QueryTxMempoolCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , query :: !TxMempoolQuery + , mOutFile :: !(Maybe (File () Out)) + } + deriving (Generic, Show) + +data QuerySlotNumberCmdArgs = QuerySlotNumberCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , utcTime :: !UTCTime + } deriving (Generic, Show) renderQueryCmds :: QueryCmds era -> Text renderQueryCmds = \case - QueryLeadershipSchedule {} -> + QueryLeadershipScheduleCmd {} -> "query leadership-schedule" - QueryProtocolParameters' {} -> + QueryProtocolParametersCmd {} -> "query protocol-parameters " - QueryConstitutionHash {} -> + QueryConstitutionHashCmd {} -> "query constitution-hash " - QueryTip {} -> + QueryTipCmd {} -> "query tip" - QueryStakePools' {} -> + QueryStakePoolsCmd {} -> "query stake-pools" - QueryStakeDistribution' {} -> + QueryStakeDistributionCmd {} -> "query stake-distribution" - QueryStakeAddressInfo {} -> + QueryStakeAddressInfoCmd {} -> "query stake-address-info" - QueryUTxO' {} -> + QueryUTxOCmd {} -> "query utxo" - QueryDebugLedgerState' {} -> + QueryLedgerStateCmd {} -> "query ledger-state" - QueryProtocolState' {} -> + QueryProtocolStateCmd {} -> "query protocol-state" - QueryStakeSnapshot' {} -> + QueryStakeSnapshotCmd {} -> "query stake-snapshot" - QueryKesPeriodInfo {} -> + QueryKesPeriodInfoCmd {} -> "query kes-period-info" - QueryPoolState' {} -> + QueryPoolStateCmd {} -> "query pool-state" - QueryTxMempool _ _ _ query _ -> - "query tx-mempool" <> renderTxMempoolQuery query - QuerySlotNumber {} -> + QueryTxMempoolCmd (QueryTxMempoolCmdArgs _ _ _ q _) -> + "query tx-mempool" <> renderTxMempoolQuery q + QuerySlotNumberCmd {} -> "query slot-number" renderTxMempoolQuery :: TxMempoolQuery -> Text diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index 88889860a2..22d1c5f53c 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -58,11 +58,11 @@ import qualified Text.Parsec.String as Parsec import qualified Text.Parsec.Token as Parsec import Text.Read (readEither, readMaybe) -defaultShelleyBasedEra :: AnyShelleyBasedEra -defaultShelleyBasedEra = AnyShelleyBasedEra ShelleyBasedEraBabbage +defaultShelleyBasedEra :: EraInEon ShelleyBasedEra +defaultShelleyBasedEra = EraInEon ShelleyBasedEraBabbage -defaultShelleyToBabbageEra :: AnyShelleyToBabbageEra -defaultShelleyToBabbageEra = AnyShelleyToBabbageEra ShelleyToBabbageEraBabbage +defaultShelleyToBabbageEra :: EraInEon ShelleyToBabbageEra +defaultShelleyToBabbageEra = EraInEon ShelleyToBabbageEraBabbage command' :: String -> String -> Parser a -> Mod CommandFields a command' c descr p = @@ -101,6 +101,14 @@ pNetworkId envCli = asum $ mconcat pure <$> maybeToList (envCliNetworkId envCli) ] +toUnitIntervalOrErr :: Rational -> L.UnitInterval +toUnitIntervalOrErr r = case Ledger.boundRational r of + Nothing -> + error $ mconcat [ "toUnitIntervalOrErr: " + , "rational out of bounds " <> show r + ] + Just n -> n + pConsensusModeParams :: Parser AnyConsensusModeParams pConsensusModeParams = asum [ pShelleyMode *> pShelleyConsensusMode @@ -301,113 +309,113 @@ subInfoParser name i mps = case catMaybes mps of [] -> Nothing parsers -> Just $ subParser name $ Opt.info (asum parsers) i -pAnyShelleyBasedEra :: EnvCli -> Parser AnyShelleyBasedEra +pAnyShelleyBasedEra :: EnvCli -> Parser (EraInEon ShelleyBasedEra) pAnyShelleyBasedEra envCli = asum $ mconcat - [ [ Opt.flag' (AnyShelleyBasedEra ShelleyBasedEraShelley) + [ [ Opt.flag' (EraInEon ShelleyBasedEraShelley) $ mconcat [Opt.long "shelley-era", Opt.help "Specify the Shelley era"] - , Opt.flag' (AnyShelleyBasedEra ShelleyBasedEraAllegra) + , Opt.flag' (EraInEon ShelleyBasedEraAllegra) $ mconcat [Opt.long "allegra-era", Opt.help "Specify the Allegra era"] - , Opt.flag' (AnyShelleyBasedEra ShelleyBasedEraMary) + , Opt.flag' (EraInEon ShelleyBasedEraMary) $ mconcat [Opt.long "mary-era", Opt.help "Specify the Mary era"] - , Opt.flag' (AnyShelleyBasedEra ShelleyBasedEraAlonzo) + , Opt.flag' (EraInEon ShelleyBasedEraAlonzo) $ mconcat [Opt.long "alonzo-era", Opt.help "Specify the Alonzo era"] - , Opt.flag' (AnyShelleyBasedEra ShelleyBasedEraBabbage) + , Opt.flag' (EraInEon ShelleyBasedEraBabbage) $ mconcat [Opt.long "babbage-era", Opt.help "Specify the Babbage era (default)"] - , Opt.flag' (AnyShelleyBasedEra ShelleyBasedEraConway) + , Opt.flag' (EraInEon ShelleyBasedEraConway) $ mconcat [Opt.long "conway-era", Opt.help "Specify the Conway era"] ] , maybeToList $ pure <$> envCliAnyShelleyBasedEra envCli , pure $ pure defaultShelleyBasedEra ] -pAnyShelleyToBabbageEra :: EnvCli -> Parser AnyShelleyToBabbageEra +pAnyShelleyToBabbageEra :: EnvCli -> Parser (EraInEon ShelleyToBabbageEra) pAnyShelleyToBabbageEra envCli = asum $ mconcat - [ [ Opt.flag' (AnyShelleyToBabbageEra ShelleyToBabbageEraShelley) + [ [ Opt.flag' (EraInEon ShelleyToBabbageEraShelley) $ mconcat [Opt.long "shelley-era", Opt.help "Specify the Shelley era"] - , Opt.flag' (AnyShelleyToBabbageEra ShelleyToBabbageEraAllegra) + , Opt.flag' (EraInEon ShelleyToBabbageEraAllegra) $ mconcat [Opt.long "allegra-era", Opt.help "Specify the Allegra era"] - , Opt.flag' (AnyShelleyToBabbageEra ShelleyToBabbageEraMary) + , Opt.flag' (EraInEon ShelleyToBabbageEraMary) $ mconcat [Opt.long "mary-era", Opt.help "Specify the Mary era"] - , Opt.flag' (AnyShelleyToBabbageEra ShelleyToBabbageEraAlonzo) + , Opt.flag' (EraInEon ShelleyToBabbageEraAlonzo) $ mconcat [Opt.long "alonzo-era", Opt.help "Specify the Alonzo era"] - , Opt.flag' (AnyShelleyToBabbageEra ShelleyToBabbageEraBabbage) + , Opt.flag' (EraInEon ShelleyToBabbageEraBabbage) $ mconcat [Opt.long "babbage-era", Opt.help "Specify the Babbage era (default)"] ] , maybeToList $ pure <$> envCliAnyShelleyToBabbageEra envCli , pure $ pure defaultShelleyToBabbageEra ] -pShelleyBasedShelley :: EnvCli -> Parser AnyShelleyBasedEra +pShelleyBasedShelley :: EnvCli -> Parser (EraInEon ShelleyBasedEra) pShelleyBasedShelley envCli = asum $ mconcat - [ [ Opt.flag' (AnyShelleyBasedEra ShelleyBasedEraShelley) + [ [ Opt.flag' (EraInEon ShelleyBasedEraShelley) $ mconcat [Opt.long "shelley-era", Opt.help "Specify the Shelley era"] ] , maybeToList $ fmap pure - $ mfilter (== AnyShelleyBasedEra ShelleyBasedEraShelley) + $ mfilter (== EraInEon ShelleyBasedEraShelley) $ envCliAnyShelleyBasedEra envCli ] -pShelleyBasedAllegra :: EnvCli -> Parser AnyShelleyBasedEra +pShelleyBasedAllegra :: EnvCli -> Parser (EraInEon ShelleyBasedEra) pShelleyBasedAllegra envCli = asum $ mconcat - [ [ Opt.flag' (AnyShelleyBasedEra ShelleyBasedEraAllegra) + [ [ Opt.flag' (EraInEon ShelleyBasedEraAllegra) $ mconcat [Opt.long "allegra-era", Opt.help "Specify the Allegra era"] ] , maybeToList $ fmap pure - $ mfilter (== AnyShelleyBasedEra ShelleyBasedEraAllegra) + $ mfilter (== EraInEon ShelleyBasedEraAllegra) $ envCliAnyShelleyBasedEra envCli ] -pShelleyBasedMary :: EnvCli -> Parser AnyShelleyBasedEra +pShelleyBasedMary :: EnvCli -> Parser (EraInEon ShelleyBasedEra) pShelleyBasedMary envCli = asum $ mconcat - [ [ Opt.flag' (AnyShelleyBasedEra ShelleyBasedEraMary) + [ [ Opt.flag' (EraInEon ShelleyBasedEraMary) $ mconcat [Opt.long "mary-era", Opt.help "Specify the Mary era"] ] , maybeToList $ fmap pure - $ mfilter (== AnyShelleyBasedEra ShelleyBasedEraMary) + $ mfilter (== EraInEon ShelleyBasedEraMary) $ envCliAnyShelleyBasedEra envCli ] -pShelleyBasedAlonzo :: EnvCli -> Parser AnyShelleyBasedEra +pShelleyBasedAlonzo :: EnvCli -> Parser (EraInEon ShelleyBasedEra) pShelleyBasedAlonzo envCli = asum $ mconcat - [ [ Opt.flag' (AnyShelleyBasedEra ShelleyBasedEraAlonzo) + [ [ Opt.flag' (EraInEon ShelleyBasedEraAlonzo) $ mconcat [Opt.long "alonzo-era", Opt.help "Specify the Alonzo era"] ] , maybeToList $ fmap pure - $ mfilter (== AnyShelleyBasedEra ShelleyBasedEraAlonzo) + $ mfilter (== EraInEon ShelleyBasedEraAlonzo) $ envCliAnyShelleyBasedEra envCli ] -pShelleyBasedBabbage :: EnvCli -> Parser AnyShelleyBasedEra +pShelleyBasedBabbage :: EnvCli -> Parser (EraInEon ShelleyBasedEra) pShelleyBasedBabbage envCli = asum $ mconcat - [ [ Opt.flag' (AnyShelleyBasedEra ShelleyBasedEraBabbage) + [ [ Opt.flag' (EraInEon ShelleyBasedEraBabbage) $ mconcat [Opt.long "babbage-era", Opt.help "Specify the Babbage era (default)"] ] , maybeToList $ fmap pure - $ mfilter (== AnyShelleyBasedEra ShelleyBasedEraBabbage) + $ mfilter (== EraInEon ShelleyBasedEraBabbage) $ envCliAnyShelleyBasedEra envCli ] -pShelleyBasedConway :: EnvCli -> Parser AnyShelleyBasedEra +pShelleyBasedConway :: EnvCli -> Parser (EraInEon ShelleyBasedEra) pShelleyBasedConway envCli = asum $ mconcat - [ [ Opt.flag' (AnyShelleyBasedEra ShelleyBasedEraConway) + [ [ Opt.flag' (EraInEon ShelleyBasedEraConway) $ mconcat [Opt.long "conway-era", Opt.help "Specify the Conway era"] ] , maybeToList $ fmap pure - $ mfilter (== AnyShelleyBasedEra ShelleyBasedEraConway) + $ mfilter (== EraInEon ShelleyBasedEraConway) $ envCliAnyShelleyBasedEra envCli ] @@ -806,17 +814,25 @@ pAnyVerificationKeySource helpText = pCommitteeHotKey :: Parser (VerificationKey CommitteeHotKey) pCommitteeHotKey = - Opt.option (Opt.eitherReader deserialiseFromHex) $ mconcat + Opt.option (Opt.eitherReader deserialiseHotCCKeyFromHex) $ mconcat [ Opt.long "hot-key" , Opt.metavar "STRING" , Opt.help "Constitutional Committee hot key (hex-encoded)." ] - where - deserialiseFromHex :: String -> Either String (VerificationKey CommitteeHotKey) - deserialiseFromHex = - first (\e -> "Invalid Constitutional Committee hot key: " ++ displayError e) - . deserialiseFromRawBytesHex (AsVerificationKey AsCommitteeHotKey) - . BSC.pack + +pCommitteeHotVerificationKey :: Parser (VerificationKey CommitteeHotKey) +pCommitteeHotVerificationKey = + Opt.option (Opt.eitherReader deserialiseHotCCKeyFromHex) $ mconcat + [ Opt.long "cc-hot-verification-key" + , Opt.metavar "STRING" + , Opt.help "Constitutional Committee hot key (hex-encoded)." + ] + +deserialiseHotCCKeyFromHex :: String -> Either String (VerificationKey CommitteeHotKey) +deserialiseHotCCKeyFromHex = + first (\e -> "Invalid Constitutional Committee hot key: " ++ displayError e) + . deserialiseFromRawBytesHex (AsVerificationKey AsCommitteeHotKey) + . BSC.pack pCommitteeHotKeyFile :: Parser (VerificationKeyFile In) pCommitteeHotKeyFile = @@ -827,10 +843,20 @@ pCommitteeHotKeyFile = , Opt.completer (Opt.bashCompleter "file") ] -pCommitteeHotKeyHash :: Parser (Hash CommitteeHotKey) -pCommitteeHotKeyHash = +pCommitteeHotVerificationKeyFile :: Parser (VerificationKeyFile In) +pCommitteeHotVerificationKeyFile = + fmap File $ Opt.strOption $ mconcat + [ Opt.long "cc-hot-verification-key-file" + , Opt.metavar "FILE" + , Opt.help "Filepath of the Consitutional Committee hot key." + , Opt.completer (Opt.bashCompleter "file") + ] + +-- | The first argument is the optional prefix. +pCommitteeHotKeyHash :: Maybe String -> Parser (Hash CommitteeHotKey) +pCommitteeHotKeyHash prefix = Opt.option (Opt.eitherReader deserialiseFromHex) $ mconcat - [ Opt.long "hot-key-hash" + [ Opt.long $ prefixFlag prefix "hot-key-hash" , Opt.metavar "STRING" , Opt.help "Constitutional Committee key hash (hex-encoded)." ] @@ -852,7 +878,15 @@ pCommitteeHotKeyOrHashOrFile :: Parser (VerificationKeyOrHashOrFile CommitteeHot pCommitteeHotKeyOrHashOrFile = asum [ VerificationKeyOrFile <$> pCommitteeHotKeyOrFile - , VerificationKeyHash <$> pCommitteeHotKeyHash + , VerificationKeyHash <$> pCommitteeHotKeyHash Nothing + ] + +pCommitteeHotVerificationKeyOrHashOrVerificationFile :: Parser (VerificationKeyOrHashOrFile CommitteeHotKey) +pCommitteeHotVerificationKeyOrHashOrVerificationFile = + asum + [ VerificationKeyOrFile . VerificationKeyValue <$> pCommitteeHotVerificationKey, + VerificationKeyOrFile . VerificationKeyFilePath <$> pCommitteeHotVerificationKeyFile, + VerificationKeyHash <$> pCommitteeHotKeyHash (Just "cc") ] catCommands :: [Parser a] -> Maybe (Parser a) @@ -2795,7 +2829,153 @@ pProtocolVersion = ] ] --------------------------------------------------------------------------------- +pPoolVotingThresholds :: Parser Ledger.PoolVotingThresholds +pPoolVotingThresholds = + Ledger.PoolVotingThresholds + <$> pMotionNoConfidence + <*> pCommitteeNormal + <*> pCommitteeNoConfidence + <*> pHardForkInitiation + where + pMotionNoConfidence = + Opt.option (toUnitIntervalOrErr <$> readRationalUnitInterval) $ mconcat + [ Opt.long "pool-voting-threshold-motion-no-confidence" + , Opt.metavar "RATIONAL" + , Opt.help "TODO" + ] + pCommitteeNormal = + Opt.option (toUnitIntervalOrErr <$> readRationalUnitInterval) $ mconcat + [ Opt.long "pool-voting-threshold-committee-normal" + , Opt.metavar "RATIONAL" + , Opt.help "TODO" + ] + pCommitteeNoConfidence = + Opt.option (toUnitIntervalOrErr <$> readRationalUnitInterval) $ mconcat + [ Opt.long "pool-voting-threshold-committee-no-confidence" + , Opt.metavar "RATIONAL" + , Opt.help "TODO" + ] + pHardForkInitiation = + Opt.option (toUnitIntervalOrErr <$> readRationalUnitInterval) $ mconcat + [ Opt.long "pool-voting-threshold-hard-fork-initiation" + , Opt.metavar "RATIONAL" + , Opt.help "TODO" + ] + +pDRepVotingThresholds :: Parser Ledger.DRepVotingThresholds +pDRepVotingThresholds = + Ledger.DRepVotingThresholds + <$> pMotionNoConfidence + <*> pCommitteeNormal + <*> pCommitteeNoConfidence + <*> pUpdateToConstitution + <*> pHardForkInitiation + <*> pPPNetworkGroup + <*> pPPEconomicGroup + <*> pPPTechnicalGroup + <*> pPPGovGroup + <*> pTreasuryWithdrawal + where + pMotionNoConfidence = + Opt.option (toUnitIntervalOrErr <$> readRationalUnitInterval) $ mconcat + [ Opt.long "drep-voting-threshold-motion-no-confidence" + , Opt.metavar "RATIONAL" + , Opt.help "TODO" + ] + pCommitteeNormal = + Opt.option (toUnitIntervalOrErr <$> readRationalUnitInterval) $ mconcat + [ Opt.long "drep-voting-threshold-committee-normal" + , Opt.metavar "RATIONAL" + , Opt.help "TODO" + ] + pCommitteeNoConfidence = + Opt.option (toUnitIntervalOrErr <$> readRationalUnitInterval) $ mconcat + [ Opt.long "drep-voting-threshold-committee-no-confidence" + , Opt.metavar "RATIONAL" + , Opt.help "TODO" + ] + pUpdateToConstitution = + Opt.option (toUnitIntervalOrErr <$> readRationalUnitInterval) $ mconcat + [ Opt.long "drep-voting-threshold-update-to-constitution" + , Opt.metavar "RATIONAL" + , Opt.help "TODO" + ] + pHardForkInitiation = + Opt.option (toUnitIntervalOrErr <$> readRationalUnitInterval) $ mconcat + [ Opt.long "drep-voting-threshold-hard-fork-initiation" + , Opt.metavar "RATIONAL" + , Opt.help "TODO" + ] + pPPNetworkGroup = + Opt.option (toUnitIntervalOrErr <$> readRationalUnitInterval) $ mconcat + [ Opt.long "drep-voting-threshold-pp-network-group" + , Opt.metavar "RATIONAL" + , Opt.help "TODO" + ] + pPPEconomicGroup = + Opt.option (toUnitIntervalOrErr <$> readRationalUnitInterval) $ mconcat + [ Opt.long "drep-voting-threshold-pp-economic-group" + , Opt.metavar "RATIONAL" + , Opt.help "TODO" + ] + pPPTechnicalGroup = + Opt.option (toUnitIntervalOrErr <$> readRationalUnitInterval) $ mconcat + [ Opt.long "drep-voting-threshold-pp-technical-group" + , Opt.metavar "RATIONAL" + , Opt.help "TODO" + ] + pPPGovGroup = + Opt.option (toUnitIntervalOrErr <$> readRationalUnitInterval) $ mconcat + [ Opt.long "drep-voting-threshold-pp-governance-group" + , Opt.metavar "RATIONAL" + , Opt.help "TODO" + ] + pTreasuryWithdrawal = + Opt.option (toUnitIntervalOrErr <$> readRationalUnitInterval) $ mconcat + [ Opt.long "drep-voting-threshold-treasury-withdrawal" + , Opt.metavar "RATIONAL" + , Opt.help "TODO" + ] + +pMinCommitteeSize :: Parser Natural +pMinCommitteeSize = + Opt.option Opt.auto $ mconcat + [ Opt.long "min-committee-size" + , Opt.metavar "INT" + , Opt.help "TODO" + ] + +pCommitteeTermLength :: Parser Natural +pCommitteeTermLength = + Opt.option Opt.auto $ mconcat + [ Opt.long "committee-term-length" + , Opt.metavar "INT" + , Opt.help "TODO" + ] + +pGovActionLifetime :: Parser EpochNo +pGovActionLifetime = + fmap EpochNo $ Opt.option (bounded "EPOCH") $ mconcat + [ Opt.long "governance-action-lifetime" + , Opt.metavar "NATURAL" + , Opt.help "TODO" + ] + +pDRepDeposit :: Parser Lovelace +pDRepDeposit = + Opt.option (readerFromParsecParser parseLovelace) $ mconcat + [ Opt.long "drep-deposit" + , Opt.metavar "LOVELACE" + , Opt.help "TODO" + ] + +pDRepActivity :: Parser EpochNo +pDRepActivity = + fmap EpochNo $ Opt.option (bounded "EPOCH") $ mconcat + [ Opt.long "drep-activity" + , Opt.metavar "NATURAL" + , Opt.help "TODO" + ] parseTxOutAnyEra :: Parsec.Parser (TxOutDatumAnyEra -> ReferenceScriptAnyEra -> TxOutAnyEra) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs index 2014204e37..aa9bebb41b 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs @@ -15,6 +15,7 @@ import Cardano.CLI.EraBased.Options.Common import Cardano.CLI.EraBased.Options.Governance.Actions import Cardano.CLI.EraBased.Options.Governance.Committee import Cardano.CLI.EraBased.Options.Governance.DRep +import Cardano.CLI.EraBased.Options.Governance.Poll import Cardano.CLI.EraBased.Options.Governance.Query import Cardano.CLI.EraBased.Options.Governance.Vote import Cardano.CLI.Types.Common @@ -39,12 +40,13 @@ pGovernanceCmds era envCli = , fmap GovernanceActionCmds <$> pGovernanceActionCmds era , fmap GovernanceCommitteeCmds <$> pGovernanceCommitteeCmds era , fmap GovernanceDRepCmds <$> pGovernanceDRepCmds era + , fmap GovernancePollCmds <$> pGovernancePollCmds era , fmap GovernanceVoteCmds <$> pGovernanceVoteCmds era ] pCreateMirCertificatesCmds :: CardanoEra era -> Maybe (Parser (GovernanceCmds era)) pCreateMirCertificatesCmds era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "create-mir-certificate" $ Opt.info (pMIRPayStakeAddresses w <|> mirCertParsers w) 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 9627cbeef4..58330a4d55 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs @@ -43,7 +43,7 @@ pGovernanceActionNewInfoCmd :: CardanoEra era -> Maybe (Parser (GovernanceActionCmds era)) pGovernanceActionNewInfoCmd era = do - cOn <- maybeEonInEra era + cOn <- forEraMaybeEon era pure $ subParser "create-info" $ Opt.info @@ -63,7 +63,7 @@ pGovernanceActionNewConstitutionCmd :: CardanoEra era -> Maybe (Parser (GovernanceActionCmds era)) pGovernanceActionNewConstitutionCmd era = do - cOn <- maybeEonInEra era + cOn <- forEraMaybeEon era pure $ subParser "create-constitution" $ Opt.info @@ -85,7 +85,7 @@ pGovernanceActionNewCommitteeCmd :: CardanoEra era -> Maybe (Parser (GovernanceActionCmds era)) pGovernanceActionNewCommitteeCmd era = do - cOn <- maybeEonInEra era + cOn <- forEraMaybeEon era pure $ subParser "create-new-committee" $ Opt.info @@ -116,7 +116,7 @@ pGovernanceActionNoConfidenceCmd :: CardanoEra era -> Maybe (Parser (GovernanceActionCmds era)) pGovernanceActionNoConfidenceCmd era = do - cOn <- maybeEonInEra era + cOn <- forEraMaybeEon era pure $ subParser "create-no-confidence" $ Opt.info @@ -145,7 +145,7 @@ pGovernanceActionProtocolParametersUpdateCmd :: () => CardanoEra era -> Maybe (Parser (GovernanceActionCmds era)) pGovernanceActionProtocolParametersUpdateCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "create-protocol-parameters-update" $ Opt.info @@ -168,14 +168,6 @@ toNonNegativeIntervalOrErr r = case Ledger.boundRational r of ] Just n -> n -toUnitIntervalOrErr :: Rational -> Ledger.UnitInterval -toUnitIntervalOrErr r = case Ledger.boundRational r of - Nothing -> - error $ mconcat [ "toUnitIntervalOrErr: " - , "rational out of bounds " <> show r - ] - Just n -> n - mkProtocolVersionOrErr :: (Natural, Natural) -> Ledger.ProtVer mkProtocolVersionOrErr (majorProtVer, minorProtVer) = case (`Ledger.ProtVer` minorProtVer) <$> Ledger.mkVersion majorProtVer of @@ -236,6 +228,18 @@ pIntroducedInBabbagePParams = IntroducedInBabbagePParams <$> convertToLedger (CoinPerByte . toShelleyLovelace) (optional pUTxOCostPerByte) +pIntroducedInConwayPParams :: Parser (IntroducedInConwayPParams ledgerera) +pIntroducedInConwayPParams = + IntroducedInConwayPParams + <$> convertToLedger id (optional pPoolVotingThresholds) + <*> convertToLedger id (optional pDRepVotingThresholds) + <*> convertToLedger id (optional pMinCommitteeSize) + <*> convertToLedger id (optional pCommitteeTermLength) + <*> convertToLedger id (optional pGovActionLifetime) + <*> convertToLedger toShelleyLovelace (optional pGovActionDeposit) + <*> convertToLedger toShelleyLovelace (optional pDRepDeposit) + <*> convertToLedger id (optional pDRepActivity) + -- Not necessary in Conway era onwards pProtocolParametersUpdateGenesisKeys :: ShelleyBasedEra era -> Parser [VerificationKeyFile In] pProtocolParametersUpdateGenesisKeys = @@ -277,10 +281,11 @@ dpGovActionProtocolParametersUpdate = \case <$> pCommonProtocolParameters <*> pAlonzoOnwardsPParams <*> pIntroducedInBabbagePParams + <*> pIntroducedInConwayPParams pGovernanceActionTreasuryWithdrawalCmd :: CardanoEra era -> Maybe (Parser (GovernanceActionCmds era)) pGovernanceActionTreasuryWithdrawalCmd era = do - cOn <- maybeEonInEra era + cOn <- forEraMaybeEon era pure $ subParser "create-treasury-withdrawal" $ Opt.info diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Committee.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Committee.hs index 8ab2f8212a..71d91c1c76 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Committee.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Committee.hs @@ -33,7 +33,7 @@ pGovernanceCommitteeKeyGenColdCmd :: () => CardanoEra era -> Maybe (Parser (GovernanceCommitteeCmds era)) pGovernanceCommitteeKeyGenColdCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "key-gen-cold" $ Opt.info (pCmd w) @@ -54,7 +54,7 @@ pGovernanceCommitteeKeyGenHotCmd :: () => CardanoEra era -> Maybe (Parser (GovernanceCommitteeCmds era)) pGovernanceCommitteeKeyGenHotCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "key-gen-hot" $ Opt.info (pCmd w) @@ -75,7 +75,7 @@ pGovernanceCommitteeKeyHashCmd :: () => CardanoEra era -> Maybe (Parser (GovernanceCommitteeCmds era)) pGovernanceCommitteeKeyHashCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "key-hash" $ Opt.info @@ -91,7 +91,7 @@ pGovernanceCommitteeCreateHotKeyAuthorizationCertificateCmd :: () => CardanoEra era -> Maybe (Parser (GovernanceCommitteeCmds era)) pGovernanceCommitteeCreateHotKeyAuthorizationCertificateCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "create-hot-key-authorization-certificate" $ Opt.info @@ -109,7 +109,7 @@ pGovernanceCommitteeCreateColdKeyResignationCertificateCmd :: () => CardanoEra era -> Maybe (Parser (GovernanceCommitteeCmds era)) pGovernanceCommitteeCreateColdKeyResignationCertificateCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "create-cold-key-resignation-certificate" $ Opt.info diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs index f238e5732a..4f89f1ee6b 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs @@ -14,8 +14,12 @@ import Cardano.CLI.Environment import Cardano.CLI.EraBased.Commands.Governance.DRep import Cardano.CLI.EraBased.Options.Common import Cardano.CLI.Parser +import Cardano.CLI.Read import Cardano.CLI.Types.Common import Cardano.CLI.Types.Key +import qualified Cardano.Ledger.BaseTypes as L +import qualified Cardano.Ledger.Crypto as Crypto +import qualified Cardano.Ledger.SafeHash as L import Control.Applicative import Data.Foldable @@ -42,7 +46,7 @@ pGovernanceDRepKeyGenCmd :: () => CardanoEra era -> Maybe (Parser (GovernanceDRepCmds era)) pGovernanceDRepKeyGenCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "key-gen" $ Opt.info @@ -56,7 +60,7 @@ pGovernanceDRepKeyIdCmd :: () => CardanoEra era -> Maybe (Parser (GovernanceDRepCmds era)) pGovernanceDRepKeyIdCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "id" $ Opt.info @@ -85,17 +89,39 @@ pRegistrationCertificateCmd :: () => CardanoEra era -> Maybe (Parser (GovernanceDRepCmds era)) pRegistrationCertificateCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "registration-certificate" - $ Opt.info (mkParser w) + $ Opt.info (conwayEraOnwardsConstraints w $ mkParser w) $ Opt.progDesc "Create a registration certificate." where mkParser w = GovernanceDRepRegistrationCertificateCmd w <$> pDRepVerificationKeyOrHashOrFile <*> pKeyRegistDeposit + <*> pDRepMetadata <*> pOutputFile +pDRepMetadata :: Parser (Maybe (L.Anchor Crypto.StandardCrypto)) +pDRepMetadata = + optional $ + L.Anchor + <$> fmap unAnchorUrl pDrepMetadataUrl + <*> pDrepMetadataHash + +pDrepMetadataUrl :: Parser AnchorUrl +pDrepMetadataUrl = + AnchorUrl + <$> pUrl "drep-metadata-url" "DRep anchor URL" + +pDrepMetadataHash :: Parser (L.SafeHash Crypto.StandardCrypto L.AnchorData) +pDrepMetadataHash = + Opt.option readSafeHash $ mconcat + [ Opt.long "drep-metadata-hash" + , Opt.metavar "HASH" + , Opt.help "DRep anchor data hash." + ] + + -------------------------------------------------------------------------------- data AnyEraDecider era where diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Poll.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Poll.hs new file mode 100644 index 0000000000..369aea2563 --- /dev/null +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Poll.hs @@ -0,0 +1,73 @@ +module Cardano.CLI.EraBased.Options.Governance.Poll + ( pGovernancePollCmds, + ) +where + +import Cardano.Api + +import Cardano.CLI.EraBased.Commands.Governance.Poll (GovernancePollCmds (..)) +import Cardano.CLI.EraBased.Options.Common +import Cardano.Prelude (catMaybes, isInfixOf) + +import Control.Monad (when) +import Data.Foldable +import Options.Applicative hiding (help, str) +import qualified Options.Applicative as Opt + +pGovernancePollCmds :: () + => CardanoEra era + -> Maybe (Parser (GovernancePollCmds era)) +pGovernancePollCmds era = + case parsers of + [] -> Nothing + _ -> Just $ asum parsers + where + parsers = + catMaybes + [ subParser "create-poll" + <$> ( Opt.info + <$> pGovernanceCreatePoll era + <*> pure (Opt.progDesc "Create an SPO poll") + ), + subParser "answer-poll" + <$> ( Opt.info + <$> pGovernanceAnswerPoll era + <*> pure (Opt.progDesc "Answer an SPO poll") + ), + subParser "verify-poll" + <$> ( Opt.info + <$> pGovernanceVerifyPoll era + <*> pure (Opt.progDesc "Verify an answer to a given SPO poll") + ) + ] + +pGovernanceCreatePoll :: CardanoEra era -> Maybe (Parser (GovernancePollCmds era)) +pGovernanceCreatePoll era = do + w <- forEraMaybeEon era + when ("BabbageEraOnwardsConway" `isInfixOf` show w) Nothing -- TODO smelc remove this when BabbageEraBabbageOnly is introduced + pure $ + GovernanceCreatePoll w + <$> pPollQuestion + <*> some pPollAnswer + <*> optional pPollNonce + <*> pOutputFile + +pGovernanceAnswerPoll :: CardanoEra era -> Maybe (Parser (GovernancePollCmds era)) +pGovernanceAnswerPoll era = do + w <- forEraMaybeEon era + when ("BabbageEraOnwardsConway" `isInfixOf` show w) Nothing -- TODO smelc remove this when BabbageEraBabbageOnly is introduced + pure $ + GovernanceAnswerPoll w + <$> pPollFile + <*> optional pPollAnswerIndex + <*> optional pOutputFile + +pGovernanceVerifyPoll :: CardanoEra era -> Maybe (Parser (GovernancePollCmds era)) +pGovernanceVerifyPoll era = do + w <- forEraMaybeEon era + when ("BabbageEraOnwardsConway" `isInfixOf` show w) Nothing -- TODO smelc remove this when BabbageEraBabbageOnly is introduced + pure $ + GovernanceVerifyPoll w + <$> pPollFile + <*> pPollTxFile + <*> optional pOutputFile diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Query.hs index 941b3397cb..d47eb8e0c0 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Query.hs @@ -33,7 +33,7 @@ pGovernanceQueryGetConstitutionCmd :: () -> EnvCli -> Maybe (Parser (GovernanceQueryCmds era)) pGovernanceQueryGetConstitutionCmd era env = do - cOn <- maybeEonInEra era + cOn <- forEraMaybeEon era pure $ subParser "constitution" $ Opt.info (GovernanceQueryConstitutionCmd cOn <$> pNoArgQueryCmd env) @@ -44,7 +44,7 @@ pGovernanceQueryGetGovStateCmd :: () -> EnvCli -> Maybe (Parser (GovernanceQueryCmds era)) pGovernanceQueryGetGovStateCmd era env = do - cOn <- maybeEonInEra era + cOn <- forEraMaybeEon era pure $ subParser "gov-state" $ Opt.info (GovernanceQueryGovStateCmd cOn <$> pNoArgQueryCmd env) @@ -60,7 +60,7 @@ pGovernanceQueryDRepStateCmd :: () -> EnvCli -> Maybe (Parser (GovernanceQueryCmds era)) pGovernanceQueryDRepStateCmd era env = do - cOn <- maybeEonInEra era + cOn <- forEraMaybeEon era pure $ subParser "drep-state" $ Opt.info (GovernanceQueryDRepStateCmd cOn <$> pDRepStateQueryCmd) @@ -79,7 +79,7 @@ pGovernanceQueryDRepStakeDistributionCmd :: () -> EnvCli -> Maybe (Parser (GovernanceQueryCmds era)) pGovernanceQueryDRepStakeDistributionCmd era env = do - cOn <- maybeEonInEra era + cOn <- forEraMaybeEon era pure $ subParser "drep-stake-distribution" $ Opt.info (GovernanceQueryDRepStakeDistributionCmd cOn <$> pDRepStakeDistributionQueryCmd) @@ -98,7 +98,7 @@ pGovernanceQueryGetCommitteeStateCmd :: () -> EnvCli -> Maybe (Parser (GovernanceQueryCmds era)) pGovernanceQueryGetCommitteeStateCmd era env = do - cOn <- maybeEonInEra era + cOn <- forEraMaybeEon era pure $ subParser "committee-state" $ Opt.info (GovernanceQueryCommitteeStateCmd cOn <$> pNoArgQueryCmd env) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Vote.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Vote.hs index a3c8b54658..6afe8e6654 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Vote.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Vote.hs @@ -32,7 +32,7 @@ pGovernanceVoteCreateCmd :: () => CardanoEra era -> Maybe (Parser (GovernanceVoteCmds era)) pGovernanceVoteCreateCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "create" $ Opt.info @@ -53,4 +53,5 @@ pAnyVotingStakeVerificationKeyOrHashOrFile :: Parser AnyVotingStakeVerificationK pAnyVotingStakeVerificationKeyOrHashOrFile = asum [ AnyDRepVerificationKeyOrHashOrFile <$> pDRepVerificationKeyOrHashOrFile , AnyStakePoolVerificationKeyOrHashOrFile <$> pStakePoolVerificationKeyOrHashOrFile Nothing + , AnyCommitteeHotVerificationKeyOrHashOrFile <$> pCommitteeHotVerificationKeyOrHashOrVerificationFile ] diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs index e556f26843..36fcca6068 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs @@ -35,156 +35,165 @@ pQueryCmds envCli = ) [ Just $ subParser "protocol-parameters" - $ Opt.info (pQueryProtocolParameters envCli) + $ Opt.info (pQueryProtocolParametersCmd envCli) $ Opt.progDesc "Get the node's current protocol parameters" , Just $ subParser "constitution-hash" - $ Opt.info (pQueryConstitutionHash envCli) + $ Opt.info (pQueryConstitutionHashCmd envCli) $ Opt.progDesc "Get the constitution hash" , Just $ subParser "tip" - $ Opt.info (pQueryTip envCli) + $ Opt.info (pQueryTipCmd envCli) $ Opt.progDesc "Get the node's current tip (slot no, hash, block no)" , Just $ subParser "stake-pools" - $ Opt.info (pQueryStakePools envCli) + $ Opt.info (pQueryStakePoolsCmd envCli) $ Opt.progDesc "Get the node's current set of stake pool ids" , Just $ subParser "stake-distribution" - $ Opt.info (pQueryStakeDistribution envCli) + $ Opt.info (pQueryStakeDistributionCmd envCli) $ Opt.progDesc "Get the node's current aggregated stake distribution" , Just $ subParser "stake-address-info" - $ Opt.info (pQueryStakeAddressInfo envCli) + $ Opt.info (pQueryStakeAddressInfoCmd envCli) $ Opt.progDesc $ mconcat [ "Get the current delegations and reward accounts filtered by stake address." ] , Just $ subParser "utxo" - $ Opt.info (pQueryUTxO envCli) + $ Opt.info (pQueryUTxOCmd envCli) $ Opt.progDesc $ mconcat [ "Get a portion of the current UTxO: by tx in, by address or the whole." ] , Just $ subParser "ledger-state" - $ Opt.info (pQueryLedgerState envCli) + $ Opt.info (pQueryLedgerStateCmd envCli) $ Opt.progDesc $ mconcat [ "Dump the current ledger state of the node (Ledger.NewEpochState -- advanced command)" ] , Just $ subParser "protocol-state" - $ Opt.info (pQueryProtocolState envCli) + $ Opt.info (pQueryProtocolStateCmd envCli) $ Opt.progDesc $ mconcat [ "Dump the current protocol state of the node (Ledger.ChainDepState -- advanced command)" ] , Just $ subParser "stake-snapshot" - $ Opt.info (pQueryStakeSnapshot envCli) + $ Opt.info (pQueryStakeSnapshotCmd envCli) $ Opt.progDesc $ mconcat [ "Obtain the three stake snapshots for a pool, plus the total active stake (advanced command)" ] , Just $ hiddenSubParser "pool-params" - $ Opt.info (pQueryPoolState envCli) + $ Opt.info (pQueryPoolStateCmd envCli) $ Opt.progDesc $ mconcat [ "DEPRECATED. Use query pool-state instead. Dump the pool parameters " , "(Ledger.NewEpochState.esLState._delegationState._pState._pParams -- advanced command)" ] , Just $ subParser "leadership-schedule" - $ Opt.info (pLeadershipSchedule envCli) + $ Opt.info (pLeadershipScheduleCmd envCli) $ Opt.progDesc "Get the slots the node is expected to mint a block in (advanced command)" , Just $ subParser "kes-period-info" - $ Opt.info (pKesPeriodInfo envCli) + $ Opt.info (pKesPeriodInfoCmd envCli) $ Opt.progDesc "Get information about the current KES period and your node's operational certificate." , Just $ subParser "pool-state" - $ Opt.info (pQueryPoolState envCli) + $ Opt.info (pQueryPoolStateCmd envCli) $ Opt.progDesc "Dump the pool state" , Just $ subParser "tx-mempool" - $ Opt.info (pQueryTxMempool envCli) + $ Opt.info (pQueryTxMempoolCmd envCli) $ Opt.progDesc "Local Mempool info" , Just $ subParser "slot-number" - $ Opt.info (pQuerySlotNumber envCli) + $ Opt.info (pQuerySlotNumberCmd envCli) $ Opt.progDesc "Query slot number for UTC timestamp" ] -pQueryProtocolParameters :: EnvCli -> Parser (QueryCmds era) -pQueryProtocolParameters envCli = - QueryProtocolParameters' - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pMaybeOutputFile +pQueryProtocolParametersCmd :: EnvCli -> Parser (QueryCmds era) +pQueryProtocolParametersCmd envCli = + fmap QueryProtocolParametersCmd $ + QueryProtocolParametersCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pMaybeOutputFile -pQueryConstitutionHash :: EnvCli -> Parser (QueryCmds era) -pQueryConstitutionHash envCli = - QueryConstitutionHash - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pMaybeOutputFile +pQueryConstitutionHashCmd :: EnvCli -> Parser (QueryCmds era) +pQueryConstitutionHashCmd envCli = + fmap QueryConstitutionHashCmd $ + QueryConstitutionHashCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pMaybeOutputFile -pQueryTip :: EnvCli -> Parser (QueryCmds era) -pQueryTip envCli = - QueryTip - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pMaybeOutputFile +pQueryTipCmd :: EnvCli -> Parser (QueryCmds era) +pQueryTipCmd envCli = + fmap QueryTipCmd $ + QueryTipCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pMaybeOutputFile -pQueryUTxO :: EnvCli -> Parser (QueryCmds era) -pQueryUTxO envCli = - QueryUTxO' - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pQueryUTxOFilter - <*> pNetworkId envCli - <*> pMaybeOutputFile +pQueryUTxOCmd :: EnvCli -> Parser (QueryCmds era) +pQueryUTxOCmd envCli = + fmap QueryUTxOCmd $ + QueryUTxOCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pQueryUTxOFilter + <*> pNetworkId envCli + <*> pMaybeOutputFile -pQueryStakePools :: EnvCli -> Parser (QueryCmds era) -pQueryStakePools envCli = - QueryStakePools' - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pMaybeOutputFile +pQueryStakePoolsCmd :: EnvCli -> Parser (QueryCmds era) +pQueryStakePoolsCmd envCli = + fmap QueryStakePoolsCmd $ + QueryStakePoolsCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pMaybeOutputFile -pQueryStakeDistribution :: EnvCli -> Parser (QueryCmds era) -pQueryStakeDistribution envCli = - QueryStakeDistribution' - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pMaybeOutputFile +pQueryStakeDistributionCmd :: EnvCli -> Parser (QueryCmds era) +pQueryStakeDistributionCmd envCli = + fmap QueryStakeDistributionCmd $ + QueryStakeDistributionCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pMaybeOutputFile -pQueryStakeAddressInfo :: EnvCli -> Parser (QueryCmds era) -pQueryStakeAddressInfo envCli = - QueryStakeAddressInfo - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pFilterByStakeAddress - <*> pNetworkId envCli - <*> pMaybeOutputFile +pQueryStakeAddressInfoCmd :: EnvCli -> Parser (QueryCmds era) +pQueryStakeAddressInfoCmd envCli = + fmap QueryStakeAddressInfoCmd $ + QueryStakeAddressInfoCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pFilterByStakeAddress + <*> pNetworkId envCli + <*> pMaybeOutputFile -pQueryLedgerState :: EnvCli -> Parser (QueryCmds era) -pQueryLedgerState envCli = - QueryDebugLedgerState' - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pMaybeOutputFile +pQueryLedgerStateCmd :: EnvCli -> Parser (QueryCmds era) +pQueryLedgerStateCmd envCli = + fmap QueryLedgerStateCmd $ + QueryLedgerStateCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pMaybeOutputFile -pQueryProtocolState :: EnvCli -> Parser (QueryCmds era) -pQueryProtocolState envCli = - QueryProtocolState' - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pMaybeOutputFile +pQueryProtocolStateCmd :: EnvCli -> Parser (QueryCmds era) +pQueryProtocolStateCmd envCli = + fmap QueryProtocolStateCmd $ + QueryProtocolStateCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pMaybeOutputFile pAllStakePoolsOrOnly :: Parser (AllOrOnly [Hash StakePoolKey]) pAllStakePoolsOrOnly = pAll <|> pOnly @@ -196,31 +205,34 @@ pAllStakePoolsOrOnly = pAll <|> pOnly pOnly :: Parser (AllOrOnly [Hash StakePoolKey]) pOnly = Only <$> many (pStakePoolVerificationKeyHash Nothing) -pQueryStakeSnapshot :: EnvCli -> Parser (QueryCmds era) -pQueryStakeSnapshot envCli = - QueryStakeSnapshot' - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pAllStakePoolsOrOnly - <*> pMaybeOutputFile +pQueryStakeSnapshotCmd :: EnvCli -> Parser (QueryCmds era) +pQueryStakeSnapshotCmd envCli = + fmap QueryStakeSnapshotCmd $ + QueryStakeSnapshotCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pAllStakePoolsOrOnly + <*> pMaybeOutputFile -pQueryPoolState :: EnvCli -> Parser (QueryCmds era) -pQueryPoolState envCli = - QueryPoolState' - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> many (pStakePoolVerificationKeyHash Nothing) +pQueryPoolStateCmd :: EnvCli -> Parser (QueryCmds era) +pQueryPoolStateCmd envCli = + fmap QueryPoolStateCmd $ + QueryPoolStateCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> many (pStakePoolVerificationKeyHash Nothing) -pQueryTxMempool :: EnvCli -> Parser (QueryCmds era) -pQueryTxMempool envCli = - QueryTxMempool - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pTxMempoolQuery - <*> pMaybeOutputFile +pQueryTxMempoolCmd :: EnvCli -> Parser (QueryCmds era) +pQueryTxMempoolCmd envCli = + fmap QueryTxMempoolCmd $ + QueryTxMempoolCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pTxMempoolQuery + <*> pMaybeOutputFile where pTxMempoolQuery :: Parser TxMempoolQuery pTxMempoolQuery = asum @@ -234,37 +246,40 @@ pQueryTxMempool envCli = $ Opt.info (TxMempoolQueryTxExists <$> argument Opt.str (metavar "TX_ID")) $ Opt.progDesc "Query if a particular transaction exists in the mempool" ] -pLeadershipSchedule :: EnvCli -> Parser (QueryCmds era) -pLeadershipSchedule envCli = - QueryLeadershipSchedule - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pGenesisFile "Shelley genesis filepath" - <*> pStakePoolVerificationKeyOrHashOrFile Nothing - <*> pVrfSigningKeyFile - <*> pWhichLeadershipSchedule - <*> pMaybeOutputFile +pLeadershipScheduleCmd :: EnvCli -> Parser (QueryCmds era) +pLeadershipScheduleCmd envCli = + fmap QueryLeadershipScheduleCmd $ + QueryLeadershipScheduleCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pGenesisFile "Shelley genesis filepath" + <*> pStakePoolVerificationKeyOrHashOrFile Nothing + <*> pVrfSigningKeyFile + <*> pWhichLeadershipSchedule + <*> pMaybeOutputFile -pKesPeriodInfo :: EnvCli -> Parser (QueryCmds era) -pKesPeriodInfo envCli = - QueryKesPeriodInfo - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pOperationalCertificateFile - <*> pMaybeOutputFile +pKesPeriodInfoCmd :: EnvCli -> Parser (QueryCmds era) +pKesPeriodInfoCmd envCli = + fmap QueryKesPeriodInfoCmd $ + QueryKesPeriodInfoCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pOperationalCertificateFile + <*> pMaybeOutputFile -pQuerySlotNumber :: EnvCli -> Parser (QueryCmds era) -pQuerySlotNumber envCli = - QuerySlotNumber - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pUtcTimestamp - where - pUtcTimestamp = - convertTime <$> (Opt.strArgument . mconcat) - [ Opt.metavar "TIMESTAMP" - , Opt.help "UTC timestamp in YYYY-MM-DDThh:mm:ssZ format" - ] +pQuerySlotNumberCmd :: EnvCli -> Parser (QueryCmds era) +pQuerySlotNumberCmd envCli = + fmap QuerySlotNumberCmd $ + QuerySlotNumberCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pUtcTimestamp + where + pUtcTimestamp = + convertTime <$> (Opt.strArgument . mconcat) + [ Opt.metavar "TIMESTAMP" + , Opt.help "UTC timestamp in YYYY-MM-DDThh:mm:ssZ format" + ] diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/StakeAddress.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/StakeAddress.hs index 309a243029..be0d1a6ec3 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/StakeAddress.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/StakeAddress.hs @@ -39,7 +39,7 @@ pStakeAddressKeyGenCmd :: () => CardanoEra era -> Maybe (Parser (StakeAddressCmds era)) pStakeAddressKeyGenCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "key-gen" $ Opt.info @@ -54,7 +54,7 @@ pStakeAddressKeyHashCmd :: () => CardanoEra era -> Maybe (Parser (StakeAddressCmds era)) pStakeAddressKeyHashCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "key-hash" $ Opt.info @@ -69,7 +69,7 @@ pStakeAddressBuildCmd :: () -> EnvCli -> Maybe (Parser (StakeAddressCmds era)) pStakeAddressBuildCmd era envCli = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "build" $ Opt.info @@ -84,7 +84,7 @@ pStakeAddressRegistrationCertificateCmd :: () => CardanoEra era -> Maybe (Parser (StakeAddressCmds era)) pStakeAddressRegistrationCertificateCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "registration-certificate" $ Opt.info @@ -99,7 +99,7 @@ pStakeAddressDeregistrationCertificateCmd :: () => CardanoEra era -> Maybe (Parser (StakeAddressCmds era)) pStakeAddressDeregistrationCertificateCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "deregistration-certificate" $ Opt.info @@ -114,7 +114,7 @@ pStakeAddressStakeDelegationCertificateCmd :: () => CardanoEra era -> Maybe (Parser (StakeAddressCmds era)) pStakeAddressStakeDelegationCertificateCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "stake-delegation-certificate" $ Opt.info @@ -133,7 +133,7 @@ pStakeAddressStakeAndVoteDelegationCertificateCmd :: () => CardanoEra era -> Maybe (Parser (StakeAddressCmds era)) pStakeAddressStakeAndVoteDelegationCertificateCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "stake-and-vote-delegation-certificate" $ Opt.info @@ -153,7 +153,7 @@ pStakeAddressVoteDelegationCertificateCmd :: () => CardanoEra era -> Maybe (Parser (StakeAddressCmds era)) pStakeAddressVoteDelegationCertificateCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "vote-delegation-certificate" $ Opt.info diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/StakePool.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/StakePool.hs index 2a019776ce..7625a641e3 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/StakePool.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/StakePool.hs @@ -57,7 +57,7 @@ pStakePoolMetadataHashCmd = pStakePoolRegistrationCertificateCmd :: CardanoEra era -> EnvCli -> Maybe (Parser (StakePoolCmds era)) pStakePoolRegistrationCertificateCmd era envCli = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "registration-certificate" $ Opt.info @@ -78,7 +78,7 @@ pStakePoolRegistrationCertificateCmd era envCli = do pStakePoolDeregistrationCertificateCmd :: CardanoEra era -> Maybe (Parser (StakePoolCmds era)) pStakePoolDeregistrationCertificateCmd era = do - w <- maybeEonInEra era + w <- forEraMaybeEon era pure $ subParser "deregistration-certificate" $ Opt.info diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run.hs index 6fb79dcf15..60045fcf0b 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run.hs @@ -31,6 +31,7 @@ import Cardano.CLI.Types.Errors.CmdError import Control.Monad.Trans.Except import Control.Monad.Trans.Except.Extra (firstExceptT) import Data.Function ((&)) +import Cardano.CLI.EraBased.Run.Governance.Poll (runGovernancePollCmds) runAnyEraCommand :: () => AnyEraCommand @@ -95,6 +96,10 @@ runGovernanceCmds = \case GovernanceDRepCmds cmds -> runGovernanceDRepCmds cmds + GovernancePollCmds cmds -> + runGovernancePollCmds cmds + & firstExceptT CmdGovernanceCmdError + GovernanceVoteCmds cmds -> runGovernanceVoteCmds cmds 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 f99b6815fb..199fa23930 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs @@ -19,7 +19,6 @@ import Cardano.CLI.Read import Cardano.CLI.Types.Common import Cardano.CLI.Types.Errors.GovernanceActionsError import Cardano.CLI.Types.Key -import qualified Cardano.Ledger.Conway.Governance as Ledger import Control.Monad import Control.Monad.Except (ExceptT) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs index 7ca8c9476d..2ff2655932 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs @@ -41,9 +41,10 @@ runGovernanceDRepCmds = \case runGovernanceDRepIdCmd w vkey idOutputFormat mOutFp & firstExceptT CmdGovernanceCmdError - GovernanceDRepRegistrationCertificateCmd w vkey lovelace outFp -> - runGovernanceRegistrationCertificateCmd w vkey lovelace outFp - & firstExceptT CmdRegistrationError + GovernanceDRepRegistrationCertificateCmd w vkey lovelace anchor outFp -> + conwayEraOnwardsConstraints w $ do + runGovernanceRegistrationCertificateCmd w vkey lovelace anchor outFp + & firstExceptT CmdRegistrationError runGovernanceDRepIdCmd :: () => ConwayEraOnwards era @@ -72,16 +73,17 @@ runGovernanceRegistrationCertificateCmd :: ConwayEraOnwards era -> VerificationKeyOrHashOrFile DRepKey -> Lovelace + -> Maybe (Ledger.Anchor (Ledger.EraCrypto (ShelleyLedgerEra era))) -> File () Out -> ExceptT RegistrationError IO () -runGovernanceRegistrationCertificateCmd cOnwards drepKOrHOrF deposit outfp = do +runGovernanceRegistrationCertificateCmd cOnwards drepKOrHOrF deposit anchor outfp = do DRepKeyHash drepKeyHash <- firstExceptT RegistrationReadError . newExceptT $ readVerificationKeyOrHashOrFile AsDRepKey drepKOrHOrF let drepCred = Ledger.KeyHashObj $ conwayEraOnwardsConstraints cOnwards drepKeyHash votingCredential = VotingCredential drepCred req = DRepRegistrationRequirements cOnwards votingCredential deposit - registrationCert = makeDrepRegistrationCertificate req + registrationCert = makeDrepRegistrationCertificate req anchor description = Just @TextEnvelopeDescr "DRep Key Registration Certificate" firstExceptT RegistrationWriteFileError diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Poll.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Poll.hs new file mode 100644 index 0000000000..ef42f893b0 --- /dev/null +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Poll.hs @@ -0,0 +1,170 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module Cardano.CLI.EraBased.Run.Governance.Poll + ( runGovernancePollCmds + ) where + +import Cardano.Api +import Cardano.Api.Shelley +import qualified Cardano.Api.Shelley as Api + +import Cardano.CLI.EraBased.Commands.Governance.Poll +import Cardano.CLI.Read +import Cardano.CLI.Types.Errors.GovernanceCmdError + +import Control.Monad +import Control.Monad.IO.Class +import Control.Monad.Trans.Class (lift) +import Control.Monad.Trans.Except (ExceptT) +import Control.Monad.Trans.Except.Extra +import qualified Data.ByteString.Char8 as BSC +import Data.Function ((&)) +import Data.String (fromString) +import Data.Text (Text) +import qualified Data.Text as Text +import qualified Data.Text.Encoding as Text +import qualified Data.Text.IO as Text +import qualified Data.Text.Read as Text +import qualified System.IO as IO +import System.IO (stderr, stdin, stdout) + + +runGovernancePollCmds :: GovernancePollCmds era -> ExceptT GovernanceCmdError IO () +runGovernancePollCmds = \case + GovernanceCreatePoll w prompt choices nonce out -> + runGovernanceCreatePoll w prompt choices nonce out + GovernanceAnswerPoll w poll ix mOutFile -> + runGovernanceAnswerPoll w poll ix mOutFile + GovernanceVerifyPoll w poll metadata mOutFile -> + runGovernanceVerifyPoll w poll metadata mOutFile + +runGovernanceCreatePoll + :: BabbageEraOnwards era + -> Text + -> [Text] + -> Maybe Word + -> File GovernancePoll Out + -> ExceptT GovernanceCmdError IO () +runGovernanceCreatePoll _w govPollQuestion govPollAnswers govPollNonce out = do + let poll = GovernancePoll{ govPollQuestion, govPollAnswers, govPollNonce } + + let description = fromString $ "An on-chain poll for SPOs: " <> Text.unpack govPollQuestion + firstExceptT GovernanceCmdTextEnvWriteError . newExceptT $ + writeFileTextEnvelope out (Just description) poll + + let metadata = asTxMetadata poll + & metadataToJson TxMetadataJsonDetailedSchema + + let outPath = unFile out & Text.encodeUtf8 . Text.pack + + liftIO $ do + BSC.hPutStrLn stderr $ mconcat + [ "Poll created successfully.\n" + , "Please submit a transaction using the resulting metadata.\n" + ] + BSC.hPutStrLn stdout (prettyPrintJSON metadata) + BSC.hPutStrLn stderr $ mconcat + [ "\n" + , "Hint (1): Use '--json-metadata-detailed-schema' and '--metadata-json-file' " + , "from the build or build-raw commands.\n" + , "Hint (2): You can redirect the standard output of this command to a JSON " + , "file to capture metadata.\n\n" + , "Note: A serialized version of the poll suitable for sharing with " + , "participants has been generated at '" <> outPath <> "'." + ] + +runGovernanceAnswerPoll + :: BabbageEraOnwards era + -> File GovernancePoll In + -> Maybe Word -- ^ Answer index + -> Maybe (File () Out) -- ^ Output file + -> ExceptT GovernanceCmdError IO () +runGovernanceAnswerPoll _ pollFile maybeChoice mOutFile = do + poll <- firstExceptT GovernanceCmdTextEnvReadError . newExceptT $ + readFileTextEnvelope AsGovernancePoll pollFile + + choice <- case maybeChoice of + Nothing -> do + askInteractively poll + Just ix -> do + validateChoice poll ix + liftIO $ BSC.hPutStrLn stderr $ Text.encodeUtf8 $ Text.intercalate "\n" + [ govPollQuestion poll + , "→ " <> (govPollAnswers poll !! fromIntegral ix) + , "" + ] + pure ix + + let pollAnswer = GovernancePollAnswer + { govAnsPoll = hashGovernancePoll poll + , govAnsChoice = choice + } + let metadata = + metadataToJson TxMetadataJsonDetailedSchema (asTxMetadata pollAnswer) + + liftIO $ BSC.hPutStrLn stderr $ mconcat + [ "Poll answer created successfully.\n" + , "Please submit a transaction using the resulting metadata.\n" + , "To be valid, the transaction must also be signed using a valid key\n" + , "identifying your stake pool (e.g. your cold key).\n" + ] + + lift (writeByteStringOutput mOutFile (prettyPrintJSON metadata)) + & onLeft (left . GovernanceCmdWriteFileError) + + liftIO $ BSC.hPutStrLn stderr $ mconcat + [ "\n" + , "Hint (1): Use '--json-metadata-detailed-schema' and '--metadata-json-file' " + , "from the build or build-raw commands.\n" + , "Hint (2): You can redirect the standard output of this command to a JSON " + , "file to capture metadata." + ] + where + validateChoice :: GovernancePoll -> Word -> ExceptT GovernanceCmdError IO () + validateChoice GovernancePoll{govPollAnswers} ix = do + let maxAnswerIndex = length govPollAnswers - 1 + when (fromIntegral ix > maxAnswerIndex) $ left $ + GovernanceCmdPollOutOfBoundAnswer maxAnswerIndex + + askInteractively :: GovernancePoll -> ExceptT GovernanceCmdError IO Word + askInteractively poll@GovernancePoll{govPollQuestion, govPollAnswers} = do + liftIO $ BSC.hPutStrLn stderr $ Text.encodeUtf8 $ Text.intercalate "\n" + ( govPollQuestion + : [ "[" <> textShow ix <> "] " <> answer + | (ix :: Int, answer) <- zip [0..] govPollAnswers + ] + ) + liftIO $ BSC.hPutStrLn stderr "" + liftIO $ BSC.hPutStr stderr "Please indicate an answer (by index): " + txt <- liftIO $ Text.hGetLine stdin + liftIO $ BSC.hPutStrLn stderr "" + case Text.decimal txt of + Right (choice, rest) | Text.null rest -> + choice <$ validateChoice poll choice + _ -> + left GovernanceCmdPollInvalidChoice + +runGovernanceVerifyPoll + :: BabbageEraOnwards era + -> File GovernancePoll In + -> File (Api.Tx ()) In + -> Maybe (File () Out) -- ^ Output file + -> ExceptT GovernanceCmdError IO () +runGovernanceVerifyPoll _ pollFile txFile mOutFile = do + poll <- firstExceptT GovernanceCmdTextEnvReadError . newExceptT $ + readFileTextEnvelope AsGovernancePoll pollFile + + txFileOrPipe <- liftIO $ fileOrPipe (unFile txFile) + tx <- firstExceptT GovernanceCmdCddlError . newExceptT $ + readFileTx txFileOrPipe + + signatories <- firstExceptT GovernanceCmdVerifyPollError . newExceptT $ pure $ + verifyPollAnswer poll tx + + liftIO $ IO.hPutStrLn stderr $ "Found valid poll answer with " <> show (length signatories) <> " signatories" + + lift (writeByteStringOutput mOutFile (prettyPrintJSON signatories)) + & onLeft (left . GovernanceCmdWriteFileError) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Vote.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Vote.hs index 2f23299430..e6c0db0b93 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Vote.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Vote.hs @@ -45,11 +45,11 @@ runGovernanceVoteCreateCmd (ConwayOnwardsVote cOnwards voteChoice (govActionTxId . newExceptT $ readVerificationKeyOrHashOrTextEnvFile AsDRepKey stake let vStakeCred = StakeCredentialByKey . StakeKeyHash $ coerceKeyRole h - votingCred <- hoistEither $ first GovernanceVoteCmdCredentialDecodeError $ toVotingCredential sbe vStakeCred + votingCred <- hoistEither $ first GovernanceVoteCmdCredentialDecodeError $ toVotingCredential cOnwards vStakeCred let voter = Ledger.DRepVoter (unVotingCredential votingCred) govActIdentifier = createGovernanceActionId govActionTxId govActionIndex - voteProcedure = createVotingProcedure sbe voteChoice Nothing - votingProcedures = singletonVotingProcedures sbe voter govActIdentifier (unVotingProcedure voteProcedure) + voteProcedure = createVotingProcedure cOnwards voteChoice Nothing + votingProcedures = singletonVotingProcedures cOnwards voter govActIdentifier (unVotingProcedure voteProcedure) firstExceptT GovernanceVoteCmdWriteError . newExceptT $ writeFileTextEnvelope oFp Nothing votingProcedures AnyStakePoolVerificationKeyOrHashOrFile stake -> do @@ -58,17 +58,17 @@ runGovernanceVoteCreateCmd (ConwayOnwardsVote cOnwards voteChoice (govActionTxId let voter = Ledger.StakePoolVoter (unStakePoolKeyHash h) govActIdentifier = createGovernanceActionId govActionTxId govActionIndex - voteProcedure = createVotingProcedure sbe voteChoice Nothing - votingProcedures = singletonVotingProcedures sbe voter govActIdentifier (unVotingProcedure voteProcedure) + voteProcedure = createVotingProcedure cOnwards voteChoice Nothing + votingProcedures = singletonVotingProcedures cOnwards voter govActIdentifier (unVotingProcedure voteProcedure) firstExceptT GovernanceVoteCmdWriteError . newExceptT $ writeFileTextEnvelope oFp Nothing votingProcedures AnyCommitteeHotVerificationKeyOrHashOrFile stake -> do CommitteeHotKeyHash h <- firstExceptT GovernanceVoteCmdReadError . newExceptT $ readVerificationKeyOrHashOrTextEnvFile AsCommitteeHotKey stake let vStakeCred = StakeCredentialByKey . StakeKeyHash $ coerceKeyRole h - votingCred <- hoistEither $ first GovernanceVoteCmdCredentialDecodeError $ toVotingCredential sbe vStakeCred + votingCred <- hoistEither $ first GovernanceVoteCmdCredentialDecodeError $ toVotingCredential cOnwards vStakeCred let voter = Ledger.CommitteeVoter (Ledger.coerceKeyRole (unVotingCredential votingCred)) -- TODO Conway - remove coerceKeyRole govActIdentifier = createGovernanceActionId govActionTxId govActionIndex - voteProcedure = createVotingProcedure sbe voteChoice Nothing - votingProcedures = singletonVotingProcedures sbe voter govActIdentifier (unVotingProcedure voteProcedure) + voteProcedure = createVotingProcedure cOnwards voteChoice Nothing + votingProcedures = singletonVotingProcedures cOnwards voter govActIdentifier (unVotingProcedure voteProcedure) firstExceptT GovernanceVoteCmdWriteError . newExceptT $ writeFileTextEnvelope oFp Nothing votingProcedures diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs index 8555b87c97..106a356653 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs @@ -5,6 +5,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} +{-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} @@ -42,15 +43,14 @@ import Cardano.Api.Byron hiding (QueryInShelleyBasedEra (..)) import qualified Cardano.Api.Ledger as Ledger import Cardano.Api.Shelley hiding (QueryInShelleyBasedEra (..)) -import Cardano.CLI.EraBased.Commands.Query +import qualified Cardano.CLI.EraBased.Commands.Query as Cmd import Cardano.CLI.EraBased.Run.Genesis (readAndDecodeShelleyGenesis) import Cardano.CLI.Helpers (pPrintCBOR) import Cardano.CLI.Pretty import Cardano.CLI.Types.Common import Cardano.CLI.Types.Errors.QueryCmdError import Cardano.CLI.Types.Errors.QueryCmdLocalStateQueryError -import Cardano.CLI.Types.Key (VerificationKeyOrHashOrFile, - readVerificationKeyOrHashOrFile) +import Cardano.CLI.Types.Key import qualified Cardano.CLI.Types.Output as O import Cardano.Crypto.Hash (hashToBytesAsHex) import qualified Cardano.Crypto.Hash.Blake2b as Blake2b @@ -104,47 +104,35 @@ import Text.Printf (printf) {- HLINT ignore "Move brackets to avoid $" -} {- HLINT ignore "Redundant flip" -} -runQueryCmds :: QueryCmds era -> ExceptT QueryCmdError IO () +runQueryCmds :: Cmd.QueryCmds era -> ExceptT QueryCmdError IO () runQueryCmds = \case - QueryLeadershipSchedule mNodeSocketPath consensusModeParams network shelleyGenFp poolid vrkSkeyFp whichSchedule outputAs -> - runQueryLeadershipScheduleCmd mNodeSocketPath consensusModeParams network shelleyGenFp poolid vrkSkeyFp whichSchedule outputAs - QueryProtocolParameters' mNodeSocketPath consensusModeParams network mOutFile -> - runQueryProtocolParametersCmd mNodeSocketPath consensusModeParams network mOutFile - QueryConstitutionHash mNodeSocketPath consensusModeParams network mOutFile -> - runQueryConstitutionHashCmd mNodeSocketPath consensusModeParams network mOutFile - QueryTip mNodeSocketPath consensusModeParams network mOutFile -> - runQueryTipCmd mNodeSocketPath consensusModeParams network mOutFile - QueryStakePools' mNodeSocketPath consensusModeParams network mOutFile -> - runQueryStakePoolsCmd mNodeSocketPath consensusModeParams network mOutFile - QueryStakeDistribution' mNodeSocketPath consensusModeParams network mOutFile -> - runQueryStakeDistributionCmd mNodeSocketPath consensusModeParams network mOutFile - QueryStakeAddressInfo mNodeSocketPath consensusModeParams addr network mOutFile -> - runQueryStakeAddressInfoCmd mNodeSocketPath consensusModeParams addr network mOutFile - QueryDebugLedgerState' mNodeSocketPath consensusModeParams network mOutFile -> - runQueryLedgerStateCmd mNodeSocketPath consensusModeParams network mOutFile - QueryStakeSnapshot' mNodeSocketPath consensusModeParams network allOrOnlyPoolIds mOutFile -> - runQueryStakeSnapshotCmd mNodeSocketPath consensusModeParams network allOrOnlyPoolIds mOutFile - QueryProtocolState' mNodeSocketPath consensusModeParams network mOutFile -> - runQueryProtocolStateCmd mNodeSocketPath consensusModeParams network mOutFile - QueryUTxO' mNodeSocketPath consensusModeParams qFilter networkId mOutFile -> - runQueryUTxOCmd mNodeSocketPath consensusModeParams qFilter networkId mOutFile - QueryKesPeriodInfo mNodeSocketPath consensusModeParams network nodeOpCert mOutFile -> - runQueryKesPeriodInfoCmd mNodeSocketPath consensusModeParams network nodeOpCert mOutFile - QueryPoolState' mNodeSocketPath consensusModeParams network poolid -> - runQueryPoolStateCmd mNodeSocketPath consensusModeParams network poolid - QueryTxMempool mNodeSocketPath consensusModeParams network op mOutFile -> - runQueryTxMempoolCmd mNodeSocketPath consensusModeParams network op mOutFile - QuerySlotNumber mNodeSocketPath consensusModeParams network utcTime -> - runQuerySlotNumberCmd mNodeSocketPath consensusModeParams network utcTime - -runQueryConstitutionHashCmd - :: SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Maybe (File () Out) + Cmd.QueryLeadershipScheduleCmd args -> runQueryLeadershipScheduleCmd args + Cmd.QueryProtocolParametersCmd args -> runQueryProtocolParametersCmd args + Cmd.QueryConstitutionHashCmd args -> runQueryConstitutionHashCmd args + Cmd.QueryTipCmd args -> runQueryTipCmd args + Cmd.QueryStakePoolsCmd args -> runQueryStakePoolsCmd args + Cmd.QueryStakeDistributionCmd args -> runQueryStakeDistributionCmd args + Cmd.QueryStakeAddressInfoCmd args -> runQueryStakeAddressInfoCmd args + Cmd.QueryLedgerStateCmd args -> runQueryLedgerStateCmd args + Cmd.QueryStakeSnapshotCmd args -> runQueryStakeSnapshotCmd args + Cmd.QueryProtocolStateCmd args -> runQueryProtocolStateCmd args + Cmd.QueryUTxOCmd args -> runQueryUTxOCmd args + Cmd.QueryKesPeriodInfoCmd args -> runQueryKesPeriodInfoCmd args + Cmd.QueryPoolStateCmd args -> runQueryPoolStateCmd args + Cmd.QueryTxMempoolCmd args -> runQueryTxMempoolCmd args + Cmd.QuerySlotNumberCmd args -> runQuerySlotNumberCmd args + +runQueryConstitutionHashCmd :: () + => Cmd.QueryConstitutionHashCmdArgs -> ExceptT QueryCmdError IO () -runQueryConstitutionHashCmd socketPath (AnyConsensusModeParams cModeParams) network mOutFile = do - let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath +runQueryConstitutionHashCmd + Cmd.QueryConstitutionHashCmdArgs + { Cmd.nodeSocketPath + , Cmd.consensusModeParams = AnyConsensusModeParams cModeParams + , Cmd.networkId + , Cmd.mOutFile + } = do + let localNodeConnInfo = LocalNodeConnectInfo cModeParams networkId nodeSocketPath result <- liftIO $ executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do anyE@(AnyCardanoEra era) <- lift (determineEraExpr cModeParams) @@ -175,14 +163,17 @@ runQueryConstitutionHashCmd socketPath (AnyConsensusModeParams cModeParams) netw handleIOExceptT (QueryCmdWriteFileError . FileIOError fpath) $ LBS.writeFile fpath (encodePretty cHash) -runQueryProtocolParametersCmd - :: SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Maybe (File () Out) +runQueryProtocolParametersCmd :: () + => Cmd.QueryProtocolParametersCmdArgs -> ExceptT QueryCmdError IO () -runQueryProtocolParametersCmd socketPath (AnyConsensusModeParams cModeParams) network mOutFile = do - let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath +runQueryProtocolParametersCmd + Cmd.QueryProtocolParametersCmdArgs + { Cmd.nodeSocketPath + , Cmd.consensusModeParams = AnyConsensusModeParams cModeParams + , Cmd.networkId + , Cmd.mOutFile + } = do + let localNodeConnInfo = LocalNodeConnectInfo cModeParams networkId nodeSocketPath anyE@(AnyCardanoEra era) <- firstExceptT QueryCmdAcquireFailure $ newExceptT $ determineEra cModeParams localNodeConnInfo sbe <- case cardanoEraStyle era of LegacyByronEra -> left QueryCmdByronEra @@ -244,16 +235,19 @@ queryChainTipViaChainSync localNodeConnInfo = do "Warning: Local header state query unavailable. Falling back to chain sync query" liftIO $ getLocalChainTip localNodeConnInfo -runQueryTipCmd - :: SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Maybe (File () Out) +runQueryTipCmd :: () + => Cmd.QueryTipCmdArgs -> ExceptT QueryCmdError IO () -runQueryTipCmd socketPath (AnyConsensusModeParams cModeParams) network mOutFile = do +runQueryTipCmd + Cmd.QueryTipCmdArgs + { Cmd.nodeSocketPath + , Cmd.consensusModeParams = AnyConsensusModeParams cModeParams + , Cmd.networkId + , Cmd.mOutFile + } = do case consensusModeOnly cModeParams of CardanoMode -> do - let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath + let localNodeConnInfo = LocalNodeConnectInfo cModeParams networkId nodeSocketPath eLocalState <- ExceptT $ fmap sequence $ executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do @@ -328,16 +322,18 @@ runQueryTipCmd socketPath (AnyConsensusModeParams cModeParams) network mOutFile -- | Query the UTxO, filtered by a given set of addresses, from a Shelley node -- via the local state query protocol. -runQueryUTxOCmd - :: SocketPath - -> AnyConsensusModeParams - -> QueryUTxOFilter - -> NetworkId - -> Maybe (File () Out) +runQueryUTxOCmd :: () + => Cmd.QueryUTxOCmdArgs -> ExceptT QueryCmdError IO () -runQueryUTxOCmd socketPath (AnyConsensusModeParams cModeParams) - qfilter network mOutFile = do - let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath +runQueryUTxOCmd + Cmd.QueryUTxOCmdArgs + { Cmd.nodeSocketPath + , Cmd.consensusModeParams = AnyConsensusModeParams cModeParams + , Cmd.queryFilter + , Cmd.networkId + , Cmd.mOutFile + } = do + let localNodeConnInfo = LocalNodeConnectInfo cModeParams networkId nodeSocketPath join $ lift ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do @@ -356,7 +352,7 @@ runQueryUTxOCmd socketPath (AnyConsensusModeParams cModeParams) requireNotByronEraInByronMode eraInMode - utxo <- lift (queryUtxo eInMode sbe qfilter) + utxo <- lift (queryUtxo eInMode sbe queryFilter) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError) @@ -366,18 +362,21 @@ runQueryUTxOCmd socketPath (AnyConsensusModeParams cModeParams) & onLeft (left . QueryCmdAcquireFailure) & onLeft left -runQueryKesPeriodInfoCmd - :: SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> File () In - -> Maybe (File () Out) +runQueryKesPeriodInfoCmd :: () + => Cmd.QueryKesPeriodInfoCmdArgs -> ExceptT QueryCmdError IO () -runQueryKesPeriodInfoCmd socketPath (AnyConsensusModeParams cModeParams) network nodeOpCertFile mOutFile = do - opCert <- lift (readFileTextEnvelope AsOperationalCertificate nodeOpCertFile) +runQueryKesPeriodInfoCmd + Cmd.QueryKesPeriodInfoCmdArgs + { Cmd.nodeSocketPath + , Cmd.consensusModeParams = AnyConsensusModeParams cModeParams + , Cmd.networkId + , Cmd.nodeOpCertFp + , Cmd.mOutFile + } = do + opCert <- lift (readFileTextEnvelope AsOperationalCertificate nodeOpCertFp) & onLeft (left . QueryCmdOpCertCounterReadError) - let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath + let localNodeConnInfo = LocalNodeConnectInfo cModeParams networkId nodeSocketPath let cMode = consensusModeOnly cModeParams @@ -428,8 +427,8 @@ runQueryKesPeriodInfoCmd socketPath (AnyConsensusModeParams cModeParams) network let counterInformation = opCertNodeAndOnDiskCounters onDiskC stateC -- Always render diagnostic information - liftIO . putStrLn $ renderOpCertIntervalInformation (unFile nodeOpCertFile) opCertIntervalInformation - liftIO . putStrLn $ renderOpCertNodeAndOnDiskCounterInformation (unFile nodeOpCertFile) counterInformation + liftIO . putStrLn $ renderOpCertIntervalInformation (unFile nodeOpCertFp) opCertIntervalInformation + liftIO . putStrLn $ renderOpCertNodeAndOnDiskCounterInformation (unFile nodeOpCertFp) counterInformation let qKesInfoOutput = createQueryKesPeriodInfoOutput opCertIntervalInformation counterInformation eInfo gParams kesPeriodInfoJSON = encodePretty qKesInfoOutput @@ -647,14 +646,17 @@ renderOpCertIntervalInformation opCertFile opCertInfo = case opCertInfo of -- | Query the current and future parameters for a stake pool, including the retirement date. -- Any of these may be empty (in which case a null will be displayed). -- -runQueryPoolStateCmd - :: SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> [Hash StakePoolKey] +runQueryPoolStateCmd :: () + => Cmd.QueryPoolStateCmdArgs -> ExceptT QueryCmdError IO () -runQueryPoolStateCmd socketPath (AnyConsensusModeParams cModeParams) network poolIds = do - let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath +runQueryPoolStateCmd + Cmd.QueryPoolStateCmdArgs + { Cmd.nodeSocketPath + , Cmd.consensusModeParams = AnyConsensusModeParams cModeParams + , Cmd.networkId + , Cmd.poolIds + } = do + let localNodeConnInfo = LocalNodeConnectInfo cModeParams networkId nodeSocketPath join $ lift ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do @@ -684,15 +686,18 @@ runQueryPoolStateCmd socketPath (AnyConsensusModeParams cModeParams) network poo & onLeft left -- | Query the local mempool state -runQueryTxMempoolCmd - :: SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> TxMempoolQuery - -> Maybe (File () Out) +runQueryTxMempoolCmd :: () + => Cmd.QueryTxMempoolCmdArgs -> ExceptT QueryCmdError IO () -runQueryTxMempoolCmd socketPath (AnyConsensusModeParams cModeParams) network query mOutFile = do - let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath +runQueryTxMempoolCmd + Cmd.QueryTxMempoolCmdArgs + { Cmd.nodeSocketPath + , Cmd.consensusModeParams = AnyConsensusModeParams cModeParams + , Cmd.networkId + , Cmd.query + , Cmd.mOutFile + } = do + let localNodeConnInfo = LocalNodeConnectInfo cModeParams networkId nodeSocketPath localQuery <- case query of TxMempoolQueryTxExists tx -> do @@ -713,28 +718,34 @@ runQueryTxMempoolCmd socketPath (AnyConsensusModeParams cModeParams) network que Just (File oFp) -> handleIOExceptT (QueryCmdWriteFileError . FileIOError oFp) $ LBS.writeFile oFp renderedResult -runQuerySlotNumberCmd - :: SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> UTCTime +runQuerySlotNumberCmd :: () + => Cmd.QuerySlotNumberCmdArgs -> ExceptT QueryCmdError IO () -runQuerySlotNumberCmd sockPath aCmp network utcTime = do - SlotNo slotNo <- utcTimeToSlotNo sockPath aCmp network utcTime +runQuerySlotNumberCmd + Cmd.QuerySlotNumberCmdArgs + { Cmd.nodeSocketPath + , Cmd.consensusModeParams + , Cmd.networkId + , Cmd.utcTime + } = do + SlotNo slotNo <- utcTimeToSlotNo nodeSocketPath consensusModeParams networkId utcTime liftIO . putStr $ show slotNo -- | Obtain stake snapshot information for a pool, plus information about the total active stake. -- This information can be used for leader slot calculation, for example, and has been requested by SPOs. -- Obtaining the information directly is significantly more time and memory efficient than using a full ledger state dump. -runQueryStakeSnapshotCmd - :: SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> AllOrOnly [Hash StakePoolKey] - -> Maybe (File () Out) +runQueryStakeSnapshotCmd :: () + => Cmd.QueryStakeSnapshotCmdArgs -> ExceptT QueryCmdError IO () -runQueryStakeSnapshotCmd socketPath (AnyConsensusModeParams cModeParams) network allOrOnlyPoolIds mOutFile = do - let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath +runQueryStakeSnapshotCmd + Cmd.QueryStakeSnapshotCmdArgs + { Cmd.nodeSocketPath + , Cmd.consensusModeParams = AnyConsensusModeParams cModeParams + , Cmd.networkId + , Cmd.allOrOnlyPoolIds + , Cmd.mOutFile + } = do + let localNodeConnInfo = LocalNodeConnectInfo cModeParams networkId nodeSocketPath join $ lift ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do @@ -767,14 +778,17 @@ runQueryStakeSnapshotCmd socketPath (AnyConsensusModeParams cModeParams) network & onLeft (left . QueryCmdAcquireFailure) & onLeft left -runQueryLedgerStateCmd - :: SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Maybe (File () Out) +runQueryLedgerStateCmd :: () + => Cmd.QueryLedgerStateCmdArgs -> ExceptT QueryCmdError IO () -runQueryLedgerStateCmd socketPath (AnyConsensusModeParams cModeParams) network mOutFile = do - let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath +runQueryLedgerStateCmd + Cmd.QueryLedgerStateCmdArgs + { Cmd.nodeSocketPath + , Cmd.consensusModeParams = AnyConsensusModeParams cModeParams + , Cmd.networkId + , Cmd.mOutFile + } = do + let localNodeConnInfo = LocalNodeConnectInfo cModeParams networkId nodeSocketPath join $ lift ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do @@ -803,14 +817,17 @@ runQueryLedgerStateCmd socketPath (AnyConsensusModeParams cModeParams) network m & onLeft (left . QueryCmdAcquireFailure) & onLeft left -runQueryProtocolStateCmd - :: SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Maybe (File () Out) +runQueryProtocolStateCmd :: () + => Cmd.QueryProtocolStateCmdArgs -> ExceptT QueryCmdError IO () -runQueryProtocolStateCmd socketPath (AnyConsensusModeParams cModeParams) network mOutFile = do - let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath +runQueryProtocolStateCmd + Cmd.QueryProtocolStateCmdArgs + { Cmd.nodeSocketPath + , Cmd.consensusModeParams = AnyConsensusModeParams cModeParams + , Cmd.networkId + , Cmd.mOutFile + } = do + let localNodeConnInfo = LocalNodeConnectInfo cModeParams networkId nodeSocketPath join $ lift ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do @@ -844,15 +861,18 @@ runQueryProtocolStateCmd socketPath (AnyConsensusModeParams cModeParams) network -- | Query the current delegations and reward accounts, filtered by a given -- set of addresses, from a Shelley node via the local state query protocol. -runQueryStakeAddressInfoCmd - :: SocketPath - -> AnyConsensusModeParams - -> StakeAddress - -> NetworkId - -> Maybe (File () Out) +runQueryStakeAddressInfoCmd :: () + => Cmd.QueryStakeAddressInfoCmdArgs -> ExceptT QueryCmdError IO () -runQueryStakeAddressInfoCmd socketPath (AnyConsensusModeParams cModeParams) (StakeAddress _ addr) network mOutFile = do - let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath +runQueryStakeAddressInfoCmd + Cmd.QueryStakeAddressInfoCmdArgs + { Cmd.nodeSocketPath + , Cmd.consensusModeParams = AnyConsensusModeParams cModeParams + , Cmd.addr = StakeAddress _ addr + , Cmd.networkId + , Cmd.mOutFile + } = do + let localNodeConnInfo = LocalNodeConnectInfo cModeParams networkId nodeSocketPath join $ lift ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do @@ -873,7 +893,7 @@ runQueryStakeAddressInfoCmd socketPath (AnyConsensusModeParams cModeParams) (Sta requireNotByronEraInByronMode eraInMode - result <- lift (queryStakeAddresses eInMode sbe stakeAddr network) + result <- lift (queryStakeAddresses eInMode sbe stakeAddr networkId) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError) @@ -1080,14 +1100,17 @@ printUtxo sbe txInOutTuple = printableValue (TxOutValue _ val) = renderValue val printableValue (TxOutAdaOnly _ (Lovelace i)) = Text.pack $ show i -runQueryStakePoolsCmd - :: SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Maybe (File () Out) +runQueryStakePoolsCmd :: () + => Cmd.QueryStakePoolsCmdArgs -> ExceptT QueryCmdError IO () -runQueryStakePoolsCmd socketPath (AnyConsensusModeParams cModeParams) network mOutFile = do - let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath +runQueryStakePoolsCmd + Cmd.QueryStakePoolsCmdArgs + { Cmd.nodeSocketPath + , Cmd.consensusModeParams = AnyConsensusModeParams cModeParams + , Cmd.networkId + , Cmd.mOutFile + } = do + let localNodeConnInfo = LocalNodeConnectInfo cModeParams networkId nodeSocketPath join $ lift ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT @QueryCmdError $ do @@ -1125,14 +1148,17 @@ writeStakePools Nothing stakePools = forM_ (Set.toList stakePools) $ \poolId -> liftIO . putStrLn $ Text.unpack (serialiseToBech32 poolId) -runQueryStakeDistributionCmd - :: SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Maybe (File () Out) +runQueryStakeDistributionCmd :: () + => Cmd.QueryStakeDistributionCmdArgs -> ExceptT QueryCmdError IO () -runQueryStakeDistributionCmd socketPath (AnyConsensusModeParams cModeParams) network mOutFile = do - let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath +runQueryStakeDistributionCmd + Cmd.QueryStakeDistributionCmdArgs + { Cmd.nodeSocketPath + , Cmd.consensusModeParams = AnyConsensusModeParams cModeParams + , Cmd.networkId + , Cmd.mOutFile + } = do + let localNodeConnInfo = LocalNodeConnectInfo cModeParams networkId nodeSocketPath join $ lift ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do @@ -1197,25 +1223,25 @@ printStakeDistribution stakeDistrib = do ] runQueryLeadershipScheduleCmd - :: SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> GenesisFile -- ^ Shelley genesis - -> VerificationKeyOrHashOrFile StakePoolKey - -> SigningKeyFile In -- ^ VRF signing key - -> EpochLeadershipSchedule - -> Maybe (File () Out) + :: Cmd.QueryLeadershipScheduleCmdArgs -> ExceptT QueryCmdError IO () runQueryLeadershipScheduleCmd - socketPath (AnyConsensusModeParams cModeParams) network - (GenesisFile genFile) coldVerKeyFile vrfSkeyFp - whichSchedule mJsonOutputFile = do - let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath - - poolid <- lift (readVerificationKeyOrHashOrFile AsStakePoolKey coldVerKeyFile) + Cmd.QueryLeadershipScheduleCmdArgs + { Cmd.nodeSocketPath + , Cmd.consensusModeParams = AnyConsensusModeParams cModeParams + , Cmd.networkId + , Cmd.genesisFp = GenesisFile genFile + , Cmd.poolColdVerKeyFile + , Cmd.vrkSkeyFp + , Cmd.whichSchedule + , Cmd.mOutFile + } = do + let localNodeConnInfo = LocalNodeConnectInfo cModeParams networkId nodeSocketPath + + poolid <- lift (readVerificationKeyOrHashOrFile AsStakePoolKey poolColdVerKeyFile) & onLeft (left . QueryCmdTextReadError) - vrkSkey <- lift (readFileTextEnvelope (AsSigningKey AsVrfKey) vrfSkeyFp) + vrkSkey <- lift (readFileTextEnvelope (AsSigningKey AsVrfKey) vrkSkeyFp) & onLeft (left . QueryCmdTextEnvelopeReadError) shelleyGenesis <- lift (readAndDecodeShelleyGenesis genFile) @@ -1277,7 +1303,7 @@ runQueryLeadershipScheduleCmd serCurrentEpochState curentEpoch - writeSchedule mJsonOutputFile eInfo shelleyGenesis schedule + writeSchedule mOutFile eInfo shelleyGenesis schedule NextEpoch -> do serCurrentEpochState <- lift (queryCurrentEpochState eInMode sbe) @@ -1293,7 +1319,7 @@ runQueryLeadershipScheduleCmd serCurrentEpochState ptclState poolid vrkSkey pparams eInfo (tip, curentEpoch) - writeSchedule mJsonOutputFile eInfo shelleyGenesis schedule + writeSchedule mOutFile eInfo shelleyGenesis schedule mode -> pure $ do left . QueryCmdUnsupportedMode $ AnyConsensusMode mode @@ -1301,8 +1327,8 @@ runQueryLeadershipScheduleCmd & onLeft (left . QueryCmdAcquireFailure) & onLeft left where - writeSchedule mOutFile eInfo shelleyGenesis schedule = - case mOutFile of + writeSchedule mOutFile' eInfo shelleyGenesis schedule = + case mOutFile' of Nothing -> liftIO $ printLeadershipScheduleAsText schedule eInfo (SystemStart $ sgSystemStart shelleyGenesis) Just (File jsonOutputFile) -> liftIO $ LBS.writeFile jsonOutputFile $ @@ -1416,8 +1442,8 @@ utcTimeToSlotNo -> NetworkId -> UTCTime -> ExceptT QueryCmdError IO SlotNo -utcTimeToSlotNo socketPath (AnyConsensusModeParams cModeParams) network utcTime = do - let localNodeConnInfo = LocalNodeConnectInfo cModeParams network socketPath +utcTimeToSlotNo nodeSocketPath (AnyConsensusModeParams cModeParams) networkId utcTime = do + let localNodeConnInfo = LocalNodeConnectInfo cModeParams networkId nodeSocketPath case consensusModeOnly cModeParams of CardanoMode -> do lift diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs index 305eb57ccd..2d46b43bf1 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs @@ -72,6 +72,7 @@ import Data.Type.Equality (TestEquality (..)) import Lens.Micro ((^.)) import qualified System.IO as IO + runTransactionCmds :: TransactionCmds era -> ExceptT TxCmdError IO () runTransactionCmds cmd = case cmd of @@ -174,13 +175,13 @@ runTxBuildCmd readFileTextEnvelope AsCertificate (File certFile)) | (CertificateFile certFile, mSwit) <- certFilesAndMaybeScriptWits ] - withdrawalsAndMaybeScriptWits <- firstExceptT TxCmdScriptWitnessError - $ readScriptWitnessFilesThruple era wdrls - txMetadata <- firstExceptT TxCmdMetadataError - . newExceptT $ readTxMetadata era metadataSchema metadataFiles + withdrawalsAndMaybeScriptWits <- firstExceptT TxCmdScriptWitnessError $ + readScriptWitnessFilesThruple era wdrls + txMetadata <- firstExceptT TxCmdMetadataError . newExceptT $ + readTxMetadata era metadataSchema metadataFiles valuesWithScriptWits <- readValueScriptWitnesses era $ fromMaybe mempty mValue scripts <- firstExceptT TxCmdScriptFileError $ - mapM (readFileScriptInAnyLang . unScriptFile) scriptFiles + mapM (readFileScriptInAnyLang . unScriptFile) scriptFiles txAuxScripts <- hoistEither $ first TxCmdAuxScriptsValidationError $ validateTxAuxScripts era scripts mProp <- forM mUpProp $ \(UpdateProposalFile upFp) -> @@ -204,17 +205,15 @@ runTxBuildCmd let filteredTxinsc = Set.toList $ Set.fromList txinsc -- We need to construct the txBodycontent outside of runTxBuild - BalancedTxBody txBodycontent balancedTxBody _ _ <- + BalancedTxBody txBodyContent balancedTxBody _ _ <- runTxBuild era socketPath consensusModeParams nid mScriptValidity inputsAndMaybeScriptWits readOnlyRefIns filteredTxinsc mReturnCollateral mTotCollateral txOuts changeAddr valuesWithScriptWits mLowBound mUpperBound certsAndMaybeScriptWits withdrawalsAndMaybeScriptWits requiredSigners txAuxScripts txMetadata mProp mOverrideWits votes proposals outputOptions - mScriptWits <- - case cardanoEraStyle era of - LegacyByronEra -> return [] - ShelleyBasedEra sbe -> return $ collectTxBodyScriptWitnesses sbe txBodycontent + let mScriptWits = + forEraInEon era [] $ \sbe -> collectTxBodyScriptWitnesses sbe txBodyContent let allReferenceInputs = getAllReferenceInputs inputsAndMaybeScriptWits @@ -231,7 +230,7 @@ runTxBuildCmd -- the script cost vs having to build the tx body each time case outputOptions of OutputScriptCostOnly fp -> do - let BuildTxWith mTxProtocolParams = txProtocolParams txBodycontent + let BuildTxWith mTxProtocolParams = txProtocolParams txBodyContent pparams <- pure mTxProtocolParams & onNothing (left TxCmdProtocolParametersNotPresentInTxBody) executionUnitPrices <- pure (getExecutionUnitPrices era pparams) & onNothing (left TxCmdPParamExecutionUnitsNotAvailable) @@ -520,12 +519,12 @@ runTxBuild dummyFee = Just $ Lovelace 0 inputsThatRequireWitnessing = [input | (input,_) <- inputsAndMaybeScriptWits] - -- Pure let allReferenceInputs = getAllReferenceInputs inputsAndMaybeScriptWits (snd valuesWithScriptWits) certsAndMaybeScriptWits - withdrawals readOnlyRefIns + withdrawals + readOnlyRefIns validatedCollateralTxIns <- hoistEither $ validateTxInsCollateral era txinsc validatedRefInputs <- hoistEither $ validateTxInsReference era allReferenceInputs @@ -596,8 +595,8 @@ runTxBuild , txUpdateProposal = validatedTxUpProp , txMintValue = validatedMintValue , txScriptValidity = validatedTxScriptValidity - , txProposalProcedures = inEraEonMaybe era (`Featured` validatedTxProposalProcedures) - , txVotingProcedures = inEraEonMaybe era (`Featured` validatedTxVotes) + , txProposalProcedures = forEraInEonMaybe era (`Featured` validatedTxProposalProcedures) + , txVotingProcedures = forEraInEonMaybe era (`Featured` validatedTxVotes) } firstExceptT TxCmdTxInsDoNotExist @@ -662,21 +661,20 @@ validateTxInsCollateral :: CardanoEra era -> [TxIn] -> Either TxCmdError (TxInsCollateral era) validateTxInsCollateral _ [] = return TxInsCollateralNone -validateTxInsCollateral era txins = - case collateralSupportedInEra era of - Nothing -> txFeatureMismatchPure era TxFeatureCollateral - Just supported -> return (TxInsCollateral supported txins) +validateTxInsCollateral era txins = do + supported <- forEraMaybeEon era + & maybe (txFeatureMismatchPure era TxFeatureCollateral) Right + pure $ TxInsCollateral supported txins validateTxInsReference :: CardanoEra era -> [TxIn] -> Either TxCmdError (TxInsReference BuildTx era) validateTxInsReference _ [] = return TxInsReferenceNone -validateTxInsReference era allRefIns = - caseByronToAlonzoOrBabbageEraOnwards - (const $ txFeatureMismatchPure era TxFeatureReferenceInputs) - (\w -> return $ TxInsReference w allRefIns) - era +validateTxInsReference era allRefIns = do + supported <- forEraMaybeEon era + & maybe (txFeatureMismatchPure era TxFeatureReferenceInputs) Right + pure $ TxInsReference supported allRefIns getAllReferenceInputs :: [(TxIn, Maybe (ScriptWitness WitCtxTxIn era))] @@ -734,24 +732,6 @@ toTxOutValueInAnyEra era val = (\w -> return (TxOutValue w val)) era --- TODO move this to cardano-api -caseAlonzoOnlyOrBabbageEraOnwards :: () - => (AlonzoEraOnly era -> a) - -> (BabbageEraOnwards era -> a) - -> AlonzoEraOnwards era - -> a -caseAlonzoOnlyOrBabbageEraOnwards l r = \case - AlonzoEraOnwardsAlonzo -> l AlonzoEraOnlyAlonzo - AlonzoEraOnwardsBabbage -> r BabbageEraOnwardsBabbage - AlonzoEraOnwardsConway -> r BabbageEraOnwardsConway - --- TODO move this to cardano-api -alonzoEraOnlyToAlonzoEraOnwards :: () - => AlonzoEraOnly era - -> AlonzoEraOnwards era -alonzoEraOnlyToAlonzoEraOnwards = \case - AlonzoEraOnlyAlonzo -> AlonzoEraOnwardsAlonzo - toTxOutInAnyEra :: CardanoEra era -> TxOutAnyEra -> ExceptT TxCmdError IO (TxOut CtxTx era) diff --git a/cardano-cli/src/Cardano/CLI/Json/Friendly.hs b/cardano-cli/src/Cardano/CLI/Json/Friendly.hs index 4b1aa7230e..5129ff7c41 100644 --- a/cardano-cli/src/Cardano/CLI/Json/Friendly.hs +++ b/cardano-cli/src/Cardano/CLI/Json/Friendly.hs @@ -177,7 +177,7 @@ pattern ShelleyTtl :: SlotNo -> (TxValidityLowerBound era, TxValidityUpperBound era) pattern ShelleyTtl ttl <- ( TxValidityNoLowerBound - , TxValidityUpperBound ValidityUpperBoundInShelleyEra ttl + , TxValidityUpperBound _ ttl ) friendlyValidityRange @@ -200,8 +200,8 @@ friendlyValidityRange era = \case ] | otherwise -> Null where - isLowerBoundSupported = isJust $ validityLowerBoundSupportedInEra era - isUpperBoundSupported = isJust $ validityUpperBoundSupportedInEra era + isLowerBoundSupported = isJust $ inEonForEraMaybe TxValidityLowerBound era + isUpperBoundSupported = isJust $ inEonForEraMaybe TxValidityUpperBound era friendlyWithdrawals :: TxWithdrawals ViewTx era -> Aeson.Value friendlyWithdrawals TxWithdrawalsNone = Null @@ -350,7 +350,7 @@ friendlyCertificates sbe = \case TxCertificates _ cs _ -> array $ map (friendlyCertificate sbe) cs friendlyCertificate :: ShelleyBasedEra era -> Certificate era -> Aeson.Value -friendlyCertificate sbe = withShelleyBasedEraConstraintsForLedger sbe $ +friendlyCertificate sbe = shelleyBasedEraConstraints sbe $ object . (: []) . renderCertificate sbe renderCertificate :: ShelleyBasedEra era -> Certificate era -> (Aeson.Key, Aeson.Value) diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Commands/Governance.hs b/cardano-cli/src/Cardano/CLI/Legacy/Commands/Governance.hs index f992246456..723f908e63 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Commands/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Commands/Governance.hs @@ -14,18 +14,18 @@ import Data.Text (Text) data LegacyGovernanceCmds = GovernanceMIRPayStakeAddressesCertificate - AnyShelleyToBabbageEra + (EraInEon ShelleyToBabbageEra) MIRPot [StakeAddress] [Lovelace] (File () Out) | GovernanceMIRTransfer - AnyShelleyToBabbageEra + (EraInEon ShelleyToBabbageEra) Lovelace (File () Out) TransferDirection | GovernanceGenesisKeyDelegationCertificate - AnyShelleyBasedEra + (EraInEon ShelleyBasedEra) (VerificationKeyOrHashOrFile GenesisKey) (VerificationKeyOrHashOrFile GenesisDelegateKey) (VerificationKeyOrHashOrFile VrfKey) @@ -35,19 +35,6 @@ data LegacyGovernanceCmds [VerificationKeyFile In] ProtocolParametersUpdate (Maybe FilePath) - | GovernanceCreatePoll - Text -- Prompt - [Text] -- Choices - (Maybe Word) -- Nonce - (File GovernancePoll Out) - | GovernanceAnswerPoll - (File GovernancePoll In) -- Poll file - (Maybe Word) -- Answer index - (Maybe (File () Out)) -- Tx file - | GovernanceVerifyPoll - (File GovernancePoll In) -- Poll file - (File (Tx ()) In) -- Tx file - (Maybe (File () Out)) -- Tx file deriving Show renderLegacyGovernanceCmds :: LegacyGovernanceCmds -> Text @@ -57,7 +44,4 @@ renderLegacyGovernanceCmds = \case GovernanceMIRTransfer _ _ _ TransferToTreasury -> "governance create-mir-certificate transfer-to-treasury" GovernanceMIRTransfer _ _ _ TransferToReserves -> "governance create-mir-certificate transfer-to-reserves" GovernanceUpdateProposal {} -> "governance create-update-proposal" - GovernanceCreatePoll{} -> "governance create-poll" - GovernanceAnswerPoll{} -> "governance answer-poll" - GovernanceVerifyPoll{} -> "governance verify-poll" diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Commands/Query.hs b/cardano-cli/src/Cardano/CLI/Legacy/Commands/Query.hs index abb24a926a..d5f43cce92 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Commands/Query.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Commands/Query.hs @@ -1,8 +1,25 @@ {-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE LambdaCase #-} module Cardano.CLI.Legacy.Commands.Query ( LegacyQueryCmds (..) + , LegacyQueryLeadershipScheduleCmdArgs (..) + , LegacyQueryProtocolParametersCmdArgs (..) + , LegacyQueryConstitutionHashCmdArgs (..) + , LegacyQueryTipCmdArgs (..) + , LegacyQueryStakePoolsCmdArgs (..) + , LegacyQueryStakeDistributionCmdArgs (..) + , LegacyQueryStakeAddressInfoCmdArgs (..) + , LegacyQueryUTxOCmdArgs (..) + , LegacyQueryLedgerStateCmdArgs (..) + , LegacyQueryProtocolStateCmdArgs (..) + , LegacyQueryStakeSnapshotCmdArgs (..) + , LegacyQueryKesPeriodInfoCmdArgs (..) + , LegacyQueryPoolStateCmdArgs (..) + , LegacyQueryTxMempoolCmdArgs (..) + , LegacyQuerySlotNumberCmdArgs (..) , renderLegacyQueryCmds ) where @@ -13,115 +30,160 @@ import Cardano.CLI.Types.Key import Data.Text (Text) import Data.Time.Clock +import GHC.Generics -data LegacyQueryCmds = - QueryLeadershipSchedule - SocketPath - AnyConsensusModeParams - NetworkId - GenesisFile - (VerificationKeyOrHashOrFile StakePoolKey) - (SigningKeyFile In) - EpochLeadershipSchedule - (Maybe (File () Out)) - | QueryProtocolParameters' - SocketPath - AnyConsensusModeParams - NetworkId - (Maybe (File () Out)) - | QueryConstitutionHash - SocketPath - AnyConsensusModeParams - NetworkId - (Maybe (File () Out)) - | QueryTip - SocketPath - AnyConsensusModeParams - NetworkId - (Maybe (File () Out)) - | QueryStakePools' - SocketPath - AnyConsensusModeParams - NetworkId - (Maybe (File () Out)) - | QueryStakeDistribution' - SocketPath - AnyConsensusModeParams - NetworkId - (Maybe (File () Out)) - | QueryStakeAddressInfo - SocketPath - AnyConsensusModeParams - StakeAddress - NetworkId - (Maybe (File () Out)) - | QueryUTxO' - SocketPath - AnyConsensusModeParams - QueryUTxOFilter - NetworkId - (Maybe (File () Out)) - | QueryDebugLedgerState' - SocketPath - AnyConsensusModeParams - NetworkId - (Maybe (File () Out)) - | QueryProtocolState' - SocketPath - AnyConsensusModeParams - NetworkId - (Maybe (File () Out)) - | QueryStakeSnapshot' - SocketPath - AnyConsensusModeParams - NetworkId - (AllOrOnly [Hash StakePoolKey]) - (Maybe (File () Out)) - | QueryKesPeriodInfo - SocketPath - AnyConsensusModeParams - NetworkId - (File () In) - -- ^ Node operational certificate - (Maybe (File () Out)) - | QueryPoolState' - SocketPath - AnyConsensusModeParams - NetworkId - [Hash StakePoolKey] - | QueryTxMempool - SocketPath - AnyConsensusModeParams - NetworkId - TxMempoolQuery - (Maybe (File () Out)) - | QuerySlotNumber - SocketPath - AnyConsensusModeParams - NetworkId - UTCTime - deriving Show +data LegacyQueryCmds + = QueryLeadershipScheduleCmd !LegacyQueryLeadershipScheduleCmdArgs + | QueryProtocolParametersCmd !LegacyQueryProtocolParametersCmdArgs + | QueryConstitutionHashCmd !LegacyQueryConstitutionHashCmdArgs + | QueryTipCmd !LegacyQueryTipCmdArgs + | QueryStakePoolsCmd !LegacyQueryStakePoolsCmdArgs + | QueryStakeDistributionCmd !LegacyQueryStakeDistributionCmdArgs + | QueryStakeAddressInfoCmd !LegacyQueryStakeAddressInfoCmdArgs + | QueryUTxOCmd !LegacyQueryUTxOCmdArgs + | QueryLedgerStateCmd !LegacyQueryLedgerStateCmdArgs + | QueryProtocolStateCmd !LegacyQueryProtocolStateCmdArgs + | QueryStakeSnapshotCmd !LegacyQueryStakeSnapshotCmdArgs + | QueryKesPeriodInfoCmd !LegacyQueryKesPeriodInfoCmdArgs + | QueryPoolStateCmd !LegacyQueryPoolStateCmdArgs + | QueryTxMempoolCmd !LegacyQueryTxMempoolCmdArgs + | QuerySlotNumberCmd !LegacyQuerySlotNumberCmdArgs + deriving (Generic, Show) + +data LegacyQueryLeadershipScheduleCmdArgs = LegacyQueryLeadershipScheduleCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , genesisFp :: !GenesisFile + , poolColdVerKeyFile :: !(VerificationKeyOrHashOrFile StakePoolKey) + , vrkSkeyFp :: !(SigningKeyFile In) + , whichSchedule :: !EpochLeadershipSchedule + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data LegacyQueryProtocolParametersCmdArgs = LegacyQueryProtocolParametersCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data LegacyQueryConstitutionHashCmdArgs = LegacyQueryConstitutionHashCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data LegacyQueryTipCmdArgs = LegacyQueryTipCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data LegacyQueryStakePoolsCmdArgs = LegacyQueryStakePoolsCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data LegacyQueryStakeDistributionCmdArgs = LegacyQueryStakeDistributionCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data LegacyQueryStakeAddressInfoCmdArgs = LegacyQueryStakeAddressInfoCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , addr :: !StakeAddress + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data LegacyQueryUTxOCmdArgs = LegacyQueryUTxOCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , queryFilter :: !QueryUTxOFilter + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data LegacyQueryLedgerStateCmdArgs = LegacyQueryLedgerStateCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data LegacyQueryProtocolStateCmdArgs = LegacyQueryProtocolStateCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data LegacyQueryStakeSnapshotCmdArgs = LegacyQueryStakeSnapshotCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , allOrOnlyPoolIds :: !(AllOrOnly [Hash StakePoolKey]) + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data LegacyQueryKesPeriodInfoCmdArgs = LegacyQueryKesPeriodInfoCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , nodeOpCertFp :: !(File () In) -- ^ Node operational certificate + , mOutFile :: !(Maybe (File () Out)) + } deriving (Generic, Show) + +data LegacyQueryPoolStateCmdArgs = LegacyQueryPoolStateCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , poolIds :: ![Hash StakePoolKey] + } deriving (Generic, Show) + +data LegacyQueryTxMempoolCmdArgs = LegacyQueryTxMempoolCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , query :: !TxMempoolQuery + , mOutFile :: !(Maybe (File () Out)) + } + deriving (Generic, Show) + +data LegacyQuerySlotNumberCmdArgs = LegacyQuerySlotNumberCmdArgs + { nodeSocketPath :: !SocketPath + , consensusModeParams :: !AnyConsensusModeParams + , networkId :: !NetworkId + , utcTime :: !UTCTime + } deriving (Generic, Show) renderLegacyQueryCmds :: LegacyQueryCmds -> Text renderLegacyQueryCmds = \case - QueryLeadershipSchedule {} -> "query leadership-schedule" - QueryProtocolParameters' {} -> "query protocol-parameters " - QueryConstitutionHash {} -> "query constitution-hash " - QueryTip {} -> "query tip" - QueryStakePools' {} -> "query stake-pools" - QueryStakeDistribution' {} -> "query stake-distribution" - QueryStakeAddressInfo {} -> "query stake-address-info" - QueryUTxO' {} -> "query utxo" - QueryDebugLedgerState' {} -> "query ledger-state" - QueryProtocolState' {} -> "query protocol-state" - QueryStakeSnapshot' {} -> "query stake-snapshot" - QueryKesPeriodInfo {} -> "query kes-period-info" - QueryPoolState' {} -> "query pool-state" - QueryTxMempool _ _ _ query _ -> "query tx-mempool" <> renderTxMempoolQuery query - QuerySlotNumber {} -> "query slot-number" + QueryLeadershipScheduleCmd {} -> "query leadership-schedule" + QueryProtocolParametersCmd {} -> "query protocol-parameters " + QueryConstitutionHashCmd {} -> "query constitution-hash " + QueryTipCmd {} -> "query tip" + QueryStakePoolsCmd {} -> "query stake-pools" + QueryStakeDistributionCmd {} -> "query stake-distribution" + QueryStakeAddressInfoCmd {} -> "query stake-address-info" + QueryUTxOCmd {} -> "query utxo" + QueryLedgerStateCmd {} -> "query ledger-state" + QueryProtocolStateCmd {} -> "query protocol-state" + QueryStakeSnapshotCmd {} -> "query stake-snapshot" + QueryKesPeriodInfoCmd {} -> "query kes-period-info" + QueryPoolStateCmd {} -> "query pool-state" + QueryTxMempoolCmd (LegacyQueryTxMempoolCmdArgs _ _ _ txMempoolQuery _) -> "query tx-mempool" <> renderTxMempoolQuery txMempoolQuery + QuerySlotNumberCmd {} -> "query slot-number" where - renderTxMempoolQuery query = - case query of - TxMempoolQueryTxExists tx -> "tx-exists " <> serialiseToRawBytesHexText tx - TxMempoolQueryNextTx -> "next-tx" - TxMempoolQueryInfo -> "info" + renderTxMempoolQuery = \case + TxMempoolQueryTxExists tx -> "tx-exists " <> serialiseToRawBytesHexText tx + TxMempoolQueryNextTx -> "next-tx" + TxMempoolQueryInfo -> "info" diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Commands/StakeAddress.hs b/cardano-cli/src/Cardano/CLI/Legacy/Commands/StakeAddress.hs index 00d33d86be..637fdc38b2 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Commands/StakeAddress.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Commands/StakeAddress.hs @@ -29,17 +29,17 @@ data LegacyStakeAddressCmds NetworkId (Maybe (File () Out)) | StakeAddressRegistrationCertificateCmd - AnyShelleyBasedEra + (EraInEon ShelleyBasedEra) StakeIdentifier (Maybe Lovelace) (File () Out) | StakeAddressDelegationCertificateCmd - AnyShelleyBasedEra + (EraInEon ShelleyBasedEra) StakeIdentifier (VerificationKeyOrHashOrFile StakePoolKey) (File () Out) | StakeAddressDeregistrationCertificateCmd - AnyShelleyBasedEra + (EraInEon ShelleyBasedEra) StakeIdentifier (Maybe Lovelace) (File () Out) diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Commands/StakePool.hs b/cardano-cli/src/Cardano/CLI/Legacy/Commands/StakePool.hs index 9824f098cb..537aeb0754 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Commands/StakePool.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Commands/StakePool.hs @@ -17,7 +17,7 @@ import Data.Text (Text) data LegacyStakePoolCmds = StakePoolDeregistrationCertificateCmd - AnyShelleyBasedEra + (EraInEon ShelleyBasedEra) -- ^ Era in which to retire the stake pool. (VerificationKeyOrFile StakePoolKey) -- ^ Stake pool verification key. @@ -32,7 +32,7 @@ data LegacyStakePoolCmds (StakePoolMetadataFile In) (Maybe (File () Out)) | StakePoolRegistrationCertificateCmd - AnyShelleyBasedEra + (EraInEon ShelleyBasedEra) -- ^ Era in which to register the stake pool. (VerificationKeyOrFile StakePoolKey) -- ^ Stake pool verification key. diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Options.hs b/cardano-cli/src/Cardano/CLI/Legacy/Options.hs index c1b4cae740..fdacb56e67 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Options.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Options.hs @@ -848,48 +848,54 @@ pQueryCmds envCli = where pQueryProtocolParameters :: Parser LegacyQueryCmds pQueryProtocolParameters = - QueryProtocolParameters' - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pMaybeOutputFile + fmap QueryProtocolParametersCmd $ + LegacyQueryProtocolParametersCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pMaybeOutputFile pQueryConstitutionHash :: Parser LegacyQueryCmds pQueryConstitutionHash = - QueryConstitutionHash - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pMaybeOutputFile + fmap QueryConstitutionHashCmd $ + LegacyQueryConstitutionHashCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pMaybeOutputFile pQueryTip :: Parser LegacyQueryCmds pQueryTip = - QueryTip - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pMaybeOutputFile + fmap QueryTipCmd $ + LegacyQueryTipCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pMaybeOutputFile pQueryUTxO :: Parser LegacyQueryCmds pQueryUTxO = - QueryUTxO' - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pQueryUTxOFilter - <*> pNetworkId envCli - <*> pMaybeOutputFile + fmap QueryUTxOCmd $ + LegacyQueryUTxOCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pQueryUTxOFilter + <*> pNetworkId envCli + <*> pMaybeOutputFile pQueryStakePools :: Parser LegacyQueryCmds pQueryStakePools = - QueryStakePools' - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pMaybeOutputFile + fmap QueryStakePoolsCmd $ + LegacyQueryStakePoolsCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pMaybeOutputFile pQueryStakeDistribution :: Parser LegacyQueryCmds pQueryStakeDistribution = - QueryStakeDistribution' + fmap QueryStakeDistributionCmd $ + LegacyQueryStakeDistributionCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli @@ -897,7 +903,8 @@ pQueryCmds envCli = pQueryStakeAddressInfo :: Parser LegacyQueryCmds pQueryStakeAddressInfo = - QueryStakeAddressInfo + fmap QueryStakeAddressInfoCmd $ + LegacyQueryStakeAddressInfoCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pFilterByStakeAddress @@ -906,7 +913,8 @@ pQueryCmds envCli = pQueryLedgerState :: Parser LegacyQueryCmds pQueryLedgerState = - QueryDebugLedgerState' + fmap QueryLedgerStateCmd $ + LegacyQueryLedgerStateCmdArgs <$> pSocketPath envCli <*> pConsensusModeParams <*> pNetworkId envCli @@ -914,11 +922,12 @@ pQueryCmds envCli = pQueryProtocolState :: Parser LegacyQueryCmds pQueryProtocolState = - QueryProtocolState' - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pMaybeOutputFile + fmap QueryProtocolStateCmd $ + LegacyQueryProtocolStateCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pMaybeOutputFile pAllStakePoolsOrOnly :: Parser (AllOrOnly [Hash StakePoolKey]) pAllStakePoolsOrOnly = pAll <|> pOnly @@ -932,29 +941,32 @@ pQueryCmds envCli = pQueryStakeSnapshot :: Parser LegacyQueryCmds pQueryStakeSnapshot = - QueryStakeSnapshot' - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pAllStakePoolsOrOnly - <*> pMaybeOutputFile + fmap QueryStakeSnapshotCmd $ + LegacyQueryStakeSnapshotCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pAllStakePoolsOrOnly + <*> pMaybeOutputFile pQueryPoolState :: Parser LegacyQueryCmds pQueryPoolState = - QueryPoolState' - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> many (pStakePoolVerificationKeyHash Nothing) + fmap QueryPoolStateCmd $ + LegacyQueryPoolStateCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> many (pStakePoolVerificationKeyHash Nothing) pQueryTxMempool :: Parser LegacyQueryCmds pQueryTxMempool = - QueryTxMempool - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pTxMempoolQuery - <*> pMaybeOutputFile + fmap QueryTxMempoolCmd $ + LegacyQueryTxMempoolCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pTxMempoolQuery + <*> pMaybeOutputFile where pTxMempoolQuery :: Parser TxMempoolQuery pTxMempoolQuery = asum @@ -970,38 +982,41 @@ pQueryCmds envCli = ] pLeadershipSchedule :: Parser LegacyQueryCmds pLeadershipSchedule = - QueryLeadershipSchedule - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pGenesisFile "Shelley genesis filepath" - <*> pStakePoolVerificationKeyOrHashOrFile Nothing - <*> pVrfSigningKeyFile - <*> pWhichLeadershipSchedule - <*> pMaybeOutputFile + fmap QueryLeadershipScheduleCmd $ + LegacyQueryLeadershipScheduleCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pGenesisFile "Shelley genesis filepath" + <*> pStakePoolVerificationKeyOrHashOrFile Nothing + <*> pVrfSigningKeyFile + <*> pWhichLeadershipSchedule + <*> pMaybeOutputFile pKesPeriodInfo :: Parser LegacyQueryCmds pKesPeriodInfo = - QueryKesPeriodInfo - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pOperationalCertificateFile - <*> pMaybeOutputFile + fmap QueryKesPeriodInfoCmd $ + LegacyQueryKesPeriodInfoCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pOperationalCertificateFile + <*> pMaybeOutputFile pQuerySlotNumber :: Parser LegacyQueryCmds pQuerySlotNumber = - QuerySlotNumber - <$> pSocketPath envCli - <*> pConsensusModeParams - <*> pNetworkId envCli - <*> pUtcTimestamp - where - pUtcTimestamp = - convertTime <$> (Opt.strArgument . mconcat) - [ Opt.metavar "TIMESTAMP" - , Opt.help "UTC timestamp in YYYY-MM-DDThh:mm:ssZ format" - ] + fmap QuerySlotNumberCmd $ + LegacyQuerySlotNumberCmdArgs + <$> pSocketPath envCli + <*> pConsensusModeParams + <*> pNetworkId envCli + <*> pUtcTimestamp + where + pUtcTimestamp = + convertTime <$> (Opt.strArgument . mconcat) + [ Opt.metavar "TIMESTAMP" + , Opt.help "UTC timestamp in YYYY-MM-DDThh:mm:ssZ format" + ] -- TODO: Conway era - move to Cardano.CLI.Conway.Parsers @@ -1017,15 +1032,6 @@ pGovernanceCmds envCli = , subParser "create-update-proposal" $ Opt.info pUpdateProposal $ Opt.progDesc "Create an update proposal" - , subParser "create-poll" - $ Opt.info pGovernanceCreatePoll - $ Opt.progDesc "Create an SPO poll" - , subParser "answer-poll" - $ Opt.info pGovernanceAnswerPoll - $ Opt.progDesc "Answer an SPO poll" - , subParser "verify-poll" - $ Opt.info pGovernanceVerifyPoll - $ Opt.progDesc "Verify an answer to a given SPO poll" ] where mirCertParsers :: Parser LegacyGovernanceCmds @@ -1084,28 +1090,6 @@ pGovernanceCmds envCli = <*> pProtocolParametersUpdate <*> optional pCostModels - pGovernanceCreatePoll :: Parser LegacyGovernanceCmds - pGovernanceCreatePoll = - GovernanceCreatePoll - <$> pPollQuestion - <*> some pPollAnswer - <*> optional pPollNonce - <*> pOutputFile - - pGovernanceAnswerPoll :: Parser LegacyGovernanceCmds - pGovernanceAnswerPoll = - GovernanceAnswerPoll - <$> pPollFile - <*> optional pPollAnswerIndex - <*> optional pOutputFile - - pGovernanceVerifyPoll :: Parser LegacyGovernanceCmds - pGovernanceVerifyPoll = - GovernanceVerifyPoll - <$> pPollFile - <*> pPollTxFile - <*> optional pOutputFile - pGenesisCmds :: EnvCli -> Parser LegacyGenesisCmds pGenesisCmds envCli = asum @@ -1452,5 +1436,6 @@ pLegacyCardanoEra envCli = , pure $ pure defaultCardanoEra ] where - defaultCardanoEra = defaultShelleyBasedEra & \(AnyShelleyBasedEra era) -> - AnyCardanoEra (shelleyBasedToCardanoEra era) + defaultCardanoEra = defaultShelleyBasedEra & \(EraInEon era) -> + let cera = toCardanoEra era + in cardanoEraConstraints cera (AnyCardanoEra cera) diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Run/Governance.hs b/cardano-cli/src/Cardano/CLI/Legacy/Run/Governance.hs index 7e4f1e05a7..5a5799a2b3 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Run/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Run/Governance.hs @@ -1,7 +1,6 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} -{-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE ScopedTypeVariables #-} module Cardano.CLI.Legacy.Run.Governance @@ -11,32 +10,20 @@ module Cardano.CLI.Legacy.Run.Governance import Cardano.Api import qualified Cardano.Api.Ledger as Ledger import Cardano.Api.Shelley -import qualified Cardano.Api.Shelley as Api import Cardano.CLI.EraBased.Run.Governance import Cardano.CLI.Legacy.Commands.Governance -import Cardano.CLI.Read import Cardano.CLI.Types.Common import Cardano.CLI.Types.Errors.GovernanceCmdError import Cardano.CLI.Types.Key import Control.Monad -import Control.Monad.IO.Class -import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Except (ExceptT) import Control.Monad.Trans.Except.Extra import Data.Aeson (eitherDecode) -import qualified Data.ByteString.Char8 as BSC import qualified Data.ByteString.Lazy as LB import Data.Function ((&)) -import Data.String (fromString) -import Data.Text (Text) import qualified Data.Text as Text -import qualified Data.Text.Encoding as Text -import qualified Data.Text.IO as Text -import qualified Data.Text.Read as Text -import qualified System.IO as IO -import System.IO (stderr, stdin, stdout) runLegacyGovernanceCmds :: LegacyGovernanceCmds -> ExceptT GovernanceCmdError IO () runLegacyGovernanceCmds = \case @@ -48,40 +35,34 @@ runLegacyGovernanceCmds = \case runLegacyGovernanceGenesisKeyDelegationCertificate sbe genVk genDelegVk vrfVk out GovernanceUpdateProposal out eNo genVKeys ppUp mCostModelFp -> runLegacyGovernanceUpdateProposal out eNo genVKeys ppUp mCostModelFp - GovernanceCreatePoll prompt choices nonce out -> - runLegacyGovernanceCreatePoll prompt choices nonce out - GovernanceAnswerPoll poll ix mOutFile -> - runLegacyGovernanceAnswerPoll poll ix mOutFile - GovernanceVerifyPoll poll metadata mOutFile -> - runLegacyGovernanceVerifyPoll poll metadata mOutFile runLegacyGovernanceMIRCertificatePayStakeAddrs - :: AnyShelleyToBabbageEra + :: EraInEon ShelleyToBabbageEra -> Ledger.MIRPot -> [StakeAddress] -- ^ Stake addresses -> [Lovelace] -- ^ Corresponding reward amounts (same length) -> File () Out -> ExceptT GovernanceCmdError IO () -runLegacyGovernanceMIRCertificatePayStakeAddrs (AnyShelleyToBabbageEra w) = +runLegacyGovernanceMIRCertificatePayStakeAddrs (EraInEon w) = runGovernanceMIRCertificatePayStakeAddrs w runLegacyGovernanceMIRCertificateTransfer - :: AnyShelleyToBabbageEra + :: EraInEon ShelleyToBabbageEra -> Lovelace -> File () Out -> TransferDirection -> ExceptT GovernanceCmdError IO () -runLegacyGovernanceMIRCertificateTransfer (AnyShelleyToBabbageEra w) = +runLegacyGovernanceMIRCertificateTransfer (EraInEon w) = runGovernanceMIRCertificateTransfer w runLegacyGovernanceGenesisKeyDelegationCertificate - :: AnyShelleyBasedEra + :: EraInEon ShelleyBasedEra -> VerificationKeyOrHashOrFile GenesisKey -> VerificationKeyOrHashOrFile GenesisDelegateKey -> VerificationKeyOrHashOrFile VrfKey -> File () Out -> ExceptT GovernanceCmdError IO () -runLegacyGovernanceGenesisKeyDelegationCertificate (AnyShelleyBasedEra sbe) +runLegacyGovernanceGenesisKeyDelegationCertificate (EraInEon sbe) genVkOrHashOrFp genDelVkOrHashOrFp vrfVkOrHashOrFp @@ -102,6 +83,7 @@ runLegacyGovernanceGenesisKeyDelegationCertificate (AnyShelleyBasedEra sbe) firstExceptT GovernanceCmdTextEnvWriteError . newExceptT $ writeLazyByteStringFile oFp + $ shelleyBasedEraConstraints sbe $ textEnvelopeToJSON (Just genKeyDelegCertDesc) genKeyDelegCert where genKeyDelegCertDesc :: TextEnvelopeDescr @@ -162,128 +144,3 @@ runLegacyGovernanceUpdateProposal upFile eNo genVerKeyFiles upPprams mCostModelF firstExceptT GovernanceCmdTextEnvWriteError . newExceptT $ writeLazyByteStringFile upFile $ textEnvelopeToJSON Nothing upProp - -runLegacyGovernanceCreatePoll - :: Text - -> [Text] - -> Maybe Word - -> File GovernancePoll Out - -> ExceptT GovernanceCmdError IO () -runLegacyGovernanceCreatePoll govPollQuestion govPollAnswers govPollNonce out = do - let poll = GovernancePoll{ govPollQuestion, govPollAnswers, govPollNonce } - - let description = fromString $ "An on-chain poll for SPOs: " <> Text.unpack govPollQuestion - firstExceptT GovernanceCmdTextEnvWriteError . newExceptT $ - writeFileTextEnvelope out (Just description) poll - - let metadata = asTxMetadata poll - & metadataToJson TxMetadataJsonDetailedSchema - - let outPath = unFile out & Text.encodeUtf8 . Text.pack - - liftIO $ do - BSC.hPutStrLn stderr $ mconcat - [ "Poll created successfully.\n" - , "Please submit a transaction using the resulting metadata.\n" - ] - BSC.hPutStrLn stdout (prettyPrintJSON metadata) - BSC.hPutStrLn stderr $ mconcat - [ "\n" - , "Hint (1): Use '--json-metadata-detailed-schema' and '--metadata-json-file' " - , "from the build or build-raw commands.\n" - , "Hint (2): You can redirect the standard output of this command to a JSON " - , "file to capture metadata.\n\n" - , "Note: A serialized version of the poll suitable for sharing with " - , "participants has been generated at '" <> outPath <> "'." - ] - -runLegacyGovernanceAnswerPoll - :: File GovernancePoll In - -> Maybe Word -- ^ Answer index - -> Maybe (File () Out) -- ^ Output file - -> ExceptT GovernanceCmdError IO () -runLegacyGovernanceAnswerPoll pollFile maybeChoice mOutFile = do - poll <- firstExceptT GovernanceCmdTextEnvReadError . newExceptT $ - readFileTextEnvelope AsGovernancePoll pollFile - - choice <- case maybeChoice of - Nothing -> do - askInteractively poll - Just ix -> do - validateChoice poll ix - liftIO $ BSC.hPutStrLn stderr $ Text.encodeUtf8 $ Text.intercalate "\n" - [ govPollQuestion poll - , "→ " <> (govPollAnswers poll !! fromIntegral ix) - , "" - ] - pure ix - - let pollAnswer = GovernancePollAnswer - { govAnsPoll = hashGovernancePoll poll - , govAnsChoice = choice - } - let metadata = - metadataToJson TxMetadataJsonDetailedSchema (asTxMetadata pollAnswer) - - liftIO $ BSC.hPutStrLn stderr $ mconcat - [ "Poll answer created successfully.\n" - , "Please submit a transaction using the resulting metadata.\n" - , "To be valid, the transaction must also be signed using a valid key\n" - , "identifying your stake pool (e.g. your cold key).\n" - ] - - lift (writeByteStringOutput mOutFile (prettyPrintJSON metadata)) - & onLeft (left . GovernanceCmdWriteFileError) - - liftIO $ BSC.hPutStrLn stderr $ mconcat - [ "\n" - , "Hint (1): Use '--json-metadata-detailed-schema' and '--metadata-json-file' " - , "from the build or build-raw commands.\n" - , "Hint (2): You can redirect the standard output of this command to a JSON " - , "file to capture metadata." - ] - where - validateChoice :: GovernancePoll -> Word -> ExceptT GovernanceCmdError IO () - validateChoice GovernancePoll{govPollAnswers} ix = do - let maxAnswerIndex = length govPollAnswers - 1 - when (fromIntegral ix > maxAnswerIndex) $ left $ - GovernanceCmdPollOutOfBoundAnswer maxAnswerIndex - - askInteractively :: GovernancePoll -> ExceptT GovernanceCmdError IO Word - askInteractively poll@GovernancePoll{govPollQuestion, govPollAnswers} = do - liftIO $ BSC.hPutStrLn stderr $ Text.encodeUtf8 $ Text.intercalate "\n" - ( govPollQuestion - : [ "[" <> textShow ix <> "] " <> answer - | (ix :: Int, answer) <- zip [0..] govPollAnswers - ] - ) - liftIO $ BSC.hPutStrLn stderr "" - liftIO $ BSC.hPutStr stderr "Please indicate an answer (by index): " - txt <- liftIO $ Text.hGetLine stdin - liftIO $ BSC.hPutStrLn stderr "" - case Text.decimal txt of - Right (choice, rest) | Text.null rest -> - choice <$ validateChoice poll choice - _ -> - left GovernanceCmdPollInvalidChoice - -runLegacyGovernanceVerifyPoll - :: File GovernancePoll In - -> File (Api.Tx ()) In - -> Maybe (File () Out) -- ^ Output file - -> ExceptT GovernanceCmdError IO () -runLegacyGovernanceVerifyPoll pollFile txFile mOutFile = do - poll <- firstExceptT GovernanceCmdTextEnvReadError . newExceptT $ - readFileTextEnvelope AsGovernancePoll pollFile - - txFileOrPipe <- liftIO $ fileOrPipe (unFile txFile) - tx <- firstExceptT GovernanceCmdCddlError . newExceptT $ - readFileTx txFileOrPipe - - signatories <- firstExceptT GovernanceCmdVerifyPollError . newExceptT $ pure $ - verifyPollAnswer poll tx - - liftIO $ IO.hPutStrLn stderr $ "Found valid poll answer with " <> show (length signatories) <> " signatories" - - lift (writeByteStringOutput mOutFile (prettyPrintJSON signatories)) - & onLeft (left . GovernanceCmdWriteFileError) diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Run/Query.hs b/cardano-cli/src/Cardano/CLI/Legacy/Run/Query.hs index e6f5f75548..626ae01e5f 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Run/Query.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Run/Query.hs @@ -1,195 +1,137 @@ +{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-} + {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} - -{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-} +{-# LANGUAGE RecordWildCards #-} module Cardano.CLI.Legacy.Run.Query ( runLegacyQueryCmds ) where -import Cardano.Api hiding (QueryInShelleyBasedEra (..)) -import Cardano.Api.Shelley hiding (QueryInShelleyBasedEra (..)) - +import qualified Cardano.CLI.EraBased.Commands.Query as EraBased import qualified Cardano.CLI.EraBased.Run.Query as EraBased -import Cardano.CLI.Legacy.Commands.Query -import Cardano.CLI.Types.Common +import qualified Cardano.CLI.Legacy.Commands.Query as Cmd import Cardano.CLI.Types.Errors.QueryCmdError -import Cardano.CLI.Types.Key (VerificationKeyOrHashOrFile) import Control.Monad.Trans.Except -import Data.Time.Clock -runLegacyQueryCmds :: LegacyQueryCmds -> ExceptT QueryCmdError IO () +runLegacyQueryCmds :: Cmd.LegacyQueryCmds -> ExceptT QueryCmdError IO () runLegacyQueryCmds = \case - QueryLeadershipSchedule mNodeSocketPath consensusModeParams network shelleyGenFp poolid vrkSkeyFp whichSchedule outputAs -> - runLegacyQueryLeadershipScheduleCmd mNodeSocketPath consensusModeParams network shelleyGenFp poolid vrkSkeyFp whichSchedule outputAs - QueryProtocolParameters' mNodeSocketPath consensusModeParams network mOutFile -> - runLegacyQueryProtocolParametersCmd mNodeSocketPath consensusModeParams network mOutFile - QueryConstitutionHash mNodeSocketPath consensusModeParams network mOutFile -> - runLegacyQueryConstitutionHashCmd mNodeSocketPath consensusModeParams network mOutFile - QueryTip mNodeSocketPath consensusModeParams network mOutFile -> - runLegacyQueryTipCmd mNodeSocketPath consensusModeParams network mOutFile - QueryStakePools' mNodeSocketPath consensusModeParams network mOutFile -> - runLegacyQueryStakePoolsCmd mNodeSocketPath consensusModeParams network mOutFile - QueryStakeDistribution' mNodeSocketPath consensusModeParams network mOutFile -> - runLegacyQueryStakeDistributionCmd mNodeSocketPath consensusModeParams network mOutFile - QueryStakeAddressInfo mNodeSocketPath consensusModeParams addr network mOutFile -> - runLegacyQueryStakeAddressInfoCmd mNodeSocketPath consensusModeParams addr network mOutFile - QueryDebugLedgerState' mNodeSocketPath consensusModeParams network mOutFile -> - runLegacyQueryLedgerStateCmd mNodeSocketPath consensusModeParams network mOutFile - QueryStakeSnapshot' mNodeSocketPath consensusModeParams network allOrOnlyPoolIds mOutFile -> - runLegacyQueryStakeSnapshotCmd mNodeSocketPath consensusModeParams network allOrOnlyPoolIds mOutFile - QueryProtocolState' mNodeSocketPath consensusModeParams network mOutFile -> - runLegacyQueryProtocolStateCmd mNodeSocketPath consensusModeParams network mOutFile - QueryUTxO' mNodeSocketPath consensusModeParams qFilter networkId mOutFile -> - runLegacyQueryUTxOCmd mNodeSocketPath consensusModeParams qFilter networkId mOutFile - QueryKesPeriodInfo mNodeSocketPath consensusModeParams network nodeOpCert mOutFile -> - runLegacyQueryKesPeriodInfoCmd mNodeSocketPath consensusModeParams network nodeOpCert mOutFile - QueryPoolState' mNodeSocketPath consensusModeParams network poolid -> - runLegacyQueryPoolStateCmd mNodeSocketPath consensusModeParams network poolid - QueryTxMempool mNodeSocketPath consensusModeParams network op mOutFile -> - runLegacyQueryTxMempoolCmd mNodeSocketPath consensusModeParams network op mOutFile - QuerySlotNumber mNodeSocketPath consensusModeParams network utcTime -> - runLegacyQuerySlotNumberCmd mNodeSocketPath consensusModeParams network utcTime + Cmd.QueryLeadershipScheduleCmd args -> runLegacyQueryLeadershipScheduleCmd args + Cmd.QueryProtocolParametersCmd args -> runLegacyQueryProtocolParametersCmd args + Cmd.QueryConstitutionHashCmd args -> runLegacyQueryConstitutionHashCmd args + Cmd.QueryTipCmd args -> runLegacyQueryTipCmd args + Cmd.QueryStakePoolsCmd args -> runLegacyQueryStakePoolsCmd args + Cmd.QueryStakeDistributionCmd args -> runLegacyQueryStakeDistributionCmd args + Cmd.QueryStakeAddressInfoCmd args -> runLegacyQueryStakeAddressInfoCmd args + Cmd.QueryLedgerStateCmd args -> runLegacyQueryLedgerStateCmd args + Cmd.QueryStakeSnapshotCmd args -> runLegacyQueryStakeSnapshotCmd args + Cmd.QueryProtocolStateCmd args -> runLegacyQueryProtocolStateCmd args + Cmd.QueryUTxOCmd args -> runLegacyQueryUTxOCmd args + Cmd.QueryKesPeriodInfoCmd args -> runLegacyQueryKesPeriodInfoCmd args + Cmd.QueryPoolStateCmd args -> runLegacyQueryPoolStateCmd args + Cmd.QueryTxMempoolCmd args -> runLegacyQueryTxMempoolCmd args + Cmd.QuerySlotNumberCmd args -> runLegacyQuerySlotNumberCmd args runLegacyQueryConstitutionHashCmd :: () - => SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Maybe (File () Out) + => Cmd.LegacyQueryConstitutionHashCmdArgs -> ExceptT QueryCmdError IO () -runLegacyQueryConstitutionHashCmd = EraBased.runQueryConstitutionHashCmd +runLegacyQueryConstitutionHashCmd Cmd.LegacyQueryConstitutionHashCmdArgs {..} = + EraBased.runQueryConstitutionHashCmd EraBased.QueryConstitutionHashCmdArgs {..} runLegacyQueryProtocolParametersCmd :: () - => SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Maybe (File () Out) + => Cmd.LegacyQueryProtocolParametersCmdArgs -> ExceptT QueryCmdError IO () -runLegacyQueryProtocolParametersCmd = EraBased.runQueryProtocolParametersCmd +runLegacyQueryProtocolParametersCmd Cmd.LegacyQueryProtocolParametersCmdArgs {..} = + EraBased.runQueryProtocolParametersCmd EraBased.QueryProtocolParametersCmdArgs {..} runLegacyQueryTipCmd :: () - => SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Maybe (File () Out) + => Cmd.LegacyQueryTipCmdArgs -> ExceptT QueryCmdError IO () -runLegacyQueryTipCmd = EraBased.runQueryTipCmd +runLegacyQueryTipCmd Cmd.LegacyQueryTipCmdArgs {..} = + EraBased.runQueryTipCmd EraBased.QueryTipCmdArgs {..} -- | Query the UTxO, filtered by a given set of addresses, from a Shelley node -- via the local state query protocol. runLegacyQueryUTxOCmd :: () - => SocketPath - -> AnyConsensusModeParams - -> QueryUTxOFilter - -> NetworkId - -> Maybe (File () Out) + => Cmd.LegacyQueryUTxOCmdArgs -> ExceptT QueryCmdError IO () -runLegacyQueryUTxOCmd = EraBased.runQueryUTxOCmd +runLegacyQueryUTxOCmd Cmd.LegacyQueryUTxOCmdArgs {..} = + EraBased.runQueryUTxOCmd EraBased.QueryUTxOCmdArgs {..} runLegacyQueryKesPeriodInfoCmd :: () - => SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> File () In - -> Maybe (File () Out) + => Cmd.LegacyQueryKesPeriodInfoCmdArgs -> ExceptT QueryCmdError IO () -runLegacyQueryKesPeriodInfoCmd = EraBased.runQueryKesPeriodInfoCmd +runLegacyQueryKesPeriodInfoCmd Cmd.LegacyQueryKesPeriodInfoCmdArgs {..} = + EraBased.runQueryKesPeriodInfoCmd EraBased.QueryKesPeriodInfoCmdArgs {..} -- | Query the current and future parameters for a stake pool, including the retirement date. -- Any of these may be empty (in which case a null will be displayed). -- runLegacyQueryPoolStateCmd :: () - => SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> [Hash StakePoolKey] + => Cmd.LegacyQueryPoolStateCmdArgs -> ExceptT QueryCmdError IO () -runLegacyQueryPoolStateCmd = EraBased.runQueryPoolStateCmd +runLegacyQueryPoolStateCmd Cmd.LegacyQueryPoolStateCmdArgs {..} = + EraBased.runQueryPoolStateCmd EraBased.QueryPoolStateCmdArgs {..} -- | Query the local mempool state runLegacyQueryTxMempoolCmd :: () - => SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> TxMempoolQuery - -> Maybe (File () Out) + => Cmd.LegacyQueryTxMempoolCmdArgs -> ExceptT QueryCmdError IO () -runLegacyQueryTxMempoolCmd = EraBased.runQueryTxMempoolCmd +runLegacyQueryTxMempoolCmd Cmd.LegacyQueryTxMempoolCmdArgs {..} = + EraBased.runQueryTxMempoolCmd EraBased.QueryTxMempoolCmdArgs {..} runLegacyQuerySlotNumberCmd :: () - => SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> UTCTime + => Cmd.LegacyQuerySlotNumberCmdArgs -> ExceptT QueryCmdError IO () -runLegacyQuerySlotNumberCmd = EraBased.runQuerySlotNumberCmd +runLegacyQuerySlotNumberCmd Cmd.LegacyQuerySlotNumberCmdArgs {..} = + EraBased.runQuerySlotNumberCmd EraBased.QuerySlotNumberCmdArgs {..} -- | Obtain stake snapshot information for a pool, plus information about the total active stake. -- This information can be used for leader slot calculation, for example, and has been requested by SPOs. -- Obtaining the information directly is significantly more time and memory efficient than using a full ledger state dump. runLegacyQueryStakeSnapshotCmd :: () - => SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> AllOrOnly [Hash StakePoolKey] - -> Maybe (File () Out) + => Cmd.LegacyQueryStakeSnapshotCmdArgs -> ExceptT QueryCmdError IO () -runLegacyQueryStakeSnapshotCmd = EraBased.runQueryStakeSnapshotCmd +runLegacyQueryStakeSnapshotCmd Cmd.LegacyQueryStakeSnapshotCmdArgs {..} = + EraBased.runQueryStakeSnapshotCmd EraBased.QueryStakeSnapshotCmdArgs {..} runLegacyQueryLedgerStateCmd :: () - => SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Maybe (File () Out) + => Cmd.LegacyQueryLedgerStateCmdArgs -> ExceptT QueryCmdError IO () -runLegacyQueryLedgerStateCmd = EraBased.runQueryLedgerStateCmd +runLegacyQueryLedgerStateCmd Cmd.LegacyQueryLedgerStateCmdArgs {..} = + EraBased.runQueryLedgerStateCmd EraBased.QueryLedgerStateCmdArgs {..} runLegacyQueryProtocolStateCmd :: () - => SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Maybe (File () Out) + => Cmd.LegacyQueryProtocolStateCmdArgs -> ExceptT QueryCmdError IO () -runLegacyQueryProtocolStateCmd = EraBased.runQueryProtocolStateCmd +runLegacyQueryProtocolStateCmd Cmd.LegacyQueryProtocolStateCmdArgs {..} = + EraBased.runQueryProtocolStateCmd EraBased.QueryProtocolStateCmdArgs {..} -- | Query the current delegations and reward accounts, filtered by a given -- set of addresses, from a Shelley node via the local state query protocol. runLegacyQueryStakeAddressInfoCmd :: () - => SocketPath - -> AnyConsensusModeParams - -> StakeAddress - -> NetworkId - -> Maybe (File () Out) + => Cmd.LegacyQueryStakeAddressInfoCmdArgs -> ExceptT QueryCmdError IO () -runLegacyQueryStakeAddressInfoCmd = EraBased.runQueryStakeAddressInfoCmd +runLegacyQueryStakeAddressInfoCmd Cmd.LegacyQueryStakeAddressInfoCmdArgs {..} = + EraBased.runQueryStakeAddressInfoCmd EraBased.QueryStakeAddressInfoCmdArgs {..} runLegacyQueryStakePoolsCmd :: () - => SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Maybe (File () Out) + => Cmd.LegacyQueryStakePoolsCmdArgs -> ExceptT QueryCmdError IO () -runLegacyQueryStakePoolsCmd = EraBased.runQueryStakePoolsCmd +runLegacyQueryStakePoolsCmd Cmd.LegacyQueryStakePoolsCmdArgs {..} = + EraBased.runQueryStakePoolsCmd EraBased.QueryStakePoolsCmdArgs {..} runLegacyQueryStakeDistributionCmd :: () - => SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> Maybe (File () Out) + => Cmd.LegacyQueryStakeDistributionCmdArgs -> ExceptT QueryCmdError IO () -runLegacyQueryStakeDistributionCmd = EraBased.runQueryStakeDistributionCmd +runLegacyQueryStakeDistributionCmd Cmd.LegacyQueryStakeDistributionCmdArgs {..} = + EraBased.runQueryStakeDistributionCmd EraBased.QueryStakeDistributionCmdArgs {..} runLegacyQueryLeadershipScheduleCmd :: () - => SocketPath - -> AnyConsensusModeParams - -> NetworkId - -> GenesisFile -- ^ Shelley genesis - -> VerificationKeyOrHashOrFile StakePoolKey - -> SigningKeyFile In -- ^ VRF signing key - -> EpochLeadershipSchedule - -> Maybe (File () Out) + => Cmd.LegacyQueryLeadershipScheduleCmdArgs -> ExceptT QueryCmdError IO () -runLegacyQueryLeadershipScheduleCmd = EraBased.runQueryLeadershipScheduleCmd +runLegacyQueryLeadershipScheduleCmd Cmd.LegacyQueryLeadershipScheduleCmdArgs {..} = + EraBased.runQueryLeadershipScheduleCmd EraBased.QueryLeadershipScheduleCmdArgs {..} diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Run/StakeAddress.hs b/cardano-cli/src/Cardano/CLI/Legacy/Run/StakeAddress.hs index c537e57ee2..d9ed1e287f 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Run/StakeAddress.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Run/StakeAddress.hs @@ -57,16 +57,16 @@ runLegacyStakeAddressBuildCmd = runStakeAddressBuildCmd runLegacyStakeAddressRegistrationCertificateCmd :: () - => AnyShelleyBasedEra + => EraInEon ShelleyBasedEra -> StakeIdentifier -> Maybe Lovelace -- ^ Deposit required in conway era -> File () Out -> ExceptT StakeAddressCmdError IO () -runLegacyStakeAddressRegistrationCertificateCmd (AnyShelleyBasedEra sbe) = +runLegacyStakeAddressRegistrationCertificateCmd (EraInEon sbe) = runStakeAddressRegistrationCertificateCmd sbe runLegacyStakeAddresslDelegationCertificateCmd :: () - => AnyShelleyBasedEra + => EraInEon ShelleyBasedEra -> StakeIdentifier -- ^ Delegator stake verification key, verification key file or script file. -> VerificationKeyOrHashOrFile StakePoolKey @@ -74,14 +74,14 @@ runLegacyStakeAddresslDelegationCertificateCmd :: () -- verification key hash. -> File () Out -> ExceptT StakeAddressCmdError IO () -runLegacyStakeAddresslDelegationCertificateCmd (AnyShelleyBasedEra sbe) = +runLegacyStakeAddresslDelegationCertificateCmd (EraInEon sbe) = runStakeAddressStakeDelegationCertificateCmd sbe runLegacyStakeAddressDeregistrationCertificateCmd :: () - => AnyShelleyBasedEra + => EraInEon ShelleyBasedEra -> StakeIdentifier -> Maybe Lovelace -- ^ Deposit required in conway era -> File () Out -> ExceptT StakeAddressCmdError IO () -runLegacyStakeAddressDeregistrationCertificateCmd (AnyShelleyBasedEra sbe) = +runLegacyStakeAddressDeregistrationCertificateCmd (EraInEon sbe) = runStakeAddressDeregistrationCertificateCmd sbe diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Run/StakePool.hs b/cardano-cli/src/Cardano/CLI/Legacy/Run/StakePool.hs index 61044cdf3f..efc02950e8 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Run/StakePool.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Run/StakePool.hs @@ -35,7 +35,7 @@ runLegacyStakePoolCmds = \case -- TODO: Metadata and more stake pool relay support to be -- added in the future. runLegacyStakePoolRegistrationCertificateCmd :: () - => AnyShelleyBasedEra + => EraInEon ShelleyBasedEra -> VerificationKeyOrFile StakePoolKey -- ^ Stake pool verification key. -> VerificationKeyOrFile VrfKey @@ -58,17 +58,17 @@ runLegacyStakePoolRegistrationCertificateCmd :: () -> File () Out -> ExceptT StakePoolCmdError IO () runLegacyStakePoolRegistrationCertificateCmd = \case - AnyShelleyBasedEra sbe -> + EraInEon sbe -> runStakePoolRegistrationCertificateCmd sbe runLegacyStakePoolDeregistrationCertificateCmd :: () - => AnyShelleyBasedEra + => EraInEon ShelleyBasedEra -> VerificationKeyOrFile StakePoolKey -> Shelley.EpochNo -> File () Out -> ExceptT StakePoolCmdError IO () runLegacyStakePoolDeregistrationCertificateCmd = \case - AnyShelleyBasedEra sbe -> + EraInEon sbe -> runStakePoolRetirementCertificateCmd sbe runLegacyStakePoolIdCmd :: () diff --git a/cardano-cli/src/Cardano/CLI/Read.hs b/cardano-cli/src/Cardano/CLI/Read.hs index 65e186e8ed..0ad4b6cd0e 100644 --- a/cardano-cli/src/Cardano/CLI/Read.hs +++ b/cardano-cli/src/Cardano/CLI/Read.hs @@ -139,6 +139,7 @@ import GHC.IO.Handle.FD (openFileBlocking) import qualified Options.Applicative as Opt import System.IO (IOMode (ReadMode)) + -- Metadata data MetadataError @@ -176,7 +177,7 @@ readTxMetadata :: CardanoEra era -> IO (Either MetadataError (TxMetadataInEra era)) readTxMetadata _ _ [] = return $ Right TxMetadataNone readTxMetadata era schema files = cardanoEraConstraints era $ runExceptT $ do - supported <- maybeEonInEra era + supported <- forEraMaybeEon era & hoistMaybe (MetadataErrorNotAvailableInEra $ AnyCardanoEra era) metadata <- mapM (readFileTxMetadata schema) files pure $ TxMetadataInEra supported $ mconcat metadata @@ -288,9 +289,9 @@ readScriptWitness era (PlutusScriptWitnessFiles case script' of PlutusScript version pscript -> do datum <- firstExceptT ScriptWitnessErrorScriptData - $ readScriptDatumOrFile datumOrFile + $ readScriptDatumOrFile datumOrFile redeemer <- firstExceptT ScriptWitnessErrorScriptData - $ readScriptRedeemerOrFile redeemerOrFile + $ readScriptRedeemerOrFile redeemerOrFile return $ PlutusScriptWitness langInEra version (PScript pscript) datum @@ -619,6 +620,9 @@ data SomeSigningWitness | AGenesisDelegateExtendedSigningWitness (SigningKey GenesisDelegateExtendedKey) | AGenesisUTxOSigningWitness (SigningKey GenesisUTxOKey) | ADRepSigningWitness (SigningKey DRepKey) + | ACommitteeColdSigningWitness (SigningKey CommitteeColdKey) + | ACommitteeHotSigningWitness (SigningKey CommitteeHotKey) + deriving Show -- | Data required for constructing a Shelley bootstrap witness. @@ -652,6 +656,8 @@ categoriseSomeSigningWitness swsk = AGenesisDelegateExtendedSigningWitness sk -> AShelleyKeyWitness (WitnessGenesisDelegateExtendedKey sk) AGenesisUTxOSigningWitness sk -> AShelleyKeyWitness (WitnessGenesisUTxOKey sk) ADRepSigningWitness sk -> AShelleyKeyWitness (WitnessPaymentKey $ castDrep sk) + ACommitteeColdSigningWitness sk -> AShelleyKeyWitness (WitnessCommitteeColdKey sk) + ACommitteeHotSigningWitness sk -> AShelleyKeyWitness (WitnessCommitteeHotKey sk) -- TODO: Conway era - Add constrctor for SigningKey DrepKey to ShelleyWitnessSigningKey castDrep :: SigningKey DRepKey -> SigningKey PaymentKey @@ -704,6 +710,8 @@ readWitnessSigningData (KeyWitnessSigningData skFile mbByronAddr) = do , FromSomeType (AsSigningKey AsGenesisDelegateExtendedKey ) AGenesisDelegateExtendedSigningWitness , FromSomeType (AsSigningKey AsGenesisUTxOKey ) AGenesisUTxOSigningWitness , FromSomeType (AsSigningKey AsDRepKey ) ADRepSigningWitness + , FromSomeType (AsSigningKey AsCommitteeColdKey ) ACommitteeColdSigningWitness + , FromSomeType (AsSigningKey AsCommitteeHotKey ) ACommitteeHotSigningWitness ] bech32FileTypes = @@ -796,7 +804,7 @@ readTxGovernanceActions -> IO (Either ConstitutionError [Proposal era]) readTxGovernanceActions _ [] = return $ Right [] readTxGovernanceActions era files = runExceptT $ do - w <- maybeEonInEra era + w <- forEraMaybeEon era & hoistMaybe (ConstitutionNotSupportedInEra $ cardanoEraConstraints era $ AnyCardanoEra era) newExceptT $ sequence <$> mapM (readProposal w) files diff --git a/cardano-cli/src/Cardano/CLI/Types/Common.hs b/cardano-cli/src/Cardano/CLI/Types/Common.hs index 164b443bbc..90ed3cc3e6 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Common.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Common.hs @@ -6,7 +6,9 @@ {-# LANGUAGE StandaloneDeriving #-} module Cardano.CLI.Types.Common - ( AllOrOnly(..) + ( AnchorDataHash(..) + , AnchorUrl(..) + , AllOrOnly(..) , AddressKeyType(..) , BalanceTxExecUnits (..) , BlockId(..) @@ -128,6 +130,14 @@ data ProposalHashSource | ProposalHashSourceHash (L.SafeHash Crypto.StandardCrypto L.AnchorData) deriving Show +newtype AnchorUrl = AnchorUrl + { unAnchorUrl :: L.Url + } deriving (Eq, Show) + +newtype AnchorDataHash = AnchorDataHash + { unAnchorDataHash :: L.SafeHash Crypto.StandardCrypto L.AnchorData + } deriving (Eq, Show) + -- | Specify whether to render the script cost as JSON -- in the cli's build command. data TxBuildOutputOptions = OutputScriptCostOnly (File () Out) diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/StakeAddressDelegationError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/StakeAddressDelegationError.hs index 8de937f6b0..1586b4a3f8 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/StakeAddressDelegationError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/StakeAddressDelegationError.hs @@ -1,6 +1,5 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} module Cardano.CLI.Types.Errors.StakeAddressDelegationError ( StakeAddressDelegationError(..) @@ -10,12 +9,11 @@ import Cardano.Api import qualified Data.Text as Text -newtype StakeAddressDelegationError = VoteDelegationNotSupported AnyShelleyToBabbageEra deriving Show +newtype StakeAddressDelegationError = VoteDelegationNotSupported (EraInEon ShelleyToBabbageEra) deriving Show instance Error StakeAddressDelegationError where displayError = \case - VoteDelegationNotSupported (AnyShelleyToBabbageEra stbe) -> "Vote delegation not supported in " <> eraTxt stbe <> " era." + VoteDelegationNotSupported (EraInEon eraInEon) -> "Vote delegation not supported in " <> eraTxt <> " era." where - eraTxt :: forall era. ShelleyToBabbageEra era -> String - eraTxt stbe' = shelleyToBabbageEraConstraints stbe' $ - Text.unpack . renderEra $ AnyCardanoEra (cardanoEra @era) + cEra = toCardanoEra eraInEon + eraTxt = cardanoEraConstraints cEra $ Text.unpack . renderEra $ AnyCardanoEra cEra diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/TxCmdError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/TxCmdError.hs index 98af501e7e..29e610e7b3 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/TxCmdError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/TxCmdError.hs @@ -15,8 +15,8 @@ import Cardano.Api.Shelley import Cardano.CLI.Read import Cardano.CLI.Types.Common -import Cardano.CLI.Types.Errors.ProtocolParamsError import Cardano.CLI.Types.Errors.BootstrapWitnessError +import Cardano.CLI.Types.Errors.ProtocolParamsError import Cardano.CLI.Types.Errors.TxValidationError import Cardano.CLI.Types.Output import Cardano.CLI.Types.TxFeature diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/TxValidationError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/TxValidationError.hs index 068a634b45..ad14c7b7de 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/TxValidationError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/TxValidationError.hs @@ -1,11 +1,10 @@ -{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} - {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} module Cardano.CLI.Types.Errors.TxValidationError ( TxAuxScriptsValidationError(..) @@ -36,12 +35,12 @@ module Cardano.CLI.Types.Errors.TxValidationError ) where import Cardano.Api +import qualified Cardano.Api.Ledger as L import Cardano.Api.Shelley import Prelude import Data.Bifunctor (first) -import Data.Function import qualified Data.Map.Strict as Map import Data.Maybe import qualified Data.Text as Text @@ -104,12 +103,9 @@ validateTxTotalCollateral :: CardanoEra era -> Maybe Lovelace -> Either TxTotalCollateralValidationError (TxTotalCollateral era) validateTxTotalCollateral _ Nothing = return TxTotalCollateralNone -validateTxTotalCollateral era (Just coll) = - case totalAndReturnCollateralSupportedInEra era of - Just supp -> return $ TxTotalCollateral supp coll - Nothing -> Left $ TxTotalCollateralNotSupported - $ cardanoEraConstraints era - $ AnyCardanoEra era +validateTxTotalCollateral era (Just coll) = do + supported <- conjureWitness era TxTotalCollateralNotSupported + pure $ TxTotalCollateral supported coll newtype TxReturnCollateralValidationError = TxReturnCollateralNotSupported AnyCardanoEra @@ -124,11 +120,8 @@ validateTxReturnCollateral :: CardanoEra era -> Either TxReturnCollateralValidationError (TxReturnCollateral CtxTx era) validateTxReturnCollateral _ Nothing = return TxReturnCollateralNone validateTxReturnCollateral era (Just retColTxOut) = do - case totalAndReturnCollateralSupportedInEra era of - Just supp -> return $ TxReturnCollateral supp retColTxOut - Nothing -> Left $ TxReturnCollateralNotSupported - $ cardanoEraConstraints era - $ AnyCardanoEra era + supported <- conjureWitness era TxReturnCollateralNotSupported + pure $ TxReturnCollateral supported retColTxOut newtype TxValidityLowerBoundValidationError = TxValidityLowerBoundNotSupported AnyCardanoEra @@ -143,12 +136,9 @@ validateTxValidityLowerBound :: CardanoEra era -> Maybe SlotNo -> Either TxValidityLowerBoundValidationError (TxValidityLowerBound era) validateTxValidityLowerBound _ Nothing = return TxValidityNoLowerBound -validateTxValidityLowerBound era (Just slot) = - case validityLowerBoundSupportedInEra era of - Nothing -> Left $ TxValidityLowerBoundNotSupported - $ cardanoEraConstraints era - $ AnyCardanoEra era - Just supported -> return (TxValidityLowerBound supported slot) +validateTxValidityLowerBound era (Just slot) = do + supported <- conjureWitness era TxValidityLowerBoundNotSupported + pure $ TxValidityLowerBound supported slot newtype TxValidityUpperBoundValidationError = TxValidityUpperBoundNotSupported AnyCardanoEra @@ -162,18 +152,13 @@ validateTxValidityUpperBound :: CardanoEra era -> Maybe SlotNo -> Either TxValidityUpperBoundValidationError (TxValidityUpperBound era) -validateTxValidityUpperBound era Nothing = - case validityNoUpperBoundSupportedInEra era of - Nothing -> Left $ TxValidityUpperBoundNotSupported - $ cardanoEraConstraints era - $ AnyCardanoEra era - Just supported -> return (TxValidityNoUpperBound supported) -validateTxValidityUpperBound era (Just slot) = - case validityUpperBoundSupportedInEra era of - Nothing -> Left $ TxValidityUpperBoundNotSupported - $ cardanoEraConstraints era - $ AnyCardanoEra era - Just supported -> return (TxValidityUpperBound supported slot) +validateTxValidityUpperBound era = \case + Just slot -> do + supported <- conjureWitness era TxValidityUpperBoundNotSupported + pure $ TxValidityUpperBound supported slot + Nothing -> do + supported <- conjureWitness era TxValidityUpperBoundNotSupported + pure $ TxValidityNoUpperBound supported data TxAuxScriptsValidationError = TxAuxScriptsNotSupportedInEra AnyCardanoEra @@ -191,14 +176,10 @@ validateTxAuxScripts -> [ScriptInAnyLang] -> Either TxAuxScriptsValidationError (TxAuxScripts era) validateTxAuxScripts _ [] = return TxAuxScriptsNone -validateTxAuxScripts era scripts = - case auxScriptsSupportedInEra era of - Nothing -> Left $ TxAuxScriptsNotSupportedInEra - $ cardanoEraConstraints era - $ AnyCardanoEra era - Just supported -> do - scriptsInEra <- mapM (first TxAuxScriptsLanguageError . validateScriptSupportedInEra era) scripts - return $ TxAuxScripts supported scriptsInEra +validateTxAuxScripts era scripts = do + supported <- conjureWitness era TxAuxScriptsNotSupportedInEra + scriptsInEra <- mapM (first TxAuxScriptsLanguageError . validateScriptSupportedInEra era) scripts + pure $ TxAuxScripts supported scriptsInEra newtype TxRequiredSignersValidationError = TxRequiredSignersValidationError AnyCardanoEra @@ -213,12 +194,9 @@ validateRequiredSigners -> [Hash PaymentKey] -> Either TxRequiredSignersValidationError (TxExtraKeyWitnesses era) validateRequiredSigners _ [] = return TxExtraKeyWitnessesNone -validateRequiredSigners era reqSigs = - case extraKeyWitnessesSupportedInEra era of - Nothing -> Left $ TxRequiredSignersValidationError - $ cardanoEraConstraints era - $ AnyCardanoEra era - Just supported -> return $ TxExtraKeyWitnesses supported reqSigs +validateRequiredSigners era reqSigs = do + supported <- conjureWitness era TxRequiredSignersValidationError + pure $ TxExtraKeyWitnesses supported reqSigs newtype TxWithdrawalsValidationError = TxWithdrawalsNotSupported AnyCardanoEra @@ -235,8 +213,7 @@ validateTxWithdrawals -> Either TxWithdrawalsValidationError (TxWithdrawals BuildTx era) validateTxWithdrawals _ [] = return TxWithdrawalsNone validateTxWithdrawals era withdrawals = do - supported <- maybeEonInEra era - & maybe (cardanoEraConstraints era $ Left . TxWithdrawalsNotSupported $ AnyCardanoEra era) Right + supported <- conjureWitness era TxWithdrawalsNotSupported let convWithdrawals = map convert withdrawals pure $ TxWithdrawals supported convWithdrawals where @@ -264,36 +241,55 @@ validateTxCertificates -> Either TxCertificatesValidationError (TxCertificates BuildTx era) validateTxCertificates _ [] = return TxCertificatesNone validateTxCertificates era certsAndScriptWitnesses = cardanoEraConstraints era $ do - supported <- maybeEonInEra era - & maybe (Left . TxCertificatesValidationNotSupported $ AnyCardanoEra era) Right + supported <- conjureWitness era TxCertificatesValidationNotSupported let certs = map fst certsAndScriptWitnesses reqWits = Map.fromList $ mapMaybe convert certsAndScriptWitnesses pure $ TxCertificates supported certs $ BuildTxWith reqWits where - -- We get the stake credential witness for a certificate that requires it. - -- NB: Only stake address deregistration and delegation requires - -- witnessing (witness can be script or key) - deriveStakeCredentialWitness - :: Certificate era - -> Maybe StakeCredential - deriveStakeCredentialWitness _cert = Nothing - -- case cert of - -- -- TODO: Conway era - -- -- StakeAddressDeregistrationCertificate sCred -> Just sCred - -- -- StakeAddressPoolDelegationCertificate sCred _ -> Just sCred - -- _ -> Nothing - - convert - :: (Certificate era, Maybe (ScriptWitness WitCtxStake era)) - -> Maybe (StakeCredential, Witness WitCtxStake era) - convert (cert, mScriptWitnessFiles) = do - sCred <- deriveStakeCredentialWitness cert - case mScriptWitnessFiles of - Just sWit -> do - Just ( sCred - , ScriptWitness ScriptWitnessForStakeAddr sWit - ) - Nothing -> Just (sCred, KeyWitness KeyWitnessForStakeAddr) + -- We get the stake credential witness for a certificate that requires it. + -- NB: Only stake address deregistration and delegation requires + -- witnessing (witness can be script or key) + deriveStakeCredentialWitness + :: Certificate era + -> Maybe StakeCredential + deriveStakeCredentialWitness = fmap fromShelleyStakeCredential . \case + ShelleyRelatedCertificate stbEra shelleyCert -> shelleyToBabbageEraConstraints stbEra $ + case shelleyCert of + L.RegTxCert _sCred -> Nothing -- not required + L.UnRegTxCert sCred -> Just sCred + L.DelegStakeTxCert sCred _ -> Just sCred + L.RegPoolTxCert _ -> Nothing + L.RetirePoolTxCert _ _ -> Nothing + L.MirTxCert _ -> Nothing + L.GenesisDelegTxCert{} -> Nothing + + ConwayCertificate cEra conwayCert -> conwayEraOnwardsConstraints cEra $ + case conwayCert of + L.RegPoolTxCert _ -> Nothing + L.RetirePoolTxCert _ _ -> Nothing + L.RegTxCert _ -> Nothing + L.UnRegTxCert sCred -> Just sCred + L.RegDepositTxCert _ _ -> Nothing + L.UnRegDepositTxCert sCred _ -> Just sCred + L.DelegTxCert sCred _ -> Just sCred + L.RegDepositDelegTxCert sCred _ _ -> Just sCred + L.AuthCommitteeHotKeyTxCert{} -> Nothing + L.ResignCommitteeColdTxCert _ -> Nothing + L.RegDRepTxCert{} -> Nothing + L.UnRegDRepTxCert{} -> Nothing + L.UpdateDRepTxCert{} -> Nothing + + convert + :: (Certificate era, Maybe (ScriptWitness WitCtxStake era)) + -> Maybe (StakeCredential, Witness WitCtxStake era) + convert (cert, mScriptWitnessFiles) = do + sCred <- deriveStakeCredentialWitness cert + case mScriptWitnessFiles of + Just sWit -> do + Just ( sCred + , ScriptWitness ScriptWitnessForStakeAddr sWit + ) + Nothing -> Just (sCred, KeyWitness KeyWitnessForStakeAddr) newtype TxProtocolParametersValidationError = ProtocolParametersNotSupported AnyCardanoEra @@ -308,12 +304,9 @@ validateProtocolParameters -> Maybe (LedgerProtocolParameters era) -> Either TxProtocolParametersValidationError (BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))) validateProtocolParameters _ Nothing = return (BuildTxWith Nothing) -validateProtocolParameters era (Just pparams) = - case cardanoEraStyle era of - LegacyByronEra -> Left $ ProtocolParametersNotSupported - $ cardanoEraConstraints era - $ AnyCardanoEra era - ShelleyBasedEra _ -> return . BuildTxWith $ Just pparams +validateProtocolParameters era (Just pparams) = do + _ <- conjureWitness @ShelleyBasedEra era ProtocolParametersNotSupported + pure . BuildTxWith $ Just pparams newtype TxUpdateProposalValidationError = TxUpdateProposalNotSupported AnyCardanoEra @@ -329,8 +322,7 @@ validateTxUpdateProposal -> Either TxUpdateProposalValidationError (TxUpdateProposal era) validateTxUpdateProposal _ Nothing = return TxUpdateProposalNone validateTxUpdateProposal era (Just prop) = do - supported <- maybeEonInEra era - & maybe (cardanoEraConstraints era $ Left . TxUpdateProposalNotSupported $ AnyCardanoEra era) Right + supported <- conjureWitness era TxUpdateProposalNotSupported pure $ TxUpdateProposal supported prop newtype TxScriptValidityValidationError @@ -346,9 +338,15 @@ validateTxScriptValidity -> Maybe ScriptValidity -> Either TxScriptValidityValidationError (TxScriptValidity era) validateTxScriptValidity _ Nothing = pure TxScriptValidityNone -validateTxScriptValidity era (Just scriptValidity) = - case txScriptValiditySupportedInCardanoEra era of - Nothing -> Left $ ScriptValidityNotSupported - $ cardanoEraConstraints era - $ AnyCardanoEra era - Just supported -> pure $ TxScriptValidity supported scriptValidity +validateTxScriptValidity era (Just scriptValidity) = do + supported <- conjureWitness era ScriptValidityNotSupported + pure $ TxScriptValidity supported scriptValidity + + +conjureWitness :: Eon eon + => CardanoEra era -- ^ era to try to conjure eon from + -> (AnyCardanoEra -> e) -- ^ error wrapper function + -> Either e (eon era) -- ^ eon if it includes the era, an error otherwise +conjureWitness era errF = + maybe (cardanoEraConstraints era $ Left . errF $ AnyCardanoEra era) Right $ + forEraMaybeEon era diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/SigningKeys.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/SigningKeys.hs index a1961f1e79..b074b77b2c 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/SigningKeys.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/SigningKeys.hs @@ -32,21 +32,21 @@ import Hedgehog.Internal.Property (failWith) hprop_deserialise_legacy_signing_Key :: Property hprop_deserialise_legacy_signing_Key = propertyOnce $ do - legSkeyBs <- H.evalIO $ LB.readFile "test/cardano-cli-golden/files/golden/byron/keys/legacy.skey" + legSkeyBs <- H.evalIO $ LB.readFile "test/cardano-cli-golden/files/input/byron/keys/legacy.skey" case deserialiseFromBytes decodeLegacyDelegateKey legSkeyBs of Left deSerFail -> failWith Nothing $ show deSerFail Right _ -> success hprop_deserialise_nonLegacy_signing_Key :: Property hprop_deserialise_nonLegacy_signing_Key = propertyOnce $ do - skeyBs <- H.evalIO $ LB.readFile "test/cardano-cli-golden/files/golden/byron/keys/byron.skey" + skeyBs <- H.evalIO $ LB.readFile "test/cardano-cli-golden/files/input/byron/keys/byron.skey" case deserialiseFromBytes Crypto.fromCBORXPrv skeyBs of Left deSerFail -> failWith Nothing $ show deSerFail Right _ -> success hprop_print_legacy_signing_key_address :: Property hprop_print_legacy_signing_key_address = propertyOnce $ do - let legKeyFp = "test/cardano-cli-golden/files/golden/byron/keys/legacy.skey" + let legKeyFp = "test/cardano-cli-golden/files/input/byron/keys/legacy.skey" void $ execCardanoCLI [ "signing-key-address", "--byron-legacy-formats" @@ -62,7 +62,7 @@ hprop_print_legacy_signing_key_address = propertyOnce $ do hprop_print_nonLegacy_signing_key_address :: Property hprop_print_nonLegacy_signing_key_address = propertyOnce $ do - let nonLegKeyFp = "test/cardano-cli-golden/files/golden/byron/keys/byron.skey" + let nonLegKeyFp = "test/cardano-cli-golden/files/input/byron/keys/byron.skey" void $ execCardanoCLI [ "signing-key-address", "--byron-formats" @@ -86,7 +86,7 @@ hprop_generate_and_read_nonlegacy_signingkeys = property $ do hprop_migrate_legacy_to_nonlegacy_signingkeys :: Property hprop_migrate_legacy_to_nonlegacy_signingkeys = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do - let legKeyFp = "test/cardano-cli-golden/files/golden/byron/keys/legacy.skey" + let legKeyFp = "test/cardano-cli-golden/files/input/byron/keys/legacy.skey" nonLegacyKeyFp <- noteTempFile tempDir "nonlegacy.skey" void $ execCardanoCLI @@ -104,14 +104,14 @@ hprop_migrate_legacy_to_nonlegacy_signingkeys = hprop_deserialise_NonLegacy_Signing_Key_API :: Property hprop_deserialise_NonLegacy_Signing_Key_API = propertyOnce $ do - eFailOrWit <- H.evalIO . runExceptT $ readByronSigningKey NonLegacyByronKeyFormat "test/cardano-cli-golden/files/golden/byron/keys/byron.skey" + eFailOrWit <- H.evalIO . runExceptT $ readByronSigningKey NonLegacyByronKeyFormat "test/cardano-cli-golden/files/input/byron/keys/byron.skey" case eFailOrWit of Left keyFailure -> failWith Nothing $ show keyFailure Right _ -> success hprop_deserialiseLegacy_Signing_Key_API :: Property hprop_deserialiseLegacy_Signing_Key_API = propertyOnce $ do - eFailOrWit <- H.evalIO . runExceptT $ readByronSigningKey LegacyByronKeyFormat "test/cardano-cli-golden/files/golden/byron/keys/legacy.skey" + eFailOrWit <- H.evalIO . runExceptT $ readByronSigningKey LegacyByronKeyFormat "test/cardano-cli-golden/files/input/byron/keys/legacy.skey" case eFailOrWit of Left keyFailure -> failWith Nothing $ show keyFailure Right _ -> success diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/Tx.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/Tx.hs index ed3239782e..7facd6aef2 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/Tx.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/Tx.hs @@ -22,10 +22,10 @@ import Hedgehog.Internal.Property (failWith) {- HLINT ignore "Use camelCase" -} -hprop_golden_byronTx_legacy :: Property -hprop_golden_byronTx_legacy = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do - signingKey <- noteInputFile "test/cardano-cli-golden/files/golden/byron/keys/legacy.skey" - goldenTx <- noteInputFile "test/cardano-cli-golden/files/golden/byron/tx/legacy.tx" +hprop_byronTx_legacy :: Property +hprop_byronTx_legacy = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do + signingKey <- noteInputFile "test/cardano-cli-golden/files/input/byron/keys/legacy.skey" + expectedTx <- noteInputFile "test/cardano-cli-golden/files/input/byron/tx/legacy.tx" createdTx <- noteTempFile tempDir "tx" void $ execCardanoCLI [ "byron", "transaction", "issue-utxo-expenditure" @@ -37,12 +37,12 @@ hprop_golden_byronTx_legacy = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir , "--txout", "(\"2657WMsDfac6eFirdvKVPVMxNVYuACd1RGM2arH3g1y1yaQCr1yYpb2jr2b2aSiDZ\",999)" ] - compareByronTxs createdTx goldenTx + compareByronTxs createdTx expectedTx -hprop_golden_byronTx :: Property -hprop_golden_byronTx = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do - signingKey <- noteInputFile "test/cardano-cli-golden/files/golden/byron/keys/byron.skey" - goldenTx <- noteInputFile "test/cardano-cli-golden/files/golden/byron/tx/normal.tx" +hprop_byronTx :: Property +hprop_byronTx = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do + signingKey <- noteInputFile "test/cardano-cli-golden/files/input/byron/keys/byron.skey" + expectedTx <- noteInputFile "test/cardano-cli-golden/files/input/byron/tx/normal.tx" createdTx <- noteTempFile tempDir "tx" void $ execCardanoCLI [ "byron", "transaction", "issue-utxo-expenditure" @@ -54,7 +54,7 @@ hprop_golden_byronTx = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do , "--txout", "(\"2657WMsDfac6eFirdvKVPVMxNVYuACd1RGM2arH3g1y1yaQCr1yYpb2jr2b2aSiDZ\",999)" ] - compareByronTxs createdTx goldenTx + compareByronTxs createdTx expectedTx getTxByteString :: FilePath -> H.PropertyT IO (ATxAux ByteString) getTxByteString txFp = do @@ -64,8 +64,8 @@ getTxByteString txFp = do Right aTxAuxBS -> return aTxAuxBS compareByronTxs :: FilePath -> FilePath -> H.PropertyT IO () -compareByronTxs createdTx goldenTx = do +compareByronTxs createdTx expectedTx = do createdATxAuxBS <- getTxByteString createdTx - goldenATxAuxBS <- getTxByteString goldenTx + expectedATxAuxBS <- getTxByteString expectedTx - normalByronTxToGenTx goldenATxAuxBS === normalByronTxToGenTx createdATxAuxBS + normalByronTxToGenTx expectedATxAuxBS === normalByronTxToGenTx createdATxAuxBS diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/UpdateProposal.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/UpdateProposal.hs index 944ba9b8cb..228c7207f1 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/UpdateProposal.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/UpdateProposal.hs @@ -17,10 +17,10 @@ import Hedgehog.Internal.Property (failWith) {- HLINT ignore "Use camelCase" -} -hprop_golden_byron_update_proposal :: Property -hprop_golden_byron_update_proposal = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do - goldenUpdateProposal <- noteInputFile "test/cardano-cli-golden/files/golden/byron/update-proposal" - signingKey <- noteInputFile "test/cardano-cli-golden/files/golden/byron/keys/byron.skey" +hprop_byron_update_proposal :: Property +hprop_byron_update_proposal = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do + expectedUpdateProposal <- noteInputFile "test/cardano-cli-golden/files/input/byron/update-proposal" + signingKey <- noteInputFile "test/cardano-cli-golden/files/input/byron/keys/byron.skey" createdUpdateProposal <- noteTempFile tempDir "byron-update-proposal" void $ execCardanoCLI [ "byron", "governance", "create-update-proposal" @@ -36,8 +36,8 @@ hprop_golden_byron_update_proposal = propertyOnce $ H.moduleWorkspace "tmp" $ \t , "--filepath", createdUpdateProposal ] - eGolden <- liftIO . runExceptT $ readByronUpdateProposal goldenUpdateProposal - golden <- case eGolden of + eExpected <- liftIO . runExceptT $ readByronUpdateProposal expectedUpdateProposal + expected <- case eExpected of Left err -> failWith Nothing . Text.unpack $ renderByronUpdateProposalError err Right prop -> return prop @@ -46,4 +46,4 @@ hprop_golden_byron_update_proposal = propertyOnce $ H.moduleWorkspace "tmp" $ \t Left err -> failWith Nothing . Text.unpack $ renderByronUpdateProposalError err Right prop -> return prop - golden === created + expected === created diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/Vote.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/Vote.hs index c468bcc442..d40dfc461d 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/Vote.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/Vote.hs @@ -17,11 +17,11 @@ import Hedgehog.Internal.Property (failWith) {- HLINT ignore "Use camelCase" -} -hprop_golden_byron_yes_vote :: Property -hprop_golden_byron_yes_vote = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do - goldenYesVote <- noteInputFile "test/cardano-cli-golden/files/golden/byron/votes/vote-yes" - proposal <- noteInputFile "test/cardano-cli-golden/files/golden/byron/update-proposal" - signingKey <- noteInputFile "test/cardano-cli-golden/files/golden/byron/keys/byron.skey" +hprop_byron_yes_vote :: Property +hprop_byron_yes_vote = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do + expectedYesVote <- noteInputFile "test/cardano-cli-golden/files/input/byron/votes/vote-yes" + proposal <- noteInputFile "test/cardano-cli-golden/files/input/byron/update-proposal" + signingKey <- noteInputFile "test/cardano-cli-golden/files/input/byron/keys/byron.skey" createdYesVote <- noteTempFile tempDir "byron-yes-vote" void $ execCardanoCLI [ "byron", "governance", "create-proposal-vote" @@ -32,8 +32,8 @@ hprop_golden_byron_yes_vote = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir , "--output-filepath", createdYesVote ] - eGolden <- liftIO . runExceptT $ readByronVote goldenYesVote - golden <- case eGolden of + eExpected <- liftIO . runExceptT $ readByronVote expectedYesVote + expected <- case eExpected of Left err -> failWith Nothing . Text.unpack $ renderByronVoteError err Right prop -> return prop @@ -42,13 +42,13 @@ hprop_golden_byron_yes_vote = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir Left err -> failWith Nothing . Text.unpack $ renderByronVoteError err Right prop -> return prop - golden === created + expected === created -hprop_golden_byron_no_vote :: Property -hprop_golden_byron_no_vote = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do - goldenNoVote <- noteInputFile "test/cardano-cli-golden/files/golden/byron/votes/vote-no" - proposal <- noteInputFile "test/cardano-cli-golden/files/golden/byron/update-proposal" - signingKey <- noteInputFile "test/cardano-cli-golden/files/golden/byron/keys/byron.skey" +hprop_byron_no_vote :: Property +hprop_byron_no_vote = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do + expectedNoVote <- noteInputFile "test/cardano-cli-golden/files/input/byron/votes/vote-no" + proposal <- noteInputFile "test/cardano-cli-golden/files/input/byron/update-proposal" + signingKey <- noteInputFile "test/cardano-cli-golden/files/input/byron/keys/byron.skey" createdNoVote <- noteTempFile tempDir "byron-no-vote" void $ execCardanoCLI [ "byron", "governance", "create-proposal-vote" @@ -59,8 +59,8 @@ hprop_golden_byron_no_vote = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir - , "--output-filepath", createdNoVote ] - eGolden <- liftIO . runExceptT $ readByronVote goldenNoVote - golden <- case eGolden of + eExpected <- liftIO . runExceptT $ readByronVote expectedNoVote + expected <- case eExpected of Left err -> failWith Nothing . Text.unpack $ renderByronVoteError err Right prop -> return prop @@ -69,4 +69,4 @@ hprop_golden_byron_no_vote = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir - Left err -> failWith Nothing . Text.unpack $ renderByronVoteError err Right prop -> return prop - golden === created + expected === created diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/AnswerPoll.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/AnswerPoll.hs new file mode 100644 index 0000000000..b4485892b8 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/AnswerPoll.hs @@ -0,0 +1,77 @@ +{-# LANGUAGE OverloadedStrings #-} + +module Test.Golden.EraBased.Governance.AnswerPoll where + +import Control.Monad (void) + +import Test.Cardano.CLI.Util + +import Hedgehog (Property) +import qualified Hedgehog as H +import qualified Hedgehog.Extras.Test.Base as H +import qualified Hedgehog.Extras.Test.File as H +import qualified Hedgehog.Extras.Test.Golden as H + +{- HLINT ignore "Use camelCase" -} + +hprop_golden_governanceAnswerPollNeg1Invalid :: Property +hprop_golden_governanceAnswerPollNeg1Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" + outFile <- H.noteTempFile tempDir "answer-file.json" + + result <- tryExecCardanoCLI + [ "babbage", "governance", "answer-poll" + , "--poll-file", pollFile + , "--answer", "-1" + , "--out-file", outFile + ] + + H.assertFileMissing outFile + + either (const H.success) (const H.failure) result + +hprop_golden_governanceAnswerPoll0 :: Property +hprop_golden_governanceAnswerPoll0 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" + goldenAnswerFile <- H.note "test/cardano-cli-golden/files/golden/governance/polls/basic.answer.0.json" + outFile <- H.noteTempFile tempDir "answer-file.json" + + void $ execCardanoCLI + [ "babbage", "governance", "answer-poll" + , "--poll-file", pollFile + , "--answer", "0" + , "--out-file", outFile + ] + + H.diffFileVsGoldenFile outFile goldenAnswerFile + +hprop_golden_governanceAnswerPollPos1 :: Property +hprop_golden_governanceAnswerPollPos1 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" + goldenAnswerFile <- H.note "test/cardano-cli-golden/files/golden/governance/polls/basic.answer.1.json" + outFile <- H.noteTempFile tempDir "answer-file.json" + + void $ execCardanoCLI + [ "babbage", "governance", "answer-poll" + , "--poll-file", pollFile + , "--answer", "1" + , "--out-file", outFile + ] + + H.diffFileVsGoldenFile outFile goldenAnswerFile + +hprop_golden_governanceAnswerPollPos2Invalid :: Property +hprop_golden_governanceAnswerPollPos2Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" + outFile <- H.noteTempFile tempDir "answer-file.json" + + result <- tryExecCardanoCLI + [ "babbage", "governance", "answer-poll" + , "--poll-file", pollFile + , "--answer", "2" + , "--out-file", outFile + ] + + H.assertFileMissing outFile + + either (const H.success) (const H.failure) result diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/CreatePoll.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/CreatePoll.hs similarity index 71% rename from cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/CreatePoll.hs rename to cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/CreatePoll.hs index 96ad904e68..169e27d07e 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/CreatePoll.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/CreatePoll.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} -module Test.Golden.Shelley.Governance.CreatePoll where +module Test.Golden.EraBased.Governance.CreatePoll where import Control.Monad (void) @@ -13,13 +13,13 @@ import qualified Hedgehog.Extras.Test.File as H {- HLINT ignore "Use camelCase" -} -hprop_golden_shelleyGovernanceCreatePoll :: Property -hprop_golden_shelleyGovernanceCreatePoll = +hprop_golden_governanceCreatePoll :: Property +hprop_golden_governanceCreatePoll = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do pollFile <- noteTempFile tempDir "poll.json" stdout <- execCardanoCLI - [ "legacy", "governance", "create-poll" + [ "babbage", "governance", "create-poll" , "--question", "Pineapples on pizza?" , "--answer", "yes" , "--answer", "no" @@ -27,19 +27,19 @@ hprop_golden_shelleyGovernanceCreatePoll = ] void $ H.readFile pollFile - noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/create/basic.json" + noteInputFile "test/cardano-cli-golden/files/input/governance/create/basic.json" >>= H.readFile >>= (H.===) stdout H.assertFileOccurences 1 "GovernancePoll" pollFile H.assertEndsWithSingleNewline pollFile -hprop_golden_shelleyGovernanceCreateLongPoll :: Property -hprop_golden_shelleyGovernanceCreateLongPoll = +hprop_golden_governanceCreateLongPoll :: Property +hprop_golden_governanceCreateLongPoll = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do pollFile <- noteTempFile tempDir "poll.json" stdout <- execCardanoCLI - [ "legacy", "governance", "create-poll" + [ "babbage", "governance", "create-poll" , "--question", "What is the most adequate topping to put on a pizza (please consider all possibilities and take time to answer)?" , "--answer", "pineapples" , "--answer", "only traditional topics should go on a pizza, this isn't room for jokes" @@ -47,7 +47,7 @@ hprop_golden_shelleyGovernanceCreateLongPoll = ] void $ H.readFile pollFile - noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/create/long-text.json" + noteInputFile "test/cardano-cli-golden/files/input/governance/create/long-text.json" >>= H.readFile >>= (H.===) stdout H.assertFileOccurences 1 "GovernancePoll" pollFile diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs new file mode 100644 index 0000000000..c3be9464d9 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs @@ -0,0 +1,93 @@ +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE OverloadedStrings #-} + +module Test.Golden.EraBased.Governance.VerifyPoll where + +import Cardano.Api + +import Cardano.CLI.Types.Key (VerificationKeyOrFile (..), + readVerificationKeyOrTextEnvFile) + +import Control.Monad.IO.Class (liftIO) +import qualified Data.ByteString.Char8 as BSC + +import Test.Cardano.CLI.Util + +import Hedgehog (Property) +import qualified Hedgehog as H +import qualified Hedgehog.Internal.Property as H +import qualified Hedgehog.Extras as H + +{- HLINT ignore "Use camelCase" -} + +hprop_golden_governanceVerifyPoll :: Property +hprop_golden_governanceVerifyPoll = propertyOnce $ do + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/verify/valid" + goldenVkFile <- VerificationKeyFilePath . File <$> + H.note "test/cardano-cli-golden/files/golden/governance/cold.vk" + + stdout <- BSC.pack <$> execCardanoCLI + [ "babbage", "governance", "verify-poll" + , "--poll-file", pollFile + , "--tx-file", txFile + ] + + liftIO (readVerificationKeyOrTextEnvFile AsStakePoolKey goldenVkFile) >>= \case + Left e -> + H.failWith Nothing (displayError e) + Right vk -> do + let expected = prettyPrintJSON $ serialiseToRawBytesHexText <$> [verificationKeyHash vk] + H.assert $ expected `BSC.isInfixOf` stdout + +hprop_golden_governanceVerifyPollMismatch :: Property +hprop_golden_governanceVerifyPollMismatch = propertyOnce $ do + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/verify/mismatch" + + result <- tryExecCardanoCLI + [ "babbage", "governance", "verify-poll" + , "--poll-file", pollFile + , "--tx-file", txFile + ] + + either (const H.success) (H.failWith Nothing) result + +hprop_golden_governanceVerifyPollNoAnswer :: Property +hprop_golden_governanceVerifyPollNoAnswer = propertyOnce $ do + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/verify/none" + + result <- tryExecCardanoCLI + [ "babbage", "governance", "verify-poll" + , "--poll-file", pollFile + , "--tx-file", txFile + ] + + either (const H.success) (H.failWith Nothing) result + +hprop_golden_governanceVerifyPollMalformedAnswer :: Property +hprop_golden_governanceVerifyPollMalformedAnswer = propertyOnce $ do + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/verify/malformed" + + result <- tryExecCardanoCLI + [ "babbage", "governance", "verify-poll" + , "--poll-file", pollFile + , "--tx-file", txFile + ] + + either (const H.success) (H.failWith Nothing) result + +hprop_golden_governanceVerifyPollInvalidAnswer :: Property +hprop_golden_governanceVerifyPollInvalidAnswer = propertyOnce $ do + pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json" + txFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/verify/invalid" + + result <- tryExecCardanoCLI + [ "babbage", "governance", "verify-poll" + , "--poll-file", pollFile + , "--tx-file", txFile + ] + + either (const H.success) (H.failWith Nothing) result diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Key/NonExtendedKey.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Key/NonExtendedKey.hs index 2a3b14c753..05b30767f8 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Key/NonExtendedKey.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Key/NonExtendedKey.hs @@ -5,6 +5,7 @@ module Test.Golden.Key.NonExtendedKey where import Control.Monad (void) import System.FilePath (()) +import qualified Test.Cardano.CLI.Util as H import Test.Cardano.CLI.Util (execCardanoCLI, propertyOnce) import Hedgehog (Property) @@ -19,7 +20,7 @@ import qualified Hedgehog.Extras.Test.Golden as H hprop_golden_KeyNonExtendedKey_GenesisExtendedVerificationKey :: Property hprop_golden_KeyNonExtendedKey_GenesisExtendedVerificationKey = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do - genesisVKeyFp <- H.note "test/cardano-cli-golden/files/golden/key/non-extended-keys/shelley.000.vkey" + genesisVKeyFp <- H.noteInputFile "test/cardano-cli-golden/files/input/key/non-extended-keys/shelley.000.vkey" nonExtendedFp <- H.note "test/cardano-cli-golden/files/golden/key/non-extended-keys/non-extended-shelley.000.vkey" outFp <- H.note $ tempDir "non-extended-shelley.000.vkey" @@ -42,7 +43,7 @@ hprop_golden_KeyNonExtendedKey_GenesisExtendedVerificationKey = hprop_golden_KeyNonExtendedKey_StakeExtendedVerificationKeyShelley :: Property hprop_golden_KeyNonExtendedKey_StakeExtendedVerificationKeyShelley = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do - genesisVKeyFp <- H.note "test/cardano-cli-golden/files/golden/key/non-extended-keys/stake.000.vkey" + genesisVKeyFp <- H.noteInputFile "test/cardano-cli-golden/files/input/key/non-extended-keys/stake.000.vkey" nonExtendedFp <- H.note "test/cardano-cli-golden/files/golden/key/non-extended-keys/non-extended-stake.000.vkey" outFp <- H.note $ tempDir "non-extended-stake.000.vkey" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Address/Build.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Address/Build.hs index 6a581fef77..7c36f20adc 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Address/Build.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Address/Build.hs @@ -14,10 +14,10 @@ import qualified Hedgehog.Extras.Test.File as H hprop_golden_shelleyAddressBuild :: Property hprop_golden_shelleyAddressBuild = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do - addressVKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/payment_keys/verification_key" - addressSKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/verification_key" - goldenStakingAddressHexFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/addresses/staking-address.hex" - goldenEnterpriseAddressHexFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/addresses/enterprise-address.hex" + addressVKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/payment_keys/verification_key" + addressSKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/stake_keys/verification_key" + goldenStakingAddressHexFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/addresses/staking-address.hex" + goldenEnterpriseAddressHexFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/addresses/enterprise-address.hex" stakingAddressHexFile <- noteTempFile tempDir "staking-address.hex" enterpriseAddressHexFile <- noteTempFile tempDir "enterprise-address.hex" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/Create.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/Create.hs index edb7c7fdb9..183e342fef 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/Create.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/Create.hs @@ -68,9 +68,9 @@ parseTotalSupply = J.withObject "Object" $ \ o -> do hprop_golden_shelleyGenesisCreate :: Property hprop_golden_shelleyGenesisCreate = propertyOnce $ do H.moduleWorkspace "tmp" $ \tempDir -> do - sourceGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/genesis/genesis.spec.json" - sourceAlonzoGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/golden/alonzo/genesis.alonzo.spec.json" - sourceConwayGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/golden/conway/genesis.conway.spec.json" + sourceGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/genesis/genesis.spec.json" + sourceAlonzoGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/input/alonzo/genesis.alonzo.spec.json" + sourceConwayGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/input/conway/genesis.conway.spec.json" genesisSpecFile <- noteTempFile tempDir "genesis.spec.json" alonzoSpecFile <- noteTempFile tempDir "genesis.alonzo.spec.json" @@ -160,11 +160,11 @@ hprop_golden_shelleyGenesisCreate = propertyOnce $ do (delegateCount, fmtDelegateCount) <- fmap (OP.withSnd show) $ forAll $ G.int (R.linear 4 19) (utxoCount, fmtUtxoCount) <- fmap (OP.withSnd show) $ forAll $ G.int (R.linear 4 19) - sourceAlonzoGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/golden/alonzo/genesis.alonzo.spec.json" + sourceAlonzoGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/input/alonzo/genesis.alonzo.spec.json" alonzoSpecFile <- noteTempFile tempDir "genesis.alonzo.spec.json" H.copyFile sourceAlonzoGenesisSpecFile alonzoSpecFile - sourceConwayGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/golden/conway/genesis.conway.spec.json" + sourceConwayGenesisSpecFile <- noteInputFile "test/cardano-cli-golden/files/input/conway/genesis.conway.spec.json" conwaySpecFile <- noteTempFile tempDir "genesis.conway.spec.json" H.copyFile sourceConwayGenesisSpecFile conwaySpecFile diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/InitialTxIn.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/InitialTxIn.hs index b5f0bfff25..316d7f8726 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/InitialTxIn.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/InitialTxIn.hs @@ -5,25 +5,18 @@ module Test.Golden.Shelley.Genesis.InitialTxIn where import Test.Cardano.CLI.Util import Hedgehog (Property) -import qualified Hedgehog.Extras.Test.Base as H -import qualified Hedgehog.Extras.Test.File as H +import qualified Hedgehog.Extras.Test.Golden as H {- HLINT ignore "Use camelCase" -} hprop_golden_shelleyGenesisInitialTxIn :: Property -hprop_golden_shelleyGenesisInitialTxIn = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do - verificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/genesis_verification_keys/genesis-utxo.vkey" +hprop_golden_shelleyGenesisInitialTxIn = propertyOnce $ do + verificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/genesis_verification_keys/genesis-utxo.vkey" goldenUtxoHashFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/genesis_utxo_hashes/utxo_hash" - utxoHashFile <- noteTempFile tempDir "utxo_hash" - utxoHash <- execCardanoCLI [ "genesis","initial-txin" , "--testnet-magic", "16" , "--verification-key-file", verificationKeyFile ] - H.writeFile utxoHashFile utxoHash - - goldenUtxoHash <- H.readFile goldenUtxoHashFile - - equivalence utxoHash goldenUtxoHash + H.diffVsGoldenFile utxoHash goldenUtxoHashFile diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/KeyHash.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/KeyHash.hs index bb2cf4d3ba..31cb5d12a9 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/KeyHash.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Genesis/KeyHash.hs @@ -12,8 +12,8 @@ import qualified Hedgehog.Extras.Test.File as H hprop_golden_shelleyGenesisKeyHash :: Property hprop_golden_shelleyGenesisKeyHash = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do - referenceVerificationKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/genesis_keys/verification_key" - goldenGenesisVerificationKeyHashFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/genesis_keys/verification_key.key-hash" + referenceVerificationKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/genesis_keys/verification_key" + goldenGenesisVerificationKeyHashFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/genesis_keys/verification_key.key-hash" genesisVerificationKeyHashFile <- noteTempFile tempDir "key-hash.hex" genesisVerificationKeyHash <- execCardanoCLI diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/AnswerPoll.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/AnswerPoll.hs deleted file mode 100644 index fcf4658534..0000000000 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/AnswerPoll.hs +++ /dev/null @@ -1,77 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - -module Test.Golden.Shelley.Governance.AnswerPoll where - -import Control.Monad (void) - -import Test.Cardano.CLI.Util - -import Hedgehog (Property) -import qualified Hedgehog as H -import qualified Hedgehog.Extras.Test.Base as H -import qualified Hedgehog.Extras.Test.File as H -import qualified Hedgehog.Extras.Test.Golden as H - -{- HLINT ignore "Use camelCase" -} - -hprop_golden_shelleyGovernanceAnswerPollNeg1Invalid :: Property -hprop_golden_shelleyGovernanceAnswerPollNeg1Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" - outFile <- H.noteTempFile tempDir "answer-file.json" - - result <- tryExecCardanoCLI - [ "legacy", "governance", "answer-poll" - , "--poll-file", pollFile - , "--answer", "-1" - , "--out-file", outFile - ] - - H.assertFileMissing outFile - - either (const H.success) (const H.failure) result - -hprop_golden_shelleyGovernanceAnswerPoll0 :: Property -hprop_golden_shelleyGovernanceAnswerPoll0 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" - expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.answer.0.json" - outFile <- H.noteTempFile tempDir "answer-file.json" - - void $ execCardanoCLI - [ "legacy", "governance", "answer-poll" - , "--poll-file", pollFile - , "--answer", "0" - , "--out-file", outFile - ] - - H.diffFileVsGoldenFile outFile expectedAnswerFile - -hprop_golden_shelleyGovernanceAnswerPollPos1 :: Property -hprop_golden_shelleyGovernanceAnswerPollPos1 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" - expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.answer.1.json" - outFile <- H.noteTempFile tempDir "answer-file.json" - - void $ execCardanoCLI - [ "legacy", "governance", "answer-poll" - , "--poll-file", pollFile - , "--answer", "1" - , "--out-file", outFile - ] - - H.diffFileVsGoldenFile outFile expectedAnswerFile - -hprop_golden_shelleyGovernanceAnswerPollPos2Invalid :: Property -hprop_golden_shelleyGovernanceAnswerPollPos2Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" - outFile <- H.noteTempFile tempDir "answer-file.json" - - result <- tryExecCardanoCLI - [ "legacy", "governance", "answer-poll" - , "--poll-file", pollFile - , "--answer", "2" - , "--out-file", outFile - ] - - H.assertFileMissing outFile - - either (const H.success) (const H.failure) result diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/VerifyPoll.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/VerifyPoll.hs deleted file mode 100644 index 488a7e9564..0000000000 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Governance/VerifyPoll.hs +++ /dev/null @@ -1,92 +0,0 @@ -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE OverloadedStrings #-} - -module Test.Golden.Shelley.Governance.VerifyPoll where - -import Cardano.Api - -import Cardano.CLI.Types.Key (VerificationKeyOrFile (..), - readVerificationKeyOrTextEnvFile) - -import Control.Monad.IO.Class (liftIO) -import qualified Data.ByteString.Char8 as BSC - -import Test.Cardano.CLI.Util - -import Hedgehog (Property) -import qualified Hedgehog as H -import qualified Hedgehog.Internal.Property as H - -{- HLINT ignore "Use camelCase" -} - -hprop_golden_shelleyGovernanceVerifyPoll :: Property -hprop_golden_shelleyGovernanceVerifyPoll = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/verify/valid" - vkFile <- VerificationKeyFilePath . File <$> - noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/cold.vk" - - stdout <- BSC.pack <$> execCardanoCLI - [ "legacy", "governance", "verify-poll" - , "--poll-file", pollFile - , "--tx-file", txFile - ] - - liftIO (readVerificationKeyOrTextEnvFile AsStakePoolKey vkFile) >>= \case - Left e -> - H.failWith Nothing (displayError e) - Right vk -> do - let expected = prettyPrintJSON $ serialiseToRawBytesHexText <$> [verificationKeyHash vk] - H.assert $ expected `BSC.isInfixOf` stdout - -hprop_golden_shelleyGovernanceVerifyPollMismatch :: Property -hprop_golden_shelleyGovernanceVerifyPollMismatch = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/verify/mismatch" - - result <- tryExecCardanoCLI - [ "legacy", "governance", "verify-poll" - , "--poll-file", pollFile - , "--tx-file", txFile - ] - - either (const H.success) (H.failWith Nothing) result - -hprop_golden_shelleyGovernanceVerifyPollNoAnswer :: Property -hprop_golden_shelleyGovernanceVerifyPollNoAnswer = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/verify/none" - - result <- tryExecCardanoCLI - [ "legacy", "governance", "verify-poll" - , "--poll-file", pollFile - , "--tx-file", txFile - ] - - either (const H.success) (H.failWith Nothing) result - -hprop_golden_shelleyGovernanceVerifyPollMalformedAnswer :: Property -hprop_golden_shelleyGovernanceVerifyPollMalformedAnswer = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/verify/malformed" - - result <- tryExecCardanoCLI - [ "legacy", "governance", "verify-poll" - , "--poll-file", pollFile - , "--tx-file", txFile - ] - - either (const H.success) (H.failWith Nothing) result - -hprop_golden_shelleyGovernanceVerifyPollInvalidAnswer :: Property -hprop_golden_shelleyGovernanceVerifyPollInvalidAnswer = propertyOnce $ do - pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json" - txFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/verify/invalid" - - result <- tryExecCardanoCLI - [ "legacy", "governance", "verify-poll" - , "--poll-file", pollFile - , "--tx-file", txFile - ] - - either (const H.success) (H.failWith Nothing) result diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Key/ConvertCardanoAddressKey.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Key/ConvertCardanoAddressKey.hs index e0ed82818b..b36682fed3 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Key/ConvertCardanoAddressKey.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Key/ConvertCardanoAddressKey.hs @@ -7,9 +7,10 @@ import Data.Text (Text) import Test.Cardano.CLI.Util -import Hedgehog (Property, (===)) +import Hedgehog (Property) import qualified Hedgehog.Extras.Test.Base as H import qualified Hedgehog.Extras.Test.File as H +import qualified Hedgehog.Extras.Test.Golden as H {- HLINT ignore "Use camelCase" -} @@ -67,12 +68,8 @@ hprop_golden_convertCardanoAddressByronSigningKey = -- Check that the contents of the converted signing key file match that of -- the golden file. - actualConvertedSigningKey <- H.readFile convertedSigningKeyFp - expectedConvertedSigningKey <- - H.readFile $ - "test/cardano-cli-golden/files/golden/shelley/keys/converted_cardano-address_keys/" - <> "byron_signing_key" - expectedConvertedSigningKey === actualConvertedSigningKey + H.diffFileVsGoldenFile convertedSigningKeyFp + "test/cardano-cli-golden/files/golden/shelley/keys/converted_cardano-address_keys/byron_signing_key" -- | Test that converting a @cardano-address@ Icarus signing key yields the -- expected result. @@ -104,12 +101,8 @@ hprop_golden_convertCardanoAddressIcarusSigningKey = -- Check that the contents of the converted signing key file match that of -- the golden file. - actualConvertedSigningKey <- H.readFile convertedSigningKeyFp - expectedConvertedSigningKey <- - H.readFile $ - "test/cardano-cli-golden/files/golden/shelley/keys/converted_cardano-address_keys/" - <> "icarus_signing_key" - expectedConvertedSigningKey === actualConvertedSigningKey + H.diffFileVsGoldenFile convertedSigningKeyFp + "test/cardano-cli-golden/files/golden/shelley/keys/converted_cardano-address_keys/icarus_signing_key" -- | Test that converting a @cardano-address@ Shelley payment signing key -- yields the expected result. @@ -142,12 +135,8 @@ hprop_golden_convertCardanoAddressShelleyPaymentSigningKey = -- Check that the contents of the converted signing key file match that of -- the golden file. - actualConvertedSigningKey <- H.readFile convertedSigningKeyFp - expectedConvertedSigningKey <- - H.readFile $ - "test/cardano-cli-golden/files/golden/shelley/keys/converted_cardano-address_keys/" - <> "shelley_payment_signing_key" - expectedConvertedSigningKey === actualConvertedSigningKey + H.diffFileVsGoldenFile convertedSigningKeyFp + "test/cardano-cli-golden/files/golden/shelley/keys/converted_cardano-address_keys/shelley_payment_signing_key" -- | Test that converting a @cardano-address@ Shelley stake signing key yields -- the expected result. @@ -180,9 +169,5 @@ hprop_golden_convertCardanoAddressShelleyStakeSigningKey = -- Check that the contents of the converted signing key file match that of -- the golden file. - actualConvertedSigningKey <- H.readFile convertedSigningKeyFp - expectedConvertedSigningKey <- - H.readFile $ - "test/cardano-cli-golden/files/golden/shelley/keys/converted_cardano-address_keys/" - <> "shelley_stake_signing_key" - expectedConvertedSigningKey === actualConvertedSigningKey + H.diffFileVsGoldenFile convertedSigningKeyFp + "test/cardano-cli-golden/files/golden/shelley/keys/converted_cardano-address_keys/shelley_stake_signing_key" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Metadata/StakePoolMetadata.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Metadata/StakePoolMetadata.hs index 417481ebbd..ea90dbb66d 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Metadata/StakePoolMetadata.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Metadata/StakePoolMetadata.hs @@ -17,7 +17,7 @@ import qualified Hedgehog.Extras.Test.File as H hprop_golden_stakePoolMetadataHash :: Property hprop_golden_stakePoolMetadataHash = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do - referenceStakePoolMetadata <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/metadata/stake_pool_metadata_hash" + referenceStakePoolMetadata <- noteInputFile "test/cardano-cli-golden/files/input/shelley/metadata/stake_pool_metadata_hash" stakePoolMetadataFile <- noteTempFile tempDir "stake-pool-metadata.json" outputStakePoolMetadataHashFp <- noteTempFile tempDir "stake-pool-metadata-hash.txt" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/MultiSig/Address.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/MultiSig/Address.hs index c50f222902..dda7b39117 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/MultiSig/Address.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/MultiSig/Address.hs @@ -7,12 +7,13 @@ import Test.Cardano.CLI.Util as OP import Hedgehog (Property) import qualified Hedgehog.Extras.Test.Base as H import qualified Hedgehog.Extras.Test.File as H +import qualified Hedgehog.Extras.Test.Golden as H {- HLINT ignore "Use camelCase" -} hprop_golden_shelleyAllMultiSigAddressBuild :: Property hprop_golden_shelleyAllMultiSigAddressBuild = propertyOnce . H.moduleWorkspace "tmp" $ \_ -> do - allMultiSigFp <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/multisig/scripts/all" + allMultiSigFp <- noteInputFile "test/cardano-cli-golden/files/input/shelley/multisig/scripts/all" allMultiSigAddress <- execCardanoCLI [ "address", "build" @@ -20,7 +21,7 @@ hprop_golden_shelleyAllMultiSigAddressBuild = propertyOnce . H.moduleWorkspace " , "--mainnet" ] - goldenAllMultiSigAddrFp <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/multisig/addresses/all" + goldenAllMultiSigAddrFp <- noteInputFile "test/cardano-cli-golden/files/input/shelley/multisig/addresses/all" goldenAllMs <- H.readFile goldenAllMultiSigAddrFp @@ -28,7 +29,7 @@ hprop_golden_shelleyAllMultiSigAddressBuild = propertyOnce . H.moduleWorkspace " hprop_golden_shelleyAnyMultiSigAddressBuild :: Property hprop_golden_shelleyAnyMultiSigAddressBuild = propertyOnce . H.moduleWorkspace "tmp" $ \_ -> do - anyMultiSigFp <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/multisig/scripts/any" + anyMultiSigFp <- noteInputFile "test/cardano-cli-golden/files/input/shelley/multisig/scripts/any" anyMultiSigAddress <- execCardanoCLI [ "address", "build" @@ -36,7 +37,7 @@ hprop_golden_shelleyAnyMultiSigAddressBuild = propertyOnce . H.moduleWorkspace " , "--mainnet" ] - goldenAnyMultiSigAddrFp <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/multisig/addresses/any" + goldenAnyMultiSigAddrFp <- noteInputFile "test/cardano-cli-golden/files/input/shelley/multisig/addresses/any" goldenAnyMs <- H.readFile goldenAnyMultiSigAddrFp @@ -44,7 +45,7 @@ hprop_golden_shelleyAnyMultiSigAddressBuild = propertyOnce . H.moduleWorkspace " hprop_golden_shelleyAtLeastMultiSigAddressBuild :: Property hprop_golden_shelleyAtLeastMultiSigAddressBuild = propertyOnce . H.moduleWorkspace "tmp" $ \_ -> do - atLeastMultiSigFp <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/multisig/scripts/atleast" + atLeastMultiSigFp <- noteInputFile "test/cardano-cli-golden/files/input/shelley/multisig/scripts/atleast" atLeastMultiSigAddress <- execCardanoCLI [ "address", "build" @@ -52,8 +53,6 @@ hprop_golden_shelleyAtLeastMultiSigAddressBuild = propertyOnce . H.moduleWorkspa , "--mainnet" ] - goldenAtLeastMultiSigAddrFp <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/multisig/addresses/atleast" + goldenAtLeastMultiSigAddrFp <- H.note "test/cardano-cli-golden/files/golden/shelley/multisig/addresses/atleast" - goldenAtLeastMs <- H.readFile goldenAtLeastMultiSigAddrFp - - equivalence atLeastMultiSigAddress goldenAtLeastMs + H.diffVsGoldenFile atLeastMultiSigAddress goldenAtLeastMultiSigAddrFp diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Node/IssueOpCert.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Node/IssueOpCert.hs index 81db1680ef..faadd0e372 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Node/IssueOpCert.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Node/IssueOpCert.hs @@ -14,9 +14,9 @@ import qualified Hedgehog.Extras.Test.File as H hprop_golden_shelleyNodeIssueOpCert :: Property hprop_golden_shelleyNodeIssueOpCert = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do - hotKesVerificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/kes_keys/verification_key" - coldSigningKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/genesis_delegate_keys/signing_key" - originalOperationalCertificateIssueCounterFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/genesis_delegate_keys/operational_certificate_counter" + hotKesVerificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/kes_keys/verification_key" + coldSigningKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/genesis_delegate_keys/signing_key" + originalOperationalCertificateIssueCounterFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/genesis_delegate_keys/operational_certificate_counter" operationalCertificateIssueCounterFile <- noteTempFile tempDir "delegate-op-cert.counter" operationalCertFile <- noteTempFile tempDir "operational.cert" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/StakeAddress/Build.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/StakeAddress/Build.hs index 7f853cd5a4..6babfa43d7 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/StakeAddress/Build.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/StakeAddress/Build.hs @@ -12,8 +12,8 @@ import qualified Hedgehog.Extras.Test.File as H hprop_golden_shelleyStakeAddressBuild :: Property hprop_golden_shelleyStakeAddressBuild = propertyOnce . H.moduleWorkspace "tmp" $ \_ -> do - verificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/verification_key" - goldenRewardAddressFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/reward_address" + verificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/stake_keys/verification_key" + goldenRewardAddressFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/stake_keys/reward_address" rewardAddress <- execCardanoCLI [ "stake-address","build" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/StakeAddress/DeregistrationCertificate.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/StakeAddress/DeregistrationCertificate.hs index f9e4772b2d..1196bbc34c 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/StakeAddress/DeregistrationCertificate.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/StakeAddress/DeregistrationCertificate.hs @@ -18,7 +18,7 @@ hprop_golden_shelleyStakeAddressDeregistrationCertificate :: Property hprop_golden_shelleyStakeAddressDeregistrationCertificate = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do base <- H.getProjectBase - verificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/verification_key" + verificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/stake_keys/verification_key" deregistrationCertFile <- noteTempFile tempDir "deregistrationCertFile" scriptDeregistrationCertFile <- noteTempFile tempDir "scripDeregistrationCertFile" exampleScript <- noteInputFile $ base "scripts/plutus/scripts/v1/custom-guess-42-datum-42.plutus" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/StakeAddress/RegistrationCertificate.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/StakeAddress/RegistrationCertificate.hs index 749c8681a1..03f93799c5 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/StakeAddress/RegistrationCertificate.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/StakeAddress/RegistrationCertificate.hs @@ -18,7 +18,7 @@ hprop_golden_shelleyStakeAddressRegistrationCertificate :: Property hprop_golden_shelleyStakeAddressRegistrationCertificate = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do base <- H.getProjectBase - keyGenStakingVerificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/verification_key" + keyGenStakingVerificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/stake_keys/verification_key" registrationCertFile <- noteTempFile tempDir "registration.cert" scriptRegistrationCertFile <- noteTempFile tempDir "script-registration.cert" exampleScript <- noteInputFile $ base "scripts/plutus/scripts/v1/custom-guess-42-datum-42.plutus" @@ -43,7 +43,7 @@ hprop_golden_shelleyStakeAddressRegistrationCertificate = propertyOnce . H.modul hprop_golden_shelleyStakeAddressRegistrationCertificateWithBuildRaw :: Property hprop_golden_shelleyStakeAddressRegistrationCertificateWithBuildRaw = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do - keyGenStakingVerificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/verification_key" + keyGenStakingVerificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/stake_keys/verification_key" registrationCertFile <- noteTempFile tempDir "registration.cert" txRawFile <- noteTempFile tempDir "tx.raw" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/StakePool/RegistrationCertificate.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/StakePool/RegistrationCertificate.hs index b8c4053235..198977dbf3 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/StakePool/RegistrationCertificate.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/StakePool/RegistrationCertificate.hs @@ -14,9 +14,9 @@ import qualified Hedgehog.Extras.Test.File as H hprop_golden_shelleyStakePoolRegistrationCertificate :: Property hprop_golden_shelleyStakePoolRegistrationCertificate = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do - operatorVerificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/node-pool/operator.vkey" - vrfVerificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/node-pool/vrf.vkey" - ownerVerificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/node-pool/owner.vkey" + operatorVerificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/node-pool/operator.vkey" + vrfVerificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/node-pool/vrf.vkey" + ownerVerificationKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/node-pool/owner.vkey" registrationCertFile <- noteTempFile tempDir "registration.cert" void $ execCardanoCLI diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegation.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegation.hs index 4921794f3e..bf64985644 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegation.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegation.hs @@ -23,7 +23,7 @@ hprop_golden_shelleyGenesisKeyDelegationCertificate = -- Reference certificate referenceCertificateFilePath <- noteInputFile $ - "test/cardano-cli-golden/files/golden/shelley/certificates/" + "test/cardano-cli-golden/files/input/shelley/certificates/" <> "genesis_key_delegation_certificate" -- Verification key and certificate filepaths diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/MIR.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/MIR.hs index e7462cf189..37a05d37b6 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/MIR.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/MIR.hs @@ -22,7 +22,7 @@ hprop_golden_shelleyMIRCertificate = propertyOnce . H.moduleWorkspace "tmp" $ \t let era = BabbageEra -- Reference keys - referenceMIRCertificate <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/certificates/mir_certificate" + referenceMIRCertificate <- noteInputFile "test/cardano-cli-golden/files/input/shelley/certificates/mir_certificate" -- Key filepaths verKey <- noteTempFile tempDir "stake-verification-key-file" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/Operational.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/Operational.hs index 7bfdd8504b..889de72520 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/Operational.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/Operational.hs @@ -21,7 +21,7 @@ import qualified Hedgehog.Extras.Test.File as H hprop_golden_shelleyOperationalCertificate :: Property hprop_golden_shelleyOperationalCertificate = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do -- Reference keys - referenceOperationalCertificate <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/certificates/operational_certificate" + referenceOperationalCertificate <- noteInputFile "test/cardano-cli-golden/files/input/shelley/certificates/operational_certificate" -- Key filepaths kesVerKey <- noteTempFile tempDir "KES-verification-key-file" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/StakeAddress.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/StakeAddress.hs index b15ae89e78..0d728bae01 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/StakeAddress.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/StakeAddress.hs @@ -22,8 +22,10 @@ hprop_golden_shelleyStakeAddressCertificates = propertyOnce . H.moduleWorkspace let era = BabbageEra -- Reference files - referenceRegistrationCertificate <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/certificates/stake_address_registration_certificate" - referenceDeregistrationCertificate <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/certificates/stake_address_deregistration_certificate" + referenceRegistrationCertificate <- noteInputFile "test/cardano-cli-golden/files/input/shelley/certificates/stake_address_registration_certificate" + referenceDeregistrationCertificate <- noteInputFile "test/cardano-cli-golden/files/input/shelley/certificates/stake_address_deregistration_certificate" + referenceDelegationCertificate <- noteInputFile "test/cardano-cli-golden/files/input/shelley/certificates/stake_address_delegation_certificate" + operatorVkey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/node-pool/operator.vkey" -- Key filepaths verKey <- noteTempFile tempDir "stake-verification-key-file" @@ -64,17 +66,14 @@ hprop_golden_shelleyStakeAddressCertificates = propertyOnce . H.moduleWorkspace -- golden files checkTextEnvelopeFormat registrationCertificateType referenceDeregistrationCertificate deregistrationCertificate --- TODO: After delegation-certificate command is fixed to take a hash instead of a verification key -{- -- Create stake address delegation certificate void $ execCardanoCLI [ "stake-address", "delegation-certificate" , "--stake-verification-key-file", verKey - , "--cold-verification-key-file", verKey --TODO: Should be stake pool's hash + , "--cold-verification-key-file", operatorVkey , "--out-file", deregistrationCertificate ] -- Check the newly created files have not deviated from the -- golden files - checkTextEnvelopeFormat registrationCertificateType referenceDeregistrationCertificate deregistrationCertificate --} + checkTextEnvelopeFormat registrationCertificateType referenceDelegationCertificate deregistrationCertificate diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/StakePool.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/StakePool.hs index 21a449c323..0e2e6b0945 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/StakePool.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Certificates/StakePool.hs @@ -26,8 +26,8 @@ hprop_golden_shelleyStakePoolCertificates = propertyOnce . H.moduleWorkspace "tm let era = BabbageEra -- TODO generate for all eras -- Reference files - referenceRegistrationCertificate <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/certificates/stake_pool_registration_certificate" - referenceDeregistrationCertificate <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/certificates/stake_pool_deregistration_certificate" + referenceRegistrationCertificate <- noteInputFile "test/cardano-cli-golden/files/input/shelley/certificates/stake_pool_registration_certificate" + referenceDeregistrationCertificate <- noteInputFile "test/cardano-cli-golden/files/input/shelley/certificates/stake_pool_deregistration_certificate" -- Key filepaths coldVerKey <- noteTempFile tempDir "cold-verification-key-file" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/ExtendedPaymentKeys.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/ExtendedPaymentKeys.hs index 18af05230b..2630d07d47 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/ExtendedPaymentKeys.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/ExtendedPaymentKeys.hs @@ -23,8 +23,8 @@ import qualified Hedgehog.Extras.Test.File as H hprop_golden_shelleyExtendedPaymentKeys :: Property hprop_golden_shelleyExtendedPaymentKeys = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do -- Reference keys - referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/extended_payment_keys/verification_key" - referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/extended_payment_keys/signing_key" + referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/extended_payment_keys/verification_key" + referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/extended_payment_keys/signing_key" -- Key filepaths verKey <- noteTempFile tempDir "extended-payment-verification-key-file" @@ -52,8 +52,8 @@ hprop_golden_shelleyExtendedPaymentKeys = propertyOnce . H.moduleWorkspace "tmp" hprop_golden_shelleyExtendedPaymentKeys_te :: Property hprop_golden_shelleyExtendedPaymentKeys_te = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do -- Reference keys - referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/extended_payment_keys/verification_key" - referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/extended_payment_keys/signing_key" + referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/extended_payment_keys/verification_key" + referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/extended_payment_keys/signing_key" -- Key filepaths verKey <- noteTempFile tempDir "extended-payment-verification-key-file" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/GenesisDelegateKeys.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/GenesisDelegateKeys.hs index 97073b1544..816b7222ef 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/GenesisDelegateKeys.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/GenesisDelegateKeys.hs @@ -19,9 +19,9 @@ import qualified Hedgehog.Extras.Test.Base as H hprop_golden_shelleyGenesisDelegateKeys :: Property hprop_golden_shelleyGenesisDelegateKeys = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do -- Reference keys - referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/genesis_delegate_keys/verification_key" - referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/genesis_delegate_keys/signing_key" - referenceOpCertCounter <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/genesis_delegate_keys/operational_certificate_counter" + referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/genesis_delegate_keys/verification_key" + referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/genesis_delegate_keys/signing_key" + referenceOpCertCounter <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/genesis_delegate_keys/operational_certificate_counter" -- Key filepaths verKey <- noteTempFile tempDir "genesis-delegate-verification-key-file" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/GenesisKeys.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/GenesisKeys.hs index d1a903ad69..819e77356c 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/GenesisKeys.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/GenesisKeys.hs @@ -19,8 +19,8 @@ import qualified Hedgehog.Extras.Test.Base as H hprop_golden_shelleyGenesisKeys :: Property hprop_golden_shelleyGenesisKeys = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do -- Reference keys - referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/genesis_keys/verification_key" - referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/genesis_keys/signing_key" + referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/genesis_keys/verification_key" + referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/genesis_keys/signing_key" -- Key filepaths verKey <- noteTempFile tempDir "genesis-verification-key-file" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/GenesisUTxOKeys.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/GenesisUTxOKeys.hs index 9d5d389036..ba1fea089a 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/GenesisUTxOKeys.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/GenesisUTxOKeys.hs @@ -19,8 +19,8 @@ import qualified Hedgehog.Extras.Test.Base as H hprop_golden_shelleyGenesisUTxOKeys :: Property hprop_golden_shelleyGenesisUTxOKeys = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do -- Reference keys - referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/genesis_utxo_keys/verification_key" - referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/genesis_utxo_keys/signing_key" + referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/genesis_utxo_keys/verification_key" + referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/genesis_utxo_keys/signing_key" -- Key filepaths verKey <- noteTempFile tempDir "genesis-utxo-verification-key-file" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/KESKeys.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/KESKeys.hs index 12f875b20d..c1ba9d855d 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/KESKeys.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/KESKeys.hs @@ -23,8 +23,8 @@ import qualified Hedgehog.Extras.Test.File as H hprop_golden_shelleyKESKeys :: Property hprop_golden_shelleyKESKeys = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do -- Reference keys - referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/kes_keys/verification_key" - referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/kes_keys/signing_key" + referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/kes_keys/verification_key" + referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/kes_keys/signing_key" -- Key filepaths verKey <- noteTempFile tempDir "kes-verification-key-file" @@ -51,8 +51,8 @@ hprop_golden_shelleyKESKeys = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir hprop_golden_shelleyKESKeys_te :: Property hprop_golden_shelleyKESKeys_te = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do -- Reference keys - referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/kes_keys/verification_key" - referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/kes_keys/signing_key" + referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/kes_keys/verification_key" + referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/kes_keys/signing_key" -- Key filepaths verKey <- noteTempFile tempDir "kes-verification-key-file" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/PaymentKeys.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/PaymentKeys.hs index 320de4a478..4912e9ec33 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/PaymentKeys.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/PaymentKeys.hs @@ -23,8 +23,8 @@ import qualified Hedgehog.Extras.Test.File as H hprop_golden_shelleyPaymentKeys :: Property hprop_golden_shelleyPaymentKeys = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do -- Reference keys - referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/payment_keys/verification_key" - referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/payment_keys/signing_key" + referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/payment_keys/verification_key" + referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/payment_keys/signing_key" -- Key filepaths verKey <- noteTempFile tempDir "payment-verification-key-file" @@ -51,8 +51,8 @@ hprop_golden_shelleyPaymentKeys = propertyOnce . H.moduleWorkspace "tmp" $ \temp hprop_golden_shelleyPaymentKeys_te :: Property hprop_golden_shelleyPaymentKeys_te = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do -- Reference keys - referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/payment_keys/verification_key" - referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/payment_keys/signing_key" + referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/payment_keys/verification_key" + referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/payment_keys/signing_key" -- Key filepaths verKey <- noteTempFile tempDir "payment-verification-key-file" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/StakeKeys.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/StakeKeys.hs index 7f325175dc..0954c27197 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/StakeKeys.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/StakeKeys.hs @@ -23,8 +23,8 @@ import qualified Hedgehog.Extras.Test.File as H hprop_golden_shelleyStakeKeys :: Property hprop_golden_shelleyStakeKeys = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do -- Reference keys - referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/verification_key" - referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/signing_key" + referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/stake_keys/verification_key" + referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/stake_keys/signing_key" -- Key filepaths verKey <- noteTempFile tempDir "stake-verification-key-file" @@ -51,8 +51,8 @@ hprop_golden_shelleyStakeKeys = propertyOnce . H.moduleWorkspace "tmp" $ \tempDi hprop_golden_shelleyStakeKeys_te :: Property hprop_golden_shelleyStakeKeys_te = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do -- Reference keys - referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/verification_key" - referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/signing_key" + referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/stake_keys/verification_key" + referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/stake_keys/signing_key" -- Key filepaths verKey <- noteTempFile tempDir "stake-verification-key-file" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/VRFKeys.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/VRFKeys.hs index d99ec931bf..1bd1027b6c 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/VRFKeys.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Keys/VRFKeys.hs @@ -25,8 +25,8 @@ hprop_golden_shelleyVRFKeys = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir H.note_ tempDir -- Reference keys - referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/vrf_keys/verification_key" - referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/vrf_keys/signing_key" + referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/vrf_keys/verification_key" + referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/vrf_keys/signing_key" -- Key filepaths verKey <- noteTempFile tempDir "vrf-verification-key-file" @@ -55,8 +55,8 @@ hprop_golden_shelleyVRFKeys_te = propertyOnce . H.moduleWorkspace "tmp" $ \tempD H.note_ tempDir -- Reference keys - referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/vrf_keys/verification_key" - referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/vrf_keys/signing_key" + referenceVerKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/vrf_keys/verification_key" + referenceSignKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/vrf_keys/signing_key" -- Key filepaths verKey <- noteTempFile tempDir "vrf-verification-key-file" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Tx/Tx.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Tx/Tx.hs index df890563df..a7c6c0b832 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Tx/Tx.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Tx/Tx.hs @@ -18,10 +18,10 @@ import qualified Hedgehog.Extras.Test.Base as H hprop_golden_shelleyTx :: Property hprop_golden_shelleyTx = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do -- Reference keys - let referenceTx = "test/cardano-cli-golden/files/golden/alonzo/tx" + let goldenReferenceTx = "test/cardano-cli-golden/files/golden/alonzo/tx" -- Key filepaths - paymentSignKey <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/transaction-sign/utxo.skey" + paymentSignKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/transaction-sign/utxo.skey" transactionFile <- noteTempFile tempDir "tx-file" transactionBodyFile <- noteTempFile tempDir "tx-body-file" @@ -44,6 +44,43 @@ hprop_golden_shelleyTx = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do , "--out-file", transactionFile ] + -- Check the newly created files have not deviated from the + -- golden files + checkTxCddlFormat goldenReferenceTx transactionFile + +-- TODO Re-enable this test +disable_hprop_golden_checkIfConstitutionalCommitteeKeyCanSign :: Property +disable_hprop_golden_checkIfConstitutionalCommitteeKeyCanSign = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do + -- Reference keys + let referenceTx = "test/cardano-cli-golden/files/input/conway/tx" + + -- Key filepaths + paymentSignKey <- noteInputFile "test/cardano-cli-golden/files/input/shelley/transaction-sign/utxo.skey" + -- constitutional committee signing key + paymentSignKey2 <- noteInputFile "test/cardano-cli-golden/files/input/conway/cold1-cc.skey" + transactionFile <- noteTempFile tempDir "tx-file" + transactionBodyFile <- noteTempFile tempDir "tx-body-file" + + -- Create transaction body + void $ execCardanoCLI + [ "conway", "transaction", "build-raw" + , "--tx-in", "f62cd7bc15d8c6d2c8519fb8d13c57c0157ab6bab50af62bc63706feb966393d#0" + , "--tx-out", "addr_test1qpmxr8d8jcl25kyz2tz9a9sxv7jxglhddyf475045y8j3zxjcg9vquzkljyfn3rasfwwlkwu7hhm59gzxmsyxf3w9dps8832xh+1199989833223" + , "--tx-out", "addr_test1vpqgspvmh6m2m5pwangvdg499srfzre2dd96qq57nlnw6yctpasy4+10000000" + , "--fee", "166777" + , "--out-file", transactionBodyFile + ] + + -- Sign transaction + void $ execCardanoCLI + [ "transaction", "sign" + , "--tx-body-file", transactionBodyFile + , "--signing-key-file", paymentSignKey + , "--signing-key-file", paymentSignKey2 + , "--testnet-magic", "42" + , "--out-file", transactionFile + ] + -- Check the newly created files have not deviated from the -- golden files checkTxCddlFormat referenceTx transactionFile diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Tx/TxBody.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Tx/TxBody.hs index 4bc202e347..c1902d6774 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Tx/TxBody.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextEnvelope/Tx/TxBody.hs @@ -16,7 +16,7 @@ import qualified Hedgehog.Extras.Test.Base as H hprop_golden_shelleyTxBody :: Property hprop_golden_shelleyTxBody = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do -- Reference keys - referenceTxBody <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/tx/txbody" + referenceTxBody <- noteInputFile "test/cardano-cli-golden/files/input/shelley/tx/txbody" -- Key filepaths transactionBodyFile <- noteTempFile tempDir "transaction-body-file" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextView/DecodeCbor.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextView/DecodeCbor.hs index 0a98e41d7f..a8479d2b25 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextView/DecodeCbor.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/TextView/DecodeCbor.hs @@ -12,7 +12,7 @@ import qualified Hedgehog.Extras.Test.File as H hprop_golden_shelleyTextViewDecodeCbor :: Property hprop_golden_shelleyTextViewDecodeCbor = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do - unsignedTxFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/tx/unsigned.tx" + unsignedTxFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/tx/unsigned.tx" decodedTxtFile <- noteTempFile tempDir "decoded.txt" -- Defaults to signing a Mainnet transaction. diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/Assemble.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/Assemble.hs index ed5194cb5e..4e69c3822c 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/Assemble.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/Assemble.hs @@ -17,8 +17,8 @@ import qualified Hedgehog.Extras.Test.File as H hprop_golden_shelleyTransactionAssembleWitness_SigningKey :: Property hprop_golden_shelleyTransactionAssembleWitness_SigningKey = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do witnessTx <- noteTempFile tempDir "single-signing-key-witness-tx" - txBodyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/tx/txbody" - signingKeyWitnessFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/witnesses/singleSigningKeyWitness" + txBodyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/tx/txbody" + signingKeyWitnessFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/witnesses/singleSigningKeyWitness" void $ execCardanoCLI [ "transaction","sign-witness" , "--tx-body-file", txBodyFile diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/Build.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/Build.hs index b3e75dc920..bf67639af0 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/Build.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/Build.hs @@ -42,8 +42,8 @@ hprop_golden_shelleyTransactionBuild = hprop_golden_shelleyTransactionBuild_CertificateScriptWitnessed :: Property hprop_golden_shelleyTransactionBuild_CertificateScriptWitnessed = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do - let deregcert = "test/cardano-cli-golden/files/golden/shelley/certificates/stake_address_deregistration_certificate" - scriptWit = "test/cardano-cli-golden/files/golden/shelley/multisig/scripts/any" + let deregcert = "test/cardano-cli-golden/files/input/shelley/certificates/stake_address_deregistration_certificate" + scriptWit = "test/cardano-cli-golden/files/input/shelley/multisig/scripts/any" txBodyOutFile <- noteTempFile tempDir "tx-body-out" @@ -63,7 +63,7 @@ hprop_golden_shelleyTransactionBuild_CertificateScriptWitnessed = hprop_golden_shelleyTransactionBuild_Minting :: Property hprop_golden_shelleyTransactionBuild_Minting = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do - let scriptWit = "test/cardano-cli-golden/files/golden/shelley/multisig/scripts/any" + let scriptWit = "test/cardano-cli-golden/files/input/shelley/multisig/scripts/any" polid <- execCardanoCLI [ "transaction" @@ -96,10 +96,10 @@ hprop_golden_shelleyTransactionBuild_WithdrawalScriptWitnessed = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do txBodyOutFile <- noteTempFile tempDir "tx-body-out" - stakeAddress <- H.readFile "test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/reward_address" + stakeAddress <- H.readFile "test/cardano-cli-golden/files/input/shelley/keys/stake_keys/reward_address" let withdrawal = filter (/= '\n') $ stakeAddress <> "+100" - scriptWit = "test/cardano-cli-golden/files/golden/shelley/multisig/scripts/any" + scriptWit = "test/cardano-cli-golden/files/input/shelley/multisig/scripts/any" void $ execCardanoCLI [ "mary", "transaction", "build-raw" @@ -117,7 +117,7 @@ hprop_golden_shelleyTransactionBuild_WithdrawalScriptWitnessed = hprop_golden_shelleyTransactionBuild_TxInScriptWitnessed :: Property hprop_golden_shelleyTransactionBuild_TxInScriptWitnessed = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do - let scriptWit = "test/cardano-cli-golden/files/golden/shelley/multisig/scripts/any" + let scriptWit = "test/cardano-cli-golden/files/input/shelley/multisig/scripts/any" txBodyOutFile <- noteTempFile tempDir "tx-body-out" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/CalculateMinFee.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/CalculateMinFee.hs index 1e89d6f739..c0f741dd31 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/CalculateMinFee.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/CalculateMinFee.hs @@ -13,8 +13,8 @@ import qualified Hedgehog.Extras.Test.File as H hprop_golden_shelleyTransactionCalculateMinFee :: Property hprop_golden_shelleyTransactionCalculateMinFee = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do - protocolParamsJsonFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/transaction-calculate-min-fee/protocol-params.json" - txBodyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/tx/txbody" + protocolParamsJsonFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/transaction-calculate-min-fee/protocol-params.json" + txBodyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/tx/txbody" minFeeTxtFile <- noteTempFile tempDir "min-fee.txt" minFeeTxt <- execCardanoCLI diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/CreateWitness.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/CreateWitness.hs index 4fa21615e3..fc48d92236 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/CreateWitness.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/CreateWitness.hs @@ -34,7 +34,7 @@ hprop_golden_shelleyTransactionSigningKeyWitness = propertyOnce $ H.moduleWorksp -- Create all multisig witness witnessOutFile <- noteTempFile tempDir "signingkey-witness" - signingKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/payment_keys/signing_key" + signingKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/payment_keys/signing_key" void $ execCardanoCLI [ "transaction","witness" , "--tx-body-file", txBodyOutFile diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/Sign.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/Sign.hs index 50092ce48f..7ac4f6df1b 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/Sign.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Shelley/Transaction/Sign.hs @@ -14,11 +14,12 @@ import qualified Hedgehog.Extras.Test.File as H hprop_golden_shelleyTransactionSign :: Property hprop_golden_shelleyTransactionSign = propertyOnce $ H.moduleWorkspace "tmp" $ \tempDir -> do - txBodyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/tx/txbody" - initialUtxo1SigningKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/keys/payment_keys/signing_key" - utxoSigningKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/transaction-sign/utxo.skey" - stakeSigningKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/transaction-sign/stake.skey" - nodeColdSigningKeyFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/transaction-sign/node-cold.skey" + txBodyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/tx/txbody" + initialUtxo1SigningKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/keys/payment_keys/signing_key" + utxoSigningKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/transaction-sign/utxo.skey" + stakeSigningKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/transaction-sign/stake.skey" + nodeColdSigningKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/shelley/transaction-sign/node-cold.skey" + ccHotSigningKeyFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/cc-hot.skey" signedTransactionFile <- noteTempFile tempDir "signed.tx" transactionPoolRegSignedFile <- noteTempFile tempDir "tx-pool-reg.signed" @@ -64,3 +65,14 @@ hprop_golden_shelleyTransactionSign = propertyOnce $ H.moduleWorkspace "tmp" $ \ H.assertFileOccurences 1 "Tx MaryEra" transactionPoolRegSignedFile H.assertEndsWithSingleNewline transactionPoolRegSignedFile + + void $ execCardanoCLI + [ "transaction","sign" + , "--mainnet" + , "--tx-body-file", txBodyFile + , "--signing-key-file", ccHotSigningKeyFile + , "--tx-file", transactionPoolRegSignedFile + ] + + H.assertFileOccurences 1 "Tx MaryEra" transactionPoolRegSignedFile + H.assertEndsWithSingleNewline transactionPoolRegSignedFile diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/TxView.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/TxView.hs index 34ff6814bc..2e7e3b9e5c 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/TxView.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/TxView.hs @@ -107,7 +107,7 @@ hprop_golden_view_shelley_yaml = let , "--epoch", "64" , "--extra-entropy", extraEntropySeed , "--genesis-verification-key-file" - , "test/cardano-cli-golden/files/golden/shelley/keys/genesis_keys/verification_key" + , "test/cardano-cli-golden/files/input/shelley/keys/genesis_keys/verification_key" , "--key-reg-deposit-amt", "71" , "--max-block-body-size", "72" , "--max-block-header-size", "73" @@ -149,6 +149,7 @@ hprop_golden_view_shelley_yaml = let result <- execCardanoCLI ["transaction", "view", "--tx-body-file", transactionBodyFile, "--output-format", "yaml"] + H.diffVsGoldenFile result "test/cardano-cli-golden/files/golden/shelley/transaction-view.out" hprop_golden_view_allegra_yaml :: Property @@ -237,8 +238,8 @@ hprop_golden_view_mary_yaml = , " a06ee5ffdd7f9b5bd992eb9543f44418323f81229526b77b0e4be067" , ".736b79" ] - , "--mint-script-file", "test/cardano-cli-golden/files/golden/mary/scripts/mint.all" - , "--mint-script-file", "test/cardano-cli-golden/files/golden/mary/scripts/mint.sig" + , "--mint-script-file", "test/cardano-cli-golden/files/input/mary/scripts/mint.all" + , "--mint-script-file", "test/cardano-cli-golden/files/input/mary/scripts/mint.sig" , "--out-file", transactionBodyFile ] @@ -271,8 +272,7 @@ createAlonzoTxBody mUpdateProposalFile transactionBodyFile = do hprop_golden_view_alonzo_yaml :: Property hprop_golden_view_alonzo_yaml = - propertyOnce $ - moduleWorkspace "tmp" $ \tempDir -> do + propertyOnce $ moduleWorkspace "tmp" $ \tempDir -> do updateProposalFile <- noteTempFile tempDir "update-proposal" transactionBodyFile <- noteTempFile tempDir "transaction-body" @@ -287,7 +287,7 @@ hprop_golden_view_alonzo_yaml = [ "legacy", "governance", "create-update-proposal" , "--epoch", "190" , "--genesis-verification-key-file" - , "test/cardano-cli-golden/files/golden/shelley/keys/genesis_keys/verification_key" + , "test/cardano-cli-golden/files/input/shelley/keys/genesis_keys/verification_key" , "--utxo-cost-per-word", "194" , "--price-execution-steps", "195/196" , "--price-execution-memory", "196/197" @@ -309,26 +309,27 @@ hprop_golden_view_alonzo_yaml = hprop_golden_view_alonzo_signed_yaml :: Property hprop_golden_view_alonzo_signed_yaml = - let testData = "test/cardano-cli-golden/files/golden/alonzo" - in - propertyOnce $ - moduleWorkspace "tmp" $ \tempDir -> do - transactionBodyFile <- noteTempFile tempDir "transaction-body" - transactionFile <- noteTempFile tempDir "transaction" + propertyOnce $ moduleWorkspace "tmp" $ \tempDir -> do + let golden = "test/cardano-cli-golden/files/golden/alonzo" + let input = "test/cardano-cli-golden/files/input/alonzo" - createAlonzoTxBody Nothing transactionBodyFile + transactionBodyFile <- noteTempFile tempDir "transaction-body" + transactionFile <- noteTempFile tempDir "transaction" - -- Sign - void $ - execCardanoCLI - [ "transaction", "sign" - , "--tx-body-file", transactionBodyFile - , "--signing-key-file", testData "signing.key" - , "--out-file", transactionFile - ] + createAlonzoTxBody Nothing transactionBodyFile - -- View transaction body - result <- - execCardanoCLI - ["transaction", "view", "--tx-file", transactionFile, "--output-format", "yaml"] - H.diffVsGoldenFile result (testData "signed-transaction-view.out") + -- Sign + void $ + execCardanoCLI + [ "transaction", "sign" + , "--tx-body-file", transactionBodyFile + , "--signing-key-file", input "signing.key" + , "--out-file", transactionFile + ] + + -- View transaction body + result <- + execCardanoCLI + ["transaction", "view", "--tx-file", transactionFile, "--output-format", "yaml"] + + H.diffVsGoldenFile result (golden "signed-transaction-view.out") \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/allegra/transaction-view.out b/cardano-cli/test/cardano-cli-golden/files/golden/allegra/transaction-view.out index b4a82f94d2..8fe812eff0 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/allegra/transaction-view.out +++ b/cardano-cli/test/cardano-cli-golden/files/golden/allegra/transaction-view.out @@ -22,6 +22,5 @@ return collateral: null total collateral: null update proposal: null validity range: - lower bound: null - upper bound: 101 + time to live: 101 withdrawals: null diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/alonzo/tx b/cardano-cli/test/cardano-cli-golden/files/golden/alonzo/tx index edce62bab2..4ca8a23be1 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/alonzo/tx +++ b/cardano-cli/test/cardano-cli-golden/files/golden/alonzo/tx @@ -2,4 +2,4 @@ "type": "Witnessed Tx AlonzoEra", "description": "Ledger Cddl Format", "cborHex": "84a30081825820f62cd7bc15d8c6d2c8519fb8d13c57c0157ab6bab50af62bc63706feb966393d0001828258390076619da7963eaa588252c45e960667a4647eed69135f51f5a10f2888d2c20ac07056fc8899c47d825cefd9dcf5efba150236e043262e2b431b0000011764f7be0782581d604088059bbeb6add02eecd0c6a2a52c06910f2a6b4ba0029e9fe6ed131a00989680021a00028b79a100818258208dc60533b5dfa60a530955a696323a2ef4f14e8bc95a8f84cf6c441fea4234275840043220211a264209f6e61903e60e80093b7b3a08e8bc5fe8f8707635acd69b6e0589e61aea544b87729983955decded90a59f9701042bebe57f2afba7c94fc02f5f6" -} \ No newline at end of file +} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/alonzo/verification.key b/cardano-cli/test/cardano-cli-golden/files/golden/alonzo/verification.key deleted file mode 100644 index 6d7ec63397..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/alonzo/verification.key +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "PaymentVerificationKeyShelley_ed25519", - "description": "Payment Verification Key", - "cborHex": "582084ce03e08b05533685d593c14cd6ca5c7485824156ca11fb303ddac9dd3ef41c" -} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/conway/genesis.conway.spec.json b/cardano-cli/test/cardano-cli-golden/files/golden/conway/genesis.conway.spec.json deleted file mode 100644 index 9fb397192c..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/conway/genesis.conway.spec.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "committeeTermLimit": 0, - "dRepActivity": 0, - "dRepDeposit": 0, - "dRepVotingThresholds": { - "dvtCommitteeNoConfidence": 0, - "dvtCommitteeNormal": 0, - "dvtHardForkInitiation": 0, - "dvtMotionNoConfidence": 0, - "dvtPPEconomicGroup": 0, - "dvtPPGovGroup": 0, - "dvtPPNetworkGroup": 0, - "dvtPPTechnicalGroup": 0, - "dvtTreasuryWithdrawal": 0, - "dvtUpdateToConstitution": 0 - }, - "govActionDeposit": 0, - "govActionExpiration": 0, - "minCommitteeSize": 0, - "poolVotingThresholds": { - "pvtCommitteeNoConfidence": 0, - "pvtCommitteeNormal": 0, - "pvtHardForkInitiation": 0, - "pvtMotionNoConfidence": 0 - } -} \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/cold.vk b/cardano-cli/test/cardano-cli-golden/files/golden/governance/cold.vk similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/cold.vk rename to cardano-cli/test/cardano-cli-golden/files/golden/governance/cold.vk diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.answer.0.json b/cardano-cli/test/cardano-cli-golden/files/golden/governance/polls/basic.answer.0.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.answer.0.json rename to cardano-cli/test/cardano-cli-golden/files/golden/governance/polls/basic.answer.0.json diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.answer.1.json b/cardano-cli/test/cardano-cli-golden/files/golden/governance/polls/basic.answer.1.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.answer.1.json rename to cardano-cli/test/cardano-cli-golden/files/golden/governance/polls/basic.answer.1.json 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 f79e133356..c81bf5f8b5 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -4977,7 +4977,13 @@ Usage: cardano-cli babbage genesis hash --genesis FILE Compute the hash of a genesis file -Usage: cardano-cli babbage governance (create-mir-certificate | action) +Usage: cardano-cli babbage governance + ( create-mir-certificate + | action + | create-poll + | answer-poll + | verify-poll + ) Governance commands. @@ -5050,6 +5056,25 @@ Usage: cardano-cli babbage governance action create-protocol-parameters-update - Create a protocol parameters update. +Usage: cardano-cli babbage governance create-poll --question STRING + (--answer STRING) + [--nonce UINT] + --out-file FILE + + Create an SPO poll + +Usage: cardano-cli babbage governance answer-poll --poll-file FILE + [--answer INT] + [--out-file FILE] + + Answer an SPO poll + +Usage: cardano-cli babbage governance verify-poll --poll-file FILE + --tx-file FILE + [--out-file FILE] + + Verify an answer to a given SPO poll + Usage: cardano-cli babbage node ( key-gen | key-gen-KES @@ -6397,6 +6422,26 @@ Usage: cardano-cli conway governance action create-protocol-parameters-update -- [--collateral-percent INT] [--max-collateral-inputs INT] [--utxo-cost-per-byte LOVELACE] + [--pool-voting-threshold-motion-no-confidence RATIONAL + --pool-voting-threshold-committee-normal RATIONAL + --pool-voting-threshold-committee-no-confidence RATIONAL + --pool-voting-threshold-hard-fork-initiation RATIONAL] + [--drep-voting-threshold-motion-no-confidence RATIONAL + --drep-voting-threshold-committee-normal RATIONAL + --drep-voting-threshold-committee-no-confidence RATIONAL + --drep-voting-threshold-update-to-constitution RATIONAL + --drep-voting-threshold-hard-fork-initiation RATIONAL + --drep-voting-threshold-pp-network-group RATIONAL + --drep-voting-threshold-pp-economic-group RATIONAL + --drep-voting-threshold-pp-technical-group RATIONAL + --drep-voting-threshold-pp-governance-group RATIONAL + --drep-voting-threshold-treasury-withdrawal RATIONAL] + [--min-committee-size INT] + [--committee-term-length INT] + [--governance-action-lifetime NATURAL] + [--governance-action-deposit NATURAL] + [--drep-deposit LOVELACE] + [--drep-activity NATURAL] --out-file FILE Create a protocol parameters update. @@ -6509,6 +6554,8 @@ Usage: cardano-cli conway governance drep registration-certificate | --drep-key-hash HASH ) --key-reg-deposit-amt NATURAL + [--drep-metadata-url TEXT + --drep-metadata-hash HASH] --out-file FILE Create a registration certificate. @@ -6526,6 +6573,9 @@ Usage: cardano-cli conway governance vote create (--yes | --no | --abstain) | --stake-pool-verification-key STRING | --cold-verification-key-file FILE | --stake-pool-id STAKE_POOL_ID + | --cc-hot-verification-key STRING + | --cc-hot-verification-key-file FILE + | --cc-hot-key-hash STRING ) --out-file FILE @@ -7684,7 +7734,13 @@ Usage: cardano-cli latest genesis hash --genesis FILE Compute the hash of a genesis file -Usage: cardano-cli latest governance (create-mir-certificate | action) +Usage: cardano-cli latest governance + ( create-mir-certificate + | action + | create-poll + | answer-poll + | verify-poll + ) Governance commands. @@ -7757,6 +7813,25 @@ Usage: cardano-cli latest governance action create-protocol-parameters-update -- Create a protocol parameters update. +Usage: cardano-cli latest governance create-poll --question STRING + (--answer STRING) + [--nonce UINT] + --out-file FILE + + Create an SPO poll + +Usage: cardano-cli latest governance answer-poll --poll-file FILE + [--answer INT] + [--out-file FILE] + + Answer an SPO poll + +Usage: cardano-cli latest governance verify-poll --poll-file FILE + --tx-file FILE + [--out-file FILE] + + Verify an answer to a given SPO poll + Usage: cardano-cli latest node ( key-gen | key-gen-KES @@ -8638,9 +8713,6 @@ Usage: cardano-cli legacy governance ( create-mir-certificate | create-genesis-key-delegation-certificate | create-update-proposal - | create-poll - | answer-poll - | verify-poll ) Governance commands @@ -8767,25 +8839,6 @@ Usage: cardano-cli legacy governance create-update-proposal --out-file FILE Create an update proposal -Usage: cardano-cli legacy governance create-poll --question STRING - (--answer STRING) - [--nonce UINT] - --out-file FILE - - Create an SPO poll - -Usage: cardano-cli legacy governance answer-poll --poll-file FILE - [--answer INT] - [--out-file FILE] - - Answer an SPO poll - -Usage: cardano-cli legacy governance verify-poll --poll-file FILE - --tx-file FILE - [--out-file FILE] - - Verify an answer to a given SPO poll - Usage: cardano-cli legacy genesis ( key-gen-genesis | key-gen-delegate @@ -9950,9 +10003,6 @@ Usage: cardano-cli governance ( create-mir-certificate | create-genesis-key-delegation-certificate | create-update-proposal - | create-poll - | answer-poll - | verify-poll ) Governance commands @@ -10079,25 +10129,6 @@ Usage: cardano-cli governance create-update-proposal --out-file FILE Create an update proposal -Usage: cardano-cli governance create-poll --question STRING - (--answer STRING) - [--nonce UINT] - --out-file FILE - - Create an SPO poll - -Usage: cardano-cli governance answer-poll --poll-file FILE - [--answer INT] - [--out-file FILE] - - Answer an SPO poll - -Usage: cardano-cli governance verify-poll --poll-file FILE - --tx-file FILE - [--out-file FILE] - - Verify an answer to a given SPO poll - Usage: cardano-cli genesis ( key-gen-genesis | key-gen-delegate diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_governance_drep_registration-certificate.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_governance_drep_registration-certificate.cli deleted file mode 100644 index e0a37cfae0..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_governance_drep_registration-certificate.cli +++ /dev/null @@ -1,84 +0,0 @@ -Usage: cardano-cli allegra governance drep registration-certificate - ( ( --stake-pool-verification-key STRING - | --cold-verification-key-file FILE - ) - ( --vrf-verification-key STRING - | --vrf-verification-key-file FILE - ) - --pool-pledge LOVELACE - --pool-cost LOVELACE - --pool-margin RATIONAL - ( --pool-reward-account-verification-key STRING - | --pool-reward-account-verification-key-file FILE - ) - ( --pool-owner-verification-key STRING - | --pool-owner-stake-verification-key-file FILE - ) - [ [--pool-relay-ipv4 STRING] - [--pool-relay-ipv6 STRING] - --pool-relay-port INT - | --single-host-pool-relay STRING - [--pool-relay-port INT] - | --multi-host-pool-relay STRING - ] - [--metadata-url URL - --metadata-hash HASH] - ( --mainnet - | --testnet-magic NATURAL - ) - | --stake-verification-key STRING - | --stake-verification-key-file FILE - | --stake-script-file FILE - | --stake-address ADDRESS - ) - --out-file FILE - - Create a registration certificate. - -Available options: - --stake-pool-verification-key STRING - Stake pool verification key (Bech32 or hex-encoded). - --cold-verification-key-file FILE - Filepath of the stake pool verification key. - --vrf-verification-key STRING - VRF verification key (Bech32 or hex-encoded). - --vrf-verification-key-file FILE - Filepath of the VRF verification key. - --pool-pledge LOVELACE The stake pool's pledge. - --pool-cost LOVELACE The stake pool's cost. - --pool-margin RATIONAL The stake pool's margin. - --pool-reward-account-verification-key STRING - Reward account stake verification key (Bech32 or - hex-encoded). - --pool-reward-account-verification-key-file FILE - Filepath of the reward account stake verification - key. - --pool-owner-verification-key STRING - Pool owner stake verification key (Bech32 or - hex-encoded). - --pool-owner-stake-verification-key-file FILE - Filepath of the pool owner stake verification key. - --pool-relay-ipv4 STRING The stake pool relay's IPv4 address - --pool-relay-ipv6 STRING The stake pool relay's IPv6 address - --pool-relay-port INT The stake pool relay's port - --single-host-pool-relay STRING - The stake pool relay's DNS name that corresponds to - an A or AAAA DNS record - --pool-relay-port INT The stake pool relay's port - --multi-host-pool-relay STRING - The stake pool relay's DNS name that corresponds to - an SRV DNS record - --metadata-url URL Pool metadata URL (maximum length of 64 characters). - --metadata-hash HASH Pool metadata hash. - --mainnet Use the mainnet magic id. This overrides the - CARDANO_NODE_NETWORK_ID environment variable - --testnet-magic NATURAL Specify a testnet magic id. This overrides the - CARDANO_NODE_NETWORK_ID environment variable - --stake-verification-key STRING - Stake verification key (Bech32 or hex-encoded). - --stake-verification-key-file FILE - Filepath of the staking verification key. - --stake-script-file FILE Filepath of the staking script. - --stake-address ADDRESS Target stake address (bech32 format). - --out-file FILE The output file. - -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_governance_drep_registration-certificate.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_governance_drep_registration-certificate.cli deleted file mode 100644 index 8628fb3685..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_governance_drep_registration-certificate.cli +++ /dev/null @@ -1,84 +0,0 @@ -Usage: cardano-cli alonzo governance drep registration-certificate - ( ( --stake-pool-verification-key STRING - | --cold-verification-key-file FILE - ) - ( --vrf-verification-key STRING - | --vrf-verification-key-file FILE - ) - --pool-pledge LOVELACE - --pool-cost LOVELACE - --pool-margin RATIONAL - ( --pool-reward-account-verification-key STRING - | --pool-reward-account-verification-key-file FILE - ) - ( --pool-owner-verification-key STRING - | --pool-owner-stake-verification-key-file FILE - ) - [ [--pool-relay-ipv4 STRING] - [--pool-relay-ipv6 STRING] - --pool-relay-port INT - | --single-host-pool-relay STRING - [--pool-relay-port INT] - | --multi-host-pool-relay STRING - ] - [--metadata-url URL - --metadata-hash HASH] - ( --mainnet - | --testnet-magic NATURAL - ) - | --stake-verification-key STRING - | --stake-verification-key-file FILE - | --stake-script-file FILE - | --stake-address ADDRESS - ) - --out-file FILE - - Create a registration certificate. - -Available options: - --stake-pool-verification-key STRING - Stake pool verification key (Bech32 or hex-encoded). - --cold-verification-key-file FILE - Filepath of the stake pool verification key. - --vrf-verification-key STRING - VRF verification key (Bech32 or hex-encoded). - --vrf-verification-key-file FILE - Filepath of the VRF verification key. - --pool-pledge LOVELACE The stake pool's pledge. - --pool-cost LOVELACE The stake pool's cost. - --pool-margin RATIONAL The stake pool's margin. - --pool-reward-account-verification-key STRING - Reward account stake verification key (Bech32 or - hex-encoded). - --pool-reward-account-verification-key-file FILE - Filepath of the reward account stake verification - key. - --pool-owner-verification-key STRING - Pool owner stake verification key (Bech32 or - hex-encoded). - --pool-owner-stake-verification-key-file FILE - Filepath of the pool owner stake verification key. - --pool-relay-ipv4 STRING The stake pool relay's IPv4 address - --pool-relay-ipv6 STRING The stake pool relay's IPv6 address - --pool-relay-port INT The stake pool relay's port - --single-host-pool-relay STRING - The stake pool relay's DNS name that corresponds to - an A or AAAA DNS record - --pool-relay-port INT The stake pool relay's port - --multi-host-pool-relay STRING - The stake pool relay's DNS name that corresponds to - an SRV DNS record - --metadata-url URL Pool metadata URL (maximum length of 64 characters). - --metadata-hash HASH Pool metadata hash. - --mainnet Use the mainnet magic id. This overrides the - CARDANO_NODE_NETWORK_ID environment variable - --testnet-magic NATURAL Specify a testnet magic id. This overrides the - CARDANO_NODE_NETWORK_ID environment variable - --stake-verification-key STRING - Stake verification key (Bech32 or hex-encoded). - --stake-verification-key-file FILE - Filepath of the staking verification key. - --stake-script-file FILE Filepath of the staking script. - --stake-address ADDRESS Target stake address (bech32 format). - --out-file FILE The output file. - -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance.cli index c46b2145a0..1ca4e1eec5 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance.cli @@ -1,4 +1,10 @@ -Usage: cardano-cli babbage governance (create-mir-certificate | action) +Usage: cardano-cli babbage governance + ( create-mir-certificate + | action + | create-poll + | answer-poll + | verify-poll + ) Governance commands. @@ -9,3 +15,6 @@ Available commands: create-mir-certificate Create an MIR (Move Instantaneous Rewards) certificate action Governance action commands. + create-poll Create an SPO poll + answer-poll Answer an SPO poll + verify-poll Verify an answer to a given SPO poll diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance_answer-poll.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_answer-poll.cli similarity index 61% rename from cardano-cli/test/cardano-cli-golden/files/golden/help/governance_answer-poll.cli rename to cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_answer-poll.cli index 5b98ca49e6..010c8f307d 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance_answer-poll.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_answer-poll.cli @@ -1,6 +1,6 @@ -Usage: cardano-cli governance answer-poll --poll-file FILE - [--answer INT] - [--out-file FILE] +Usage: cardano-cli babbage governance answer-poll --poll-file FILE + [--answer INT] + [--out-file FILE] Answer an SPO poll diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance_create-poll.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_create-poll.cli similarity index 57% rename from cardano-cli/test/cardano-cli-golden/files/golden/help/governance_create-poll.cli rename to cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_create-poll.cli index 1549cb8231..a2ae7fbd74 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance_create-poll.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_create-poll.cli @@ -1,7 +1,7 @@ -Usage: cardano-cli governance create-poll --question STRING - (--answer STRING) - [--nonce UINT] - --out-file FILE +Usage: cardano-cli babbage governance create-poll --question STRING + (--answer STRING) + [--nonce UINT] + --out-file FILE Create an SPO poll diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_drep_registration-certificate.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_drep_registration-certificate.cli deleted file mode 100644 index 39c1a48ccc..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_drep_registration-certificate.cli +++ /dev/null @@ -1,84 +0,0 @@ -Usage: cardano-cli babbage governance drep registration-certificate - ( ( --stake-pool-verification-key STRING - | --cold-verification-key-file FILE - ) - ( --vrf-verification-key STRING - | --vrf-verification-key-file FILE - ) - --pool-pledge LOVELACE - --pool-cost LOVELACE - --pool-margin RATIONAL - ( --pool-reward-account-verification-key STRING - | --pool-reward-account-verification-key-file FILE - ) - ( --pool-owner-verification-key STRING - | --pool-owner-stake-verification-key-file FILE - ) - [ [--pool-relay-ipv4 STRING] - [--pool-relay-ipv6 STRING] - --pool-relay-port INT - | --single-host-pool-relay STRING - [--pool-relay-port INT] - | --multi-host-pool-relay STRING - ] - [--metadata-url URL - --metadata-hash HASH] - ( --mainnet - | --testnet-magic NATURAL - ) - | --stake-verification-key STRING - | --stake-verification-key-file FILE - | --stake-script-file FILE - | --stake-address ADDRESS - ) - --out-file FILE - - Create a registration certificate. - -Available options: - --stake-pool-verification-key STRING - Stake pool verification key (Bech32 or hex-encoded). - --cold-verification-key-file FILE - Filepath of the stake pool verification key. - --vrf-verification-key STRING - VRF verification key (Bech32 or hex-encoded). - --vrf-verification-key-file FILE - Filepath of the VRF verification key. - --pool-pledge LOVELACE The stake pool's pledge. - --pool-cost LOVELACE The stake pool's cost. - --pool-margin RATIONAL The stake pool's margin. - --pool-reward-account-verification-key STRING - Reward account stake verification key (Bech32 or - hex-encoded). - --pool-reward-account-verification-key-file FILE - Filepath of the reward account stake verification - key. - --pool-owner-verification-key STRING - Pool owner stake verification key (Bech32 or - hex-encoded). - --pool-owner-stake-verification-key-file FILE - Filepath of the pool owner stake verification key. - --pool-relay-ipv4 STRING The stake pool relay's IPv4 address - --pool-relay-ipv6 STRING The stake pool relay's IPv6 address - --pool-relay-port INT The stake pool relay's port - --single-host-pool-relay STRING - The stake pool relay's DNS name that corresponds to - an A or AAAA DNS record - --pool-relay-port INT The stake pool relay's port - --multi-host-pool-relay STRING - The stake pool relay's DNS name that corresponds to - an SRV DNS record - --metadata-url URL Pool metadata URL (maximum length of 64 characters). - --metadata-hash HASH Pool metadata hash. - --mainnet Use the mainnet magic id. This overrides the - CARDANO_NODE_NETWORK_ID environment variable - --testnet-magic NATURAL Specify a testnet magic id. This overrides the - CARDANO_NODE_NETWORK_ID environment variable - --stake-verification-key STRING - Stake verification key (Bech32 or hex-encoded). - --stake-verification-key-file FILE - Filepath of the staking verification key. - --stake-script-file FILE Filepath of the staking script. - --stake-address ADDRESS Target stake address (bech32 format). - --out-file FILE The output file. - -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance_verify-poll.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_verify-poll.cli similarity index 61% rename from cardano-cli/test/cardano-cli-golden/files/golden/help/governance_verify-poll.cli rename to cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_verify-poll.cli index 30915e6559..1ee21545fd 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance_verify-poll.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_verify-poll.cli @@ -1,6 +1,6 @@ -Usage: cardano-cli governance verify-poll --poll-file FILE - --tx-file FILE - [--out-file FILE] +Usage: cardano-cli babbage governance verify-poll --poll-file FILE + --tx-file FILE + [--out-file FILE] Verify an answer to a given SPO poll diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-protocol-parameters-update.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-protocol-parameters-update.cli index 04dc627575..dbd8e54e7c 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-protocol-parameters-update.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-protocol-parameters-update.cli @@ -22,6 +22,26 @@ Usage: cardano-cli conway governance action create-protocol-parameters-update -- [--collateral-percent INT] [--max-collateral-inputs INT] [--utxo-cost-per-byte LOVELACE] + [--pool-voting-threshold-motion-no-confidence RATIONAL + --pool-voting-threshold-committee-normal RATIONAL + --pool-voting-threshold-committee-no-confidence RATIONAL + --pool-voting-threshold-hard-fork-initiation RATIONAL] + [--drep-voting-threshold-motion-no-confidence RATIONAL + --drep-voting-threshold-committee-normal RATIONAL + --drep-voting-threshold-committee-no-confidence RATIONAL + --drep-voting-threshold-update-to-constitution RATIONAL + --drep-voting-threshold-hard-fork-initiation RATIONAL + --drep-voting-threshold-pp-network-group RATIONAL + --drep-voting-threshold-pp-economic-group RATIONAL + --drep-voting-threshold-pp-technical-group RATIONAL + --drep-voting-threshold-pp-governance-group RATIONAL + --drep-voting-threshold-treasury-withdrawal RATIONAL] + [--min-committee-size INT] + [--committee-term-length INT] + [--governance-action-lifetime NATURAL] + [--governance-action-deposit NATURAL] + [--drep-deposit LOVELACE] + [--drep-activity NATURAL] --out-file FILE Create a protocol parameters update. @@ -88,5 +108,42 @@ Available options: --utxo-cost-per-byte LOVELACE Cost in lovelace per unit of UTxO storage (from Babbage era). + --pool-voting-threshold-motion-no-confidence RATIONAL + TODO + --pool-voting-threshold-committee-normal RATIONAL + TODO + --pool-voting-threshold-committee-no-confidence RATIONAL + TODO + --pool-voting-threshold-hard-fork-initiation RATIONAL + TODO + --drep-voting-threshold-motion-no-confidence RATIONAL + TODO + --drep-voting-threshold-committee-normal RATIONAL + TODO + --drep-voting-threshold-committee-no-confidence RATIONAL + TODO + --drep-voting-threshold-update-to-constitution RATIONAL + TODO + --drep-voting-threshold-hard-fork-initiation RATIONAL + TODO + --drep-voting-threshold-pp-network-group RATIONAL + TODO + --drep-voting-threshold-pp-economic-group RATIONAL + TODO + --drep-voting-threshold-pp-technical-group RATIONAL + TODO + --drep-voting-threshold-pp-governance-group RATIONAL + TODO + --drep-voting-threshold-treasury-withdrawal RATIONAL + TODO + --min-committee-size INT TODO + --committee-term-length INT + TODO + --governance-action-lifetime NATURAL + TODO + --governance-action-deposit NATURAL + Deposit required to submit a governance action. + --drep-deposit LOVELACE TODO + --drep-activity NATURAL TODO --out-file FILE The output file. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_drep_registration-certificate.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_drep_registration-certificate.cli index cc32c49b43..4c2d4c8897 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_drep_registration-certificate.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_drep_registration-certificate.cli @@ -4,6 +4,8 @@ Usage: cardano-cli conway governance drep registration-certificate | --drep-key-hash HASH ) --key-reg-deposit-amt NATURAL + [--drep-metadata-url TEXT + --drep-metadata-hash HASH] --out-file FILE Create a registration certificate. @@ -18,5 +20,8 @@ Available options: is allowed. --key-reg-deposit-amt NATURAL Key registration deposit amount. + --drep-metadata-url TEXT DRep anchor URL + --drep-metadata-hash HASH + DRep anchor data hash. --out-file FILE The output file. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_vote_create.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_vote_create.cli index 0ef7ea6bbb..a1f7b7d026 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_vote_create.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_vote_create.cli @@ -7,6 +7,9 @@ Usage: cardano-cli conway governance vote create (--yes | --no | --abstain) | --stake-pool-verification-key STRING | --cold-verification-key-file FILE | --stake-pool-id STAKE_POOL_ID + | --cc-hot-verification-key STRING + | --cc-hot-verification-key-file FILE + | --cc-hot-key-hash STRING ) --out-file FILE @@ -32,5 +35,10 @@ Available options: Stake pool ID/verification key hash (either Bech32-encoded or hex-encoded). Zero or more occurences of this option is allowed. + --cc-hot-verification-key STRING + Constitutional Committee hot key (hex-encoded). + --cc-hot-verification-key-file FILE + Filepath of the Consitutional Committee hot key. + --cc-hot-key-hash STRING Constitutional Committee key hash (hex-encoded). --out-file FILE Output filepath of the vote. -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/governance.cli index d06eba4ede..4d83c87bcb 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/governance.cli @@ -2,9 +2,6 @@ Usage: cardano-cli governance ( create-mir-certificate | create-genesis-key-delegation-certificate | create-update-proposal - | create-poll - | answer-poll - | verify-poll ) Governance commands @@ -18,6 +15,3 @@ Available commands: create-genesis-key-delegation-certificate Create a genesis key delegation certificate create-update-proposal Create an update proposal - create-poll Create an SPO poll - answer-poll Answer an SPO poll - verify-poll Verify an answer to a given SPO poll diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance.cli index 4e78e466fa..9833a1a374 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance.cli @@ -1,4 +1,10 @@ -Usage: cardano-cli latest governance (create-mir-certificate | action) +Usage: cardano-cli latest governance + ( create-mir-certificate + | action + | create-poll + | answer-poll + | verify-poll + ) Governance commands. @@ -9,3 +15,6 @@ Available commands: create-mir-certificate Create an MIR (Move Instantaneous Rewards) certificate action Governance action commands. + create-poll Create an SPO poll + answer-poll Answer an SPO poll + verify-poll Verify an answer to a given SPO poll diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_answer-poll.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_answer-poll.cli similarity index 87% rename from cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_answer-poll.cli rename to cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_answer-poll.cli index 0c788de0f2..6f74d1dfff 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_answer-poll.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_answer-poll.cli @@ -1,4 +1,4 @@ -Usage: cardano-cli legacy governance answer-poll --poll-file FILE +Usage: cardano-cli latest governance answer-poll --poll-file FILE [--answer INT] [--out-file FILE] diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_create-poll.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_create-poll.cli similarity index 89% rename from cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_create-poll.cli rename to cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_create-poll.cli index 18a3e7f2b2..aae43025f8 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_create-poll.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_create-poll.cli @@ -1,4 +1,4 @@ -Usage: cardano-cli legacy governance create-poll --question STRING +Usage: cardano-cli latest governance create-poll --question STRING (--answer STRING) [--nonce UINT] --out-file FILE diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_drep_registration-certificate.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_drep_registration-certificate.cli deleted file mode 100644 index 02ea9583af..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_drep_registration-certificate.cli +++ /dev/null @@ -1,84 +0,0 @@ -Usage: cardano-cli latest governance drep registration-certificate - ( ( --stake-pool-verification-key STRING - | --cold-verification-key-file FILE - ) - ( --vrf-verification-key STRING - | --vrf-verification-key-file FILE - ) - --pool-pledge LOVELACE - --pool-cost LOVELACE - --pool-margin RATIONAL - ( --pool-reward-account-verification-key STRING - | --pool-reward-account-verification-key-file FILE - ) - ( --pool-owner-verification-key STRING - | --pool-owner-stake-verification-key-file FILE - ) - [ [--pool-relay-ipv4 STRING] - [--pool-relay-ipv6 STRING] - --pool-relay-port INT - | --single-host-pool-relay STRING - [--pool-relay-port INT] - | --multi-host-pool-relay STRING - ] - [--metadata-url URL - --metadata-hash HASH] - ( --mainnet - | --testnet-magic NATURAL - ) - | --stake-verification-key STRING - | --stake-verification-key-file FILE - | --stake-script-file FILE - | --stake-address ADDRESS - ) - --out-file FILE - - Create a registration certificate. - -Available options: - --stake-pool-verification-key STRING - Stake pool verification key (Bech32 or hex-encoded). - --cold-verification-key-file FILE - Filepath of the stake pool verification key. - --vrf-verification-key STRING - VRF verification key (Bech32 or hex-encoded). - --vrf-verification-key-file FILE - Filepath of the VRF verification key. - --pool-pledge LOVELACE The stake pool's pledge. - --pool-cost LOVELACE The stake pool's cost. - --pool-margin RATIONAL The stake pool's margin. - --pool-reward-account-verification-key STRING - Reward account stake verification key (Bech32 or - hex-encoded). - --pool-reward-account-verification-key-file FILE - Filepath of the reward account stake verification - key. - --pool-owner-verification-key STRING - Pool owner stake verification key (Bech32 or - hex-encoded). - --pool-owner-stake-verification-key-file FILE - Filepath of the pool owner stake verification key. - --pool-relay-ipv4 STRING The stake pool relay's IPv4 address - --pool-relay-ipv6 STRING The stake pool relay's IPv6 address - --pool-relay-port INT The stake pool relay's port - --single-host-pool-relay STRING - The stake pool relay's DNS name that corresponds to - an A or AAAA DNS record - --pool-relay-port INT The stake pool relay's port - --multi-host-pool-relay STRING - The stake pool relay's DNS name that corresponds to - an SRV DNS record - --metadata-url URL Pool metadata URL (maximum length of 64 characters). - --metadata-hash HASH Pool metadata hash. - --mainnet Use the mainnet magic id. This overrides the - CARDANO_NODE_NETWORK_ID environment variable - --testnet-magic NATURAL Specify a testnet magic id. This overrides the - CARDANO_NODE_NETWORK_ID environment variable - --stake-verification-key STRING - Stake verification key (Bech32 or hex-encoded). - --stake-verification-key-file FILE - Filepath of the staking verification key. - --stake-script-file FILE Filepath of the staking script. - --stake-address ADDRESS Target stake address (bech32 format). - --out-file FILE The output file. - -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_verify-poll.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_verify-poll.cli similarity index 87% rename from cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_verify-poll.cli rename to cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_verify-poll.cli index 32671bada3..8fa45ec966 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_verify-poll.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_verify-poll.cli @@ -1,4 +1,4 @@ -Usage: cardano-cli legacy governance verify-poll --poll-file FILE +Usage: cardano-cli latest governance verify-poll --poll-file FILE --tx-file FILE [--out-file FILE] diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance.cli index b8aa60f019..1ac6d67f4c 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance.cli @@ -2,9 +2,6 @@ Usage: cardano-cli legacy governance ( create-mir-certificate | create-genesis-key-delegation-certificate | create-update-proposal - | create-poll - | answer-poll - | verify-poll ) Governance commands @@ -18,6 +15,3 @@ Available commands: create-genesis-key-delegation-certificate Create a genesis key delegation certificate create-update-proposal Create an update proposal - create-poll Create an SPO poll - answer-poll Answer an SPO poll - verify-poll Verify an answer to a given SPO poll diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_governance_drep_registration-certificate.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_governance_drep_registration-certificate.cli deleted file mode 100644 index 6ea55bde0e..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_governance_drep_registration-certificate.cli +++ /dev/null @@ -1,84 +0,0 @@ -Usage: cardano-cli mary governance drep registration-certificate - ( ( --stake-pool-verification-key STRING - | --cold-verification-key-file FILE - ) - ( --vrf-verification-key STRING - | --vrf-verification-key-file FILE - ) - --pool-pledge LOVELACE - --pool-cost LOVELACE - --pool-margin RATIONAL - ( --pool-reward-account-verification-key STRING - | --pool-reward-account-verification-key-file FILE - ) - ( --pool-owner-verification-key STRING - | --pool-owner-stake-verification-key-file FILE - ) - [ [--pool-relay-ipv4 STRING] - [--pool-relay-ipv6 STRING] - --pool-relay-port INT - | --single-host-pool-relay STRING - [--pool-relay-port INT] - | --multi-host-pool-relay STRING - ] - [--metadata-url URL - --metadata-hash HASH] - ( --mainnet - | --testnet-magic NATURAL - ) - | --stake-verification-key STRING - | --stake-verification-key-file FILE - | --stake-script-file FILE - | --stake-address ADDRESS - ) - --out-file FILE - - Create a registration certificate. - -Available options: - --stake-pool-verification-key STRING - Stake pool verification key (Bech32 or hex-encoded). - --cold-verification-key-file FILE - Filepath of the stake pool verification key. - --vrf-verification-key STRING - VRF verification key (Bech32 or hex-encoded). - --vrf-verification-key-file FILE - Filepath of the VRF verification key. - --pool-pledge LOVELACE The stake pool's pledge. - --pool-cost LOVELACE The stake pool's cost. - --pool-margin RATIONAL The stake pool's margin. - --pool-reward-account-verification-key STRING - Reward account stake verification key (Bech32 or - hex-encoded). - --pool-reward-account-verification-key-file FILE - Filepath of the reward account stake verification - key. - --pool-owner-verification-key STRING - Pool owner stake verification key (Bech32 or - hex-encoded). - --pool-owner-stake-verification-key-file FILE - Filepath of the pool owner stake verification key. - --pool-relay-ipv4 STRING The stake pool relay's IPv4 address - --pool-relay-ipv6 STRING The stake pool relay's IPv6 address - --pool-relay-port INT The stake pool relay's port - --single-host-pool-relay STRING - The stake pool relay's DNS name that corresponds to - an A or AAAA DNS record - --pool-relay-port INT The stake pool relay's port - --multi-host-pool-relay STRING - The stake pool relay's DNS name that corresponds to - an SRV DNS record - --metadata-url URL Pool metadata URL (maximum length of 64 characters). - --metadata-hash HASH Pool metadata hash. - --mainnet Use the mainnet magic id. This overrides the - CARDANO_NODE_NETWORK_ID environment variable - --testnet-magic NATURAL Specify a testnet magic id. This overrides the - CARDANO_NODE_NETWORK_ID environment variable - --stake-verification-key STRING - Stake verification key (Bech32 or hex-encoded). - --stake-verification-key-file FILE - Filepath of the staking verification key. - --stake-script-file FILE Filepath of the staking script. - --stake-address ADDRESS Target stake address (bech32 format). - --out-file FILE The output file. - -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_governance_drep_registration-certificate.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_governance_drep_registration-certificate.cli deleted file mode 100644 index 8d1cadffc0..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_governance_drep_registration-certificate.cli +++ /dev/null @@ -1,84 +0,0 @@ -Usage: cardano-cli shelley governance drep registration-certificate - ( ( --stake-pool-verification-key STRING - | --cold-verification-key-file FILE - ) - ( --vrf-verification-key STRING - | --vrf-verification-key-file FILE - ) - --pool-pledge LOVELACE - --pool-cost LOVELACE - --pool-margin RATIONAL - ( --pool-reward-account-verification-key STRING - | --pool-reward-account-verification-key-file FILE - ) - ( --pool-owner-verification-key STRING - | --pool-owner-stake-verification-key-file FILE - ) - [ [--pool-relay-ipv4 STRING] - [--pool-relay-ipv6 STRING] - --pool-relay-port INT - | --single-host-pool-relay STRING - [--pool-relay-port INT] - | --multi-host-pool-relay STRING - ] - [--metadata-url URL - --metadata-hash HASH] - ( --mainnet - | --testnet-magic NATURAL - ) - | --stake-verification-key STRING - | --stake-verification-key-file FILE - | --stake-script-file FILE - | --stake-address ADDRESS - ) - --out-file FILE - - Create a registration certificate. - -Available options: - --stake-pool-verification-key STRING - Stake pool verification key (Bech32 or hex-encoded). - --cold-verification-key-file FILE - Filepath of the stake pool verification key. - --vrf-verification-key STRING - VRF verification key (Bech32 or hex-encoded). - --vrf-verification-key-file FILE - Filepath of the VRF verification key. - --pool-pledge LOVELACE The stake pool's pledge. - --pool-cost LOVELACE The stake pool's cost. - --pool-margin RATIONAL The stake pool's margin. - --pool-reward-account-verification-key STRING - Reward account stake verification key (Bech32 or - hex-encoded). - --pool-reward-account-verification-key-file FILE - Filepath of the reward account stake verification - key. - --pool-owner-verification-key STRING - Pool owner stake verification key (Bech32 or - hex-encoded). - --pool-owner-stake-verification-key-file FILE - Filepath of the pool owner stake verification key. - --pool-relay-ipv4 STRING The stake pool relay's IPv4 address - --pool-relay-ipv6 STRING The stake pool relay's IPv6 address - --pool-relay-port INT The stake pool relay's port - --single-host-pool-relay STRING - The stake pool relay's DNS name that corresponds to - an A or AAAA DNS record - --pool-relay-port INT The stake pool relay's port - --multi-host-pool-relay STRING - The stake pool relay's DNS name that corresponds to - an SRV DNS record - --metadata-url URL Pool metadata URL (maximum length of 64 characters). - --metadata-hash HASH Pool metadata hash. - --mainnet Use the mainnet magic id. This overrides the - CARDANO_NODE_NETWORK_ID environment variable - --testnet-magic NATURAL Specify a testnet magic id. This overrides the - CARDANO_NODE_NETWORK_ID environment variable - --stake-verification-key STRING - Stake verification key (Bech32 or hex-encoded). - --stake-verification-key-file FILE - Filepath of the staking verification key. - --stake-script-file FILE Filepath of the staking script. - --stake-address ADDRESS Target stake address (bech32 format). - --out-file FILE The output file. - -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/genesis.conway.spec.json b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/genesis.conway.spec.json deleted file mode 100644 index 4525ef4a58..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/genesis.conway.spec.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "genDelegs": {} -} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/cold.sk b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/cold.sk deleted file mode 100644 index c766daf4dd..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/cold.sk +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "StakePoolSigningKey_ed25519", - "description": "Stake Pool Operator Signing Key", - "cborHex": "58201d298ffa1544da0a5b2ea544728fc1ba7d2ae7c60e1d37da03895019740dd00a" -} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/polls/long-text.json b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/polls/long-text.json deleted file mode 100644 index fe4480afea..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/polls/long-text.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "GovernancePoll", - "description": "An on-chain poll for SPOs: What is the most adequate topping to put on a pizza (please consider all possibilities and take time to answer)?", - "cborHex": "a1185ea2008278405768617420697320746865206d6f737420616465717561746520746f7070696e6720746f20707574206f6e20612070697a7a612028706c6561736520636f6e7378306964657220616c6c20706f73736962696c697469657320616e642074616b652074696d6520746f20616e73776572293f0182816a70696e656170706c65738278406f6e6c7920747261646974696f6e616c20746f706963732073686f756c6420676f206f6e20612070697a7a612c20746869732069736e277420726f6f6d20666f6772206a6f6b6573" -} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/verify/invalid b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/verify/invalid deleted file mode 100644 index a8cadf462c..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/verify/invalid +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "Tx BabbageEra", - "description": "", - "cborHex": "84a50081825820000000000000000000000000000000000000000000000000000000000000000000018002000e81581cf8db28823f8ebd01a2d9e24efb2f0d18e387665770274513e370b5d507582071c60fbdbf7a81f5c1115a45ecd2b95517f23dd820df8339323bf18ad513af17a1008182582029ade2115fbcbc17f063eec41ec0d358ccc5b52c2bccb47c0918727695619a68584043dff7946b6bbb5fc48783f18fe42ff0f3638ee539a41dff2fdae4aaf560e15073d40962b6d56e08329901e6d53b035309ea8551dc27ccc937a470d8bdd22101f5d90103a100a1185ea202582029093fd43fc30ba31e306af06ce8537390e1668ae7496fe53d53684683c3762c03182a" -} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/verify/malformed b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/verify/malformed deleted file mode 100644 index 99c373b2ab..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/verify/malformed +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "Tx BabbageEra", - "description": "", - "cborHex": "84a50081825820000000000000000000000000000000000000000000000000000000000000000000018002000e81581cf8db28823f8ebd01a2d9e24efb2f0d18e387665770274513e370b5d5075820eb050f4d211a6eb0cc26b329543d1efd10c63640ca27712effe0020eec94cf51a1008182582029ade2115fbcbc17f063eec41ec0d358ccc5b52c2bccb47c0918727695619a68584029360e6594884bc4be2d2e1e548739dd6081583e76ecfb4eb8059f293b2f8082399d0e9322e0d9218281bfdf5486b1486fb6fa9f3e9e51ec3d77300600b3fc09f5d90103a100a1185ea2623134582029093fd43fc30ba31e306af06ce8537390e1668ae7496fe53d53684683c3762c810301" -} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/verify/mismatch b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/verify/mismatch deleted file mode 100644 index 2b830809fe..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/verify/mismatch +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "Tx BabbageEra", - "description": "", - "cborHex": "84a50081825820000000000000000000000000000000000000000000000000000000000000000000018002000e81581cf8db28823f8ebd01a2d9e24efb2f0d18e387665770274513e370b5d5075820741abe0b22490400b7f86833095f5c9acb7fdb19794c430a9a5f88303f91fb9ea1008182582029ade2115fbcbc17f063eec41ec0d358ccc5b52c2bccb47c0918727695619a685840ba84c617c839ed4461f4d327057e31d6f36cf6e77d23538bc0b59908c665fb83c838c21009f8f48156e4f85f062fe0cd6ab7872a1caf9bc65223bb924ff8c908f5d90103a100a1185ea2025820ff093fd43fc30ba31e306af06ce8537390e1668ae7496fe53d53684683c376ff0301" -} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/verify/none b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/verify/none deleted file mode 100644 index b9d8a582d9..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/verify/none +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "Tx BabbageEra", - "description": "", - "cborHex": "84a40081825820000000000000000000000000000000000000000000000000000000000000000000018002000e81581cf8db28823f8ebd01a2d9e24efb2f0d18e387665770274513e370b5d5a1008182582029ade2115fbcbc17f063eec41ec0d358ccc5b52c2bccb47c0918727695619a68584020dca762a77d32b1c9982739e3d23f979b25c6fa0bb8a06a2523e5e2334bf4c8489f9a93c8dd620b6e390c89da3ec7797a66193609a96df2c36cd0356501a307f5f6" -} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-calculate-min-fee/tx-body-file b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-calculate-min-fee/tx-body-file deleted file mode 100644 index e24bb7d3bc..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-calculate-min-fee/tx-body-file +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "TxUnsignedShelley", - "description": "", - "cborHex": "82a4008182582091999ea21177b33ebe6b8690724a0c026d410a11ad7521caa350abdafa5394c300018182581d615dbe1e2117641f8d618034b801a870ca731ce758c3bedd5c7e4429c11a05f5e100021a000f4240031a0007a120f6" -} \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-sign/initial-utxo1.skey b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-sign/initial-utxo1.skey deleted file mode 100644 index 7d51acd54b..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-sign/initial-utxo1.skey +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "GenesisUTxOSigningKey_ed25519", - "description": "Genesis Initial UTxO Signing Key", - "cborHex": "5820b930f931fd32d7b78d147ec283ef7c0822df68c1a21f226d12269be47557a036" -} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-sign/initial-utxo2.skey b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-sign/initial-utxo2.skey deleted file mode 100644 index 52d0c8a5c0..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-sign/initial-utxo2.skey +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "GenesisUTxOSigningKey_ed25519", - "description": "Genesis Initial UTxO Signing Key", - "cborHex": "58204efdf94501ac1213dc1e8f174c1d8d4f8d906757926fd7aa844efec136d014b5" -} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-sign/tx-body-file b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-sign/tx-body-file deleted file mode 100644 index e24bb7d3bc..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-sign/tx-body-file +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "TxUnsignedShelley", - "description": "", - "cborHex": "82a4008182582091999ea21177b33ebe6b8690724a0c026d410a11ad7521caa350abdafa5394c300018182581d615dbe1e2117641f8d618034b801a870ca731ce758c3bedd5c7e4429c11a05f5e100021a000f4240031a0007a120f6" -} \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-view.out b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-view.out index b0642cc787..774c2780d4 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-view.out +++ b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-view.out @@ -10,9 +10,9 @@ certificates: - amount: 1000 Lovelace stake credential key hash: ee475cade27e95faf1093541b0783498016cdcfba0d6441055b2dfcb - stake address deregistration: - key hash: d0efd9836e62225a47baf9bedfeaccbb86ba3f49d9edc4ac0aa26df5 + keyHash: d0efd9836e62225a47baf9bedfeaccbb86ba3f49d9edc4ac0aa26df5 - stake address registration: - key hash: c6ea7e348d300b32798888497290db24a99a36f2238ed9668f602d7a + keyHash: c6ea7e348d300b32798888497290db24a99a36f2238ed9668f602d7a - stake pool retirement: epoch: 42 pool: pool13lllruv6rd63l70vkpgye2ea856f22k8xhujmf2vvlul5ytw7mx @@ -27,7 +27,7 @@ certificates: relays: [] rewardAccount: credential: - key hash: f25fc5c9f341ec3bd785ddea746f76b6a9ac7f38fdd7aef1779bbe81 + keyHash: f25fc5c9f341ec3bd785ddea746f76b6a9ac7f38fdd7aef1779bbe81 network: Mainnet vrf: 8d445260282cef45e4c6a862b8a924aeed1b316ccba779dd39f9517220e96407 collateral inputs: null diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/tx/tx b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/tx/tx deleted file mode 100644 index 3f807180fc..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/tx/tx +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "Witnessed Tx AlonzoEra", - "description": "Ledger Cddl Format", - "cborHex": "84a30081825820256fe89fc62e787e470c54e6d17390309ed6ceed27f11b9f873dd55802a6272f0001828258390076619da7963eaa588252c45e960667a4647eed69135f51f5a10f2888d2c20ac07056fc8899c47d825cefd9dcf5efba150236e043262e2b431b0000011764f7be0782581d604088059bbeb6add02eecd0c6a2a52c06910f2a6b4ba0029e9fe6ed131a00989680021a00028b79a100818258206cf237caaf3218032c28fe858aaeeb835a8b315f45ec273970fb64b3dd1cc7dc58402271384dc35dc926468747e901aba167d03f17d1f01374f8631210af32b2dfb601d4949bd9e03158473493425a31db653a3de8460510c5da92ff01022eecc801f5f6" -} \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/update-proposal b/cardano-cli/test/cardano-cli-golden/files/golden/shelley/update-proposal deleted file mode 100644 index 93e7aef6f3..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/update-proposal +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "UpdateProposalShelley", - "description": "", - "cborHex": "82a1581ca2512fa96a5f51d7aa8b8558669561fdd905f505ad7e0f4047b15c9eb100197a6601197a6702197a6e03197a6804197a6d05197a6406197a6307197a6108197a6009d81e82197a5f1903e80ad81e82197a5b1a000186a00bd81e82197a591a000186a00cd81e82197a6f1a000186a00d82015820ee32869218e317d16b9cba9e8f0737e23a6c9328e71068f161e5cc3cf54c45be0e82197a6a197a6b0f197a6510197a62197a69" -} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/alonzo/genesis.alonzo.spec.json b/cardano-cli/test/cardano-cli-golden/files/input/alonzo/genesis.alonzo.spec.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/alonzo/genesis.alonzo.spec.json rename to cardano-cli/test/cardano-cli-golden/files/input/alonzo/genesis.alonzo.spec.json diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/alonzo/signing.key b/cardano-cli/test/cardano-cli-golden/files/input/alonzo/signing.key similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/alonzo/signing.key rename to cardano-cli/test/cardano-cli-golden/files/input/alonzo/signing.key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/byron/keys/byron.skey b/cardano-cli/test/cardano-cli-golden/files/input/byron/keys/byron.skey similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/byron/keys/byron.skey rename to cardano-cli/test/cardano-cli-golden/files/input/byron/keys/byron.skey diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/byron/keys/legacy.skey b/cardano-cli/test/cardano-cli-golden/files/input/byron/keys/legacy.skey similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/byron/keys/legacy.skey rename to cardano-cli/test/cardano-cli-golden/files/input/byron/keys/legacy.skey diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/byron/tx/legacy.tx b/cardano-cli/test/cardano-cli-golden/files/input/byron/tx/legacy.tx similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/byron/tx/legacy.tx rename to cardano-cli/test/cardano-cli-golden/files/input/byron/tx/legacy.tx diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/byron/tx/normal.tx b/cardano-cli/test/cardano-cli-golden/files/input/byron/tx/normal.tx similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/byron/tx/normal.tx rename to cardano-cli/test/cardano-cli-golden/files/input/byron/tx/normal.tx diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/byron/update-proposal b/cardano-cli/test/cardano-cli-golden/files/input/byron/update-proposal similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/byron/update-proposal rename to cardano-cli/test/cardano-cli-golden/files/input/byron/update-proposal diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/byron/votes/vote-no b/cardano-cli/test/cardano-cli-golden/files/input/byron/votes/vote-no similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/byron/votes/vote-no rename to cardano-cli/test/cardano-cli-golden/files/input/byron/votes/vote-no diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/byron/votes/vote-yes b/cardano-cli/test/cardano-cli-golden/files/input/byron/votes/vote-yes similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/byron/votes/vote-yes rename to cardano-cli/test/cardano-cli-golden/files/input/byron/votes/vote-yes diff --git a/cardano-cli/test/cardano-cli-golden/files/input/conway/cold1-cc.skey b/cardano-cli/test/cardano-cli-golden/files/input/conway/cold1-cc.skey new file mode 100644 index 0000000000..4b6b7ff107 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/conway/cold1-cc.skey @@ -0,0 +1,5 @@ +{ + "type": "ConstitutionalCommitteeColdSigningKey_ed25519", + "description": "Constitutional Committee Cold Signing Key", + "cborHex": "5820f213c36a77aea6174875b778d8cc60b4c5a3f47eb3a75c11effe64d2b7ce34db" +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/conway/genesis.conway.spec.json b/cardano-cli/test/cardano-cli-golden/files/input/conway/genesis.conway.spec.json new file mode 100644 index 0000000000..59ed2c5f43 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/conway/genesis.conway.spec.json @@ -0,0 +1,39 @@ +{ + "poolVotingThresholds": { + "pvtCommitteeNormal": 0, + "pvtCommitteeNoConfidence": 0, + "pvtHardForkInitiation": 0, + "pvtMotionNoConfidence": 0 + }, + "dRepVotingThresholds": { + "dvtMotionNoConfidence": 0, + "dvtCommitteeNormal": 0, + "dvtCommitteeNoConfidence": 0, + "dvtUpdateToConstitution": 0, + "dvtHardForkInitiation": 0, + "dvtPPNetworkGroup": 0, + "dvtPPEconomicGroup": 0, + "dvtPPTechnicalGroup": 0, + "dvtPPGovGroup": 0, + "dvtTreasuryWithdrawal": 0 + }, + "committeeMinSize": 0, + "committeeMaxTermLength": 0, + "govActionLifetime": 0, + "govActionDeposit": 0, + "dRepDeposit": 0, + "dRepActivity": 0, + "constitution": { + "anchor": { + "url": "", + "dataHash": "0000000000000000000000000000000000000000000000000000000000000000" + } + }, + "committee": { + "members": { + "keyHash-4e88cc2d27c364aaf90648a87dfb95f8ee103ba67fa1f12f5e86c42a": 1, + "scriptHash-4e88cc2d27c364aaf90648a87dfb95f8ee103ba67fa1f12f5e86c42a": 2 + }, + "quorum": 0.5 + } +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/conway/tx b/cardano-cli/test/cardano-cli-golden/files/input/conway/tx new file mode 100644 index 0000000000..159aa406c6 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/conway/tx @@ -0,0 +1,5 @@ +{ + "type": "Witnessed Tx ConwayEra", + "description": "Ledger Cddl Format", + "cborHex": "84a30081825820f62cd7bc15d8c6d2c8519fb8d13c57c0157ab6bab50af62bc63706feb966393d000182a20058390076619da7963eaa588252c45e960667a4647eed69135f51f5a10f2888d2c20ac07056fc8899c47d825cefd9dcf5efba150236e043262e2b43011b0000011764f7be07a200581d604088059bbeb6add02eecd0c6a2a52c06910f2a6b4ba0029e9fe6ed13011a00989680021a00028b79a100828258208dc60533b5dfa60a530955a696323a2ef4f14e8bc95a8f84cf6c441fea4234275840963b5af8b899f154f35cb9effe40474035dad7f403fe5b1a7e70690f69971683b7c99da2fab04e02a28a765815eab76b9c4c8f0cd5b407a8e1cd7e214478560f825820ccb96e5d87424375c30b5d1539be8beca496bd87f48d8a4111145c92575dc22458403531dba28f0eafdd77363efc135ec56ec2e118506b61a26c6f8089aa17402532afc2bd16d92009263b749d49cfe0b97289ba73293e1c18af0c1605cadbe5270cf5f6" +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/drep.skey b/cardano-cli/test/cardano-cli-golden/files/input/drep.skey deleted file mode 100644 index 2bffd0436e..0000000000 --- a/cardano-cli/test/cardano-cli-golden/files/input/drep.skey +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "DRepSigningKey_ed25519", - "description": "Delegate Representative Signing Key", - "cborHex": "58201872d334e12a3a062dbdc4f2a22dc77f6e88ba8ecb39d0a2e385375f15ba0005" -} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/governance/cc-cold.skey b/cardano-cli/test/cardano-cli-golden/files/input/governance/cc-cold.skey new file mode 100644 index 0000000000..e6b770c1de --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/governance/cc-cold.skey @@ -0,0 +1,5 @@ +{ + "type": "ConstitutionalCommitteeColdSigningKey_ed25519", + "description": "Constitutional Committee Cold Signing Key", + "cborHex": "5820ef19a7c87cf4979232da72647fe91f633facd4d1fa817712d6d978ddd68cde33" +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/governance/cc-cold.vkey b/cardano-cli/test/cardano-cli-golden/files/input/governance/cc-cold.vkey new file mode 100644 index 0000000000..4eddf8df63 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/governance/cc-cold.vkey @@ -0,0 +1,5 @@ +{ + "type": "ConstitutionalCommitteeColdVerificationKey_ed25519", + "description": "Constitutional Committee Cold Verification Key", + "cborHex": "582017c7526f7cd307a361f959b6ab2e7fa339852c9a08309b968023a0df9b84c47a" +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/governance/cc-hot.skey b/cardano-cli/test/cardano-cli-golden/files/input/governance/cc-hot.skey new file mode 100644 index 0000000000..a05aa80ce2 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/governance/cc-hot.skey @@ -0,0 +1,5 @@ +{ + "type": "ConstitutionalCommitteeHotSigningKey_ed25519", + "description": "Constitutional Committee Hot Signing Key", + "cborHex": "5820d2039207db7cff9dad95b0f98bfe2aea192e9d159e7c0e9a1f31bd2dc8cd4b47" +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/governance/cc-hot.vkey b/cardano-cli/test/cardano-cli-golden/files/input/governance/cc-hot.vkey new file mode 100644 index 0000000000..eb1093626e --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/governance/cc-hot.vkey @@ -0,0 +1,5 @@ +{ + "type": "ConstitutionalCommitteeHotVerificationKey_ed25519", + "description": "Constitutional Committee Hot Verification Key", + "cborHex": "58202b35e914764560fcf7655523d303d8cf27fc8306b6e86891802feedcfa087715" +} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/create/basic.json b/cardano-cli/test/cardano-cli-golden/files/input/governance/create/basic.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/create/basic.json rename to cardano-cli/test/cardano-cli-golden/files/input/governance/create/basic.json diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/create/long-text.json b/cardano-cli/test/cardano-cli-golden/files/input/governance/create/long-text.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/create/long-text.json rename to cardano-cli/test/cardano-cli-golden/files/input/governance/create/long-text.json diff --git a/cardano-cli/test/cardano-cli-golden/files/input/governance/hot-auth.cert b/cardano-cli/test/cardano-cli-golden/files/input/governance/hot-auth.cert new file mode 100644 index 0000000000..00f33ccd39 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/governance/hot-auth.cert @@ -0,0 +1,5 @@ +{ + "type": "CertificateShelley", + "description": "Constitutional Committee Hot Key Registration Certificate", + "cborHex": "830e8200581c9c0682d5a71b1496ccbe4a79c332fcbc7cb317ec3b8faf6d45723e408200581cbb0fe4aca8548f6fd2050e5bd1b419d12bac166f3719b4959f323908" +} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json b/cardano-cli/test/cardano-cli-golden/files/input/governance/polls/basic.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json rename to cardano-cli/test/cardano-cli-golden/files/input/governance/polls/basic.json diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/verify/valid b/cardano-cli/test/cardano-cli-golden/files/input/governance/verify/valid similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/verify/valid rename to cardano-cli/test/cardano-cli-golden/files/input/governance/verify/valid diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/key/non-extended-keys/shelley.000.vkey b/cardano-cli/test/cardano-cli-golden/files/input/key/non-extended-keys/shelley.000.vkey similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/key/non-extended-keys/shelley.000.vkey rename to cardano-cli/test/cardano-cli-golden/files/input/key/non-extended-keys/shelley.000.vkey diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/key/non-extended-keys/stake.000.vkey b/cardano-cli/test/cardano-cli-golden/files/input/key/non-extended-keys/stake.000.vkey similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/key/non-extended-keys/stake.000.vkey rename to cardano-cli/test/cardano-cli-golden/files/input/key/non-extended-keys/stake.000.vkey diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/mary/scripts/mint.all b/cardano-cli/test/cardano-cli-golden/files/input/mary/scripts/mint.all similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/mary/scripts/mint.all rename to cardano-cli/test/cardano-cli-golden/files/input/mary/scripts/mint.all diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/mary/scripts/mint.sig b/cardano-cli/test/cardano-cli-golden/files/input/mary/scripts/mint.sig similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/mary/scripts/mint.sig rename to cardano-cli/test/cardano-cli-golden/files/input/mary/scripts/mint.sig diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/addresses/enterprise-address.hex b/cardano-cli/test/cardano-cli-golden/files/input/shelley/addresses/enterprise-address.hex similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/addresses/enterprise-address.hex rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/addresses/enterprise-address.hex diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/addresses/staking-address.hex b/cardano-cli/test/cardano-cli-golden/files/input/shelley/addresses/staking-address.hex similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/addresses/staking-address.hex rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/addresses/staking-address.hex diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/certificates/genesis_key_delegation_certificate b/cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/genesis_key_delegation_certificate similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/certificates/genesis_key_delegation_certificate rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/genesis_key_delegation_certificate diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/certificates/mir_certificate b/cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/mir_certificate similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/certificates/mir_certificate rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/mir_certificate diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/certificates/operational_certificate b/cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/operational_certificate similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/certificates/operational_certificate rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/operational_certificate diff --git a/cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/stake_address_delegation_certificate b/cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/stake_address_delegation_certificate new file mode 100644 index 0000000000..34cf5f0d95 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/stake_address_delegation_certificate @@ -0,0 +1,5 @@ +{ + "type": "CertificateShelley", + "description": "Stake Address Delegation Certificate", + "cborHex": "83028200581c6b69790498faca4908e4b44a1005d6dbec9a3d511fa62d4636355ff1581c4124a0c2ba8a7ba05824b3df23f706a1c8b3239446ab16709ae85aa1" +} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/certificates/stake_address_deregistration_certificate b/cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/stake_address_deregistration_certificate similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/certificates/stake_address_deregistration_certificate rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/stake_address_deregistration_certificate diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/certificates/stake_address_registration_certificate b/cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/stake_address_registration_certificate similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/certificates/stake_address_registration_certificate rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/stake_address_registration_certificate diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/certificates/stake_pool_deregistration_certificate b/cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/stake_pool_deregistration_certificate similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/certificates/stake_pool_deregistration_certificate rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/stake_pool_deregistration_certificate diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/certificates/stake_pool_registration_certificate b/cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/stake_pool_registration_certificate similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/certificates/stake_pool_registration_certificate rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/certificates/stake_pool_registration_certificate diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/genesis/genesis.spec.json b/cardano-cli/test/cardano-cli-golden/files/input/shelley/genesis/genesis.spec.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/genesis/genesis.spec.json rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/genesis/genesis.spec.json diff --git a/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/cold.vk b/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/cold.vk new file mode 100644 index 0000000000..a58782c085 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/cold.vk @@ -0,0 +1,5 @@ +{ + "type": "StakePoolVerificationKey_ed25519", + "description": "Stake Pool Operator Verification Key", + "cborHex": "582029ade2115fbcbc17f063eec41ec0d358ccc5b52c2bccb47c0918727695619a68" +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/create/basic.json b/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/create/basic.json new file mode 100644 index 0000000000..35c4821c3e --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/create/basic.json @@ -0,0 +1,41 @@ +{ + "94": { + "map": [ + { + "k": { + "int": 0 + }, + "v": { + "list": [ + { + "string": "Pineapples on pizza?" + } + ] + } + }, + { + "k": { + "int": 1 + }, + "v": { + "list": [ + { + "list": [ + { + "string": "yes" + } + ] + }, + { + "list": [ + { + "string": "no" + } + ] + } + ] + } + } + ] + } +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/create/long-text.json b/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/create/long-text.json new file mode 100644 index 0000000000..4adc595572 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/create/long-text.json @@ -0,0 +1,47 @@ +{ + "94": { + "map": [ + { + "k": { + "int": 0 + }, + "v": { + "list": [ + { + "string": "What is the most adequate topping to put on a pizza (please cons" + }, + { + "string": "ider all possibilities and take time to answer)?" + } + ] + } + }, + { + "k": { + "int": 1 + }, + "v": { + "list": [ + { + "list": [ + { + "string": "pineapples" + } + ] + }, + { + "list": [ + { + "string": "only traditional topics should go on a pizza, this isn't room fo" + }, + { + "string": "r jokes" + } + ] + } + ] + } + } + ] + } +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/polls/basic.answer.0.json b/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/polls/basic.answer.0.json new file mode 100644 index 0000000000..d327ecda03 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/polls/basic.answer.0.json @@ -0,0 +1,22 @@ +{ + "94": { + "map": [ + { + "k": { + "int": 2 + }, + "v": { + "bytes": "29093fd43fc30ba31e306af06ce8537390e1668ae7496fe53d53684683c3762c" + } + }, + { + "k": { + "int": 3 + }, + "v": { + "int": 0 + } + } + ] + } +} \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/answer/basic.json b/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/polls/basic.answer.1.json similarity index 99% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/answer/basic.json rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/polls/basic.answer.1.json index 9bdbb2b0b8..d5e0b3312b 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/governance/answer/basic.json +++ b/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/polls/basic.answer.1.json @@ -19,4 +19,4 @@ } ] } -} +} \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/polls/basic.json b/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/polls/basic.json new file mode 100644 index 0000000000..8bca376771 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/polls/basic.json @@ -0,0 +1,5 @@ +{ + "type": "GovernancePoll", + "description": "An on-chain poll for SPOs: Pineapples on pizza?", + "cborHex": "a1185ea200817450696e656170706c6573206f6e2070697a7a613f0182816379657381626e6f" +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/verify/valid b/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/verify/valid new file mode 100644 index 0000000000..7406268cbd --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/shelley/governance/verify/valid @@ -0,0 +1,5 @@ +{ + "type": "Witnessed Tx BabbageEra", + "description": "Ledger Cddl Format", + "cborHex": "84a50081825820000000000000000000000000000000000000000000000000000000000000000000018002000e81581cf8db28823f8ebd01a2d9e24efb2f0d18e387665770274513e370b5d50758201ea2695790e7d9d0404cee31558ac032e4dd80f1fe971f96d496c73d41ad9d38a1008182582029ade2115fbcbc17f063eec41ec0d358ccc5b52c2bccb47c0918727695619a68584015c6bf278505e6a47f8221737ef475da4b1cd11779eac98edc72824a8c1746525e73a6def3fa1a725e57f90674c9494ee99bd42544fccc3ea06a594a21a65d0ef5d90103a100a1185ea202582029093fd43fc30ba31e306af06ce8537390e1668ae7496fe53d53684683c3762c0301" +} diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/extended_payment_keys/signing_key b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/extended_payment_keys/signing_key similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/extended_payment_keys/signing_key rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/extended_payment_keys/signing_key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/extended_payment_keys/verification_key b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/extended_payment_keys/verification_key similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/extended_payment_keys/verification_key rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/extended_payment_keys/verification_key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_delegate_keys/operational_certificate_counter b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_delegate_keys/operational_certificate_counter similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_delegate_keys/operational_certificate_counter rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_delegate_keys/operational_certificate_counter diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_delegate_keys/signing_key b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_delegate_keys/signing_key similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_delegate_keys/signing_key rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_delegate_keys/signing_key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_delegate_keys/verification_key b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_delegate_keys/verification_key similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_delegate_keys/verification_key rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_delegate_keys/verification_key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_keys/signing_key b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_keys/signing_key similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_keys/signing_key rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_keys/signing_key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_keys/verification_key b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_keys/verification_key similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_keys/verification_key rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_keys/verification_key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_keys/verification_key.key-hash b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_keys/verification_key.key-hash similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_keys/verification_key.key-hash rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_keys/verification_key.key-hash diff --git a/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_utxo_hashes/utxo_hash b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_utxo_hashes/utxo_hash new file mode 100644 index 0000000000..67701828dc --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_utxo_hashes/utxo_hash @@ -0,0 +1 @@ +a8905555bf684e27ffbe192c412bf979d120d4788e6e5ccbe8c19cb03906342b#0 diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_utxo_keys/signing_key b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_utxo_keys/signing_key similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_utxo_keys/signing_key rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_utxo_keys/signing_key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_utxo_keys/verification_key b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_utxo_keys/verification_key similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_utxo_keys/verification_key rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_utxo_keys/verification_key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_verification_keys/genesis-utxo.vkey b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_verification_keys/genesis-utxo.vkey similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/genesis_verification_keys/genesis-utxo.vkey rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/genesis_verification_keys/genesis-utxo.vkey diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/kes_keys/signing_key b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/kes_keys/signing_key similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/kes_keys/signing_key rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/kes_keys/signing_key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/kes_keys/verification_key b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/kes_keys/verification_key similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/kes_keys/verification_key rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/kes_keys/verification_key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/payment_keys/signing_key b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/payment_keys/signing_key similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/payment_keys/signing_key rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/payment_keys/signing_key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/payment_keys/verification_key b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/payment_keys/verification_key similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/payment_keys/verification_key rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/payment_keys/verification_key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/reward_address b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/stake_keys/reward_address similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/reward_address rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/stake_keys/reward_address diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/signing_key b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/stake_keys/signing_key similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/signing_key rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/stake_keys/signing_key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/verification_key b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/stake_keys/verification_key similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/stake_keys/verification_key rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/stake_keys/verification_key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/vrf_keys/signing_key b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/vrf_keys/signing_key similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/vrf_keys/signing_key rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/vrf_keys/signing_key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/vrf_keys/verification_key b/cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/vrf_keys/verification_key similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/keys/vrf_keys/verification_key rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/keys/vrf_keys/verification_key diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/metadata/stake_pool_metadata_hash b/cardano-cli/test/cardano-cli-golden/files/input/shelley/metadata/stake_pool_metadata_hash similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/metadata/stake_pool_metadata_hash rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/metadata/stake_pool_metadata_hash diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/multisig/addresses/all b/cardano-cli/test/cardano-cli-golden/files/input/shelley/multisig/addresses/all similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/multisig/addresses/all rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/multisig/addresses/all diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/multisig/addresses/any b/cardano-cli/test/cardano-cli-golden/files/input/shelley/multisig/addresses/any similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/multisig/addresses/any rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/multisig/addresses/any diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/multisig/scripts/all b/cardano-cli/test/cardano-cli-golden/files/input/shelley/multisig/scripts/all similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/multisig/scripts/all rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/multisig/scripts/all diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/multisig/scripts/any b/cardano-cli/test/cardano-cli-golden/files/input/shelley/multisig/scripts/any similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/multisig/scripts/any rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/multisig/scripts/any diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/multisig/scripts/atleast b/cardano-cli/test/cardano-cli-golden/files/input/shelley/multisig/scripts/atleast similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/multisig/scripts/atleast rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/multisig/scripts/atleast diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/node-pool/operator.vkey b/cardano-cli/test/cardano-cli-golden/files/input/shelley/node-pool/operator.vkey similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/node-pool/operator.vkey rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/node-pool/operator.vkey diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/node-pool/owner.vkey b/cardano-cli/test/cardano-cli-golden/files/input/shelley/node-pool/owner.vkey similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/node-pool/owner.vkey rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/node-pool/owner.vkey diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/node-pool/vrf.vkey b/cardano-cli/test/cardano-cli-golden/files/input/shelley/node-pool/vrf.vkey similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/node-pool/vrf.vkey rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/node-pool/vrf.vkey diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-calculate-min-fee/protocol-params.json b/cardano-cli/test/cardano-cli-golden/files/input/shelley/transaction-calculate-min-fee/protocol-params.json similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-calculate-min-fee/protocol-params.json rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/transaction-calculate-min-fee/protocol-params.json diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-sign/node-cold.skey b/cardano-cli/test/cardano-cli-golden/files/input/shelley/transaction-sign/node-cold.skey similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-sign/node-cold.skey rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/transaction-sign/node-cold.skey diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-sign/stake.skey b/cardano-cli/test/cardano-cli-golden/files/input/shelley/transaction-sign/stake.skey similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-sign/stake.skey rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/transaction-sign/stake.skey diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-sign/utxo.skey b/cardano-cli/test/cardano-cli-golden/files/input/shelley/transaction-sign/utxo.skey similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/transaction-sign/utxo.skey rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/transaction-sign/utxo.skey diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/tx/txbody b/cardano-cli/test/cardano-cli-golden/files/input/shelley/tx/txbody similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/tx/txbody rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/tx/txbody diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/tx/unsigned.tx b/cardano-cli/test/cardano-cli-golden/files/input/shelley/tx/unsigned.tx similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/tx/unsigned.tx rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/tx/unsigned.tx diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/shelley/witnesses/singleSigningKeyWitness b/cardano-cli/test/cardano-cli-golden/files/input/shelley/witnesses/singleSigningKeyWitness similarity index 100% rename from cardano-cli/test/cardano-cli-golden/files/golden/shelley/witnesses/singleSigningKeyWitness rename to cardano-cli/test/cardano-cli-golden/files/input/shelley/witnesses/singleSigningKeyWitness diff --git a/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Util.hs b/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Util.hs index a231278625..f3331e534f 100644 --- a/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Util.hs +++ b/cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Util.hs @@ -32,7 +32,11 @@ import Data.Monoid (Last (..)) import Data.Text (Text) import GHC.Stack (CallStack, HasCallStack) import qualified GHC.Stack as GHC +import qualified System.Directory as IO +import qualified System.Environment as IO import qualified System.Exit as IO +import System.FilePath (takeDirectory) +import qualified System.IO.Unsafe as IO import qualified System.Process as IO import System.Process (CreateProcess) @@ -148,12 +152,35 @@ checkTxCddlFormat -> FilePath -- ^ Newly created file -> m () checkTxCddlFormat referencePath createdPath = do - reference <- H.evalIO $ fileOrPipe referencePath - created <- H.evalIO $ fileOrPipe createdPath - r <- H.evalIO $ readCddlTx reference - c <- H.evalIO $ readCddlTx created - r H.=== c + fileExists <- liftIO $ IO.doesFileExist referencePath + + if fileExists + then do + reference <- H.evalIO $ fileOrPipe referencePath + created <- H.evalIO $ fileOrPipe createdPath + r <- H.evalIO $ readCddlTx reference + c <- H.evalIO $ readCddlTx created + r H.=== c + else if createFiles + then do + -- CREATE_GOLDEN_FILES is set, so we create any golden files that don't + -- already exist. + H.note_ $ "Creating golden file " <> referencePath + H.createDirectoryIfMissing_ (takeDirectory referencePath) + H.readFile createdPath >>= H.writeFile referencePath + else do + H.note_ $ mconcat + [ "Golden file " <> referencePath + , " does not exist. To create, run with CREATE_GOLDEN_FILES=1" + ] + H.failure + +-- | Whether the test should create the golden files if the file does ont exist. +createFiles :: Bool +createFiles = IO.unsafePerformIO $ do + value <- IO.lookupEnv "CREATE_GOLDEN_FILES" + return $ value == Just "1" -------------------------------------------------------------------------------- -- Helpers, Error rendering & Clean up diff --git a/flake.lock b/flake.lock index 35475114bc..0d964fa376 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1695809408, - "narHash": "sha256-3RLFxpAhvZGPq+K0MrHOC46eFeXTfMevxWYHTCY8kpo=", + "lastModified": 1696532530, + "narHash": "sha256-Tabp1I371941jDRh+5X7/zp4cxKACt3H4hrXR5TdA8Y=", "owner": "input-output-hk", "repo": "cardano-haskell-packages", - "rev": "1198d4af66ccbdf2d744bdd705f1a7af6be5effb", + "rev": "6d33ceace68c32707cb6a5d08483dd7c35059f31", "type": "github" }, "original": {