Skip to content

Commit

Permalink
Generate TextEnvelope types using textEnvelopeType directly
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Sep 19, 2024
1 parent 2f867e4 commit 1f0137b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions cardano-cli/src/Cardano/CLI/Read.hs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ import qualified Data.ByteString.Lazy.Char8 as LBS
import Data.Function ((&))
import Data.IORef (IORef, newIORef, readIORef, writeIORef)
import qualified Data.List as List
import Data.Proxy (Proxy (..))
import Data.String
import Data.Text (Text)
import qualified Data.Text as T
Expand Down Expand Up @@ -627,10 +628,13 @@ readCddlTx =

txTextEnvelopeTypes :: [Text]
txTextEnvelopeTypes =
"TxSignedShelley"
: [ "Tx " <> T.pack (show $ toCardanoEra sbe)
| AnyShelleyBasedEra sbe <- [AnyShelleyBasedEra ShelleyBasedEraAllegra ..]
]
[ let TextEnvelopeType d = shelleyBasedEraConstraints sbe $ textEnvelopeType (proxyToAsType (makeTxProxy sbe))
in T.pack d
| AnyShelleyBasedEra sbe <- [minBound .. maxBound]
]
where
makeTxProxy :: ShelleyBasedEra era -> Proxy (Tx era)
makeTxProxy _ = Proxy

-- Tx witnesses

Expand Down Expand Up @@ -690,9 +694,13 @@ readCddlWitness fp = do

txWitnessTextEnvelopeTypes :: [Text]
txWitnessTextEnvelopeTypes =
[ "TxWitness " <> T.pack (show $ toCardanoEra sbe)
| AnyShelleyBasedEra sbe <- [AnyShelleyBasedEra ShelleyBasedEraShelley ..]
[ let TextEnvelopeType d = shelleyBasedEraConstraints sbe $ textEnvelopeType (proxyToAsType (makeWitnessProxy sbe))
in T.pack d
| AnyShelleyBasedEra sbe <- [minBound .. maxBound]
]
where
makeWitnessProxy :: ShelleyBasedEra era -> Proxy (KeyWitness era)
makeWitnessProxy _ = Proxy

-- Witness handling

Expand Down

0 comments on commit 1f0137b

Please sign in to comment.