Skip to content

Commit ae17805

Browse files
authored
Merge pull request #1426 from IntersectMBO/derive-accepted-witness-eras
Derive the accepted era list when reading transaction witnesses
2 parents eefdd5c + 6605fa1 commit ae17805

2 files changed

Lines changed: 16 additions & 24 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
description: |
2+
Fixed `transaction assemble` (also known as `transaction sign-witness`) rejecting witness files from eras after Conway: witness files from every supported era, including Dijkstra, are now accepted.
3+
kind:
4+
- bugfix
5+
pr: 1426
6+
project: cardano-cli

‎cardano-cli/src/Cardano/CLI/Read.hs‎

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,16 @@ readFileTxKeyWitness
341341
-> IO (Either (FileError TextEnvelopeError) (InAnyShelleyBasedEra KeyWitness))
342342
readFileTxKeyWitness fp = do
343343
file <- fileOrPipe fp
344-
readFileInAnyShelleyBasedEra AsKeyWitness file
344+
readFileOrPipeTextEnvelopeAnyOf fromSomeShelleyTxWitness file
345+
346+
fromSomeShelleyTxWitness :: [FromSomeType HasTextEnvelope (InAnyShelleyBasedEra KeyWitness)]
347+
fromSomeShelleyTxWitness =
348+
[ shelleyBasedEraConstraints sbe $ FromSomeType (makeWitnessProxy sbe) (InAnyShelleyBasedEra sbe)
349+
| AnyShelleyBasedEra sbe <- [minBound .. maxBound]
350+
]
351+
where
352+
makeWitnessProxy :: HasTypeProxy era => ShelleyBasedEra era -> AsType (KeyWitness era)
353+
makeWitnessProxy _ = AsKeyWitness (proxyToAsType (Proxy :: Proxy era))
345354

346355
txWitnessTextEnvelopeTypes :: [Text]
347356
txWitnessTextEnvelopeTypes =
@@ -614,29 +623,6 @@ readCostModels (File fp) = do
614623
when (null $ fromAlonzoCostModels costModels) $ throwE $ CostModelsErrorEmpty fp
615624
return costModels
616625

617-
-- Misc
618-
619-
readFileInAnyShelleyBasedEra
620-
:: ( HasTextEnvelope (thing ShelleyEra)
621-
, HasTextEnvelope (thing AllegraEra)
622-
, HasTextEnvelope (thing MaryEra)
623-
, HasTextEnvelope (thing AlonzoEra)
624-
, HasTextEnvelope (thing BabbageEra)
625-
, HasTextEnvelope (thing ConwayEra)
626-
)
627-
=> (forall era. AsType era -> AsType (thing era))
628-
-> FileOrPipe
629-
-> IO (Either (FileError TextEnvelopeError) (InAnyShelleyBasedEra thing))
630-
readFileInAnyShelleyBasedEra asThing =
631-
readFileOrPipeTextEnvelopeAnyOf
632-
[ FromSomeType (asThing AsShelleyEra) (InAnyShelleyBasedEra ShelleyBasedEraShelley)
633-
, FromSomeType (asThing AsAllegraEra) (InAnyShelleyBasedEra ShelleyBasedEraAllegra)
634-
, FromSomeType (asThing AsMaryEra) (InAnyShelleyBasedEra ShelleyBasedEraMary)
635-
, FromSomeType (asThing AsAlonzoEra) (InAnyShelleyBasedEra ShelleyBasedEraAlonzo)
636-
, FromSomeType (asThing AsBabbageEra) (InAnyShelleyBasedEra ShelleyBasedEraBabbage)
637-
, FromSomeType (asThing AsConwayEra) (InAnyShelleyBasedEra ShelleyBasedEraConway)
638-
]
639-
640626
-- | We need a type for handling files that may be actually be things like
641627
-- pipes. Currently the CLI makes no guarantee that a "file" will only
642628
-- be read once. This is a problem for a user who who expects to be able to pass

0 commit comments

Comments
 (0)