diff --git a/eras/mary/impl/src/Cardano/Ledger/Mary/Value.hs b/eras/mary/impl/src/Cardano/Ledger/Mary/Value.hs index 2c4f737eeea..00449b98267 100644 --- a/eras/mary/impl/src/Cardano/Ledger/Mary/Value.hs +++ b/eras/mary/impl/src/Cardano/Ledger/Mary/Value.hs @@ -135,14 +135,27 @@ instance DecCBOR AssetName where -- | Policy ID newtype PolicyID c = PolicyID {policyID :: ScriptHash c} - deriving (Show, Eq, EncCBOR, DecCBOR, Ord, NoThunks, NFData, Generic) + deriving + ( Show + , Eq + , Ord + , Generic + , NoThunks + , NFData + , EncCBOR + , DecCBOR + , ToJSON + , FromJSON + , ToJSONKey + , FromJSONKey + ) -- | The MultiAssets map newtype MultiAsset c = MultiAsset (Map (PolicyID c) (Map AssetName Integer)) deriving (Show, Generic, ToJSON) instance Crypto c => Eq (MultiAsset c) where - (MultiAsset x) == (MultiAsset y) = pointWise (pointWise (==)) x y + MultiAsset x == MultiAsset y = pointWise (pointWise (==)) x y instance NFData (MultiAsset cypto) where rnf (MultiAsset m) = rnf m @@ -150,8 +163,8 @@ instance NFData (MultiAsset cypto) where instance NoThunks (MultiAsset c) instance Semigroup (MultiAsset c) where - (MultiAsset m) <> (MultiAsset m1) = - MultiAsset (canonicalMapUnion (canonicalMapUnion (+)) m m1) + MultiAsset m1 <> MultiAsset m2 = + MultiAsset (canonicalMapUnion (canonicalMapUnion (+)) m1 m2) instance Monoid (MultiAsset c) where mempty = MultiAsset mempty @@ -179,8 +192,8 @@ instance NFData (MaryValue c) where instance NoThunks (MaryValue c) instance Semigroup (MaryValue c) where - MaryValue c m <> MaryValue c1 m1 = - MaryValue (c + c1) (m <> m1) + MaryValue c1 m1 <> MaryValue c2 m2 = + MaryValue (c1 + c2) (m1 <> m2) instance Monoid (MaryValue c) where mempty = MaryValue 0 mempty @@ -398,14 +411,6 @@ instance ToJSON AssetName where instance ToJSONKey AssetName where toJSONKey = toJSONKeyText assetNameToTextAsHex -instance ToJSON (PolicyID era) where - toJSON (PolicyID (ScriptHash h)) = Aeson.String (Hash.hashToTextAsHex h) - -instance ToJSONKey (PolicyID era) where - toJSONKey = toJSONKeyText render - where - render (PolicyID (ScriptHash h)) = Hash.hashToTextAsHex h - -- ======================================================================== -- Compactible -- This is used in the TxOut which stores the (CompactForm MaryValue). diff --git a/eras/shelley/impl/CHANGELOG.md b/eras/shelley/impl/CHANGELOG.md index ac907e312b1..9b287aa83c5 100644 --- a/eras/shelley/impl/CHANGELOG.md +++ b/eras/shelley/impl/CHANGELOG.md @@ -27,6 +27,7 @@ * `AccountState`, `EpochState`, `UTxOState`, `IncrementalStake` and `LedgerState` * `Likelihood` and `NonMyopic` * `RewardUpdate` and `PulsingRewUpdate` +* Added of `ToJSON`/`FromJSON` instances for `LogWeight` ### `testlib`