Skip to content

Commit

Permalink
Unify types
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed May 20, 2024
1 parent 280e5e4 commit d4d32e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
6 changes: 4 additions & 2 deletions cardano-api/internal/Cardano/Api/SerialiseLedgerCddl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand All @@ -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
}
Expand Down
26 changes: 13 additions & 13 deletions cardano-api/internal/Cardano/Api/Tx/Sign.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"



Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit d4d32e4

Please sign in to comment.