From c61a14ac743a7f662b281dbf1ea556e1ed8712f9 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Thu, 13 Aug 2026 17:42:58 +1000 Subject: [PATCH 1/3] Adapt to cardano-api's removed closed-range eon eliminators and validation 1.2 cardano-api's b53b1ed2f (upstream, already merged, unrelated to crypton) replaced caseShelleyToAllegraOrMaryEraOnwards, caseShelleyToMaryOrAlonzoEraOnwards, and caseShelleyToAlonzoOrBabbageEraOnwards with forEraInEon/Convert; this port mirrors that at cardano-cli's own three call sites (TxOut.hs, two Option.hs, and Query/Run.hs). Also replaces Data.Validation's removed liftError (Read/DRep.hs, Read/Committee/{Hot,Cold}Key.hs) with Either.either (Failure . return) Success, the direct equivalent for the 1.1 -> 1.2 breaking rewrite (same one already fixed in cardano-api's own Sign.hs). --- .../src/Cardano/CLI/Compatible/Transaction/Option.hs | 7 ++++--- .../src/Cardano/CLI/Compatible/Transaction/TxOut.hs | 6 +++--- .../Cardano/CLI/EraBased/Governance/Actions/Option.hs | 7 ++++--- cardano-cli/src/Cardano/CLI/EraBased/Query/Run.hs | 6 +++--- cardano-cli/src/Cardano/CLI/Read/Committee/ColdKey.hs | 9 +++++---- cardano-cli/src/Cardano/CLI/Read/Committee/HotKey.hs | 9 +++++---- cardano-cli/src/Cardano/CLI/Read/DRep.hs | 9 +++++---- 7 files changed, 29 insertions(+), 24 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/Compatible/Transaction/Option.hs b/cardano-cli/src/Cardano/CLI/Compatible/Transaction/Option.hs index 40c7d62c11..7cea1d92a2 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/Transaction/Option.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/Transaction/Option.hs @@ -87,9 +87,10 @@ pTxOutEraAware sbe = <*> pRefScriptFp sbe pTxOutDatum :: ShelleyBasedEra era -> Parser TxOutDatumAnyEra -pTxOutDatum = - caseShelleyToMaryOrAlonzoEraOnwards - (const $ pure TxOutDatumByNone) +pTxOutDatum sbe = + forEraInEon + (convert sbe) + (pure TxOutDatumByNone) ( \case AlonzoEraOnwardsAlonzo -> pAlonzoDatumFunctionality <|> pure TxOutDatumByNone diff --git a/cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs b/cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs index 38be2af237..09738e455c 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs @@ -83,13 +83,13 @@ toTxOutValueInShelleyBasedEra -> Value -> CIO e (TxOutValue era) toTxOutValueInShelleyBasedEra sbe val = - caseShelleyToAllegraOrMaryEraOnwards - ( \_ -> case valueToLovelace val of + forEraInEon + (convert sbe) + ( case valueToLovelace val of Just l -> return (TxOutValueShelleyBased sbe l) Nothing -> txFeatureMismatch sbe TxFeatureMultiAssetOutputs ) (\w -> return (TxOutValueShelleyBased sbe (toLedgerValue w val))) - sbe toTxAlonzoDatum :: () diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Option.hs b/cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Option.hs index 2b70dfe8e8..dc16622a26 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Option.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Option.hs @@ -195,9 +195,10 @@ pUpdateProtocolParametersCmd = -- | Cost models only makes sense in eras from Alonzo onwards. For earlier -- eras, this parser doesn't show up in the command line and returns 'Nothing'. pCostModelsFile :: ShelleyBasedEra era -> Parser (Maybe (CostModelsFile era)) -pCostModelsFile = - caseShelleyToMaryOrAlonzoEraOnwards - (const $ pure Nothing) +pCostModelsFile sbe = + forEraInEon + (convert sbe) + (pure Nothing) ( \alonzoOnwards -> fmap (CostModelsFile alonzoOnwards . File) <$> optional pCostModels diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Query/Run.hs b/cardano-cli/src/Cardano/CLI/EraBased/Query/Run.hs index bc1ae27126..dc628a5448 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Query/Run.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Query/Run.hs @@ -1251,10 +1251,10 @@ utxoToText sbe (TxIn (TxId txhash) (TxIx index), Exp.TxOut ledgerTxOut) = -- datum where it exists and an empty placeholder otherwise. printableDatum :: Text printableDatum = - caseShelleyToAlonzoOrBabbageEraOnwards - (const "") + forEraInEon + (convert sbe) + "" (\beo -> babbageEraOnwardsConstraints beo $ Text.pack $ show (ledgerTxOut ^. L.datumTxOutL)) - sbe runQueryStakePoolsCmd :: () diff --git a/cardano-cli/src/Cardano/CLI/Read/Committee/ColdKey.hs b/cardano-cli/src/Cardano/CLI/Read/Committee/ColdKey.hs index 026248ec80..691660a051 100644 --- a/cardano-cli/src/Cardano/CLI/Read/Committee/ColdKey.hs +++ b/cardano-cli/src/Cardano/CLI/Read/Committee/ColdKey.hs @@ -22,6 +22,7 @@ import Cardano.Prelude qualified as Text import Prelude import Data.Validation +import Data.Either qualified as Either data AnyCommitteeColdVerificationKey where AnyCommitteeColdVerificationKey @@ -35,11 +36,11 @@ readCommitteeColdBech32VerificationKeyText :: Text -> Validation [Bech32DecodeError] AnyCommitteeColdVerificationKey readCommitteeColdBech32VerificationKeyText committeeColdText = let vkey = - liftError return $ + Either.either (Failure . return) Success $ AnyCommitteeColdVerificationKey <$> deserialiseFromBech32 committeeColdText extendedVkey = - liftError return $ + Either.either (Failure . return) Success $ AnyCommitteeColdExtendedVerificationKey <$> deserialiseFromBech32 committeeColdText in vkey <> extendedVkey @@ -49,11 +50,11 @@ readCommitteeColdHexVerificationKeyText readCommitteeColdHexVerificationKeyText committeeColdText = let committeeColdBs = Text.encodeUtf8 committeeColdText vkey = - liftError return $ + Either.either (Failure . return) Success $ AnyCommitteeColdVerificationKey <$> deserialiseFromRawBytesHex committeeColdBs extendedVkey = - liftError return $ + Either.either (Failure . return) Success $ AnyCommitteeColdExtendedVerificationKey <$> deserialiseFromRawBytesHex committeeColdBs in vkey <> extendedVkey diff --git a/cardano-cli/src/Cardano/CLI/Read/Committee/HotKey.hs b/cardano-cli/src/Cardano/CLI/Read/Committee/HotKey.hs index 61ebf39573..b8c7799671 100644 --- a/cardano-cli/src/Cardano/CLI/Read/Committee/HotKey.hs +++ b/cardano-cli/src/Cardano/CLI/Read/Committee/HotKey.hs @@ -22,6 +22,7 @@ import Cardano.Prelude qualified as Text import Prelude import Data.Validation +import Data.Either qualified as Either data AnyCommitteeHotVerificationKey where AnyCommitteeHotVerificationKey :: VerificationKey CommitteeHotKey -> AnyCommitteeHotVerificationKey @@ -34,11 +35,11 @@ readCommitteeHotBech32VerificationKeyText :: Text -> Validation [Bech32DecodeError] AnyCommitteeHotVerificationKey readCommitteeHotBech32VerificationKeyText committeeHot = let vkey = - liftError return $ + Either.either (Failure . return) Success $ AnyCommitteeHotVerificationKey <$> deserialiseFromBech32 committeeHot extendedVkey = - liftError return $ + Either.either (Failure . return) Success $ AnyCommitteeHotExtendedVerificationKey <$> deserialiseFromBech32 committeeHot in vkey <> extendedVkey @@ -48,11 +49,11 @@ readCommitteeHotHexVerificationKeyText readCommitteeHotHexVerificationKeyText committeeHotText = let committeeHotBs = Text.encodeUtf8 committeeHotText vkey = - liftError return $ + Either.either (Failure . return) Success $ AnyCommitteeHotVerificationKey <$> deserialiseFromRawBytesHex committeeHotBs extendedVkey = - liftError return $ + Either.either (Failure . return) Success $ AnyCommitteeHotExtendedVerificationKey <$> deserialiseFromRawBytesHex committeeHotBs in vkey <> extendedVkey diff --git a/cardano-cli/src/Cardano/CLI/Read/DRep.hs b/cardano-cli/src/Cardano/CLI/Read/DRep.hs index a0655d158d..01e6c55f9c 100644 --- a/cardano-cli/src/Cardano/CLI/Read/DRep.hs +++ b/cardano-cli/src/Cardano/CLI/Read/DRep.hs @@ -22,6 +22,7 @@ import Cardano.Prelude qualified as Text import Prelude import Data.Validation +import Data.Either qualified as Either data AnyDrepVerificationKey where AnyDrepVerificationKey :: VerificationKey DRepKey -> AnyDrepVerificationKey @@ -32,10 +33,10 @@ deriving instance Show AnyDrepVerificationKey readDRepBech32VerificationKeyText :: Text -> Validation [Bech32DecodeError] AnyDrepVerificationKey readDRepBech32VerificationKeyText drep = let vkey = - liftError return $ + Either.either (Failure . return) Success $ AnyDrepVerificationKey <$> deserialiseFromBech32 drep extendedVkey = - liftError return $ + Either.either (Failure . return) Success $ AnyDrepExtendedVerificationKey <$> deserialiseFromBech32 drep in vkey <> extendedVkey @@ -43,10 +44,10 @@ readDRepHexVerificationKeyText :: Text -> Validation [RawBytesHexError] AnyDrepV readDRepHexVerificationKeyText drepText = let drepBs = Text.encodeUtf8 drepText vkey = - liftError return $ + Either.either (Failure . return) Success $ AnyDrepVerificationKey <$> deserialiseFromRawBytesHex drepBs extendedVkey = - liftError return $ + Either.either (Failure . return) Success $ AnyDrepExtendedVerificationKey <$> deserialiseFromRawBytesHex drepBs in vkey <> extendedVkey From b270c95d0f532119efe39a74ffebfb6d7808a0a9 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Thu, 13 Aug 2026 17:46:23 +1000 Subject: [PATCH 2/3] Fix TxOut's lost Value~Coin evidence and Cip129 Run's toEither toTxOutValueInShelleyBasedEra's negative branch lost the Value~Coin type equality the removed ShelleyToAllegraEra witness used to provide (same issue cardano-api's own b53b1ed2f flagged for fromLedgerValue); use L.inject under shelleyBasedEraConstraints instead, matching that fix's lovelaceToValue/L.coin pattern. Cip129/Run.hs used Valid.toEither directly (also removed in validation 1.2); foldValidation Left Right is the direct catamorphism replacement, avoiding a new lens dependency. --- .../src/Cardano/CLI/Compatible/Transaction/TxOut.hs | 7 ++++--- .../src/Cardano/CLI/EraIndependent/Cip/Cip129/Run.hs | 12 ++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs b/cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs index 09738e455c..17878b6aec 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs @@ -85,9 +85,10 @@ toTxOutValueInShelleyBasedEra toTxOutValueInShelleyBasedEra sbe val = forEraInEon (convert sbe) - ( case valueToLovelace val of - Just l -> return (TxOutValueShelleyBased sbe l) - Nothing -> txFeatureMismatch sbe TxFeatureMultiAssetOutputs + ( shelleyBasedEraConstraints sbe $ + case valueToLovelace val of + Just l -> return (TxOutValueShelleyBased sbe (L.inject l)) + Nothing -> txFeatureMismatch sbe TxFeatureMultiAssetOutputs ) (\w -> return (TxOutValueShelleyBased sbe (toLedgerValue w val))) diff --git a/cardano-cli/src/Cardano/CLI/EraIndependent/Cip/Cip129/Run.hs b/cardano-cli/src/Cardano/CLI/EraIndependent/Cip/Cip129/Run.hs index 2c231cc6b3..bae6887dfa 100644 --- a/cardano-cli/src/Cardano/CLI/EraIndependent/Cip/Cip129/Run.hs +++ b/cardano-cli/src/Cardano/CLI/EraIndependent/Cip/Cip129/Run.hs @@ -32,9 +32,9 @@ runCip129 (Cip129DRep inp out) = do f <- liftIO $ fileOrPipe textEnvFp fromEitherIOCli $ readDrepVerificationKeyFile f InputHexText t -> do - fromEitherCli . Valid.toEither $ readDRepHexVerificationKeyText t + fromEitherCli . Valid.foldValidation Left Right $ readDRepHexVerificationKeyText t InputBech32Text t -> do - fromEitherCli . Valid.toEither $ readDRepBech32VerificationKeyText t + fromEitherCli . Valid.foldValidation Left Right $ readDRepBech32VerificationKeyText t let cip129Output = Text.encodeUtf8 $ encodeCip129DrepVerficationKeyText k renderOutput cip129Output out runCip129 (Cip129CommitteeHotKey inp out) = do @@ -43,9 +43,9 @@ runCip129 (Cip129CommitteeHotKey inp out) = do f <- liftIO $ fileOrPipe textEnvFp fromEitherIOCli $ readCommitteeHotVerificationKeyFile f InputHexText t -> - fromEitherCli . Valid.toEither $ readCommitteeHotHexVerificationKeyText t + fromEitherCli . Valid.foldValidation Left Right $ readCommitteeHotHexVerificationKeyText t InputBech32Text t -> - fromEitherCli . Valid.toEither $ readCommitteeHotBech32VerificationKeyText t + fromEitherCli . Valid.foldValidation Left Right $ readCommitteeHotBech32VerificationKeyText t let cip129Output = Text.encodeUtf8 $ encodeCip129CommitteeHotVerficationKeyText k renderOutput cip129Output out runCip129 (Cip129CommitteeColdKey inp out) = do @@ -54,9 +54,9 @@ runCip129 (Cip129CommitteeColdKey inp out) = do f <- liftIO $ fileOrPipe textEnvFp fromEitherIOCli $ readCommitteeColdVerificationKeyFile f InputHexText t -> - fromEitherCli . Valid.toEither $ readCommitteeColdHexVerificationKeyText t + fromEitherCli . Valid.foldValidation Left Right $ readCommitteeColdHexVerificationKeyText t InputBech32Text t -> - fromEitherCli . Valid.toEither $ readCommitteeColdBech32VerificationKeyText t + fromEitherCli . Valid.foldValidation Left Right $ readCommitteeColdBech32VerificationKeyText t let cip129Output = Text.encodeUtf8 $ encodeCip129CommitteeColdVerficationKeyText k renderOutput cip129Output out runCip129 (Cip129GovernanceAction inp out) = From 5b3feaaa0a24ffa33e961ab06b84d9d6f645bbb7 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Thu, 13 Aug 2026 17:48:20 +1000 Subject: [PATCH 3/3] TxOut: supply the Eq (L.Value era) instance via maryEraOnwardsConstraints The removed MaryEraOnwards-witness positive branch used to bundle this instance implicitly; forEraInEon's callback needs it discharged explicitly, same pattern as cardano-api's own upstream fixes for this migration. --- cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs b/cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs index 17878b6aec..d74c2bbe74 100644 --- a/cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs +++ b/cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs @@ -90,7 +90,7 @@ toTxOutValueInShelleyBasedEra sbe val = Just l -> return (TxOutValueShelleyBased sbe (L.inject l)) Nothing -> txFeatureMismatch sbe TxFeatureMultiAssetOutputs ) - (\w -> return (TxOutValueShelleyBased sbe (toLedgerValue w val))) + (\w -> maryEraOnwardsConstraints w $ return (TxOutValueShelleyBased sbe (toLedgerValue w val))) toTxAlonzoDatum :: ()