File tree Expand file tree Collapse file tree
libs/cardano-ledger-canonical-state/src/Cardano/Ledger/CanonicalState Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -121,6 +121,19 @@ instance FromCanonicalCBOR v CanonicalCoin where
121121instance ToCanonicalCBOR v CanonicalCoin where
122122 toCanonicalCBOR v (CanonicalCoin (CompactCoin c)) = toCanonicalCBOR v c
123123
124+ instance ToCanonicalCBOR v a => ToCanonicalCBOR v (Maybe a ) where
125+ toCanonicalCBOR v Nothing = toCanonicalCBOR v ()
126+ toCanonicalCBOR v (Just x) = toCanonicalCBOR v x
127+
128+ instance FromCanonicalCBOR v a => FromCanonicalCBOR v (Maybe a ) where
129+ fromCanonicalCBOR = do
130+ mt <- peekTokenType
131+ case mt of
132+ D. TypeNull -> do
133+ Versioned () <- fromCanonicalCBOR
134+ pure (Versioned Nothing )
135+ _ -> fmap Just <$> fromCanonicalCBOR
136+
124137instance ToCanonicalCBOR v a => ToCanonicalCBOR v (StrictMaybe a ) where
125138 toCanonicalCBOR v SNothing = toCanonicalCBOR v ()
126139 toCanonicalCBOR v (SJust x) = toCanonicalCBOR v x
You can’t perform that action at this time.
0 commit comments