diff --git a/cardano-api-gen/cardano-api-gen.cabal b/cardano-api-gen/cardano-api-gen.cabal index 99dcd21494..2eea47cee4 100644 --- a/cardano-api-gen/cardano-api-gen.cabal +++ b/cardano-api-gen/cardano-api-gen.cabal @@ -1,7 +1,7 @@ cabal-version: 3.0 name: cardano-api-gen -version: 8.1.1.0 +version: 8.1.1.1 synopsis: Generators for the cardano api description: Generators for the cardano api. category: Cardano, diff --git a/cardano-api/CHANGELOG.md b/cardano-api/CHANGELOG.md index afba9ae1bc..c5e13ed808 100644 --- a/cardano-api/CHANGELOG.md +++ b/cardano-api/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog for cardano-api +## 8.8.1.1 + +- Add a HasTypeProxy constraint to getVerificationKey + (feature; compatible) + [PR 122](https://github.com/input-output-hk/cardano-api/pull/122) + ## 8.8.1.0 - Make it build with ghc-9.6 diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index 80aa09ccda..d88c2a1ab9 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -1,7 +1,7 @@ cabal-version: 3.4 name: cardano-api -version: 8.8.1.0 +version: 8.8.1.1 synopsis: The cardano api description: The cardano api. category: Cardano, diff --git a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs index 56ee85cd04..11de172454 100644 --- a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs +++ b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} @@ -746,10 +747,26 @@ genWitnesses era = (genShelleyKeyWitness era) return $ bsWits ++ keyWits -genVerificationKey :: Key keyrole => AsType keyrole -> Gen (VerificationKey keyrole) +genVerificationKey :: +#if __GLASGOW_HASKELL__ >= 902 +-- GHC 8.10 considers the HasTypeProxy constraint redundant but ghc-9.6 complains if its not +-- present. + (Key keyrole, HasTypeProxy keyrole) => +#else + Key keyrole => +#endif + AsType keyrole -> Gen (VerificationKey keyrole) genVerificationKey roletoken = getVerificationKey <$> genSigningKey roletoken -genVerificationKeyHash :: Key keyrole => AsType keyrole -> Gen (Hash keyrole) +genVerificationKeyHash :: +#if __GLASGOW_HASKELL__ >= 902 +-- GHC 8.10 considers the HasTypeProxy constraint redundant but ghc-9.6 complains if its not +-- present. + (Key keyrole, HasTypeProxy keyrole) => +#else + Key keyrole => +#endif + AsType keyrole -> Gen (Hash keyrole) genVerificationKeyHash roletoken = verificationKeyHash <$> genVerificationKey roletoken diff --git a/cardano-api/internal/Cardano/Api/Keys/Class.hs b/cardano-api/internal/Cardano/Api/Keys/Class.hs index fe7f684757..60e9685736 100644 --- a/cardano-api/internal/Cardano/Api/Keys/Class.hs +++ b/cardano-api/internal/Cardano/Api/Keys/Class.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeFamilies #-} @@ -44,7 +45,14 @@ class (Eq (VerificationKey keyrole), data SigningKey keyrole :: Type -- | Get the corresponding verification key from a signing key. - getVerificationKey :: SigningKey keyrole -> VerificationKey keyrole + getVerificationKey :: +#if __GLASGOW_HASKELL__ >= 902 +-- GHC 8.10 considers this constraint redundant but ghc-9.6 complains if its not present. +-- More annoyingly, absence of this constraint does not manifest in this repo, but in +-- `cardano-cli` :facepalm:. + HasTypeProxy keyrole => +#endif + SigningKey keyrole -> VerificationKey keyrole -- | Generate a 'SigningKey' deterministically, given a 'Crypto.Seed'. The -- required size of the seed is given by 'deterministicSigningKeySeedSize'. diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/Envelope.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/Envelope.hs index 33977d8722..20bc5ec8d5 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/Envelope.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/Envelope.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} module Test.Cardano.Api.Typed.Envelope @@ -89,8 +90,15 @@ prop_roundtrip_VrfSigningKey_envelope = -- ----------------------------------------------------------------------------- -roundtrip_VerificationKey_envelope :: Key keyrole - => AsType keyrole -> Property +roundtrip_VerificationKey_envelope :: +#if __GLASGOW_HASKELL__ >= 902 +-- GHC 8.10 considers the HasTypeProxy constraint redundant but ghc-9.2 and above complains if its +-- not present. + (Key keyrole, HasTypeProxy keyrole) => +#else + Key keyrole => +#endif + AsType keyrole -> Property roundtrip_VerificationKey_envelope roletoken = H.property $ do vkey <- H.forAll (genVerificationKey roletoken) diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/RawBytes.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/RawBytes.hs index cb83156b7d..ca002b8d87 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/RawBytes.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/RawBytes.hs @@ -85,10 +85,10 @@ roundtrip_raw_bytes asType g = H.tripping v serialiseToRawBytes (deserialiseFromRawBytes asType) roundtrip_verification_key_hash_raw -#if __GLASGOW_HASKELL__ < 906 +#if __GLASGOW_HASKELL__ < 902 :: (Key keyrole, Eq (Hash keyrole), Show (Hash keyrole)) #else - -- GHC 9.6 needs an extra constraint. + -- GHC 9.2 and above needs an extra constraint. :: (Key keyrole, Eq (Hash keyrole), Show (Hash keyrole), HasTypeProxy keyrole) #endif => AsType keyrole -> Property