diff --git a/.changes/20260827_111653_cardano-cli_palas_accept_newer_era_witnesses.yml b/.changes/20260827_111653_cardano-cli_palas_accept_newer_era_witnesses.yml new file mode 100644 index 0000000000..ee7c8b3022 --- /dev/null +++ b/.changes/20260827_111653_cardano-cli_palas_accept_newer_era_witnesses.yml @@ -0,0 +1,6 @@ +description: | + 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. +kind: +- bugfix +pr: 1426 +project: cardano-cli diff --git a/cardano-cli/src/Cardano/CLI/Read.hs b/cardano-cli/src/Cardano/CLI/Read.hs index 7e11c21e51..a82e22a79b 100644 --- a/cardano-cli/src/Cardano/CLI/Read.hs +++ b/cardano-cli/src/Cardano/CLI/Read.hs @@ -341,7 +341,16 @@ readFileTxKeyWitness -> IO (Either (FileError TextEnvelopeError) (InAnyShelleyBasedEra KeyWitness)) readFileTxKeyWitness fp = do file <- fileOrPipe fp - readFileInAnyShelleyBasedEra AsKeyWitness file + readFileOrPipeTextEnvelopeAnyOf fromSomeShelleyTxWitness file + +fromSomeShelleyTxWitness :: [FromSomeType HasTextEnvelope (InAnyShelleyBasedEra KeyWitness)] +fromSomeShelleyTxWitness = + [ shelleyBasedEraConstraints sbe $ FromSomeType (makeWitnessProxy sbe) (InAnyShelleyBasedEra sbe) + | AnyShelleyBasedEra sbe <- [minBound .. maxBound] + ] + where + makeWitnessProxy :: HasTypeProxy era => ShelleyBasedEra era -> AsType (KeyWitness era) + makeWitnessProxy _ = AsKeyWitness (proxyToAsType (Proxy :: Proxy era)) txWitnessTextEnvelopeTypes :: [Text] txWitnessTextEnvelopeTypes = @@ -614,29 +623,6 @@ readCostModels (File fp) = do when (null $ fromAlonzoCostModels costModels) $ throwE $ CostModelsErrorEmpty fp return costModels --- Misc - -readFileInAnyShelleyBasedEra - :: ( HasTextEnvelope (thing ShelleyEra) - , HasTextEnvelope (thing AllegraEra) - , HasTextEnvelope (thing MaryEra) - , HasTextEnvelope (thing AlonzoEra) - , HasTextEnvelope (thing BabbageEra) - , HasTextEnvelope (thing ConwayEra) - ) - => (forall era. AsType era -> AsType (thing era)) - -> FileOrPipe - -> IO (Either (FileError TextEnvelopeError) (InAnyShelleyBasedEra thing)) -readFileInAnyShelleyBasedEra asThing = - readFileOrPipeTextEnvelopeAnyOf - [ FromSomeType (asThing AsShelleyEra) (InAnyShelleyBasedEra ShelleyBasedEraShelley) - , FromSomeType (asThing AsAllegraEra) (InAnyShelleyBasedEra ShelleyBasedEraAllegra) - , FromSomeType (asThing AsMaryEra) (InAnyShelleyBasedEra ShelleyBasedEraMary) - , FromSomeType (asThing AsAlonzoEra) (InAnyShelleyBasedEra ShelleyBasedEraAlonzo) - , FromSomeType (asThing AsBabbageEra) (InAnyShelleyBasedEra ShelleyBasedEraBabbage) - , FromSomeType (asThing AsConwayEra) (InAnyShelleyBasedEra ShelleyBasedEraConway) - ] - -- | We need a type for handling files that may be actually be things like -- pipes. Currently the CLI makes no guarantee that a "file" will only -- be read once. This is a problem for a user who who expects to be able to pass