diff --git a/shelley-ma/impl/src/Cardano/Ledger/ShelleyMA/Metadata.hs b/shelley-ma/impl/src/Cardano/Ledger/ShelleyMA/Metadata.hs index 8b471128df3..8578ce4ef28 100644 --- a/shelley-ma/impl/src/Cardano/Ledger/ShelleyMA/Metadata.hs +++ b/shelley-ma/impl/src/Cardano/Ledger/ShelleyMA/Metadata.hs @@ -38,6 +38,7 @@ import Data.Typeable (Typeable) import Data.Word (Word64) import GHC.Generics (Generic) import NoThunks.Class +import Shelley.Spec.Ledger.Serialization (mapFromCBOR, mapToCBOR) import Shelley.Spec.Ledger.MetaData ( MetaDataHash (..), MetaDatum, @@ -124,7 +125,7 @@ encMetadataRaw :: Encode ( 'Closed 'Dense) (MetadataRaw era) encMetadataRaw (MetadataRaw blob sp) = Rec MetadataRaw - !> To blob + !> E mapToCBOR blob !> E encodeFoldable sp instance @@ -136,13 +137,13 @@ instance TypeMapLen -> decode ( Ann (Emit MetadataRaw) - <*! Ann From + <*! Ann (D mapFromCBOR) <*! Ann (Emit StrictSeq.empty) ) TypeListLen -> decode - ( Ann (RecD MetadataRaw) - <*! Ann From + ( Ann (RecD MetadataRaw) -- i think this is SparseKeyed rather than RecD. should look like the decoder for TxBody + <*! Ann (D mapFromCBOR) <*! D (sequence <$> decodeStrictSeq fromCBOR) ) _ -> error "Failed to decode Metadata" diff --git a/shelley-ma/shelley-ma-test/src/Test/Cardano/Ledger/ShelleyMA/Serialisation/CDDL.hs b/shelley-ma/shelley-ma-test/src/Test/Cardano/Ledger/ShelleyMA/Serialisation/CDDL.hs index b7ef3c34922..6fa6db512ae 100644 --- a/shelley-ma/shelley-ma-test/src/Test/Cardano/Ledger/ShelleyMA/Serialisation/CDDL.hs +++ b/shelley-ma/shelley-ma-test/src/Test/Cardano/Ledger/ShelleyMA/Serialisation/CDDL.hs @@ -9,7 +9,6 @@ where import Cardano.Ledger.Allegra (AllegraEra) import qualified Cardano.Ledger.Core as Core import Cardano.Ledger.Mary (MaryEra) -import Cardano.Ledger.Shelley (ShelleyEra) import qualified Data.ByteString.Lazy as BSL import Test.Shelley.Spec.Ledger.ConcreteCryptoTypes (C_Crypto) import Test.Shelley.Spec.Ledger.Serialisation.CDDLUtils @@ -18,8 +17,6 @@ import Test.Shelley.Spec.Ledger.Serialisation.CDDLUtils ) import Test.Tasty (TestTree, testGroup, withResource) -type S = ShelleyEra C_Crypto - type A = AllegraEra C_Crypto type M = MaryEra C_Crypto @@ -35,9 +32,8 @@ cddlTests n = withResource combinedCDDL (const (pure ())) $ \cddl -> cddlTest' @(Core.Script A) n "native_script", -- Verify that Shelley-era metadata will validate correctly as MA-era -- metadata - cddlTest' @(Core.Metadata S) n "metadata", - cddlTest' @(Core.Metadata M) n "metadata", - cddlTest' @(Core.Metadata A) n "metadata" + cddlTest' @(Core.Metadata M) n "transaction_metadata", + cddlTest' @(Core.Metadata A) n "transaction_metadata" ] <*> pure cddl