diff --git a/cabal.project b/cabal.project index c91076e926..fee28e5cad 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-10-27T12:25:48Z + , cardano-haskell-packages 2023-11-03T08:46:06Z packages: cardano-cli diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 91155427e4..6c20d6859d 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -202,7 +202,7 @@ library , binary , bytestring , canonical-json - , cardano-api ^>= 8.29.0.0 + , cardano-api ^>= 8.30.0.0 , cardano-binary , cardano-crypto , cardano-crypto-class ^>= 2.1.2 diff --git a/cardano-cli/src/Cardano/CLI/Byron/Run.hs b/cardano-cli/src/Cardano/CLI/Byron/Run.hs index 0aa26a0e62..3437ff00a3 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Run.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Run.hs @@ -177,7 +177,7 @@ runSubmitTx nodeSocketPath network fp = do runGetTxId :: TxFile In -> ExceptT ByronClientCmdError IO () runGetTxId fp = firstExceptT ByronCmdTxError $ do tx <- readByronTx fp - let txbody = getTxBody (ByronTx tx) + let txbody = getTxBody (ByronTx ByronEraOnlyByron tx) txid = getTxId txbody liftIO $ BS.putStrLn $ serialiseToRawBytesHex txid diff --git a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs index 1518ab6be2..a70be26fdf 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs @@ -244,12 +244,12 @@ nodeSubmitTx nodeSocketPath network gentx = do localNodeNetworkId = network, localConsensusModeParams = CardanoModeParams (EpochSlots 21600) } - res <- liftIO $ submitTxToNodeLocal connctInfo (TxInByronSpecial gentx ByronEraInCardanoMode) + res <- liftIO $ submitTxToNodeLocal connctInfo (TxInByronSpecial ByronEraOnlyByron gentx) case res of Net.Tx.SubmitSuccess -> liftIO $ Text.putStrLn "Transaction successfully submitted." Net.Tx.SubmitFail reason -> case reason of - TxValidationErrorInMode err _eraInMode -> left . ByronTxSubmitError . Text.pack $ show err + TxValidationErrorInCardanoMode err -> left . ByronTxSubmitError . Text.pack $ show err TxValidationEraMismatch mismatchErr -> left $ ByronTxSubmitErrorEraMismatch mismatchErr return () diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs index 06e8de96f9..5a3ffbc4e2 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Query.hs @@ -61,7 +61,7 @@ data QueryCmds era data QueryLeadershipScheduleCmdArgs = QueryLeadershipScheduleCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , genesisFp :: !GenesisFile , poolColdVerKeyFile :: !(VerificationKeyOrHashOrFile StakePoolKey) @@ -72,42 +72,42 @@ data QueryLeadershipScheduleCmdArgs = QueryLeadershipScheduleCmdArgs data QueryProtocolParametersCmdArgs = QueryProtocolParametersCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) data QueryConstitutionHashCmdArgs = QueryConstitutionHashCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) data QueryTipCmdArgs = QueryTipCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) data QueryStakePoolsCmdArgs = QueryStakePoolsCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) data QueryStakeDistributionCmdArgs = QueryStakeDistributionCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) data QueryStakeAddressInfoCmdArgs = QueryStakeAddressInfoCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , addr :: !StakeAddress , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) @@ -115,7 +115,7 @@ data QueryStakeAddressInfoCmdArgs = QueryStakeAddressInfoCmdArgs data QueryUTxOCmdArgs = QueryUTxOCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , queryFilter :: !QueryUTxOFilter , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) @@ -123,21 +123,21 @@ data QueryUTxOCmdArgs = QueryUTxOCmdArgs data QueryLedgerStateCmdArgs = QueryLedgerStateCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) data QueryProtocolStateCmdArgs = QueryProtocolStateCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) data QueryStakeSnapshotCmdArgs = QueryStakeSnapshotCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , allOrOnlyPoolIds :: !(AllOrOnly [Hash StakePoolKey]) , mOutFile :: !(Maybe (File () Out)) @@ -145,7 +145,7 @@ data QueryStakeSnapshotCmdArgs = QueryStakeSnapshotCmdArgs data QueryKesPeriodInfoCmdArgs = QueryKesPeriodInfoCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , nodeOpCertFp :: !(File () In) -- ^ Node operational certificate , mOutFile :: !(Maybe (File () Out)) @@ -153,14 +153,14 @@ data QueryKesPeriodInfoCmdArgs = QueryKesPeriodInfoCmdArgs data QueryPoolStateCmdArgs = QueryPoolStateCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , poolIds :: ![Hash StakePoolKey] } deriving (Generic, Show) data QueryTxMempoolCmdArgs = QueryTxMempoolCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , query :: !TxMempoolQuery , mOutFile :: !(Maybe (File () Out)) @@ -169,7 +169,7 @@ data QueryTxMempoolCmdArgs = QueryTxMempoolCmdArgs data QuerySlotNumberCmdArgs = QuerySlotNumberCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , utcTime :: !UTCTime } deriving (Generic, Show) @@ -177,7 +177,7 @@ data QuerySlotNumberCmdArgs = QuerySlotNumberCmdArgs data QueryNoArgCmdArgs era = QueryNoArgCmdArgs { eon :: !(ConwayEraOnwards era) , nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) } deriving Show @@ -185,7 +185,7 @@ data QueryNoArgCmdArgs era = QueryNoArgCmdArgs data QueryDRepStateCmdArgs era = QueryDRepStateCmdArgs { eon :: !(ConwayEraOnwards era) , nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , drepKeys :: ![VerificationKeyOrHashOrFile DRepKey] , mOutFile :: !(Maybe (File () Out)) @@ -194,7 +194,7 @@ data QueryDRepStateCmdArgs era = QueryDRepStateCmdArgs data QueryDRepStakeDistributionCmdArgs era = QueryDRepStakeDistributionCmdArgs { eon :: !(ConwayEraOnwards era) , nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , drepKeys :: ![VerificationKeyOrHashOrFile DRepKey] , mOutFile :: !(Maybe (File () Out)) @@ -203,7 +203,7 @@ data QueryDRepStakeDistributionCmdArgs era = QueryDRepStakeDistributionCmdArgs data QueryCommitteeMembersStateCmdArgs era = QueryCommitteeMembersStateCmdArgs { eon :: !(ConwayEraOnwards era) , nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , committeeColdKeys :: ![VerificationKeyOrHashOrFile CommitteeColdKey] , committeeHotKeys :: ![VerificationKeyOrHashOrFile CommitteeHotKey] diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs index 8919f2dedd..2002f6fdb5 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Transaction.hs @@ -84,7 +84,7 @@ data TransactionBuildRawCmdArgs era = TransactionBuildRawCmdArgs data TransactionBuildCmdArgs era = TransactionBuildCmdArgs { eon :: !(ShelleyBasedEra era) , nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , mScriptValidity :: !(Maybe ScriptValidity) -- ^ Mark script as expected to pass or fail validation @@ -148,7 +148,7 @@ data TransactionSignWitnessCmdArgs = TransactionSignWitnessCmdArgs data TransactionSubmitCmdArgs = TransactionSubmitCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , txFile :: !FilePath } deriving Show diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index 896a35364a..be8a3a1a2c 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -109,7 +109,7 @@ toUnitIntervalOrErr r = case Ledger.boundRational r of ] Just n -> n -pConsensusModeParams :: Parser (ConsensusModeParams CardanoMode) +pConsensusModeParams :: Parser ConsensusModeParams pConsensusModeParams = asum [ pCardanoMode *> pCardanoConsensusMode , pDefaultConsensusMode @@ -122,10 +122,10 @@ pConsensusModeParams = asum , Opt.help "For talking to a node running in full Cardano mode (default)." ] - pCardanoConsensusMode :: Parser (ConsensusModeParams CardanoMode) + pCardanoConsensusMode :: Parser ConsensusModeParams pCardanoConsensusMode = CardanoModeParams <$> pEpochSlots - pDefaultConsensusMode :: Parser (ConsensusModeParams CardanoMode) + pDefaultConsensusMode :: Parser ConsensusModeParams pDefaultConsensusMode = pure . CardanoModeParams $ EpochSlots defaultByronEpochSlots diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs index 43cf4d76c4..cb06d0c17c 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs @@ -144,15 +144,12 @@ runQueryConstitutionHashCmd let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath result <- liftIO $ executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do - AnyCardanoEra era <- lift (determineEraExpr consensusModeParams) - & onLeft (left . QueryCmdUnsupportedNtcVersion) + AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) sbe <- requireShelleyBasedEra era & onNothing (left QueryCmdByronEra) - let eraInMode = toEraInCardanoMode era - - lift (shelleyBasedEraConstraints sbe (queryConstitutionHash eraInMode sbe)) + lift (shelleyBasedEraConstraints sbe (queryConstitutionHash sbe)) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdEraMismatch) @@ -180,15 +177,11 @@ runQueryProtocolParametersCmd , Cmd.mOutFile } = do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath - AnyCardanoEra era <- firstExceptT QueryCmdAcquireFailure $ newExceptT $ determineEra consensusModeParams localNodeConnInfo - sbe <- case cardanoEraStyle era of - LegacyByronEra -> left QueryCmdByronEra - ShelleyBasedEra sbe -> return sbe - let eraInMode = toEraInCardanoMode era - - let qInMode = QueryInEra eraInMode $ QueryInShelleyBasedEra sbe Api.QueryProtocolParameters + AnyCardanoEra era <- firstExceptT QueryCmdAcquireFailure $ newExceptT $ determineEra localNodeConnInfo + sbe <- forEraInEon @ShelleyBasedEra era (left QueryCmdByronEra) pure + let qInMode = QueryInEra $ QueryInShelleyBasedEra sbe Api.QueryProtocolParameters pp <- firstExceptT QueryCmdConvenienceError - . newExceptT $ executeQueryAnyMode era localNodeConnInfo qInMode + . newExceptT $ executeQueryAnyMode localNodeConnInfo qInMode writeProtocolParameters sbe mOutFile pp where -- TODO: Conway era - use ledger PParams JSON @@ -233,7 +226,7 @@ relativeTimeSeconds (RelativeTime dt) = floor (nominalDiffTimeToSeconds dt) -- | Query the chain tip via the chain sync protocol. -- -- This is a fallback query to support older versions of node to client protocol. -queryChainTipViaChainSync :: MonadIO m => LocalNodeConnectInfo mode -> m ChainTip +queryChainTipViaChainSync :: MonadIO m => LocalNodeConnectInfo -> m ChainTip queryChainTipViaChainSync localNodeConnInfo = do liftIO . T.hPutStrLn IO.stderr $ "Warning: Local header state query unavailable. Falling back to chain sync query" @@ -337,15 +330,13 @@ runQueryUTxOCmd join $ lift ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do - AnyCardanoEra era <- lift (determineEraExpr consensusModeParams) + AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) sbe <- requireShelleyBasedEra era & onNothing (left QueryCmdByronEra) - let eraInMode = toEraInCardanoMode era - - utxo <- lift (queryUtxo eraInMode sbe queryFilter) + utxo <- lift (queryUtxo sbe queryFilter) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError) @@ -373,17 +364,15 @@ runQueryKesPeriodInfoCmd join $ lift ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do - AnyCardanoEra era <- lift (determineEraExpr consensusModeParams) + AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) sbe <- requireShelleyBasedEra era & onNothing (left QueryCmdByronEra) - let eraInMode = toEraInCardanoMode era - -- We check that the KES period specified in the operational certificate is correct -- based on the KES period defined in the genesis parameters and the current slot number - gParams <- lift (queryGenesisParameters eraInMode sbe) + gParams <- lift (queryGenesisParameters sbe) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError) @@ -394,7 +383,7 @@ runQueryKesPeriodInfoCmd -- We get the operational certificate counter from the protocol state and check that -- it is equivalent to what we have on disk. - ptclState <- lift (queryProtocolState eraInMode sbe) + ptclState <- lift (queryProtocolState sbe) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError) @@ -642,15 +631,13 @@ runQueryPoolStateCmd join $ lift ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do - AnyCardanoEra era <- lift (determineEraExpr consensusModeParams) + AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) sbe <- requireShelleyBasedEra era & onNothing (left QueryCmdByronEra) - let eraInMode = toEraInCardanoMode era - - result <- lift (queryPoolState eraInMode sbe $ Just $ Set.fromList poolIds) + result <- lift (queryPoolState sbe $ Just $ Set.fromList poolIds) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError) @@ -676,11 +663,9 @@ runQueryTxMempoolCmd localQuery <- case query of TxMempoolQueryTxExists tx -> do - AnyCardanoEra era <- lift (executeLocalStateQueryExpr localNodeConnInfo Nothing (determineEraExpr consensusModeParams)) + AnyCardanoEra era <- lift (determineEra localNodeConnInfo) & onLeft (left . QueryCmdAcquireFailure) - & onLeft (left . QueryCmdUnsupportedNtcVersion) - let eraInMode = toEraInCardanoMode era - pure $ LocalTxMonitoringQueryTx $ TxIdInMode tx eraInMode + pure $ LocalTxMonitoringQueryTx $ TxIdInMode era tx TxMempoolQueryNextTx -> pure LocalTxMonitoringSendNextTx TxMempoolQueryInfo -> pure LocalTxMonitoringMempoolInformation @@ -722,19 +707,17 @@ runQueryStakeSnapshotCmd join $ lift ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do - AnyCardanoEra era <- lift (determineEraExpr consensusModeParams) + AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) sbe <- requireShelleyBasedEra era & onNothing (left QueryCmdByronEra) - let eraInMode = toEraInCardanoMode era - let poolFilter = case allOrOnlyPoolIds of All -> Nothing Only poolIds -> Just $ Set.fromList poolIds - result <- lift (queryStakeSnapshot eraInMode sbe poolFilter) + result <- lift (queryStakeSnapshot sbe poolFilter) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError) @@ -758,15 +741,13 @@ runQueryLedgerStateCmd join $ lift ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do - AnyCardanoEra era <- lift (determineEraExpr consensusModeParams) + AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) sbe <- requireShelleyBasedEra era & onNothing (left QueryCmdByronEra) - let eraInMode = toEraInCardanoMode era - - result <- lift (queryDebugLedgerState eraInMode sbe) + result <- lift (queryDebugLedgerState sbe) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError) @@ -790,15 +771,13 @@ runQueryProtocolStateCmd join $ lift ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do - AnyCardanoEra era <- lift (determineEraExpr consensusModeParams) + AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) sbe <- requireShelleyBasedEra era & onNothing (left QueryCmdByronEra) - let eraInMode = toEraInCardanoMode era - - result <- lift (queryProtocolState eraInMode sbe) + result <- lift (queryProtocolState sbe) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError) @@ -825,21 +804,19 @@ runQueryStakeAddressInfoCmd join $ lift ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do - AnyCardanoEra era <- lift (determineEraExpr consensusModeParams) + AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) sbe <- requireShelleyBasedEra era & onNothing (left QueryCmdByronEra) - let eraInMode = toEraInCardanoMode era - let stakeAddr = Set.singleton $ fromShelleyStakeCredential addr - (stakeRewardAccountBalances, stakePools) <- lift (queryStakeAddresses eraInMode sbe stakeAddr networkId) + (stakeRewardAccountBalances, stakePools) <- lift (queryStakeAddresses sbe stakeAddr networkId) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError) - stakeDelegDeposits <- lift (queryStakeDelegDeposits eraInMode sbe stakeAddr) + stakeDelegDeposits <- lift (queryStakeDelegDeposits sbe stakeAddr) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError) @@ -1091,12 +1068,10 @@ runQueryStakePoolsCmd ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT @QueryCmdError $ do AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) - let eraInMode = toEraInCardanoMode era - sbe <- requireShelleyBasedEra era & onNothing (left QueryCmdByronEra) - poolIds <- lift (queryStakePools eraInMode sbe) + poolIds <- lift (queryStakePools sbe) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdEraMismatch) @@ -1131,15 +1106,13 @@ runQueryStakeDistributionCmd join $ lift ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do - AnyCardanoEra era <- lift (determineEraExpr consensusModeParams) + AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) sbe <- requireShelleyBasedEra era & onNothing (left QueryCmdByronEra) - let eraInMode = toEraInCardanoMode era - - result <- lift (queryStakeDistribution eraInMode sbe) + result <- lift (queryStakeDistribution sbe) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError) @@ -1211,19 +1184,17 @@ runQueryLeadershipScheduleCmd join $ lift ( executeLocalStateQueryExpr localNodeConnInfo Nothing $ runExceptT $ do - AnyCardanoEra era <- lift (determineEraExpr consensusModeParams) + AnyCardanoEra era <- lift queryCurrentEra & onLeft (left . QueryCmdUnsupportedNtcVersion) sbe <- requireShelleyBasedEra era & onNothing (left QueryCmdByronEra) - let eraInMode = toEraInCardanoMode era - - pparams <- lift (queryProtocolParameters eraInMode sbe) + pparams <- lift (queryProtocolParameters sbe) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError) - ptclState <- lift (queryProtocolState eraInMode sbe) + ptclState <- lift (queryProtocolState sbe) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError) @@ -1232,13 +1203,13 @@ runQueryLeadershipScheduleCmd let eInfo = toEpochInfo eraHistory - curentEpoch <- lift (queryEpoch eraInMode sbe) + curentEpoch <- lift (queryEpoch sbe) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError) case whichSchedule of CurrentEpoch -> do - serCurrentEpochState <- lift (queryPoolDistribution eraInMode sbe (Just (Set.singleton poolid))) + serCurrentEpochState <- lift (queryPoolDistribution sbe (Just (Set.singleton poolid))) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError) @@ -1259,7 +1230,7 @@ runQueryLeadershipScheduleCmd writeSchedule mOutFile eInfo shelleyGenesis schedule NextEpoch -> do - serCurrentEpochState <- lift (queryCurrentEpochState eraInMode sbe) + serCurrentEpochState <- lift (queryCurrentEpochState sbe) & onLeft (left . QueryCmdUnsupportedNtcVersion) & onLeft (left . QueryCmdLocalStateQueryError . EraMismatchError) @@ -1356,11 +1327,8 @@ runQueryConstitution } = conwayEraOnwardsConstraints eon $ do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath sbe = conwayEraOnwardsToShelleyBasedEra eon - cEra = conwayEraOnwardsToCardanoEra eon - - let eraInMode = toEraInCardanoMode cEra - constitution <- runQuery localNodeConnInfo $ queryConstitution eraInMode sbe + constitution <- runQuery localNodeConnInfo $ queryConstitution sbe writeOutput mOutFile constitution runQueryGovState @@ -1376,11 +1344,8 @@ runQueryGovState } = conwayEraOnwardsConstraints eon $ do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath sbe = conwayEraOnwardsToShelleyBasedEra eon - cEra = conwayEraOnwardsToCardanoEra eon - let eraInMode = toEraInCardanoMode cEra - - govState <- runQuery localNodeConnInfo $ queryGovState eraInMode sbe + govState <- runQuery localNodeConnInfo $ queryGovState sbe writeOutput mOutFile govState runQueryDRepState @@ -1397,13 +1362,10 @@ runQueryDRepState } = conwayEraOnwardsConstraints eon $ do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath sbe = conwayEraOnwardsToShelleyBasedEra eon - cEra = conwayEraOnwardsToCardanoEra eon - - let eraInMode = toEraInCardanoMode cEra drepCreds <- Set.fromList <$> mapM (firstExceptT QueryCmdDRepKeyError . getDRepCredentialFromVerKeyHashOrFile) drepKeys - drepState <- runQuery localNodeConnInfo $ queryDRepState eraInMode sbe drepCreds + drepState <- runQuery localNodeConnInfo $ queryDRepState sbe drepCreds writeOutput mOutFile $ second drepStateToJson <$> Map.assocs drepState where @@ -1427,16 +1389,13 @@ runQueryDRepStakeDistribution } = conwayEraOnwardsConstraints eon $ do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath sbe = conwayEraOnwardsToShelleyBasedEra eon - cEra = conwayEraOnwardsToCardanoEra eon let drepFromVrfKey = fmap Ledger.DRepCredential . firstExceptT QueryCmdDRepKeyError . getDRepCredentialFromVerKeyHashOrFile dreps <- Set.fromList <$> mapM drepFromVrfKey drepKeys - let eraInMode = toEraInCardanoMode cEra - - drepStakeDistribution <- runQuery localNodeConnInfo $ queryDRepStakeDistribution eraInMode sbe dreps + drepStakeDistribution <- runQuery localNodeConnInfo $ queryDRepStakeDistribution sbe dreps writeOutput mOutFile $ Map.assocs drepStakeDistribution @@ -1456,7 +1415,6 @@ runQueryCommitteeMembersState } = conwayEraOnwardsConstraints eon $ do let localNodeConnInfo = LocalNodeConnectInfo consensusModeParams networkId nodeSocketPath sbe = conwayEraOnwardsToShelleyBasedEra eon - cEra = conwayEraOnwardsToCardanoEra eon let coldKeysFromVerKeyHashOrFile = firstExceptT QueryCmdCommitteeColdKeyError . getCommitteeColdCredentialFromVerKeyHashOrFile @@ -1466,17 +1424,15 @@ runQueryCommitteeMembersState firstExceptT QueryCmdCommitteeHotKeyError . getCommitteeHotCredentialFromVerKeyHashOrFile hotKeys <- Set.fromList <$> mapM hotKeysFromVerKeyHashOrFile hotCredKeys - let eraInMode = toEraInCardanoMode cEra - committeeState <- runQuery localNodeConnInfo $ - queryCommitteeMembersState eraInMode sbe coldKeys hotKeys (Set.fromList memberStatuses) + queryCommitteeMembersState sbe coldKeys hotKeys (Set.fromList memberStatuses) writeOutput mOutFile $ A.toJSON committeeState -runQuery :: LocalNodeConnectInfo mode +runQuery :: LocalNodeConnectInfo -> LocalStateQueryExpr - (BlockInMode mode) + BlockInMode ChainPoint - (QueryInMode mode) + QueryInMode () IO (Either @@ -1502,8 +1458,8 @@ writeOutput mOutFile content = case mOutFile of -- Helpers -toEpochInfo :: EraHistory CardanoMode -> EpochInfo (Either Text) -toEpochInfo (EraHistory _ interpreter) = +toEpochInfo :: EraHistory -> EpochInfo (Either Text) +toEpochInfo (EraHistory interpreter) = hoistEpochInfo (first (Text.pack . show) . runExcept) $ Consensus.interpreterToEpochInfo interpreter @@ -1517,8 +1473,8 @@ newtype Tentative a = Tentative { tentative :: a } deriving (Eq, Show) -- This interpreter will compute accurate values into the future as long as a -- a hard fork does not happen in the intervening time. Those values are thus -- "tentative" because they can change in the event of a hard fork. -toTentativeEpochInfo :: EraHistory CardanoMode -> Tentative (EpochInfo (Either Text)) -toTentativeEpochInfo (EraHistory _ interpreter) = +toTentativeEpochInfo :: EraHistory -> Tentative (EpochInfo (Either Text)) +toTentativeEpochInfo (EraHistory interpreter) = Tentative $ hoistEpochInfo (first (Text.pack . show) . runExcept) $ Consensus.interpreterToEpochInfo (Consensus.unsafeExtendSafeZone interpreter) @@ -1527,7 +1483,7 @@ toTentativeEpochInfo (EraHistory _ interpreter) = -- | Get slot number for timestamp, or an error if the UTC timestamp is before 'SystemStart' or after N+1 era utcTimeToSlotNo :: SocketPath - -> ConsensusModeParams CardanoMode + -> ConsensusModeParams -> NetworkId -> UTCTime -> ExceptT QueryCmdError IO SlotNo diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs index 916d56271c..8d74b09651 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs @@ -7,6 +7,7 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-} +{-# LANGUAGE TypeApplications #-} {-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} @@ -36,7 +37,6 @@ import Cardano.Api.Shelley import qualified Cardano.CLI.EraBased.Commands.Transaction as Cmd import Cardano.CLI.EraBased.Run.Genesis -import Cardano.CLI.Helpers import Cardano.CLI.Json.Friendly (FriendlyFormat (..), friendlyTx, friendlyTxBody) import Cardano.CLI.Read import Cardano.CLI.Types.Common @@ -184,7 +184,7 @@ runTransactionBuildCmd -- We need to construct the txBodycontent outside of runTxBuild BalancedTxBody txBodyContent balancedTxBody _ _ <- runTxBuild - eon nodeSocketPath consensusModeParams networkId mScriptValidity inputsAndMaybeScriptWits readOnlyReferenceInputs + eon nodeSocketPath networkId mScriptValidity inputsAndMaybeScriptWits readOnlyReferenceInputs filteredTxinsc mReturnCollateral mTotalCollateral txOuts changeAddresses valuesWithScriptWits mValidityLowerBound mValidityUpperBound certsAndMaybeScriptWits withdrawalsAndMaybeScriptWits requiredSigners txAuxScripts txMetadata mProp mOverrideWitnesses votingProcedures proposals buildOutputOptions @@ -212,7 +212,7 @@ runTransactionBuildCmd pparams <- pure mTxProtocolParams & onNothing (left TxCmdProtocolParametersNotPresentInTxBody) executionUnitPrices <- pure (getExecutionUnitPrices era pparams) & onNothing (left TxCmdPParamExecutionUnitsNotAvailable) - AnyCardanoEra nodeEra <- lift (executeLocalStateQueryExpr localNodeConnInfo Nothing (determineEraExpr consensusModeParams)) + AnyCardanoEra nodeEra <- lift (executeLocalStateQueryExpr localNodeConnInfo Nothing queryCurrentEra) & onLeft (left . TxCmdQueryConvenienceError . AcqFailure) & onLeft (left . TxCmdQueryConvenienceError . QceUnsupportedNtcVersion) @@ -226,7 +226,7 @@ runTransactionBuildCmd scriptExecUnitsMap <- firstExceptT TxCmdTxExecUnitsErr $ hoistEither - $ evaluateTransactionExecutionUnits + $ evaluateTransactionExecutionUnits era systemStart (toLedgerEpochInfo eraHistory) pparams txEraUtxo balancedTxBody @@ -245,15 +245,10 @@ runTransactionBuildCmd & onLeft (left . TxCmdWriteFileError) getExecutionUnitPrices :: CardanoEra era -> LedgerProtocolParameters era -> Maybe Ledger.Prices -getExecutionUnitPrices cEra (LedgerProtocolParameters pp) = do - ShelleyBasedEra sbe <- pure $ cardanoEraStyle cEra - case sbe of - ShelleyBasedEraShelley -> Nothing - ShelleyBasedEraAllegra -> Nothing - ShelleyBasedEraMary -> Nothing - ShelleyBasedEraAlonzo -> Just $ pp ^. Ledger.ppPricesL - ShelleyBasedEraBabbage -> Just $ pp ^. Ledger.ppPricesL - ShelleyBasedEraConway -> Just $ pp ^. Ledger.ppPricesL +getExecutionUnitPrices cEra (LedgerProtocolParameters pp) = + forEraInEonMaybe cEra $ \aeo -> + alonzoEraOnwardsConstraints aeo $ + pp ^. Ledger.ppPricesL runTransactionBuildRawCmd :: () => Cmd.TransactionBuildRawCmdArgs era @@ -291,15 +286,13 @@ runTransactionBuildRawCmd -- TODO: Conway era - How can we make this more composable? certsAndMaybeScriptWits <- - case cardanoEraStyle eon of - LegacyByronEra -> return [] - ShelleyBasedEra sbe -> - shelleyBasedEraConstraints sbe $ - sequence - [ fmap (,mSwit) (firstExceptT TxCmdReadTextViewFileError . newExceptT $ - readFileTextEnvelope AsCertificate (File certFile)) - | (CertificateFile certFile, mSwit) <- certFilesAndMaybeScriptWits - ] + forEraInEon eon (pure mempty) $ \sbe -> + shelleyBasedEraConstraints sbe $ + sequence + [ fmap (,mSwit) (firstExceptT TxCmdReadTextViewFileError . newExceptT $ + readFileTextEnvelope AsCertificate (File certFile)) + | (CertificateFile certFile, mSwit) <- certFilesAndMaybeScriptWits + ] withdrawalsAndMaybeScriptWits <- firstExceptT TxCmdScriptWitnessError $ readScriptWitnessFilesThruple eon withdrawals @@ -314,9 +307,8 @@ runTransactionBuildRawCmd pparams <- forM mProtocolParamsFile $ \ppf -> firstExceptT TxCmdProtocolParamsError (readProtocolParameters ppf) - mLedgerPParams <- case cardanoEraStyle eon of - LegacyByronEra -> return Nothing - ShelleyBasedEra sbe -> + mLedgerPParams <- + forEraInEon eon (pure Nothing) $ \sbe -> forM pparams $ \pp -> firstExceptT TxCmdProtocolParamsConverstionError . hoistEither $ convertToLedgerProtocolParameters sbe pp @@ -461,7 +453,6 @@ runTxBuildRaw era runTxBuild :: () => ShelleyBasedEra era -> SocketPath - -> ConsensusModeParams CardanoMode -> NetworkId -> Maybe ScriptValidity -- ^ Mark script as expected to pass or fail validation @@ -499,7 +490,7 @@ runTxBuild :: () -> TxBuildOutputOptions -> ExceptT TxCmdError IO (BalancedTxBody era) runTxBuild - sbe socketPath consensusModeParams networkId mScriptValidity + sbe socketPath networkId mScriptValidity inputsAndMaybeScriptWits readOnlyRefIns txinsc mReturnCollateral mTotCollateral txouts (TxOutChangeAddress changeAddr) valuesWithScriptWits mLowerBound mUpperBound certsAndMaybeScriptWits withdrawals reqSigners txAuxScripts txMetadata @@ -537,7 +528,7 @@ runTxBuild , localNodeSocketPath = socketPath } - AnyCardanoEra nodeEra <- lift (executeLocalStateQueryExpr localNodeConnInfo Nothing (determineEraExpr consensusModeParams)) + AnyCardanoEra nodeEra <- lift (executeLocalStateQueryExpr localNodeConnInfo Nothing queryCurrentEra) & onLeft (left . TxCmdQueryConvenienceError . AcqFailure) & onLeft (left . TxCmdQueryConvenienceError . QceUnsupportedNtcVersion) @@ -930,8 +921,7 @@ runTransactionSubmitCmd } = do txFileOrPipe <- liftIO $ fileOrPipe txFile InAnyCardanoEra era tx <- lift (readFileTx txFileOrPipe) & onLeft (left . TxCmdCddlError) - let eraInMode = toEraInCardanoMode era - let txInMode = TxInMode tx eraInMode + let txInMode = TxInMode era tx localNodeConnInfo = LocalNodeConnectInfo { localConsensusModeParams = consensusModeParams , localNodeNetworkId = networkId @@ -943,7 +933,7 @@ runTransactionSubmitCmd Net.Tx.SubmitSuccess -> liftIO $ Text.putStrLn "Transaction successfully submitted." Net.Tx.SubmitFail reason -> case reason of - TxValidationErrorInMode err _eraInMode -> left . TxCmdTxSubmitError . Text.pack $ show err + TxValidationErrorInCardanoMode err -> left . TxCmdTxSubmitError . Text.pack $ show err TxValidationEraMismatch mismatchErr -> left $ TxCmdTxSubmitErrorEraMismatch mismatchErr -- ---------------------------------------------------------------------------- @@ -1014,14 +1004,13 @@ runTransactionCalculateMinValueCmd } = do pp <- firstExceptT TxCmdProtocolParamsError (readProtocolParameters protocolParamsFile) out <- toTxOutInAnyEra eon txOut - case cardanoEraStyle eon of - LegacyByronEra -> error "runTransactionCalculateMinValueCmd: Byron era not implemented yet" - ShelleyBasedEra sbe -> do - firstExceptT TxCmdPParamsErr . hoistEither - $ checkProtocolParameters sbe pp - pp' <- hoistEither . first TxCmdProtocolParamsConverstionError $ toLedgerPParams sbe pp - let minValue = calculateMinimumUTxO sbe out pp' - liftIO . IO.print $ minValue + -- TODO: shouldn't we just require shelley based era here instead of error-ing for byron? + forEraInEon eon (error "runTransactionCalculateMinValueCmd: Byron era not implemented yet") $ \sbe -> do + firstExceptT TxCmdPParamsErr . hoistEither + $ checkProtocolParameters sbe pp + pp' <- hoistEither . first TxCmdProtocolParamsConverstionError $ toLedgerPParams sbe pp + let minValue = calculateMinimumUTxO sbe out pp' + liftIO . IO.print $ minValue runTransactionPolicyIdCmd :: () => Cmd.TransactionPolicyIdCmdArgs @@ -1268,6 +1257,5 @@ onlyInShelleyBasedEras :: () -> InAnyCardanoEra a -> ExceptT TxCmdError IO (InAnyShelleyBasedEra a) onlyInShelleyBasedEras notImplMsg (InAnyCardanoEra era x) = - case cardanoEraStyle era of - LegacyByronEra -> left (TxCmdNotImplemented notImplMsg) - ShelleyBasedEra sbe -> shelleyBasedEraConstraints sbe $ return (InAnyShelleyBasedEra sbe x) + forEraInEon era (left $ TxCmdNotImplemented notImplMsg) $ \sbe -> + shelleyBasedEraConstraints sbe $ return (InAnyShelleyBasedEra sbe x) diff --git a/cardano-cli/src/Cardano/CLI/Helpers.hs b/cardano-cli/src/Cardano/CLI/Helpers.hs index 911432fcd6..475a218f14 100644 --- a/cardano-cli/src/Cardano/CLI/Helpers.hs +++ b/cardano-cli/src/Cardano/CLI/Helpers.hs @@ -1,5 +1,4 @@ {-# LANGUAGE GADTs #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -14,11 +13,8 @@ module Cardano.CLI.Helpers , readCBOR , renderHelpersError , validateCBOR - , toEraInCardanoMode ) where -import Cardano.Api (CardanoEra (..), CardanoMode, EraInMode (..)) - import Cardano.Chain.Block (decCBORABlockOrBoundary) import qualified Cardano.Chain.Delegation as Delegation import qualified Cardano.Chain.Update as Update @@ -133,13 +129,3 @@ validateCBOR cborObject bs = CBORVoteByron -> do void $ decodeCBOR bs (fromCBOR :: Decoder s Update.Vote) Right "Valid Byron vote." - -toEraInCardanoMode :: CardanoEra era -> EraInMode era CardanoMode -toEraInCardanoMode = \case - ByronEra -> ByronEraInCardanoMode - ShelleyEra -> ShelleyEraInCardanoMode - AllegraEra -> AllegraEraInCardanoMode - MaryEra -> MaryEraInCardanoMode - AlonzoEra -> AlonzoEraInCardanoMode - BabbageEra -> BabbageEraInCardanoMode - ConwayEra -> ConwayEraInCardanoMode diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Commands/Query.hs b/cardano-cli/src/Cardano/CLI/Legacy/Commands/Query.hs index 879230794a..7dd87051dc 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Commands/Query.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Commands/Query.hs @@ -52,7 +52,7 @@ data LegacyQueryCmds data LegacyQueryLeadershipScheduleCmdArgs = LegacyQueryLeadershipScheduleCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , genesisFp :: !GenesisFile , poolColdVerKeyFile :: !(VerificationKeyOrHashOrFile StakePoolKey) @@ -63,42 +63,42 @@ data LegacyQueryLeadershipScheduleCmdArgs = LegacyQueryLeadershipScheduleCmdArgs data LegacyQueryProtocolParametersCmdArgs = LegacyQueryProtocolParametersCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) data LegacyQueryConstitutionHashCmdArgs = LegacyQueryConstitutionHashCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) data LegacyQueryTipCmdArgs = LegacyQueryTipCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) data LegacyQueryStakePoolsCmdArgs = LegacyQueryStakePoolsCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) data LegacyQueryStakeDistributionCmdArgs = LegacyQueryStakeDistributionCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) data LegacyQueryStakeAddressInfoCmdArgs = LegacyQueryStakeAddressInfoCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , addr :: !StakeAddress , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) @@ -106,7 +106,7 @@ data LegacyQueryStakeAddressInfoCmdArgs = LegacyQueryStakeAddressInfoCmdArgs data LegacyQueryUTxOCmdArgs = LegacyQueryUTxOCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , queryFilter :: !QueryUTxOFilter , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) @@ -114,21 +114,21 @@ data LegacyQueryUTxOCmdArgs = LegacyQueryUTxOCmdArgs data LegacyQueryLedgerStateCmdArgs = LegacyQueryLedgerStateCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) data LegacyQueryProtocolStateCmdArgs = LegacyQueryProtocolStateCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , mOutFile :: !(Maybe (File () Out)) } deriving (Generic, Show) data LegacyQueryStakeSnapshotCmdArgs = LegacyQueryStakeSnapshotCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , allOrOnlyPoolIds :: !(AllOrOnly [Hash StakePoolKey]) , mOutFile :: !(Maybe (File () Out)) @@ -136,7 +136,7 @@ data LegacyQueryStakeSnapshotCmdArgs = LegacyQueryStakeSnapshotCmdArgs data LegacyQueryKesPeriodInfoCmdArgs = LegacyQueryKesPeriodInfoCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , nodeOpCertFp :: !(File () In) -- ^ Node operational certificate , mOutFile :: !(Maybe (File () Out)) @@ -144,14 +144,14 @@ data LegacyQueryKesPeriodInfoCmdArgs = LegacyQueryKesPeriodInfoCmdArgs data LegacyQueryPoolStateCmdArgs = LegacyQueryPoolStateCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , poolIds :: ![Hash StakePoolKey] } deriving (Generic, Show) data LegacyQueryTxMempoolCmdArgs = LegacyQueryTxMempoolCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , query :: !TxMempoolQuery , mOutFile :: !(Maybe (File () Out)) @@ -160,7 +160,7 @@ data LegacyQueryTxMempoolCmdArgs = LegacyQueryTxMempoolCmdArgs data LegacyQuerySlotNumberCmdArgs = LegacyQuerySlotNumberCmdArgs { nodeSocketPath :: !SocketPath - , consensusModeParams :: !(ConsensusModeParams CardanoMode) + , consensusModeParams :: !ConsensusModeParams , networkId :: !NetworkId , utcTime :: !UTCTime } deriving (Generic, Show) diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Commands/Transaction.hs b/cardano-cli/src/Cardano/CLI/Legacy/Commands/Transaction.hs index a3f9cc10ad..89a654c575 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Commands/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Commands/Transaction.hs @@ -54,7 +54,7 @@ data LegacyTransactionCmds | TransactionBuildCmd SocketPath (EraInEon ShelleyBasedEra) - (ConsensusModeParams CardanoMode) + ConsensusModeParams NetworkId (Maybe ScriptValidity) -- ^ Mark script as expected to pass or fail validation (Maybe Word) @@ -109,7 +109,7 @@ data LegacyTransactionCmds (File () Out) | TransactionSubmitCmd SocketPath - (ConsensusModeParams CardanoMode) + ConsensusModeParams NetworkId FilePath | TransactionPolicyIdCmd diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/Legacy/Run/Transaction.hs index cdd6d79a96..79eca31535 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Run/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Run/Transaction.hs @@ -67,7 +67,7 @@ runLegacyTransactionCmds = \case runLegacyTransactionBuildCmd :: () => SocketPath -> EraInEon ShelleyBasedEra - -> ConsensusModeParams CardanoMode + -> ConsensusModeParams -> NetworkId -> Maybe ScriptValidity -> Maybe Word -- ^ Override the required number of tx witnesses @@ -185,7 +185,7 @@ runLegacyTransactionSignCmd runLegacyTransactionSubmitCmd :: () => SocketPath - -> ConsensusModeParams CardanoMode + -> ConsensusModeParams -> NetworkId -> FilePath -> ExceptT TxCmdError IO () diff --git a/cardano-cli/src/Cardano/CLI/Types/Output.hs b/cardano-cli/src/Cardano/CLI/Types/Output.hs index 4ddd3bea10..d9ba4b9039 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Output.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Output.hs @@ -142,7 +142,7 @@ createOpCertIntervalInfo c@(CurrentKesPeriod cKesPeriod) data QueryTipLocalState mode = QueryTipLocalState { era :: AnyCardanoEra - , eraHistory :: EraHistory CardanoMode + , eraHistory :: EraHistory , mSystemStart :: Maybe SystemStart , mChainTip :: Maybe ChainTip } diff --git a/flake.lock b/flake.lock index 32dedb0bb4..4fc708f359 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1698409315, - "narHash": "sha256-0h8SwdLnp/c02K9dXMlT37nTtmhgA1hKVaMjHLEtFYE=", + "lastModified": 1699002072, + "narHash": "sha256-WEhB4QGcO2tw4Kyi/217Oe0Sl7FJzQdWaiwsoqZuHac=", "owner": "input-output-hk", "repo": "cardano-haskell-packages", - "rev": "9313f1f20599a693e4828600b67a19dbf7db2e30", + "rev": "79dd4bb1db3da3ea342bf8759821c7fe46a188f3", "type": "github" }, "original": {