From d4d32e4fe15d598fa72e036c3e5fd9a678e783f6 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Mon, 20 May 2024 20:50:09 +0200 Subject: [PATCH] Unify types --- .../Cardano/Api/SerialiseLedgerCddl.hs | 6 +++-- cardano-api/internal/Cardano/Api/Tx/Sign.hs | 26 +++++++++---------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/cardano-api/internal/Cardano/Api/SerialiseLedgerCddl.hs b/cardano-api/internal/Cardano/Api/SerialiseLedgerCddl.hs index ca62ffcbc8..272cd952d6 100644 --- a/cardano-api/internal/Cardano/Api/SerialiseLedgerCddl.hs +++ b/cardano-api/internal/Cardano/Api/SerialiseLedgerCddl.hs @@ -120,7 +120,9 @@ instance Error TextEnvelopeCddlError where {-# DEPRECATED serialiseTxLedgerCddl "Use 'serialiseToTextEnvelope' from 'Cardano.Api.SerialiseTextEnvelope' instead." #-} serialiseTxLedgerCddl :: ShelleyBasedEra era -> Tx era -> TextEnvelope serialiseTxLedgerCddl era tx = shelleyBasedEraConstraints era $ - serialiseToTextEnvelope (Just (TextEnvelopeDescr "Ledger Cddl Format")) tx + case getTxWitnesses tx of + [] -> serialiseToTextEnvelope (Just (TextEnvelopeDescr "Ledger Cddl Format")) (getTxBody tx) + _ -> serialiseToTextEnvelope (Just (TextEnvelopeDescr "Ledger Cddl Format")) tx {-# DEPRECATED deserialiseTxLedgerCddl "Use 'deserialiseFromTextEnvelope' from 'Cardano.Api.SerialiseTextEnvelope' instead." #-} deserialiseTxLedgerCddl :: forall era . @@ -146,7 +148,7 @@ writeByronTxFileTextEnvelopeCddl path w = serializeByronTx :: Byron.ATxAux ByteString -> TextEnvelope serializeByronTx tx = TextEnvelope - { teType = "Tx ByronEra" + { teType = "Witnessed Tx ByronEra" , teDescription = "Ledger Cddl Format" , teRawCBOR = CBOR.recoverBytes tx } diff --git a/cardano-api/internal/Cardano/Api/Tx/Sign.hs b/cardano-api/internal/Cardano/Api/Tx/Sign.hs index 882f4fd2b8..79432334b8 100644 --- a/cardano-api/internal/Cardano/Api/Tx/Sign.hs +++ b/cardano-api/internal/Cardano/Api/Tx/Sign.hs @@ -273,12 +273,12 @@ getTxBody (ShelleyTx sbe tx) = instance IsShelleyBasedEra era => HasTextEnvelope (Tx era) where textEnvelopeType _ = case shelleyBasedEra :: ShelleyBasedEra era of - ShelleyBasedEraShelley -> "TxSignedShelley" - ShelleyBasedEraAllegra -> "Tx AllegraEra" - ShelleyBasedEraMary -> "Tx MaryEra" - ShelleyBasedEraAlonzo -> "Tx AlonzoEra" - ShelleyBasedEraBabbage -> "Tx BabbageEra" - ShelleyBasedEraConway -> "Tx ConwayEra" + ShelleyBasedEraShelley -> "Witnessed Tx Shelley" + ShelleyBasedEraAllegra -> "Witnessed Tx AllegraEra" + ShelleyBasedEraMary -> "Witnessed Tx MaryEra" + ShelleyBasedEraAlonzo -> "Witnessed Tx AlonzoEra" + ShelleyBasedEraBabbage -> "Witnessed Tx BabbageEra" + ShelleyBasedEraConway -> "Witnessed Tx ConwayEra" @@ -459,12 +459,12 @@ instance IsShelleyBasedEra era => SerialiseAsCBOR (TxBody era) where instance IsShelleyBasedEra era => HasTextEnvelope (TxBody era) where textEnvelopeType _ = case shelleyBasedEra :: ShelleyBasedEra era of - ShelleyBasedEraShelley -> "TxUnsignedShelley" - ShelleyBasedEraAllegra -> "TxBodyAllegra" - ShelleyBasedEraMary -> "TxBodyMary" - ShelleyBasedEraAlonzo -> "TxBodyAlonzo" - ShelleyBasedEraBabbage -> "TxBodyBabbage" - ShelleyBasedEraConway -> "TxBodyConway" + ShelleyBasedEraShelley -> "Unwitnessed Tx ShelleyEra" + ShelleyBasedEraAllegra -> "Unwitnessed Tx AllegraEra" + ShelleyBasedEraMary -> "Unwitnessed Tx MaryEra" + ShelleyBasedEraAlonzo -> "Unwitnessed Tx AlonzoEra" + ShelleyBasedEraBabbage -> "Unwitnessed Tx BabbageEra" + ShelleyBasedEraConway -> "Unwitnessed Tx ConwayEra" data TxBodyScriptData era where TxBodyNoScriptData :: TxBodyScriptData era @@ -705,7 +705,7 @@ decodeShelleyBasedWitness sbe = instance IsCardanoEra era => HasTextEnvelope (KeyWitness era) where textEnvelopeType _ = case cardanoEra :: CardanoEra era of - ByronEra -> "TxWitnessByron" + ByronEra -> "TxWitness ByronEra" ShelleyEra -> "TxWitness ShelleyEra" AllegraEra -> "TxWitness AllegraEra" MaryEra -> "TxWitness MaryEra"