Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@ toTxOutValueInShelleyBasedEra
-> Value
-> CIO e (TxOutValue era)
toTxOutValueInShelleyBasedEra sbe val =
caseShelleyToAllegraOrMaryEraOnwards
( \_ -> case valueToLovelace val of
Just l -> return (TxOutValueShelleyBased sbe l)
Nothing -> txFeatureMismatch sbe TxFeatureMultiAssetOutputs
forEraInEon
(convert sbe)
( 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)))
sbe
(\w -> maryEraOnwardsConstraints w $ return (TxOutValueShelleyBased sbe (toLedgerValue w val)))

toTxAlonzoDatum
:: ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions cardano-cli/src/Cardano/CLI/EraBased/Query/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
:: ()
Expand Down
12 changes: 6 additions & 6 deletions cardano-cli/src/Cardano/CLI/EraIndependent/Cip/Cip129/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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) =
Expand Down
9 changes: 5 additions & 4 deletions cardano-cli/src/Cardano/CLI/Read/Committee/ColdKey.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 $
Comment on lines +39 to +43
AnyCommitteeColdExtendedVerificationKey
<$> deserialiseFromBech32 committeeColdText
in vkey <> extendedVkey
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions cardano-cli/src/Cardano/CLI/Read/Committee/HotKey.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 $
Comment on lines +38 to +42
AnyCommitteeHotExtendedVerificationKey
<$> deserialiseFromBech32 committeeHot
in vkey <> extendedVkey
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions cardano-cli/src/Cardano/CLI/Read/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,21 +33,21 @@ 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
Comment on lines +36 to 40
in vkey <> extendedVkey

readDRepHexVerificationKeyText :: Text -> Validation [RawBytesHexError] AnyDrepVerificationKey
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
Expand Down